1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64-apple-ios -run-pass=aarch64-prelegalizer-combiner %s -o - -verify-machineinstrs | FileCheck %s
5 # Check that we fold two adds of constant offsets with G_PTR_ADD into a single G_PTR_ADD.
8 tracksRegLiveness: true
13 ; CHECK-LABEL: name: ptradd_chain
16 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
17 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
18 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
19 ; CHECK-NEXT: $x0 = COPY [[PTR_ADD]](p0)
20 ; CHECK-NEXT: RET_ReallyLR implicit $x0
22 %1:_(s64) = G_CONSTANT i64 4
23 %2:_(s64) = G_CONSTANT i64 12
24 %3:_(p0) = G_PTR_ADD %0(p0), %1
25 %4:_(p0) = G_PTR_ADD %3(p0), %2
27 RET_ReallyLR implicit $x0
31 tracksRegLiveness: true
35 ; CHECK-LABEL: name: ptradd_chain_2
38 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
39 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 28
40 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
41 ; CHECK-NEXT: $x0 = COPY [[PTR_ADD]](p0)
42 ; CHECK-NEXT: RET_ReallyLR implicit $x0
44 %1:_(s64) = G_CONSTANT i64 4
45 %2:_(s64) = G_CONSTANT i64 12
46 %3:_(p0) = G_PTR_ADD %0(p0), %1
47 %4:_(p0) = G_PTR_ADD %3(p0), %2
48 %5:_(p0) = G_PTR_ADD %4(p0), %2
50 RET_ReallyLR implicit $x0
53 name: ptradd_chain_lookthough
54 tracksRegLiveness: true
58 ; CHECK-LABEL: name: ptradd_chain_lookthough
61 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
62 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 28
63 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
64 ; CHECK-NEXT: $x0 = COPY [[PTR_ADD]](p0)
65 ; CHECK-NEXT: RET_ReallyLR implicit $x0
67 %1:_(s64) = G_CONSTANT i64 4
68 %2:_(s64) = G_CONSTANT i64 12
69 %6:_(s32) = G_TRUNC %2(s64)
70 %7:_(s64) = G_SEXT %6(s32)
71 %3:_(p0) = G_PTR_ADD %0(p0), %1
72 %4:_(p0) = G_PTR_ADD %3(p0), %2
73 %5:_(p0) = G_PTR_ADD %4(p0), %7
75 RET_ReallyLR implicit $x0
78 name: ptradd_would_form_illegal_load_addressing
79 tracksRegLiveness: true
84 ; CHECK-LABEL: name: ptradd_would_form_illegal_load_addressing
87 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
88 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
89 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4096
90 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
91 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTR_ADD]], [[C1]](s64)
92 ; CHECK-NEXT: %ld:_(s64) = G_LOAD [[PTR_ADD1]](p0) :: (load (s64))
93 ; CHECK-NEXT: %ld_other:_(s64) = G_LOAD [[PTR_ADD]](p0) :: (load (s64))
94 ; CHECK-NEXT: $x0 = COPY %ld(s64)
95 ; CHECK-NEXT: $x1 = COPY %ld_other(s64)
96 ; CHECK-NEXT: RET_ReallyLR implicit $x0
98 %1:_(s64) = G_CONSTANT i64 4
99 %2:_(s64) = G_CONSTANT i64 4096
100 %3:_(p0) = G_PTR_ADD %0(p0), %1
101 %4:_(p0) = G_PTR_ADD %3(p0), %2
102 %ld:_(s64) = G_LOAD %4(p0) :: (load 8)
103 %ld_other:_(s64) = G_LOAD %3(p0) :: (load 8)
105 $x1 = COPY %ld_other(s64)
106 RET_ReallyLR implicit $x0
109 name: ptradd_would_form_illegal_load_addressing_wrong_orig_immed
110 tracksRegLiveness: true
115 ; CHECK-LABEL: name: ptradd_would_form_illegal_load_addressing_wrong_orig_immed
116 ; CHECK: liveins: $x0
118 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
119 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1600136
120 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
121 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
122 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTR_ADD]], [[C1]](s64)
123 ; CHECK-NEXT: %ld:_(s64) = G_LOAD [[PTR_ADD1]](p0) :: (load (s64))
124 ; CHECK-NEXT: %ld_other:_(s64) = G_LOAD [[PTR_ADD]](p0) :: (load (s64))
125 ; CHECK-NEXT: $x0 = COPY %ld(s64)
126 ; CHECK-NEXT: $x1 = COPY %ld_other(s64)
127 ; CHECK-NEXT: RET_ReallyLR implicit $x0
129 %1:_(s64) = G_CONSTANT i64 1600136
130 %2:_(s64) = G_CONSTANT i64 8
131 %3:_(p0) = G_PTR_ADD %0(p0), %1
132 %4:_(p0) = G_PTR_ADD %3(p0), %2
133 %ld:_(s64) = G_LOAD %4(p0) :: (load 8)
134 %ld_other:_(s64) = G_LOAD %3(p0) :: (load 8)
136 $x1 = COPY %ld_other(s64)
137 RET_ReallyLR implicit $x0
141 name: ptradd_constant_type_mismatch
142 tracksRegLiveness: true
147 ; CHECK-LABEL: name: ptradd_constant_type_mismatch
148 ; CHECK: liveins: $x0, $x1
150 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
151 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
152 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
153 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[COPY1]](s64)
154 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTR_ADD]], [[C]](s64)
155 ; CHECK-NEXT: %ld:_(s64) = G_LOAD [[PTR_ADD1]](p0) :: (load (s64))
156 ; CHECK-NEXT: $x0 = COPY %ld(s64)
157 ; CHECK-NEXT: RET_ReallyLR implicit $x0
160 %2:_(s32) = G_CONSTANT i32 8
161 %3:_(s64) = G_ZEXT %2:_(s32)
162 %4:_(p0) = G_PTR_ADD %0:_, %3:_(s64)
163 %5:_(p0) = G_PTR_ADD %4:_, %1:_(s64)
164 %ld:_(s64) = G_LOAD %5(p0) :: (load 8)
166 RET_ReallyLR implicit $x0