[llvm] [LV] Split checking if tail-folding is possible, collecting masked ops. (PR #77612)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 8 07:29:16 PDT 2024
================
@@ -1601,8 +1601,24 @@ bool LoopVectorizationLegality::prepareToFoldTailByMasking() {
LLVM_DEBUG(dbgs() << "LV: can fold tail by masking.\n");
- MaskedOp.insert(TmpMaskedOp.begin(), TmpMaskedOp.end());
return true;
}
+void LoopVectorizationLegality::prepareToFoldTailByMasking() {
+ // The list of pointers that we can safely read and write to remains empty.
+ SmallPtrSet<Value *, 8> SafePointers;
+
+ // Collect masked ops in temporary set first to avoid partially populating
+ // MaskedOp if a block cannot be predicated.
+ SmallPtrSet<const Instruction *, 8> TmpMaskedOp;
+
+ // Check and mark all blocks for predication, including those that ordinarily
+ // do not need predication such as the header block.
+ for (BasicBlock *BB : TheLoop->blocks()) {
+ bool R = blockCanBePredicated(BB, SafePointers, MaskedOp);
----------------
fhahn wrote:
Left as is for now for this PR to keep the number of changes small, but will check as follow-up. More generally, we should probably collect and consider safe pointers with tail folding as well
https://github.com/llvm/llvm-project/pull/77612
More information about the llvm-commits
mailing list