Skip to content

Commit

Permalink
The shuf behavior is 3c5000 only
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Dec 12, 2023
1 parent 98b3d76 commit 661f5a1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion code/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SRCS=$(wildcard *.cpp)
HDRS=$(wildcard *.h)
EXES=$(patsubst %.cpp,%,$(SRCS))
CXX?=g++

all: $(EXES)

Expand All @@ -11,4 +12,4 @@ clean:
rm -rf $(EXES)

%: %.cpp $(HDRS)
g++ $< -mlsx -mlasx -o $@
$(CXX) $< -mlsx -mlasx -o $@
4 changes: 4 additions & 0 deletions code/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ typedef uint32_t u32;
typedef int64_t s64;
typedef uint64_t u64;

#ifndef MACHINE_3C5000
#define MACHINE_3C5000 0
#endif

union v128 {
__m128i m128i;
__m128 m128;
Expand Down
4 changes: 2 additions & 2 deletions code/vshuf_b.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
for (int i = 0; i < 16; i++) {
if (c.byte[i] >= 64) {
// Caveat: observed in 3C5000, but not in QEMU
if (c.byte[i] >= 64 && MACHINE_3C5000) {
// Caveat: observed in 3C5000
dst.byte[i] = 0;
} else if ((c.byte[i] % 32) < 16) {
dst.byte[i] = b.byte[c.byte[i] % 16];
Expand Down
4 changes: 2 additions & 2 deletions code/vshuf_d.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
for (int i = 0; i < 2; i++) {
if ((a.dword[i] % 256) >= 64) {
// Caveat: observed in 3C5000, but not in QEMU
if ((a.dword[i] % 256) >= 64 && MACHINE_3C5000) {
// Caveat: observed in 3C5000
dst.dword[i] = 0;
} else if ((a.dword[i] % 4) < 2) {
dst.dword[i] = c.dword[a.dword[i] % 2];
Expand Down
4 changes: 2 additions & 2 deletions code/vshuf_h.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
for (int i = 0; i < 8; i++) {
if ((a.half[i] % 256) >= 64) {
// Caveat: observed in 3C5000, but not in QEMU
if ((a.half[i] % 256) >= 64 && MACHINE_3C5000) {
// Caveat: observed in 3C5000
dst.half[i] = 0;
} else if ((a.half[i] % 16) < 8) {
dst.half[i] = c.half[a.half[i] % 8];
Expand Down
4 changes: 2 additions & 2 deletions code/vshuf_w.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
for (int i = 0; i < 4; i++) {
if ((a.word[i] % 256) >= 64) {
// Caveat: observed in 3C5000, but not in QEMU
if ((a.word[i] % 256) >= 64 && MACHINE_3C5000) {
// Caveat: observed in 3C5000
dst.word[i] = 0;
} else if ((a.word[i] % 8) < 4) {
dst.word[i] = c.word[a.word[i] % 4];
Expand Down

0 comments on commit 661f5a1

Please sign in to comment.