-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[VPlan] Also print final VPlan directly before codegen/execute. #82269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d9903b1
[VPlan] Also print final VPlan directly before codegen/execute.
fhahn 7c03e01
Merge remote-tracking branch 'origin/main' into vplan-print-final-plan
fhahn 24edfff
Merge remote-tracking branch 'origin/main' into vplan-print-final-plan
fhahn 68b9983
Merge branch 'main' into vplan-print-final-plan
fhahn 5cf4df4
@fixup move printing Excecuting... to dumping plan.
fhahn 7717d7e
!fixup fix formatting.
fhahn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
llvm/test/Transforms/LoopVectorize/vplan-printing-before-execute.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
; RUN: opt -passes=loop-vectorize -force-vector-width=8 -force-vector-interleave=2 -disable-output -debug -S %s 2>&1 | FileCheck --check-prefixes=CHECK %s | ||
|
||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128" | ||
|
||
; REQUIRES: asserts | ||
|
||
; Check if the vector loop condition can be simplified to true for a given | ||
; VF/IC combination. | ||
define void @test_tc_less_than_16(ptr %A, i64 %N) { | ||
; CHECK: LV: Scalarizing: %cmp = | ||
; CHECK-NEXT: VPlan 'Initial VPlan for VF={8},UF>=1' { | ||
; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF | ||
; CHECK-NEXT: Live-in vp<[[VTC:%.+]]> = vector-trip-count | ||
; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count | ||
; CHECK-EMPTY: | ||
; CHECK-NEXT: ph: | ||
; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (zext i4 (trunc i64 %N to i4) to i64) | ||
; CHECK-NEXT: No successors | ||
; CHECK-EMPTY: | ||
; CHECK-NEXT: vector.ph: | ||
; CHECK-NEXT: Successor(s): vector loop | ||
; CHECK-EMPTY: | ||
; CHECK-NEXT: <x1> vector loop: { | ||
; CHECK-NEXT: vector.body: | ||
; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION ir<0>, vp<[[CAN_IV_NEXT:%.+]]> | ||
; CHECK-NEXT: EMIT ir<%p.src> = WIDEN-POINTER-INDUCTION ir<%A>, 1 | ||
; CHECK-NEXT: vp<[[VPTR:%.]]> = vector-pointer ir<%p.src> | ||
; CHECK-NEXT: WIDEN ir<%l> = load vp<[[VPTR]]> | ||
; CHECK-NEXT: WIDEN ir<%add> = add nsw ir<%l>, ir<10> | ||
; CHECK-NEXT: vp<[[VPTR2:%.+]]> = vector-pointer ir<%p.src> | ||
; CHECK-NEXT: WIDEN store vp<[[VPTR2]]>, ir<%add> | ||
; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT]]> = add nuw vp<[[CAN_IV:%.+]]>, vp<[[VFxUF]]> | ||
; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VTC]]> | ||
; CHECK-NEXT: No successors | ||
; CHECK-NEXT: } | ||
; CHECK-NEXT: Successor(s): middle.block | ||
; CHECK-EMPTY: | ||
; CHECK-NEXT: middle.block: | ||
; CHECK-NEXT: No successors | ||
; CHECK-NEXT: } | ||
; | ||
; CHECK: Executing best plan with VF=8, UF=2 | ||
; CHECK-NEXT: VPlan 'Final VPlan for VF={8},UF={2}' { | ||
; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF | ||
; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count | ||
; CHECK-EMPTY: | ||
; CHECK-NEXT: ph: | ||
; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (zext i4 (trunc i64 %N to i4) to i64) | ||
; CHECK-NEXT: No successors | ||
; CHECK-EMPTY: | ||
; CHECK-NEXT: vector.ph: | ||
; CHECK-NEXT: Successor(s): vector loop | ||
; CHECK-EMPTY: | ||
; CHECK-NEXT: <x1> vector loop: { | ||
; CHECK-NEXT: vector.body: | ||
; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION ir<0>, vp<[[CAN_IV_NEXT:%.+]]> | ||
; CHECK-NEXT: EMIT ir<%p.src> = WIDEN-POINTER-INDUCTION ir<%A>, 1 | ||
; CHECK-NEXT: vp<[[VPTR:%.]]> = vector-pointer ir<%p.src> | ||
; CHECK-NEXT: WIDEN ir<%l> = load vp<[[VPTR]]> | ||
; CHECK-NEXT: WIDEN ir<%add> = add nsw ir<%l>, ir<10> | ||
; CHECK-NEXT: vp<[[VPTR2:%.+]]> = vector-pointer ir<%p.src> | ||
; CHECK-NEXT: WIDEN store vp<[[VPTR2]]>, ir<%add> | ||
; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT]]> = add nuw vp<[[CAN_IV:%.+]]>, vp<[[VFxUF]]> | ||
; CHECK-NEXT: EMIT branch-on-cond ir<true> | ||
; CHECK-NEXT: No successors | ||
; CHECK-NEXT: } | ||
; CHECK-NEXT: Successor(s): middle.block | ||
; CHECK-EMPTY: | ||
; CHECK-NEXT: middle.block: | ||
; CHECK-NEXT: No successors | ||
; CHECK-NEXT: } | ||
; | ||
entry: | ||
%and = and i64 %N, 15 | ||
br label %loop | ||
|
||
loop: | ||
%iv = phi i64 [ %and, %entry ], [ %iv.next, %loop ] | ||
%p.src = phi ptr [ %A, %entry ], [ %p.src.next, %loop ] | ||
%p.src.next = getelementptr inbounds i8, ptr %p.src, i64 1 | ||
%l = load i8, ptr %p.src, align 1 | ||
%add = add nsw i8 %l, 10 | ||
store i8 %add, ptr %p.src | ||
%iv.next = add nsw i64 %iv, -1 | ||
%cmp = icmp eq i64 %iv.next, 0 | ||
br i1 %cmp, label %exit, label %loop | ||
|
||
exit: | ||
ret void | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Final" VPlans should indeed be printed after the last optimizeForVFAndUF(), but preferably along with the "Executing best plan ..." dump above?
Regarding VPlan's name - "Initial" VPlans are currently dumped following buildVPlansWithVPRecipes() which also optimize()'s them, except for the last optimizeForVFAndUF(). Perhaps the processing stage a VPlan is currently in should be better maintained than in a name string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, will move printing "Executing best plan..." down!
Perhaps Initial = after initial construction, Optimized = during most VPlan transforms, Final = just before execution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM. Although the name may be used more persistently to associate a VPlan with the fixed original loop, complemented with optimization decisions (e.g., VF, UF), rather than keep track of which optimizations were processed.