-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[MachineLICM] Do not rely on hasSideEffect when handling impdefs #145379
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
atrosinenko
wants to merge
4
commits into
main
Choose a base branch
from
users/atrosinenko/machine-licm-implicit-defs
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.
+110
−12
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
df21ee2
[MachineLICM] Precommit tests for implicit-def handling
atrosinenko 182a490
[MachineLICM] Do not rely on hasSideEffect when handling impdefs
atrosinenko 707a36c
Fix hoisting safe dead implicit-defs
atrosinenko 4c29db1
Drop useless corner case
atrosinenko 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,103 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 | ||
# RUN: llc -mtriple=aarch64 -run-pass machinelicm -verify-machineinstrs -o - %s | FileCheck %s | ||
# RUN: llc -mtriple=aarch64 -passes machinelicm -o - %s | FileCheck %s | ||
|
||
--- | ||
name: unsafe_to_move | ||
tracksRegLiveness: true | ||
body: | | ||
; CHECK-LABEL: name: unsafe_to_move | ||
; CHECK: bb.0: | ||
; CHECK-NEXT: successors: %bb.1(0x80000000) | ||
; CHECK-NEXT: liveins: $x0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: $x16 = COPY killed $x0 | ||
; CHECK-NEXT: B %bb.1 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: bb.1: | ||
; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000) | ||
; CHECK-NEXT: liveins: $x16 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: $x1 = COPY killed $x16 | ||
; CHECK-NEXT: $x2 = MOVi64imm 1024, implicit-def dead $x16 | ||
; CHECK-NEXT: $x16 = LDRXroX killed $x1, killed $x2, 0, 0 | ||
; CHECK-NEXT: $xzr = SUBSXri $x16, 0, 0, implicit-def $nzcv | ||
; CHECK-NEXT: Bcc 1, %bb.1, implicit $nzcv | ||
; CHECK-NEXT: B %bb.2 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: bb.2: | ||
; CHECK-NEXT: liveins: $x1 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: $x0 = COPY killed $x1 | ||
; CHECK-NEXT: RET_ReallyLR | ||
bb.0: | ||
liveins: $x0 | ||
$x16 = COPY killed $x0 | ||
B %bb.1 | ||
bb.1: | ||
liveins: $x16 | ||
$x1 = COPY killed $x16 | ||
/* MOVi64imm below mimics a pseudo instruction that doesn't have any */ | ||
/* unmodelled side effects, but uses x16 as a scratch register. */ | ||
$x2 = MOVi64imm 1024, implicit-def dead $x16 | ||
$x16 = LDRXroX killed $x1, killed $x2, 0, 0 | ||
$xzr = SUBSXri $x16, 0, 0, implicit-def $nzcv | ||
Bcc 1, %bb.1, implicit $nzcv | ||
B %bb.2 | ||
bb.2: | ||
liveins: $x1 | ||
$x0 = COPY killed $x1 | ||
RET_ReallyLR | ||
... | ||
|
||
--- | ||
name: dead_implicit_def | ||
tracksRegLiveness: true | ||
body: | | ||
; CHECK-LABEL: name: dead_implicit_def | ||
; CHECK: bb.0: | ||
; CHECK-NEXT: successors: %bb.1(0x80000000) | ||
; CHECK-NEXT: liveins: $x0 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: $x12 = COPY killed $x0 | ||
; CHECK-NEXT: $x2 = MOVi64imm 1024, implicit-def dead $x16 | ||
; CHECK-NEXT: B %bb.1 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: bb.1: | ||
; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000) | ||
; CHECK-NEXT: liveins: $x12, $x2 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: $x1 = COPY killed $x12 | ||
; CHECK-NEXT: $x16 = LDRXroX killed $x1, $x2, 0, 0 | ||
; CHECK-NEXT: $xzr = SUBSXri $x16, 0, 0, implicit-def $nzcv | ||
; CHECK-NEXT: Bcc 1, %bb.1, implicit $nzcv | ||
; CHECK-NEXT: B %bb.2 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: bb.2: | ||
; CHECK-NEXT: liveins: $x1 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: $x0 = COPY killed $x1 | ||
; CHECK-NEXT: RET_ReallyLR | ||
bb.0: | ||
liveins: $x0 | ||
$x12 = COPY killed $x0 | ||
B %bb.1 | ||
bb.1: | ||
liveins: $x12 | ||
$x1 = COPY killed $x12 | ||
/* MOVi64imm below mimics a pseudo instruction that doesn't have any */ | ||
/* unmodelled side effects, but uses x16 as a scratch register. */ | ||
$x2 = MOVi64imm 1024, implicit-def dead $x16 | ||
$x16 = LDRXroX killed $x1, killed $x2, 0, 0 | ||
$xzr = SUBSXri $x16, 0, 0, implicit-def $nzcv | ||
Bcc 1, %bb.1, implicit $nzcv | ||
B %bb.2 | ||
bb.2: | ||
liveins: $x1 | ||
$x0 = COPY killed $x1 | ||
RET_ReallyLR | ||
... |
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.
What's unclear to me is why implicit defs are special here as well. I uploaded #147624 which merges the logic for implicit and explicit defs, and it passes the new test from this PR. I also ran a stage2 check-llvm and check-clang and they both pass. It requires updates to some target-specific tests; I'm not an expert on all of the affected ISAs but they seem correct.