[PATCH] D139408: [InstCombine] Fold logic-and/logic-or by distributive laws

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 05:58:27 PST 2022


lebedev.ri 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:
> 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()); }

```


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

https://reviews.llvm.org/D139408



More information about the llvm-commits mailing list