[llvm] [InstCombine] Fold `select Cond, not X, X` into `Cond ^ X` (PR #93591)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 11:38:30 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))))
----------------
goldsteinn wrote:
This is outstanding. Otherwise basically lgtm
https://github.com/llvm/llvm-project/pull/93591
More information about the llvm-commits
mailing list