fix Issue 24283 - [SIMD][CODEGEN] Bad codegen with and not + AVX2 registers (#15921)

This commit is contained in:
Walter Bright 2023-12-19 12:13:54 -08:00 committed by Nicholas Wilson
parent e5d742b92e
commit fb0b964e3c
2 changed files with 33 additions and 6 deletions

View file

@ -1316,8 +1316,8 @@ elem* toElem(Expression e, ref IRState irs)
elem *ez = el_calloc();
ez.Eoper = OPconst;
ez.Ety = e.Ety;
ez.EV.Vcent.lo = 0;
ez.EV.Vcent.hi = 0;
foreach (ref v; ez.EV.Vlong8)
v = 0;
e = el_bin(OPmin, totym(ne.type), ez, e);
break;
}
@ -1355,8 +1355,8 @@ elem* toElem(Expression e, ref IRState irs)
elem *ec = el_calloc();
ec.Eoper = OPconst;
ec.Ety = e1.Ety;
ec.EV.Vcent.lo = ~0L;
ec.EV.Vcent.hi = ~0L;
foreach (ref v; ec.EV.Vlong8)
v = ~0L;
e = el_bin(OPxor, ty, e1, ec);
break;
}
@ -2009,8 +2009,8 @@ elem* toElem(Expression e, ref IRState irs)
elem *ec = el_calloc();
ec.Eoper = OPconst;
ec.Ety = totym(t1);
ec.EV.Vcent.lo = ~0L;
ec.EV.Vcent.hi = ~0L;
foreach (ref v; ec.EV.Vlong8)
v = ~0L;
e = el_bin(OPxor, ec.Ety, ex, ec);
}
else

View file

@ -5,6 +5,7 @@ version (D_SIMD)
{
import core.simd;
import core.stdc.stdio;
import core.stdc.string;
alias TypeTuple(T...) = T;
@ -283,6 +284,31 @@ void testdbl()
/*****************************************/
version (none)//(D_AVX2)
{
// https://issues.dlang.org/show_bug.cgi?id=24283
import core.simd;
import core.stdc.stdio;
void test24283()
{
int8 A = [7, -2, 9, 54654, 7, -2, 9, 54654];
int8 B = [14, 78, 111, -256, 14, 78, 111, -256];
int8 R = (~A) & B;
int[8] correct = [8, 0, 102, -54784, 8, 0, 102, -54784];
//printf("%d %d %d %d %d %d %d %d\n", R[0], R[1], R[2], R[3], R[4], R[5], R[6], R[7]);
assert(R.array == correct);
}
}
else
{
void test24283() { }
}
/*****************************************/
int main()
{
test21474();
@ -300,6 +326,7 @@ int main()
testunscmp();
testflt();
testdbl();
test24283();
return 0;
}