Adding vector add tests and fixing bugs found (still broken).
This commit is contained in:
@@ -2630,7 +2630,7 @@ uint32_t Translate_VECTOR_ADD_I32(IntCodeState& ics, const IntCode* i) {
|
||||
if (arithmetic_flags & ARITHMETIC_SATURATE) {
|
||||
if (arithmetic_flags & ARITHMETIC_UNSIGNED) {
|
||||
for (int n = 0; n < 4; n++) {
|
||||
uint64_t v = VECI4(src1, n) + VECI4(src2, n);
|
||||
uint64_t v = (uint64_t)VECI4(src1, n) + (uint64_t)VECI4(src2, n);
|
||||
if (v > 0xFFFFFFFF) {
|
||||
VECI4(dest, n) = 0xFFFFFFFF;
|
||||
ics.did_saturate = 1;
|
||||
@@ -2640,7 +2640,7 @@ uint32_t Translate_VECTOR_ADD_I32(IntCodeState& ics, const IntCode* i) {
|
||||
}
|
||||
} else {
|
||||
for (int n = 0; n < 4; n++) {
|
||||
int64_t v = (int32_t)VECI4(src1, n) + (int32_t)VECI4(src2, n);
|
||||
int64_t v = (int64_t)(int32_t)VECI4(src1, n) + (int64_t)(int32_t)VECI4(src2, n);
|
||||
if (v > 0x7FFFFFFF) {
|
||||
VECI4(dest, n) = 0x7FFFFFFF;
|
||||
ics.did_saturate = 1;
|
||||
|
||||
@@ -2749,7 +2749,7 @@ EMITTER(VECTOR_ADD, MATCH(I<OPCODE_VECTOR_ADD, V128<>, V128<>, V128<>>)) {
|
||||
e.vblendvps(e.xmm2, e.xmm0, e.GetXmmConstPtr(XMMSignMaskPS), e.xmm2);
|
||||
e.vpor(e.xmm1, src1, src2); // sign_or
|
||||
e.vpandn(e.xmm1, e.xmm0); // max_sat_mask
|
||||
e.vblendvps(e.xmm2, e.GetXmmConstPtr(XMMAbsMaskPS), e.xmm1);
|
||||
e.vblendvps(dest, e.GetXmmConstPtr(XMMAbsMaskPS), e.xmm1);
|
||||
}
|
||||
} else {
|
||||
e.vpaddd(dest, src1, src2);
|
||||
|
||||
@@ -42,6 +42,13 @@ typedef struct alignas(16) vec128_s {
|
||||
return low == b.low && high == b.high;
|
||||
}
|
||||
} vec128_t;
|
||||
static inline vec128_t vec128i(uint32_t src) {
|
||||
vec128_t v;
|
||||
for (auto i = 0; i < 4; ++i) {
|
||||
v.i4[i] = src;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
static inline vec128_t vec128i(uint32_t x, uint32_t y, uint32_t z, uint32_t w) {
|
||||
vec128_t v;
|
||||
v.i4[0] = x;
|
||||
@@ -50,6 +57,13 @@ static inline vec128_t vec128i(uint32_t x, uint32_t y, uint32_t z, uint32_t w) {
|
||||
v.i4[3] = w;
|
||||
return v;
|
||||
}
|
||||
static inline vec128_t vec128f(float src) {
|
||||
vec128_t v;
|
||||
for (auto i = 0; i < 4; ++i) {
|
||||
v.f4[i] = src;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
static inline vec128_t vec128f(float x, float y, float z, float w) {
|
||||
vec128_t v;
|
||||
v.f4[0] = x;
|
||||
|
||||
Reference in New Issue
Block a user