@@ -749,18 +749,18 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
749749 }
750750
751751 Constant *C;
752- if (match (Src, m_OneUse (m_LShr (m_Value (X), m_Constant (C))))) {
752+ if (match (Src, m_OneUse (m_LShr (m_Value (X), m_ImmConstant (C))))) {
753753 // trunc (lshr X, C) to i1 --> icmp ne (and X, C'), 0
754754 Constant *One = ConstantInt::get (SrcTy, APInt (SrcWidth, 1 ));
755- Constant *MaskC = ConstantExpr::getShl (One, C);
755+ Value *MaskC = Builder. CreateShl (One, C);
756756 Value *And = Builder.CreateAnd (X, MaskC);
757757 return new ICmpInst (ICmpInst::ICMP_NE, And, Zero);
758758 }
759759 if (match (Src, m_OneUse (m_c_Or (m_LShr (m_Value (X), m_ImmConstant (C)),
760760 m_Deferred (X))))) {
761761 // trunc (or (lshr X, C), X) to i1 --> icmp ne (and X, C'), 0
762762 Constant *One = ConstantInt::get (SrcTy, APInt (SrcWidth, 1 ));
763- Constant *MaskC = ConstantExpr::getShl (One, C);
763+ Value *MaskC = Builder. CreateShl (One, C);
764764 Value *And = Builder.CreateAnd (X, Builder.CreateOr (MaskC, One));
765765 return new ICmpInst (ICmpInst::ICMP_NE, And, Zero);
766766 }
0 commit comments