summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2016-10-17 12:54:07 +0000
committerJames Molloy <james.molloy@arm.com>2016-10-17 12:54:07 +0000
commitaa79b19a3e8ba5099f6fb5843e7e8cd3f44bd5ef (patch)
tree4051488e7e83fe93dbfda20e32f9934488606484
parentecbcd7ca11005fbb8a314d92b7abc79750a78274 (diff)
downloadbcm5719-llvm-aa79b19a3e8ba5099f6fb5843e7e8cd3f44bd5ef.tar.gz
bcm5719-llvm-aa79b19a3e8ba5099f6fb5843e7e8cd3f44bd5ef.zip
[SDAG] Use ABI type alignment for constant pools when optimizing for size
SelectionDAG::getConstantPool will automatically determine an appropriate alignment if one is not specified. It does this by querying the type's preferred alignment. This can end up creating quite a lot of padding when the preferred alignment for vectors is 128. In optimize-for-size mode, it makes sense to instead query the ABI type alignment which is often smaller and causes less padding. llvm-svn: 284381
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp4
-rw-r--r--llvm/test/CodeGen/ARM/constantpool-align.ll19
2 files changed, 22 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 19fae7fa748..7cca214da49 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1315,7 +1315,9 @@ SDValue SelectionDAG::getConstantPool(const Constant *C, EVT VT,
assert((TargetFlags == 0 || isTarget) &&
"Cannot set target flags on target-independent globals");
if (Alignment == 0)
- Alignment = getDataLayout().getPrefTypeAlignment(C->getType());
+ Alignment = MF->getFunction()->optForSize()
+ ? getDataLayout().getABITypeAlignment(C->getType())
+ : getDataLayout().getPrefTypeAlignment(C->getType());
unsigned Opc = isTarget ? ISD::TargetConstantPool : ISD::ConstantPool;
FoldingSetNodeID ID;
AddNodeIDNode(ID, Opc, getVTList(VT), None);
diff --git a/llvm/test/CodeGen/ARM/constantpool-align.ll b/llvm/test/CodeGen/ARM/constantpool-align.ll
new file mode 100644
index 00000000000..1815b87469b
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/constantpool-align.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s | FileCheck %s
+target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+target triple = "thumbv7-arm-none-eabi"
+
+; CHECK-LABEL: f:
+; CHECK: vld1.64 {{.*}}, [r1:128]
+; CHECK: .p2align 4
+define void @f(<4 x i32>* %p) {
+ store <4 x i32> <i32 -1, i32 0, i32 0, i32 -1>, <4 x i32>* %p, align 4
+ ret void
+}
+
+; CHECK-LABEL: f_optsize:
+; CHECK: vld1.64 {{.*}}, [r1]
+; CHECK: .p2align 3
+define void @f_optsize(<4 x i32>* %p) optsize {
+ store <4 x i32> <i32 -1, i32 0, i32 0, i32 -1>, <4 x i32>* %p, align 4
+ ret void
+}
OpenPOWER on IntegriCloud