[llvm] [VPlan] Simplify (X && Y) || (X && !Y) -> X. (PR #89386)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 13 10:41:03 PDT 2024
================
@@ -192,6 +191,43 @@ using AllBinaryRecipe_match =
BinaryRecipe_match<Op0_t, Op1_t, Opcode, VPWidenRecipe, VPReplicateRecipe,
VPWidenCastRecipe, VPInstruction>;
+template <typename Op0_t, typename Op1_t, unsigned Opcode, bool Commutable,
+ typename... RecipeTys>
+struct LogicalRecipe_match {
+ Op0_t LHS;
+ Op1_t RHS;
+
+ LogicalRecipe_match(Op0_t LHS, Op1_t RHS) : LHS(LHS), RHS(RHS) {}
+
+ bool match(const VPValue *V) {
+ auto *DefR = V->getDefiningRecipe();
+ return DefR && match(DefR);
+ }
+
+ bool match(const VPRecipeBase *R) {
+ if (!detail::MatchRecipeAndOpcode<Opcode, RecipeTys...>::match(R)) {
+ if (!detail::MatchRecipeAndOpcode<Instruction::Select,
+ RecipeTys...>::match(R))
+ return false;
+ if (Opcode == Instruction::And) {
+ if (!m_False().match(R->getOperand(2)))
+ return false;
+ } else if (Opcode == Instruction::Or) {
+ if (!m_True().match(R->getOperand(1)))
+ return false;
----------------
ayalz wrote:
Is this folding of And-with-true and Or-with-false redundancies and inherent part of folding (X&&Y)||(X&&!Y)->X redundancy?
https://github.com/llvm/llvm-project/pull/89386
More information about the llvm-commits
mailing list