[llvm] [InstCombine] Fold shift of boolean zext to logic sequence (PR #180596)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 10 06:35:53 PST 2026


================
@@ -7894,6 +7894,27 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
     }
   }
 
+  // icmp eq (shl (zext i1 x), (zext i1 y)), 1 --> and i1 x, (not i1 y)
+  // icmp ne (shl (zext i1 x), (zext i1 y)), 1 --> or i1 (not i1 x), y
+  {
+    Value *A, *B;
+    CmpPredicate CmpPred;
+
+    if (match(&I, m_ICmp(CmpPred, m_Shl(m_ZExt(m_Value(A)), m_ZExt(m_Value(B))),
----------------
dtcxzyw wrote:

Missing one-use check: https://llvm.org/docs/InstCombineContributorGuide.html#multi-use-handling

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


More information about the llvm-commits mailing list