[llvm] [LV] Add -predicated-epilogue option for tail-folded epilogue (PR #190697)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 03:46:14 PDT 2026


================
@@ -8555,6 +8571,8 @@ static ScalarEpilogueLowering getScalarEpilogueLowering(
       return CM_ScalarEpilogueNotNeededUsePredicate;
     case PreferPredicateTy::PredicateOrDontVectorize:
       return CM_ScalarEpilogueNotAllowedUsePredicate;
+    default:
+      break;
----------------
david-arm wrote:

OK I understand that the goal is probably to have a separate cost model for each of the predicated and unpredicated versions of the loop. However, I still worry about the consequences of pretending that the main vector loop will have a scalar tail. I'd like to take a look at all the places where we check for CM_ScalarEpilogueAllowed and see if there are potential incorrect assumptions being made. Even if it's safe, it's still quite confusing.

With the new flag being added I understand one of two things could happen:
1. We may use a tail-folded vector epilogue if legal to do so and the cost model thinks it's beneficial, or
2. We may fall back on a scalar epilogue.

So it's actually closer to CM_ScalarEpilogueNotNeededUsePredicate, although in this case the tail-folding takes place in the epilogue.

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


More information about the llvm-commits mailing list