Skip to content

Commit 5099b78

Browse files
cotamemfrob
authored andcommitted
[mlir] Check generated IR of math_polynomial_approx.mlir
Instead of just checking that we emit something. Differential Revision: https://reviews.llvm.org/D101940
1 parent 8f21a6e commit 5099b78

File tree

1 file changed

+305
-24
lines changed

1 file changed

+305
-24
lines changed

mlir/test/Dialect/Math/polynomial-approximation.mlir

Lines changed: 305 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,311 @@
33
// Check that all math functions lowered to approximations built from
44
// standard operations (add, mul, fma, shift, etc...).
55

6-
// CHECK-LABEL: @scalar
7-
func @scalar(%arg0: f32) -> f32 {
8-
// CHECK-NOT: tanh
6+
// CHECK-LABEL: func @exp_scalar(
7+
// CHECK-SAME: %[[VAL_0:.*]]: f32) -> f32 {
8+
// CHECK: %[[VAL_1:.*]] = constant 0.693147182 : f32
9+
// CHECK: %[[VAL_2:.*]] = constant 1.44269502 : f32
10+
// CHECK: %[[VAL_3:.*]] = constant 1.000000e+00 : f32
11+
// CHECK: %[[VAL_4:.*]] = constant 0.499705136 : f32
12+
// CHECK: %[[VAL_5:.*]] = constant 0.168738902 : f32
13+
// CHECK: %[[VAL_6:.*]] = constant 0.0366896503 : f32
14+
// CHECK: %[[VAL_7:.*]] = constant 1.314350e-02 : f32
15+
// CHECK: %[[VAL_8:.*]] = constant 23 : i32
16+
// CHECK: %[[VAL_9:.*]] = constant 0.000000e+00 : f32
17+
// CHECK: %[[VAL_10:.*]] = constant 0x7F800000 : f32
18+
// CHECK: %[[VAL_11:.*]] = constant 0xFF800000 : f32
19+
// CHECK: %[[VAL_12:.*]] = constant 1.17549435E-38 : f32
20+
// CHECK: %[[VAL_13:.*]] = constant 127 : i32
21+
// CHECK: %[[VAL_14:.*]] = constant -127 : i32
22+
// CHECK: %[[VAL_15:.*]] = mulf %[[VAL_0]], %[[VAL_2]] : f32
23+
// CHECK: %[[VAL_16:.*]] = floorf %[[VAL_15]] : f32
24+
// CHECK: %[[VAL_17:.*]] = mulf %[[VAL_16]], %[[VAL_1]] : f32
25+
// CHECK: %[[VAL_18:.*]] = subf %[[VAL_0]], %[[VAL_17]] : f32
26+
// CHECK: %[[VAL_19:.*]] = mulf %[[VAL_18]], %[[VAL_18]] : f32
27+
// CHECK: %[[VAL_20:.*]] = mulf %[[VAL_19]], %[[VAL_19]] : f32
28+
// CHECK: %[[VAL_21:.*]] = fmaf %[[VAL_3]], %[[VAL_18]], %[[VAL_3]] : f32
29+
// CHECK: %[[VAL_22:.*]] = fmaf %[[VAL_5]], %[[VAL_18]], %[[VAL_4]] : f32
30+
// CHECK: %[[VAL_23:.*]] = fmaf %[[VAL_7]], %[[VAL_18]], %[[VAL_6]] : f32
31+
// CHECK: %[[VAL_24:.*]] = fmaf %[[VAL_22]], %[[VAL_19]], %[[VAL_21]] : f32
32+
// CHECK: %[[VAL_25:.*]] = fmaf %[[VAL_23]], %[[VAL_20]], %[[VAL_24]] : f32
33+
// CHECK: %[[VAL_26:.*]] = fptosi %[[VAL_16]] : f32 to i32
34+
// CHECK: %[[VAL_27:.*]] = addi %[[VAL_26]], %[[VAL_13]] : i32
35+
// CHECK: %[[VAL_28:.*]] = shift_left %[[VAL_27]], %[[VAL_8]] : i32
36+
// CHECK: %[[VAL_29:.*]] = llvm.bitcast %[[VAL_28]] : i32 to f32
37+
// CHECK: %[[VAL_30:.*]] = mulf %[[VAL_25]], %[[VAL_29]] : f32
38+
// CHECK: %[[VAL_31:.*]] = cmpi sle, %[[VAL_26]], %[[VAL_13]] : i32
39+
// CHECK: %[[VAL_32:.*]] = cmpi sge, %[[VAL_26]], %[[VAL_14]] : i32
40+
// CHECK: %[[VAL_33:.*]] = cmpf oeq, %[[VAL_0]], %[[VAL_11]] : f32
41+
// CHECK: %[[VAL_34:.*]] = cmpf ogt, %[[VAL_0]], %[[VAL_9]] : f32
42+
// CHECK: %[[VAL_35:.*]] = and %[[VAL_31]], %[[VAL_32]] : i1
43+
// CHECK: %[[VAL_36:.*]] = select %[[VAL_33]], %[[VAL_9]], %[[VAL_12]] : f32
44+
// CHECK: %[[VAL_37:.*]] = select %[[VAL_34]], %[[VAL_10]], %[[VAL_36]] : f32
45+
// CHECK: %[[VAL_38:.*]] = select %[[VAL_35]], %[[VAL_30]], %[[VAL_37]] : f32
46+
// CHECK: return %[[VAL_38]] : f32
47+
// CHECK: }
48+
func @exp_scalar(%arg0: f32) -> f32 {
49+
%0 = math.exp %arg0 : f32
50+
return %0 : f32
51+
}
52+
53+
// CHECK-LABEL: func @exp_vector(
54+
// CHECK-SAME: %[[VAL_0:.*]]: vector<8xf32>) -> vector<8xf32> {
55+
// CHECK: %[[VAL_1:.*]] = constant dense<0.693147182> : vector<8xf32>
56+
// CHECK-NOT: exp
57+
// CHECK-COUNT-2: select
58+
// CHECK: %[[VAL_38:.*]] = select
59+
// CHECK: return %[[VAL_38]] : vector<8xf32>
60+
// CHECK: }
61+
func @exp_vector(%arg0: vector<8xf32>) -> vector<8xf32> {
62+
%0 = math.exp %arg0 : vector<8xf32>
63+
return %0 : vector<8xf32>
64+
}
65+
66+
// CHECK-LABEL: func @expm1_scalar(
67+
// CHECK-SAME: %[[X:.*]]: f32) -> f32 {
68+
// CHECK: %[[CST_MINUSONE:.*]] = constant -1.000000e+00 : f32
69+
// CHECK: %[[CST_LOG2E:.*]] = constant 1.44269502 : f32
70+
// CHECK: %[[CST_ONE:.*]] = constant 1.000000e+00 : f32
71+
// CHECK: %[[BEGIN_EXP_X:.*]] = mulf %[[X]], %[[CST_LOG2E]] : f32
72+
// CHECK-NOT: exp
73+
// CHECK-COUNT-2: select
74+
// CHECK: %[[EXP_X:.*]] = select
75+
// CHECK: %[[VAL_58:.*]] = cmpf oeq, %[[EXP_X]], %[[CST_ONE]] : f32
76+
// CHECK: %[[VAL_59:.*]] = subf %[[EXP_X]], %[[CST_ONE]] : f32
77+
// CHECK: %[[VAL_60:.*]] = cmpf oeq, %[[VAL_59]], %[[CST_MINUSONE]] : f32
78+
// CHECK-NOT: log
79+
// CHECK-COUNT-5: select
80+
// CHECK: %[[LOG_U:.*]] = select
81+
// CHECK: %[[VAL_104:.*]] = cmpf oeq, %[[LOG_U]], %[[EXP_X]] : f32
82+
// CHECK: %[[VAL_105:.*]] = divf %[[X]], %[[LOG_U]] : f32
83+
// CHECK: %[[VAL_106:.*]] = mulf %[[VAL_59]], %[[VAL_105]] : f32
84+
// CHECK: %[[VAL_107:.*]] = select %[[VAL_104]], %[[EXP_X]], %[[VAL_106]] : f32
85+
// CHECK: %[[VAL_108:.*]] = select %[[VAL_60]], %[[CST_MINUSONE]], %[[VAL_107]] : f32
86+
// CHECK: %[[VAL_109:.*]] = select %[[VAL_58]], %[[X]], %[[VAL_108]] : f32
87+
// CHECK: return %[[VAL_109]] : f32
88+
// CHECK: }
89+
func @expm1_scalar(%arg0: f32) -> f32 {
90+
%0 = math.expm1 %arg0 : f32
91+
return %0 : f32
92+
}
93+
94+
// CHECK-LABEL: func @expm1_vector(
95+
// CHECK-SAME: %[[VAL_0:.*]]: vector<8xf32>) -> vector<8xf32> {
96+
// CHECK: %[[VAL_1:.*]] = constant dense<-1.000000e+00> : vector<8xf32>
97+
// CHECK-NOT: exp
98+
// CHECK-COUNT-3: select
99+
// CHECK-NOT: log
100+
// CHECK-COUNT-6: vector.broadcast
101+
// CHECK-COUNT-5: select
102+
// CHECK-NOT: expm1
103+
// CHECK-COUNT-2: select
104+
// CHECK: %[[VAL_115:.*]] = select
105+
// CHECK: return %[[VAL_115]] : vector<8xf32>
106+
// CHECK: }
107+
func @expm1_vector(%arg0: vector<8xf32>) -> vector<8xf32> {
108+
%0 = math.expm1 %arg0 : vector<8xf32>
109+
return %0 : vector<8xf32>
110+
}
111+
112+
// CHECK-LABEL: func @log_scalar(
113+
// CHECK-SAME: %[[X:.*]]: f32) -> f32 {
114+
// CHECK: %[[VAL_1:.*]] = constant 0.000000e+00 : f32
115+
// CHECK: %[[VAL_2:.*]] = constant 1.000000e+00 : f32
116+
// CHECK: %[[VAL_3:.*]] = constant -5.000000e-01 : f32
117+
// CHECK: %[[VAL_4:.*]] = constant 8388608 : i32
118+
// CHECK: %[[VAL_5:.*]] = constant -8388608 : i32
119+
// CHECK: %[[VAL_6:.*]] = constant 2139095040 : i32
120+
// CHECK: %[[VAL_7:.*]] = constant 2143289344 : i32
121+
// CHECK: %[[VAL_8:.*]] = constant 0.707106769 : f32
122+
// CHECK: %[[VAL_9:.*]] = constant 0.0703768358 : f32
123+
// CHECK: %[[VAL_10:.*]] = constant -0.115146101 : f32
124+
// CHECK: %[[VAL_11:.*]] = constant 0.116769984 : f32
125+
// CHECK: %[[VAL_12:.*]] = constant -0.12420141 : f32
126+
// CHECK: %[[VAL_13:.*]] = constant 0.142493233 : f32
127+
// CHECK: %[[VAL_14:.*]] = constant -0.166680574 : f32
128+
// CHECK: %[[VAL_15:.*]] = constant 0.200007141 : f32
129+
// CHECK: %[[VAL_16:.*]] = constant -0.24999994 : f32
130+
// CHECK: %[[VAL_17:.*]] = constant 0.333333313 : f32
131+
// CHECK: %[[VAL_18:.*]] = constant 1.260000e+02 : f32
132+
// CHECK: %[[VAL_19:.*]] = constant 5.000000e-01 : f32
133+
// CHECK: %[[VAL_20:.*]] = constant -2139095041 : i32
134+
// CHECK: %[[VAL_21:.*]] = constant 23 : i32
135+
// CHECK: %[[CST_LN2:.*]] = constant 0.693147182 : f32
136+
// CHECK: %[[VAL_23:.*]] = llvm.bitcast %[[VAL_4]] : i32 to f32
137+
// CHECK: %[[VAL_24:.*]] = llvm.bitcast %[[VAL_5]] : i32 to f32
138+
// CHECK: %[[VAL_25:.*]] = llvm.bitcast %[[VAL_6]] : i32 to f32
139+
// CHECK: %[[VAL_26:.*]] = llvm.bitcast %[[VAL_7]] : i32 to f32
140+
// CHECK: %[[VAL_27:.*]] = cmpf ogt, %[[X]], %[[VAL_23]] : f32
141+
// CHECK: %[[VAL_28:.*]] = select %[[VAL_27]], %[[X]], %[[VAL_23]] : f32
142+
// CHECK-NOT: frexp
143+
// CHECK: %[[VAL_29:.*]] = llvm.bitcast %[[VAL_20]] : i32 to f32
144+
// CHECK: %[[VAL_30:.*]] = llvm.bitcast %[[VAL_19]] : f32 to i32
145+
// CHECK: %[[VAL_31:.*]] = llvm.bitcast %[[VAL_29]] : f32 to i32
146+
// CHECK: %[[VAL_32:.*]] = llvm.bitcast %[[VAL_28]] : f32 to i32
147+
// CHECK: %[[VAL_33:.*]] = llvm.and %[[VAL_32]], %[[VAL_31]] : i32
148+
// CHECK: %[[VAL_34:.*]] = llvm.or %[[VAL_33]], %[[VAL_30]] : i32
149+
// CHECK: %[[VAL_35:.*]] = llvm.bitcast %[[VAL_34]] : i32 to f32
150+
// CHECK: %[[VAL_36:.*]] = llvm.bitcast %[[VAL_28]] : f32 to i32
151+
// CHECK: %[[VAL_37:.*]] = shift_right_unsigned %[[VAL_36]], %[[VAL_21]] : i32
152+
// CHECK: %[[FREXP_X:.*]] = sitofp %[[VAL_37]] : i32 to f32
153+
// CHECK: %[[VAL_39:.*]] = subf %[[FREXP_X]], %[[VAL_18]] : f32
154+
// CHECK: %[[VAL_40:.*]] = cmpf olt, %[[VAL_35]], %[[VAL_8]] : f32
155+
// CHECK: %[[VAL_41:.*]] = select %[[VAL_40]], %[[VAL_35]], %[[VAL_1]] : f32
156+
// CHECK: %[[VAL_42:.*]] = subf %[[VAL_35]], %[[VAL_2]] : f32
157+
// CHECK: %[[VAL_43:.*]] = select %[[VAL_40]], %[[VAL_2]], %[[VAL_1]] : f32
158+
// CHECK: %[[VAL_44:.*]] = subf %[[VAL_39]], %[[VAL_43]] : f32
159+
// CHECK: %[[VAL_45:.*]] = addf %[[VAL_42]], %[[VAL_41]] : f32
160+
// CHECK: %[[VAL_46:.*]] = mulf %[[VAL_45]], %[[VAL_45]] : f32
161+
// CHECK: %[[VAL_47:.*]] = mulf %[[VAL_46]], %[[VAL_45]] : f32
162+
// CHECK: %[[VAL_48:.*]] = fmaf %[[VAL_9]], %[[VAL_45]], %[[VAL_10]] : f32
163+
// CHECK: %[[VAL_49:.*]] = fmaf %[[VAL_12]], %[[VAL_45]], %[[VAL_13]] : f32
164+
// CHECK: %[[VAL_50:.*]] = fmaf %[[VAL_15]], %[[VAL_45]], %[[VAL_16]] : f32
165+
// CHECK: %[[VAL_51:.*]] = fmaf %[[VAL_48]], %[[VAL_45]], %[[VAL_11]] : f32
166+
// CHECK: %[[VAL_52:.*]] = fmaf %[[VAL_49]], %[[VAL_45]], %[[VAL_14]] : f32
167+
// CHECK: %[[VAL_53:.*]] = fmaf %[[VAL_50]], %[[VAL_45]], %[[VAL_17]] : f32
168+
// CHECK: %[[VAL_54:.*]] = fmaf %[[VAL_51]], %[[VAL_47]], %[[VAL_52]] : f32
169+
// CHECK: %[[VAL_55:.*]] = fmaf %[[VAL_54]], %[[VAL_47]], %[[VAL_53]] : f32
170+
// CHECK: %[[VAL_56:.*]] = mulf %[[VAL_55]], %[[VAL_47]] : f32
171+
// CHECK: %[[VAL_57:.*]] = fmaf %[[VAL_3]], %[[VAL_46]], %[[VAL_56]] : f32
172+
// CHECK: %[[VAL_58:.*]] = addf %[[VAL_45]], %[[VAL_57]] : f32
173+
// CHECK: %[[VAL_59:.*]] = fmaf %[[VAL_44]], %[[CST_LN2]], %[[VAL_58]] : f32
174+
// CHECK: %[[VAL_60:.*]] = cmpf ult, %[[X]], %[[VAL_1]] : f32
175+
// CHECK: %[[VAL_61:.*]] = cmpf oeq, %[[X]], %[[VAL_1]] : f32
176+
// CHECK: %[[VAL_62:.*]] = cmpf oeq, %[[X]], %[[VAL_25]] : f32
177+
// CHECK: %[[VAL_63:.*]] = select %[[VAL_62]], %[[VAL_25]], %[[VAL_59]] : f32
178+
// CHECK: %[[VAL_64:.*]] = select %[[VAL_60]], %[[VAL_26]], %[[VAL_63]] : f32
179+
// CHECK: %[[VAL_65:.*]] = select %[[VAL_61]], %[[VAL_24]], %[[VAL_64]] : f32
180+
// CHECK: return %[[VAL_65]] : f32
181+
// CHECK: }
182+
func @log_scalar(%arg0: f32) -> f32 {
183+
%0 = math.log %arg0 : f32
184+
return %0 : f32
185+
}
186+
187+
// CHECK-LABEL: func @log_vector(
188+
// CHECK-SAME: %[[VAL_0:.*]]: vector<8xf32>) -> vector<8xf32> {
189+
// CHECK: %[[CST_LN2:.*]] = constant dense<0.693147182> : vector<8xf32>
190+
// CHECK-COUNT-6: vector.broadcast
191+
// CHECK-COUNT-4: select
192+
// CHECK: %[[VAL_71:.*]] = select
193+
// CHECK: return %[[VAL_71]] : vector<8xf32>
194+
// CHECK: }
195+
func @log_vector(%arg0: vector<8xf32>) -> vector<8xf32> {
196+
%0 = math.log %arg0 : vector<8xf32>
197+
return %0 : vector<8xf32>
198+
}
199+
200+
// CHECK-LABEL: func @log2_scalar(
201+
// CHECK-SAME: %[[VAL_0:.*]]: f32) -> f32 {
202+
// CHECK: %[[CST_LOG2E:.*]] = constant 1.44269502 : f32
203+
// CHECK-COUNT-5: select
204+
// CHECK: %[[VAL_65:.*]] = select
205+
// CHECK: return %[[VAL_65]] : f32
206+
// CHECK: }
207+
func @log2_scalar(%arg0: f32) -> f32 {
208+
%0 = math.log2 %arg0 : f32
209+
return %0 : f32
210+
}
211+
212+
// CHECK-LABEL: func @log2_vector(
213+
// CHECK-SAME: %[[VAL_0:.*]]: vector<8xf32>) -> vector<8xf32> {
214+
// CHECK: %[[CST_LOG2E:.*]] = constant dense<1.44269502> : vector<8xf32>
215+
// CHECK-COUNT-6: vector.broadcast
216+
// CHECK-COUNT-4: select
217+
// CHECK: %[[VAL_71:.*]] = select
218+
// CHECK: return %[[VAL_71]] : vector<8xf32>
219+
// CHECK: }
220+
func @log2_vector(%arg0: vector<8xf32>) -> vector<8xf32> {
221+
%0 = math.log2 %arg0 : vector<8xf32>
222+
return %0 : vector<8xf32>
223+
}
224+
225+
// CHECK-LABEL: func @log1p_scalar(
226+
// CHECK-SAME: %[[X:.*]]: f32) -> f32 {
227+
// CHECK: %[[CST_ONE:.*]] = constant 1.000000e+00 : f32
228+
// CHECK: %[[U:.*]] = addf %[[X]], %[[CST_ONE]] : f32
229+
// CHECK: %[[U_SMALL:.*]] = cmpf oeq, %[[U]], %[[CST_ONE]] : f32
230+
// CHECK-NOT: log
231+
// CHECK-COUNT-5: select
232+
// CHECK: %[[LOG_U:.*]] = select
233+
// CHECK: %[[U_INF:.*]] = cmpf oeq, %[[U]], %[[LOG_U]] : f32
234+
// CHECK: %[[VAL_69:.*]] = subf %[[U]], %[[CST_ONE]] : f32
235+
// CHECK: %[[VAL_70:.*]] = divf %[[LOG_U]], %[[VAL_69]] : f32
236+
// CHECK: %[[LOG_LARGE:.*]] = mulf %[[X]], %[[VAL_70]] : f32
237+
// CHECK: %[[VAL_72:.*]] = llvm.or %[[U_SMALL]], %[[U_INF]] : i1
238+
// CHECK: %[[APPROX:.*]] = select %[[VAL_72]], %[[X]], %[[LOG_LARGE]] : f32
239+
// CHECK: return %[[APPROX]] : f32
240+
// CHECK: }
241+
func @log1p_scalar(%arg0: f32) -> f32 {
242+
%0 = math.log1p %arg0 : f32
243+
return %0 : f32
244+
}
245+
246+
// CHECK-LABEL: func @log1p_vector(
247+
// CHECK-SAME: %[[VAL_0:.*]]: vector<8xf32>) -> vector<8xf32> {
248+
// CHECK: %[[CST_ONE:.*]] = constant dense<1.000000e+00> : vector<8xf32>
249+
// CHECK-COUNT-6: vector.broadcast
250+
// CHECK-COUNT-5: select
251+
// CHECK: %[[VAL_79:.*]] = select
252+
// CHECK: return %[[VAL_79]] : vector<8xf32>
253+
// CHECK: }
254+
func @log1p_vector(%arg0: vector<8xf32>) -> vector<8xf32> {
255+
%0 = math.log1p %arg0 : vector<8xf32>
256+
return %0 : vector<8xf32>
257+
}
258+
259+
260+
// CHECK-LABEL: func @tanh_scalar(
261+
// CHECK-SAME: %[[VAL_0:.*]]: f32) -> f32 {
262+
// CHECK: %[[VAL_1:.*]] = constant -7.90531111 : f32
263+
// CHECK: %[[VAL_2:.*]] = constant 7.90531111 : f32
264+
// CHECK: %[[VAL_3:.*]] = constant 4.000000e-04 : f32
265+
// CHECK: %[[VAL_4:.*]] = constant 0.00489352457 : f32
266+
// CHECK: %[[VAL_5:.*]] = constant 6.37261954E-4 : f32
267+
// CHECK: %[[VAL_6:.*]] = constant 1.48572235E-5 : f32
268+
// CHECK: %[[VAL_7:.*]] = constant 5.12229725E-8 : f32
269+
// CHECK: %[[VAL_8:.*]] = constant -8.60467184E-11 : f32
270+
// CHECK: %[[VAL_9:.*]] = constant 2.00018794E-13 : f32
271+
// CHECK: %[[VAL_10:.*]] = constant -2.76076837E-16 : f32
272+
// CHECK: %[[VAL_11:.*]] = constant 0.00489352504 : f32
273+
// CHECK: %[[VAL_12:.*]] = constant 0.00226843474 : f32
274+
// CHECK: %[[VAL_13:.*]] = constant 1.18534706E-4 : f32
275+
// CHECK: %[[VAL_14:.*]] = constant 1.19825836E-6 : f32
276+
// CHECK: %[[VAL_15:.*]] = cmpf olt, %[[VAL_0]], %[[VAL_2]] : f32
277+
// CHECK: %[[VAL_16:.*]] = select %[[VAL_15]], %[[VAL_0]], %[[VAL_2]] : f32
278+
// CHECK: %[[VAL_17:.*]] = cmpf ogt, %[[VAL_16]], %[[VAL_1]] : f32
279+
// CHECK: %[[VAL_18:.*]] = select %[[VAL_17]], %[[VAL_16]], %[[VAL_1]] : f32
280+
// CHECK: %[[VAL_19:.*]] = absf %[[VAL_0]] : f32
281+
// CHECK: %[[VAL_20:.*]] = cmpf olt, %[[VAL_19]], %[[VAL_3]] : f32
282+
// CHECK: %[[VAL_21:.*]] = mulf %[[VAL_18]], %[[VAL_18]] : f32
283+
// CHECK: %[[VAL_22:.*]] = fmaf %[[VAL_21]], %[[VAL_10]], %[[VAL_9]] : f32
284+
// CHECK: %[[VAL_23:.*]] = fmaf %[[VAL_21]], %[[VAL_22]], %[[VAL_8]] : f32
285+
// CHECK: %[[VAL_24:.*]] = fmaf %[[VAL_21]], %[[VAL_23]], %[[VAL_7]] : f32
286+
// CHECK: %[[VAL_25:.*]] = fmaf %[[VAL_21]], %[[VAL_24]], %[[VAL_6]] : f32
287+
// CHECK: %[[VAL_26:.*]] = fmaf %[[VAL_21]], %[[VAL_25]], %[[VAL_5]] : f32
288+
// CHECK: %[[VAL_27:.*]] = fmaf %[[VAL_21]], %[[VAL_26]], %[[VAL_4]] : f32
289+
// CHECK: %[[VAL_28:.*]] = mulf %[[VAL_18]], %[[VAL_27]] : f32
290+
// CHECK: %[[VAL_29:.*]] = fmaf %[[VAL_21]], %[[VAL_14]], %[[VAL_13]] : f32
291+
// CHECK: %[[VAL_30:.*]] = fmaf %[[VAL_21]], %[[VAL_29]], %[[VAL_12]] : f32
292+
// CHECK: %[[VAL_31:.*]] = fmaf %[[VAL_21]], %[[VAL_30]], %[[VAL_11]] : f32
293+
// CHECK: %[[VAL_32:.*]] = divf %[[VAL_28]], %[[VAL_31]] : f32
294+
// CHECK: %[[VAL_33:.*]] = select %[[VAL_20]], %[[VAL_18]], %[[VAL_32]] : f32
295+
// CHECK: return %[[VAL_33]] : f32
296+
// CHECK: }
297+
func @tanh_scalar(%arg0: f32) -> f32 {
9298
%0 = math.tanh %arg0 : f32
10-
// CHECK-NOT: log
11-
%1 = math.log %0 : f32
12-
%2 = math.log2 %1 : f32
13-
%3 = math.log1p %2 : f32
14-
// CHECK-NOT: exp
15-
%4 = math.exp %3 : f32
16-
%5 = math.expm1 %4 : f32
17-
return %5 : f32
18-
}
19-
20-
// CHECK-LABEL: @vector
21-
func @vector(%arg0: vector<8xf32>) -> vector<8xf32> {
22-
// CHECK-NOT: tanh
299+
return %0 : f32
300+
}
301+
302+
// CHECK-LABEL: func @tanh_vector(
303+
// CHECK-SAME: %[[VAL_0:.*]]: vector<8xf32>) -> vector<8xf32> {
304+
// CHECK: %[[VAL_1:.*]] = constant dense<-7.90531111> : vector<8xf32>
305+
// CHECK-NOT: tanh
306+
// CHECK-COUNT-2: select
307+
// CHECK: %[[VAL_33:.*]] = select
308+
// CHECK: return %[[VAL_33]] : vector<8xf32>
309+
// CHECK: }
310+
func @tanh_vector(%arg0: vector<8xf32>) -> vector<8xf32> {
23311
%0 = math.tanh %arg0 : vector<8xf32>
24-
// CHECK-NOT: log
25-
%1 = math.log %0 : vector<8xf32>
26-
%2 = math.log2 %1 : vector<8xf32>
27-
%3 = math.log1p %2 : vector<8xf32>
28-
// CHECK-NOT: exp
29-
%4 = math.exp %3 : vector<8xf32>
30-
%5 = math.expm1 %4 : vector<8xf32>
31-
return %5 : vector<8xf32>
312+
return %0 : vector<8xf32>
32313
}

0 commit comments

Comments
 (0)