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 3 4# Check that we fold two adds of constant offsets with G_PTR_ADD into a single G_PTR_ADD. 5--- 6name: ptradd_chain 7tracksRegLiveness: true 8body: | 9 bb.1: 10 liveins: $x0 11 12 ; CHECK-LABEL: name: ptradd_chain 13 ; CHECK: liveins: $x0 14 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0 15 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16 16 ; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64) 17 ; CHECK: $x0 = COPY [[PTR_ADD]](p0) 18 ; CHECK: RET_ReallyLR implicit $x0 19 %0:_(p0) = COPY $x0 20 %1:_(s64) = G_CONSTANT i64 4 21 %2:_(s64) = G_CONSTANT i64 12 22 %3:_(p0) = G_PTR_ADD %0(p0), %1 23 %4:_(p0) = G_PTR_ADD %3(p0), %2 24 $x0 = COPY %4(p0) 25 RET_ReallyLR implicit $x0 26... 27--- 28name: ptradd_chain_2 29tracksRegLiveness: true 30body: | 31 bb.1: 32 liveins: $x0 33 ; CHECK-LABEL: name: ptradd_chain_2 34 ; CHECK: liveins: $x0 35 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0 36 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 28 37 ; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64) 38 ; CHECK: $x0 = COPY [[PTR_ADD]](p0) 39 ; CHECK: RET_ReallyLR implicit $x0 40 %0:_(p0) = COPY $x0 41 %1:_(s64) = G_CONSTANT i64 4 42 %2:_(s64) = G_CONSTANT i64 12 43 %3:_(p0) = G_PTR_ADD %0(p0), %1 44 %4:_(p0) = G_PTR_ADD %3(p0), %2 45 %5:_(p0) = G_PTR_ADD %4(p0), %2 46 $x0 = COPY %5(p0) 47 RET_ReallyLR implicit $x0 48... 49--- 50name: ptradd_chain_lookthough 51tracksRegLiveness: true 52body: | 53 bb.1: 54 liveins: $x0 55 ; CHECK-LABEL: name: ptradd_chain_lookthough 56 ; CHECK: liveins: $x0 57 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0 58 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 28 59 ; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64) 60 ; CHECK: $x0 = COPY [[PTR_ADD]](p0) 61 ; CHECK: RET_ReallyLR implicit $x0 62 %0:_(p0) = COPY $x0 63 %1:_(s64) = G_CONSTANT i64 4 64 %2:_(s64) = G_CONSTANT i64 12 65 %6:_(s32) = G_TRUNC %2(s64) 66 %7:_(s64) = G_SEXT %6(s32) 67 %3:_(p0) = G_PTR_ADD %0(p0), %1 68 %4:_(p0) = G_PTR_ADD %3(p0), %2 69 %5:_(p0) = G_PTR_ADD %4(p0), %7 70 $x0 = COPY %5(p0) 71 RET_ReallyLR implicit $x0 72... 73