[llvm] [InstCombine] Fold `select Cond, not X, X` into `Cond ^ X` (PR #93591)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 4 02:52:53 PDT 2024
================
@@ -3502,6 +3502,34 @@ static bool matchFMulByZeroIfResultEqZero(InstCombinerImpl &IC, Value *Cmp0,
return false;
}
+/// Return true iff:
+/// 1. X is poison implies Y is poison.
+/// 2. X is true implies Y is false.
+/// 3. X is false implies Y is true.
+/// Otherwise, return false.
+static bool isKnownInversion(Value *X, Value *Y) {
+ // Handle X = icmp pred V, C1, Y = icmp pred V, C2.
+ Value *V;
+ Constant *C1, *C2;
+ ICmpInst::Predicate Pred1, Pred2;
+ if (!match(X, m_ICmp(Pred1, m_Value(V), m_Constant(C1))) ||
+ !match(Y, m_ICmp(Pred2, m_Specific(V), m_Constant(C2))))
----------------
dtcxzyw wrote:
> The two constants could be any value type. Wouldn't really req any change as you have the APInt check later on.
`m_Specific(V)` implies the types of C1 and C2 are the same.
https://github.com/llvm/llvm-project/pull/93591
More information about the llvm-commits
mailing list