diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2011-02-26 22:03:50 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2011-02-26 22:03:50 +0000 |
| commit | d0e4e96dc17a6c1c6de3340842c80f0e187ba349 (patch) | |
| tree | ddf53b8bd9235bcb0b8aae16c5e22310dcdad665 /test/Transforms | |
| parent | cf099d11218cb6f6c5cce947d6738e347f07fb12 (diff) | |
Notes
Diffstat (limited to 'test/Transforms')
| -rw-r--r-- | test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll | 12 | ||||
| -rw-r--r-- | test/Transforms/InstCombine/call.ll | 16 | ||||
| -rw-r--r-- | test/Transforms/InstCombine/or-xor.ll | 94 | ||||
| -rw-r--r-- | test/Transforms/LoopDeletion/multiple-exits.ll | 26 | ||||
| -rw-r--r-- | test/Transforms/SimplifyCFG/select-gep.ll | 40 |
5 files changed, 175 insertions, 13 deletions
diff --git a/test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll b/test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll deleted file mode 100644 index fdb8fd9363c6..000000000000 --- a/test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll +++ /dev/null @@ -1,12 +0,0 @@ -; RUN: opt < %s -instcombine -S | FileCheck %s -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" - -declare void @free(i8*) - -define void @test(i32* %X) { - call void (...)* bitcast (void (i8*)* @free to void (...)*)( i32* %X ) ; <i32>:1 [#uses=0] -; CHECK: %tmp = bitcast i32* %X to i8* -; CHECK: call void @free(i8* %tmp) - ret void -; CHECK: ret void -} diff --git a/test/Transforms/InstCombine/call.ll b/test/Transforms/InstCombine/call.ll index c256724a08ee..2ef8dc0670f0 100644 --- a/test/Transforms/InstCombine/call.ll +++ b/test/Transforms/InstCombine/call.ll @@ -32,7 +32,7 @@ define i32 @test2(i32 %A) { ; Resolving this should insert a cast from sbyte to int, following the C ; promotion rules. -declare void @test3a(i8, ...) +define void @test3a(i8, ...) {unreachable } define void @test3(i8 %A, i8 %B) { call void bitcast (void (i8, ...)* @test3a to void (i8, i8)*)( i8 %A, i8 %B @@ -116,3 +116,17 @@ try.handler: ; preds = %entry ; CHECK: @test8() { ; CHECK-NEXT: invoke void @test8a() + + +; Don't turn this into a direct call, because test9x is just a prototype and +; doing so will make it varargs. +; rdar://9038601 +declare i8* @test9x(i8*, i8*, ...) noredzone +define i8* @test9(i8* %arg, i8* %tmp3) nounwind ssp noredzone { +entry: + %call = call i8* bitcast (i8* (i8*, i8*, ...)* @test9x to i8* (i8*, i8*)*)(i8* %arg, i8* %tmp3) noredzone + ret i8* %call +; CHECK: @test9( +; CHECK: call i8* bitcast +} + diff --git a/test/Transforms/InstCombine/or-xor.ll b/test/Transforms/InstCombine/or-xor.ll new file mode 100644 index 000000000000..f496dd48c402 --- /dev/null +++ b/test/Transforms/InstCombine/or-xor.ll @@ -0,0 +1,94 @@ +; RUN: opt -S -instcombine < %s | FileCheck %s + +define i32 @test1(i32 %x, i32 %y) nounwind { + %or = or i32 %x, %y + %not = xor i32 %or, -1 + %z = or i32 %x, %not + ret i32 %z +; CHECK: @test1 +; CHECK-NEXT: %y.not = xor i32 %y, -1 +; CHECK-NEXT: %z = or i32 %y.not, %x +; CHECK-NEXT: ret i32 %z +} + +define i32 @test2(i32 %x, i32 %y) nounwind { + %or = or i32 %x, %y + %not = xor i32 %or, -1 + %z = or i32 %y, %not + ret i32 %z +; CHECK: @test2 +; CHECK-NEXT: %x.not = xor i32 %x, -1 +; CHECK-NEXT: %z = or i32 %x.not, %y +; CHECK-NEXT: ret i32 %z +} + +define i32 @test3(i32 %x, i32 %y) nounwind { + %xor = xor i32 %x, %y + %not = xor i32 %xor, -1 + %z = or i32 %x, %not + ret i32 %z +; CHECK: @test3 +; CHECK-NEXT: %y.not = xor i32 %y, -1 +; CHECK-NEXT: %z = or i32 %y.not, %x +; CHECK-NEXT: ret i32 %z +} + +define i32 @test4(i32 %x, i32 %y) nounwind { + %xor = xor i32 %x, %y + %not = xor i32 %xor, -1 + %z = or i32 %y, %not + ret i32 %z +; CHECK: @test4 +; CHECK-NEXT: %x.not = xor i32 %x, -1 +; CHECK-NEXT: %z = or i32 %x.not, %y +; CHECK-NEXT: ret i32 %z +} + +define i32 @test5(i32 %x, i32 %y) nounwind { + %and = and i32 %x, %y + %not = xor i32 %and, -1 + %z = or i32 %x, %not + ret i32 %z +; CHECK: @test5 +; CHECK-NEXT: ret i32 -1 +} + +define i32 @test6(i32 %x, i32 %y) nounwind { + %and = and i32 %x, %y + %not = xor i32 %and, -1 + %z = or i32 %y, %not + ret i32 %z +; CHECK: @test6 +; CHECK-NEXT: ret i32 -1 +} + +define i32 @test7(i32 %x, i32 %y) nounwind { + %xor = xor i32 %x, %y + %z = or i32 %y, %xor + ret i32 %z +; CHECK: @test7 +; CHECK-NEXT: %z = or i32 %x, %y +; CHECK-NEXT: ret i32 %z +} + +define i32 @test8(i32 %x, i32 %y) nounwind { + %not = xor i32 %y, -1 + %xor = xor i32 %x, %not + %z = or i32 %y, %xor + ret i32 %z +; CHECK: @test8 +; CHECK-NEXT: %x.not = xor i32 %x, -1 +; CHECK-NEXT: %z = or i32 %x.not, %y +; CHECK-NEXT: ret i32 %z +} + +define i32 @test9(i32 %x, i32 %y) nounwind { + %not = xor i32 %x, -1 + %xor = xor i32 %not, %y + %z = or i32 %x, %xor + ret i32 %z +; CHECK: @test9 +; CHECK-NEXT: %y.not = xor i32 %y, -1 +; CHECK-NEXT: %z = or i32 %y.not, %x +; CHECK-NEXT: ret i32 %z +} diff --git a/test/Transforms/LoopDeletion/multiple-exits.ll b/test/Transforms/LoopDeletion/multiple-exits.ll new file mode 100644 index 000000000000..6af413b49cd9 --- /dev/null +++ b/test/Transforms/LoopDeletion/multiple-exits.ll @@ -0,0 +1,26 @@ +; RUN: opt < %s -loop-deletion -S | FileCheck %s + +; Checks whether dead loops with multiple exits can be eliminated + +; CHECK: entry: +; CHECK-NEXT: br label %return + +; CHECK: return: +; CHECK-NEXT: ret void + +define void @foo(i64 %n, i64 %m) nounwind { +entry: + br label %bb + +bb: + %x.0 = phi i64 [ 0, %entry ], [ %t0, %bb2 ] + %t0 = add i64 %x.0, 1 + %t1 = icmp slt i64 %x.0, %n + br i1 %t1, label %bb2, label %return +bb2: + %t2 = icmp slt i64 %x.0, %m + br i1 %t1, label %bb, label %return + +return: + ret void +} diff --git a/test/Transforms/SimplifyCFG/select-gep.ll b/test/Transforms/SimplifyCFG/select-gep.ll new file mode 100644 index 000000000000..009f05e5574c --- /dev/null +++ b/test/Transforms/SimplifyCFG/select-gep.ll @@ -0,0 +1,40 @@ +; RUN: opt -S -simplifycfg %s | FileCheck %s + +define i8* @test1(i8* %x, i64 %y) nounwind { +entry: + %tmp1 = load i8* %x, align 1 + %cmp = icmp eq i8 %tmp1, 47 + br i1 %cmp, label %if.then, label %if.end + +if.then: + %incdec.ptr = getelementptr inbounds i8* %x, i64 %y + br label %if.end + +if.end: + %x.addr = phi i8* [ %incdec.ptr, %if.then ], [ %x, %entry ] + ret i8* %x.addr + +; CHECK: @test1 +; CHECK-NOT: select +; CHECK: ret i8* %x.addr +} + +%ST = type { i8, i8 } + +define i8* @test2(%ST* %x, i8* %y) nounwind { +entry: + %cmp = icmp eq %ST* %x, null + br i1 %cmp, label %if.then, label %if.end + +if.then: + %incdec.ptr = getelementptr %ST* %x, i32 0, i32 1 + br label %if.end + +if.end: + %x.addr = phi i8* [ %incdec.ptr, %if.then ], [ %y, %entry ] + ret i8* %x.addr + +; CHECK: @test2 +; CHECK: %x.addr = select i1 %cmp, i8* %incdec.ptr, i8* %y +; CHECK: ret i8* %x.addr +} |
