[clang-tools-extra] [InstCombine] Simplify the pattern `a ne/eq (zext (a ne/eq c))` (PR #65852)

Yingwei Zheng via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 18 10:28:48 PDT 2023


================
@@ -6380,7 +6380,56 @@ Instruction *InstCombinerImpl::foldICmpUsingBoolRange(ICmpInst &I) {
       Y->getType()->isIntOrIntVectorTy(1) && Pred == ICmpInst::ICMP_ULE)
     return BinaryOperator::CreateOr(Builder.CreateIsNull(X), Y);
 
+  ICmpInst::Predicate Pred1, Pred2;
   const APInt *C;
+  // icmp eq/ne X, (zext (icmp eq/ne X, C))
+  if (match(&I, m_c_ICmp(Pred1, m_Value(X),
+                         m_ZExt(m_ICmp(Pred2, m_Deferred(X), m_APInt(C))))) &&
----------------
dtcxzyw wrote:

Proof for `sext`: https://alive2.llvm.org/ce/z/tv5wuE

https://github.com/llvm/llvm-project/pull/65852


More information about the cfe-commits mailing list