blob: 1a38a7619debdaac3a002e171a982777f13f6796 [file] [log] [blame]
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -07001; Trivial smoke test of bitcast between integer and FP types.
2
Jim Stichnoth729dbd02015-02-25 14:48:43 -08003; RUN: %p2i --filetype=obj --disassemble -i %s --args -O2 | FileCheck %s
4; RUN: %p2i --filetype=obj --disassemble -i %s --args -Om1 | FileCheck %s
Jim Stichnothf7c9a142014-04-29 10:52:43 -07005
Jim Stichnoth033dda72016-10-03 07:56:25 -07006; RUN: %if --need=target_ARM32 --command %p2i --filetype=obj --disassemble \
7; RUN: --target arm32 -i %s --args -O2 \
8; RUN: | %if --need=target_ARM32 --command FileCheck %s \
John Portof977f712015-09-14 16:28:33 -07009; RUN: --check-prefix=ARM32
10
Jim Stichnoth033dda72016-10-03 07:56:25 -070011; RUN: %if --need=target_ARM32 --command %p2i --filetype=obj --disassemble \
12; RUN: --target arm32 -i %s --args -Om1 \
13; RUN: | %if --need=target_ARM32 --command FileCheck %s \
John Portof977f712015-09-14 16:28:33 -070014; RUN: --check-prefix=ARM32
15
Sagar Thakurb001cc42016-10-11 23:36:01 -070016; RUN: %if --need=target_MIPS32 --need=allow_dump \
17; RUN: --command %p2i --filetype=asm \
18; RUN: --target mips32 -i %s --args -O2 \
19; RUN: | %if --need=target_MIPS32 --need=allow_dump \
20; RUN: --command FileCheck %s \
21; RUN: --check-prefix=MIPS32 --check-prefix=MIPS32-O2
22
23; RUN: %if --need=target_MIPS32 --need=allow_dump \
24; RUN: --command %p2i --filetype=asm \
25; RUN: --target mips32 -i %s --args -Om1 \
26; RUN: | %if --need=target_MIPS32 --need=allow_dump \
27; RUN: --command FileCheck %s \
28; RUN: --check-prefix=MIPS32 --check-prefix=MIPS32-OM1
29
Jim Stichnothf7c9a142014-04-29 10:52:43 -070030define internal i32 @cast_f2i(float %f) {
31entry:
32 %v0 = bitcast float %f to i32
33 ret i32 %v0
34}
Jan Voung1ee34162014-06-24 13:43:30 -070035; CHECK-LABEL: cast_f2i
Jim Stichnotha1410df2016-06-16 10:02:48 -070036; CHECK: movd eax
John Portof977f712015-09-14 16:28:33 -070037; ARM32-LABEL: cast_f2i
38; ARM32: vmov r{{[0-9]+}}, s{{[0-9]+}}
Sagar Thakurb001cc42016-10-11 23:36:01 -070039; MIPS32-LABEL: cast_f2i
40; MIPS32-O2: mfc1 $v0, $f{{[0-9]+}}
41; MIPS32-OM1: swc1
42; MIPS32-OM1: lw
Jim Stichnothd97c7df2014-06-04 11:57:08 -070043
Jim Stichnothf7c9a142014-04-29 10:52:43 -070044define internal float @cast_i2f(i32 %i) {
45entry:
46 %v0 = bitcast i32 %i to float
47 ret float %v0
48}
Jan Voung1ee34162014-06-24 13:43:30 -070049; CHECK-LABEL: cast_i2f
Jan Vounga2703ae2015-02-19 11:27:44 -080050; CHECK: fld DWORD PTR
John Portof977f712015-09-14 16:28:33 -070051; ARM32-LABEL: cast_i2f
52; ARM32: vmov s{{[0-9]+}}, r{{[0-9]+}}
Sagar Thakurb001cc42016-10-11 23:36:01 -070053; MIPS32-LABEL: cast_i2f
54; MIPS32-O2: mtc1 $a0, $f{{[0-9]+}}
55; MIPS32-OM1: sw
56; MIPS32-OM1: lwc1
Jim Stichnothd97c7df2014-06-04 11:57:08 -070057
Jim Stichnothf7c9a142014-04-29 10:52:43 -070058define internal i64 @cast_d2ll(double %d) {
59entry:
60 %v0 = bitcast double %d to i64
61 ret i64 %v0
62}
Jan Voung1ee34162014-06-24 13:43:30 -070063; CHECK-LABEL: cast_d2ll
64; CHECK: mov edx
John Portof977f712015-09-14 16:28:33 -070065; ARM32-LABEL: cast_d2ll
66; ARM32: vmov r{{[0-9]+}}, r{{[0-9]+}}, d{{[0-9]+}}
Sagar Thakurb001cc42016-10-11 23:36:01 -070067; MIPS32-LABEL: cast_d2ll
Jaydeep Patil2bbda7f2017-01-10 21:48:58 -080068; MIPS32-O2: swc1 $f13, {{.*}}
69; MIPS32-O2: swc1 $f12, {{.*}}
70; MIPS32-O2: lw $v0, {{.*}}
71; MIPS32-O2: lw $v1, {{.*}}
Sagar Thakurb001cc42016-10-11 23:36:01 -070072; MIPS32-OM1: sdc1
73; MIPS32-OM1: lw
74; MIPS32-OM1: lw
Jim Stichnothf7c9a142014-04-29 10:52:43 -070075
Jan Voung1ee34162014-06-24 13:43:30 -070076define internal i64 @cast_d2ll_const() {
77entry:
78 %v0 = bitcast double 0x12345678901234 to i64
79 ret i64 %v0
80}
81; CHECK-LABEL: cast_d2ll_const
Jim Stichnothe922c232016-04-09 08:54:20 -070082; CHECK: mov e{{..}},{{(DWORD PTR )?}}ds:0x0 {{.*}} {{.*}}0012345678901234
83; CHECK: mov e{{..}},{{(DWORD PTR )?}}ds:0x4 {{.*}} {{.*}}0012345678901234
John Portof977f712015-09-14 16:28:33 -070084; ARM32-LABEL: cast_d2ll_const
Jim Stichnoth033dda72016-10-03 07:56:25 -070085; ARM32-DAG: movw [[ADDR:r[0-9]+]], #{{.*_MOVW_}}
86; ARM32-DAG: movt [[ADDR]], #{{.*_MOVT_}}
John Portoba6a67c2015-09-25 15:19:45 -070087; ARM32-DAG: vldr [[DREG:d[0-9]+]], {{\[}}[[ADDR]]{{\]}}
John Portof977f712015-09-14 16:28:33 -070088; ARM32: vmov r{{[0-9]+}}, r{{[0-9]+}}, [[DREG]]
Sagar Thakurb001cc42016-10-11 23:36:01 -070089; MIPS32-LABEL: cast_d2ll_const
90; MIPS32: lui {{.*}}, %hi(.L$double$0012345678901234)
91; MIPS32: ldc1 {{.*}}, %lo(.L$double$0012345678901234)({{.*}})
Jaydeep Patil2bbda7f2017-01-10 21:48:58 -080092; MIPS32: swc1 $f{{[0-9]+}}, {{.*}}
93; MIPS32: swc1 $f{{[0-9]+}}, {{.*}}
94; MIPS32: lw $v0, {{.*}}
95; MIPS32: lw $v1, {{.*}}
Jim Stichnothd97c7df2014-06-04 11:57:08 -070096
Jim Stichnothf7c9a142014-04-29 10:52:43 -070097define internal double @cast_ll2d(i64 %ll) {
98entry:
99 %v0 = bitcast i64 %ll to double
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700100 ret double %v0
101}
Jan Voung1ee34162014-06-24 13:43:30 -0700102; CHECK-LABEL: cast_ll2d
Jan Vounga2703ae2015-02-19 11:27:44 -0800103; CHECK: fld QWORD PTR
John Portof977f712015-09-14 16:28:33 -0700104; ARM32-LABEL: cast_ll2d
105; ARM32: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
Sagar Thakurb001cc42016-10-11 23:36:01 -0700106; MIPS32-LABEL: cast_ll2d
107; MIPS32-O2: mtc1 $a0, $f{{[0-9]+}}
108; MIPS32-O2: mtc1 $a1, $f{{[0-9]+}}
109; MIPS32-OM1: sw
110; MIPS32-OM1: sw
111; MIPS32-OM1: ldc1
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700112
Jan Voung1ee34162014-06-24 13:43:30 -0700113define internal double @cast_ll2d_const() {
114entry:
115 %v0 = bitcast i64 12345678901234 to double
116 ret double %v0
117}
118; CHECK-LABEL: cast_ll2d_const
Jan Vounga2703ae2015-02-19 11:27:44 -0800119; CHECK: mov {{.*}},0x73ce2ff2
120; CHECK: mov {{.*}},0xb3a
121; CHECK: fld QWORD PTR
John Portof977f712015-09-14 16:28:33 -0700122; ARM32-LABEL: cast_ll2d_const
123; ARM32-DAG: movw [[REG0:r[0-9]+]], #12274
124; ARM32-DAG: movt [[REG0:r[0-9]+]], #29646
125; ARM32-DAG: movw [[REG1:r[0-9]+]], #2874
126; ARM32: vmov d{{[0-9]+}}, [[REG0]], [[REG1]]
Sagar Thakurb001cc42016-10-11 23:36:01 -0700127; MIPS32-LABEL: cast_ll2d_const
128; MIPS32: lui {{.*}}, 29646
129; MIPS32: ori {{.*}}, {{.*}}, 12274
130; MIPS32: addiu {{.*}}, $zero, 2874
131; MIPS32-O2: mtc1 {{.*}}, $f{{[0-9]+}}
132; MIPS32-O2: mtc1 {{.*}}, $f{{[0-9]+}}
133; MIPS32-OM1: sw
134; MIPS32-OM1: sw
135; MIPS32-OM1: ldc1