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-Tag: llvmorg-10-init~8595 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02599de2e1e9688ed74e2d1080c4e4f73c6072af;p=platform%2Fupstream%2Fllvm.git [DAGCombine] Don't use getZExtValue() until we know the constant is in range. Noticed during prep for a patch for PR40758. llvm-svn: 357571 --- diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index e58e835..93d5bce 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/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;