Skip to content

Commit 422068f

Browse files
committed
Make the order creating the ops explicit to make sure the same sequence is
created for different Linux systems.
1 parent 7c4a594 commit 422068f

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,9 +1184,10 @@ ErfcPolynomialApproximation::matchAndRewrite(math::ErfcOp op,
11841184
Value d = builder.create<math::FmaOp>(pos2, a, one);
11851185
r = builder.create<arith::DivFOp>(one, d);
11861186
q = builder.create<math::FmaOp>(p, r, r);
1187-
e = builder.create<math::FmaOp>(
1188-
builder.create<math::FmaOp>(q, builder.create<arith::NegFOp>(a), onehalf),
1189-
pos2, builder.create<arith::SubFOp>(p, q));
1187+
Value negfa = builder.create<arith::NegFOp>(a);
1188+
Value fmaqah = builder.create<math::FmaOp>(q, negfa, onehalf);
1189+
Value psubq = builder.create<arith::SubFOp>(p, q);
1190+
e = builder.create<math::FmaOp>(fmaqah, pos2, psubq);
11901191
r = builder.create<math::FmaOp>(e, r, q);
11911192

11921193
Value s = builder.create<arith::MulFOp>(a, a);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ func.func @erf_scalar(%arg0: f32) -> f32 {
139139
// CHECK-NEXT: %[[val_20:.*]] = math.fma %[[cst_26]], %[[val_2]], %[[cst_22]] : f32
140140
// CHECK-NEXT: %[[val_21:.*]] = arith.divf %[[cst_22]], %[[val_20]] : f32
141141
// CHECK-NEXT: %[[val_22:.*]] = math.fma %[[val_19]], %[[val_21]], %[[val_21]] : f32
142-
// CHECK-NEXT: %[[val_23:.*]] = arith.subf %[[val_19]], %[[val_22]] : f32
143-
// CHECK-NEXT: %[[val_24:.*]] = arith.negf %[[val_2]] : f32
144-
// CHECK-NEXT: %[[val_25:.*]] = math.fma %[[val_22]], %[[val_24]], %[[cst_23]] : f32
145-
// CHECK-NEXT: %[[val_26:.*]] = math.fma %[[val_25]], %[[cst_26]], %[[val_23]] : f32
142+
// CHECK-NEXT: %[[val_23:.*]] = arith.negf %[[val_2]] : f32
143+
// CHECK-NEXT: %[[val_24:.*]] = math.fma %[[val_22]], %[[val_23]], %[[cst_23]] : f32
144+
// CHECK-NEXT: %[[val_25:.*]] = arith.subf %[[val_19]], %[[val_22]] : f32
145+
// CHECK-NEXT: %[[val_26:.*]] = math.fma %[[val_24]], %[[cst_26]], %[[val_25]] : f32
146146
// CHECK-NEXT: %[[val_27:.*]] = math.fma %[[val_26]], %[[val_21]], %[[val_22]] : f32
147147
// CHECK-NEXT: %[[val_28:.*]] = arith.mulf %[[val_2]], %[[val_2]] : f32
148148
// CHECK-NEXT: %[[val_29:.*]] = arith.negf %[[val_28]] : f32

0 commit comments

Comments
 (0)