diff options
author | Bob Wilson <bob.wilson@apple.com> | 2010-01-30 04:42:39 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2010-01-30 04:42:39 +0000 |
commit | 49db68fba01722ca032dc5170f8248a9d25f0199 (patch) | |
tree | 575e1422b433c1028bda1df8331249b35730b54d /test/Transforms | |
parent | a6bff982c10f6f19c0a9ba20a6300201449c5f39 (diff) | |
download | external_llvm-49db68fba01722ca032dc5170f8248a9d25f0199.zip external_llvm-49db68fba01722ca032dc5170f8248a9d25f0199.tar.gz external_llvm-49db68fba01722ca032dc5170f8248a9d25f0199.tar.bz2 |
Check alignment of loads when deciding whether it is safe to execute them
unconditionally. Besides checking the offset, also check that the underlying
object is aligned as much as the load itself.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94875 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r-- | test/Transforms/GVN/load-pre-align.ll | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/Transforms/GVN/load-pre-align.ll b/test/Transforms/GVN/load-pre-align.ll new file mode 100644 index 0000000..3a66c0b --- /dev/null +++ b/test/Transforms/GVN/load-pre-align.ll @@ -0,0 +1,44 @@ +; RUN: opt < %s -gvn -S | FileCheck %s + +target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:32-n32" + +@p = external global i32 + +define arm_apcscc i32 @test(i32 %n) nounwind { +; CHECK: @test +entry: + br label %for.cond + +; loads aligned greater than the memory should not be moved past conditionals +; CHECK-NOT: load +; CHECK: br i1 + +for.cond: + %i.0 = phi i32 [ 0, %entry ], [ %indvar.next, %for.inc ] + %cmp = icmp slt i32 %i.0, %n + br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge + +for.cond.for.end_crit_edge: +; ...but PRE can still move the load out of for.end to here. +; CHECK: for.cond.for.end_crit_edge: +; CHECK-NEXT: load + br label %for.end + +for.body: + %tmp3 = load i32* @p, align 8 + %dec = add i32 %tmp3, -1 + store i32 %dec, i32* @p + %cmp6 = icmp slt i32 %dec, 0 + br i1 %cmp6, label %for.body.for.end_crit_edge, label %for.inc + +for.body.for.end_crit_edge: + br label %for.end + +for.inc: + %indvar.next = add i32 %i.0, 1 + br label %for.cond + +for.end: + %tmp9 = load i32* @p, align 8 + ret i32 %tmp9 +} |