]> granicus.if.org Git - llvm/commitdiff
[InstCombine] Cherry-pick NFC cleanups of foldShiftIntoShiftInAnotherHandOfAndInICmp...
authorRoman Lebedev <lebedev.ri@gmail.com>
Sun, 18 Aug 2019 12:26:33 +0000 (12:26 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sun, 18 Aug 2019 12:26:33 +0000 (12:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369207 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineCompares.cpp

index babbd9df9089cd9bf33546ca3be1d2400e09ebe5..620b5563804a929416d368e4b9a7661c51a8ab94 100644 (file)
@@ -3321,12 +3321,15 @@ foldShiftIntoShiftInAnotherHandOfAndInICmp(ICmpInst &I, const SimplifyQuery SQ,
                                m_Instruction(MaybeTruncation)))))
     return nullptr;
 
-  Instruction *UntruncatedShift = XShift;
-
   // We potentially looked past 'trunc', but only when matching YShift,
   // therefore YShift must have the widest type.
-  Type *WidestTy = YShift->getType();
-  assert(XShift->getType() == I.getOperand(0)->getType() &&
+  Instruction *WidestShift = YShift;
+  // Therefore XShift must have the shallowest type.
+  // Or they both have identical types if there was no truncation.
+  Instruction *NarrowestShift = XShift;
+
+  Type *WidestTy = WidestShift->getType();
+  assert(NarrowestShift->getType() == I.getOperand(0)->getType() &&
          "We did not look past any shifts while matching XShift though.");
   bool HadTrunc = WidestTy != I.getOperand(0)->getType();
 
@@ -3363,7 +3366,7 @@ foldShiftIntoShiftInAnotherHandOfAndInICmp(ICmpInst &I, const SimplifyQuery SQ,
       // Due to the 'trunc', we will need to widen X. For that either the old
       // 'trunc' or the shift amt in the non-truncated shift should be one-use.
       if (!MaybeTruncation->hasOneUse() &&
-          !UntruncatedShift->getOperand(1)->hasOneUse())
+          !NarrowestShift->getOperand(1)->hasOneUse())
         return nullptr;
     }
   }