[llvm] r375153 - [NFC][InstCombine] Some more preparatory cleanup for dropRedundantMaskingOfLeftShiftInput()

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 17 11:30:03 PDT 2019


Author: lebedevri
Date: Thu Oct 17 11:30:03 2019
New Revision: 375153

URL: http://llvm.org/viewvc/llvm-project?rev=375153&view=rev
Log:
[NFC][InstCombine] Some more preparatory cleanup for dropRedundantMaskingOfLeftShiftInput()

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp?rev=375153&r1=375152&r2=375153&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp Thu Oct 17 11:30:03 2019
@@ -158,8 +158,8 @@ dropRedundantMaskingOfLeftShiftInput(Bin
   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(Bin
   }
 
   // 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;




More information about the llvm-commits mailing list