@@ -977,26 +977,23 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
977977 // trunc ( OP i8 C1, V1) to i1 -> icmp eq V1, log_2(C1) iff C1 is power of 2
978978 if (DestWidth == 1 && match (Src, m_Shr (m_Power2 (C1), m_Value (V1)))) {
979979 Value *Right = ConstantInt::get (V1->getType (), C1->countr_zero ());
980- Value *Icmp = Builder.CreateICmpEQ (V1, Right);
981- return replaceInstUsesWith (Trunc, Icmp);
980+ return new ICmpInst (ICmpInst::ICMP_EQ, V1, Right);
982981 }
983982
984983 // OP = { lshr, ashr }
985984 // trunc ( OP i8 C1, V1) to i1 -> icmp ult V1, log_2(C1 + 1) iff (C1 + 1) is
986985 // power of 2
987986 if (DestWidth == 1 && match (Src, m_Shr (m_LowBitMask (C1), m_Value (V1)))) {
988987 Value *Right = ConstantInt::get (V1->getType (), C1->countr_one ());
989- Value *Icmp = Builder.CreateICmpULT (V1, Right);
990- return replaceInstUsesWith (Trunc, Icmp);
988+ return new ICmpInst (ICmpInst::ICMP_ULT, V1, Right);
991989 }
992990
993991 // OP = { lshr, ashr }
994992 // trunc ( OP i8 C1, V1) to i1 -> icmp ugt V1, cttz(C1) - 1 iff (C1) is
995993 // negative power of 2
996994 if (DestWidth == 1 && match (Src, m_Shr (m_NegatedPower2 (C1), m_Value (V1)))) {
997995 Value *Right = ConstantInt::get (V1->getType (), C1->countr_zero ());
998- Value *Icmp = Builder.CreateICmpUGE (V1, Right);
999- return replaceInstUsesWith (Trunc, Icmp);
996+ return new ICmpInst (ICmpInst::ICMP_UGE, V1, Right);
1000997 }
1001998
1002999 return Changed ? &Trunc : nullptr ;
0 commit comments