-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[DAGCombiner][X86] Push bitcast/ext through freeze for loads #163070
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
guy-david
wants to merge
2
commits into
main
Choose a base branch
from
users/guy-david/fold-conv-freeze-load
base: main
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.
+2,405
−2,216
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
| ; RUN: llc < %s -mtriple=aarch64 | FileCheck %s | ||
guy-david marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| define double @test_bitcast_freeze_load(ptr %p) { | ||
| ; CHECK-LABEL: test_bitcast_freeze_load: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: ldr d0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| %v = load <2 x float>, ptr %p | ||
| %f = freeze <2 x float> %v | ||
| %b = bitcast <2 x float> %f to double | ||
| ret double %b | ||
| } | ||
|
|
||
| define i32 @test_sext_freeze_load_i8(ptr %p) { | ||
| ; CHECK-LABEL: test_sext_freeze_load_i8: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: ldrsb w0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| %v = load i8, ptr %p | ||
| %f = freeze i8 %v | ||
| %e = sext i8 %f to i32 | ||
| ret i32 %e | ||
| } | ||
|
|
||
| define i64 @test_sext_freeze_load_i32(ptr %p) { | ||
| ; CHECK-LABEL: test_sext_freeze_load_i32: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: ldr w8, [x0] | ||
| ; CHECK-NEXT: sxtw x0, w8 | ||
| ; CHECK-NEXT: ret | ||
| %v = load i32, ptr %p | ||
| %f = freeze i32 %v | ||
| %e = sext i32 %f to i64 | ||
| ret i64 %e | ||
| } | ||
|
|
||
| define i64 @test_sext_freeze_load_i16(ptr %p) { | ||
| ; CHECK-LABEL: test_sext_freeze_load_i16: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: ldrsh x0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| %v = load i16, ptr %p | ||
| %f = freeze i16 %v | ||
| %e = sext i16 %f to i64 | ||
| ret i64 %e | ||
| } | ||
|
|
||
| define i32 @test_zext_freeze_load_i8(ptr %p) { | ||
| ; CHECK-LABEL: test_zext_freeze_load_i8: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: ldrb w0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| %v = load i8, ptr %p | ||
| %f = freeze i8 %v | ||
| %e = zext i8 %f to i32 | ||
| ret i32 %e | ||
| } | ||
|
|
||
| define i64 @test_zext_freeze_load_i32(ptr %p) { | ||
| ; CHECK-LABEL: test_zext_freeze_load_i32: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: ldr w0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| %v = load i32, ptr %p | ||
| %f = freeze i32 %v | ||
| %e = zext i32 %f to i64 | ||
| ret i64 %e | ||
| } | ||
|
|
||
| define i64 @test_zext_freeze_load_i16(ptr %p) { | ||
| ; CHECK-LABEL: test_zext_freeze_load_i16: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: ldrh w0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| %v = load i16, ptr %p | ||
| %f = freeze i16 %v | ||
| %e = zext i16 %f to i64 | ||
| ret i64 %e | ||
| } | ||
|
|
||
| define i32 @test_sext_freeze_load_multiuse(ptr %p) { | ||
| ; CHECK-LABEL: test_sext_freeze_load_multiuse: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: ldrb w8, [x0] | ||
| ; CHECK-NEXT: sxtb w9, w8 | ||
| ; CHECK-NEXT: add w0, w9, w8, uxtb | ||
| ; CHECK-NEXT: ret | ||
| %v = load i8, ptr %p | ||
| %f = freeze i8 %v | ||
| %e = sext i8 %f to i32 | ||
| %z = zext i8 %f to i32 | ||
| %r = add i32 %e, %z | ||
| ret i32 %r | ||
| } | ||
|
|
||
| define <4 x i32> @test_sext_freeze_load_v4i16(ptr %p) { | ||
| ; CHECK-LABEL: test_sext_freeze_load_v4i16: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: ldr d0, [x0] | ||
| ; CHECK-NEXT: sshll v0.4s, v0.4h, #0 | ||
| ; CHECK-NEXT: ret | ||
| %v = load <4 x i16>, ptr %p | ||
| %f = freeze <4 x i16> %v | ||
| %e = sext <4 x i16> %f to <4 x i32> | ||
| ret <4 x i32> %e | ||
| } | ||
|
|
||
| define <4 x i32> @test_zext_freeze_load_v4i16(ptr %p) { | ||
| ; CHECK-LABEL: test_zext_freeze_load_v4i16: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: ldr d0, [x0] | ||
| ; CHECK-NEXT: ushll v0.4s, v0.4h, #0 | ||
| ; CHECK-NEXT: ret | ||
| %v = load <4 x i16>, ptr %p | ||
| %f = freeze <4 x i16> %v | ||
| %e = zext <4 x i16> %f to <4 x i32> | ||
| ret <4 x i32> %e | ||
| } | ||
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
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.
Why didn't you try to do this in visitBITCAST and add FREEZE handling into the existing BITCAST(LOAD) fold?
My concern is that we already have had problems with ReplaceAllUsesWith with frozen/unfrozen uses of a node, and worry this might add to 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.
It will create a conflict with
visitFREEZEand enter an infinite loop, see the PR description.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.
Also, this will fold only when the
FREEZEnode has a single use.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.
@RKSimon Regarding #164618, how does it scale w.r.t. extensions?
I tried to address your comment with the last commit.
And a general question about
FREEZEoperations- is there a point in the lowering where we should strip them entirely? It seems quite cumbersome that every optimization has to potentially peel these in every use case.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.
No, these are not simply droppable
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.
#164618 only handles BITCASTS - we need to handle EXT cases separately