summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/alias-static-alloca.ll
diff options
context:
space:
mode:
authorNirav Dave <niravd@google.com>2017-07-10 15:39:41 +0000
committerNirav Dave <niravd@google.com>2017-07-10 15:39:41 +0000
commit163e1ad9dcfe6113ddf0cc8d73976dfc5db17ebe (patch)
tree25f67898c4cbac749b00a0485aca16cb5f5658d4 /llvm/test/CodeGen/X86/alias-static-alloca.ll
parent7cd7c1a7b50abcc729ddffa0e5654c343e7b03f7 (diff)
downloadbcm5719-llvm-163e1ad9dcfe6113ddf0cc8d73976dfc5db17ebe.tar.gz
bcm5719-llvm-163e1ad9dcfe6113ddf0cc8d73976dfc5db17ebe.zip
[DAG] Improve Aliasing of operations to static alloca
Memory accesses offset from frame indices may alias, e.g., we may merge write from function arguments passed on the stack when they are contiguous. As a result, when checking aliasing, we consider the underlying frame index's offset from the stack pointer. Static allocs are realized as stack objects in SelectionDAG, but its offset is not set until post-DAG causing DAGCombiner's alias check to consider access to static allocas to frequently alias. Modify isAlias to consider access between static allocas and access from other frame objects to be considered aliasing. Many test changes are included here. Most are fixes for tests which indirectly relied on our aliasing ability and needed to be modified to preserve their original intent. The remaining tests have minor improvements due to relaxed ordering. The exception is CodeGen/X86/2011-10-19-widen_vselect.ll which has a minor degradation dispite though the pre-legalized DAG is improved. Reviewers: rnk, mkuper, jonpa, hfinkel, uweigand Reviewed By: rnk Subscribers: sdardis, nemanjai, javed.absar, llvm-commits Differential Revision: https://reviews.llvm.org/D33345 llvm-svn: 307546
Diffstat (limited to 'llvm/test/CodeGen/X86/alias-static-alloca.ll')
-rw-r--r--llvm/test/CodeGen/X86/alias-static-alloca.ll37
1 files changed, 37 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/alias-static-alloca.ll b/llvm/test/CodeGen/X86/alias-static-alloca.ll
new file mode 100644
index 00000000000..f4ca7e39f4f
--- /dev/null
+++ b/llvm/test/CodeGen/X86/alias-static-alloca.ll
@@ -0,0 +1,37 @@
+; RUN: llc -o - -mtriple=x86_64-linux-gnu %s | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; We should be able to bypass the load values to their corresponding
+; stores here.
+
+; CHECK-LABEL: foo
+; CHECK-DAG: movl %esi, -8(%rsp)
+; CHECK-DAG: movl %ecx, -16(%rsp)
+; CHECK-DAG: movl %edi, -4(%rsp)
+; CHECK-DAG: movl %edx, -12(%rsp)
+; CHECK: leal
+; CHECK: addl
+; CHECK: addl
+; CHECK: retq
+
+define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d) {
+entry:
+ %a0 = alloca i32
+ %a1 = alloca i32
+ %a2 = alloca i32
+ %a3 = alloca i32
+ store i32 %b, i32* %a1
+ store i32 %d, i32* %a3
+ store i32 %a, i32* %a0
+ store i32 %c, i32* %a2
+ %l0 = load i32, i32* %a0
+ %l1 = load i32, i32* %a1
+ %l2 = load i32, i32* %a2
+ %l3 = load i32, i32* %a3
+ %add0 = add nsw i32 %l0, %l1
+ %add1 = add nsw i32 %add0, %l2
+ %add2 = add nsw i32 %add1, %l3
+ ret i32 %add2
+}
OpenPOWER on IntegriCloud