Skip to content

Commit 2c1789b

Browse files
committed
[AArch64][GlobalISel] Add ptradd_immed_chain combine to post-legalizer combiner.
1 parent 643ce61 commit 2c1789b

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

llvm/lib/Target/AArch64/AArch64Combine.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ def AArch64PostLegalizerCombinerHelper
212212
form_bitfield_extract, rotate_out_of_range,
213213
icmp_to_true_false_known_bits, merge_unmerge,
214214
select_combines, fold_merge_to_zext,
215-
constant_fold, identity_combines]> {
215+
constant_fold, identity_combines,
216+
ptr_add_immed_chain]> {
216217
let DisableRuleOption = "aarch64postlegalizercombiner-disable-rule";
217218
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 --aarch64postlegalizercombinerhelper-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+
---
7+
name: ptradd_chain
8+
tracksRegLiveness: true
9+
legalized: true
10+
body: |
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+
...

0 commit comments

Comments
 (0)