[llvm] [VPlan] Reassociate (x & y) & z -> x & (y & z) (PR #155383)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 2 04:23:41 PDT 2025
================
@@ -1119,6 +1119,15 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
return;
}
+ // Reassociate (x && y) && z -> x && (y && z) if x has multiple users. With
+ // tail folding it is likely that x is a header mask and can be simplified
+ // further.
+ if (match(Def, m_LogicalAnd(m_LogicalAnd(m_VPValue(X), m_VPValue(Y)),
+ m_VPValue(Z))) &&
+ X->hasMoreThanOneUniqueUser())
+ return Def->replaceAllUsesWith(
+ Builder.createLogicalAnd(X, Builder.createLogicalAnd(X, Y)));
----------------
lukel97 wrote:
Fixed in 7661966. I ran this again on SPEC CPU 2017 for RISC-V and there's still the original codegen improvements from the initial version of this PR where we remove the header mask in more places
https://github.com/llvm/llvm-project/pull/155383
More information about the llvm-commits
mailing list