Remove llvm-upgrade and update tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48137 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Tanya Lattner
2008-03-10 07:21:50 +00:00
parent f79e60649a
commit ceca194c43
115 changed files with 2565 additions and 3126 deletions

View File

@@ -1,10 +1,11 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls -disable-output
; RUN: llvm-as < %s | opt -simplify-libcalls -disable-output
%G = constant [3 x sbyte] c"%s\00"
@G = constant [3 x i8] c"%s\00" ; <[3 x i8]*> [#uses=1]
declare int %sprintf(sbyte*, sbyte*, ...)
declare i32 @sprintf(i8*, i8*, ...)
void %foo(sbyte*%P, int *%X) {
call int(sbyte*,sbyte*, ...)* %sprintf(sbyte* %P, sbyte* getelementptr ([3 x sbyte]* %G, int 0, int 0), int* %X)
ret void
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
}

View File

@@ -1,15 +1,15 @@
; Test that the ExitInMainOptimization pass works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: grep {ret i32 3} | count 1
; END.
declare void %exit(int)
declare void %exitonly(int)
declare void @exit(i32)
implementation ; Functions:
declare void @exitonly(i32)
int %main () {
call void %exitonly ( int 3 )
call void %exit ( int 3 )
ret int 0
define i32 @main() {
call void @exitonly( i32 3 )
call void @exit( i32 3 )
ret i32 0
}

View File

@@ -1,29 +1,30 @@
; Test that the ToAsciiOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*%ffs}
declare int %ffs(int)
declare int %ffsl(int)
declare int %ffsll(long)
@non_const = external global i32 ; <i32*> [#uses=1]
%non_const = external global int
declare i32 @ffs(i32)
implementation ; Functions:
declare i32 @ffsl(i32)
int %main () {
%arg = load int* %non_const
%val0 = call int %ffs(int %arg)
%val1 = call int %ffs(int 1)
%val2 = call int %ffs(int 2048)
%val3 = call int %ffsl(int 65536)
%val4 = call int %ffsll(long 1024)
%val5 = call int %ffsll(long 17179869184)
%val6 = call int %ffsll(long 1152921504606846976)
%rslt1 = add int %val1, %val2
%rslt2 = add int %val3, %val4
%rslt3 = add int %val5, %val6
%rslt4 = add int %rslt1, %rslt2
%rslt5 = add int %rslt4, %rslt3
%rslt6 = add int %rslt5, %val0
ret int %rslt5
declare i32 @ffsll(i64)
define i32 @main() {
%arg = load i32* @non_const ; <i32> [#uses=1]
%val0 = call i32 @ffs( i32 %arg ) ; <i32> [#uses=1]
%val1 = call i32 @ffs( i32 1 ) ; <i32> [#uses=1]
%val2 = call i32 @ffs( i32 2048 ) ; <i32> [#uses=1]
%val3 = call i32 @ffsl( i32 65536 ) ; <i32> [#uses=1]
%val4 = call i32 @ffsll( i64 1024 ) ; <i32> [#uses=1]
%val5 = call i32 @ffsll( i64 17179869184 ) ; <i32> [#uses=1]
%val6 = call i32 @ffsll( i64 1152921504606846976 ) ; <i32> [#uses=1]
%rslt1 = add i32 %val1, %val2 ; <i32> [#uses=1]
%rslt2 = add i32 %val3, %val4 ; <i32> [#uses=1]
%rslt3 = add i32 %val5, %val6 ; <i32> [#uses=1]
%rslt4 = add i32 %rslt1, %rslt2 ; <i32> [#uses=1]
%rslt5 = add i32 %rslt4, %rslt3 ; <i32> [#uses=2]
%rslt6 = add i32 %rslt5, %val0 ; <i32> [#uses=0]
ret i32 %rslt5
}

View File

@@ -1,29 +1,25 @@
; Test that the FPrintFOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*fprintf}
;
%struct._IO_FILE = type { int, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, %struct._IO_marker*, %struct._IO_FILE*, int, int, int, ushort, sbyte, [1 x sbyte], sbyte*, long, sbyte*, sbyte*, int, [52 x sbyte] }
%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, int }
%struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i32, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i32, [52 x i8] }
%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 }
@str = constant [3 x i8] c"%s\00" ; <[3 x i8]*> [#uses=1]
@chr = constant [3 x i8] c"%c\00" ; <[3 x i8]*> [#uses=1]
@hello = constant [13 x i8] c"hello world\0A\00" ; <[13 x i8]*> [#uses=1]
@stdout = external global %struct._IO_FILE* ; <%struct._IO_FILE**> [#uses=3]
%str = constant [3 x sbyte] c"%s\00"
%chr = constant [3 x sbyte] c"%c\00"
%hello = constant [13 x sbyte] c"hello world\0A\00"
%stdout = external global %struct._IO_FILE*
declare i32 @fprintf(%struct._IO_FILE*, i8*, ...)
declare int %fprintf(%struct._IO_FILE*, sbyte*, ...)
implementation
int %foo()
{
define i32 @foo() {
entry:
%tmp.1 = load %struct._IO_FILE** %stdout
%tmp.0 = call int (%struct._IO_FILE*, sbyte*, ...)* %fprintf( %struct._IO_FILE* %tmp.1, sbyte* getelementptr ([13 x sbyte]* %hello, int 0, int 0) )
%tmp.4 = load %struct._IO_FILE** %stdout
%tmp.3 = call int (%struct._IO_FILE*, sbyte*, ...)* %fprintf( %struct._IO_FILE* %tmp.4, sbyte* getelementptr ([3 x sbyte]* %str, int 0, int 0), sbyte* getelementptr ([13 x sbyte]* %hello, int 0, int 0) )
%tmp.8 = load %struct._IO_FILE** %stdout
%tmp.7 = call int (%struct._IO_FILE*, sbyte*, ...)* %fprintf( %struct._IO_FILE* %tmp.8, sbyte* getelementptr ([3 x sbyte]* %chr, int 0, int 0), int 33 )
ret int 0
%tmp.1 = load %struct._IO_FILE** @stdout ; <%struct._IO_FILE*> [#uses=1]
%tmp.0 = call i32 (%struct._IO_FILE*, i8*, ...)* @fprintf( %struct._IO_FILE* %tmp.1, i8* getelementptr ([13 x i8]* @hello, i32 0, i32 0) ) ; <i32> [#uses=0]
%tmp.4 = load %struct._IO_FILE** @stdout ; <%struct._IO_FILE*> [#uses=1]
%tmp.3 = call i32 (%struct._IO_FILE*, i8*, ...)* @fprintf( %struct._IO_FILE* %tmp.4, i8* getelementptr ([3 x i8]* @str, i32 0, i32 0), i8* getelementptr ([13 x i8]* @hello, i32 0, i32 0) ) ; <i32> [#uses=0]
%tmp.8 = load %struct._IO_FILE** @stdout ; <%struct._IO_FILE*> [#uses=1]
%tmp.7 = call i32 (%struct._IO_FILE*, i8*, ...)* @fprintf( %struct._IO_FILE* %tmp.8, i8* getelementptr ([3 x i8]* @chr, i32 0, i32 0), i32 33 ) ; <i32> [#uses=0]
ret i32 0
}

View File

@@ -1,21 +1,21 @@
; Test that the IsDigitOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep call
declare int %isdigit(int)
declare int %isascii(int)
declare i32 @isdigit(i32)
implementation ; Functions:
declare i32 @isascii(i32)
int %main () {
%val1 = call int %isdigit(int 47)
%val2 = call int %isdigit(int 48)
%val3 = call int %isdigit(int 57)
%val4 = call int %isdigit(int 58)
%rslt1 = add int %val1, %val2
%rslt2 = add int %val3, %val4
%sum = add int %rslt1, %rslt2
%rslt = call int %isdigit(int %sum)
%tmp = call int %isascii(int %rslt)
ret int %tmp
define i32 @main() {
%val1 = call i32 @isdigit( i32 47 ) ; <i32> [#uses=1]
%val2 = call i32 @isdigit( i32 48 ) ; <i32> [#uses=1]
%val3 = call i32 @isdigit( i32 57 ) ; <i32> [#uses=1]
%val4 = call i32 @isdigit( i32 58 ) ; <i32> [#uses=1]
%rslt1 = add i32 %val1, %val2 ; <i32> [#uses=1]
%rslt2 = add i32 %val3, %val4 ; <i32> [#uses=1]
%sum = add i32 %rslt1, %rslt2 ; <i32> [#uses=1]
%rslt = call i32 @isdigit( i32 %sum ) ; <i32> [#uses=1]
%tmp = call i32 @isascii( i32 %rslt ) ; <i32> [#uses=1]
ret i32 %tmp
}

View File

@@ -1,22 +1,22 @@
; Test that the StrCatOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -constprop -simplify-libcalls | \
; RUN: llvm-as < %s | opt -constprop -simplify-libcalls | \
; RUN: llvm-dis | not grep {call.*llvm.memcpy.i32}
declare void %llvm.memcpy.i32(sbyte*,sbyte*,uint,uint)
%h = constant [2 x sbyte] c"h\00"
%hel = constant [4 x sbyte] c"hel\00"
%hello_u = constant [8 x sbyte] c"hello_u\00"
@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]
implementation ; Functions:
declare void @llvm.memcpy.i32(i8*, i8*, i32, i32)
int %main () {
%h_p = getelementptr [2 x sbyte]* %h, int 0, int 0
%hel_p = getelementptr [4 x sbyte]* %hel, int 0, int 0
%hello_u_p = getelementptr [8 x sbyte]* %hello_u, int 0, int 0
%target = alloca [1024 x sbyte]
%target_p = getelementptr [1024 x sbyte]* %target, int 0, int 0
call void %llvm.memcpy.i32(sbyte* %target_p, sbyte* %h_p, uint 2, uint 2)
call void %llvm.memcpy.i32(sbyte* %target_p, sbyte* %hel_p, uint 4, uint 4)
call void %llvm.memcpy.i32(sbyte* %target_p, sbyte* %hello_u_p, uint 8, uint 8)
ret int 0
define i32 @main() {
%h_p = getelementptr [2 x i8]* @h, i32 0, i32 0 ; <i8*> [#uses=1]
%hel_p = getelementptr [4 x i8]* @hel, i32 0, i32 0 ; <i8*> [#uses=1]
%hello_u_p = getelementptr [8 x i8]* @hello_u, i32 0, i32 0 ; <i8*> [#uses=1]
%target = alloca [1024 x i8] ; <[1024 x i8]*> [#uses=1]
%target_p = getelementptr [1024 x i8]* %target, i32 0, i32 0 ; <i8*> [#uses=3]
call void @llvm.memcpy.i32( i8* %target_p, i8* %h_p, i32 2, i32 2 )
call void @llvm.memcpy.i32( i8* %target_p, i8* %hel_p, i32 4, i32 4 )
call void @llvm.memcpy.i32( i8* %target_p, i8* %hello_u_p, i32 8, i32 8 )
ret i32 0
}

View File

@@ -1,22 +1,22 @@
; Test that the StrCatOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -constprop -simplify-libcalls | \
; RUN: llvm-as < %s | opt -constprop -simplify-libcalls | \
; RUN: llvm-dis | not grep {call.*llvm.memmove.i32}
declare void %llvm.memmove.i32(sbyte*,sbyte*,uint,uint)
%h = constant [2 x sbyte] c"h\00"
%hel = constant [4 x sbyte] c"hel\00"
%hello_u = constant [8 x sbyte] c"hello_u\00"
@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]
implementation ; Functions:
declare void @llvm.memmove.i32(i8*, i8*, i32, i32)
int %main () {
%h_p = getelementptr [2 x sbyte]* %h, int 0, int 0
%hel_p = getelementptr [4 x sbyte]* %hel, int 0, int 0
%hello_u_p = getelementptr [8 x sbyte]* %hello_u, int 0, int 0
%target = alloca [1024 x sbyte]
%target_p = getelementptr [1024 x sbyte]* %target, int 0, int 0
call void %llvm.memmove.i32(sbyte* %target_p, sbyte* %h_p, uint 2, uint 2)
call void %llvm.memmove.i32(sbyte* %target_p, sbyte* %hel_p, uint 4, uint 4)
call void %llvm.memmove.i32(sbyte* %target_p, sbyte* %hello_u_p, uint 8, uint 8)
ret int 0
define i32 @main() {
%h_p = getelementptr [2 x i8]* @h, i32 0, i32 0 ; <i8*> [#uses=1]
%hel_p = getelementptr [4 x i8]* @hel, i32 0, i32 0 ; <i8*> [#uses=1]
%hello_u_p = getelementptr [8 x i8]* @hello_u, i32 0, i32 0 ; <i8*> [#uses=1]
%target = alloca [1024 x i8] ; <[1024 x i8]*> [#uses=1]
%target_p = getelementptr [1024 x i8]* %target, i32 0, i32 0 ; <i8*> [#uses=3]
call void @llvm.memmove.i32( i8* %target_p, i8* %h_p, i32 2, i32 2 )
call void @llvm.memmove.i32( i8* %target_p, i8* %hel_p, i32 4, i32 4 )
call void @llvm.memmove.i32( i8* %target_p, i8* %hello_u_p, i32 8, i32 8 )
ret i32 0
}

View File

@@ -1,19 +1,18 @@
; Test that the LLVMMemSetOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*llvm.memset}
; END.
declare void %llvm.memset.i32(sbyte*,ubyte,uint,uint)
declare void @llvm.memset.i32(i8*, i8, i32, i32)
implementation ; Functions:
int %main () {
%target = alloca [1024 x sbyte]
%target_p = getelementptr [1024 x sbyte]* %target, int 0, int 0
call void %llvm.memset.i32(sbyte* %target_p, ubyte 1, uint 0, uint 1)
call void %llvm.memset.i32(sbyte* %target_p, ubyte 1, uint 1, uint 1)
call void %llvm.memset.i32(sbyte* %target_p, ubyte 1, uint 2, uint 2)
call void %llvm.memset.i32(sbyte* %target_p, ubyte 1, uint 4, uint 4)
call void %llvm.memset.i32(sbyte* %target_p, ubyte 1, uint 8, uint 8)
ret int 0
define i32 @main() {
%target = alloca [1024 x i8] ; <[1024 x i8]*> [#uses=1]
%target_p = getelementptr [1024 x i8]* %target, i32 0, i32 0 ; <i8*> [#uses=5]
call void @llvm.memset.i32( i8* %target_p, i8 1, i32 0, i32 1 )
call void @llvm.memset.i32( i8* %target_p, i8 1, i32 1, i32 1 )
call void @llvm.memset.i32( i8* %target_p, i8 1, i32 2, i32 2 )
call void @llvm.memset.i32( i8* %target_p, i8 1, i32 4, i32 4 )
call void @llvm.memset.i32( i8* %target_p, i8 1, i32 8, i32 8 )
ret i32 0
}

View File

@@ -1,24 +1,24 @@
; Testcase for calls to the standard C "pow" function
;
; Equivalent to: http://gcc.gnu.org/ml/gcc-patches/2003-02/msg01786.html
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call double .pow}
; END.
declare double %pow(double, double)
declare double @pow(double, double)
double %test1(double %X) {
%Y = call double %pow(double %X, double 0.0)
ret double %Y ; x^0.0 always equals 1.0
define double @test1(double %X) {
%Y = call double @pow( double %X, double 0.000000e+00 ) ; <double> [#uses=1]
ret double %Y
}
double %test2(double %X) {
%Y = call double %pow(double %X, double -0.0)
ret double %Y ; x^-0.0 always equals 1.0
define double @test2(double %X) {
%Y = call double @pow( double %X, double -0.000000e+00 ) ; <double> [#uses=1]
ret double %Y
}
double %test3(double %X) {
%Y = call double %pow(double 1.0, double %X)
ret double %Y ; 1.0^x always equals 1.0
define double @test3(double %X) {
%Y = call double @pow( double 1.000000e+00, double %X ) ; <double> [#uses=1]
ret double %Y
}

View File

@@ -1,27 +1,26 @@
; Test that the PutsCatOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*fputs}
;
%struct._IO_FILE = type { int, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, %struct._IO_marker*, %struct._IO_FILE*, int, int, int, ushort, sbyte, [1 x sbyte], sbyte*, long, sbyte*, sbyte*, int, [52 x sbyte] }
%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, int }
%stdout = external global %struct._IO_FILE* ; <%struct._IO_FILE**> [#uses=1]
declare int %fputs(sbyte*, %struct._IO_FILE*)
%struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i32, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i32, [52 x i8] }
%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 }
@stdout = external global %struct._IO_FILE* ; <%struct._IO_FILE**> [#uses=1]
@empty = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1]
@len1 = constant [2 x i8] c"A\00" ; <[2 x i8]*> [#uses=1]
@long = constant [7 x i8] c"hello\0A\00" ; <[7 x i8]*> [#uses=1]
%empty = constant [1 x sbyte] c"\00"
%len1 = constant [2 x sbyte] c"A\00"
%long = constant [7 x sbyte] c"hello\0A\00"
declare i32 @fputs(i8*, %struct._IO_FILE*)
implementation ; Functions:
int %main() {
define i32 @main() {
entry:
%out = load %struct._IO_FILE** %stdout
%s1 = getelementptr [1 x sbyte]* %empty, int 0, int 0
%s2 = getelementptr [2 x sbyte]* %len1, int 0, int 0
%s3 = getelementptr [7 x sbyte]* %long, int 0, int 0
%a = call int %fputs( sbyte* %s1, %struct._IO_FILE* %out )
%b = call int %fputs( sbyte* %s2, %struct._IO_FILE* %out )
%c = call int %fputs( sbyte* %s3, %struct._IO_FILE* %out )
ret int 0
%out = load %struct._IO_FILE** @stdout ; <%struct._IO_FILE*> [#uses=3]
%s1 = getelementptr [1 x i8]* @empty, i32 0, i32 0 ; <i8*> [#uses=1]
%s2 = getelementptr [2 x i8]* @len1, i32 0, i32 0 ; <i8*> [#uses=1]
%s3 = getelementptr [7 x i8]* @long, i32 0, i32 0 ; <i8*> [#uses=1]
%a = call i32 @fputs( i8* %s1, %struct._IO_FILE* %out ) ; <i32> [#uses=0]
%b = call i32 @fputs( i8* %s2, %struct._IO_FILE* %out ) ; <i32> [#uses=0]
%c = call i32 @fputs( i8* %s3, %struct._IO_FILE* %out ) ; <i32> [#uses=0]
ret i32 0
}

View File

@@ -1,36 +1,36 @@
; Test that the SPrintFOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*sprintf}
declare int %sprintf(sbyte*,sbyte*,...)
declare int %puts(sbyte*)
%hello = constant [6 x sbyte] c"hello\00"
%null = constant [1 x sbyte] c"\00"
%null_hello = constant [7 x sbyte] c"\00hello\00"
%fmt1 = constant [3 x sbyte] c"%s\00"
%fmt2 = constant [3 x sbyte] c"%c\00"
@hello = constant [6 x i8] c"hello\00" ; <[6 x i8]*> [#uses=1]
@null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1]
@null_hello = constant [7 x i8] c"\00hello\00" ; <[7 x i8]*> [#uses=1]
@fmt1 = constant [3 x i8] c"%s\00" ; <[3 x i8]*> [#uses=1]
@fmt2 = constant [3 x i8] c"%c\00" ; <[3 x i8]*> [#uses=1]
implementation ; Functions:
declare i32 @sprintf(i8*, i8*, ...)
int %foo (sbyte* %p) {
%target = alloca [1024 x sbyte]
%target_p = getelementptr [1024 x sbyte]* %target, int 0, int 0
%hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
%null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
%nh_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
%fmt1_p = getelementptr [3 x sbyte]* %fmt1, int 0, int 0
%fmt2_p = getelementptr [3 x sbyte]* %fmt2, int 0, int 0
store sbyte 0, sbyte* %target_p
%r1 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %hello_p)
%r2 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %null_p)
%r3 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %nh_p)
%r4 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %fmt1_p, sbyte* %hello_p)
%r4.1 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %fmt1_p, sbyte* %p)
%r5 = call int (sbyte*,sbyte*,...)* %sprintf(sbyte* %target_p, sbyte* %fmt2_p, int 82)
%r6 = add int %r1, %r2
%r7 = add int %r3, %r6
%r8 = add int %r5, %r7
%r9 = add int %r8, %r4
%r10 = add int %r9, %r4.1
ret int %r10
declare i32 @puts(i8*)
define i32 @foo(i8* %p) {
%target = alloca [1024 x i8] ; <[1024 x i8]*> [#uses=1]
%target_p = getelementptr [1024 x i8]* %target, i32 0, i32 0 ; <i8*> [#uses=7]
%hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=2]
%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=1]
%nh_p = getelementptr [7 x i8]* @null_hello, i32 0, i32 0 ; <i8*> [#uses=1]
%fmt1_p = getelementptr [3 x i8]* @fmt1, i32 0, i32 0 ; <i8*> [#uses=2]
%fmt2_p = getelementptr [3 x i8]* @fmt2, i32 0, i32 0 ; <i8*> [#uses=1]
store i8 0, i8* %target_p
%r1 = call i32 (i8*, i8*, ...)* @sprintf( i8* %target_p, i8* %hello_p ) ; <i32> [#uses=1]
%r2 = call i32 (i8*, i8*, ...)* @sprintf( i8* %target_p, i8* %null_p ) ; <i32> [#uses=1]
%r3 = call i32 (i8*, i8*, ...)* @sprintf( i8* %target_p, i8* %nh_p ) ; <i32> [#uses=1]
%r4 = call i32 (i8*, i8*, ...)* @sprintf( i8* %target_p, i8* %fmt1_p, i8* %hello_p ) ; <i32> [#uses=1]
%r4.1 = call i32 (i8*, i8*, ...)* @sprintf( i8* %target_p, i8* %fmt1_p, i8* %p ) ; <i32> [#uses=1]
%r5 = call i32 (i8*, i8*, ...)* @sprintf( i8* %target_p, i8* %fmt2_p, i32 82 ) ; <i32> [#uses=1]
%r6 = add i32 %r1, %r2 ; <i32> [#uses=1]
%r7 = add i32 %r3, %r6 ; <i32> [#uses=1]
%r8 = add i32 %r5, %r7 ; <i32> [#uses=1]
%r9 = add i32 %r8, %r4 ; <i32> [#uses=1]
%r10 = add i32 %r9, %r4.1 ; <i32> [#uses=1]
ret i32 %r10
}

View File

@@ -1,25 +1,26 @@
; Test that the StrCatOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*strcat}
declare sbyte* %strcat(sbyte*,sbyte*)
declare int %puts(sbyte*)
%hello = constant [6 x sbyte] c"hello\00"
%null = constant [1 x sbyte] c"\00"
%null_hello = constant [7 x sbyte] c"\00hello\00"
@hello = constant [6 x i8] c"hello\00" ; <[6 x i8]*> [#uses=1]
@null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1]
@null_hello = constant [7 x i8] c"\00hello\00" ; <[7 x i8]*> [#uses=1]
implementation ; Functions:
declare i8* @strcat(i8*, i8*)
int %main () {
%target = alloca [1024 x sbyte]
%arg1 = getelementptr [1024 x sbyte]* %target, int 0, int 0
store sbyte 0, sbyte* %arg1
%arg2 = getelementptr [6 x sbyte]* %hello, int 0, int 0
%rslt1 = call sbyte* %strcat(sbyte* %arg1, sbyte* %arg2)
%arg3 = getelementptr [1 x sbyte]* %null, int 0, int 0
%rslt2 = call sbyte* %strcat(sbyte* %rslt1, sbyte* %arg3)
%arg4 = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
%rslt3 = call sbyte* %strcat(sbyte* %rslt2, sbyte* %arg4)
call int %puts(sbyte* %rslt3)
ret int 0
declare i32 @puts(i8*)
define i32 @main() {
%target = alloca [1024 x i8] ; <[1024 x i8]*> [#uses=1]
%arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 ; <i8*> [#uses=2]
store i8 0, i8* %arg1
%arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=1]
%rslt1 = call i8* @strcat( i8* %arg1, i8* %arg2 ) ; <i8*> [#uses=1]
%arg3 = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=1]
%rslt2 = call i8* @strcat( i8* %rslt1, i8* %arg3 ) ; <i8*> [#uses=1]
%arg4 = getelementptr [7 x i8]* @null_hello, i32 0, i32 0 ; <i8*> [#uses=1]
%rslt3 = call i8* @strcat( i8* %rslt2, i8* %arg4 ) ; <i8*> [#uses=1]
call i32 @puts( i8* %rslt3 ) ; <i32>:1 [#uses=0]
ret i32 0
}

View File

@@ -1,22 +1,22 @@
; Test that the StrChrOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*%strchr}
declare sbyte* %strchr(sbyte*,int)
declare int %puts(sbyte*)
%hello = constant [14 x sbyte] c"hello world\n\00"
%null = constant [1 x sbyte] c"\00"
@hello = constant [14 x i8] c"hello world\5Cn\00" ; <[14 x i8]*> [#uses=1]
@null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1]
implementation ; Functions:
declare i8* @strchr(i8*, i32)
int %main () {
%hello_p = getelementptr [14 x sbyte]* %hello, int 0, int 0
%null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
declare i32 @puts(i8*)
%world = call sbyte* %strchr(sbyte* %hello_p, int 119 )
%ignore = call sbyte* %strchr(sbyte* %null_p, int 119 )
%len = call int %puts(sbyte* %world)
%index = add int %len, 112
%result = call sbyte* %strchr(sbyte* %hello_p, int %index)
ret int %index
define i32 @main() {
%hello_p = getelementptr [14 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=2]
%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=1]
%world = call i8* @strchr( i8* %hello_p, i32 119 ) ; <i8*> [#uses=1]
%ignore = call i8* @strchr( i8* %null_p, i32 119 ) ; <i8*> [#uses=0]
%len = call i32 @puts( i8* %world ) ; <i32> [#uses=1]
%index = add i32 %len, 112 ; <i32> [#uses=2]
%result = call i8* @strchr( i8* %hello_p, i32 %index ) ; <i8*> [#uses=0]
ret i32 %index
}

View File

@@ -1,27 +1,28 @@
; Test that the StrCmpOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*strcmp}
declare int %strcmp(sbyte*,sbyte*)
declare int %puts(sbyte*)
%hello = constant [6 x sbyte] c"hello\00"
%hell = constant [5 x sbyte] c"hell\00"
%null = constant [1 x sbyte] c"\00"
@hello = constant [6 x i8] c"hello\00" ; <[6 x i8]*> [#uses=1]
@hell = constant [5 x i8] c"hell\00" ; <[5 x i8]*> [#uses=1]
@null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1]
implementation ; Functions:
declare i32 @strcmp(i8*, i8*)
int %main () {
%hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
%hell_p = getelementptr [5 x sbyte]* %hell, int 0, int 0
%null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
%temp1 = call int %strcmp(sbyte* %hello_p, sbyte* %hello_p)
%temp2 = call int %strcmp(sbyte* %null_p, sbyte* %null_p)
%temp3 = call int %strcmp(sbyte* %hello_p, sbyte* %null_p)
%temp4 = call int %strcmp(sbyte* %null_p, sbyte* %hello_p)
%temp5 = call int %strcmp(sbyte* %hell_p, sbyte* %hello_p)
%rslt1 = add int %temp1, %temp2
%rslt2 = add int %rslt1, %temp3
%rslt3 = add int %rslt2, %temp4
%rslt4 = add int %rslt3, %temp5
ret int %rslt4
declare i32 @puts(i8*)
define i32 @main() {
%hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=5]
%hell_p = getelementptr [5 x i8]* @hell, i32 0, i32 0 ; <i8*> [#uses=1]
%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=4]
%temp1 = call i32 @strcmp( i8* %hello_p, i8* %hello_p ) ; <i32> [#uses=1]
%temp2 = call i32 @strcmp( i8* %null_p, i8* %null_p ) ; <i32> [#uses=1]
%temp3 = call i32 @strcmp( i8* %hello_p, i8* %null_p ) ; <i32> [#uses=1]
%temp4 = call i32 @strcmp( i8* %null_p, i8* %hello_p ) ; <i32> [#uses=1]
%temp5 = call i32 @strcmp( i8* %hell_p, i8* %hello_p ) ; <i32> [#uses=1]
%rslt1 = add i32 %temp1, %temp2 ; <i32> [#uses=1]
%rslt2 = add i32 %rslt1, %temp3 ; <i32> [#uses=1]
%rslt3 = add i32 %rslt2, %temp4 ; <i32> [#uses=1]
%rslt4 = add i32 %rslt3, %temp5 ; <i32> [#uses=1]
ret i32 %rslt4
}

View File

@@ -1,25 +1,26 @@
; Test that the StrCpyOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*strcpy}
declare sbyte* %strcpy(sbyte*,sbyte*)
declare int %puts(sbyte*)
%hello = constant [6 x sbyte] c"hello\00"
%null = constant [1 x sbyte] c"\00"
%null_hello = constant [7 x sbyte] c"\00hello\00"
@hello = constant [6 x i8] c"hello\00" ; <[6 x i8]*> [#uses=1]
@null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1]
@null_hello = constant [7 x i8] c"\00hello\00" ; <[7 x i8]*> [#uses=1]
implementation ; Functions:
declare i8* @strcpy(i8*, i8*)
int %main () {
%target = alloca [1024 x sbyte]
%arg1 = getelementptr [1024 x sbyte]* %target, int 0, int 0
store sbyte 0, sbyte* %arg1
%arg2 = getelementptr [6 x sbyte]* %hello, int 0, int 0
%rslt1 = call sbyte* %strcpy(sbyte* %arg1, sbyte* %arg2)
%arg3 = getelementptr [1 x sbyte]* %null, int 0, int 0
%rslt2 = call sbyte* %strcpy(sbyte* %rslt1, sbyte* %arg3)
%arg4 = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
%rslt3 = call sbyte* %strcpy(sbyte* %rslt2, sbyte* %arg4)
call int %puts(sbyte* %rslt3)
ret int 0
declare i32 @puts(i8*)
define i32 @main() {
%target = alloca [1024 x i8] ; <[1024 x i8]*> [#uses=1]
%arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 ; <i8*> [#uses=2]
store i8 0, i8* %arg1
%arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=1]
%rslt1 = call i8* @strcpy( i8* %arg1, i8* %arg2 ) ; <i8*> [#uses=1]
%arg3 = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=1]
%rslt2 = call i8* @strcpy( i8* %rslt1, i8* %arg3 ) ; <i8*> [#uses=1]
%arg4 = getelementptr [7 x i8]* @null_hello, i32 0, i32 0 ; <i8*> [#uses=1]
%rslt3 = call i8* @strcpy( i8* %rslt2, i8* %arg4 ) ; <i8*> [#uses=1]
call i32 @puts( i8* %rslt3 ) ; <i32>:1 [#uses=0]
ret i32 0
}

View File

@@ -1,58 +1,56 @@
; Test that the StrCatOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*strlen}
target datalayout = "e-p:32:32"
@hello = constant [6 x i8] c"hello\00" ; <[6 x i8]*> [#uses=3]
@null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=3]
@null_hello = constant [7 x i8] c"\00hello\00" ; <[7 x i8]*> [#uses=1]
declare uint %strlen(sbyte*)
%hello = constant [6 x sbyte] c"hello\00"
%null = constant [1 x sbyte] c"\00"
%null_hello = constant [7 x sbyte] c"\00hello\00"
declare i32 @strlen(i8*)
implementation ; Functions:
uint %test1() {
%hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
%hello_l = call uint %strlen(sbyte* %hello_p)
ret uint %hello_l
define i32 @test1() {
%hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=1]
%hello_l = call i32 @strlen( i8* %hello_p ) ; <i32> [#uses=1]
ret i32 %hello_l
}
uint %test2() {
%null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
%null_l = call uint %strlen(sbyte* %null_p)
ret uint %null_l
define i32 @test2() {
%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=1]
%null_l = call i32 @strlen( i8* %null_p ) ; <i32> [#uses=1]
ret i32 %null_l
}
uint %test3() {
%null_hello_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
%null_hello_l = call uint %strlen(sbyte* %null_hello_p)
ret uint %null_hello_l
define i32 @test3() {
%null_hello_p = getelementptr [7 x i8]* @null_hello, i32 0, i32 0 ; <i8*> [#uses=1]
%null_hello_l = call i32 @strlen( i8* %null_hello_p ) ; <i32> [#uses=1]
ret i32 %null_hello_l
}
bool %test4() {
%hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
%hello_l = call uint %strlen(sbyte* %hello_p)
%eq_hello = seteq uint %hello_l, 0
ret bool %eq_hello
define i1 @test4() {
%hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=1]
%hello_l = call i32 @strlen( i8* %hello_p ) ; <i32> [#uses=1]
%eq_hello = icmp eq i32 %hello_l, 0 ; <i1> [#uses=1]
ret i1 %eq_hello
}
bool %test5() {
%null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
%null_l = call uint %strlen(sbyte* %null_p)
%eq_null = seteq uint %null_l, 0
ret bool %eq_null
define i1 @test5() {
%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=1]
%null_l = call i32 @strlen( i8* %null_p ) ; <i32> [#uses=1]
%eq_null = icmp eq i32 %null_l, 0 ; <i1> [#uses=1]
ret i1 %eq_null
}
bool %test6() {
%hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
%hello_l = call uint %strlen(sbyte* %hello_p)
%ne_hello = setne uint %hello_l, 0
ret bool %ne_hello
define i1 @test6() {
%hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=1]
%hello_l = call i32 @strlen( i8* %hello_p ) ; <i32> [#uses=1]
%ne_hello = icmp ne i32 %hello_l, 0 ; <i1> [#uses=1]
ret i1 %ne_hello
}
bool %test7() {
%null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
%null_l = call uint %strlen(sbyte* %null_p)
%ne_null = setne uint %null_l, 0
ret bool %ne_null
define i1 @test7() {
%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=1]
%null_l = call i32 @strlen( i8* %null_p ) ; <i32> [#uses=1]
%ne_null = icmp ne i32 %null_l, 0 ; <i1> [#uses=1]
ret i1 %ne_null
}

View File

@@ -1,27 +1,28 @@
; Test that the StrNCmpOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*strncmp}
declare int %strncmp(sbyte*,sbyte*,int)
declare int %puts(sbyte*)
%hello = constant [6 x sbyte] c"hello\00"
%hell = constant [5 x sbyte] c"hell\00"
%null = constant [1 x sbyte] c"\00"
@hello = constant [6 x i8] c"hello\00" ; <[6 x i8]*> [#uses=1]
@hell = constant [5 x i8] c"hell\00" ; <[5 x i8]*> [#uses=1]
@null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1]
implementation ; Functions:
declare i32 @strncmp(i8*, i8*, i32)
int %main () {
%hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
%hell_p = getelementptr [5 x sbyte]* %hell, int 0, int 0
%null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
%temp1 = call int %strncmp(sbyte* %hello_p, sbyte* %hello_p,int 5)
%temp2 = call int %strncmp(sbyte* %null_p, sbyte* %null_p,int 0)
%temp3 = call int %strncmp(sbyte* %hello_p, sbyte* %null_p,int 0)
%temp4 = call int %strncmp(sbyte* %null_p, sbyte* %hello_p,int 0)
%temp5 = call int %strncmp(sbyte* %hell_p, sbyte* %hello_p,int 4)
%rslt1 = add int %temp1, %temp2
%rslt2 = add int %rslt1, %temp3
%rslt3 = add int %rslt2, %temp4
%rslt4 = add int %rslt3, %temp5
ret int %rslt4
declare i32 @puts(i8*)
define i32 @main() {
%hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=5]
%hell_p = getelementptr [5 x i8]* @hell, i32 0, i32 0 ; <i8*> [#uses=1]
%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=4]
%temp1 = call i32 @strncmp( i8* %hello_p, i8* %hello_p, i32 5 ) ; <i32> [#uses=1]
%temp2 = call i32 @strncmp( i8* %null_p, i8* %null_p, i32 0 ) ; <i32> [#uses=1]
%temp3 = call i32 @strncmp( i8* %hello_p, i8* %null_p, i32 0 ) ; <i32> [#uses=1]
%temp4 = call i32 @strncmp( i8* %null_p, i8* %hello_p, i32 0 ) ; <i32> [#uses=1]
%temp5 = call i32 @strncmp( i8* %hell_p, i8* %hello_p, i32 4 ) ; <i32> [#uses=1]
%rslt1 = add i32 %temp1, %temp2 ; <i32> [#uses=1]
%rslt2 = add i32 %rslt1, %temp3 ; <i32> [#uses=1]
%rslt3 = add i32 %rslt2, %temp4 ; <i32> [#uses=1]
%rslt4 = add i32 %rslt3, %temp5 ; <i32> [#uses=1]
ret i32 %rslt4
}

View File

@@ -1,22 +1,21 @@
; Test that the ToAsciiOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*toascii}
declare int %toascii(int)
declare i32 @toascii(i32)
implementation ; Functions:
int %main () {
%val1 = call int %toascii(int 1)
%val2 = call int %toascii(int 0)
%val3 = call int %toascii(int 127)
%val4 = call int %toascii(int 128)
%val5 = call int %toascii(int 255)
%val6 = call int %toascii(int 256)
%rslt1 = add int %val1, %val2
%rslt2 = add int %val3, %val4
%rslt3 = add int %val5, %val6
%rslt4 = add int %rslt1, %rslt2
%rslt5 = add int %rslt4, %rslt3
ret int %rslt5
define i32 @main() {
%val1 = call i32 @toascii( i32 1 ) ; <i32> [#uses=1]
%val2 = call i32 @toascii( i32 0 ) ; <i32> [#uses=1]
%val3 = call i32 @toascii( i32 127 ) ; <i32> [#uses=1]
%val4 = call i32 @toascii( i32 128 ) ; <i32> [#uses=1]
%val5 = call i32 @toascii( i32 255 ) ; <i32> [#uses=1]
%val6 = call i32 @toascii( i32 256 ) ; <i32> [#uses=1]
%rslt1 = add i32 %val1, %val2 ; <i32> [#uses=1]
%rslt2 = add i32 %val3, %val4 ; <i32> [#uses=1]
%rslt3 = add i32 %val5, %val6 ; <i32> [#uses=1]
%rslt4 = add i32 %rslt1, %rslt2 ; <i32> [#uses=1]
%rslt5 = add i32 %rslt4, %rslt3 ; <i32> [#uses=1]
ret i32 %rslt5
}

View File

@@ -1,4 +1,4 @@
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis > %t
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis > %t
; RUN: not grep {call.*floor(} %t
; RUN: grep {call.*floorf(} %t
; RUN: not grep {call.*ceil(} %t
@@ -7,28 +7,33 @@
; RUN: grep {call.*nearbyintf(} %t
; XFAIL: sparc
declare double %floor(double)
declare double %ceil(double)
declare double %nearbyint(double)
declare double @floor(double)
float %test_floor(float %C) {
%D = cast float %C to double
%E = call double %floor(double %D) ; --> floorf
%F = cast double %E to float
declare double @ceil(double)
declare double @nearbyint(double)
define float @test_floor(float %C) {
%D = fpext float %C to double ; <double> [#uses=1]
; --> floorf
%E = call double @floor( double %D ) ; <double> [#uses=1]
%F = fptrunc double %E to float ; <float> [#uses=1]
ret float %F
}
float %test_ceil(float %C) {
%D = cast float %C to double
%E = call double %ceil(double %D) ; --> ceilf
%F = cast double %E to float
define float @test_ceil(float %C) {
%D = fpext float %C to double ; <double> [#uses=1]
; --> ceilf
%E = call double @ceil( double %D ) ; <double> [#uses=1]
%F = fptrunc double %E to float ; <float> [#uses=1]
ret float %F
}
float %test_nearbyint(float %C) {
%D = cast float %C to double
%E = call double %nearbyint(double %D) ; --> floorf
%F = cast double %E to float
define float @test_nearbyint(float %C) {
%D = fpext float %C to double ; <double> [#uses=1]
; --> floorf
%E = call double @nearbyint( double %D ) ; <double> [#uses=1]
%F = fptrunc double %E to float ; <float> [#uses=1]
ret float %F
}

View File

@@ -1,24 +1,24 @@
; Test that the memcmpOptimizer works correctly
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
; RUN: not grep {call.*memcmp}
; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls -disable-output
; RUN: llvm-as < %s | opt -simplify-libcalls -disable-output
declare int %memcmp(sbyte*,sbyte*,int)
%h = constant [2 x sbyte] c"h\00"
%hel = constant [4 x sbyte] c"hel\00"
%hello_u = constant [8 x sbyte] c"hello_u\00"
@h = constant [2 x i8] c"h\00" ; <[2 x i8]*> [#uses=0]
@hel = constant [4 x i8] c"hel\00" ; <[4 x i8]*> [#uses=0]
@hello_u = constant [8 x i8] c"hello_u\00" ; <[8 x i8]*> [#uses=0]
implementation
declare i32 @memcmp(i8*, i8*, i32)
void %test(sbyte *%P, sbyte *%Q, int %N, int* %IP, bool *%BP) {
%A = call int %memcmp(sbyte *%P, sbyte* %P, int %N)
volatile store int %A, int* %IP
%B = call int %memcmp(sbyte *%P, sbyte* %Q, int 0)
volatile store int %B, int* %IP
%C = call int %memcmp(sbyte *%P, sbyte* %Q, int 1)
volatile store int %C, int* %IP
%D = call int %memcmp(sbyte *%P, sbyte* %Q, int 2)
%E = seteq int %D, 0
volatile store bool %E, bool* %BP
ret void
define void @test(i8* %P, i8* %Q, i32 %N, i32* %IP, i1* %BP) {
%A = call i32 @memcmp( i8* %P, i8* %P, i32 %N ) ; <i32> [#uses=1]
volatile store i32 %A, i32* %IP
%B = call i32 @memcmp( i8* %P, i8* %Q, i32 0 ) ; <i32> [#uses=1]
volatile store i32 %B, i32* %IP
%C = call i32 @memcmp( i8* %P, i8* %Q, i32 1 ) ; <i32> [#uses=1]
volatile store i32 %C, i32* %IP
%D = call i32 @memcmp( i8* %P, i8* %Q, i32 2 ) ; <i32> [#uses=1]
%E = icmp eq i32 %D, 0 ; <i1> [#uses=1]
volatile store i1 %E, i1* %BP
ret void
}