diff --git a/lib/Differentiator/ReverseModeVisitor.cpp b/lib/Differentiator/ReverseModeVisitor.cpp index b497abe26..89e291c31 100644 --- a/lib/Differentiator/ReverseModeVisitor.cpp +++ b/lib/Differentiator/ReverseModeVisitor.cpp @@ -2397,37 +2397,37 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, Rdiff = Visit(R, BuildOp(UO_Minus, oldValue)); valueForRevPass = BuildOp(BO_Sub, Rdiff.getRevSweepAsExpr(), Ldiff.getRevSweepAsExpr()); } else if (opCode == BO_MulAssign) { - auto RDelayed = DelayedGlobalStoreAndRef(R); - StmtDiff RResult = RDelayed.Result; + // Create a reference variable to keep the result of LHS, since it + // must be used on 2 places: when storing to a global variable + // accessible from the reverse pass, and when rebuilding the original + // expression for the forward pass. This allows to avoid executing + // same expression with side effects twice. E.g., on + // double r = (x *= y) *= z; + // instead of: + // _t0 = (x *= y); + // double r = (x *= y) *= z; + // which modifies x twice, we get: + // double & _ref0 = (x *= y); + // _t0 = _ref0; + // double r = _ref0 *= z; + if (isInsideLoop) + addToCurrentBlock(LCloned, direction::forward); + /// Capture all the emitted statements while visiting R + /// and insert them after `dl += dl * R` + beginBlock(direction::reverse); + Expr* dr = BuildOp(BO_Mul, LCloned, oldValue); + dr = StoreAndRef(dr, direction::reverse); + Rdiff = Visit(R, dr); + Stmts RBlock = EndBlockWithoutCreatingCS(direction::reverse); addToCurrentBlock( BuildOp(BO_AddAssign, AssignedDiff, - BuildOp(BO_Mul, oldValue, RResult.getExpr_dx())), + BuildOp(BO_Mul, oldValue, Rdiff.getRevSweepAsExpr())), direction::reverse); - if (!RDelayed.isConstant) { - // Create a reference variable to keep the result of LHS, since it - // must be used on 2 places: when storing to a global variable - // accessible from the reverse pass, and when rebuilding the original - // expression for the forward pass. This allows to avoid executing - // same expression with side effects twice. E.g., on - // double r = (x *= y) *= z; - // instead of: - // _t0 = (x *= y); - // double r = (x *= y) *= z; - // which modifies x twice, we get: - // double & _ref0 = (x *= y); - // _t0 = _ref0; - // double r = _ref0 *= z; - - if (isInsideLoop) - addToCurrentBlock(LCloned, direction::forward); - Expr* dr = BuildOp(BO_Mul, LCloned, oldValue); - dr = StoreAndRef(dr, direction::reverse); - Rdiff = Visit(R, dr); - RDelayed.Finalize(Rdiff.getExpr()); - } + for (auto& S : RBlock) + addToCurrentBlock(S, direction::reverse); valueForRevPass = BuildOp(BO_Mul, Rdiff.getRevSweepAsExpr(), Ldiff.getRevSweepAsExpr()); - std::tie(Ldiff, Rdiff) = std::make_pair(LCloned, RResult.getExpr()); + std::tie(Ldiff, Rdiff) = std::make_pair(LCloned, Rdiff.getExpr()); } else if (opCode == BO_DivAssign) { auto RDelayed = DelayedGlobalStoreAndRef(R); StmtDiff RResult = RDelayed.Result; diff --git a/test/Arrays/ArrayInputsReverseMode.C b/test/Arrays/ArrayInputsReverseMode.C index a52144c63..7cab27267 100644 --- a/test/Arrays/ArrayInputsReverseMode.C +++ b/test/Arrays/ArrayInputsReverseMode.C @@ -75,14 +75,13 @@ float func(float* a, float* b) { //CHECK-NEXT: int _d_i = 0; //CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: clad::tape _t2 = {}; -//CHECK-NEXT: clad::tape _t3 = {}; //CHECK-NEXT: float sum = 0; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < 3; i++) { //CHECK-NEXT: _t0++; //CHECK-NEXT: clad::push(_t1, a[i]); -//CHECK-NEXT: a[i] *= clad::push(_t2, b[i]); -//CHECK-NEXT: clad::push(_t3, sum); +//CHECK-NEXT: a[i] *= b[i]; +//CHECK-NEXT: clad::push(_t2, sum); //CHECK-NEXT: sum += a[i]; //CHECK-NEXT: } //CHECK-NEXT: goto _label0; @@ -91,7 +90,7 @@ float func(float* a, float* b) { //CHECK-NEXT: for (; _t0; _t0--) { //CHECK-NEXT: i--; //CHECK-NEXT: { -//CHECK-NEXT: sum = clad::pop(_t3); +//CHECK-NEXT: sum = clad::pop(_t2); //CHECK-NEXT: float _r_d1 = _d_sum; //CHECK-NEXT: _d_sum += _r_d1; //CHECK-NEXT: _d_a[i] += _r_d1; @@ -100,7 +99,7 @@ float func(float* a, float* b) { //CHECK-NEXT: { //CHECK-NEXT: a[i] = clad::pop(_t1); //CHECK-NEXT: float _r_d0 = _d_a[i]; -//CHECK-NEXT: _d_a[i] += _r_d0 * clad::pop(_t2); +//CHECK-NEXT: _d_a[i] += _r_d0 * b[i]; //CHECK-NEXT: float _r0 = a[i] * _r_d0; //CHECK-NEXT: _d_b[i] += _r0; //CHECK-NEXT: _d_a[i] -= _r_d0; diff --git a/test/ErrorEstimation/ConditonalStatements.C b/test/ErrorEstimation/ConditonalStatements.C index c66c32844..e19890efe 100644 --- a/test/ErrorEstimation/ConditonalStatements.C +++ b/test/ErrorEstimation/ConditonalStatements.C @@ -188,28 +188,25 @@ float func4(float x, float y) { //CHECK-NEXT: float _EERepl_x0 = x; //CHECK-NEXT: float _EERepl_x1; //CHECK-NEXT: float _t1; -//CHECK-NEXT: float _t2; //CHECK-NEXT: float _EERepl_x2; -//CHECK-NEXT: float _t3; +//CHECK-NEXT: float _t2; //CHECK-NEXT: double _ret_value0 = 0; //CHECK-NEXT: _cond0 = !x; //CHECK-NEXT: if (_cond0) //CHECK-NEXT: _t0 = x; -//CHECK-NEXT: else { +//CHECK-NEXT: else //CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t2 = x; -//CHECK-NEXT: } -//CHECK-NEXT: _cond0 ? (x += 1) : (x *= _t2); +//CHECK-NEXT: _cond0 ? (x += 1) : (x *= x); //CHECK-NEXT: _EERepl_x2 = x; //CHECK-NEXT: _EERepl_x1 = x; -//CHECK-NEXT: _t3 = x; -//CHECK-NEXT: _ret_value0 = y / _t3; +//CHECK-NEXT: _t2 = x; +//CHECK-NEXT: _ret_value0 = y / _t2; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: float _r1 = 1 / _t3; +//CHECK-NEXT: float _r1 = 1 / _t2; //CHECK-NEXT: * _d_y += _r1; -//CHECK-NEXT: float _r2 = 1 * -y / (_t3 * _t3); +//CHECK-NEXT: float _r2 = 1 * -y / (_t2 * _t2); //CHECK-NEXT: * _d_x += _r2; //CHECK-NEXT: } //CHECK-NEXT: { @@ -222,7 +219,7 @@ float func4(float x, float y) { //CHECK-NEXT: } else { //CHECK-NEXT: x = _t1; //CHECK-NEXT: float _r_d1 = * _d_x; -//CHECK-NEXT: * _d_x += _r_d1 * _t2; +//CHECK-NEXT: * _d_x += _r_d1 * x; //CHECK-NEXT: float _r0 = x * _r_d1; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: _delta_x += std::abs(_r_d1 * _EERepl_x2 * {{.+}}); diff --git a/test/Gradient/Assignments.C b/test/Gradient/Assignments.C index cc180b021..e63396d87 100644 --- a/test/Gradient/Assignments.C +++ b/test/Gradient/Assignments.C @@ -233,7 +233,7 @@ double f6(double x, double y) { return t; } -//CHECK-NEXT: void f6_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { +//CHECK: void f6_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { //CHECK-NEXT: double _t0; //CHECK-NEXT: double _d_t = 0; //CHECK-NEXT: bool _cond0; @@ -301,7 +301,7 @@ double f7(double x, double y) { return t[0]; // == x } -//CHECK-NEXT: void f7_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { +//CHECK: void f7_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { //CHECK-NEXT: double _t0; //CHECK-NEXT: clad::array _d_t(3UL); //CHECK-NEXT: double _t1; @@ -312,7 +312,6 @@ double f7(double x, double y) { //CHECK-NEXT: double _t6; //CHECK-NEXT: double _t7; //CHECK-NEXT: double _t8; -//CHECK-NEXT: double _t9; //CHECK-NEXT: _t0 = x; //CHECK-NEXT: double t[3] = {1, x, x * _t0}; //CHECK-NEXT: t[0]++; @@ -326,20 +325,19 @@ double f7(double x, double y) { //CHECK-NEXT: _t3 = t[0]; //CHECK-NEXT: t[0] += t[1]; //CHECK-NEXT: _t4 = t[0]; -//CHECK-NEXT: _t5 = t[1]; -//CHECK-NEXT: t[0] *= _t5; -//CHECK-NEXT: _t6 = t[0]; -//CHECK-NEXT: _t7 = t[1]; -//CHECK-NEXT: t[0] /= _t7; -//CHECK-NEXT: _t8 = t[0]; +//CHECK-NEXT: t[0] *= t[1]; +//CHECK-NEXT: _t5 = t[0]; +//CHECK-NEXT: _t6 = t[1]; +//CHECK-NEXT: t[0] /= _t6; +//CHECK-NEXT: _t7 = t[0]; //CHECK-NEXT: t[0] -= t[1]; -//CHECK-NEXT: _t9 = x; +//CHECK-NEXT: _t8 = x; //CHECK-NEXT: x = ++t[0]; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t[0] += 1; //CHECK-NEXT: { -//CHECK-NEXT: x = _t9; +//CHECK-NEXT: x = _t8; //CHECK-NEXT: double _r_d6 = * _d_x; //CHECK-NEXT: _d_t[0] += _r_d6; //CHECK-NEXT: --t[0]; @@ -347,7 +345,7 @@ double f7(double x, double y) { //CHECK-NEXT: * _d_x; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: t[0] = _t8; +//CHECK-NEXT: t[0] = _t7; //CHECK-NEXT: double _r_d5 = _d_t[0]; //CHECK-NEXT: _d_t[0] += _r_d5; //CHECK-NEXT: _d_t[1] += -_r_d5; @@ -355,10 +353,10 @@ double f7(double x, double y) { //CHECK-NEXT: _d_t[0]; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: t[0] = _t6; +//CHECK-NEXT: t[0] = _t5; //CHECK-NEXT: double _r_d4 = _d_t[0]; -//CHECK-NEXT: _d_t[0] += _r_d4 / _t7; -//CHECK-NEXT: double _r3 = _r_d4 * -t[0] / (_t7 * _t7); +//CHECK-NEXT: _d_t[0] += _r_d4 / _t6; +//CHECK-NEXT: double _r3 = _r_d4 * -t[0] / (_t6 * _t6); //CHECK-NEXT: _d_t[1] += _r3; //CHECK-NEXT: _d_t[0] -= _r_d4; //CHECK-NEXT: _d_t[0]; @@ -366,7 +364,7 @@ double f7(double x, double y) { //CHECK-NEXT: { //CHECK-NEXT: t[0] = _t4; //CHECK-NEXT: double _r_d3 = _d_t[0]; -//CHECK-NEXT: _d_t[0] += _r_d3 * _t5; +//CHECK-NEXT: _d_t[0] += _r_d3 * t[1]; //CHECK-NEXT: double _r2 = t[0] * _r_d3; //CHECK-NEXT: _d_t[1] += _r2; //CHECK-NEXT: _d_t[0] -= _r_d3; @@ -419,20 +417,18 @@ double f8(double x, double y) { return t[3]; // == y * y } -//CHECK-NEXT: void f8_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { +//CHECK: void f8_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { //CHECK-NEXT: clad::array _d_t(4UL); //CHECK-NEXT: double _t0; //CHECK-NEXT: double _t1; //CHECK-NEXT: double _t2; //CHECK-NEXT: double _t3; -//CHECK-NEXT: double _t4; //CHECK-NEXT: double t[4] = {1, x, y, 1}; //CHECK-NEXT: _t0 = t[3]; //CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _t3 = t[0]; -//CHECK-NEXT: _t4 = t[1]; -//CHECK-NEXT: _t2 = (t[0] = t[1] = t[2]); -//CHECK-NEXT: t[3] = (y *= _t2); +//CHECK-NEXT: _t2 = t[0]; +//CHECK-NEXT: _t3 = t[1]; +//CHECK-NEXT: t[3] = (y *= (t[0] = t[1] = t[2])); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t[3] += 1; @@ -442,13 +438,13 @@ double f8(double x, double y) { //CHECK-NEXT: * _d_y += _r_d0; //CHECK-NEXT: y = _t1; //CHECK-NEXT: double _r_d1 = * _d_y; -//CHECK-NEXT: * _d_y += _r_d1 * _t2; +//CHECK-NEXT: * _d_y += _r_d1 * t[2]; //CHECK-NEXT: double _r0 = y * _r_d1; //CHECK-NEXT: _d_t[0] += _r0; -//CHECK-NEXT: t[0] = _t3; +//CHECK-NEXT: t[0] = _t2; //CHECK-NEXT: double _r_d2 = _d_t[0]; //CHECK-NEXT: _d_t[1] += _r_d2; -//CHECK-NEXT: t[1] = _t4; +//CHECK-NEXT: t[1] = _t3; //CHECK-NEXT: double _r_d3 = _d_t[1]; //CHECK-NEXT: _d_t[2] += _r_d3; //CHECK-NEXT: _d_t[1] -= _r_d3; @@ -472,29 +468,25 @@ double f9(double x, double y) { //CHECK: void f9_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { //CHECK-NEXT: double _d_t = 0; //CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: double _t4; +//CHECK-NEXT: double _t2; //CHECK-NEXT: double t = x; //CHECK-NEXT: _t0 = t; -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: double &_t2 = (t *= _t1); -//CHECK-NEXT: _t3 = t; -//CHECK-NEXT: _t4 = y; -//CHECK-NEXT: _t2 *= _t4; +//CHECK-NEXT: double &_t1 = (t *= x); +//CHECK-NEXT: _t2 = t; +//CHECK-NEXT: _t1 *= y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: { -//CHECK-NEXT: t = _t3; +//CHECK-NEXT: t = _t2; //CHECK-NEXT: double _r_d1 = _d_t; -//CHECK-NEXT: _d_t += _r_d1 * _t4; -//CHECK-NEXT: double _r1 = _t2 * _r_d1; +//CHECK-NEXT: _d_t += _r_d1 * y; +//CHECK-NEXT: double _r1 = _t1 * _r_d1; //CHECK-NEXT: * _d_y += _r1; //CHECK-NEXT: _d_t -= _r_d1; //CHECK-NEXT: t = _t0; //CHECK-NEXT: double _r_d0 = _d_t; -//CHECK-NEXT: _d_t += _r_d0 * _t1; +//CHECK-NEXT: _d_t += _r_d0 * x; //CHECK-NEXT: double _r0 = t * _r_d0; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: _d_t -= _r_d0; @@ -576,7 +568,6 @@ double f12(double x, double y) { //CHECK-NEXT: double _t1; //CHECK-NEXT: double _t3; //CHECK-NEXT: double _t4; -//CHECK-NEXT: double _t5; //CHECK-NEXT: double t; //CHECK-NEXT: _cond0 = x > y; //CHECK-NEXT: if (_cond0) @@ -586,8 +577,7 @@ double f12(double x, double y) { //CHECK-NEXT: double &_t2 = (_cond0 ? (t = x) : (t = y)); //CHECK-NEXT: _t3 = t; //CHECK-NEXT: _t4 = t; -//CHECK-NEXT: _t5 = y; -//CHECK-NEXT: _t2 *= _t5; +//CHECK-NEXT: _t2 *= y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; @@ -595,7 +585,7 @@ double f12(double x, double y) { //CHECK-NEXT: t = _t3; //CHECK-NEXT: t = _t4; //CHECK-NEXT: double _r_d2 = (_cond0 ? _d_t : _d_t); -//CHECK-NEXT: (_cond0 ? _d_t : _d_t) += _r_d2 * _t5; +//CHECK-NEXT: (_cond0 ? _d_t : _d_t) += _r_d2 * y; //CHECK-NEXT: double _r0 = _t2 * _r_d2; //CHECK-NEXT: * _d_y += _r0; //CHECK-NEXT: (_cond0 ? _d_t : _d_t) -= _r_d2; @@ -661,7 +651,6 @@ double f14(double i, double j) { // CHECK-NEXT: double _t1; // CHECK-NEXT: double _t2; // CHECK-NEXT: double _t3; -// CHECK-NEXT: double _t4; // CHECK-NEXT: _d_a = &* _d_i; // CHECK-NEXT: double &a = i; // CHECK-NEXT: _t0 = a; @@ -670,15 +659,14 @@ double f14(double i, double j) { // CHECK-NEXT: _t2 = a; // CHECK-NEXT: a += i; // CHECK-NEXT: _t3 = a; -// CHECK-NEXT: _t4 = i; -// CHECK-NEXT: a *= _t4; +// CHECK-NEXT: a *= i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: * _d_i += 1; // CHECK-NEXT: { // CHECK-NEXT: a = _t3; // CHECK-NEXT: double _r_d2 = *_d_a; -// CHECK-NEXT: *_d_a += _r_d2 * _t4; +// CHECK-NEXT: *_d_a += _r_d2 * i; // CHECK-NEXT: double _r2 = a * _r_d2; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: *_d_a -= _r_d2; @@ -725,8 +713,6 @@ double f15(double i, double j) { // CHECK-NEXT: double _t5; // CHECK-NEXT: double _t6; // CHECK-NEXT: double _t7; -// CHECK-NEXT: double _t8; -// CHECK-NEXT: double _t9; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: double b = i * _t0; // CHECK-NEXT: _d_a = &_d_b; @@ -736,18 +722,16 @@ double f15(double i, double j) { // CHECK-NEXT: _d_d = &* _d_j; // CHECK-NEXT: double &d = j; // CHECK-NEXT: _t1 = a; -// CHECK-NEXT: _t2 = i; -// CHECK-NEXT: a *= _t2; -// CHECK-NEXT: _t3 = b; -// CHECK-NEXT: _t4 = i; -// CHECK-NEXT: b += 2 * _t4; -// CHECK-NEXT: _t5 = c; -// CHECK-NEXT: _t6 = i; -// CHECK-NEXT: c += 3 * _t6; -// CHECK-NEXT: _t7 = d; -// CHECK-NEXT: _t9 = j; -// CHECK-NEXT: _t8 = 3 * _t9; -// CHECK-NEXT: d *= _t8; +// CHECK-NEXT: a *= i; +// CHECK-NEXT: _t2 = b; +// CHECK-NEXT: _t3 = i; +// CHECK-NEXT: b += 2 * _t3; +// CHECK-NEXT: _t4 = c; +// CHECK-NEXT: _t5 = i; +// CHECK-NEXT: c += 3 * _t5; +// CHECK-NEXT: _t6 = d; +// CHECK-NEXT: _t7 = j; +// CHECK-NEXT: d *= 3 * _t7; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { @@ -756,29 +740,29 @@ double f15(double i, double j) { // CHECK-NEXT: *_d_d += 1; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: d = _t7; +// CHECK-NEXT: d = _t6; // CHECK-NEXT: double _r_d3 = *_d_d; -// CHECK-NEXT: *_d_d += _r_d3 * _t8; +// CHECK-NEXT: *_d_d += _r_d3 * 3 * _t7; // CHECK-NEXT: double _r7 = d * _r_d3; -// CHECK-NEXT: double _r8 = _r7 * _t9; +// CHECK-NEXT: double _r8 = _r7 * _t7; // CHECK-NEXT: double _r9 = 3 * _r7; // CHECK-NEXT: * _d_j += _r9; // CHECK-NEXT: *_d_d -= _r_d3; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: c = _t5; +// CHECK-NEXT: c = _t4; // CHECK-NEXT: double _r_d2 = *_d_c; // CHECK-NEXT: *_d_c += _r_d2; -// CHECK-NEXT: double _r5 = _r_d2 * _t6; +// CHECK-NEXT: double _r5 = _r_d2 * _t5; // CHECK-NEXT: double _r6 = 3 * _r_d2; // CHECK-NEXT: * _d_i += _r6; // CHECK-NEXT: *_d_c -= _r_d2; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: b = _t3; +// CHECK-NEXT: b = _t2; // CHECK-NEXT: double _r_d1 = _d_b; // CHECK-NEXT: _d_b += _r_d1; -// CHECK-NEXT: double _r3 = _r_d1 * _t4; +// CHECK-NEXT: double _r3 = _r_d1 * _t3; // CHECK-NEXT: double _r4 = 2 * _r_d1; // CHECK-NEXT: * _d_i += _r4; // CHECK-NEXT: _d_b -= _r_d1; @@ -786,7 +770,7 @@ double f15(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: a = _t1; // CHECK-NEXT: double _r_d0 = *_d_a; -// CHECK-NEXT: *_d_a += _r_d0 * _t2; +// CHECK-NEXT: *_d_a += _r_d0 * i; // CHECK-NEXT: double _r2 = a * _r_d0; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: *_d_a -= _r_d0; @@ -813,7 +797,6 @@ double f16(double i, double j) { // CHECK-NEXT: double *_d_c = 0; // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; // CHECK-NEXT: _d_a = &* _d_i; // CHECK-NEXT: double &a = i; // CHECK-NEXT: _d_b = &*_d_a; @@ -821,18 +804,17 @@ double f16(double i, double j) { // CHECK-NEXT: _d_c = &*_d_b; // CHECK-NEXT: double &c = b; // CHECK-NEXT: _t0 = c; -// CHECK-NEXT: _t2 = j; -// CHECK-NEXT: _t1 = 4 * _t2; -// CHECK-NEXT: c *= _t1; +// CHECK-NEXT: _t1 = j; +// CHECK-NEXT: c *= 4 * _t1; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: * _d_i += 1; // CHECK-NEXT: { // CHECK-NEXT: c = _t0; // CHECK-NEXT: double _r_d0 = *_d_c; -// CHECK-NEXT: *_d_c += _r_d0 * _t1; +// CHECK-NEXT: *_d_c += _r_d0 * 4 * _t1; // CHECK-NEXT: double _r0 = c * _r_d0; -// CHECK-NEXT: double _r1 = _r0 * _t2; +// CHECK-NEXT: double _r1 = _r0 * _t1; // CHECK-NEXT: double _r2 = 4 * _r0; // CHECK-NEXT: * _d_j += _r2; // CHECK-NEXT: *_d_c -= _r_d0; @@ -910,7 +892,7 @@ double f19(double a, double b) { return std::fma(a, b, b); } -//CHECK-NEXT: void f19_grad(double a, double b, clad::array_ref _d_a, clad::array_ref _d_b) { +//CHECK: void f19_grad(double a, double b, clad::array_ref _d_a, clad::array_ref _d_b) { //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: {