diff options
Diffstat (limited to 'llvm/test/Transforms/TailCallElim/reorder_load.ll')
| -rw-r--r-- | llvm/test/Transforms/TailCallElim/reorder_load.ll | 27 | 
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/test/Transforms/TailCallElim/reorder_load.ll b/llvm/test/Transforms/TailCallElim/reorder_load.ll index 2f9b692d099..78621b105f5 100644 --- a/llvm/test/Transforms/TailCallElim/reorder_load.ll +++ b/llvm/test/Transforms/TailCallElim/reorder_load.ll @@ -7,6 +7,7 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"  ; then eliminate the tail recursion. +  @global = external global i32		; <i32*> [#uses=1]  @extern_weak_global = extern_weak global i32		; <i32*> [#uses=1] @@ -145,3 +146,29 @@ else:		; preds = %entry  	%tmp10 = add i32 %tmp9, %tmp8		; <i32> [#uses=1]  	ret i32 %tmp10  } + +; This load can be moved above the call because the function call does not write to the memory the load +; is accessing and the load is safe to speculate. +define fastcc i32 @raise_load_6(i32* %a_arg, i32 %a_len_arg, i32 %start_arg) nounwind  { +; CHECK-LABEL: @raise_load_6( +; CHECK-NOT: call +; CHECK: load i32, i32* +; CHECK-NOT: call +; CHECK: } +entry: +  %s = alloca i32 +  store i32 4, i32* %s +	%tmp2 = icmp sge i32 %start_arg, %a_len_arg		; <i1> [#uses=1] +	br i1 %tmp2, label %if, label %else + +if:		; preds = %entry +  store i32 1, i32* %a_arg +	ret i32 0 + +else:		; preds = %entry +	%tmp7 = add i32 %start_arg, 1		; <i32> [#uses=1] +	%tmp8 = call fastcc i32 @raise_load_6(i32* %a_arg, i32 %a_len_arg, i32 %tmp7)		; <i32> [#uses=1] +	%tmp9 = load i32, i32* %s		; <i32> [#uses=1] +	%tmp10 = add i32 %tmp9, %tmp8		; <i32> [#uses=1] +	ret i32 %tmp10 +}  | 

