-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[CodeGen] Prevent register coalescer rematerialization based on target #148430
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
Closed
Changes from all commits
Commits
Show all changes
3 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
174 changes: 174 additions & 0 deletions
174
llvm/test/CodeGen/AArch64/arm64-reg-coalesce-remat-zero-cycle-regmov-fpr.mir
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,174 @@ | ||
# RUN: llc -o - -mtriple=arm64-linux-gnu -run-pass=register-coalescer -verify-coalescing %s | FileCheck %s -check-prefixes=NOTCPU-LINUX | ||
# RUN: llc -o - -mtriple=arm64-apple-macosx -mcpu=generic -run-pass=register-coalescer -verify-coalescing %s | FileCheck %s -check-prefixes=NOTCPU-APPLE | ||
# RUN: llc -o - -mtriple=arm64-apple-macosx -mcpu=apple-m1 -run-pass=register-coalescer -verify-coalescing %s | FileCheck %s -check-prefixes=CPU | ||
# RUN: llc -o - -mtriple=arm64-apple-macosx -mcpu=apple-m1 -mattr=-zcm-fpr64 -mattr=-zcm-fpr128 -run-pass=register-coalescer -verify-coalescing %s | FileCheck %s -check-prefixes=NOTATTR | ||
# RUN: llc -o - -mtriple=arm64-apple-macosx -mattr=+zcm-fpr64 -mattr=+zcm-fpr128 -run-pass=register-coalescer -verify-coalescing %s | FileCheck %s -check-prefixes=ATTR | ||
|
||
--- | | ||
define void @remat_FPR128() { | ||
ret void | ||
} | ||
declare void @foo_v4i32(<4 x float>, <4 x float>) | ||
|
||
define void @remat_FPR64() { | ||
ret void | ||
} | ||
declare void @foo_double(double, double) | ||
|
||
define void @remat_FPR32() { | ||
ret void | ||
} | ||
declare void @foo_float(float, float) | ||
|
||
define void @remat_FPR16() { | ||
ret void | ||
} | ||
declare void @foo_half(half, half) | ||
... | ||
--- | ||
name: remat_FPR128 | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
; CHECK-LABEL: name: remat_FPR128 | ||
|
||
; NOTCPU-LINUX: %0:fpr128 = MOVIv2d_ns 64 | ||
; NOTCPU-LINUX-NEXT: %1:fpr128 = MOVIv2d_ns 64 | ||
; NOTCPU-LINUX: BL @foo_v4i32 | ||
|
||
; NOTCPU-APPLE: %0:fpr128 = MOVIv2d_ns 64 | ||
; NOTCPU-APPLE-NEXT: %1:fpr128 = MOVIv2d_ns 64 | ||
; NOTCPU-APPLE: BL @foo_v4i32 | ||
|
||
; CPU: %0:fpr128 = MOVIv2d_ns 64 | ||
; CPU-NEXT: %1:fpr128 = COPY %0 | ||
; CPU: BL @foo_v4i32 | ||
|
||
; NOTATTR: %0:fpr128 = MOVIv2d_ns 64 | ||
; NOTATTR-NEXT: %1:fpr128 = MOVIv2d_ns 64 | ||
; NOTATTR: BL @foo_v4i32 | ||
|
||
; ATTR: %0:fpr128 = MOVIv2d_ns 64 | ||
; ATTR-NEXT: %1:fpr128 = COPY %0 | ||
; ATTR: BL @foo_v4i32 | ||
|
||
%0:fpr128 = MOVIv2d_ns 64 | ||
%1:fpr128 = COPY %0 | ||
|
||
; Creates a live range interference to prevent coalescing and force | ||
; trying to rematerialize the previous COPY. | ||
%1 = ADDv4i32 %1, %1 | ||
|
||
BL @foo_v4i32, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit %0, implicit %1 | ||
RET_ReallyLR | ||
|
||
--- | ||
name: remat_FPR64 | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
; CHECK-LABEL: name: remat_FPR64 | ||
|
||
; NOTCPU-LINUX: %0:fpr64 = FMOVDi 64 | ||
; NOTCPU-LINUX-NEXT: %1:fpr64 = FMOVDi 64 | ||
; NOTCPU-LINUX: BL @foo_double | ||
|
||
; NOTCPU-APPLE: %0:fpr64 = FMOVDi 64 | ||
; NOTCPU-APPLE-NEXT: %1:fpr64 = FMOVDi 64 | ||
; NOTCPU-APPLE: BL @foo_double | ||
|
||
; CPU: %0:fpr64 = FMOVDi 64 | ||
; CPU-NEXT: %1:fpr64 = COPY %0 | ||
; CPU: BL @foo_double | ||
|
||
; NOTATTR: %0:fpr64 = FMOVDi 64 | ||
; NOTATTR-NEXT: %1:fpr64 = FMOVDi 64 | ||
; NOTATTR: BL @foo_double | ||
|
||
; ATTR: %0:fpr64 = FMOVDi 64 | ||
; ATTR-NEXT: %1:fpr64 = COPY %0 | ||
; ATTR: BL @foo_double | ||
|
||
%0:fpr64 = FMOVDi 64 | ||
%1:fpr64 = COPY %0 | ||
|
||
; Creates a live range interference to prevent coalescing and force | ||
; trying to rematerialize the previous COPY. | ||
%1 = FADDDrr %1, %1, implicit $fpcr | ||
|
||
BL @foo_double, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit %0, implicit %1 | ||
RET_ReallyLR | ||
|
||
--- | ||
name: remat_FPR32 | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
; CHECK-LABEL: name: remat_FPR32 | ||
|
||
; NOTCPU-LINUX: %0:fpr32 = FMOVSi 64 | ||
; NOTCPU-LINUX-NEXT: %1:fpr32 = FMOVSi 64 | ||
; NOTCPU-LINUX: BL @foo_float | ||
|
||
; NOTCPU-APPLE: %0:fpr32 = FMOVSi 64 | ||
; NOTCPU-APPLE-NEXT: %1:fpr32 = FMOVSi 64 | ||
; NOTCPU-APPLE: BL @foo_float | ||
|
||
; CPU: %0:fpr32 = FMOVSi 64 | ||
; CPU-NEXT: %1:fpr32 = COPY %0 | ||
; CPU: BL @foo_float | ||
|
||
; NOTATTR: %0:fpr32 = FMOVSi 64 | ||
; NOTATTR-NEXT: %1:fpr32 = FMOVSi 64 | ||
; NOTATTR: BL @foo_float | ||
|
||
; ATTR: %0:fpr32 = FMOVSi 64 | ||
; ATTR-NEXT: %1:fpr32 = COPY %0 | ||
; ATTR: BL @foo_float | ||
|
||
%0:fpr32 = FMOVSi 64 | ||
%1:fpr32 = COPY %0 | ||
|
||
; Creates a live range interference to prevent coalescing and force | ||
; trying to rematerialize the previous COPY. | ||
%1 = FADDSrr %1, %1, implicit $fpcr | ||
|
||
BL @foo_float, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit %0, implicit %1 | ||
RET_ReallyLR | ||
|
||
--- | ||
name: remat_FPR16 | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
; CHECK-LABEL: name: remat_FPR16 | ||
|
||
; NOTCPU-LINUX: %0:fpr16 = FMOVHi 64 | ||
; NOTCPU-LINUX-NEXT: %1:fpr16 = FMOVHi 64 | ||
; NOTCPU-LINUX: BL @foo_half | ||
|
||
; NOTCPU-APPLE: %0:fpr16 = FMOVHi 64 | ||
; NOTCPU-APPLE-NEXT: %1:fpr16 = FMOVHi 64 | ||
; NOTCPU-APPLE: BL @foo_half | ||
|
||
; CPU: %0:fpr16 = FMOVHi 64 | ||
; CPU-NEXT: %1:fpr16 = COPY %0 | ||
; CPU: BL @foo_half | ||
|
||
; NOTATTR: %0:fpr16 = FMOVHi 64 | ||
; NOTATTR-NEXT: %1:fpr16 = FMOVHi 64 | ||
; NOTATTR: BL @foo_half | ||
|
||
; ATTR: %0:fpr16 = FMOVHi 64 | ||
; ATTR-NEXT: %1:fpr16 = COPY %0 | ||
; ATTR: BL @foo_half | ||
|
||
%0:fpr16 = FMOVHi 64 | ||
%1:fpr16 = COPY %0 | ||
|
||
; Creates a live range interference to prevent coalescing and force | ||
; trying to rematerialize the previous COPY. | ||
%1 = FADDHrr %1, %1, implicit $fpcr | ||
|
||
BL @foo_half, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit %0, implicit %1 | ||
RET_ReallyLR |
90 changes: 90 additions & 0 deletions
90
llvm/test/CodeGen/AArch64/arm64-reg-coalesce-remat-zero-cycle-regmov-gpr.mir
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,90 @@ | ||
# RUN: llc -o - -mtriple=arm64-linux-gnu -run-pass=register-coalescer -verify-coalescing %s | FileCheck %s -check-prefixes=NOTCPU-LINUX | ||
# RUN: llc -o - -mtriple=arm64-apple-macosx -mcpu=generic -run-pass=register-coalescer -verify-coalescing %s | FileCheck %s -check-prefixes=NOTCPU-APPLE | ||
# RUN: llc -o - -mtriple=arm64-apple-macosx -mcpu=apple-m1 -run-pass=register-coalescer -verify-coalescing %s | FileCheck %s -check-prefixes=CPU | ||
# RUN: llc -o - -mtriple=arm64-apple-macosx -mcpu=apple-m1 -mattr=-zcm-gpr64 -run-pass=register-coalescer -verify-coalescing %s | FileCheck %s -check-prefixes=NOTATTR | ||
# RUN: llc -o - -mtriple=arm64-apple-macosx -mattr=+zcm-gpr64 -run-pass=register-coalescer -verify-coalescing %s | FileCheck %s -check-prefixes=ATTR | ||
|
||
--- | | ||
define void @remat_GPR32() { | ||
ret void | ||
} | ||
declare void @foo_i32(i32, i32) | ||
|
||
define void @remat_GPR64() { | ||
ret void | ||
} | ||
declare void @foo_i64(i64, i64) | ||
... | ||
--- | ||
name: remat_GPR32 | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
; CHECK-LABEL: name: remat_GPR32 | ||
|
||
; NOTCPU-LINUX: %0:gpr32 = MOVi32imm 32 | ||
; NOTCPU-LINUX-NEXT: %1:gpr32common = MOVi32imm 32 | ||
; NOTCPU-LINUX: BL @foo_i32 | ||
|
||
; NOTCPU-APPLE: %0:gpr32 = MOVi32imm 32 | ||
; NOTCPU-APPLE-NEXT: %1:gpr32common = MOVi32imm 32 | ||
; NOTCPU-APPLE: BL @foo_i32 | ||
|
||
; CPU: %0:gpr32 = MOVi32imm 32 | ||
; CPU-NEXT: %1:gpr32sp = COPY %0 | ||
; CPU: BL @foo_i32 | ||
|
||
; NOTATTR: %0:gpr32 = MOVi32imm 32 | ||
; NOTATTR-NEXT: %1:gpr32common = MOVi32imm 32 | ||
; NOTATTR: BL @foo_i32 | ||
|
||
; ATTR: %0:gpr32 = MOVi32imm 32 | ||
; ATTR-NEXT: %1:gpr32sp = COPY %0 | ||
; ATTR: BL @foo_i32 | ||
|
||
%0:gpr32 = MOVi32imm 32 | ||
%1:gpr32sp = COPY %0 | ||
|
||
; Creates a live range interference to prevent coalescing and force | ||
; trying to rematerialize the previous COPY. | ||
%1 = ADDWri %1, 1, 0 | ||
|
||
BL @foo_i32, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit %0, implicit %1 | ||
RET_ReallyLR | ||
|
||
--- | ||
name: remat_GPR64 | ||
tracksRegLiveness: true | ||
body: | | ||
bb.0: | ||
; CHECK-LABEL: name: remat_GPR64 | ||
|
||
; NOTCPU-LINUX: %0:gpr64 = MOVi64imm 64 | ||
; NOTCPU-LINUX-NEXT: %1:gpr64common = MOVi64imm 64 | ||
; NOTCPU-LINUX: BL @foo_i64 | ||
|
||
; NOTCPU-APPLE: %0:gpr64 = MOVi64imm 64 | ||
; NOTCPU-APPLE-NEXT: %1:gpr64common = MOVi64imm 64 | ||
; NOTCPU-APPLE: BL @foo_i64 | ||
|
||
; CPU: %0:gpr64 = MOVi64imm 64 | ||
; CPU-NEXT: %1:gpr64sp = COPY %0 | ||
; CPU: BL @foo_i64 | ||
|
||
; NOTATTR: %0:gpr64 = MOVi64imm 64 | ||
; NOTATTR-NEXT: %1:gpr64common = MOVi64imm 64 | ||
; NOTATTR: BL @foo_i64 | ||
|
||
; ATTR: %0:gpr64 = MOVi64imm 64 | ||
; ATTR-NEXT: %1:gpr64sp = COPY %0 | ||
; ATTR: BL @foo_i64 | ||
|
||
%0:gpr64 = MOVi64imm 64 | ||
%1:gpr64sp = COPY %0 | ||
|
||
; Creates a live range interference to prevent coalescing and force | ||
; trying to rematerialize the previous COPY. | ||
%1 = ADDXri %1, 1, 0 | ||
|
||
BL @foo_i64, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit %0, implicit %1 | ||
RET_ReallyLR |
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.
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.
Don't need the IR section
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 not? need to provide a function def, otherwise it fails with:
function 'remat_FPR128' isn't defined in the provided LLVM IR