]> granicus.if.org Git - llvm/commitdiff
[NFC][InstCombine] Some more preparatory cleanup for dropRedundantMaskingOfLeftShiftI...
authorRoman Lebedev <lebedev.ri@gmail.com>
Thu, 17 Oct 2019 18:30:03 +0000 (18:30 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Thu, 17 Oct 2019 18:30:03 +0000 (18:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375153 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineShifts.cpp

index 11b7a165d6eebc4a95f9e526ea90c2d42e3031c9..cc0e35e4a9cac09875ddeda7636c2aeb73b53ae7 100644 (file)
@@ -158,8 +158,8 @@ dropRedundantMaskingOfLeftShiftInput(BinaryOperator *OuterShift,
   assert(OuterShift->getOpcode() == Instruction::BinaryOps::Shl &&
          "The input must be 'shl'!");
 
-  Value *Masked = OuterShift->getOperand(0);
-  Value *ShiftShAmt = OuterShift->getOperand(1);
+  Value *Masked, *ShiftShAmt;
+  match(OuterShift, m_Shift(m_Value(Masked), m_Value(ShiftShAmt)));
 
   Type *NarrowestTy = OuterShift->getType();
   Type *WidestTy = Masked->getType();
@@ -252,8 +252,8 @@ dropRedundantMaskingOfLeftShiftInput(BinaryOperator *OuterShift,
   }
 
   // No 'NUW'/'NSW'! We no longer know that we won't shift-out non-0 bits.
-  auto *NewShift =
-      BinaryOperator::Create(OuterShift->getOpcode(), X, ShiftShAmt);
+  auto *NewShift = BinaryOperator::Create(OuterShift->getOpcode(), X,
+                                          OuterShift->getOperand(1));
 
   if (!NeedMask)
     return NewShift;