From: Simon Pilgrim Date: Wed, 3 Apr 2019 11:00:55 +0000 (+0000) Subject: [DAGCombine] Don't use getZExtValue() until we know the constant is in range. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9337d5b41f4348fe8efddbf00cb8bd46d53152bc;p=llvm [DAGCombine] Don't use getZExtValue() until we know the constant is in range. Noticed during prep for a patch for PR40758. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357571 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index e58e8353617..93d5bce9abf 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -6843,8 +6843,8 @@ SDValue DAGCombiner::visitSHL(SDNode *N) { if (N1C && N0.getOpcode() == ISD::SRL && N0.hasOneUse() && TLI.shouldFoldShiftPairToMask(N, Level)) { if (ConstantSDNode *N0C1 = isConstOrConstSplat(N0.getOperand(1))) { - uint64_t c1 = N0C1->getZExtValue(); - if (c1 < OpSizeInBits) { + if (N0C1->getAPIntValue().ult(OpSizeInBits)) { + uint64_t c1 = N0C1->getZExtValue(); uint64_t c2 = N1C->getZExtValue(); APInt Mask = APInt::getHighBitsSet(OpSizeInBits, OpSizeInBits - c1); SDValue Shift;