-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[PGO] Fix zeroed estimated trip count #167792
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
jdenny-ornl
merged 5 commits into
main
from
users/jdenny-ornl/fix-zero-estimated-trip-count
Nov 25, 2025
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7550b95
[PGO] Fix zeroed estimated trip count
jdenny-ornl e2cc9dc
Update tests missed because didn't built with asserts
jdenny-ornl f42fcfa
Rethink fix: Don't convert 0 to 1.
jdenny-ornl 8617eef
Merge branch 'main' into fix-zero-estimated-trip-count
jdenny-ornl 7add214
Expand comment
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
34 changes: 34 additions & 0 deletions
34
llvm/test/Transforms/LoopVectorize/vectorize-zero-estimated-trip-count.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,34 @@ | ||
| ; Check that an estimated trip count of zero does not crash or otherwise break | ||
| ; LoopVectorize behavior while it tries to create runtime memory checks inside | ||
| ; an outer loop. | ||
|
|
||
| ; RUN: opt -passes=loop-vectorize -S %s | FileCheck %s | ||
|
|
||
| target triple = "x86_64-unknown-linux-gnu" | ||
|
|
||
| ; Look for basic signs that vectorization ran and produced memory checks. | ||
| ; CHECK: @test( | ||
| ; CHECK: vector.memcheck: | ||
| ; CHECK: vector.body: | ||
| ; CHECK: inner: | ||
|
|
||
| define void @test(ptr addrspace(1) %p, i32 %n) { | ||
| entry: | ||
| br label %outer | ||
| outer: | ||
| br label %inner | ||
| inner: | ||
| %i = phi i32 [ %inc, %inner ], [ 0, %outer ] | ||
| store i32 0, ptr addrspace(1) %p | ||
| %load = load i32, ptr addrspace(1) null | ||
| %inc = add i32 %i, 1 | ||
| %cmp = icmp slt i32 %i, %n | ||
| br i1 %cmp, label %inner, label %outer.latch | ||
| outer.latch: | ||
| br i1 %cmp, label %outer, label %exit, !llvm.loop !0 | ||
| exit: | ||
| ret void | ||
| } | ||
|
|
||
| !0 = distinct !{!0, !1} | ||
| !1 = !{!"llvm.loop.estimated_trip_count", i32 0} |
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
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.
nit: can you expand why (because it's naively counter-intuitive. I'd just copy and paste the .rst text.)
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.
Done. Thanks for the review.