[PATCH] D148275: [InstCombine] support fold select(X|Y,X|Y,X) to X|Y

chenglin.bi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 13 19:55:41 PDT 2023


bcl5980 added a comment.

We can extend it to and also:
; X & Y == -1 ? X : X & Y --> X & Y
And please try to attach or pattern's alive2 proof like this:
https://alive2.llvm.org/ce/z/c2MBGy



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:3585
+  Value *Y;
+  if (match(CondVal, m_ICmp(Pred, m_Specific(FalseVal), m_Zero())) &&
+      match(FalseVal, m_Or(m_Value(X), m_Value(Y))) &&
----------------
If the cmp LHS is FalseVal, pred should be ne here.
If the cmp LHS is TrueVal, pred should be eq I guess.



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:3587
+      match(FalseVal, m_Or(m_Value(X), m_Value(Y))) &&
+      (match(TrueVal, m_Specific(X)) || match(TrueVal, m_Specific(Y))))
+    return replaceInstUsesWith(SI, FalseVal);
----------------
TrueVal == X || TrueVal == Y?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148275



More information about the llvm-commits mailing list