diff options
author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-23 14:19:52 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-23 14:19:52 +0000 |
commit | 4a142eb28942073eb27a112b5ca1cca3f01beb9c (patch) | |
tree | 22cc59e4b240d84c3a5a60531119c4eca914a256 /test/Transforms | |
parent | 5cd822fa9bbb9622241e3bf4d7674ed49ccde5b9 (diff) |
Diffstat (limited to 'test/Transforms')
-rw-r--r-- | test/Transforms/ConstProp/constant-expr.ll | 60 | ||||
-rw-r--r-- | test/Transforms/ConstProp/loads.ll | 89 | ||||
-rw-r--r-- | test/Transforms/GVN/calls-readonly.ll | 28 | ||||
-rw-r--r-- | test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll | 26 | ||||
-rw-r--r-- | test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll | 30 | ||||
-rw-r--r-- | test/Transforms/GlobalOpt/malloc-promote-2.ll | 4 | ||||
-rw-r--r-- | test/Transforms/GlobalOpt/malloc-promote-3.ll | 4 | ||||
-rw-r--r-- | test/Transforms/Inline/crash.ll | 33 | ||||
-rw-r--r-- | test/Transforms/InstCombine/cast.ll | 10 | ||||
-rw-r--r-- | test/Transforms/InstCombine/crash.ll | 83 | ||||
-rw-r--r-- | test/Transforms/InstCombine/getelementptr.ll | 2 | ||||
-rw-r--r-- | test/Transforms/InstCombine/malloc-free-delete.ll | 2 | ||||
-rw-r--r-- | test/Transforms/InstCombine/malloc2.ll | 7 | ||||
-rw-r--r-- | test/Transforms/InstCombine/malloc3.ll | 2 | ||||
-rw-r--r-- | test/Transforms/JumpThreading/crash.ll | 35 | ||||
-rw-r--r-- | test/Transforms/LoopSimplify/unreachable-loop-pred.ll | 20 | ||||
-rw-r--r-- | test/Transforms/SCCP/ipsccp-basic.ll | 135 | ||||
-rw-r--r-- | test/Transforms/SCCP/sccptest.ll | 65 |
18 files changed, 582 insertions, 53 deletions
diff --git a/test/Transforms/ConstProp/constant-expr.ll b/test/Transforms/ConstProp/constant-expr.ll new file mode 100644 index 000000000000..eece37fa69df --- /dev/null +++ b/test/Transforms/ConstProp/constant-expr.ll @@ -0,0 +1,60 @@ +; RUN: llvm-as < %s | llvm-dis | FileCheck %s + +@X = external global i8 +@Y = external global i8 +@Z = external global i8 + +@A = global i1 add (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) +; CHECK: @A = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) +@B = global i1 sub (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)), align 2 +; CHECK: @B = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) +@C = global i1 mul (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) +; CHECK: @C = global i1 and (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) + +@D = global i1 sdiv (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) +; CHECK: @D = global i1 icmp ult (i8* @X, i8* @Y) +@E = global i1 udiv (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) +; CHECK: @E = global i1 icmp ult (i8* @X, i8* @Y) +@F = global i1 srem (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) +; CHECK: @F = global i1 false ; <i1*> [#uses=0] +@G = global i1 urem (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) +; CHECK: @G = global i1 false ; <i1*> [#uses=0] + +@H = global i1 icmp ule (i32* bitcast (i8* @X to i32*), i32* bitcast (i8* @Y to i32*)) +; CHECK: @H = global i1 icmp ule (i8* @X, i8* @Y) + +@I = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 false) +; CHECK: @I = global i1 icmp ult (i8* @X, i8* @Y) +@J = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 true) +; CHECK: @J = global i1 icmp uge (i8* @X, i8* @Y) + +@K = global i1 icmp eq (i1 icmp ult (i8* @X, i8* @Y), i1 false) +; CHECK: @K = global i1 icmp uge (i8* @X, i8* @Y) +@L = global i1 icmp eq (i1 icmp ult (i8* @X, i8* @Y), i1 true) +; CHECK: @L = global i1 icmp ult (i8* @X, i8* @Y) +@M = global i1 icmp ne (i1 icmp ult (i8* @X, i8* @Y), i1 true) +; CHECK: @M = global i1 icmp uge (i8* @X, i8* @Y) +@N = global i1 icmp ne (i1 icmp ult (i8* @X, i8* @Y), i1 false) +; CHECK: @N = global i1 icmp ult (i8* @X, i8* @Y) + +@O = global i1 icmp eq (i32 zext (i1 icmp ult (i8* @X, i8* @Y) to i32), i32 0) +; CHECK: @O = global i1 icmp uge (i8* @X, i8* @Y) + + + +; PR5176 + +; CHECK: @T1 = global i1 true +@T1 = global i1 icmp eq (i64 and (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 64) to i64), i64 1), i64 0) + +; CHECK: @T2 = global i1* @B +@T2 = global i1* inttoptr (i64 add (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 192)), i256 192) to i64), i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 192)), i256 128) to i64)) to i1*) + +; CHECK: @T3 = global i64 add (i64 ptrtoint (i1* @B to i64), i64 -1) +@T3 = global i64 add (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 64) to i64), i64 -1) + +; CHECK: @T4 = global i1* @B +@T4 = global i1* inttoptr (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 64) to i64) to i1*) + +; CHECK: @T5 = global i1* @A +@T5 = global i1* inttoptr (i64 add (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 192) to i64), i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 128) to i64)) to i1*)
\ No newline at end of file diff --git a/test/Transforms/ConstProp/loads.ll b/test/Transforms/ConstProp/loads.ll new file mode 100644 index 000000000000..f3e7f6a4b7bc --- /dev/null +++ b/test/Transforms/ConstProp/loads.ll @@ -0,0 +1,89 @@ +; 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" + +@test1 = constant {{i32,i8},i32} {{i32,i8} { i32 -559038737, i8 186 }, i32 -889275714 } +@test2 = constant double 1.0 +@test3 = constant {i64, i64} { i64 123, i64 112312312 } + +; Simple load +define i32 @test1() { + %r = load i32* getelementptr ({{i32,i8},i32}* @test1, i32 0, i32 0, i32 0) + ret i32 %r +; @test1 +; CHECK: ret i32 -559038737 +} + +; PR3152 +; Load of first 16 bits of 32-bit value. +define i16 @test2() { + %r = load i16* bitcast(i32* getelementptr ({{i32,i8},i32}* @test1, i32 0, i32 0, i32 0) to i16*) + ret i16 %r + +; @test2 +; CHECK: ret i16 -16657 +} + +; Load of second 16 bits of 32-bit value. +define i16 @test3() { + %r = load i16* getelementptr(i16* bitcast(i32* getelementptr ({{i32,i8},i32}* @test1, i32 0, i32 0, i32 0) to i16*), i32 1) + ret i16 %r + +; @test3 +; CHECK: ret i16 -8531 +} + +; Load of 8 bit field + tail padding. +define i16 @test4() { + %r = load i16* getelementptr(i16* bitcast(i32* getelementptr ({{i32,i8},i32}* @test1, i32 0, i32 0, i32 0) to i16*), i32 2) + ret i16 %r +; @test4 +; CHECK: ret i16 186 +} + +; Load of double bits. +define i64 @test6() { + %r = load i64* bitcast(double* @test2 to i64*) + ret i64 %r + +; @test6 +; CHECK: ret i64 4607182418800017408 +} + +; Load of double bits. +define i16 @test7() { + %r = load i16* bitcast(double* @test2 to i16*) + ret i16 %r + +; @test7 +; CHECK: ret i16 0 +} + +; Double load. +define double @test8() { + %r = load double* bitcast({{i32,i8},i32}* @test1 to double*) + ret double %r + +; @test8 +; CHECK: ret double 0xDEADBEBA +} + + +; i128 load. +define i128 @test9() { + %r = load i128* bitcast({i64, i64}* @test3 to i128*) + ret i128 %r + +; @test9 +; CHECK: ret i128 112312312 +} + +; vector load. +define <2 x i64> @test10() { + %r = load <2 x i64>* bitcast({i64, i64}* @test3 to <2 x i64>*) + ret <2 x i64> %r + +; @test10 +; CHECK: ret <2 x i64> <i64 112312312, i64 0> +} + diff --git a/test/Transforms/GVN/calls-readonly.ll b/test/Transforms/GVN/calls-readonly.ll index 28b5ff09a73a..97ec91512e32 100644 --- a/test/Transforms/GVN/calls-readonly.ll +++ b/test/Transforms/GVN/calls-readonly.ll @@ -6,22 +6,22 @@ target triple = "i386-apple-darwin7" define i8* @test(i8* %P, i8* %Q, i32 %x, i32 %y) nounwind readonly { entry: - %0 = tail call i32 @strlen(i8* %P) nounwind readonly ; <i32> [#uses=2] - %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1] - br i1 %1, label %bb, label %bb1 + %0 = tail call i32 @strlen(i8* %P) ; <i32> [#uses=2] + %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1] + br i1 %1, label %bb, label %bb1 -bb: ; preds = %entry - %2 = sdiv i32 %x, %y ; <i32> [#uses=1] - br label %bb1 +bb: ; preds = %entry + %2 = sdiv i32 %x, %y ; <i32> [#uses=1] + br label %bb1 -bb1: ; preds = %bb, %entry - %x_addr.0 = phi i32 [ %2, %bb ], [ %x, %entry ] ; <i32> [#uses=1] - %3 = tail call i8* @strchr(i8* %Q, i32 97) nounwind readonly ; <i8*> [#uses=1] - %4 = tail call i32 @strlen(i8* %P) nounwind readonly ; <i32> [#uses=1] - %5 = add i32 %x_addr.0, %0 ; <i32> [#uses=1] - %.sum = sub i32 %5, %4 ; <i32> [#uses=1] - %6 = getelementptr i8* %3, i32 %.sum ; <i8*> [#uses=1] - ret i8* %6 +bb1: ; preds = %bb, %entry + %x_addr.0 = phi i32 [ %2, %bb ], [ %x, %entry ] ; <i32> [#uses=1] + %3 = tail call i8* @strchr(i8* %Q, i32 97) ; <i8*> [#uses=1] + %4 = tail call i32 @strlen(i8* %P) ; <i32> [#uses=1] + %5 = add i32 %x_addr.0, %0 ; <i32> [#uses=1] + %.sum = sub i32 %5, %4 ; <i32> [#uses=1] + %6 = getelementptr i8* %3, i32 %.sum ; <i8*> [#uses=1] + ret i8* %6 } declare i32 @strlen(i8*) nounwind readonly diff --git a/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll b/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll new file mode 100644 index 000000000000..54e8f9097906 --- /dev/null +++ b/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll @@ -0,0 +1,26 @@ +; RUN: opt < %s -globalopt -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" +target triple = "x86_64-apple-darwin10.0" + +%struct.hashheader = type { i16, i16, i16, i16, i16, i16, i32, i32, i32, i32, i32, i32, i32, i32, i32, [5 x i8], [13 x i8], i8, i8, i8, [228 x i16], [228 x i8], [228 x i8], [228 x i8], [228 x i8], [228 x i8], [228 x i8], [128 x i8], [100 x [11 x i8]], [100 x i32], [100 x i32], i16 } +%struct.strchartype = type { i8*, i8*, i8* } + +@hashheader = internal global %struct.hashheader zeroinitializer, align 32 ; <%struct.hashheader*> [#uses=1] +@chartypes = internal global %struct.strchartype* null ; <%struct.strchartype**> [#uses=1] +; CHECK-NOT: @hashheader +; CHECK-NOT: @chartypes + +; based on linit in office-ispell +define void @test() nounwind ssp { + %1 = load i32* getelementptr inbounds (%struct.hashheader* @hashheader, i64 0, i32 13), align 8 ; <i32> [#uses=1] + %2 = sext i32 %1 to i64 ; <i64> [#uses=1] + %3 = mul i64 %2, ptrtoint (%struct.strchartype* getelementptr (%struct.strchartype* null, i64 1) to i64) ; <i64> [#uses=1] + %4 = tail call i8* @malloc(i64 %3) ; <i8*> [#uses=1] +; CHECK: call i8* @malloc(i64 + %5 = bitcast i8* %4 to %struct.strchartype* ; <%struct.strchartype*> [#uses=1] + store %struct.strchartype* %5, %struct.strchartype** @chartypes, align 8 + ret void +} + +declare noalias i8* @malloc(i64) diff --git a/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll b/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll new file mode 100644 index 000000000000..c43565af635b --- /dev/null +++ b/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll @@ -0,0 +1,30 @@ +; Test ensures that non-optimizable array mallocs are not optimized; specifically +; GlobalOpt was treating a non-optimizable array malloc as a non-array malloc +; and optimizing the global object that the malloc was stored to as a single +; element global. The global object @TOP in this test should not be optimized. +; RUN: opt < %s -globalopt -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" +target triple = "x86_64-apple-darwin10.0" + +@TOP = internal global i64* null ; <i64**> [#uses=2] +; CHECK: @TOP = internal global i64* null +@channelColumns = internal global i64 0 ; <i64*> [#uses=2] + +; Derived from @DescribeChannel() in yacr2 +define void @test() nounwind ssp { + store i64 2335, i64* @channelColumns, align 8 + %1 = load i64* @channelColumns, align 8 ; <i64> [#uses=1] + %2 = shl i64 %1, 3 ; <i64> [#uses=1] + %3 = add i64 %2, 8 ; <i64> [#uses=1] + %4 = call noalias i8* @malloc(i64 %3) nounwind ; <i8*> [#uses=1] +; CHECK: call noalias i8* @malloc + %5 = bitcast i8* %4 to i64* ; <i64*> [#uses=1] + store i64* %5, i64** @TOP, align 8 + %6 = load i64** @TOP, align 8 ; <i64*> [#uses=1] + %7 = getelementptr inbounds i64* %6, i64 13 ; <i64*> [#uses=1] + store i64 0, i64* %7, align 8 + ret void +} + +declare noalias i8* @malloc(i64) nounwind diff --git a/test/Transforms/GlobalOpt/malloc-promote-2.ll b/test/Transforms/GlobalOpt/malloc-promote-2.ll index 0d03835cf530..d3d225260ab3 100644 --- a/test/Transforms/GlobalOpt/malloc-promote-2.ll +++ b/test/Transforms/GlobalOpt/malloc-promote-2.ll @@ -1,4 +1,6 @@ -; RUN: opt < %s -globalopt -S | not grep malloc +; RUN: opt < %s -globalopt -globaldce -S | not grep malloc +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i686-apple-darwin8" @G = internal global i32* null ; <i32**> [#uses=3] diff --git a/test/Transforms/GlobalOpt/malloc-promote-3.ll b/test/Transforms/GlobalOpt/malloc-promote-3.ll index d4ee4e861c2d..a920b611501c 100644 --- a/test/Transforms/GlobalOpt/malloc-promote-3.ll +++ b/test/Transforms/GlobalOpt/malloc-promote-3.ll @@ -1,4 +1,6 @@ -; RUN: opt < %s -globalopt -S | not grep malloc +; RUN: opt < %s -globalopt -globaldce -S | not grep malloc +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i686-apple-darwin8" @G = internal global i32* null ; <i32**> [#uses=4] diff --git a/test/Transforms/Inline/crash.ll b/test/Transforms/Inline/crash.ll index 30eae7a96a7b..f34b44c2aa08 100644 --- a/test/Transforms/Inline/crash.ll +++ b/test/Transforms/Inline/crash.ll @@ -51,7 +51,38 @@ entry: unreachable } +declare fastcc void @list_Rplacd1284() nounwind ssp -declare fastcc void @list_Rplacd1284() nounwind ssp + +;============================ +; PR5208 + +define void @AAA() { +entry: + %A = alloca i8, i32 undef, align 1 + invoke fastcc void @XXX() + to label %invcont98 unwind label %lpad156 + +invcont98: + unreachable + +lpad156: + unreachable +} + +declare fastcc void @YYY() + +define internal fastcc void @XXX() { +entry: + %B = alloca i8, i32 undef, align 1 + invoke fastcc void @YYY() + to label %bb260 unwind label %lpad + +bb260: + ret void + +lpad: + unwind +} diff --git a/test/Transforms/InstCombine/cast.ll b/test/Transforms/InstCombine/cast.ll index 9835d657c9bb..c5266f3b8640 100644 --- a/test/Transforms/InstCombine/cast.ll +++ b/test/Transforms/InstCombine/cast.ll @@ -102,8 +102,8 @@ define i32* @test12() { %p = malloc [4 x i8] ; <[4 x i8]*> [#uses=1] %c = bitcast [4 x i8]* %p to i32* ; <i32*> [#uses=1] ret i32* %c -; CHECK: %p = malloc i32 -; CHECK: ret i32* %p +; CHECK: %malloccall = tail call i8* @malloc(i32 ptrtoint ([4 x i8]* getelementptr ([4 x i8]* null, i32 1) to i32)) +; CHECK: ret i32* %c } define i8* @test13(i64 %A) { @@ -274,9 +274,9 @@ define void @test32(double** %tmp) { %tmp8.upgrd.1 = bitcast [16 x i8]* %tmp8 to double* ; <double*> [#uses=1] store double* %tmp8.upgrd.1, double** %tmp ret void -; CHECK: %tmp81 = malloc [2 x double] -; CHECK: %tmp81.sub = getelementptr inbounds [2 x double]* %tmp81, i64 0, i64 0 -; CHECK: store double* %tmp81.sub, double** %tmp +; CHECK: %malloccall = tail call i8* @malloc(i32 ptrtoint ([16 x i8]* getelementptr ([16 x i8]* null, i32 1) to i32)) +; CHECK: %tmp8.upgrd.1 = bitcast i8* %malloccall to double* +; CHECK: store double* %tmp8.upgrd.1, double** %tmp ; CHECK: ret void } diff --git a/test/Transforms/InstCombine/crash.ll b/test/Transforms/InstCombine/crash.ll index d475ab5bc57c..fbac472e1972 100644 --- a/test/Transforms/InstCombine/crash.ll +++ b/test/Transforms/InstCombine/crash.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine | llvm-dis +; RUN: opt < %s -instcombine -S target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i386-apple-darwin10.0" @@ -44,3 +44,84 @@ entry: store i32 %ins, i32* %arrayidx20 ret void } + +; PR5262 +@tmp2 = global i64 0 ; <i64*> [#uses=1] + +declare void @use(i64) nounwind + +define void @foo(i1) nounwind align 2 { +; <label>:1 + br i1 %0, label %2, label %3 + +; <label>:2 ; preds = %1 + br label %3 + +; <label>:3 ; preds = %2, %1 + %4 = phi i8 [ 1, %2 ], [ 0, %1 ] ; <i8> [#uses=1] + %5 = icmp eq i8 %4, 0 ; <i1> [#uses=1] + %6 = load i64* @tmp2, align 8 ; <i64> [#uses=1] + %7 = select i1 %5, i64 0, i64 %6 ; <i64> [#uses=1] + br label %8 + +; <label>:8 ; preds = %3 + call void @use(i64 %7) + ret void +} + +%t0 = type { i32, i32 } +%t1 = type { i32, i32, i32, i32, i32* } + +declare %t0* @bar2(i64) + +define void @bar3(i1, i1) nounwind align 2 { +; <label>:2 + br i1 %1, label %10, label %3 + +; <label>:3 ; preds = %2 + %4 = getelementptr inbounds %t0* null, i64 0, i32 1 ; <i32*> [#uses=0] + %5 = getelementptr inbounds %t1* null, i64 0, i32 4 ; <i32**> [#uses=1] + %6 = load i32** %5, align 8 ; <i32*> [#uses=1] + %7 = icmp ne i32* %6, null ; <i1> [#uses=1] + %8 = zext i1 %7 to i32 ; <i32> [#uses=1] + %9 = add i32 %8, 0 ; <i32> [#uses=1] + br label %10 + +; <label>:10 ; preds = %3, %2 + %11 = phi i32 [ %9, %3 ], [ 0, %2 ] ; <i32> [#uses=1] + br i1 %1, label %12, label %13 + +; <label>:12 ; preds = %10 + br label %13 + +; <label>:13 ; preds = %12, %10 + %14 = zext i32 %11 to i64 ; <i64> [#uses=1] + %15 = tail call %t0* @bar2(i64 %14) nounwind ; <%0*> [#uses=0] + ret void +} + + + + +; PR5262 +; Make sure the PHI node gets put in a place where all of its operands dominate +; it. +define i64 @test4(i1 %c, i64* %P) nounwind align 2 { +BB0: + br i1 %c, label %BB1, label %BB2 + +BB1: + br label %BB2 + +BB2: + %v5_ = phi i1 [ true, %BB0], [false, %BB1] + %v6 = load i64* %P + br label %l8 + +l8: + br label %l10 + +l10: + %v11 = select i1 %v5_, i64 0, i64 %v6 + ret i64 %v11 +} diff --git a/test/Transforms/InstCombine/getelementptr.ll b/test/Transforms/InstCombine/getelementptr.ll index ffaa6afa85e3..285e0ba602f4 100644 --- a/test/Transforms/InstCombine/getelementptr.ll +++ b/test/Transforms/InstCombine/getelementptr.ll @@ -58,7 +58,7 @@ define i32* @test6() { %B = getelementptr i32* %A, i64 2 ret i32* %B ; CHECK: @test6 -; CHECK: getelementptr [4 x i32]* %M, i64 0, i64 2 +; CHECK: getelementptr i8* %malloccall, i64 8 } define i32* @test7(i32* %I, i64 %C, i64 %D) { diff --git a/test/Transforms/InstCombine/malloc-free-delete.ll b/test/Transforms/InstCombine/malloc-free-delete.ll index 2ed5ec6996d6..fd91e447bddd 100644 --- a/test/Transforms/InstCombine/malloc-free-delete.ll +++ b/test/Transforms/InstCombine/malloc-free-delete.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -S | grep {ret i32 0} -; RUN: opt < %s -instcombine -S | not grep malloc +; RUN: opt < %s -instcombine -globaldce -S | not grep malloc ; PR1201 define i32 @main(i32 %argc, i8** %argv) { %c_19 = alloca i8* ; <i8**> [#uses=2] diff --git a/test/Transforms/InstCombine/malloc2.ll b/test/Transforms/InstCombine/malloc2.ll index 102422ee5fc7..8462dacf857f 100644 --- a/test/Transforms/InstCombine/malloc2.ll +++ b/test/Transforms/InstCombine/malloc2.ll @@ -1,19 +1,22 @@ -; RUN: opt < %s -instcombine -S | grep {ret i32 0} -; RUN: opt < %s -instcombine -S | not grep malloc +; RUN: opt < %s -instcombine -S | FileCheck %s ; PR1313 define i32 @test1(i32 %argc, i8* %argv, i8* %envp) { %tmp15.i.i.i23 = malloc [2564 x i32] ; <[2564 x i32]*> [#uses=1] +; CHECK-NOT: call i8* @malloc %c = icmp eq [2564 x i32]* %tmp15.i.i.i23, null ; <i1>:0 [#uses=1] %retval = zext i1 %c to i32 ; <i32> [#uses=1] ret i32 %retval +; CHECK: ret i32 0 } define i32 @test2(i32 %argc, i8* %argv, i8* %envp) { %tmp15.i.i.i23 = malloc [2564 x i32] ; <[2564 x i32]*> [#uses=1] +; CHECK-NOT: call i8* @malloc %X = bitcast [2564 x i32]* %tmp15.i.i.i23 to i32* %c = icmp ne i32* %X, null %retval = zext i1 %c to i32 ; <i32> [#uses=1] ret i32 %retval +; CHECK: ret i32 1 } diff --git a/test/Transforms/InstCombine/malloc3.ll b/test/Transforms/InstCombine/malloc3.ll index cd407ffb02f3..f1c0cae15ae9 100644 --- a/test/Transforms/InstCombine/malloc3.ll +++ b/test/Transforms/InstCombine/malloc3.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {malloc.*struct.foo} | count 2 +; RUN: opt < %s -instcombine -S | not grep load ; PR1728 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" diff --git a/test/Transforms/JumpThreading/crash.ll b/test/Transforms/JumpThreading/crash.ll index 0b6cd27110e4..023c7d01e90f 100644 --- a/test/Transforms/JumpThreading/crash.ll +++ b/test/Transforms/JumpThreading/crash.ll @@ -54,3 +54,38 @@ bb15: bb61: ret void } + + +; PR5258 +define i32 @test(i1 %cond, i1 %cond2, i32 %a) { +A: + br i1 %cond, label %F, label %A1 +F: + br label %A1 + +A1: + %d = phi i1 [false, %A], [true, %F] + %e = add i32 %a, %a + br i1 %d, label %B, label %G + +G: + br i1 %cond2, label %B, label %D + +B: + %f = phi i32 [%e, %G], [%e, %A1] + %b = add i32 0, 0 + switch i32 %a, label %C [ + i32 7, label %D + i32 8, label %D + i32 9, label %D + ] + +C: + br label %D + +D: + %c = phi i32 [%e, %B], [%e, %B], [%e, %B], [%f, %C], [%e, %G] + ret i32 %c +E: + ret i32 412 +}
\ No newline at end of file diff --git a/test/Transforms/LoopSimplify/unreachable-loop-pred.ll b/test/Transforms/LoopSimplify/unreachable-loop-pred.ll new file mode 100644 index 000000000000..faaaf97d72fa --- /dev/null +++ b/test/Transforms/LoopSimplify/unreachable-loop-pred.ll @@ -0,0 +1,20 @@ +; RUN: opt -S -loopsimplify -disable-output -verify-loop-info -verify-dom-info < %s +; PR5235 + +; When loopsimplify inserts a preheader for this loop, it should add the new +; block to the enclosing loop and not get confused by the unreachable +; bogus loop entry. + +define void @is_extract_cab() nounwind { +entry: + br label %header + +header: ; preds = %if.end206, %cond.end66, %if.end23 + br label %while.body115 + +while.body115: ; preds = %9, %if.end192, %if.end101 + br i1 undef, label %header, label %while.body115 + +foo: + br label %while.body115 +} diff --git a/test/Transforms/SCCP/ipsccp-basic.ll b/test/Transforms/SCCP/ipsccp-basic.ll index 7f0772e53d93..d3584d1b3ce7 100644 --- a/test/Transforms/SCCP/ipsccp-basic.ll +++ b/test/Transforms/SCCP/ipsccp-basic.ll @@ -1,13 +1,136 @@ -; RUN: opt < %s -ipsccp -S | \ -; RUN: grep -v {ret i32 17} | grep -v {ret i32 undef} | not grep ret +; RUN: opt < %s -ipsccp -S | FileCheck %s -define internal i32 @bar(i32 %A) { - %X = add i32 1, 2 ; <i32> [#uses=0] +;;======================== test1 + +define internal i32 @test1a(i32 %A) { + %X = add i32 1, 2 ret i32 %A } +; CHECK: define internal i32 @test1a +; CHECK: ret i32 undef -define i32 @foo() { - %X = call i32 @bar( i32 17 ) ; <i32> [#uses=1] +define i32 @test1b() { + %X = call i32 @test1a( i32 17 ) ret i32 %X + +; CHECK: define i32 @test1b +; CHECK: ret i32 17 +} + + + +;;======================== test2 + +define internal i32 @test2a(i32 %A) { + %C = icmp eq i32 %A, 0 + br i1 %C, label %T, label %F +T: + %B = call i32 @test2a( i32 0 ) + ret i32 0 +F: + %C.upgrd.1 = call i32 @test2a(i32 1) + ret i32 %C.upgrd.1 +} +; CHECK: define internal i32 @test2a +; CHECK-NEXT: br label %T +; CHECK: ret i32 undef + + +define i32 @test2b() { + %X = call i32 @test2a(i32 0) + ret i32 %X +} +; CHECK: define i32 @test2b +; CHECK-NEXT: %X = call i32 @test2a(i32 0) +; CHECK-NEXT: ret i32 0 + + +;;======================== test3 + +@G = internal global i32 undef + +define void @test3a() { + %X = load i32* @G + store i32 %X, i32* @G + ret void +} +; CHECK: define void @test3a +; CHECK-NEXT: ret void + + +define i32 @test3b() { + %V = load i32* @G + %C = icmp eq i32 %V, 17 + br i1 %C, label %T, label %F +T: + store i32 17, i32* @G + ret i32 %V +F: + store i32 123, i32* @G + ret i32 0 +} +; CHECK: define i32 @test3b +; CHECK-NOT: store +; CHECK: ret i32 0 + + +;;======================== test4 + +define internal {i64,i64} @test4a() { + %a = insertvalue {i64,i64} undef, i64 4, 1 + %b = insertvalue {i64,i64} %a, i64 5, 0 + ret {i64,i64} %b +} + +define i64 @test4b() { + %a = invoke {i64,i64} @test4a() + to label %A unwind label %B +A: + %b = extractvalue {i64,i64} %a, 0 + %c = call i64 @test4c(i64 %b) + ret i64 %c +B: + ret i64 0 +} +; CHECK: define i64 @test4b() +; CHECK: %c = call i64 @test4c(i64 5) +; CHECK-NEXT: ret i64 5 + + +define internal i64 @test4c(i64 %a) { + ret i64 %a +} +; CHECK: define internal i64 @test4c +; CHECK: ret i64 undef + + + +;;======================== test5 + +; PR4313 +define internal {i64,i64} @test5a() { + %a = insertvalue {i64,i64} undef, i64 4, 1 + %b = insertvalue {i64,i64} %a, i64 5, 0 + ret {i64,i64} %b +} + +define i64 @test5b() { + %a = invoke {i64,i64} @test5a() + to label %A unwind label %B +A: + %c = call i64 @test5c({i64,i64} %a) + ret i64 %c +B: + ret i64 0 +} + +; CHECK: define i64 @test5b() +; CHECK: A: +; CHECK-NEXT: %c = call i64 @test5c(%0 %a) +; CHECK-NEXT: ret i64 %c + +define internal i64 @test5c({i64,i64} %a) { + %b = extractvalue {i64,i64} %a, 0 + ret i64 %b } diff --git a/test/Transforms/SCCP/sccptest.ll b/test/Transforms/SCCP/sccptest.ll index 6f422f07d661..a719f6cfb48d 100644 --- a/test/Transforms/SCCP/sccptest.ll +++ b/test/Transforms/SCCP/sccptest.ll @@ -1,31 +1,58 @@ +; RUN: opt < %s -sccp -S | FileCheck %s + +; This is a basic sanity check for constant propagation. The add instruction +; should be eliminated. + +define i32 @test1(i1 %B) { + br i1 %B, label %BB1, label %BB2 +BB1: ; preds = %0 + %Val = add i32 0, 0 ; <i32> [#uses=1] + br label %BB3 +BB2: ; preds = %0 + br label %BB3 +BB3: ; preds = %BB2, %BB1 + %Ret = phi i32 [ %Val, %BB1 ], [ 1, %BB2 ] ; <i32> [#uses=1] + ret i32 %Ret + +; CHECK: @test1 +; CHECK: %Ret = phi i32 [ 0, %BB1 ], [ 1, %BB2 ] +} + ; This is the test case taken from appel's book that illustrates a hard case -; that SCCP gets right. BB3 should be completely eliminated. +; that SCCP gets right. ; -; RUN: opt < %s -sccp -constprop -dce -simplifycfg | \ -; RUN: llvm-dis | not grep BB3 - -define i32 @testfunction(i32 %i0, i32 %j0) { +define i32 @test2(i32 %i0, i32 %j0) { +; CHECK: @test2 BB1: br label %BB2 -BB2: ; preds = %BB7, %BB1 - %j2 = phi i32 [ %j4, %BB7 ], [ 1, %BB1 ] ; <i32> [#uses=2] - %k2 = phi i32 [ %k4, %BB7 ], [ 0, %BB1 ] ; <i32> [#uses=4] - %kcond = icmp slt i32 %k2, 100 ; <i1> [#uses=1] +BB2: + %j2 = phi i32 [ %j4, %BB7 ], [ 1, %BB1 ] + %k2 = phi i32 [ %k4, %BB7 ], [ 0, %BB1 ] + %kcond = icmp slt i32 %k2, 100 br i1 %kcond, label %BB3, label %BB4 -BB3: ; preds = %BB2 - %jcond = icmp slt i32 %j2, 20 ; <i1> [#uses=1] +BB3: + %jcond = icmp slt i32 %j2, 20 br i1 %jcond, label %BB5, label %BB6 -BB4: ; preds = %BB2 +; CHECK: BB3: +; CHECK-NEXT: br i1 true, label %BB5, label %BB6 +BB4: ret i32 %j2 -BB5: ; preds = %BB3 - %k3 = add i32 %k2, 1 ; <i32> [#uses=1] +; CHECK: BB4: +; CHECK-NEXT: ret i32 1 +BB5: + %k3 = add i32 %k2, 1 br label %BB7 -BB6: ; preds = %BB3 - %k5 = add i32 %k2, 1 ; <i32> [#uses=1] +BB6: + %k5 = add i32 %k2, 1 br label %BB7 -BB7: ; preds = %BB6, %BB5 - %j4 = phi i32 [ 1, %BB5 ], [ %k2, %BB6 ] ; <i32> [#uses=1] - %k4 = phi i32 [ %k3, %BB5 ], [ %k5, %BB6 ] ; <i32> [#uses=1] +; CHECK: BB6: +; CHECK-NEXT: br label %BB7 +BB7: + %j4 = phi i32 [ 1, %BB5 ], [ %k2, %BB6 ] + %k4 = phi i32 [ %k3, %BB5 ], [ %k5, %BB6 ] br label %BB2 +; CHECK: BB7: +; CHECK-NEXT: %k4 = phi i32 [ %k3, %BB5 ], [ undef, %BB6 ] +; CHECK-NEXT: br label %BB2 } |