]> granicus.if.org Git - llvm/commitdiff
[DAGCombine] Don't use getZExtValue() until we know the constant is in range.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 3 Apr 2019 11:00:55 +0000 (11:00 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 3 Apr 2019 11:00:55 +0000 (11:00 +0000)
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

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index e58e83536176be4c89c8270d3d546f3bce0828dc..93d5bce9abf28ffb350704ae68f7c15e00508b4c 100644 (file)
@@ -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;