-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[InstCombine] Preserve profile data with select instructions and binary operators #158375
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
alanzhao1
merged 12 commits into
llvm:main
from
alanzhao1:feature/instcombine-binop-profile
Sep 15, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5ac86b7
[InstCombine] Preserve profile data with select instructions and bina…
alanzhao1 cad50aa
fix missing trailing newline
alanzhao1 938a4d4
fix conditional
alanzhao1 5d7169e
test fixes
alanzhao1 701bf31
more test fixes
alanzhao1 fe929d4
code formatting fixes
alanzhao1 d2979b4
initialize ProfileData to nullptr
alanzhao1 52d9c46
assert that LHS and RHS profile are the same
alanzhao1 d8731d3
pass original select to MDFrom argument of CreateSelect
alanzhao1 dfbd3f3
use update_test_checks.py
alanzhao1 9acdfbd
remove profdata assert
alanzhao1 68356be
restore use of ProfcheckDisableMeatadataFixes
alanzhao1 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --version 6 | ||
; RUN: opt < %s -passes=instcombine -S | FileCheck %s | ||
alanzhao1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
define i32 @LHSBin(i1 %C) !prof !0 { | ||
; CHECK-LABEL: define i32 @LHSBin( | ||
; CHECK-SAME: i1 [[C:%.*]]) !prof [[PROF0:![0-9]+]] { | ||
; CHECK-NEXT: [[V:%.*]] = select i1 [[C]], i32 1010, i32 20, !prof [[PROF1:![0-9]+]] | ||
; CHECK-NEXT: ret i32 [[V]] | ||
; | ||
%A = select i1 %C, i32 1000, i32 10, !prof !1 | ||
%V = add i32 %A, 10 | ||
ret i32 %V | ||
} | ||
|
||
define i32 @RHSBin(i1 %C) !prof !0 { | ||
; CHECK-LABEL: define i32 @RHSBin( | ||
; CHECK-SAME: i1 [[C:%.*]]) !prof [[PROF0]] { | ||
; CHECK-NEXT: [[V:%.*]] = select i1 [[C]], i32 1010, i32 20, !prof [[PROF1]] | ||
; CHECK-NEXT: ret i32 [[V]] | ||
; | ||
%A = select i1 %C, i32 1000, i32 10, !prof !1 | ||
%V = add i32 10, %A | ||
ret i32 %V; | ||
} | ||
|
||
define i32 @BothBin(i1 %C) !prof !0 { | ||
; CHECK-LABEL: define i32 @BothBin( | ||
; CHECK-SAME: i1 [[C:%.*]]) !prof [[PROF0]] { | ||
; CHECK-NEXT: [[V:%.*]] = select i1 [[C]], i32 2000, i32 20, !prof [[PROF1]] | ||
; CHECK-NEXT: ret i32 [[V]] | ||
; | ||
%A = select i1 %C, i32 1000, i32 10, !prof !1 | ||
%B = select i1 %C, i32 1000, i32 10, !prof !1 | ||
%V = add i32 %A, %B | ||
ret i32 %V; | ||
} | ||
|
||
define i32 @NegBin(i1 %C) !prof !0 { | ||
; CHECK-LABEL: define i32 @NegBin( | ||
; CHECK-SAME: i1 [[C:%.*]]) !prof [[PROF0]] { | ||
; CHECK-NEXT: [[V:%.*]] = select i1 [[C]], i32 1010, i32 0, !prof [[PROF1]] | ||
; CHECK-NEXT: ret i32 [[V]] | ||
; | ||
%A = select i1 %C, i32 1000, i32 -10, !prof !1 | ||
%V = add i32 %A, 10 | ||
ret i32 %V | ||
} | ||
|
||
!0 = !{!"function_entry_count", i64 1000} | ||
!1 = !{!"branch_weights", i32 2, i32 3} | ||
;. | ||
; CHECK: [[PROF0]] = !{!"function_entry_count", i64 1000} | ||
; CHECK: [[PROF1]] = !{!"branch_weights", i32 2, i32 3} | ||
;. |
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.