-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[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
Merged
Merged
Changes from 58 commits
Commits
Show all changes
59 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 13d1fbb
[PGO] Add `llvm.loop.estimated_trip_count` metadata
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 db5920a
Merge branch 'main' into pgo-estimated-trip-count
jdenny-ornl 47fbe85
Add PGOEstimateTripCounts in more cases
jdenny-ornl f8097fb
Add unused initialization
jdenny-ornl 7b27203
Simplify some test changes
jdenny-ornl 4c4669a
Extend verify pass to cover new metadata
jdenny-ornl 0f40efd
Fix test for some builds
jdenny-ornl 2791a1c
Merge branch 'main' into pgo-estimated-trip-count
jdenny-ornl 6148922
Apply some small reviewer suggestions
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 3a49b43
Attempt to fix windows pre-commit CI
jdenny-ornl c283ebe
Merge branch 'pgo-estimated-trip-count' into fix-peel-branch-weights
jdenny-ornl 2f7daa8
Merge branch 'main' into pgo-estimated-trip-count
jdenny-ornl ecbf6e0
Merge branch 'pgo-estimated-trip-count' into fix-peel-branch-weights
jdenny-ornl c627fc5
Merge branch 'main' into pgo-estimated-trip-count
jdenny-ornl f1fa8d9
Run update script on new test from last merge
jdenny-ornl 38ace1e
Reapply 3a18fe33f0763cd9276c99c276448412100f6270
jdenny-ornl 92ddaa0
Convert to function pass, avoid needless pass invalidation
jdenny-ornl a3e0d72
Fix layering violation
jdenny-ornl 67f22cd
Apply clang-format
jdenny-ornl f0ff2e2
Merge branch 'main' into pgo-estimated-trip-count
jdenny-ornl 69fe051
Merge branch 'pgo-estimated-trip-count' into fix-peel-branch-weights
jdenny-ornl e7eb1fe
Merge branch 'main' into pgo-estimated-trip-count
jdenny-ornl e4f68c3
Merge branch 'pgo-estimated-trip-count' into fix-peel-branch-weights
jdenny-ornl 0973ab3
Merge branch 'main' into pgo-estimated-trip-count
jdenny-ornl 680bdc2
Remove PGOEstimateTripCountsPass and no-value form of metadata
jdenny-ornl 83531b3
Merge branch 'pgo-estimated-trip-count' into fix-peel-branch-weights
jdenny-ornl 59cd184
Fix case where nested loops share latch
jdenny-ornl 47051ce
Merge branch 'pgo-estimated-trip-count' into fix-peel-branch-weights
jdenny-ornl 5d00250
Merge branch 'main' into pgo-estimated-trip-count
jdenny-ornl 5719779
Remove redundant code
jdenny-ornl 98cab7b
Clarify recent comments some
jdenny-ornl 3cbe07d
Merge branch 'pgo-estimated-trip-count' into fix-peel-branch-weights
jdenny-ornl b3831b6
Merge branch 'main' into pgo-estimated-trip-count
jdenny-ornl 59ab013
Merge branch 'pgo-estimated-trip-count' into fix-peel-branch-weights
jdenny-ornl b8aed9b
Merge branch 'main' into pgo-estimated-trip-count
jdenny-ornl 5c9e43e
Merge branch 'pgo-estimated-trip-count' into fix-peel-branch-weights
jdenny-ornl 83ac767
Merge branch 'main' into fix-peel-branch-weights
jdenny-ornl 1f81310
Empty commit to try to restart pre-commit CI
jdenny-ornl 04c8ade
Merge branch 'main' into fix-peel-branch-weights
jdenny-ornl a1a5460
Merge branch 'main' into fix-peel-branch-weights
jdenny-ornl f5b1885
Remove fixme about probability < 1:1 ratio
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
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"} |
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
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.
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.
After many months, there have been no remarks on this fixme comment. I am inclined to just remove the comment.
@mtrofin Thanks for accepting. Is it ok with you if I just remove it?
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.
I have decided to move forward with removing the fixme and merging the PR. If there are objections after the merge, I can revert or fix.