-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[LoopPeel] Fix branch weights' effect on block frequencies #128785
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
Open
jdenny-ornl
wants to merge
20
commits into
llvm:users/jdenny-ornl/pgo-estimated-trip-count
Choose a base branch
from
jdenny-ornl:fix-peel-branch-weights
base: users/jdenny-ornl/pgo-estimated-trip-count
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f413520
[LoopPeel] Fix branch weights' effect on block frequencies
jdenny-ornl f821eeb
Run update_test_checks.py on a test
jdenny-ornl af8ec56
Fix typo
jdenny-ornl a0264ad
Merge branch 'main' into fix-peel-branch-weights
jdenny-ornl fd29a49
Merge branch 'main' into fix-peel-branch-weights
jdenny-ornl 6303177
Document new metadata
jdenny-ornl bbd0e95
Improve LangRef.rst entry
jdenny-ornl 715cb0a
Merge branch 'main' into fix-peel-branch-weights
jdenny-ornl 67fa67d
Merge branch 'main' into fix-peel-branch-weights
jdenny-ornl 37ce859
Update fixmes
jdenny-ornl 4337dcd
Merge branch 'main' into fix-peel-branch-weights
jdenny-ornl 5193158
Update test for AArch4, which I did not build before
jdenny-ornl bbd2f22
Merge branch 'main' into fix-peel-branch-weights
jdenny-ornl b23f467
Run update script on test changed by merge from main
jdenny-ornl e250cfc
Merge branch 'main' into fix-peel-branch-weights
jdenny-ornl 859b84d
Merge branch 'pgo-estimated-trip-count' into fix-peel-branch-weights
jdenny-ornl 3f6a91a
Merge branch 'pgo-estimated-trip-count' into fix-peel-branch-weights
jdenny-ornl e5a0a26
Update for merge from pgo-estimated-trip-count
jdenny-ornl c283ebe
Merge branch 'pgo-estimated-trip-count' into fix-peel-branch-weights
jdenny-ornl ecbf6e0
Merge branch 'pgo-estimated-trip-count' into fix-peel-branch-weights
jdenny-ornl 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
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
75 changes: 75 additions & 0 deletions
75
llvm/test/Transforms/LoopUnroll/peel-branch-weights-freq.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,75 @@ | ||
; Test branch weight metadata, estimated trip count metadata, and block | ||
; frequencies after loop peeling. | ||
|
||
; RUN: opt < %s -S -passes='print<block-freq>' 2>&1 | \ | ||
; RUN: FileCheck -check-prefix=CHECK %s | ||
|
||
; The -implicit-check-not options make sure that no additional labels or calls | ||
; to @f show up. | ||
; RUN: opt < %s -S -passes='loop-unroll,print<block-freq>' \ | ||
; RUN: -unroll-force-peel-count=2 2>&1 | \ | ||
; RUN: FileCheck %s -check-prefix=CHECK-UR \ | ||
; RUN: -implicit-check-not='{{^[^ ;]*:}}' \ | ||
; RUN: -implicit-check-not='call void @f' | ||
|
||
; CHECK: block-frequency-info: test | ||
; CHECK: do.body: float = 10.0, | ||
|
||
; The sum should still be ~10. | ||
; | ||
; CHECK-UR: block-frequency-info: test | ||
; CHECK-UR: - [[DO_BODY_PEEL:.*]]: float = 1.0, | ||
; CHECK-UR: - [[DO_BODY_PEEL2:.*]]: float = 0.9, | ||
; CHECK-UR: - [[DO_BODY:.*]]: float = 8.1, | ||
|
||
declare void @f(i32) | ||
|
||
define void @test(i32 %n) { | ||
; CHECK-UR-LABEL: define void @test( | ||
; CHECK-UR: [[ENTRY:.*]]: | ||
; CHECK-UR: br label %[[DO_BODY_PEEL_BEGIN:.*]] | ||
; CHECK-UR: [[DO_BODY_PEEL_BEGIN]]: | ||
; CHECK-UR: br label %[[DO_BODY_PEEL:.*]] | ||
; CHECK-UR: [[DO_BODY_PEEL]]: | ||
; CHECK-UR: call void @f | ||
; CHECK-UR: br i1 %{{.*}}, label %[[DO_END:.*]], label %[[DO_BODY_PEEL_NEXT:.*]], !prof ![[#PROF:]] | ||
; CHECK-UR: [[DO_BODY_PEEL_NEXT]]: | ||
; CHECK-UR: br label %[[DO_BODY_PEEL2:.*]] | ||
; CHECK-UR: [[DO_BODY_PEEL2]]: | ||
; CHECK-UR: call void @f | ||
; CHECK-UR: br i1 %{{.*}}, label %[[DO_END]], label %[[DO_BODY_PEEL_NEXT1:.*]], !prof ![[#PROF]] | ||
; CHECK-UR: [[DO_BODY_PEEL_NEXT1]]: | ||
; CHECK-UR: br label %[[DO_BODY_PEEL_NEXT5:.*]] | ||
; CHECK-UR: [[DO_BODY_PEEL_NEXT5]]: | ||
; CHECK-UR: br label %[[ENTRY_PEEL_NEWPH:.*]] | ||
; CHECK-UR: [[ENTRY_PEEL_NEWPH]]: | ||
; CHECK-UR: br label %[[DO_BODY]] | ||
; CHECK-UR: [[DO_BODY]]: | ||
; CHECK-UR: call void @f | ||
; CHECK-UR: br i1 %{{.*}}, label %[[DO_END_LOOPEXIT:.*]], label %[[DO_BODY]], !prof ![[#PROF]], !llvm.loop ![[#LOOP_UR_LATCH:]] | ||
; CHECK-UR: [[DO_END_LOOPEXIT]]: | ||
; CHECK-UR: br label %[[DO_END]] | ||
; CHECK-UR: [[DO_END]]: | ||
; CHECK-UR: ret void | ||
|
||
entry: | ||
br label %do.body | ||
|
||
do.body: | ||
%i = phi i32 [ 0, %entry ], [ %inc, %do.body ] | ||
%inc = add i32 %i, 1 | ||
call void @f(i32 %i) | ||
%c = icmp sge i32 %inc, %n | ||
br i1 %c, label %do.end, label %do.body, !prof !0 | ||
|
||
do.end: | ||
ret void | ||
} | ||
|
||
!0 = !{!"branch_weights", i32 1, i32 9} | ||
|
||
; CHECK-UR: ![[#PROF]] = !{!"branch_weights", i32 1, i32 9} | ||
; CHECK-UR: ![[#LOOP_UR_LATCH]] = distinct !{![[#LOOP_UR_LATCH]], ![[#LOOP_UR_PC:]], ![[#LOOP_UR_TC:]], ![[#DISABLE:]]} | ||
; CHECK-UR: ![[#LOOP_UR_PC]] = !{!"llvm.loop.peeled.count", i32 2} | ||
; CHECK-UR: ![[#LOOP_UR_TC]] = !{!"llvm.loop.estimated_trip_count", i32 8} | ||
; CHECK-UR: ![[#DISABLE]] = !{!"llvm.loop.unroll.disable"} |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.