[llvm] [VPlan] Constant-fold ActiveLaneMask intrinsics (PR #208852)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 05:37:46 PDT 2026
================
@@ -1355,6 +1355,34 @@ VPIRValue *vputils::tryToFoldLiveIns(VPSingleDefRecipe &R,
case Instruction::ExtractElement:
assert(!Ops[0]->getType()->isVectorTy() && "Live-ins should be scalar");
return Ops[0];
+ case VPInstruction::ActiveLaneMask:
----------------
fhahn wrote:
I think this case is currently not covered by tests.
Could you add something like the test below? I'd expect this to fold the first part, but not the second.
```
; opt -force-tail-folding-style=data -tail-folding-policy=must-fold-tail -force-vector-width=4
-force-vector-interleave=2
define void @f(ptr noalias %dst, ptr noalias %src) {
entry:
br label %loop
loop:
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
%p = getelementptr inbounds i64, ptr %src, i64 %iv
%l = load i64, ptr %p, align 8
%m = mul i64 %l, 3
%q = getelementptr inbounds i64, ptr %dst, i64 %iv
store i64 %m, ptr %q, align 8
%iv.next = add nuw nsw i64 %iv, 1
%ec = icmp eq i64 %iv.next, 7
br i1 %ec, label %exit, label %loop
exit:
ret void
}
```
https://github.com/llvm/llvm-project/pull/208852
More information about the llvm-commits
mailing list