[PATCH] D122152: [InstCombine] Fold two select patterns into and-or

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 14:52:30 PDT 2022


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:2582-2583
+    // select (~c & b), a, b -> and b, (or a, c)
+    if ((match(CondVal, m_And(m_Not(m_Value(C)), m_Value(FalseVal))) ||
+         match(CondVal, m_And(m_Value(FalseVal), m_Not(m_Value(C))))) &&
+        CondVal->hasOneUse()) {
----------------
Here and above - this is not the correct way to match an existing value. See `m_Specific` or `m_Deferred`.

This could crash or miscompile as written, so we need at least 2 negative tests where there is no repeated value from the select T/F in the condition to make sure the pattern matching is not broken.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122152/new/

https://reviews.llvm.org/D122152



More information about the llvm-commits mailing list