blob: 3b43be46b4520922055052cfa0105217a019da68 [file] [log] [blame]
Chad Rosierfa8d8932011-06-24 19:23:04 +00001; RUN: llc < %s -mtriple=armv7-apple-ios | FileCheck %s
2
3@in = global float 0x400921FA00000000, align 4
4@iin = global i32 -1023, align 4
5@uin = global i32 1023, align 4
6
7declare void @foo_int32x4_t(<4 x i32>)
8
9; Test signed conversion.
10; CHECK: t1
Duncan Sands5f8397a2012-04-07 20:04:00 +000011; CHECK-NOT: {{vdiv|vmul}}
Chad Rosierfa8d8932011-06-24 19:23:04 +000012define void @t1() nounwind {
13entry:
Manman Ren1a5ff282013-04-30 17:52:57 +000014 %tmp = load i32* @iin, align 4
Chad Rosierfa8d8932011-06-24 19:23:04 +000015 %vecinit.i = insertelement <2 x i32> undef, i32 %tmp, i32 0
16 %vecinit2.i = insertelement <2 x i32> %vecinit.i, i32 %tmp, i32 1
17 %vcvt.i = sitofp <2 x i32> %vecinit2.i to <2 x float>
18 %div.i = fdiv <2 x float> %vcvt.i, <float 8.000000e+00, float 8.000000e+00>
19 tail call void @foo_float32x2_t(<2 x float> %div.i) nounwind
20 ret void
21}
22
23declare void @foo_float32x2_t(<2 x float>)
24
25; Test unsigned conversion.
26; CHECK: t2
Duncan Sands5f8397a2012-04-07 20:04:00 +000027; CHECK-NOT: {{vdiv|vmul}}
Chad Rosierfa8d8932011-06-24 19:23:04 +000028define void @t2() nounwind {
29entry:
Manman Ren1a5ff282013-04-30 17:52:57 +000030 %tmp = load i32* @uin, align 4
Chad Rosierfa8d8932011-06-24 19:23:04 +000031 %vecinit.i = insertelement <2 x i32> undef, i32 %tmp, i32 0
32 %vecinit2.i = insertelement <2 x i32> %vecinit.i, i32 %tmp, i32 1
33 %vcvt.i = uitofp <2 x i32> %vecinit2.i to <2 x float>
34 %div.i = fdiv <2 x float> %vcvt.i, <float 8.000000e+00, float 8.000000e+00>
35 tail call void @foo_float32x2_t(<2 x float> %div.i) nounwind
36 ret void
37}
38
39; Test which should not fold due to non-power of 2.
40; CHECK: t3
Duncan Sands5f8397a2012-04-07 20:04:00 +000041; CHECK: {{vdiv|vmul}}
Chad Rosierfa8d8932011-06-24 19:23:04 +000042define void @t3() nounwind {
43entry:
Manman Ren1a5ff282013-04-30 17:52:57 +000044 %tmp = load i32* @iin, align 4
Chad Rosierfa8d8932011-06-24 19:23:04 +000045 %vecinit.i = insertelement <2 x i32> undef, i32 %tmp, i32 0
46 %vecinit2.i = insertelement <2 x i32> %vecinit.i, i32 %tmp, i32 1
47 %vcvt.i = sitofp <2 x i32> %vecinit2.i to <2 x float>
48 %div.i = fdiv <2 x float> %vcvt.i, <float 0x401B333340000000, float 0x401B333340000000>
49 tail call void @foo_float32x2_t(<2 x float> %div.i) nounwind
50 ret void
51}
52
53; Test which should not fold due to power of 2 out of range.
54; CHECK: t4
Duncan Sands5f8397a2012-04-07 20:04:00 +000055; CHECK: {{vdiv|vmul}}
Chad Rosierfa8d8932011-06-24 19:23:04 +000056define void @t4() nounwind {
57entry:
Manman Ren1a5ff282013-04-30 17:52:57 +000058 %tmp = load i32* @iin, align 4
Chad Rosierfa8d8932011-06-24 19:23:04 +000059 %vecinit.i = insertelement <2 x i32> undef, i32 %tmp, i32 0
60 %vecinit2.i = insertelement <2 x i32> %vecinit.i, i32 %tmp, i32 1
61 %vcvt.i = sitofp <2 x i32> %vecinit2.i to <2 x float>
62 %div.i = fdiv <2 x float> %vcvt.i, <float 0x4200000000000000, float 0x4200000000000000>
63 tail call void @foo_float32x2_t(<2 x float> %div.i) nounwind
64 ret void
65}
66
67; Test case where const is max power of 2 (i.e., 2^32).
68; CHECK: t5
Duncan Sands5f8397a2012-04-07 20:04:00 +000069; CHECK-NOT: {{vdiv|vmul}}
Chad Rosierfa8d8932011-06-24 19:23:04 +000070define void @t5() nounwind {
71entry:
Manman Ren1a5ff282013-04-30 17:52:57 +000072 %tmp = load i32* @iin, align 4
Chad Rosierfa8d8932011-06-24 19:23:04 +000073 %vecinit.i = insertelement <2 x i32> undef, i32 %tmp, i32 0
74 %vecinit2.i = insertelement <2 x i32> %vecinit.i, i32 %tmp, i32 1
75 %vcvt.i = sitofp <2 x i32> %vecinit2.i to <2 x float>
76 %div.i = fdiv <2 x float> %vcvt.i, <float 0x41F0000000000000, float 0x41F0000000000000>
77 tail call void @foo_float32x2_t(<2 x float> %div.i) nounwind
78 ret void
79}
80
81; Test quadword.
82; CHECK: t6
Duncan Sands5f8397a2012-04-07 20:04:00 +000083; CHECK-NOT: {{vdiv|vmul}}
Chad Rosierfa8d8932011-06-24 19:23:04 +000084define void @t6() nounwind {
85entry:
Manman Ren1a5ff282013-04-30 17:52:57 +000086 %tmp = load i32* @iin, align 4
Chad Rosierfa8d8932011-06-24 19:23:04 +000087 %vecinit.i = insertelement <4 x i32> undef, i32 %tmp, i32 0
88 %vecinit2.i = insertelement <4 x i32> %vecinit.i, i32 %tmp, i32 1
89 %vecinit4.i = insertelement <4 x i32> %vecinit2.i, i32 %tmp, i32 2
90 %vecinit6.i = insertelement <4 x i32> %vecinit4.i, i32 %tmp, i32 3
91 %vcvt.i = sitofp <4 x i32> %vecinit6.i to <4 x float>
92 %div.i = fdiv <4 x float> %vcvt.i, <float 8.000000e+00, float 8.000000e+00, float 8.000000e+00, float 8.000000e+00>
93 tail call void @foo_float32x4_t(<4 x float> %div.i) nounwind
94 ret void
95}
96
97declare void @foo_float32x4_t(<4 x float>)
Tim Northover7cbc2152013-06-28 15:29:25 +000098
99define <4 x float> @fix_unsigned_i16_to_float(<4 x i16> %in) {
100; CHECK: fix_unsigned_i16_to_float:
101; CHECK: vmovl.u16 [[TMP:q[0-9]+]], {{d[0-9]+}}
102; CHECK: vcvt.f32.u32 {{q[0-9]+}}, [[TMP]], #1
103
104 %conv = uitofp <4 x i16> %in to <4 x float>
105 %shift = fdiv <4 x float> %conv, <float 2.0, float 2.0, float 2.0, float 2.0>
106 ret <4 x float> %shift
107}
108
109define <4 x float> @fix_signed_i16_to_float(<4 x i16> %in) {
110; CHECK: fix_signed_i16_to_float:
111; CHECK: vmovl.s16 [[TMP:q[0-9]+]], {{d[0-9]+}}
112; CHECK: vcvt.f32.s32 {{q[0-9]+}}, [[TMP]], #1
113
114 %conv = sitofp <4 x i16> %in to <4 x float>
115 %shift = fdiv <4 x float> %conv, <float 2.0, float 2.0, float 2.0, float 2.0>
116 ret <4 x float> %shift
117}
118
119define <2 x float> @fix_i64_to_float(<2 x i64> %in) {
120; CHECK: fix_i64_to_float:
121; CHECK: bl
122; CHECK: bl
123
124 %conv = uitofp <2 x i64> %in to <2 x float>
125 %shift = fdiv <2 x float> %conv, <float 2.0, float 2.0>
126 ret <2 x float> %shift
127}
128
129define <2 x double> @fix_i64_to_double(<2 x i64> %in) {
130; CHECK: fix_i64_to_double:
131; CHECK: bl
132; CHECK: bl
133
134 %conv = uitofp <2 x i64> %in to <2 x double>
135 %shift = fdiv <2 x double> %conv, <double 2.0, double 2.0>
136 ret <2 x double> %shift
137}
138