[PATCH] D139408: [InstCombine] Fold logic-and/logic-or by distributive laws
chenglin.bi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 8 06:15:48 PST 2022
bcl5980 added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:2695
+ (CondVal->hasOneUse() || FalseVal->hasOneUse())) {
+ bool CondLogicAnd = isa<SelectInst>(CondVal);
+ bool FalseLogicAnd = isa<SelectInst>(FalseVal);
----------------
RKSimon wrote:
> lebedev.ri wrote:
> > RKSimon wrote:
> > > Sorry if I've missed something (looooong day) - but how can this match as a SelectInst if its already matched as m_LogicalAnd above?
> > ```
> > /// Matches L && R either in the form of L & R or L ? R : false.
> > /// Note that the latter form is poison-blocking.
> > template <typename LHS, typename RHS>
> > inline LogicalOp_match<LHS, RHS, Instruction::And> m_LogicalAnd(const LHS &L,
> > const RHS &R) {
> > return LogicalOp_match<LHS, RHS, Instruction::And>(L, R);
> > }
> >
> > /// Matches L && R where L and R are arbitrary values.
> > inline auto m_LogicalAnd() { return m_LogicalAnd(m_Value(), m_Value()); }
> >
> > ```
> Cheers - so what do we gain from matching with m_LogicalAnd first and then checking isa<SelectInst> ?
Hi @RKSimon , this should be first part of this change. Later I will send two folllow up patch for the case like:
and + and + select, and + select + select.
So check the m_LogicalAnd first is necessary.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139408/new/
https://reviews.llvm.org/D139408
More information about the llvm-commits
mailing list