@@ -232,8 +232,8 @@ func.func @powf_func(%a: f64, %b: f64) ->f64 {
232
232
233
233
// -----
234
234
235
- // CHECK-LABEL: func.func @roundeven32
236
- func.func @roundeven32 (%arg: f32 ) -> f32 {
235
+ // CHECK-LABEL: func.func @roundeven
236
+ func.func @roundeven (%arg: f32 ) -> f32 {
237
237
%res = math.roundeven %arg : f32
238
238
return %res : f32
239
239
}
@@ -331,90 +331,3 @@ func.func @roundeven32(%arg: f32) -> f32 {
331
331
// CHECK: %[[COPYSIGN:.*]] = math.copysign %[[RESULT]], %[[VAL_0]] : f32
332
332
333
333
// CHECK: return %[[COPYSIGN]] : f32
334
-
335
- // -----
336
-
337
- // CHECK-LABEL: func.func @roundeven16
338
- func.func @roundeven16 (%arg: f16 ) -> f16 {
339
- %res = math.roundeven %arg : f16
340
- return %res : f16
341
- }
342
-
343
- // CHECK-SAME: %[[VAL_0:.*]]: f16) -> f16 {
344
- // CHECK-DAG: %[[C_0:.*]] = arith.constant 0 : i16
345
- // CHECK-DAG: %[[C_1:.*]] = arith.constant 1 : i16
346
- // CHECK-DAG: %[[C_NEG_1:.*]] = arith.constant -1 : i16
347
- // CHECK-DAG: %[[C_1_FLOAT:.*]] = arith.constant 1.000000e+00 : f16
348
- // CHECK-DAG: %[[C_10:.*]] = arith.constant 10 : i16
349
- // CHECK-DAG: %[[C_15:.*]] = arith.constant 15 : i16
350
- // CHECK-DAG: %[[C_512:.*]] = arith.constant 512 : i16
351
- // CHECK-DAG: %[[C_1023:.*]] = arith.constant 1023 : i16
352
- // CHECK-DAG: %[[EXP_MASK:.*]] = arith.constant 31 : i16
353
-
354
- // CHECK: %[[OPERAND_BITCAST:.*]] = arith.bitcast %[[VAL_0]] : f16 to i16
355
- // CHECK: %[[ROUND:.*]] = math.round %[[VAL_0]] : f16
356
- // CHECK: %[[ROUND_BITCAST:.*]] = arith.bitcast %[[ROUND]] : f16 to i16
357
-
358
- // Get biased exponents of `round` and `operand`
359
- // CHECK: %[[SHIFTED_OPERAND_BITCAST:.*]] = arith.shrui %[[OPERAND_BITCAST]], %[[C_10]] : i16
360
- // CHECK: %[[OPERAND_EXP:.*]] = arith.andi %[[SHIFTED_OPERAND_BITCAST]], %[[EXP_MASK]] : i16
361
- // CHECK: %[[OPERAND_BIASED_EXP:.*]] = arith.subi %[[OPERAND_EXP]], %[[C_15]] : i16
362
- // CHECK: %[[SHIFTED_ROUND_BITCAST:.*]] = arith.shrui %[[ROUND_BITCAST]], %[[C_10]] : i16
363
- // CHECK: %[[ROUND_EXP:.*]] = arith.andi %[[SHIFTED_ROUND_BITCAST]], %[[EXP_MASK]] : i16
364
- // CHECK: %[[ROUND_BIASED_EXP:.*]] = arith.subi %[[ROUND_EXP]], %[[C_15]] : i16
365
-
366
- // Determine if `ROUND_BITCAST` is an even whole number or a special value
367
- // +-inf, +-nan.
368
- // Mask mantissa of `ROUND_BITCAST` with a mask shifted to the right by
369
- // `ROUND_BIASED_EXP - 1`
370
- // CHECK-DAG: %[[ROUND_BIASED_EXP_MINUS_1:.*]] = arith.subi %[[ROUND_BIASED_EXP]], %[[C_1]] : i16
371
- // CHECK-DAG: %[[CLAMPED_SHIFT_0:.*]] = arith.maxsi %[[ROUND_BIASED_EXP_MINUS_1]], %[[C_0]] : i16
372
- // CHECK-DAG: %[[CLAMPED_SHIFT_1:.*]] = arith.minsi %[[CLAMPED_SHIFT_0]], %[[C_15]] : i16
373
- // CHECK-DAG: %[[SHIFTED_MANTISSA_MASK_0:.*]] = arith.shrui %[[C_1023]], %[[CLAMPED_SHIFT_1]] : i16
374
- // CHECK-DAG: %[[ROUND_MASKED_MANTISSA:.*]] = arith.andi %[[ROUND_BITCAST]], %[[SHIFTED_MANTISSA_MASK_0]] : i16
375
-
376
- // `ROUND_BITCAST` is not even whole number or special value if masked
377
- // mantissa is != 0 or `ROUND_BIASED_EXP == 0`
378
- // CHECK-DAG: %[[ROUND_IS_NOT_EVEN_OR_SPECIAL_0:.*]] = arith.cmpi ne, %[[ROUND_MASKED_MANTISSA]], %[[C_0]] : i16
379
- // CHECK-DAG: %[[ROUND_BIASED_EXP_EQ_0:.*]] = arith.cmpi eq, %[[ROUND_BIASED_EXP]], %[[C_0]] : i16
380
- // CHECK-DAG: %[[ROUND_IS_NOT_EVEN_OR_SPECIAL_1:.*]] = arith.ori %[[ROUND_IS_NOT_EVEN_OR_SPECIAL_0]], %[[ROUND_BIASED_EXP_EQ_0]] : i1
381
-
382
- // Determine if operand is halfway between two integer values
383
- // CHECK: %[[OPERAND_BIASED_EXP_EQ_NEG_1:.*]] = arith.cmpi eq, %[[OPERAND_BIASED_EXP]], %[[C_NEG_1]] : i16
384
- // CHECK: %[[CLAMPED_SHIFT_2:.*]] = arith.maxsi %[[OPERAND_BIASED_EXP]], %[[C_0]] : i16
385
- // CHECK: %[[CLAMPED_SHIFT_3:.*]] = arith.minsi %[[CLAMPED_SHIFT_2]], %[[C_15]] : i16
386
- // CHECK: %[[SHIFTED_2_TO_9:.*]] = arith.shrui %[[C_512]], %[[CLAMPED_SHIFT_3]] : i16
387
-
388
- // A value with `0 <= BIASED_EXP < 10` is halfway between two consecutive
389
- // integers if the bit at index `BIASED_EXP` starting from the left in the
390
- // mantissa is 1 and all the bits to the right are zero. For the case where
391
- // `BIASED_EXP == -1, the expected mantissa is all zeros.
392
- // CHECK: %[[EXPECTED_OPERAND_MASKED_MANTISSA:.*]] = arith.select %[[OPERAND_BIASED_EXP_EQ_NEG_1]], %[[C_0]], %[[SHIFTED_2_TO_9]] : i16
393
-
394
- // Mask mantissa of `OPERAND_BITCAST` with a mask shifted to the right by
395
- // `OPERAND_BIASED_EXP`
396
- // CHECK: %[[CLAMPED_SHIFT_4:.*]] = arith.maxsi %[[OPERAND_BIASED_EXP]], %[[C_0]] : i16
397
- // CHECK: %[[CLAMPED_SHIFT_5:.*]] = arith.minsi %[[CLAMPED_SHIFT_4]], %[[C_15]] : i16
398
- // CHECK: %[[SHIFTED_MANTISSA_MASK_1:.*]] = arith.shrui %[[C_1023]], %[[CLAMPED_SHIFT_5]] : i16
399
- // CHECK: %[[OPERAND_MASKED_MANTISSA:.*]] = arith.andi %[[OPERAND_BITCAST]], %[[SHIFTED_MANTISSA_MASK_1]] : i16
400
-
401
- // The operand is halfway between two integers if the masked mantissa is equal
402
- // to the expected mantissa and the biased exponent is in the range
403
- // [-1, 23).
404
- // CHECK-DAG: %[[OPERAND_BIASED_EXP_GE_NEG_1:.*]] = arith.cmpi sge, %[[OPERAND_BIASED_EXP]], %[[C_NEG_1]] : i16
405
- // CHECK-DAG: %[[OPERAND_BIASED_EXP_LT_10:.*]] = arith.cmpi slt, %[[OPERAND_BIASED_EXP]], %[[C_10]] : i16
406
- // CHECK-DAG: %[[OPERAND_IS_HALFWAY_0:.*]] = arith.cmpi eq, %[[OPERAND_MASKED_MANTISSA]], %[[EXPECTED_OPERAND_MASKED_MANTISSA]] : i16
407
- // CHECK-DAG: %[[OPERAND_IS_HALFWAY_1:.*]] = arith.andi %[[OPERAND_IS_HALFWAY_0]], %[[OPERAND_BIASED_EXP_LT_10]] : i1
408
- // CHECK-DAG: %[[OPERAND_IS_HALFWAY_2:.*]] = arith.andi %[[OPERAND_IS_HALFWAY_1]], %[[OPERAND_BIASED_EXP_GE_NEG_1]] : i1
409
-
410
- // Adjust rounded operand with `round(operand) - sign(operand)` to correct the
411
- // case where `round` rounded in the oppositve direction of `roundeven`.
412
- // CHECK: %[[SIGN:.*]] = math.copysign %[[C_1_FLOAT]], %[[VAL_0]] : f16
413
- // CHECK: %[[ROUND_SHIFTED:.*]] = arith.subf %[[ROUND]], %[[SIGN]] : f16
414
- // CHECK: %[[NEEDS_SHIFT:.*]] = arith.andi %[[ROUND_IS_NOT_EVEN_OR_SPECIAL_1]], %[[OPERAND_IS_HALFWAY_2]] : i1
415
- // CHECK: %[[RESULT:.*]] = arith.select %[[NEEDS_SHIFT]], %[[ROUND_SHIFTED]], %[[ROUND]] : f16
416
-
417
- // The `x - sign` adjustment does not preserve the sign when we are adjusting the value -1 to -0.
418
- // CHECK: %[[COPYSIGN:.*]] = math.copysign %[[RESULT]], %[[VAL_0]] : f16
419
-
420
- // CHECK: return %[[COPYSIGN]] : f16
0 commit comments