[llvm] 2c1789b - [AArch64][GlobalISel] Add ptradd_immed_chain combine to post-legalizer combiner.
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 11 13:59:29 PDT 2021
Author: Amara Emerson
Date: 2021-08-11T13:59:23-07:00
New Revision: 2c1789bc8cfb0ff4884c5b68736eabc36d3c64cd
URL: https://github.com/llvm/llvm-project/commit/2c1789bc8cfb0ff4884c5b68736eabc36d3c64cd
DIFF: https://github.com/llvm/llvm-project/commit/2c1789bc8cfb0ff4884c5b68736eabc36d3c64cd.diff
LOG: [AArch64][GlobalISel] Add ptradd_immed_chain combine to post-legalizer combiner.
Added:
llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-combine-ptr-add-chain.mir
Modified:
llvm/lib/Target/AArch64/AArch64Combine.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64Combine.td b/llvm/lib/Target/AArch64/AArch64Combine.td
index d938008a1e071..75ec7565b5695 100644
--- a/llvm/lib/Target/AArch64/AArch64Combine.td
+++ b/llvm/lib/Target/AArch64/AArch64Combine.td
@@ -212,6 +212,7 @@ def AArch64PostLegalizerCombinerHelper
form_bitfield_extract, rotate_out_of_range,
icmp_to_true_false_known_bits, merge_unmerge,
select_combines, fold_merge_to_zext,
- constant_fold, identity_combines]> {
+ constant_fold, identity_combines,
+ ptr_add_immed_chain]> {
let DisableRuleOption = "aarch64postlegalizercombiner-disable-rule";
}
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-combine-ptr-add-chain.mir b/llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-combine-ptr-add-chain.mir
new file mode 100644
index 0000000000000..53338f9f419d0
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-combine-ptr-add-chain.mir
@@ -0,0 +1,28 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# 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
+# REQUIRES: asserts
+
+# Check that we fold two adds of constant offsets with G_PTR_ADD into a single G_PTR_ADD.
+---
+name: ptradd_chain
+tracksRegLiveness: true
+legalized: true
+body: |
+ bb.1:
+ liveins: $x0
+
+ ; CHECK-LABEL: name: ptradd_chain
+ ; CHECK: liveins: $x0
+ ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
+ ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
+ ; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
+ ; CHECK: $x0 = COPY [[PTR_ADD]](p0)
+ ; CHECK: RET_ReallyLR implicit $x0
+ %0:_(p0) = COPY $x0
+ %1:_(s64) = G_CONSTANT i64 4
+ %2:_(s64) = G_CONSTANT i64 12
+ %3:_(p0) = G_PTR_ADD %0(p0), %1
+ %4:_(p0) = G_PTR_ADD %3(p0), %2
+ $x0 = COPY %4(p0)
+ RET_ReallyLR implicit $x0
+...
More information about the llvm-commits
mailing list