[llvm] [InstCombine] Select of Symmetric Selects (PR #99245)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 17 01:34:28 PDT 2024
================
@@ -3012,6 +3012,28 @@ struct DecomposedSelect {
};
} // namespace
+/// Folds patterns like:
+/// select c2 (select c1 a b) (select c1 b a)
+/// into:
+/// select (xor c1 c2) b a
+static Instruction *
+foldSelectOfSymmetricSelect(SelectInst &OuterSelVal,
+ InstCombiner::BuilderTy &Builder) {
+
+ DecomposedSelect OuterSel, InnerSel;
+ if (!match(&OuterSelVal, m_Select(m_Value(OuterSel.Cond),
+ m_Select(m_Value(InnerSel.Cond),
+ m_Value(InnerSel.TrueVal),
+ m_Value(InnerSel.FalseVal)),
+ m_Select(m_Deferred(InnerSel.Cond),
+ m_Deferred(InnerSel.FalseVal),
+ m_Deferred(InnerSel.TrueVal)))))
----------------
dtcxzyw wrote:
I guess not. See the fuzzy matching results in https://github.com/dtcxzyw/llvm-opt-benchmark/issues/976 and https://github.com/dtcxzyw/llvm-opt-benchmark/issues/977.
https://github.com/llvm/llvm-project/pull/99245
More information about the llvm-commits
mailing list