xref: /llvm-project/llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-combine-ptr-add-chain.mir (revision 655714a300ff303a1f283718c34d9e27e096b319)
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -mtriple aarch64-apple-ios  -run-pass=aarch64-postlegalizer-combiner --aarch64postlegalizercombiner-only-enable-rule="ptr_add_immed_chain"  %s -o - -verify-machineinstrs | FileCheck %s
3# REQUIRES: asserts
4
5# Check that we fold two adds of constant offsets with G_PTR_ADD into a single G_PTR_ADD.
6---
7name: ptradd_chain
8tracksRegLiveness: true
9legalized: true
10body:             |
11  bb.1:
12    liveins: $x0
13
14    ; CHECK-LABEL: name: ptradd_chain
15    ; CHECK: liveins: $x0
16    ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
17    ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
18    ; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
19    ; CHECK: $x0 = COPY [[PTR_ADD]](p0)
20    ; CHECK: RET_ReallyLR implicit $x0
21    %0:_(p0) = COPY $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
26    $x0 = COPY %4(p0)
27    RET_ReallyLR implicit $x0
28...
29