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 --aarch64prelegalizercombinerhelper-only-enable-rule="ptr_add_immed_chain" %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
15 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
16 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
17 ; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
18 ; CHECK: $x0 = COPY [[PTR_ADD]](p0)
19 ; CHECK: RET_ReallyLR implicit $x0
21 %1:_(s64) = G_CONSTANT i64 4
22 %2:_(s64) = G_CONSTANT i64 12
23 %3:_(p0) = G_PTR_ADD %0(p0), %1
24 %4:_(p0) = G_PTR_ADD %3(p0), %2
26 RET_ReallyLR implicit $x0
30 tracksRegLiveness: true
34 ; CHECK-LABEL: name: ptradd_chain_2
36 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
37 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 28
38 ; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
39 ; CHECK: $x0 = COPY [[PTR_ADD]](p0)
40 ; CHECK: RET_ReallyLR implicit $x0
42 %1:_(s64) = G_CONSTANT i64 4
43 %2:_(s64) = G_CONSTANT i64 12
44 %3:_(p0) = G_PTR_ADD %0(p0), %1
45 %4:_(p0) = G_PTR_ADD %3(p0), %2
46 %5:_(p0) = G_PTR_ADD %4(p0), %2
48 RET_ReallyLR implicit $x0
51 name: ptradd_chain_lookthough
52 tracksRegLiveness: true
56 ; CHECK-LABEL: name: ptradd_chain_lookthough
58 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
59 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 28
60 ; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
61 ; CHECK: $x0 = COPY [[PTR_ADD]](p0)
62 ; CHECK: RET_ReallyLR implicit $x0
64 %1:_(s64) = G_CONSTANT i64 4
65 %2:_(s64) = G_CONSTANT i64 12
66 %6:_(s32) = G_TRUNC %2(s64)
67 %7:_(s64) = G_SEXT %6(s32)
68 %3:_(p0) = G_PTR_ADD %0(p0), %1
69 %4:_(p0) = G_PTR_ADD %3(p0), %2
70 %5:_(p0) = G_PTR_ADD %4(p0), %7
72 RET_ReallyLR implicit $x0
75 name: ptradd_would_form_illegal_load_addressing
76 tracksRegLiveness: true
81 ; CHECK-LABEL: name: ptradd_would_form_illegal_load_addressing
83 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
84 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
85 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4096
86 ; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
87 ; CHECK: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTR_ADD]], [[C1]](s64)
88 ; CHECK: %ld:_(s64) = G_LOAD [[PTR_ADD1]](p0) :: (load (s64))
89 ; CHECK: %ld_other:_(s64) = G_LOAD [[PTR_ADD]](p0) :: (load (s64))
90 ; CHECK: $x0 = COPY %ld(s64)
91 ; CHECK: $x1 = COPY %ld_other(s64)
92 ; CHECK: RET_ReallyLR implicit $x0
94 %1:_(s64) = G_CONSTANT i64 4
95 %2:_(s64) = G_CONSTANT i64 4096
96 %3:_(p0) = G_PTR_ADD %0(p0), %1
97 %4:_(p0) = G_PTR_ADD %3(p0), %2
98 %ld:_(s64) = G_LOAD %4(p0) :: (load 8)
99 %ld_other:_(s64) = G_LOAD %3(p0) :: (load 8)
101 $x1 = COPY %ld_other(s64)
102 RET_ReallyLR implicit $x0