convert scalar_promote to filecheck style and merge 2003-12-13-VolatilePromote.ll into it.

llvm-svn: 80521
This commit is contained in:
Chris Lattner 2009-08-30 22:08:19 +00:00
parent b284f7b1d9
commit 362654f51c
2 changed files with 45 additions and 23 deletions

View File

@ -1,16 +0,0 @@
; RUN: llvm-as < %s | opt -licm | llvm-dis | %prcontext volatile 1 | grep Loop
@X = global i32 7 ; <i32*> [#uses=2]
define void @testfunc(i32 %i) {
br label %Loop
Loop: ; preds = %Loop, %0
; Should not promote this to a register
%x = volatile load i32* @X ; <i32> [#uses=1]
%x2 = add i32 %x, 1 ; <i32> [#uses=1]
store i32 %x2, i32* @X
br i1 true, label %Out, label %Loop
Out: ; preds = %Loop
ret void
}

View File

@ -1,13 +1,17 @@
; RUN: llvm-as < %s | opt -licm -disable-output -stats |& \ ; RUN: llvm-as < %s | opt -licm | llvm-dis | FileCheck %s
; RUN: grep {memory locations promoted to register}
@X = global i32 7 ; <i32*> [#uses=4] @X = global i32 7 ; <i32*> [#uses=4]
define void @testfunc(i32 %i) { define void @test1(i32 %i) {
; <label>:0 Entry:
br label %Loop br label %Loop
; CHECK: @test1
; CHECK: Entry:
; CHECK-NEXT: load i32* @X
; CHECK-NEXT: br label %Loop
Loop: ; preds = %Loop, %0 Loop: ; preds = %Loop, %0
%j = phi i32 [ 0, %0 ], [ %Next, %Loop ] ; <i32> [#uses=1] %j = phi i32 [ 0, %Entry ], [ %Next, %Loop ] ; <i32> [#uses=1]
%x = load i32* @X ; <i32> [#uses=1] %x = load i32* @X ; <i32> [#uses=1]
%x2 = add i32 %x, 1 ; <i32> [#uses=1] %x2 = add i32 %x, 1 ; <i32> [#uses=1]
store i32 %x2, i32* @X store i32 %x2, i32* @X
@ -15,12 +19,23 @@ Loop: ; preds = %Loop, %0
%cond = icmp eq i32 %Next, 0 ; <i1> [#uses=1] %cond = icmp eq i32 %Next, 0 ; <i1> [#uses=1]
br i1 %cond, label %Out, label %Loop br i1 %cond, label %Out, label %Loop
Out: ; preds = %Loop Out:
ret void ret void
; CHECK: Out:
; CHECK-NEXT: store i32 %x2, i32* @X
; CHECK-NEXT: ret void
} }
define void @testhard(i32 %i) { define void @test2(i32 %i) {
Entry:
br label %Loop br label %Loop
; CHECK: @test2
; CHECK: Entry:
; CHECK-NEXT: %X1 = getelementptr i32* @X, i64 0
; CHECK-NEXT: %X2 = getelementptr i32* @X, i64 0
; CHECK-NEXT: %X1.promoted = load i32* %X1
; CHECK-NEXT: br label %Loop
Loop: ; preds = %Loop, %0 Loop: ; preds = %Loop, %0
%X1 = getelementptr i32* @X, i64 0 ; <i32*> [#uses=1] %X1 = getelementptr i32* @X, i64 0 ; <i32*> [#uses=1]
@ -32,4 +47,27 @@ Loop: ; preds = %Loop, %0
Exit: ; preds = %Loop Exit: ; preds = %Loop
ret void ret void
; CHECK: Exit:
; CHECK-NEXT: store i32 %V, i32* %X1
; CHECK-NEXT: ret void
} }
define void @test3(i32 %i) {
; CHECK: @test3
br label %Loop
Loop:
; Should not promote this to a register
%x = volatile load i32* @X
%x2 = add i32 %x, 1
store i32 %x2, i32* @X
br i1 true, label %Out, label %Loop
; CHECK: Loop:
; CHECK-NEXT: volatile load
Out: ; preds = %Loop
ret void
}