Skip to content

Commit 3e1b55c

Browse files
authored
[SDAG] Don't allow implicit trunc in getConstant() (#117558)
Assert that the passed value is a valid unsigned integer value for the specified type. For signed values getSignedConstant() / getSignedTargetConstant() should be used instead.
1 parent 2906232 commit 3e1b55c

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,14 +1637,7 @@ SDValue SelectionDAG::getBoolConstant(bool V, const SDLoc &DL, EVT VT,
16371637

16381638
SDValue SelectionDAG::getConstant(uint64_t Val, const SDLoc &DL, EVT VT,
16391639
bool isT, bool isO) {
1640-
EVT EltVT = VT.getScalarType();
1641-
assert((EltVT.getSizeInBits() >= 64 ||
1642-
(uint64_t)((int64_t)Val >> EltVT.getSizeInBits()) + 1 < 2) &&
1643-
"getConstant with a uint64_t value that doesn't fit in the type!");
1644-
// TODO: Avoid implicit trunc?
1645-
// See https://github.com/llvm/llvm-project/issues/112510.
1646-
return getConstant(APInt(EltVT.getSizeInBits(), Val, /*isSigned=*/false,
1647-
/*implicitTrunc=*/true),
1640+
return getConstant(APInt(VT.getScalarSizeInBits(), Val, /*isSigned=*/false),
16481641
DL, VT, isT, isO);
16491642
}
16501643

0 commit comments

Comments
 (0)