diff options
Diffstat (limited to 'test/Transforms/InstCombine')
-rw-r--r-- | test/Transforms/InstCombine/alloca.ll | 20 | ||||
-rw-r--r-- | test/Transforms/InstCombine/badmalloc.ll | 1 | ||||
-rw-r--r-- | test/Transforms/InstCombine/call.ll | 4 | ||||
-rw-r--r-- | test/Transforms/InstCombine/cast.ll | 11 | ||||
-rw-r--r-- | test/Transforms/InstCombine/crash.ll | 6 | ||||
-rw-r--r-- | test/Transforms/InstCombine/getelementptr.ll | 9 | ||||
-rw-r--r-- | test/Transforms/InstCombine/icmp.ll | 23 | ||||
-rw-r--r-- | test/Transforms/InstCombine/load.ll | 11 | ||||
-rw-r--r-- | test/Transforms/InstCombine/load2.ll | 11 | ||||
-rw-r--r-- | test/Transforms/InstCombine/load3.ll | 33 | ||||
-rw-r--r-- | test/Transforms/InstCombine/malloc-free-delete.ll | 20 | ||||
-rw-r--r-- | test/Transforms/InstCombine/select.ll | 32 |
12 files changed, 148 insertions, 33 deletions
diff --git a/test/Transforms/InstCombine/alloca.ll b/test/Transforms/InstCombine/alloca.ll index b9add4d..e4d1367 100644 --- a/test/Transforms/InstCombine/alloca.ll +++ b/test/Transforms/InstCombine/alloca.ll @@ -1,12 +1,13 @@ -; Zero byte allocas should be deleted. 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" -; RUN: opt < %s -instcombine -S | \ -; RUN: not grep alloca +; RUN: opt < %s -instcombine -S | FileCheck %s ; END. declare void @use(...) +; Zero byte allocas should be deleted. +; CHECK: @test +; CHECK-NOT: alloca define void @test() { %X = alloca [0 x i32] ; <[0 x i32]*> [#uses=1] call void (...)* @use( [0 x i32]* %X ) @@ -17,12 +18,18 @@ define void @test() { ret void } +; Zero byte allocas should be deleted. +; CHECK: @test2 +; CHECK-NOT: alloca define void @test2() { %A = alloca i32 ; <i32*> [#uses=1] store i32 123, i32* %A ret void } +; Zero byte allocas should be deleted. +; CHECK: @test3 +; CHECK-NOT: alloca define void @test3() { %A = alloca { i32 } ; <{ i32 }*> [#uses=1] %B = getelementptr { i32 }* %A, i32 0, i32 0 ; <i32*> [#uses=1] @@ -30,3 +37,10 @@ define void @test3() { ret void } +; CHECK: @test4 +; CHECK: = zext i32 %n to i64 +; CHECK: %A = alloca i32, i64 % +define i32* @test4(i32 %n) { + %A = alloca i32, i32 %n + ret i32* %A +} diff --git a/test/Transforms/InstCombine/badmalloc.ll b/test/Transforms/InstCombine/badmalloc.ll index cab23b5..f5a623d 100644 --- a/test/Transforms/InstCombine/badmalloc.ll +++ b/test/Transforms/InstCombine/badmalloc.ll @@ -10,6 +10,7 @@ declare void @free(i8*) define i1 @test1() { %A = call noalias i8* @malloc(i64 4) nounwind %B = icmp eq i8* %A, null + store i8 0, i8* %A call void @free(i8* %A) ret i1 %B diff --git a/test/Transforms/InstCombine/call.ll b/test/Transforms/InstCombine/call.ll index dd65b96..c256724 100644 --- a/test/Transforms/InstCombine/call.ll +++ b/test/Transforms/InstCombine/call.ll @@ -100,7 +100,7 @@ define void @test7() { declare void @test8a() define i8* @test8() { - invoke arm_apcscc void @test8a() + invoke void @test8a() to label %invoke.cont unwind label %try.handler invoke.cont: ; preds = %entry @@ -114,5 +114,5 @@ try.handler: ; preds = %entry ; calling conv, but the implementation of test8a may actually end up using the ; right calling conv. ; CHECK: @test8() { -; CHECK-NEXT: invoke arm_apcscc void @test8a() +; CHECK-NEXT: invoke void @test8a() diff --git a/test/Transforms/InstCombine/cast.ll b/test/Transforms/InstCombine/cast.ll index 77fccdf..102d2f0 100644 --- a/test/Transforms/InstCombine/cast.ll +++ b/test/Transforms/InstCombine/cast.ll @@ -638,3 +638,14 @@ define <4 x i32> @test62(<3 x float> %call4) nounwind { ; CHECK-NEXT: ret } +; PR7311 - Don't create invalid IR on scalar->vector cast. +define <2 x float> @test63(i64 %tmp8) nounwind { +entry: + %a = bitcast i64 %tmp8 to <2 x i32> + %vcvt.i = uitofp <2 x i32> %a to <2 x float> + ret <2 x float> %vcvt.i +; CHECK: @test63 +; CHECK: bitcast +; CHECK: uitofp +} + diff --git a/test/Transforms/InstCombine/crash.ll b/test/Transforms/InstCombine/crash.ll index 854bfc8..30d467e 100644 --- a/test/Transforms/InstCombine/crash.ll +++ b/test/Transforms/InstCombine/crash.ll @@ -127,11 +127,11 @@ l10: } ; PR5471 -define arm_apcscc i32 @test5a() { +define i32 @test5a() { ret i32 0 } -define arm_apcscc void @test5() { +define void @test5() { store i1 true, i1* undef %1 = invoke i32 @test5a() to label %exit unwind label %exit exit: @@ -212,7 +212,7 @@ define i8* @test10(i8* %self, i8* %tmp3) { entry: store i1 true, i1* undef store i1 true, i1* undef - invoke arm_apcscc void @test10a() + invoke void @test10a() to label %invoke.cont unwind label %try.handler ; <i8*> [#uses=0] invoke.cont: ; preds = %entry diff --git a/test/Transforms/InstCombine/getelementptr.ll b/test/Transforms/InstCombine/getelementptr.ll index f0bee4e..9e8547b 100644 --- a/test/Transforms/InstCombine/getelementptr.ll +++ b/test/Transforms/InstCombine/getelementptr.ll @@ -468,3 +468,12 @@ define i1 @test37() nounwind { getelementptr ([1 x i8]* @A37, i64 1, i64 0) ret i1 %t } + +; Test index promotion +define i32* @test38(i32* %I, i32 %n) { + %A = getelementptr i32* %I, i32 %n + ret i32* %A +; CHECK: @test38 +; CHECK: = sext i32 %n to i64 +; CHECK: %A = getelementptr i32* %I, i64 % +} diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll index 29997bf..802957f 100644 --- a/test/Transforms/InstCombine/icmp.ll +++ b/test/Transforms/InstCombine/icmp.ll @@ -131,3 +131,26 @@ entry: ; CHECK: ret i1 false } +define i1 @test14(i8 %X) nounwind readnone { +entry: + %cmp = icmp slt i8 undef, -128 + ret i1 %cmp +; CHECK: @test14 +; CHECK: ret i1 false +} + +define i1 @test15() nounwind readnone { +entry: + %cmp = icmp eq i8 undef, -128 + ret i1 %cmp +; CHECK: @test15 +; CHECK: ret i1 undef +} + +define i1 @test16() nounwind readnone { +entry: + %cmp = icmp ne i8 undef, -128 + ret i1 %cmp +; CHECK: @test16 +; CHECK: ret i1 undef +} diff --git a/test/Transforms/InstCombine/load.ll b/test/Transforms/InstCombine/load.ll index 75c62a8..d11e08e 100644 --- a/test/Transforms/InstCombine/load.ll +++ b/test/Transforms/InstCombine/load.ll @@ -7,6 +7,9 @@ @Y = constant [2 x { i32, float }] [ { i32, float } { i32 12, float 1.000000e+00 }, { i32, float } { i32 37, float 0x3FF3B2FEC0000000 } ] ; <[2 x { i32, float }]*> [#uses=2] @Z = constant [2 x { i32, float }] zeroinitializer ; <[2 x { i32, float }]*> [#uses=1] +@GLOBAL = internal constant [4 x i32] zeroinitializer + + define i32 @test1() { %B = load i32* @X ; <i32> [#uses=1] ret i32 %B @@ -85,3 +88,11 @@ define i32 @test12(i32* %P) { %V = load i32* %Q ret i32 %V } + +define <16 x i8> @test13(<2 x i64> %x) { +entry: + %tmp = load <16 x i8> * bitcast ([4 x i32]* @GLOBAL to <16 x i8>*) + ret <16 x i8> %tmp +} + + diff --git a/test/Transforms/InstCombine/load2.ll b/test/Transforms/InstCombine/load2.ll deleted file mode 100644 index 611b0fb..0000000 --- a/test/Transforms/InstCombine/load2.ll +++ /dev/null @@ -1,11 +0,0 @@ -; RUN: opt < %s -instcombine -S | not grep load - -@GLOBAL = internal constant [4 x i32] zeroinitializer - - -define <16 x i8> @foo(<2 x i64> %x) { -entry: - %tmp = load <16 x i8> * bitcast ([4 x i32]* @GLOBAL to <16 x i8>*) - ret <16 x i8> %tmp -} - diff --git a/test/Transforms/InstCombine/load3.ll b/test/Transforms/InstCombine/load3.ll index 9c87316..35398e1 100644 --- a/test/Transforms/InstCombine/load3.ll +++ b/test/Transforms/InstCombine/load3.ll @@ -1,14 +1,27 @@ -; RUN: opt < %s -instcombine -S | grep load | count 1 +; RUN: opt < %s -instcombine -S | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-apple-darwin10.0.0" ; Instcombine should be able to do trivial CSE of loads. -declare void @use(double %n) -define void @bar(double* %p) { - %t0 = getelementptr double* %p, i32 1 - %y = load double* %t0 - %t1 = getelementptr double* %p, i32 1 - %x = load double* %t1 - call void @use(double %x) - call void @use(double %y) - ret void +define i32 @test1(i32* %p) { + %t0 = getelementptr i32* %p, i32 1 + %y = load i32* %t0 + %t1 = getelementptr i32* %p, i32 1 + %x = load i32* %t1 + %a = sub i32 %y, %x + ret i32 %a +; CHECK: @test1 +; CHECK: ret i32 0 } + + +; PR7429 +@.str = private constant [4 x i8] c"XYZ\00" +define float @test2() { + %tmp = load float* bitcast ([4 x i8]* @.str to float*), align 1 + ret float %tmp + +; CHECK: @test2 +; CHECK: ret float 0x3806965600000000 +}
\ No newline at end of file diff --git a/test/Transforms/InstCombine/malloc-free-delete.ll b/test/Transforms/InstCombine/malloc-free-delete.ll index a4b7496..317786f 100644 --- a/test/Transforms/InstCombine/malloc-free-delete.ll +++ b/test/Transforms/InstCombine/malloc-free-delete.ll @@ -1,13 +1,25 @@ -; RUN: opt < %s -instcombine -globaldce -S | FileCheck %s +; RUN: opt < %s -instcombine -S | FileCheck %s ; PR1201 define i32 @main(i32 %argc, i8** %argv) { - %c_19 = alloca i8* ; <i8**> [#uses=2] - %malloc_206 = malloc i8, i32 10 ; <i8*> [#uses=1] + %c_19 = alloca i8* + %malloc_206 = malloc i8, i32 10 ; CHECK-NOT: malloc store i8* %malloc_206, i8** %c_19 - %tmp_207 = load i8** %c_19 ; <i8*> [#uses=1] + %tmp_207 = load i8** %c_19 free i8* %tmp_207 ; CHECK-NOT: free ret i32 0 ; CHECK: ret i32 0 } + +declare i8* @malloc(i32) +declare void @free(i8*) + +define i1 @foo() { +; CHECK: @foo +; CHECK-NEXT: ret i1 false + %m = call i8* @malloc(i32 1) + %z = icmp eq i8* %m, null + call void @free(i8* %m) + ret i1 %z +} diff --git a/test/Transforms/InstCombine/select.ll b/test/Transforms/InstCombine/select.ll index 06d5338..246a7bc 100644 --- a/test/Transforms/InstCombine/select.ll +++ b/test/Transforms/InstCombine/select.ll @@ -438,3 +438,35 @@ define i32 @test34(i32 %x, i32 %y) { ; CHECK: @test34 ; CHECK: ret i32 %x } + +define i32 @test35(i32 %x) { + %cmp = icmp sge i32 %x, 0 + %cond = select i1 %cmp, i32 60, i32 100 + ret i32 %cond +; CHECK: @test35 +; CHECK: ashr i32 %x, 31 +; CHECK: and i32 {{.*}}, 40 +; CHECK: add i32 {{.*}}, 60 +; CHECK: ret +} + +define i32 @test36(i32 %x) { + %cmp = icmp slt i32 %x, 0 + %cond = select i1 %cmp, i32 60, i32 100 + ret i32 %cond +; CHECK: @test36 +; CHECK: ashr i32 %x, 31 +; CHECK: and i32 {{.*}}, -40 +; CHECK: add i32 {{.*}}, 100 +; CHECK: ret +} + +define i32 @test37(i32 %x) { + %cmp = icmp sgt i32 %x, -1 + %cond = select i1 %cmp, i32 1, i32 -1 + ret i32 %cond +; CHECK: @test37 +; CHECK: ashr i32 %x, 31 +; CHECK: or i32 {{.*}}, 1 +; CHECK: ret +} |