-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
[InstCombine] Remove transformation on call instruction where return value need void to non-void conversion #98536
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
03bb6f3
[InstCombine] Add an option to not take advantage of void to non-void…
yozhu 0ac5dd8
Add a test case
yozhu 2a4d481
[instcombine] Remove transformation involving return value from call …
yozhu e61904e
address review feedback
yozhu 0863610
address review feedback 2
yozhu 94d4332
Forgot to remove the unnecessary add instr from the new test case
yozhu 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 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
24 changes: 24 additions & 0 deletions
24
llvm/test/Transforms/InstCombine/skip-opt-void-to-non-void-conversion.ll
This file contains 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,24 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt --passes=instcombine -S < %s | FileCheck %s | ||
|
||
define dso_local void @foo() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop dso_local. |
||
; CHECK-LABEL: define dso_local void @foo() { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: ret void | ||
; | ||
entry: | ||
ret void | ||
} | ||
|
||
define dso_local i32 @bar() { | ||
; CHECK-LABEL: define dso_local i32 @bar() { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @foo() | ||
; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[TMP0]], 1 | ||
; CHECK-NEXT: ret i32 [[TMP1]] | ||
; | ||
entry: | ||
%1 = tail call i32 @foo() | ||
%2 = add i32 %1, 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can drop the add too :) |
||
ret i32 %2 | ||
} |
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.
I think this bit might still be needed? Can you please add another function to your test that does
%res = call i32 @foo()
but does not use the result? Just want to make sure this doesn't hit some void name assertion.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.
Yes this would necessary now after we have tightened the condition above to skip transformation only when return value has uses.