[llvm] [LV] Simplify Blend/Select chain for tail folding outer loop reductions (PR #209659)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 23:10:59 PDT 2026


================
@@ -1701,6 +1701,21 @@ static void simplifyRecipe(VPSingleDefRecipe *Def) {
     return;
   }
 
+  // Simplify (select %mask0, (select %mask1, %T, %F), %F) -> (select
+  // (logical-and %mask0, %mask1), %T, %F) This is useful for exit value for
+  // predicated outer loop reductions with tail-folding which will generate a
+  // blend recipe for predication and a select for tail-folding.
+  VPValue *Mask0, *Mask1, *F;
+  if (match(Def, m_SelectLike(m_VPValue(Mask0), m_VPValue(X), m_VPValue(F)))) {
+    VPValue *T;
+    if (match(X, m_SelectLike(m_VPValue(Mask1), m_VPValue(T), m_Specific(F)))) {
----------------
lukel97 wrote:

I think this can be merged into one call to match with `m_Deferred`? Something like `m_SelectLike(m_VPValue, m_SelectLike(m_VPValue, m_VPValue, m_VPValue(F)), m_Deferred(F)))`

https://github.com/llvm/llvm-project/pull/209659


More information about the llvm-commits mailing list