Skip to content

Commit 0271d8d

Browse files
committed
Address nits and performance issues
1 parent 10d7dc9 commit 0271d8d

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3834,25 +3834,20 @@ static Constant *ConstantFoldFixedVectorCall(
38343834
assert(NumElements == 8 && Result.size() == 4 &&
38353835
"wasm dot takes i16x8 and produces i32x4");
38363836
assert(Ty->isIntegerTy());
3837-
SmallVector<APInt, 8> MulVector;
3837+
int32_t MulVector[8];
38383838

38393839
for (unsigned I = 0; I < NumElements; ++I) {
38403840
ConstantInt *Elt0 =
38413841
cast<ConstantInt>(Operands[0]->getAggregateElement(I));
38423842
ConstantInt *Elt1 =
38433843
cast<ConstantInt>(Operands[1]->getAggregateElement(I));
38443844

3845-
// sext 32 first, according to specs
38463845
APInt IMul = Elt0->getValue().sext(32) * Elt1->getValue().sext(32);
38473846

3848-
// Multiplication can never be more than 32 bit.
3849-
// We can opt to not perform modulo of imul here.
3850-
MulVector.push_back(IMul);
3847+
MulVector[I] = IMul.getSExtValue();
38513848
}
38523849
for (unsigned I = 0; I < Result.size(); I++) {
3853-
// Addition can never be more than 32 bit.
3854-
// We can opt to not perform modulo of iadd here.
3855-
APInt IAdd = MulVector[I * 2] + MulVector[I * 2 + 1];
3850+
int32_t IAdd = MulVector[I * 2] + MulVector[I * 2 + 1];
38563851
Result[I] = ConstantInt::get(Ty, IAdd);
38573852
}
38583853

0 commit comments

Comments
 (0)