@@ -29,6 +29,17 @@ define half @test3(float %a) {
2929 ret half %c
3030}
3131
32+ define half @test3_fast (float %a ) {
33+ ; CHECK-LABEL: @test3_fast(
34+ ; CHECK-NEXT: [[TMP1:%.*]] = fptrunc float [[A:%.*]] to half
35+ ; CHECK-NEXT: [[C:%.*]] = call half @llvm.fabs.f16(half [[TMP1]])
36+ ; CHECK-NEXT: ret half [[C]]
37+ ;
38+ %b = call float @llvm.fabs.f32 (float %a )
39+ %c = fptrunc fast float %b to half
40+ ret half %c
41+ }
42+
3243define half @fneg_fptrunc (float %a ) {
3344; CHECK-LABEL: @fneg_fptrunc(
3445; CHECK-NEXT: [[TMP1:%.*]] = fptrunc float [[A:%.*]] to half
@@ -78,6 +89,28 @@ define half @test4-fast(float %a) {
7889; CHECK-NEXT: [[TMP1:%.*]] = fptrunc fast float [[A:%.*]] to half
7990; CHECK-NEXT: [[C:%.*]] = fneg fast half [[TMP1]]
8091; CHECK-NEXT: ret half [[C]]
92+ ;
93+ %b = fsub fast float -0 .0 , %a
94+ %c = fptrunc fast float %b to half
95+ ret half %c
96+ }
97+
98+ define half @test4-mixed-fast-1 (float %a ) {
99+ ; CHECK-LABEL: @test4-mixed-fast-1(
100+ ; CHECK-NEXT: [[TMP1:%.*]] = fptrunc float [[A:%.*]] to half
101+ ; CHECK-NEXT: [[C:%.*]] = fneg half [[TMP1]]
102+ ; CHECK-NEXT: ret half [[C]]
103+ ;
104+ %b = fsub float -0 .0 , %a
105+ %c = fptrunc fast float %b to half
106+ ret half %c
107+ }
108+
109+ define half @test4-mixed-fast-2 (float %a ) {
110+ ; CHECK-LABEL: @test4-mixed-fast-2(
111+ ; CHECK-NEXT: [[TMP1:%.*]] = fptrunc float [[A:%.*]] to half
112+ ; CHECK-NEXT: [[C:%.*]] = fneg half [[TMP1]]
113+ ; CHECK-NEXT: ret half [[C]]
81114;
82115 %b = fsub fast float -0 .0 , %a
83116 %c = fptrunc float %b to half
@@ -89,12 +122,67 @@ define half @test4_unary_fneg-fast(float %a) {
89122; CHECK-NEXT: [[TMP1:%.*]] = fptrunc fast float [[A:%.*]] to half
90123; CHECK-NEXT: [[C:%.*]] = fneg fast half [[TMP1]]
91124; CHECK-NEXT: ret half [[C]]
125+ ;
126+ %b = fneg fast float %a
127+ %c = fptrunc fast float %b to half
128+ ret half %c
129+ }
130+
131+ define half @test4_unary_fneg-mixed-fast-1 (float %a ) {
132+ ; CHECK-LABEL: @test4_unary_fneg-mixed-fast-1(
133+ ; CHECK-NEXT: [[TMP1:%.*]] = fptrunc float [[A:%.*]] to half
134+ ; CHECK-NEXT: [[C:%.*]] = fneg half [[TMP1]]
135+ ; CHECK-NEXT: ret half [[C]]
136+ ;
137+ %b = fneg float %a
138+ %c = fptrunc fast float %b to half
139+ ret half %c
140+ }
141+
142+ define half @test4_unary_fneg-mixed-fast-2 (float %a ) {
143+ ; CHECK-LABEL: @test4_unary_fneg-mixed-fast-2(
144+ ; CHECK-NEXT: [[TMP1:%.*]] = fptrunc float [[A:%.*]] to half
145+ ; CHECK-NEXT: [[C:%.*]] = fneg half [[TMP1]]
146+ ; CHECK-NEXT: ret half [[C]]
92147;
93148 %b = fneg fast float %a
94149 %c = fptrunc float %b to half
95150 ret half %c
96151}
97152
153+ define <2 x half > @test4_unary_fneg-vec-fast (<2 x float > %a ) {
154+ ; CHECK-LABEL: @test4_unary_fneg-vec-fast(
155+ ; CHECK-NEXT: [[TMP1:%.*]] = fptrunc fast <2 x float> [[A:%.*]] to <2 x half>
156+ ; CHECK-NEXT: [[C:%.*]] = fneg fast <2 x half> [[TMP1]]
157+ ; CHECK-NEXT: ret <2 x half> [[C]]
158+ ;
159+ %b = fneg fast <2 x float > %a
160+ %c = fptrunc fast <2 x float > %b to <2 x half >
161+ ret <2 x half > %c
162+ }
163+
164+ define <2 x half > @test4_unary_fneg-vec-mixed-fast-1 (<2 x float > %a ) {
165+ ; CHECK-LABEL: @test4_unary_fneg-vec-mixed-fast-1(
166+ ; CHECK-NEXT: [[TMP1:%.*]] = fptrunc <2 x float> [[A:%.*]] to <2 x half>
167+ ; CHECK-NEXT: [[C:%.*]] = fneg <2 x half> [[TMP1]]
168+ ; CHECK-NEXT: ret <2 x half> [[C]]
169+ ;
170+ %b = fneg <2 x float > %a
171+ %c = fptrunc fast <2 x float > %b to <2 x half >
172+ ret <2 x half > %c
173+ }
174+
175+ define <2 x half > @test4_unary_fneg-vec-mixed-fast-2 (<2 x float > %a ) {
176+ ; CHECK-LABEL: @test4_unary_fneg-vec-mixed-fast-2(
177+ ; CHECK-NEXT: [[TMP1:%.*]] = fptrunc <2 x float> [[A:%.*]] to <2 x half>
178+ ; CHECK-NEXT: [[C:%.*]] = fneg <2 x half> [[TMP1]]
179+ ; CHECK-NEXT: ret <2 x half> [[C]]
180+ ;
181+ %b = fneg fast <2 x float > %a
182+ %c = fptrunc <2 x float > %b to <2 x half >
183+ ret <2 x half > %c
184+ }
185+
98186define half @test5 (float %a , float %b , float %c ) {
99187; CHECK-LABEL: @test5(
100188; CHECK-NEXT: [[D:%.*]] = fcmp ogt float [[A:%.*]], [[B:%.*]]
0 commit comments