diff --git a/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp b/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp index 7d04ae7e3d34..6e49d065f8d4 100644 --- a/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp +++ b/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp @@ -325,8 +325,8 @@ AtanApproximation::matchAndRewrite(math::AtanOp op, p = builder.create(x, p); // Remap the solution for over [0.0, 1.0] to [0.0, inf] - auto half_pi = broadcast(builder, f32Cst(builder, 1.57079632679f), shape); - Value sub = builder.create(half_pi, p); + auto halfPi = broadcast(builder, f32Cst(builder, 1.57079632679f), shape); + Value sub = builder.create(halfPi, p); Value select = builder.create(compare, p, sub); // Correct for signing of the input. @@ -366,40 +366,38 @@ Atan2Approximation::matchAndRewrite(math::Atan2Op op, // Determine what the atan would be for a 180 degree rotation. auto zero = broadcast(builder, f32Cst(builder, 0.0f), shape); auto pi = broadcast(builder, f32Cst(builder, 3.14159265359f), shape); - auto add_pi = builder.create(atan, pi); - auto sub_pi = builder.create(atan, pi); - auto atan_gt = + auto addPi = builder.create(atan, pi); + auto subPi = builder.create(atan, pi); + auto atanGt = builder.create(arith::CmpFPredicate::OGT, atan, zero); - auto flipped_atan = builder.create(atan_gt, sub_pi, add_pi); + auto flippedAtan = builder.create(atanGt, subPi, addPi); // Determine whether to directly use atan or use the 180 degree flip - auto x_gt = builder.create(arith::CmpFPredicate::OGT, x, zero); - Value result = builder.create(x_gt, atan, flipped_atan); + auto xGt = builder.create(arith::CmpFPredicate::OGT, x, zero); + Value result = builder.create(xGt, atan, flippedAtan); // Handle x = 0, y > 0 - Value x_zero = + Value xZero = builder.create(arith::CmpFPredicate::OEQ, x, zero); - Value y_gt = - builder.create(arith::CmpFPredicate::OGT, y, zero); - Value is_half_pi = builder.create(x_zero, y_gt); - auto half_pi = broadcast(builder, f32Cst(builder, 1.57079632679f), shape); - result = builder.create(is_half_pi, half_pi, result); + Value yGt = builder.create(arith::CmpFPredicate::OGT, y, zero); + Value isHalfPi = builder.create(xZero, yGt); + auto halfPi = broadcast(builder, f32Cst(builder, 1.57079632679f), shape); + result = builder.create(isHalfPi, halfPi, result); // Handle x = 0, y < 0 - Value y_lt = - builder.create(arith::CmpFPredicate::OLT, y, zero); - Value is_negative_half_pi_pi = builder.create(x_zero, y_lt); - auto negative_half_pi_pi = + Value yLt = builder.create(arith::CmpFPredicate::OLT, y, zero); + Value isNegativeHalfPiPi = builder.create(xZero, yLt); + auto negativeHalfPiPi = broadcast(builder, f32Cst(builder, -1.57079632679), shape); - result = builder.create(is_negative_half_pi_pi, negative_half_pi_pi, - result); + result = + builder.create(isNegativeHalfPiPi, negativeHalfPiPi, result); // Handle x = 0, y = 0; - Value y_zero = + Value yZero = builder.create(arith::CmpFPredicate::OEQ, y, zero); - Value is_nan = builder.create(x_zero, y_zero); - Value cst_nan = broadcast(builder, f32FromBits(builder, 0x7fc00000), shape); - result = builder.create(is_nan, cst_nan, result); + Value isNan = builder.create(xZero, yZero); + Value cstNan = broadcast(builder, f32FromBits(builder, 0x7fc00000), shape); + result = builder.create(isNan, cstNan, result); rewriter.replaceOp(op, result); return success();