[PATCH] D64285: [InstCombine] Fold select (icmp sgt x, -1), lshr (X, Y), ashr (X, Y) to ashr (X, Y))
Dávid Bolvanský via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 11 08:50:59 PDT 2019
- Previous message: [PATCH] D64285: [InstCombine] Fold select (icmp sgt x, -1), lshr (X, Y), ashr (X, Y) to ashr (X, Y))
- Next message: [PATCH] D64285: [InstCombine] Fold select (icmp sgt x, -1), lshr (X, Y), ashr (X, Y) to ashr (X, Y))
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.
================
Comment at: lib/Analysis/InstructionSimplify.cpp:92-93
+ match(CmpLHS, m_Specific(X))) {
+ if (!cast<BinaryOperator>(TrueVal)->isExact() &&
+ cast<BinaryOperator>(FalseVal)->isExact())
+ return nullptr;
----------------
lebedev.ri wrote:
> xbolva00 wrote:
> > xbolva00 wrote:
> > > lebedev.ri wrote:
> > > > lebedev.ri wrote:
> > > > > ```
> > > > > /// If either the `ashr` is non-`exact`, or `lshr` is exact too, then we can just return the `ashr` instruction.
> > > > > ```
> > > > > i think it may be less confusing to flip the `if` accordingly.
> > > > Hmm, also, as i've recently seen, `cast<BinaryOperator>` is going to break for constant expressions.
> > > > Let's just do the most obvious thing instead:
> > > > ```
> > > > if (match(TrueVal, m_LShr(m_Value(X), m_Value(Y))) &&
> > > > match(FalseVal, m_AShr(m_Specific(X), m_Specific(Y))) &&
> > > > match(CmpLHS, m_Specific(X)) &&
> > > > (!match(FalseVal, m_Exact()) || match(TrueVal, m_Exact())))
> > > > ```
> > > m_Exact() not exists?
> > m_Exact(m_BinOp()).. okay
> Ugh, right, sorry.
> Though maybe `m_Instruction()`, not `m_BinOp()`; this really asks for `m_Anything()` matcher..
m_Exact(m_Instruction()) - does not work too.
a) use m_Exact(m_Instruction(DummyInst))
b) m_Exact(m_BinOp())
?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64285/new/
https://reviews.llvm.org/D64285
- Previous message: [PATCH] D64285: [InstCombine] Fold select (icmp sgt x, -1), lshr (X, Y), ashr (X, Y) to ashr (X, Y))
- Next message: [PATCH] D64285: [InstCombine] Fold select (icmp sgt x, -1), lshr (X, Y), ashr (X, Y) to ashr (X, Y))
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the llvm-commits
mailing list