summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 53eeb67)
raw | patch | inline | side by side (parent: 53eeb67)
author | Richard Osborne <richard@xmos.com> | |
Tue, 25 Feb 2014 16:37:15 +0000 (16:37 +0000) | ||
committer | Richard Osborne <richard@xmos.com> | |
Tue, 25 Feb 2014 16:37:15 +0000 (16:37 +0000) |
The behaviour of the XCore's instruction buffer means that the performance
of the same code sequence can differ depending on whether it starts at a 4
byte aligned address or not. Since we don't model the instruction buffer
in the backend we have no way of knowing for sure if it is beneficial to
word align a specific function. However, in the absence of precise
modelling, it is better on balance to word align functions because:
* It makes a fetch-nop while executing the prologue slightly less likely.
* If we don't word align functions then a small perturbation in one
function can have a dramatic knock on effect. If the size of the function
changes it might change the alignment and therefore the performance of
all the functions that happen to follow it in the binary. This butterfly
effect makes it harder to reason about and measure the performance of
code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202163 91177308-0d34-0410-b5e6-96231b3b80d8
of the same code sequence can differ depending on whether it starts at a 4
byte aligned address or not. Since we don't model the instruction buffer
in the backend we have no way of knowing for sure if it is beneficial to
word align a specific function. However, in the absence of precise
modelling, it is better on balance to word align functions because:
* It makes a fetch-nop while executing the prologue slightly less likely.
* If we don't word align functions then a small perturbation in one
function can have a dramatic knock on effect. If the size of the function
changes it might change the alignment and therefore the performance of
all the functions that happen to follow it in the binary. This butterfly
effect makes it harder to reason about and measure the performance of
code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202163 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/XCore/XCoreISelLowering.cpp | patch | blob | history | |
test/CodeGen/XCore/align.ll | [new file with mode: 0644] | patch | blob |
index 842531c455d372267148ac4db4d4b37b59d4ca35..7af0165329f31631cba8590ffe43aed4cc2faf17 100644 (file)
setTargetDAGCombine(ISD::ADD);
setMinFunctionAlignment(1);
+ setPrefFunctionAlignment(2);
}
bool XCoreTargetLowering::isZExtFree(SDValue Val, EVT VT2) const {
diff --git a/test/CodeGen/XCore/align.ll b/test/CodeGen/XCore/align.ll
--- /dev/null
@@ -0,0 +1,15 @@
+; RUN: llc < %s -march=xcore | FileCheck %s
+
+; CHECK: .align 4
+; CHECK-LABEL: f:
+define void @f() nounwind {
+entry:
+ ret void
+}
+
+; CHECK: .align 2
+; CHECK-LABEL: g:
+define void @g() nounwind optsize {
+entry:
+ ret void
+}