Skip to content

Commit 436f0c9

Browse files
committed
Simplify blend index calculation
1 parent ec478a1 commit 436f0c9

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,11 +2845,8 @@ static bool interp__builtin_blend(InterpState &S, CodePtr OpPC,
28452845
PrimType ElemT = FalseElem.getFieldDesc()->getPrimType();
28462846
PrimType DstElemT = Dst.getFieldDesc()->getPrimType();
28472847

2848-
auto BitIndex = BuiltinID == X86::BI__builtin_ia32_pblendw256
2849-
? [](unsigned I) { return I % 8; }
2850-
: [](unsigned I) { return I; };
28512848
for (unsigned I = 0; I != NumElems; ++I) {
2852-
bool MaskBit = Mask[BitIndex(I)];
2849+
bool MaskBit = Mask[I % 8];
28532850
if (ElemT == PT_Float) {
28542851
assert(DstElemT == PT_Float);
28552852
Dst.elem<Floating>(I) =

clang/lib/AST/ExprConstant.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11967,13 +11967,10 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1196711967
auto SourceLen = SourceF.getVectorLength();
1196811968
SmallVector<APValue, 32> ResultElements;
1196911969
ResultElements.reserve(SourceLen);
11970-
auto BitIndex = E->getBuiltinCallee() == X86::BI__builtin_ia32_pblendw256
11971-
? [](unsigned I) { return I % 8; }
11972-
: [](unsigned I) { return I; };
1197311970
for (unsigned EltNum = 0; EltNum != SourceLen; ++EltNum) {
1197411971
const APValue &F = SourceF.getVectorElt(EltNum);
1197511972
const APValue &T = SourceT.getVectorElt(EltNum);
11976-
ResultElements.push_back(C[BitIndex(EltNum)] ? T : F);
11973+
ResultElements.push_back(C[EltNum % 8] ? T : F);
1197711974
}
1197811975

1197911976
return Success(APValue(ResultElements.data(), ResultElements.size()), E);

0 commit comments

Comments
 (0)