Skip to content

Commit 977eeb0

Browse files
committed
[WebAssembly] Fix some UB from ca541aa
1 parent 32e2326 commit 977eeb0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,10 +2055,10 @@ SDValue WebAssemblyTargetLowering::LowerBUILD_VECTOR(SDValue Op,
20552055
auto *Const = dyn_cast<ConstantSDNode>(Lane.getNode());
20562056
int64_t Val = Const ? Const->getSExtValue() : 0;
20572057
uint64_t LaneBits = 128 / Lanes;
2058-
assert((LaneT == MVT::i64 || Val >= -(1 << (LaneBits - 1))) &&
2058+
assert((LaneBits == 64 || Val >= -(1ll << (LaneBits - 1))) &&
20592059
"Unexpected out of bounds negative value");
2060-
if (Const && LaneT != MVT::i64 && Val > (1 << (LaneBits - 1)) - 1) {
2061-
auto NewVal = ((uint64_t)Val % (1u << LaneBits)) - (1u << LaneBits);
2060+
if (Const && LaneBits != 64 && Val > (1ll << (LaneBits - 1)) - 1) {
2061+
auto NewVal = ((uint64_t)Val % (1ll << LaneBits)) - (1ll << LaneBits);
20622062
ConstLanes.push_back(DAG.getConstant(NewVal, SDLoc(Lane), LaneT));
20632063
} else {
20642064
ConstLanes.push_back(Lane);

0 commit comments

Comments
 (0)