OSDN Git Service

Move the remaining simplify-libcalls tests to instcombine, merging most of them into...
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 19 May 2013 13:28:39 +0000 (13:28 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 19 May 2013 13:28:39 +0000 (13:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182211 91177308-0d34-0410-b5e6-96231b3b80d8

12 files changed:
test/Transforms/InstCombine/PR7357.ll [moved from test/Transforms/SimplifyLibCalls/PR7357.ll with 76% similarity]
test/Transforms/InstCombine/float-shrink-compare.ll [moved from test/Transforms/SimplifyLibCalls/float-shrink-compare.ll with 98% similarity]
test/Transforms/InstCombine/simplify-libcalls.ll [new file with mode: 0644]
test/Transforms/InstCombine/win-math.ll [moved from test/Transforms/SimplifyLibCalls/win-math.ll with 100% similarity]
test/Transforms/SimplifyLibCalls/2005-05-20-sprintf-crash.ll [deleted file]
test/Transforms/SimplifyLibCalls/2007-04-06-strchr-miscompile.ll [deleted file]
test/Transforms/SimplifyLibCalls/2008-05-19-memcmp.ll [deleted file]
test/Transforms/SimplifyLibCalls/2009-05-30-memcmp-byte.ll [deleted file]
test/Transforms/SimplifyLibCalls/2009-07-28-Exit.ll [deleted file]
test/Transforms/SimplifyLibCalls/2009-07-29-Exit2.ll [deleted file]
test/Transforms/SimplifyLibCalls/MemCpy.ll [deleted file]
test/Transforms/SimplifyLibCalls/lit.local.cfg [deleted file]

similarity index 76%
rename from test/Transforms/SimplifyLibCalls/PR7357.ll
rename to test/Transforms/InstCombine/PR7357.ll
index 3529a9c..c397c5e 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt < %s "-default-data-layout=e-p:32:32:32-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-n32" -simplify-libcalls -S | FileCheck %s
+; RUN: opt < %s "-default-data-layout=e-p:32:32:32-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-n32" -instcombine -S | FileCheck %s
 @.str1 = private constant [11 x i8] c"(){};[]&|:\00", align 4
 
 ; check that simplify libcalls will not replace a call with one calling
@@ -8,9 +8,10 @@
 ; CHECK: call arm_aapcscc  i8* @strchr
 define arm_aapcscc i32 @foo(i32 %argc) nounwind {
 bb.nph:
-  call arm_aapcscc  i8* @strchr(i8* getelementptr ([11 x i8]* @.str1, i32 0,
+  %c = call arm_aapcscc  i8* @strchr(i8* getelementptr ([11 x i8]* @.str1, i32 0,
 i32 0), i32 %argc) nounwind readonly
-  ret i32 0
+  %p = ptrtoint i8* %c to i32
+  ret i32 %p
 }
 
 declare arm_aapcscc i8* @strchr(i8*, i32) nounwind readonly
@@ -1,4 +1,4 @@
-; RUN: opt -S -simplify-libcalls -instcombine < %s | FileCheck %s
+; 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-S128"
 target triple = "x86_64-apple-macosx10.8.0"
 
diff --git a/test/Transforms/InstCombine/simplify-libcalls.ll b/test/Transforms/InstCombine/simplify-libcalls.ll
new file mode 100644 (file)
index 0000000..4f3a506
--- /dev/null
@@ -0,0 +1,132 @@
+; RUN: opt -S < %s -instcombine | FileCheck %s
+
+@G = constant [3 x i8] c"%s\00"                ; <[3 x i8]*> [#uses=1]
+
+declare i32 @sprintf(i8*, i8*, ...)
+
+define void @foo(i8* %P, i32* %X) {
+       call i32 (i8*, i8*, ...)* @sprintf( i8* %P, i8* getelementptr ([3 x i8]* @G, i32 0, i32 0), i32* %X )           ; <i32>:1 [#uses=0]
+       ret void
+}
+
+; PR1307
+@str = internal constant [5 x i8] c"foog\00"
+@str1 = internal constant [8 x i8] c"blahhh!\00"
+@str2 = internal constant [5 x i8] c"Ponk\00"
+
+define i8* @test1() {
+        %tmp3 = tail call i8* @strchr( i8* getelementptr ([5 x i8]* @str, i32 0, i32 2), i32 103 )              ; <i8*> [#uses=1]
+        ret i8* %tmp3
+
+; CHECK: @test1
+; CHECK: ret i8* getelementptr inbounds ([5 x i8]* @str, i32 0, i64 3)
+}
+
+declare i8* @strchr(i8*, i32)
+
+define i8* @test2() {
+        %tmp3 = tail call i8* @strchr( i8* getelementptr ([8 x i8]* @str1, i32 0, i32 2), i32 0 )               ; <i8*> [#uses=1]
+        ret i8* %tmp3
+
+; CHECK: @test2
+; CHECK: ret i8* getelementptr inbounds ([8 x i8]* @str1, i32 0, i64 7)
+}
+
+define i8* @test3() {
+entry:
+        %tmp3 = tail call i8* @strchr( i8* getelementptr ([5 x i8]* @str2, i32 0, i32 1), i32 80 )              ; <i8*> [#uses=1]
+        ret i8* %tmp3
+
+; CHECK: @test3
+; CHECK: ret i8* null
+}
+
+@_2E_str = external constant [5 x i8]          ; <[5 x i8]*> [#uses=1]
+
+declare i32 @memcmp(i8*, i8*, i32) nounwind readonly
+
+define i1 @PR2341(i8** %start_addr) {
+entry:
+       %tmp4 = load i8** %start_addr, align 4          ; <i8*> [#uses=1]
+       %tmp5 = call i32 @memcmp( i8* %tmp4, i8* getelementptr ([5 x i8]* @_2E_str, i32 0, i32 0), i32 4 ) nounwind readonly            ; <i32> [#uses=1]
+       %tmp6 = icmp eq i32 %tmp5, 0            ; <i1> [#uses=1]
+       ret i1 %tmp6
+
+; CHECK: @PR2341
+; CHECK: i32
+}
+
+define i32 @PR4284() nounwind {
+entry:
+       %c0 = alloca i8, align 1                ; <i8*> [#uses=2]
+       %c2 = alloca i8, align 1                ; <i8*> [#uses=2]
+       store i8 64, i8* %c0
+       store i8 -127, i8* %c2
+       %call = call i32 @memcmp(i8* %c0, i8* %c2, i32 1)               ; <i32> [#uses=1]
+       ret i32 %call
+
+; CHECK: @PR4284
+; CHECK: ret i32 -65
+}
+
+%struct.__sFILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, i8*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64, %struct.pthread_mutex*, %struct.pthread*, i32, i32, %union.anon }
+%struct.__sbuf = type { i8*, i32, [4 x i8] }
+%struct.pthread = type opaque
+%struct.pthread_mutex = type opaque
+%union.anon = type { i64, [120 x i8] }
+@.str13 = external constant [2 x i8]           ; <[2 x i8]*> [#uses=1]
+@.str14 = external constant [2 x i8]           ; <[2 x i8]*> [#uses=1]
+
+define i32 @PR4641(i32 %argc, i8** %argv) nounwind {
+entry:
+       call void @exit(i32 0) nounwind
+       %cond392 = select i1 undef, i8* getelementptr ([2 x i8]* @.str13, i32 0, i32 0), i8* getelementptr ([2 x i8]* @.str14, i32 0, i32 0)            ; <i8*> [#uses=1]
+       %call393 = call %struct.__sFILE* @fopen(i8* undef, i8* %cond392) nounwind               ; <%struct.__sFILE*> [#uses=0]
+       unreachable
+}
+
+declare %struct.__sFILE* @fopen(i8*, i8*)
+
+declare void @exit(i32)
+
+define i32 @PR4645() {
+entry:
+       br label %if.then
+
+lor.lhs.false:         ; preds = %while.body
+       br i1 undef, label %if.then, label %for.cond
+
+if.then:               ; preds = %lor.lhs.false, %while.body
+       call void @exit(i32 1)
+       br label %for.cond
+
+for.cond:              ; preds = %for.end, %if.then, %lor.lhs.false
+       %j.0 = phi i32 [ %inc47, %for.end ], [ 0, %if.then ], [ 0, %lor.lhs.false ]             ; <i32> [#uses=1]
+       unreachable
+
+for.end:               ; preds = %for.cond20
+       %inc47 = add i32 %j.0, 1                ; <i32> [#uses=1]
+       br label %for.cond
+}
+
+@h = constant [2 x i8] c"h\00"         ; <[2 x i8]*> [#uses=1]
+@hel = constant [4 x i8] c"hel\00"             ; <[4 x i8]*> [#uses=1]
+@hello_u = constant [8 x i8] c"hello_u\00"             ; <[8 x i8]*> [#uses=1]
+
+define i32 @MemCpy() {
+  %h_p = getelementptr [2 x i8]* @h, i32 0, i32 0
+  %hel_p = getelementptr [4 x i8]* @hel, i32 0, i32 0
+  %hello_u_p = getelementptr [8 x i8]* @hello_u, i32 0, i32 0
+  %target = alloca [1024 x i8]
+  %target_p = getelementptr [1024 x i8]* %target, i32 0, i32 0
+  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %target_p, i8* %h_p, i32 2, i32 2, i1 false)
+  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %target_p, i8* %hel_p, i32 4, i32 4, i1 false)
+  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %target_p, i8* %hello_u_p, i32 8, i32 8, i1 false)
+  ret i32 0
+
+; CHECK: @MemCpy
+; CHECK-NOT: llvm.memcpy
+; CHECK: ret i32 0
+}
+
+declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
diff --git a/test/Transforms/SimplifyLibCalls/2005-05-20-sprintf-crash.ll b/test/Transforms/SimplifyLibCalls/2005-05-20-sprintf-crash.ll
deleted file mode 100644 (file)
index 8816579..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-; RUN: opt < %s -simplify-libcalls -disable-output
-
-@G = constant [3 x i8] c"%s\00"                ; <[3 x i8]*> [#uses=1]
-
-declare i32 @sprintf(i8*, i8*, ...)
-
-define void @foo(i8* %P, i32* %X) {
-       call i32 (i8*, i8*, ...)* @sprintf( i8* %P, i8* getelementptr ([3 x i8]* @G, i32 0, i32 0), i32* %X )           ; <i32>:1 [#uses=0]
-       ret void
-}
-
diff --git a/test/Transforms/SimplifyLibCalls/2007-04-06-strchr-miscompile.ll b/test/Transforms/SimplifyLibCalls/2007-04-06-strchr-miscompile.ll
deleted file mode 100644 (file)
index ae917f7..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-; PR1307
-; RUN: opt < %s -simplify-libcalls -instcombine -S > %t
-; RUN: grep "@str,.*i64 3" %t
-; RUN: grep "@str1,.*i64 7" %t
-; RUN: grep "ret i8.*null" %t
-; END.
-
-@str = internal constant [5 x i8] c"foog\00"
-@str1 = internal constant [8 x i8] c"blahhh!\00"
-@str2 = internal constant [5 x i8] c"Ponk\00"
-
-define i8* @test1() {
-        %tmp3 = tail call i8* @strchr( i8* getelementptr ([5 x i8]* @str, i32 0, i32 2), i32 103 )              ; <i8*> [#uses=1]
-        ret i8* %tmp3
-}
-
-declare i8* @strchr(i8*, i32)
-
-define i8* @test2() {
-        %tmp3 = tail call i8* @strchr( i8* getelementptr ([8 x i8]* @str1, i32 0, i32 2), i32 0 )               ; <i8*> [#uses=1]
-        ret i8* %tmp3
-}
-
-define i8* @test3() {
-entry:
-        %tmp3 = tail call i8* @strchr( i8* getelementptr ([5 x i8]* @str2, i32 0, i32 1), i32 80 )              ; <i8*> [#uses=1]
-        ret i8* %tmp3
-}
-
diff --git a/test/Transforms/SimplifyLibCalls/2008-05-19-memcmp.ll b/test/Transforms/SimplifyLibCalls/2008-05-19-memcmp.ll
deleted file mode 100644 (file)
index b687432..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-; RUN: opt < %s -simplify-libcalls -S | grep i32
-; PR2341
-
-@_2E_str = external constant [5 x i8]          ; <[5 x i8]*> [#uses=1]
-
-declare i32 @memcmp(i8*, i8*, i32) nounwind readonly 
-
-define i1 @f(i8** %start_addr) {
-entry:
-       %tmp4 = load i8** %start_addr, align 4          ; <i8*> [#uses=1]
-       %tmp5 = call i32 @memcmp( i8* %tmp4, i8* getelementptr ([5 x i8]* @_2E_str, i32 0, i32 0), i32 4 ) nounwind readonly            ; <i32> [#uses=1]
-       %tmp6 = icmp eq i32 %tmp5, 0            ; <i1> [#uses=1]
-       ret i1 %tmp6
-}
diff --git a/test/Transforms/SimplifyLibCalls/2009-05-30-memcmp-byte.ll b/test/Transforms/SimplifyLibCalls/2009-05-30-memcmp-byte.ll
deleted file mode 100644 (file)
index f4c80ed..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-; RUN: opt < %s -simplify-libcalls -instcombine -S | grep "ret i32 -65"
-; PR4284
-
-define i32 @test() nounwind {
-entry:
-       %c0 = alloca i8, align 1                ; <i8*> [#uses=2]
-       %c2 = alloca i8, align 1                ; <i8*> [#uses=2]
-       store i8 64, i8* %c0
-       store i8 -127, i8* %c2
-       %call = call i32 @memcmp(i8* %c0, i8* %c2, i32 1)               ; <i32> [#uses=1]
-       ret i32 %call
-}
-
-declare i32 @memcmp(i8*, i8*, i32)
diff --git a/test/Transforms/SimplifyLibCalls/2009-07-28-Exit.ll b/test/Transforms/SimplifyLibCalls/2009-07-28-Exit.ll
deleted file mode 100644 (file)
index 7af0a26..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-; RUN: opt < %s -simplify-libcalls -disable-output
-; PR4641
-
-       %struct.__sFILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, i8*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64, %struct.pthread_mutex*, %struct.pthread*, i32, i32, %union.anon }
-       %struct.__sbuf = type { i8*, i32, [4 x i8] }
-       %struct.pthread = type opaque
-       %struct.pthread_mutex = type opaque
-       %union.anon = type { i64, [120 x i8] }
-@.str13 = external constant [2 x i8]           ; <[2 x i8]*> [#uses=1]
-@.str14 = external constant [2 x i8]           ; <[2 x i8]*> [#uses=1]
-
-define i32 @main(i32 %argc, i8** %argv) nounwind {
-entry:
-       call void @exit(i32 0) nounwind
-       %cond392 = select i1 undef, i8* getelementptr ([2 x i8]* @.str13, i32 0, i32 0), i8* getelementptr ([2 x i8]* @.str14, i32 0, i32 0)            ; <i8*> [#uses=1]
-       %call393 = call %struct.__sFILE* @fopen(i8* undef, i8* %cond392) nounwind               ; <%struct.__sFILE*> [#uses=0]
-       unreachable
-}
-
-declare %struct.__sFILE* @fopen(i8*, i8*)
-
-declare void @exit(i32)
diff --git a/test/Transforms/SimplifyLibCalls/2009-07-29-Exit2.ll b/test/Transforms/SimplifyLibCalls/2009-07-29-Exit2.ll
deleted file mode 100644 (file)
index b5a788e..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-; RUN: opt < %s -simplify-libcalls -disable-output
-; PR4645
-
-define i32 @main() {
-entry:
-       br label %if.then
-
-lor.lhs.false:         ; preds = %while.body
-       br i1 undef, label %if.then, label %for.cond
-
-if.then:               ; preds = %lor.lhs.false, %while.body
-       call void @exit(i32 1)
-       br label %for.cond
-
-for.cond:              ; preds = %for.end, %if.then, %lor.lhs.false
-       %j.0 = phi i32 [ %inc47, %for.end ], [ 0, %if.then ], [ 0, %lor.lhs.false ]             ; <i32> [#uses=1]
-       unreachable
-
-for.end:               ; preds = %for.cond20
-       %inc47 = add i32 %j.0, 1                ; <i32> [#uses=1]
-       br label %for.cond
-}
-
-declare void @exit(i32)
diff --git a/test/Transforms/SimplifyLibCalls/MemCpy.ll b/test/Transforms/SimplifyLibCalls/MemCpy.ll
deleted file mode 100644 (file)
index 1faad03..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-; RUN: opt < %s -constprop -instcombine -S | not grep "call.*llvm.memcpy.i32"
-
-@h = constant [2 x i8] c"h\00"         ; <[2 x i8]*> [#uses=1]
-@hel = constant [4 x i8] c"hel\00"             ; <[4 x i8]*> [#uses=1]
-@hello_u = constant [8 x i8] c"hello_u\00"             ; <[8 x i8]*> [#uses=1]
-
-define i32 @main() {
-  %h_p = getelementptr [2 x i8]* @h, i32 0, i32 0
-  %hel_p = getelementptr [4 x i8]* @hel, i32 0, i32 0
-  %hello_u_p = getelementptr [8 x i8]* @hello_u, i32 0, i32 0
-  %target = alloca [1024 x i8]
-  %target_p = getelementptr [1024 x i8]* %target, i32 0, i32 0
-  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %target_p, i8* %h_p, i32 2, i32 2, i1 false)
-  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %target_p, i8* %hel_p, i32 4, i32 4, i1 false)
-  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %target_p, i8* %hello_u_p, i32 8, i32 8, i1 false)
-  ret i32 0
-}
-
-declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
diff --git a/test/Transforms/SimplifyLibCalls/lit.local.cfg b/test/Transforms/SimplifyLibCalls/lit.local.cfg
deleted file mode 100644 (file)
index 19eebc0..0000000
+++ /dev/null
@@ -1 +0,0 @@
-config.suffixes = ['.ll', '.c', '.cpp']