[llvm] [VPlan] Add simple driver option to run some individual transforms. (PR #178522)
Andrei Elovikov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 30 12:50:26 PST 2026
eas wrote:
Can you envision that `vplan-test` pass would not need to depend on a loop? Something that would enable
```llvm
define void @diamond_phi(ptr %a) {
; CHECK-LABEL: 'diamond_phi'
; CHECK-NEXT: VPlan 'VPlan for diamond_phi for UF={1}' {
; CHECK-EMPTY:
; CHECK-NEXT: bb0:
; CHECK-NEXT: EMIT ir<%lane> = call ir<@llvm.vplan.test.lane>
; CHECK-NEXT: EMIT ir<%gep> = getelementptr ir<%a>, ir<%lane>
; CHECK-NEXT: EMIT ir<%c0> = icmp sle ir<%lane>, ir<0>
; CHECK-NEXT: Successor(s): bb2
; CHECK-EMPTY:
; CHECK-NEXT: bb2:
; CHECK-NEXT: EMIT [[VP1:vp<%.*>]] = not ir<%c0>
; Relies on a PR to make mask explicit in VPInstructions right in the predicator:
; CHECK-NEXT: EMIT ir<%add2> = add ir<%lane>, ir<2>, [[VP1]]
; CHECK-NEXT: Successor(s): bb1
; CHECK-EMPTY:
; CHECK-NEXT: bb1:
; CHECK-NEXT: EMIT ir<%add1> = add ir<%lane>, ir<1>, ir<%c0>
; CHECK-NEXT: Successor(s): bb4
; CHECK-EMPTY:
; CHECK-NEXT: bb4:
; CHECK-NEXT: EMIT [[VP2:vp<%.*>]] = or [[VP1]], ir<%c0>
; CHECK-NEXT: BLEND ir<%phi4> = ir<%add2> ir<%add1>/ir<%c0>
; CHECK-NEXT: EMIT store ir<%phi4>, ir<%gep>, [[VP2]]
; CHECK-NEXT: EMIT ret [[VP2]]
; CHECK-NEXT: No successors
; CHECK-NEXT: }
; CHECK-EMPTY:
;
bb0:
; bb0
; / \
; bb1 bb2
; \ /
; bb4
; TODO: bb4 should be unmasked.
%lane = call i64 @llvm.vplan.test.lane()
%gep = getelementptr i64, ptr %a, i64 %lane
%c0 = icmp sle i64 %lane, 0
br i1 %c0, label %bb1, label %bb2
bb1:
%add1 = add i64 %lane, 1
br label %bb4
bb2:
%add2 = add i64 %lane, 2
br label %bb4
bb4:
%phi4 = phi i64 [%add1, %bb1], [%add2, %bb2]
store i64 %phi4, ptr %gep
ret void
}
```
Another thing that might be useful is explicit creation of various VP recipes so that we could test later passes (in pipeline) without relying on other transforms. Something along the lines of
```llvm
declare i32 @vplan.vf.i32()
declare i32 @vplan.reduction.start.i32(i32, i32, i32)
declare i32 @vplan.canonical.iv.i32()
...
define @test() {
entry:
%red.init = call i32 @vplan.reduction.start(i32 0, i32 0, i32 1)
br label %header
header:
%red.phi = phi i32 [ %red.init, %entry ], [ %red.next, %header ]
;; Parsed into a VPValue owned by the region, as per one of your open PRs
%canonical.iv = call i32 @vplan.canonical.iv()
...
exit:
%red.final = call i32 @vplan.compute.reduction.result(i32 %red.next)
}
```
```
opt -p vplan-test<create-loop-region,parse-explicit-recipes,transform-to-partial-reduction> < %s
```
https://github.com/llvm/llvm-project/pull/178522
More information about the llvm-commits
mailing list