Skip to content

Commit 1195b05

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 1195b05

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,14 +1638,8 @@ 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),
1648-
DL, VT, isT, isO);
1641+
return getConstant(APInt(EltVT.getSizeInBits(), Val, /*isSigned=*/false), DL,
1642+
VT, isT, isO);
16491643
}
16501644

16511645
SDValue SelectionDAG::getConstant(const APInt &Val, const SDLoc &DL, EVT VT,

0 commit comments

Comments
 (0)