[llvm] [LV] Consider interleaving & tail-folding when -enable-wide-lane-mask=true (PR #163387)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 16 01:18:09 PDT 2025


================
@@ -6146,8 +6154,11 @@ bool AArch64TTIImpl::preferPredicateOverEpilogue(TailFoldingInfo *TFI) const {
   if (Required == TailFoldingOpts::Disabled)
     Required |= TailFoldingOpts::Simple;
 
-  if (!TailFoldingOptionLoc.satisfies(ST->getSVETailFoldingDefaultOpts(),
-                                      Required))
+  TailFoldingOpts DefaultOpts = ST->getSVETailFoldingDefaultOpts();
----------------
david-arm wrote:

I'm not sure about this behaviour to be honest. Enabling the use of wide lane masks itself doesn't automatically imply that we should tail-fold all simple loops. I see two issues here:

1. I think if we want to go down the route of forcing tail-folding with wide lane masks then whatever flags we use should probably be named more appropriately, i.e. ForceTailFoldingWithWideLaneMasks or something like that.
2. It gives users no option to only enable tail-folding with wide lane masks for reductions, etc. For example, -mllvm -enable-wide-lane-masks -mllvm -sve-tail-folding=reductions will never work.

If you want a way to force simple tail-folding with wide lane masks it might be better to use a target flag that lives in this file. For example, you could add a new option to `-sve-tail-folding`, i.e. something like -sve-tail-folding=simple+widelanemasks. This way also gives you the option of getting more fine-grained testing with just reductions, recurrences, etc.

You could rename the loop vectoriser flag `EnableWideLaneMasks` to `ForceWideLaneMasks` or `UseWideLaneMasks` so that there is still a way to test this for other targets, but it would be off by default. If the flag is off then the target would have another chance to opt in to this based on their preference. I guess you'd also have to change this interface to return an enum rather than a boolean. How about something like 

```
enum PreferredPredicationStyle {
  None,
  PredicatedBody,
  PredicatedBodyWideLaneMasks
};
```

or something like that?

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


More information about the llvm-commits mailing list