[llvm] [LoopVectorize] Don't scalarize predicated instruction with optsize (PR #129265)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 6 04:02:37 PST 2025
================
@@ -5660,6 +5662,13 @@ LoopVectorizationCostModel::getMemInstScalarizationCost(Instruction *I,
if (VF.isScalable())
return InstructionCost::getInvalid();
+ // Don't scalarize predicated instructions when optimizing for size unless
+ // we're forced to.
+ if (isPredicatedInst(I) && OptForSize &&
+ !ForceTailFoldingStyle.getNumOccurrences() &&
----------------
david-arm wrote:
I think this needs to be
```
!(ForceTailFoldingStyle.getNumOccurrences() && ForceTailFoldingStyle != TailFoldingStyle::None)
```
because otherwise the user could explicitly disable tail-folding for a loop that has control flow (leading to predicated instructions), and we will still scalarise. Or since the default is none anyway, you could also just write
```
ForceTailFoldingStyle != TailFoldingStyle::None &&
```
https://github.com/llvm/llvm-project/pull/129265
More information about the llvm-commits
mailing list