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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 17 07:56:53 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4588
+    Value *Y;
+    // select(X | Y == 0, X or Y, X | Y) -> X | Y
+    if (match(CondVal, m_ICmp(Pred, m_Specific(FalseVal), m_Zero())) &&
----------------
HerrCai0907 wrote:
> goldstein.w.n wrote:
> > You could also do:
> > `select(X | Y == X, X, X | Y)` -> `X | Y`
> > and
> > `select (X|Y == Y, Y, X|Y)` -> `X|Y`
> > https://alive2.llvm.org/ce/z/hawAog
> I think it can be done in next patch
We already handle this case using generic select equivalence replacement. The only reason we need this patch is that the select replacement needs to follow the implication `X | Y == 0 => X == 0`. (We could generalize the generic code to do that, but I'm fine with keeping it as a special case for now.)


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