@@ -470,11 +470,6 @@ createLinalgBodyCalculationForElementwiseOp(Operation *op, ValueRange args,
470
470
}
471
471
472
472
if (arith::FPToSIOp::areCastCompatible (srcTy, dstTy)) {
473
- auto zero = rewriter.create <arith::ConstantOp>(
474
- loc, rewriter.getF32FloatAttr (0 .0f ));
475
- auto half = rewriter.create <arith::ConstantOp>(
476
- loc, rewriter.getF32FloatAttr (0 .5f ));
477
-
478
473
auto intMin = rewriter.create <arith::ConstantOp>(
479
474
loc, rewriter.getF32FloatAttr (
480
475
APInt::getSignedMinValue (dstTy.getIntOrFloatBitWidth ())
@@ -485,12 +480,7 @@ createLinalgBodyCalculationForElementwiseOp(Operation *op, ValueRange args,
485
480
APInt::getSignedMaxValue (dstTy.getIntOrFloatBitWidth ())
486
481
.getSExtValue ()));
487
482
488
- auto added = rewriter.create <arith::AddFOp>(loc, args[0 ], half);
489
- auto subbed = rewriter.create <arith::SubFOp>(loc, args[0 ], half);
490
- auto negative = rewriter.create <arith::CmpFOp>(
491
- loc, arith::CmpFPredicate::OLT, args[0 ], zero);
492
- auto rounded =
493
- rewriter.create <arith::SelectOp>(loc, negative, subbed, added);
483
+ auto rounded = rewriter.create <math::RoundEvenOp>(loc, args[0 ]);
494
484
495
485
auto clamped = clampFloatHelper (loc, rounded, intMin, intMax, rewriter);
496
486
0 commit comments