Skip to content

Commit efdd049

Browse files
authored
Revert "Add SIMD to LowerCallMemcmp (#84530)"
This reverts commit eda1c3a.
1 parent f211984 commit efdd049

File tree

2 files changed

+15
-59
lines changed

2 files changed

+15
-59
lines changed

src/coreclr/jit/gentree.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7384,9 +7384,9 @@ GenTree* Compiler::gtNewZeroConNode(var_types type)
73847384
#ifdef FEATURE_SIMD
73857385
if (varTypeIsSIMD(type))
73867386
{
7387-
GenTreeVecCon* vecCon = gtNewVconNode(type);
7388-
vecCon->gtSimdVal = simd_t::Zero();
7389-
return vecCon;
7387+
GenTreeVecCon* allBitsSet = gtNewVconNode(type);
7388+
allBitsSet->gtSimdVal = simd_t::Zero();
7389+
return allBitsSet;
73907390
}
73917391
#endif // FEATURE_SIMD
73927392

src/coreclr/jit/lower.cpp

Lines changed: 12 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,20 +1902,8 @@ GenTree* Lowering::LowerCallMemcmp(GenTreeCall* call)
19021902
{
19031903
GenTree* lArg = call->gtArgs.GetUserArgByIndex(0)->GetNode();
19041904
GenTree* rArg = call->gtArgs.GetUserArgByIndex(1)->GetNode();
1905-
1906-
ssize_t MaxUnrollSize = 16;
1907-
#ifdef FEATURE_SIMD
1908-
MaxUnrollSize = 32;
1909-
#ifdef TARGET_XARCH
1910-
if (comp->compOpportunisticallyDependsOn(InstructionSet_Vector256))
1911-
{
1912-
MaxUnrollSize = 64;
1913-
}
1914-
// TODO-XARCH-AVX512: Consider enabling this for AVX512
1915-
#endif
1916-
#endif
1917-
1918-
if (cnsSize <= MaxUnrollSize)
1905+
// TODO: Add SIMD path for [16..128] via GT_HWINTRINSIC nodes
1906+
if (cnsSize <= 16)
19191907
{
19201908
unsigned loadWidth = 1 << BitOperations::Log2((unsigned)cnsSize);
19211909
var_types loadType;
@@ -1931,25 +1919,11 @@ GenTree* Lowering::LowerCallMemcmp(GenTreeCall* call)
19311919
{
19321920
loadType = TYP_INT;
19331921
}
1934-
else if ((loadWidth == 8) || (MaxUnrollSize == 16))
1922+
else if ((loadWidth == 8) || (loadWidth == 16))
19351923
{
19361924
loadWidth = 8;
19371925
loadType = TYP_LONG;
19381926
}
1939-
#ifdef FEATURE_SIMD
1940-
else if ((loadWidth == 16) || (MaxUnrollSize == 32))
1941-
{
1942-
loadWidth = 16;
1943-
loadType = TYP_SIMD16;
1944-
}
1945-
#ifdef TARGET_XARCH
1946-
else if ((loadWidth == 32) || (MaxUnrollSize == 64))
1947-
{
1948-
loadWidth = 32;
1949-
loadType = TYP_SIMD32;
1950-
}
1951-
#endif // TARGET_XARCH
1952-
#endif // FEATURE_SIMD
19531927
else
19541928
{
19551929
unreached();
@@ -1958,26 +1932,8 @@ GenTree* Lowering::LowerCallMemcmp(GenTreeCall* call)
19581932

19591933
GenTree* result = nullptr;
19601934

1961-
auto newBinaryOp = [](Compiler* comp, genTreeOps oper, var_types type, GenTree* op1,
1962-
GenTree* op2) -> GenTree* {
1963-
#ifdef FEATURE_SIMD
1964-
if (varTypeIsSIMD(op1))
1965-
{
1966-
if (GenTree::OperIsCmpCompare(oper))
1967-
{
1968-
assert(type == TYP_INT);
1969-
return comp->gtNewSimdCmpOpAllNode(oper, TYP_BOOL, op1, op2, CORINFO_TYPE_NATIVEUINT,
1970-
genTypeSize(op1), false);
1971-
}
1972-
return comp->gtNewSimdBinOpNode(oper, op1->TypeGet(), op1, op2, CORINFO_TYPE_NATIVEUINT,
1973-
genTypeSize(op1), false);
1974-
}
1975-
#endif
1976-
return comp->gtNewOperNode(oper, type, op1, op2);
1977-
};
1978-
19791935
// loadWidth == cnsSize means a single load is enough for both args
1980-
if (loadWidth == (unsigned)cnsSize)
1936+
if ((loadWidth == (unsigned)cnsSize) && (loadWidth <= 8))
19811937
{
19821938
// We're going to emit something like the following:
19831939
//
@@ -1987,7 +1943,7 @@ GenTree* Lowering::LowerCallMemcmp(GenTreeCall* call)
19871943
//
19881944
GenTree* lIndir = comp->gtNewIndir(loadType, lArg);
19891945
GenTree* rIndir = comp->gtNewIndir(loadType, rArg);
1990-
result = newBinaryOp(comp, GT_EQ, TYP_INT, lIndir, rIndir);
1946+
result = comp->gtNewOperNode(GT_EQ, TYP_INT, lIndir, rIndir);
19911947

19921948
BlockRange().InsertAfter(lArg, lIndir);
19931949
BlockRange().InsertAfter(rArg, rIndir);
@@ -2034,17 +1990,17 @@ GenTree* Lowering::LowerCallMemcmp(GenTreeCall* call)
20341990
//
20351991
GenTree* l1Indir = comp->gtNewIndir(loadType, lArgUse.Def());
20361992
GenTree* r1Indir = comp->gtNewIndir(loadType, rArgUse.Def());
2037-
GenTree* lXor = newBinaryOp(comp, GT_XOR, actualLoadType, l1Indir, r1Indir);
1993+
GenTree* lXor = comp->gtNewOperNode(GT_XOR, actualLoadType, l1Indir, r1Indir);
20381994
GenTree* l2Offs = comp->gtNewIconNode(cnsSize - loadWidth, TYP_I_IMPL);
2039-
GenTree* l2AddOffs = newBinaryOp(comp, GT_ADD, lArg->TypeGet(), lArgClone, l2Offs);
1995+
GenTree* l2AddOffs = comp->gtNewOperNode(GT_ADD, lArg->TypeGet(), lArgClone, l2Offs);
20401996
GenTree* l2Indir = comp->gtNewIndir(loadType, l2AddOffs);
20411997
GenTree* r2Offs = comp->gtCloneExpr(l2Offs); // offset is the same
2042-
GenTree* r2AddOffs = newBinaryOp(comp, GT_ADD, rArg->TypeGet(), rArgClone, r2Offs);
1998+
GenTree* r2AddOffs = comp->gtNewOperNode(GT_ADD, rArg->TypeGet(), rArgClone, r2Offs);
20431999
GenTree* r2Indir = comp->gtNewIndir(loadType, r2AddOffs);
2044-
GenTree* rXor = newBinaryOp(comp, GT_XOR, actualLoadType, l2Indir, r2Indir);
2045-
GenTree* resultOr = newBinaryOp(comp, GT_OR, actualLoadType, lXor, rXor);
2046-
GenTree* zeroCns = comp->gtNewZeroConNode(actualLoadType);
2047-
result = newBinaryOp(comp, GT_EQ, TYP_INT, resultOr, zeroCns);
2000+
GenTree* rXor = comp->gtNewOperNode(GT_XOR, actualLoadType, l2Indir, r2Indir);
2001+
GenTree* resultOr = comp->gtNewOperNode(GT_OR, actualLoadType, lXor, rXor);
2002+
GenTree* zeroCns = comp->gtNewIconNode(0, actualLoadType);
2003+
result = comp->gtNewOperNode(GT_EQ, TYP_INT, resultOr, zeroCns);
20482004

20492005
BlockRange().InsertAfter(rArgClone, l1Indir, r1Indir, l2Offs, l2AddOffs);
20502006
BlockRange().InsertAfter(l2AddOffs, l2Indir, r2Offs, r2AddOffs, r2Indir);

0 commit comments

Comments
 (0)