[PATCH] D148275: [InstCombine] support fold select(X|Y,X|Y,X) to X|Y
Congcong Cai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 16 23:46:54 PDT 2023
HerrCai0907 marked an inline comment as done.
HerrCai0907 added inline comments.
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4585
+ if (Pred == ICmpInst::Predicate::ICMP_EQ) {
+ Value *X;
----------------
goldstein.w.n wrote:
> Should we also have `select(X|Y != 0, X | Y, X or Y)`?
`ne` will be changed to `eq` in line 4498
================
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())) &&
----------------
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
================
Comment at: llvm/test/Transforms/InstSimplify/select_or_and.ll:11
+ %or = or i32 %y, %x
+ %cmp = icmp eq i32 %or, 0
+ %ret = select i1 %cmp, i32 %x, i32 %or
----------------
goldstein.w.n wrote:
> Can you split the next tests to a prior patch so we can see the diff this patch generates?
before this patch, opt won't do any optimization for this code. Diff between the original code and the checked code is what this patch does.
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