blob: ca4e48eb5ea4e0b2c3bd832e8d138746294c7100 [file] [log] [blame]
Tanya Lattner53a66d12008-02-19 01:41:04 +00001; RUN: llvm-as < %s | llc -march=c | \
Dan Gohman28beeea2007-08-15 13:36:28 +00002; RUN: grep __BITCAST | count 14
Reid Spencer711679e2006-12-11 20:40:28 +00003
Tanya Lattner53a66d12008-02-19 01:41:04 +00004define i32 @test1(float %F) {
5 %X = bitcast float %F to i32 ; <i32> [#uses=1]
6 ret i32 %X
Reid Spencer711679e2006-12-11 20:40:28 +00007}
8
Tanya Lattner53a66d12008-02-19 01:41:04 +00009define float @test2(i32 %I) {
10 %X = bitcast i32 %I to float ; <float> [#uses=1]
11 ret float %X
Reid Spencer711679e2006-12-11 20:40:28 +000012}
13
Tanya Lattner53a66d12008-02-19 01:41:04 +000014define i64 @test3(double %D) {
15 %X = bitcast double %D to i64 ; <i64> [#uses=1]
16 ret i64 %X
Reid Spencer711679e2006-12-11 20:40:28 +000017}
18
Tanya Lattner53a66d12008-02-19 01:41:04 +000019define double @test4(i64 %L) {
20 %X = bitcast i64 %L to double ; <double> [#uses=1]
21 ret double %X
Reid Spencer711679e2006-12-11 20:40:28 +000022}
23
Tanya Lattner53a66d12008-02-19 01:41:04 +000024define double @test5(double %D) {
25 %X = bitcast double %D to double ; <double> [#uses=1]
26 %Y = add double %X, 2.000000e+00 ; <double> [#uses=1]
27 %Z = bitcast double %Y to i64 ; <i64> [#uses=1]
28 %res = bitcast i64 %Z to double ; <double> [#uses=1]
29 ret double %res
Reid Spencer711679e2006-12-11 20:40:28 +000030}
31
Tanya Lattner53a66d12008-02-19 01:41:04 +000032define float @test6(float %F) {
33 %X = bitcast float %F to float ; <float> [#uses=1]
34 %Y = add float %X, 2.000000e+00 ; <float> [#uses=1]
35 %Z = bitcast float %Y to i32 ; <i32> [#uses=1]
36 %res = bitcast i32 %Z to float ; <float> [#uses=1]
37 ret float %res
Reid Spencer711679e2006-12-11 20:40:28 +000038}
39
Tanya Lattner53a66d12008-02-19 01:41:04 +000040define i32 @main(i32 %argc, i8** %argv) {
41 %a = call i32 @test1( float 0x400921FB40000000 ) ; <i32> [#uses=2]
42 %b = call float @test2( i32 %a ) ; <float> [#uses=0]
43 %c = call i64 @test3( double 0x400921FB4D12D84A ) ; <i64> [#uses=1]
44 %d = call double @test4( i64 %c ) ; <double> [#uses=0]
45 %e = call double @test5( double 7.000000e+00 ) ; <double> [#uses=0]
46 %f = call float @test6( float 7.000000e+00 ) ; <float> [#uses=0]
47 ret i32 %a
Reid Spencer711679e2006-12-11 20:40:28 +000048}
Tanya Lattner53a66d12008-02-19 01:41:04 +000049