Skip to content

Commit 45be4ce

Browse files
committed
[SDAG] Don't allow implicit trunc in getConstant()
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 3699931 commit 45be4ce

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,13 +1638,7 @@ SDValue SelectionDAG::getBoolConstant(bool V, const SDLoc &DL, EVT VT,
16381638
SDValue SelectionDAG::getConstant(uint64_t Val, const SDLoc &DL, EVT VT,
16391639
bool isT, bool isO) {
16401640
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),
1641+
return getConstant(APInt(EltVT.getSizeInBits(), Val, /*isSigned=*/false),
16481642
DL, VT, isT, isO);
16491643
}
16501644

0 commit comments

Comments
 (0)