[llvm] [InstCombine] Fold `trunc nuw (x xor y) to i1` to `x != y` (PR #90408)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 28 12:03:57 PDT 2024
================
@@ -770,6 +770,13 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
return new ICmpInst(ICmpInst::Predicate::ICMP_EQ, X, Zero);
}
}
+
+ if (Trunc.hasNoUnsignedWrap()) {
+ Value *X, *Y;
+ if (match(Src, m_Xor(m_Value(X), m_Value(Y)))) {
+ return new ICmpInst(ICmpInst::ICMP_NE, X, Y);
+ }
----------------
dtcxzyw wrote:
```suggestion
if (match(Src, m_Xor(m_Value(X), m_Value(Y))))
return new ICmpInst(ICmpInst::ICMP_NE, X, Y);
```
https://github.com/llvm/llvm-project/pull/90408
More information about the llvm-commits
mailing list