1 # RUN: llc -mtriple=aarch64-none-linux-gnu -run-pass greedy -verify-machineinstrs -o - %s | FileCheck %s
2 # RUN: llc -mtriple=aarch64_be-none-linux-gnu -run-pass greedy -verify-machineinstrs -o - %s | FileCheck %s
4 define i64 @test_subreg_spill_fold() { ret i64 0 }
5 define i64 @test_subreg_spill_fold2() { ret i64 0 }
6 define i64 @test_subreg_spill_fold3() { ret i64 0 }
7 define <4 x float> @test_subreg_spill_fold4() { ret <4 x float> undef }
8 define i64 @test_subreg_fill_fold() { ret i64 0 }
9 define double @test_subreg_fill_fold2() { ret double 0.0 }
10 define <4 x float> @test_subreg_fill_fold3() { ret <4 x float> undef }
11 define i64 @test_nzcv_spill_fold() { ret i64 0 }
14 # CHECK-LABEL: name: test_subreg_spill_fold
15 # Ensure that the spilled subreg COPY is eliminated and folded into the spill store.
16 name: test_subreg_spill_fold
18 - { id: 0, class: gpr64 }
21 ; CHECK: STRXui $xzr, %stack.0, 0 :: (store (s64) into %stack.0)
22 undef %0.sub_32 = COPY $wzr
23 INLINEASM &nop, 1, 12, implicit-def dead $x0, 12, implicit-def dead $x1, 12, implicit-def dead $x2, 12, implicit-def dead $x3, 12, implicit-def dead $x4, 12, implicit-def dead $x5, 12, implicit-def dead $x6, 12, implicit-def dead $x7, 12, implicit-def dead $x8, 12, implicit-def dead $x9, 12, implicit-def dead $x10, 12, implicit-def dead $x11, 12, implicit-def dead $x12, 12, implicit-def dead $x13, 12, implicit-def dead $x14, 12, implicit-def dead $x15, 12, implicit-def dead $x16, 12, implicit-def dead $x17, 12, implicit-def dead $x18, 12, implicit-def dead $x19, 12, implicit-def dead $x20, 12, implicit-def dead $x21, 12, implicit-def dead $x22, 12, implicit-def dead $x23, 12, implicit-def dead $x24, 12, implicit-def dead $x25, 12, implicit-def dead $x26, 12, implicit-def dead $x27, 12, implicit-def dead $x28, 12, implicit-def dead $fp, 12, implicit-def dead $lr, 12, implicit-def $sp
25 RET_ReallyLR implicit $x0
28 # CHECK-LABEL: name: test_subreg_spill_fold2
29 # Similar to test_subreg_spill_fold, but with a %0 register class not containing %WZR.
30 name: test_subreg_spill_fold2
32 - { id: 0, class: gpr64sp }
35 ; CHECK: STRXui $xzr, %stack.0, 0 :: (store (s64) into %stack.0)
36 undef %0.sub_32 = COPY $wzr
37 INLINEASM &nop, 1, 12, implicit-def dead $x0, 12, implicit-def dead $x1, 12, implicit-def dead $x2, 12, implicit-def dead $x3, 12, implicit-def dead $x4, 12, implicit-def dead $x5, 12, implicit-def dead $x6, 12, implicit-def dead $x7, 12, implicit-def dead $x8, 12, implicit-def dead $x9, 12, implicit-def dead $x10, 12, implicit-def dead $x11, 12, implicit-def dead $x12, 12, implicit-def dead $x13, 12, implicit-def dead $x14, 12, implicit-def dead $x15, 12, implicit-def dead $x16, 12, implicit-def dead $x17, 12, implicit-def dead $x18, 12, implicit-def dead $x19, 12, implicit-def dead $x20, 12, implicit-def dead $x21, 12, implicit-def dead $x22, 12, implicit-def dead $x23, 12, implicit-def dead $x24, 12, implicit-def dead $x25, 12, implicit-def dead $x26, 12, implicit-def dead $x27, 12, implicit-def dead $x28, 12, implicit-def dead $fp, 12, implicit-def dead $lr, 12, implicit-def $sp
39 RET_ReallyLR implicit $x0
42 # CHECK-LABEL: name: test_subreg_spill_fold3
43 # Similar to test_subreg_spill_fold, but with a cross register class copy.
44 name: test_subreg_spill_fold3
46 - { id: 0, class: fpr64 }
49 ; CHECK: STRXui $xzr, %stack.0, 0 :: (store (s64) into %stack.0)
50 undef %0.ssub = COPY $wzr
51 INLINEASM &nop, 1, 12, implicit-def dead $d0, 12, implicit-def dead $d1, 12, implicit-def dead $d2, 12, implicit-def dead $d3, 12, implicit-def dead $d4, 12, implicit-def dead $d5, 12, implicit-def dead $d6, 12, implicit-def dead $d7, 12, implicit-def dead $d8, 12, implicit-def dead $d9, 12, implicit-def dead $d10, 12, implicit-def dead $d11, 12, implicit-def dead $d12, 12, implicit-def dead $d13, 12, implicit-def dead $d14, 12, implicit-def dead $d15, 12, implicit-def dead $d16, 12, implicit-def dead $d17, 12, implicit-def dead $d18, 12, implicit-def dead $d19, 12, implicit-def dead $d20, 12, implicit-def dead $d21, 12, implicit-def dead $d22, 12, implicit-def dead $d23, 12, implicit-def dead $d24, 12, implicit-def dead $d25, 12, implicit-def dead $d26, 12, implicit-def dead $d27, 12, implicit-def dead $d28, 12, implicit-def dead $d29, 12, implicit-def dead $d30, 12, implicit-def $d31
53 RET_ReallyLR implicit $x0
56 # CHECK-LABEL: name: test_subreg_spill_fold4
57 # A spilled write to a 128-bit register needs a 128-bit store
58 name: test_subreg_spill_fold4
60 - { id: 0, class: fpr128 }
63 ; CHECK: undef %1.ssub:fpr128 = COPY $wzr
64 ; CHECK-NEXT: STRQui %1, %stack.0, 0 :: (store (s128) into %stack.0)
65 undef %0.ssub:fpr128 = COPY $wzr
66 INLINEASM &nop, 1, 12, implicit-def dead $d0, 12, implicit-def dead $d1, 12, implicit-def dead $d2, 12, implicit-def dead $d3, 12, implicit-def dead $d4, 12, implicit-def dead $d5, 12, implicit-def dead $d6, 12, implicit-def dead $d7, 12, implicit-def dead $d8, 12, implicit-def dead $d9, 12, implicit-def dead $d10, 12, implicit-def dead $d11, 12, implicit-def dead $d12, 12, implicit-def dead $d13, 12, implicit-def dead $d14, 12, implicit-def dead $d15, 12, implicit-def dead $d16, 12, implicit-def dead $d17, 12, implicit-def dead $d18, 12, implicit-def dead $d19, 12, implicit-def dead $d20, 12, implicit-def dead $d21, 12, implicit-def dead $d22, 12, implicit-def dead $d23, 12, implicit-def dead $d24, 12, implicit-def dead $d25, 12, implicit-def dead $d26, 12, implicit-def dead $d27, 12, implicit-def dead $d28, 12, implicit-def dead $d29, 12, implicit-def dead $d30, 12, implicit-def $d31
68 RET_ReallyLR implicit $q0
71 # CHECK-LABEL: name: test_subreg_fill_fold
72 # Ensure that the filled COPY is eliminated and folded into the fill load.
73 name: test_subreg_fill_fold
75 - { id: 0, class: gpr32 }
76 - { id: 1, class: gpr64 }
80 INLINEASM &nop, 1, 12, implicit-def dead $x0, 12, implicit-def dead $x1, 12, implicit-def dead $x2, 12, implicit-def dead $x3, 12, implicit-def dead $x4, 12, implicit-def dead $x5, 12, implicit-def dead $x6, 12, implicit-def dead $x7, 12, implicit-def dead $x8, 12, implicit-def dead $x9, 12, implicit-def dead $x10, 12, implicit-def dead $x11, 12, implicit-def dead $x12, 12, implicit-def dead $x13, 12, implicit-def dead $x14, 12, implicit-def dead $x15, 12, implicit-def dead $x16, 12, implicit-def dead $x17, 12, implicit-def dead $x18, 12, implicit-def dead $x19, 12, implicit-def dead $x20, 12, implicit-def dead $x21, 12, implicit-def dead $x22, 12, implicit-def dead $x23, 12, implicit-def dead $x24, 12, implicit-def dead $x25, 12, implicit-def dead $x26, 12, implicit-def dead $x27, 12, implicit-def dead $x28, 12, implicit-def dead $fp, 12, implicit-def dead $lr, 12, implicit-def $sp
81 ; CHECK: undef %1.sub_32:gpr64 = LDRWui %stack.0, 0 :: (load (s32) from %stack.0)
82 undef %1.sub_32 = COPY %0
84 RET_ReallyLR implicit $x0
87 # CHECK-LABEL: name: test_subreg_fill_fold2
88 # Similar to test_subreg_fill_fold, but with a cross-class copy.
89 name: test_subreg_fill_fold2
91 - { id: 0, class: gpr32 }
92 - { id: 1, class: fpr64 }
96 INLINEASM &nop, 1, 12, implicit-def dead $x0, 12, implicit-def dead $x1, 12, implicit-def dead $x2, 12, implicit-def dead $x3, 12, implicit-def dead $x4, 12, implicit-def dead $x5, 12, implicit-def dead $x6, 12, implicit-def dead $x7, 12, implicit-def dead $x8, 12, implicit-def dead $x9, 12, implicit-def dead $x10, 12, implicit-def dead $x11, 12, implicit-def dead $x12, 12, implicit-def dead $x13, 12, implicit-def dead $x14, 12, implicit-def dead $x15, 12, implicit-def dead $x16, 12, implicit-def dead $x17, 12, implicit-def dead $x18, 12, implicit-def dead $x19, 12, implicit-def dead $x20, 12, implicit-def dead $x21, 12, implicit-def dead $x22, 12, implicit-def dead $x23, 12, implicit-def dead $x24, 12, implicit-def dead $x25, 12, implicit-def dead $x26, 12, implicit-def dead $x27, 12, implicit-def dead $x28, 12, implicit-def dead $fp, 12, implicit-def dead $lr, 12, implicit-def $sp
97 ; CHECK: undef %1.ssub:fpr64 = LDRSui %stack.0, 0 :: (load (s32) from %stack.0)
98 undef %1.ssub = COPY %0
100 RET_ReallyLR implicit $d0
103 # CHECK-LABEL: name: test_subreg_fill_fold3
104 # A filled copy from a sub-register should load the whole register
105 name: test_subreg_fill_fold3
106 tracksRegLiveness: true
108 - { id: 0, class: fpr128 }
115 INLINEASM &nop, 1, 12, implicit-def dead $d0, 12, implicit-def dead $d1, 12, implicit-def dead $d2, 12, implicit-def dead $d3, 12, implicit-def dead $d4, 12, implicit-def dead $d5, 12, implicit-def dead $d6, 12, implicit-def dead $d7, 12, implicit-def dead $d8, 12, implicit-def dead $d9, 12, implicit-def dead $d10, 12, implicit-def dead $d11, 12, implicit-def dead $d12, 12, implicit-def dead $d13, 12, implicit-def dead $d14, 12, implicit-def dead $d15, 12, implicit-def dead $d16, 12, implicit-def dead $d17, 12, implicit-def dead $d18, 12, implicit-def dead $d19, 12, implicit-def dead $d20, 12, implicit-def dead $d21, 12, implicit-def dead $d22, 12, implicit-def dead $d23, 12, implicit-def dead $d24, 12, implicit-def dead $d25, 12, implicit-def dead $d26, 12, implicit-def dead $d27, 12, implicit-def dead $d28, 12, implicit-def dead $d29, 12, implicit-def dead $d30, 12, implicit-def $d31
116 ; CHECK: %1:fpr128 = LDRQui %stack.0, 0 :: (load (s128) from %stack.0)
117 ; CHECK-NEXT: $s0 = COPY %1.ssub
119 RET_ReallyLR implicit $s0
122 # CHECK-LABEL: name: test_nzcv_spill_fold
123 # Ensure that nzcv COPY cannot be folded.
124 name: test_nzcv_spill_fold
126 - { id: 0, class: gpr64 }
129 ; CHECK: %1:gpr64 = COPY $nzcv
130 ; CHECK: STRXui %1, %stack.0, 0 :: (store (s64) into %stack.0)
132 INLINEASM &nop, 1, 12, implicit-def dead $x0, 12, implicit-def dead $x1, 12, implicit-def dead $x2, 12, implicit-def dead $x3, 12, implicit-def dead $x4, 12, implicit-def dead $x5, 12, implicit-def dead $x6, 12, implicit-def dead $x7, 12, implicit-def dead $x8, 12, implicit-def dead $x9, 12, implicit-def dead $x10, 12, implicit-def dead $x11, 12, implicit-def dead $x12, 12, implicit-def dead $x13, 12, implicit-def dead $x14, 12, implicit-def dead $x15, 12, implicit-def dead $x16, 12, implicit-def dead $x17, 12, implicit-def dead $x18, 12, implicit-def dead $x19, 12, implicit-def dead $x20, 12, implicit-def dead $x21, 12, implicit-def dead $x22, 12, implicit-def dead $x23, 12, implicit-def dead $x24, 12, implicit-def dead $x25, 12, implicit-def dead $x26, 12, implicit-def dead $x27, 12, implicit-def dead $x28, 12, implicit-def dead $fp, 12, implicit-def dead $lr, 12, implicit-def $sp
134 RET_ReallyLR implicit $x0