Skip to content

Commit 67492fa

Browse files
committed
Addresses PR reviews
1 parent 0271d8d commit 67492fa

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3842,9 +3842,7 @@ static Constant *ConstantFoldFixedVectorCall(
38423842
ConstantInt *Elt1 =
38433843
cast<ConstantInt>(Operands[1]->getAggregateElement(I));
38443844

3845-
APInt IMul = Elt0->getValue().sext(32) * Elt1->getValue().sext(32);
3846-
3847-
MulVector[I] = IMul.getSExtValue();
3845+
MulVector[I] = Elt0->getSExtValue() * Elt1->getSExtValue();
38483846
}
38493847
for (unsigned I = 0; I < Result.size(); I++) {
38503848
int32_t IAdd = MulVector[I * 2] + MulVector[I * 2 + 1];

llvm/test/Transforms/InstSimplify/ConstProp/WebAssembly/dot.ll

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ define <4 x i32> @dot_doubly_negative() {
3636
ret <4 x i32> %res
3737
}
3838

39-
; This test checks for llvm's compliance on spec's wasm.dot's imul and iadd
40-
; Since the original number can only be i16::max == 2^15 - 1,
41-
; subsequent modulo of 2^32 of imul and iadd
42-
; should return the same result
43-
; 2*(2^15 - 1)^2 % 2^32 == 2*(2^15 - 1)^2
39+
; Tests that i16 max signed values fit in i32
4440
define <4 x i32> @dot_follow_modulo_spec_1() {
4541
; CHECK-LABEL: define <4 x i32> @dot_follow_modulo_spec_1() {
4642
; CHECK-NEXT: ret <4 x i32> <i32 2147352578, i32 0, i32 0, i32 0>
@@ -49,9 +45,7 @@ define <4 x i32> @dot_follow_modulo_spec_1() {
4945
ret <4 x i32> %res
5046
}
5147

52-
; This test checks for llvm's compliance on spec's wasm.dot's imul and iadd
53-
; 2*(- 2^15)^2 == 2^31, doesn't exceed 2^32 so we don't have to mod
54-
; wrapping around is -(2^31), still doesn't exceed 2^32
48+
; Tests that i16 min signed values fit in i32
5549
define <4 x i32> @dot_follow_modulo_spec_2() {
5650
; CHECK-LABEL: define <4 x i32> @dot_follow_modulo_spec_2() {
5751
; CHECK-NEXT: ret <4 x i32> <i32 -2147483648, i32 0, i32 0, i32 0>

0 commit comments

Comments
 (0)