[PATCH] D24857: [ARM] Assign cost of scaling used in addressing mode for ARM cores
Javed Absar via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 26 05:57:46 PDT 2016
javed.absar retitled this revision from "Assign cost of scaling used in addressing mode for ARM cores" to "[ARM] Assign cost of scaling used in addressing mode for ARM cores".
javed.absar updated this revision to Diff 72473.
javed.absar added a comment.
Hi James:
Thanks for the review and feedback.
I have made changes based on your comments:
1. Have reduced the scope to Cortex-A53 and Cortex-A57 where I can confirm the performance gains currently based on benchmark runs (results shared previously).
2. Have adjusted the cost from '2' to '1' as this is sufficient to differentiate.
Thanks
https://reviews.llvm.org/D24857
Files:
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/ARM/ARMISelLowering.h
lib/Target/ARM/ARMSubtarget.h
test/CodeGen/ARM/lsr-scale-addr-mode.ll
Index: test/CodeGen/ARM/lsr-scale-addr-mode.ll
===================================================================
--- test/CodeGen/ARM/lsr-scale-addr-mode.ll
+++ test/CodeGen/ARM/lsr-scale-addr-mode.ll
@@ -1,6 +1,10 @@
; RUN: llc -mtriple=arm-eabi %s -o - | FileCheck %s
; Should use scaled addressing mode.
+; RUN: llc -mtriple=arm-eabi -mcpu=cortex-a53 %s -o - | FileCheck %s -check-prefix CHECK-NONEGOFF-A53
+; RUN: llc -mtriple=arm-eabi -mcpu=cortex-a57 %s -o - | FileCheck %s -check-prefix CHECK-NONEGOFF-A57
+; Should not generate negated register offset
+
define void @sintzero(i32* %a) nounwind {
entry:
store i32 0, i32* %a
@@ -19,4 +23,6 @@
}
; CHECK: lsl{{.*}}#2]
+; CHECK-NONEGOFF-A53: [{{r[0-9]+}}, {{r[0-9]+}}, lsl{{.*}}#2]
+; CHECK-NONEGOFF-A57: [{{r[0-9]+}}, {{r[0-9]+}}, lsl{{.*}}#2]
Index: lib/Target/ARM/ARMSubtarget.h
===================================================================
--- lib/Target/ARM/ARMSubtarget.h
+++ lib/Target/ARM/ARMSubtarget.h
@@ -412,6 +412,8 @@
bool isCortexA8() const { return ARMProcFamily == CortexA8; }
bool isCortexA9() const { return ARMProcFamily == CortexA9; }
bool isCortexA15() const { return ARMProcFamily == CortexA15; }
+ bool isCortexA53() const { return ARMProcFamily == CortexA53; }
+ bool isCortexA57() const { return ARMProcFamily == CortexA57; }
bool isSwift() const { return ARMProcFamily == Swift; }
bool isCortexM3() const { return ARMProcFamily == CortexM3; }
bool isLikeA9() const { return isCortexA9() || isCortexA15() || isKrait(); }
Index: lib/Target/ARM/ARMISelLowering.h
===================================================================
--- lib/Target/ARM/ARMISelLowering.h
+++ lib/Target/ARM/ARMISelLowering.h
@@ -291,6 +291,14 @@
/// by AM is legal for this target, for a load/store of the specified type.
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
Type *Ty, unsigned AS) const override;
+
+ /// getScalingFactorCost - Return the cost of the scaling used in
+ /// addressing mode represented by AM.
+ /// If the AM is supported, the return value must be >= 0.
+ /// If the AM is not supported, the return value must be negative.
+ int getScalingFactorCost(const DataLayout &DL, const AddrMode &AM, Type *Ty,
+ unsigned AS) const override;
+
bool isLegalT2ScaledAddressingMode(const AddrMode &AM, EVT VT) const;
/// isLegalICmpImmediate - Return true if the specified immediate is legal
Index: lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- lib/Target/ARM/ARMISelLowering.cpp
+++ lib/Target/ARM/ARMISelLowering.cpp
@@ -11597,6 +11597,17 @@
return true;
}
+int ARMTargetLowering::getScalingFactorCost(const DataLayout &DL,
+ const AddrMode &AM, Type *Ty,
+ unsigned AS) const {
+ if (isLegalAddressingMode(DL, AM, Ty, AS)) {
+ if (Subtarget->isCortexA53() || Subtarget->isCortexA57())
+ return AM.Scale < 0 ? 1 : 0; // negative scaling costs extra cycles
+ return 0;
+ }
+ return -1;
+}
+
static bool isLegalT1AddressImmediate(int64_t V, EVT VT) {
if (V < 0)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24857.72473.patch
Type: text/x-patch
Size: 3280 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160926/2aeb6adc/attachment.bin>
More information about the llvm-commits
mailing list