-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[AArch64] improve zero-cycle regmov test #143680
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
[AArch64] improve zero-cycle regmov test #143680
Conversation
|
@llvm/pr-subscribers-backend-aarch64 Author: Tomer Shafir (tomershafir) Changes
Full diff: https://github.com/llvm/llvm-project/pull/143680.diff 2 Files Affected:
diff --git a/llvm/test/CodeGen/AArch64/arm64-zero-cycle-regmov-gpr32.ll b/llvm/test/CodeGen/AArch64/arm64-zero-cycle-regmov-gpr32.ll
new file mode 100644
index 0000000000000..9891da6622600
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/arm64-zero-cycle-regmov-gpr32.ll
@@ -0,0 +1,39 @@
+; RUN: llc < %s -march=arm64 | FileCheck %s -check-prefixes=CHECK,NOTCPU
+; RUN: llc < %s -mcpu=apple-m1 | FileCheck %s -check-prefixes=CHECK,CPU
+; RUN: llc < %s -mcpu=apple-m1 -mattr=-zcm | FileCheck %s -check-prefixes=CHECK,NOTATTR
+; RUN: llc < %s -march=arm64 -mattr=+zcm | FileCheck %s -check-prefixes=CHECK,ATTR
+
+define i32 @t(i32 %a, i32 %b, i32 %c, i32 %d) nounwind ssp {
+entry:
+; CHECK-LABEL: t:
+; NOTCPU: mov w0, w2
+; NOTCPU: mov w1, w3
+; NOTCPU: mov [[REG2:w[0-9]+]], w3
+; NOTCPU: mov [[REG1:w[0-9]+]], w2
+; CPU: mov [[REG2:x[0-9]+]], x3
+; CPU: mov [[REG1:x[0-9]+]], x2
+; CPU: mov x0, x2
+; CPU: mov x1, x3
+; NOTATTR: mov [[REG2:w[0-9]+]], w3
+; NOTATTR: mov [[REG1:w[0-9]+]], w2
+; NOTATTR: mov w0, w2
+; NOTATTR: mov w1, w3
+; ATTR: mov x0, x2
+; ATTR: mov x1, x3
+; ATTR: mov [[REG2:x[0-9]+]], x3
+; ATTR: mov [[REG1:x[0-9]+]], x2
+; CHECK: bl _foo
+; NOTCPU: mov w0, [[REG1]]
+; NOTCPU: mov w1, [[REG2]]
+; CPU: mov x0, [[REG1]]
+; CPU: mov x1, [[REG2]]
+; NOTATTR: mov w0, [[REG1]]
+; NOTATTR: mov w1, [[REG2]]
+; ATTR: mov x0, [[REG1]]
+; ATTR: mov x1, [[REG2]]
+ %call = call i32 @foo(i32 %c, i32 %d) nounwind
+ %call1 = call i32 @foo(i32 %c, i32 %d) nounwind
+ unreachable
+}
+
+declare i32 @foo(i32, i32)
diff --git a/llvm/test/CodeGen/AArch64/arm64-zero-cycle-regmov.ll b/llvm/test/CodeGen/AArch64/arm64-zero-cycle-regmov.ll
deleted file mode 100644
index b390853d44bff..0000000000000
--- a/llvm/test/CodeGen/AArch64/arm64-zero-cycle-regmov.ll
+++ /dev/null
@@ -1,23 +0,0 @@
-; RUN: llc < %s -mtriple=arm64-apple-ios -mattr=-zcm | FileCheck %s -check-prefixes=CHECK,NOT
-; RUN: llc < %s -mtriple=arm64-apple-ios -mattr=+zcm | FileCheck %s -check-prefixes=CHECK,YES
-; RUN: llc < %s -mtriple=arm64-apple-ios -mcpu=cyclone | FileCheck %s -check-prefixes=CHECK,YES
-
-; rdar://12254953
-define i32 @t(i32 %a, i32 %b, i32 %c, i32 %d) nounwind ssp {
-entry:
-; CHECK-LABEL: t:
-; NOT: mov [[REG2:w[0-9]+]], w3
-; NOT: mov [[REG1:w[0-9]+]], w2
-; YES: mov [[REG2:x[0-9]+]], x3
-; YES: mov [[REG1:x[0-9]+]], x2
-; CHECK: bl _foo
-; NOT: mov w0, [[REG1]]
-; NOT: mov w1, [[REG2]]
-; YES: mov x0, [[REG1]]
-; YES: mov x1, [[REG2]]
- %call = call i32 @foo(i32 %c, i32 %d) nounwind
- %call1 = call i32 @foo(i32 %c, i32 %d) nounwind
- unreachable
-}
-
-declare i32 @foo(i32, i32)
|
1ac2414 to
8e6cb06
Compare
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.
| define i32 @t(i32 %a, i32 %b, i32 %c, i32 %d) nounwind ssp { | |
| define i32 @t(i32 %a, i32 %b, i32 %c, i32 %d) { |
nounwind/ssp shouldn't be needed I think?
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.
How big is the full assembly for the function? Would it make sense to auto-generate the check lines via llvm/utils/update_llc_test_checks.py?
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.
its only 20-30 lines of assembly, I think its small enough to keep it manual and more manageable
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.
This interleaving off checks for different configuration makes it very hard to see what's going on.
I would expect that CPU/ATTR check lines are the same? Same for NOTATTR/NOTCPU?
If that's the case, they should be merged. Then it would make sense to auto-generate and check the full assembly for the case with and without the feature enabled (either via CPU or attribute)
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.
So CPU/ATTR differ because -mcpu changes the order of instructions. Same for NOTATTR/NOTCPU. I can separate each configuration by duplicating ; CHECK: bl {{_?foo}}, or autogen 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.
I will separate the outputs as described, as I dont think the cons of autogenerating the test worth it here (overfitting, robustness, readability, harder to debug)
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.
So CPU/ATTR differ because -mcpu changes the order of instructions. Same for NOTATTR/NOTCPU. I can separate each configuration by duplicating ; CHECK: bl {{_?foo}}, or autogen it.
Ah I see, thanks. Separating the output makes things clearer.
8e6cb06 to
916c109
Compare
|
v2:
|
c0fd9b7 to
0034d15
Compare
|
v3:
|
|
@fhahn Ping |
0034d15 to
7c835ad
Compare
|
v4:
|
fhahn
left a comment
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.
LGTM, thanks with the suggested edits
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.
This should probably also check that the call comes next
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.
So CPU/ATTR differ because -mcpu changes the order of instructions. Same for NOTATTR/NOTCPU. I can separate each configuration by duplicating ; CHECK: bl {{_?foo}}, or autogen it.
Ah I see, thanks. Separating the output makes things clearer.
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.
| define i32 @t(i32 %a, i32 %b, i32 %c, i32 %d) { | |
| define void @t(i32 %a, i32 %b, i32 %c, i32 %d) { |
nothing returned
7c835ad to
13052e5
Compare
53d57cc to
ec31b1b
Compare
- Add a `gpr32` suffix to test name to denote the specific register class being checked
- Expand `-mtriple=arm64-apple-ios` to `-march=arm64` to broaden the test context to the generic architecture, as the specific triple is not required
- Port `bl` match to Linux too via the regex: `{{_?foo}}`
- Advance `-mcpu=cyclone` to the newer M series major `-mcpu=apple-m1`
- Use `-mcpu` so that `-mattr=-zcm` has a real effect
- Add a test that generic arm64 doesn't optimize for ZCM
- Distinguish 4 different assembly layouts: NOTCPU, CPU, NOTATTR, ATTR
- Fix broken test logic, for example: `; NOT: mov [[REG2:w[0-9]+]], w3` matched `mov w1, w3` then `REG2` captured `w1` but then `; NOT: mov w1, [[REG2]]` matched by prefix `mov, w1, w19` even though it should have matched `mov w1, w1`. This change adds explicit matches for all of the generated copies, and `--match-full-lines` param to FileCheck.
- Remove nownwind and ssp from t function decleration
- Remove nounwind from foo call sites
- Separate different outputs for readability
- Change return type from `i32` to `void`
- FileCheck exact position of calls with `*-NEXT`
ec31b1b to
9cc45c9
Compare
|
v5:
|
This change emits optimized copy instructions for FPR32, FPR16, FPR8 register classes on targets that support it. The implementation is similar to what has been done for GPR32. It adds 2 regression tests for FPR32 and FPR16. Depends on: #143680 to resolve the test structure.
…(#144152) This change emits optimized copy instructions for FPR32, FPR16, FPR8 register classes on targets that support it. The implementation is similar to what has been done for GPR32. It adds 2 regression tests for FPR32 and FPR16. Depends on: llvm/llvm-project#143680 to resolve the test structure.
This change emits optimized copy instructions for FPR32, FPR16, FPR8 register classes on targets that support it. The implementation is similar to what has been done for GPR32. It adds 2 regression tests for FPR32 and FPR16. Depends on: llvm#143680 to resolve the test structure.
gpr32suffix to test name to denote the specific register class being checked-mtriple=arm64-apple-iosto-march=arm64to broaden the test context to the generic architecture, as the specific triple is not requiredblmatch to Linux too via the regex:{{_?foo}}-mcpu=cycloneto the newer M series major-mcpu=apple-m1-mcpuso that-mattr=-zcmhas a real effect; NOT: mov [[REG2:w[0-9]+]], w3matchedmov w1, w3thenREG2capturedw1but then; NOT: mov w1, [[REG2]]matched by prefixmov, w1, w19even though it should have matchedmov w1, w1. This change adds explicit matches for all of the generated copies.