@@ -620,8 +620,10 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
620
620
if (DemandedMask.countr_zero () >= ShiftAmt &&
621
621
match (I->getOperand (0 ), m_LShr (m_ImmConstant (C), m_Value (X)))) {
622
622
Constant *LeftShiftAmtC = ConstantInt::get (VTy, ShiftAmt);
623
- Constant *NewC = ConstantExpr::getShl (C, LeftShiftAmtC);
624
- if (ConstantExpr::getLShr (NewC, LeftShiftAmtC) == C) {
623
+ Constant *NewC = ConstantFoldBinaryOpOperands (Instruction::Shl, C,
624
+ LeftShiftAmtC, DL);
625
+ if (ConstantFoldBinaryOpOperands (Instruction::LShr, NewC, LeftShiftAmtC,
626
+ DL) == C) {
625
627
Instruction *Lshr = BinaryOperator::CreateLShr (NewC, X);
626
628
return InsertNewInstWith (Lshr, I->getIterator ());
627
629
}
@@ -684,8 +686,10 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
684
686
Constant *C;
685
687
if (match (I->getOperand (0 ), m_Shl (m_ImmConstant (C), m_Value (X)))) {
686
688
Constant *RightShiftAmtC = ConstantInt::get (VTy, ShiftAmt);
687
- Constant *NewC = ConstantExpr::getLShr (C, RightShiftAmtC);
688
- if (ConstantExpr::getShl (NewC, RightShiftAmtC) == C) {
689
+ Constant *NewC = ConstantFoldBinaryOpOperands (Instruction::LShr, C,
690
+ RightShiftAmtC, DL);
691
+ if (ConstantFoldBinaryOpOperands (Instruction::Shl, NewC,
692
+ RightShiftAmtC, DL) == C) {
689
693
Instruction *Shl = BinaryOperator::CreateShl (NewC, X);
690
694
return InsertNewInstWith (Shl, I->getIterator ());
691
695
}
0 commit comments