From e5cae86b8efb4aab9b4134507a0075508af1a5e9 Mon Sep 17 00:00:00 2001 From: "petro.zarytskyi" Date: Wed, 29 Nov 2023 01:18:20 +0200 Subject: [PATCH] Do not store the RHS of multiplication with no side effects. --- lib/Differentiator/ReverseModeVisitor.cpp | 28 +- test/Arrays/ArrayInputsReverseMode.C | 45 ++-- test/Arrays/Arrays.C | 12 +- test/ErrorEstimation/Assignments.C | 16 +- test/ErrorEstimation/BasicOps.C | 72 ++--- test/ErrorEstimation/ConditonalStatements.C | 43 ++- test/ErrorEstimation/LoopsAndArrays.C | 85 +++--- test/ErrorEstimation/LoopsAndArraysExec.C | 17 +- test/FirstDerivative/FunctionCalls.C | 2 +- test/Gradient/Assignments.C | 198 ++++++-------- test/Gradient/DiffInterface.C | 78 ++---- test/Gradient/FunctionCalls.C | 71 ++--- test/Gradient/Functors.C | 72 ++--- test/Gradient/Gradients.C | 235 +++++----------- test/Gradient/Loops.C | 280 +++++++++----------- test/Gradient/MemberFunctions.C | 226 ++++------------ test/Gradient/Pointers.C | 4 +- test/Gradient/TemplateFunctors.C | 80 ++---- test/Gradient/TestTypeConversion.C | 5 +- test/Gradient/UserDefinedTypes.C | 142 ++++------ test/Gradient/constexprTest.C | 35 +-- test/Hessian/BuiltinDerivatives.C | 60 ++--- test/Hessian/Hessians.C | 96 ++----- test/Hessian/NestedFunctionCalls.C | 24 +- test/Hessian/Pointers.C | 16 +- test/Jacobian/Functors.C | 232 +++++----------- test/Jacobian/Jacobian.C | 122 +++------ test/Jacobian/TemplateFunctors.C | 88 ++---- test/Jacobian/constexprTest.C | 61 ++--- test/Jacobian/testUtility.C | 61 ++--- test/Misc/RunDemos.C | 8 +- test/NestedCalls/NestedCalls.C | 8 +- test/ROOT/Interface.C | 4 +- test/ROOT/TFormula.C | 4 +- 34 files changed, 864 insertions(+), 1666 deletions(-) diff --git a/lib/Differentiator/ReverseModeVisitor.cpp b/lib/Differentiator/ReverseModeVisitor.cpp index d7d3438d2..e5ed3309e 100644 --- a/lib/Differentiator/ReverseModeVisitor.cpp +++ b/lib/Differentiator/ReverseModeVisitor.cpp @@ -2184,11 +2184,22 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, // to reduce cloning complexity and only clones once. Storing it in a // global variable allows to save current result and make it accessible // in the reverse pass. - auto RDelayed = DelayedGlobalStoreAndRef(R); - StmtDiff RResult = RDelayed.Result; + std::unique_ptr RDelayed; + Expr::EvalResult dummy; + bool RisNotConst = !clad_compat::Expr_EvaluateAsConstantExpr(R, dummy, m_Context); + StmtDiff RResult; + // If R has no side effects, it can be just cloned + // (no need to store it). + if (R->HasSideEffects(m_Context) && RisNotConst) { + RDelayed = std::unique_ptr(new DelayedStoreResult(DelayedGlobalStoreAndRef(R))); + RResult = RDelayed->Result; + } else { + RResult = StmtDiff(Clone(R)); + } + Expr* dl = nullptr; if (dfdx()) { - dl = BuildOp(BO_Mul, dfdx(), RResult.getExpr_dx()); + dl = BuildOp(BO_Mul, dfdx(), RResult.getRevSweepAsExpr()); dl = StoreAndRef(dl, direction::reverse); } Ldiff = Visit(L, dl); @@ -2196,9 +2207,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, // df/dxr += df/dxi * dxi/xr = df/dxi * xl // Store left multiplier and assign it with L. Expr* LStored = Ldiff.getExpr(); - // RDelayed.isConstant == true implies that R is a constant expression, - // therefore we can skip visiting it. - if (!RDelayed.isConstant) { + if (RisNotConst) { Expr* dr = nullptr; if (dfdx()) { dr = BuildOp(BO_Mul, Ldiff.getRevSweepAsExpr(), dfdx()); @@ -2206,7 +2215,8 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, } Rdiff = Visit(R, dr); // Assign right multiplier's variable with R. - RDelayed.Finalize(Rdiff.getExpr()); + if (RDelayed) + RDelayed->Finalize(Rdiff.getExpr()); } std::tie(Ldiff, Rdiff) = std::make_pair(LStored, RResult.getExpr()); } else if (opCode == BO_Div) { @@ -2239,7 +2249,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, Rdiff = Visit(R, dr); RDelayed.Finalize(Rdiff.getExpr()); } - std::tie(Ldiff, Rdiff) = std::make_pair(Ldiff.getRevSweepAsExpr(), RResult.getRevSweepAsExpr()); + std::tie(Ldiff, Rdiff) = std::make_pair(Ldiff.getExpr(), RResult.getExpr()); } else if (BinOp->isAssignmentOp()) { if (L->isModifiableLvalue(m_Context) != Expr::MLV_Valid) { diag(DiagnosticsEngine::Warning, @@ -2966,7 +2976,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, Expr* Push = CladTape.Push; Expr* Pop = CladTape.Pop; return DelayedStoreResult{*this, - StmtDiff{Push, Pop}, + StmtDiff{Push, Pop, nullptr, Pop}, /*isConstant*/ false, /*isInsideLoop*/ true, /*pNeedsUpdate=*/ true}; } diff --git a/test/Arrays/ArrayInputsReverseMode.C b/test/Arrays/ArrayInputsReverseMode.C index 7cab27267..35874ca1d 100644 --- a/test/Arrays/ArrayInputsReverseMode.C +++ b/test/Arrays/ArrayInputsReverseMode.C @@ -113,12 +113,10 @@ float helper(float x) { } // CHECK: void helper_pullback(float x, float _d_y, clad::array_ref _d_x) { -// CHECK-NEXT: float _t0; -// CHECK-NEXT: _t0 = x; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: float _r0 = _d_y * _t0; +// CHECK-NEXT: float _r0 = _d_y * x; // CHECK-NEXT: float _r1 = 2 * _d_y; // CHECK-NEXT: * _d_x += _r1; // CHECK-NEXT: } @@ -208,30 +206,26 @@ double func4(double x) { } //CHECK: void func4_grad(double x, clad::array_ref _d_x) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; //CHECK-NEXT: clad::array _d_arr(3UL); //CHECK-NEXT: double _d_sum = 0; -//CHECK-NEXT: unsigned long _t2; +//CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t3 = {}; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: double arr[3] = {x, 2 * _t0, x * _t1}; +//CHECK-NEXT: clad::tape _t1 = {}; +//CHECK-NEXT: double arr[3] = {x, 2 * x, x * x}; //CHECK-NEXT: double sum = 0; -//CHECK-NEXT: _t2 = 0; +//CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < 3; i++) { -//CHECK-NEXT: _t2++; -//CHECK-NEXT: clad::push(_t3, sum); +//CHECK-NEXT: _t0++; +//CHECK-NEXT: clad::push(_t1, sum); //CHECK-NEXT: sum += addArr(arr, 3); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_sum += 1; -//CHECK-NEXT: for (; _t2; _t2--) { +//CHECK-NEXT: for (; _t0; _t0--) { //CHECK-NEXT: i--; //CHECK-NEXT: { -//CHECK-NEXT: sum = clad::pop(_t3); +//CHECK-NEXT: sum = clad::pop(_t1); //CHECK-NEXT: double _r_d0 = _d_sum; //CHECK-NEXT: _d_sum += _r_d0; //CHECK-NEXT: int _grad1 = 0; @@ -243,10 +237,10 @@ double func4(double x) { //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: * _d_x += _d_arr[0]; -//CHECK-NEXT: double _r0 = _d_arr[1] * _t0; +//CHECK-NEXT: double _r0 = _d_arr[1] * x; //CHECK-NEXT: double _r1 = 2 * _d_arr[1]; //CHECK-NEXT: * _d_x += _r1; -//CHECK-NEXT: double _r2 = _d_arr[2] * _t1; +//CHECK-NEXT: double _r2 = _d_arr[2] * x; //CHECK-NEXT: * _d_x += _r2; //CHECK-NEXT: double _r3 = x * _d_arr[2]; //CHECK-NEXT: * _d_x += _r3; @@ -334,15 +328,14 @@ double func6(double seed) { //CHECK-NEXT: double _d_sum = 0; //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: clad::array _d_arr(3UL); -//CHECK-NEXT: clad::tape _t2 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: double sum = 0; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < 3; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: double arr[3] = {seed, seed * clad::push(_t1, i), seed + i}; -//CHECK-NEXT: clad::push(_t2, sum); +//CHECK-NEXT: double arr[3] = {seed, seed * i, seed + i}; +//CHECK-NEXT: clad::push(_t1, sum); //CHECK-NEXT: sum += addArr(arr, 3); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; @@ -351,7 +344,7 @@ double func6(double seed) { //CHECK-NEXT: for (; _t0; _t0--) { //CHECK-NEXT: i--; //CHECK-NEXT: { -//CHECK-NEXT: sum = clad::pop(_t2); +//CHECK-NEXT: sum = clad::pop(_t1); //CHECK-NEXT: double _r_d0 = _d_sum; //CHECK-NEXT: _d_sum += _r_d0; //CHECK-NEXT: int _grad1 = 0; @@ -362,7 +355,7 @@ double func6(double seed) { //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: * _d_seed += _d_arr[0]; -//CHECK-NEXT: double _r0 = _d_arr[1] * clad::pop(_t1); +//CHECK-NEXT: double _r0 = _d_arr[1] * i; //CHECK-NEXT: * _d_seed += _r0; //CHECK-NEXT: double _r1 = seed * _d_arr[1]; //CHECK-NEXT: _d_i += _r1; @@ -379,15 +372,13 @@ double inv_square(double *params) { //CHECK: void inv_square_pullback(double *params, double _d_y, clad::array_ref _d_params) { //CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: _t1 = params[0]; -//CHECK-NEXT: _t0 = (params[0] * _t1); +//CHECK-NEXT: _t0 = (params[0] * params[0]); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r0 = _d_y / _t0; //CHECK-NEXT: double _r1 = _d_y * -1 / (_t0 * _t0); -//CHECK-NEXT: double _r2 = _r1 * _t1; +//CHECK-NEXT: double _r2 = _r1 * params[0]; //CHECK-NEXT: _d_params[0] += _r2; //CHECK-NEXT: double _r3 = params[0] * _r1; //CHECK-NEXT: _d_params[0] += _r3; diff --git a/test/Arrays/Arrays.C b/test/Arrays/Arrays.C index 913985108..9628771e0 100644 --- a/test/Arrays/Arrays.C +++ b/test/Arrays/Arrays.C @@ -94,26 +94,20 @@ double const_dot_product(double x, double y, double z) { //CHECK: void const_dot_product_grad(double x, double y, double z, clad::array_ref _d_x, clad::array_ref _d_y, clad::array_ref _d_z) { //CHECK-NEXT: clad::array _d_vars(3UL); //CHECK-NEXT: clad::array _d_consts(3UL); -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; //CHECK-NEXT: double vars[3] = {x, y, z}; //CHECK-NEXT: double consts[3] = {1, 2, 3}; -//CHECK-NEXT: _t0 = consts[0]; -//CHECK-NEXT: _t1 = consts[1]; -//CHECK-NEXT: _t2 = consts[2]; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * consts[0]; //CHECK-NEXT: _d_vars[0] += _r0; //CHECK-NEXT: double _r1 = vars[0] * 1; //CHECK-NEXT: _d_consts[0] += _r1; -//CHECK-NEXT: double _r2 = 1 * _t1; +//CHECK-NEXT: double _r2 = 1 * consts[1]; //CHECK-NEXT: _d_vars[1] += _r2; //CHECK-NEXT: double _r3 = vars[1] * 1; //CHECK-NEXT: _d_consts[1] += _r3; -//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r4 = 1 * consts[2]; //CHECK-NEXT: _d_vars[2] += _r4; //CHECK-NEXT: double _r5 = vars[2] * 1; //CHECK-NEXT: _d_consts[2] += _r5; diff --git a/test/ErrorEstimation/Assignments.C b/test/ErrorEstimation/Assignments.C index 610ce02f7..3efd6f18b 100644 --- a/test/ErrorEstimation/Assignments.C +++ b/test/ErrorEstimation/Assignments.C @@ -57,13 +57,9 @@ float func2(float x, int y) { //CHECK-NEXT: float _t0; //CHECK-NEXT: double _delta_x = 0; //CHECK-NEXT: float _EERepl_x0 = x; -//CHECK-NEXT: float _t1; -//CHECK-NEXT: float _t2; //CHECK-NEXT: float _EERepl_x1; //CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t2 = x; -//CHECK-NEXT: x = y * _t1 + x * _t2; +//CHECK-NEXT: x = y * x + x * x; //CHECK-NEXT: _EERepl_x1 = x; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: @@ -71,11 +67,11 @@ float func2(float x, int y) { //CHECK-NEXT: { //CHECK-NEXT: x = _t0; //CHECK-NEXT: float _r_d0 = * _d_x; -//CHECK-NEXT: float _r0 = _r_d0 * _t1; +//CHECK-NEXT: float _r0 = _r_d0 * x; //CHECK-NEXT: * _d_y += _r0; //CHECK-NEXT: float _r1 = y * _r_d0; //CHECK-NEXT: * _d_x += _r1; -//CHECK-NEXT: float _r2 = _r_d0 * _t2; +//CHECK-NEXT: float _r2 = _r_d0 * x; //CHECK-NEXT: * _d_x += _r2; //CHECK-NEXT: float _r3 = x * _r_d0; //CHECK-NEXT: * _d_x += _r3; @@ -194,14 +190,12 @@ float func6(float x) { return x; } float func7(float x, float y) { return (x * y); } //CHECK: void func7_grad(float x, float y, clad::array_ref _d_x, clad::array_ref _d_y, double &_final_error) { -//CHECK-NEXT: float _t0; //CHECK-NEXT: double _ret_value0 = 0; -//CHECK-NEXT: _t0 = y; -//CHECK-NEXT: _ret_value0 = (x * _t0); +//CHECK-NEXT: _ret_value0 = (x * y); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: float _r0 = 1 * _t0; +//CHECK-NEXT: float _r0 = 1 * y; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: float _r1 = x * 1; //CHECK-NEXT: * _d_y += _r1; diff --git a/test/ErrorEstimation/BasicOps.C b/test/ErrorEstimation/BasicOps.C index b365891f5..fbcd74492 100644 --- a/test/ErrorEstimation/BasicOps.C +++ b/test/ErrorEstimation/BasicOps.C @@ -23,7 +23,6 @@ float func(float x, float y) { //CHECK-NEXT: float _EERepl_y0 = y; //CHECK-NEXT: float _EERepl_y1; //CHECK-NEXT: float _EERepl_y2; -//CHECK-NEXT: float _t2; //CHECK-NEXT: float _d_z = 0; //CHECK-NEXT: double _delta_z = 0; //CHECK-NEXT: float _EERepl_z0; @@ -34,14 +33,13 @@ float func(float x, float y) { //CHECK-NEXT: _EERepl_y1 = y; //CHECK-NEXT: y = y + y++ + y; //CHECK-NEXT: _EERepl_y2 = y; -//CHECK-NEXT: _t2 = x; -//CHECK-NEXT: float z = y * _t2; +//CHECK-NEXT: float z = y * x; //CHECK-NEXT: _EERepl_z0 = z; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_z += 1; //CHECK-NEXT: { -//CHECK-NEXT: float _r0 = _d_z * _t2; +//CHECK-NEXT: float _r0 = _d_z * x; //CHECK-NEXT: * _d_y += _r0; //CHECK-NEXT: float _r1 = y * _d_z; //CHECK-NEXT: * _d_x += _r1; @@ -85,26 +83,24 @@ float func2(float x, float y) { //CHECK-NEXT: float _t0; //CHECK-NEXT: double _delta_x = 0; //CHECK-NEXT: float _EERepl_x0 = x; -//CHECK-NEXT: float _t1; //CHECK-NEXT: float _EERepl_x1; -//CHECK-NEXT: float _t2; +//CHECK-NEXT: float _t1; //CHECK-NEXT: float _d_z = 0; //CHECK-NEXT: double _delta_z = 0; //CHECK-NEXT: float _EERepl_z0; //CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: x = x - y - y * _t1; +//CHECK-NEXT: x = x - y - y * y; //CHECK-NEXT: _EERepl_x1 = x; -//CHECK-NEXT: _t2 = x; -//CHECK-NEXT: float z = y / _t2; +//CHECK-NEXT: _t1 = x; +//CHECK-NEXT: float z = y / _t1; //CHECK-NEXT: _EERepl_z0 = z; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_z += 1; //CHECK-NEXT: { -//CHECK-NEXT: float _r2 = _d_z / _t2; +//CHECK-NEXT: float _r2 = _d_z / _t1; //CHECK-NEXT: * _d_y += _r2; -//CHECK-NEXT: float _r3 = _d_z * -y / (_t2 * _t2); +//CHECK-NEXT: float _r3 = _d_z * -y / (_t1 * _t1); //CHECK-NEXT: * _d_x += _r3; //CHECK-NEXT: _delta_z += std::abs(_d_z * _EERepl_z0 * {{.+}}); //CHECK-NEXT: } @@ -113,7 +109,7 @@ float func2(float x, float y) { //CHECK-NEXT: float _r_d0 = * _d_x; //CHECK-NEXT: * _d_x += _r_d0; //CHECK-NEXT: * _d_y += -_r_d0; -//CHECK-NEXT: float _r0 = -_r_d0 * _t1; +//CHECK-NEXT: float _r0 = -_r_d0 * y; //CHECK-NEXT: * _d_y += _r0; //CHECK-NEXT: float _r1 = y * -_r_d0; //CHECK-NEXT: * _d_y += _r1; @@ -140,14 +136,12 @@ float func3(float x, float y) { //CHECK-NEXT: float _t0; //CHECK-NEXT: double _delta_x = 0; //CHECK-NEXT: float _EERepl_x0 = x; -//CHECK-NEXT: float _t1; //CHECK-NEXT: float _EERepl_x1; //CHECK-NEXT: float _d_z = 0; //CHECK-NEXT: double _delta_z = 0; //CHECK-NEXT: float _EERepl_z0; +//CHECK-NEXT: float _t1; //CHECK-NEXT: float _t2; -//CHECK-NEXT: float _t3; -//CHECK-NEXT: float _t4; //CHECK-NEXT: double _delta_y = 0; //CHECK-NEXT: float _EERepl_y0 = y; //CHECK-NEXT: float _EERepl_y1; @@ -155,29 +149,27 @@ float func3(float x, float y) { //CHECK-NEXT: double _delta_t = 0; //CHECK-NEXT: float _EERepl_t0; //CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: x = x - y - y * _t1; +//CHECK-NEXT: x = x - y - y * y; //CHECK-NEXT: _EERepl_x1 = x; //CHECK-NEXT: float z = y; //CHECK-NEXT: _EERepl_z0 = z; -//CHECK-NEXT: _t3 = z; -//CHECK-NEXT: _t4 = y; -//CHECK-NEXT: _t2 = (y = x + x); -//CHECK-NEXT: float t = x * _t3 * _t2; +//CHECK-NEXT: _t2 = y; +//CHECK-NEXT: _t1 = (y = x + x); +//CHECK-NEXT: float t = x * z * _t1; //CHECK-NEXT: _EERepl_t0 = t; //CHECK-NEXT: _EERepl_y1 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: { -//CHECK-NEXT: float _r2 = _d_t * _t2; -//CHECK-NEXT: float _r3 = _r2 * _t3; +//CHECK-NEXT: float _r2 = _d_t * _t1; +//CHECK-NEXT: float _r3 = _r2 * z; //CHECK-NEXT: * _d_x += _r3; //CHECK-NEXT: float _r4 = x * _r2; //CHECK-NEXT: _d_z += _r4; -//CHECK-NEXT: float _r5 = x * _t3 * _d_t; +//CHECK-NEXT: float _r5 = x * z * _d_t; //CHECK-NEXT: * _d_y += _r5; -//CHECK-NEXT: y = _t4; +//CHECK-NEXT: y = _t2; //CHECK-NEXT: float _r_d1 = * _d_y; //CHECK-NEXT: * _d_x += _r_d1; //CHECK-NEXT: * _d_x += _r_d1; @@ -191,7 +183,7 @@ float func3(float x, float y) { //CHECK-NEXT: float _r_d0 = * _d_x; //CHECK-NEXT: * _d_x += _r_d0; //CHECK-NEXT: * _d_y += -_r_d0; -//CHECK-NEXT: float _r0 = -_r_d0 * _t1; +//CHECK-NEXT: float _r0 = -_r_d0 * y; //CHECK-NEXT: * _d_y += _r0; //CHECK-NEXT: float _r1 = y * -_r_d0; //CHECK-NEXT: * _d_y += _r1; @@ -239,17 +231,15 @@ float func5(float x, float y) { //CHECK-NEXT: double _delta_y = 0; //CHECK-NEXT: float _EERepl_y0 = y; //CHECK-NEXT: float _EERepl_y1; -//CHECK-NEXT: float _t1; //CHECK-NEXT: double _ret_value0 = 0; //CHECK-NEXT: _t0 = y; //CHECK-NEXT: y = std::sin(x); //CHECK-NEXT: _EERepl_y1 = y; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _ret_value0 = y * _t1; +//CHECK-NEXT: _ret_value0 = y * y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: float _r1 = 1 * _t1; +//CHECK-NEXT: float _r1 = 1 * y; //CHECK-NEXT: * _d_y += _r1; //CHECK-NEXT: float _r2 = y * 1; //CHECK-NEXT: * _d_y += _r2; @@ -259,7 +249,7 @@ float func5(float x, float y) { //CHECK-NEXT: float _r_d0 = * _d_y; //CHECK-NEXT: float _r0 = _r_d0 * clad::custom_derivatives{{(::std)?}}::sin_pushforward(x, 1.F).pushforward; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: _delta_y += std::abs(_r_d0 * _EERepl_y1 * 1.1920928955078125E-7); +//CHECK-NEXT: _delta_y += std::abs(_r_d0 * _EERepl_y1 * {{.+}}); //CHECK-NEXT: * _d_y -= _r_d0; //CHECK-NEXT: * _d_y; //CHECK-NEXT: } @@ -273,14 +263,12 @@ float func5(float x, float y) { double helper(double x, double y) { return x * y; } //CHECK: void helper_pullback(double x, double y, double _d_y0, clad::array_ref _d_x, clad::array_ref _d_y, double &_final_error) { -//CHECK-NEXT: double _t0; //CHECK-NEXT: double _ret_value0 = 0; -//CHECK-NEXT: _t0 = y; -//CHECK-NEXT: _ret_value0 = x * _t0; +//CHECK-NEXT: _ret_value0 = x * y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_y0 * _t0; +//CHECK-NEXT: double _r0 = _d_y0 * y; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = x * _d_y0; //CHECK-NEXT: * _d_y += _r1; @@ -301,16 +289,14 @@ float func6(float x, float y) { //CHECK-NEXT: float _d_z = 0; //CHECK-NEXT: double _delta_z = 0; //CHECK-NEXT: float _EERepl_z0; -//CHECK-NEXT: float _t1; //CHECK-NEXT: double _ret_value0 = 0; //CHECK-NEXT: float z = helper(x, y); //CHECK-NEXT: _EERepl_z0 = z; -//CHECK-NEXT: _t1 = z; -//CHECK-NEXT: _ret_value0 = z * _t1; +//CHECK-NEXT: _ret_value0 = z * z; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: float _r2 = 1 * _t1; +//CHECK-NEXT: float _r2 = 1 * z; //CHECK-NEXT: _d_z += _r2; //CHECK-NEXT: float _r3 = z * 1; //CHECK-NEXT: _d_z += _r3; @@ -357,14 +343,12 @@ float func7(float x) { double helper2(float& x) { return x * x; } //CHECK: void helper2_pullback(float &x, double _d_y, clad::array_ref _d_x, double &_final_error) { -//CHECK-NEXT: float _t0; //CHECK-NEXT: double _ret_value0 = 0; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _ret_value0 = x * _t0; +//CHECK-NEXT: _ret_value0 = x * x; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_y * _t0; +//CHECK-NEXT: double _r0 = _d_y * x; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = x * _d_y; //CHECK-NEXT: * _d_x += _r1; diff --git a/test/ErrorEstimation/ConditonalStatements.C b/test/ErrorEstimation/ConditonalStatements.C index e19890efe..54d5f68ad 100644 --- a/test/ErrorEstimation/ConditonalStatements.C +++ b/test/ErrorEstimation/ConditonalStatements.C @@ -22,30 +22,26 @@ float func(float x, float y) { //CHECK-NEXT: float _t0; //CHECK-NEXT: double _delta_y = 0; //CHECK-NEXT: float _EERepl_y0 = y; -//CHECK-NEXT: float _t1; //CHECK-NEXT: float _EERepl_y1; //CHECK-NEXT: float _d_temp = 0; //CHECK-NEXT: double _delta_temp = 0; //CHECK-NEXT: float _EERepl_temp0; -//CHECK-NEXT: float _t2; -//CHECK-NEXT: float _t3; +//CHECK-NEXT: float _t1; //CHECK-NEXT: float _EERepl_temp1; -//CHECK-NEXT: float _t4; +//CHECK-NEXT: float _t2; //CHECK-NEXT: double _ret_value0 = 0; //CHECK-NEXT: _cond0 = x > y; //CHECK-NEXT: if (_cond0) { //CHECK-NEXT: _t0 = y; -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: y = y * _t1; +//CHECK-NEXT: y = y * x; //CHECK-NEXT: _EERepl_y1 = y; //CHECK-NEXT: } else { //CHECK-NEXT: float temp = y; //CHECK-NEXT: _EERepl_temp0 = temp; -//CHECK-NEXT: _t2 = temp; -//CHECK-NEXT: _t3 = y; -//CHECK-NEXT: temp = y * _t3; +//CHECK-NEXT: _t1 = temp; +//CHECK-NEXT: temp = y * y; //CHECK-NEXT: _EERepl_temp1 = temp; -//CHECK-NEXT: _t4 = x; +//CHECK-NEXT: _t2 = x; //CHECK-NEXT: x = y; //CHECK-NEXT: } //CHECK-NEXT: _ret_value0 = x + y; @@ -59,7 +55,7 @@ float func(float x, float y) { //CHECK-NEXT: { //CHECK-NEXT: y = _t0; //CHECK-NEXT: float _r_d0 = * _d_y; -//CHECK-NEXT: float _r0 = _r_d0 * _t1; +//CHECK-NEXT: float _r0 = _r_d0 * x; //CHECK-NEXT: * _d_y += _r0; //CHECK-NEXT: float _r1 = y * _r_d0; //CHECK-NEXT: * _d_x += _r1; @@ -69,16 +65,16 @@ float func(float x, float y) { //CHECK-NEXT: } //CHECK-NEXT: } else { //CHECK-NEXT: { -//CHECK-NEXT: x = _t4; +//CHECK-NEXT: x = _t2; //CHECK-NEXT: float _r_d2 = * _d_x; //CHECK-NEXT: * _d_y += _r_d2; //CHECK-NEXT: * _d_x -= _r_d2; //CHECK-NEXT: * _d_x; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: temp = _t2; +//CHECK-NEXT: temp = _t1; //CHECK-NEXT: float _r_d1 = _d_temp; -//CHECK-NEXT: float _r2 = _r_d1 * _t3; +//CHECK-NEXT: float _r2 = _r_d1 * y; //CHECK-NEXT: * _d_y += _r2; //CHECK-NEXT: float _r3 = y * _r_d1; //CHECK-NEXT: * _d_y += _r3; @@ -103,23 +99,19 @@ float func2(float x) { } //CHECK: void func2_grad(float x, clad::array_ref _d_x, double &_final_error) { -//CHECK-NEXT: float _t0; //CHECK-NEXT: float _d_z = 0; //CHECK-NEXT: double _delta_z = 0; //CHECK-NEXT: float _EERepl_z0; //CHECK-NEXT: bool _cond0; //CHECK-NEXT: double _ret_value0 = 0; -//CHECK-NEXT: float _t1; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: float z = x * _t0; +//CHECK-NEXT: float z = x * x; //CHECK-NEXT: _EERepl_z0 = z; //CHECK-NEXT: _cond0 = z > 9; //CHECK-NEXT: if (_cond0) { //CHECK-NEXT: _ret_value0 = x + x; //CHECK-NEXT: goto _label0; //CHECK-NEXT: } else { -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _ret_value0 = x * _t1; +//CHECK-NEXT: _ret_value0 = x * x; //CHECK-NEXT: goto _label1; //CHECK-NEXT: } //CHECK-NEXT: if (_cond0) @@ -131,13 +123,13 @@ float func2(float x) { //CHECK-NEXT: else //CHECK-NEXT: _label1: //CHECK-NEXT: { -//CHECK-NEXT: float _r2 = 1 * _t1; +//CHECK-NEXT: float _r2 = 1 * x; //CHECK-NEXT: * _d_x += _r2; //CHECK-NEXT: float _r3 = x * 1; //CHECK-NEXT: * _d_x += _r3; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: float _r0 = _d_z * _t0; +//CHECK-NEXT: float _r0 = _d_z * x; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: float _r1 = x * _d_z; //CHECK-NEXT: * _d_x += _r1; @@ -152,16 +144,13 @@ float func3(float x, float y) { return x > 30 ? x * y : x + y; } //CHECK: void func3_grad(float x, float y, clad::array_ref _d_x, clad::array_ref _d_y, double &_final_error) { //CHECK-NEXT: bool _cond0; -//CHECK-NEXT: float _t0; //CHECK-NEXT: double _ret_value0 = 0; //CHECK-NEXT: _cond0 = x > 30; -//CHECK-NEXT: if (_cond0) -//CHECK-NEXT: _t0 = y; -//CHECK-NEXT: _ret_value0 = _cond0 ? x * _t0 : x + y; +//CHECK-NEXT: _ret_value0 = _cond0 ? x * y : x + y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: if (_cond0) { -//CHECK-NEXT: float _r0 = 1 * _t0; +//CHECK-NEXT: float _r0 = 1 * y; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: float _r1 = x * 1; //CHECK-NEXT: * _d_y += _r1; diff --git a/test/ErrorEstimation/LoopsAndArrays.C b/test/ErrorEstimation/LoopsAndArrays.C index fa80f82a3..aef6736a5 100644 --- a/test/ErrorEstimation/LoopsAndArrays.C +++ b/test/ErrorEstimation/LoopsAndArrays.C @@ -74,21 +74,20 @@ float func2(float x) { //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; //CHECK-NEXT: clad::tape _t1 = {}; -//CHECK-NEXT: clad::tape _t2 = {}; //CHECK-NEXT: float _d_m = 0; //CHECK-NEXT: double _delta_m = 0; //CHECK-NEXT: clad::tape _EERepl_m0 = {}; //CHECK-NEXT: float m = 0; -//CHECK-NEXT: clad::tape _t3 = {}; +//CHECK-NEXT: clad::tape _t2 = {}; //CHECK-NEXT: clad::tape _EERepl_z1 = {}; //CHECK-NEXT: float z; //CHECK-NEXT: _EERepl_z0 = z; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < 9; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: clad::push(_t2, m) , m = x * clad::push(_t1, x); +//CHECK-NEXT: clad::push(_t1, m) , m = x * x; //CHECK-NEXT: clad::push(_EERepl_m0, m); -//CHECK-NEXT: clad::push(_t3, z); +//CHECK-NEXT: clad::push(_t2, z); //CHECK-NEXT: z = m + m; //CHECK-NEXT: clad::push(_EERepl_z1, z); //CHECK-NEXT: } @@ -98,7 +97,7 @@ float func2(float x) { //CHECK-NEXT: for (; _t0; _t0--) { //CHECK-NEXT: i--; //CHECK-NEXT: { -//CHECK-NEXT: z = clad::pop(_t3); +//CHECK-NEXT: z = clad::pop(_t2); //CHECK-NEXT: float _r_d0 = _d_z; //CHECK-NEXT: _d_m += _r_d0; //CHECK-NEXT: _d_m += _r_d0; @@ -107,12 +106,12 @@ float func2(float x) { //CHECK-NEXT: _d_z -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: float _r0 = _d_m * clad::pop(_t1); +//CHECK-NEXT: float _r0 = _d_m * x; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: float _r1 = x * _d_m; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: _d_m = 0; -//CHECK-NEXT: m = clad::pop(_t2); +//CHECK-NEXT: m = clad::pop(_t1); //CHECK-NEXT: float _r2 = clad::pop(_EERepl_m0); //CHECK-NEXT: _delta_m += std::abs(_d_m * _r2 * {{.+}}); //CHECK-NEXT: } @@ -136,26 +135,24 @@ float func3(float x, float y) { //CHECK-NEXT: double _t0; //CHECK-NEXT: double _EERepl_arr0; //CHECK-NEXT: double _t1; -//CHECK-NEXT: float _t2; //CHECK-NEXT: double _EERepl_arr1; -//CHECK-NEXT: double _t3; +//CHECK-NEXT: double _t2; //CHECK-NEXT: double _EERepl_arr2; //CHECK-NEXT: double arr[3]; //CHECK-NEXT: _t0 = arr[0]; //CHECK-NEXT: arr[0] = x + y; //CHECK-NEXT: _EERepl_arr0 = arr[0]; //CHECK-NEXT: _t1 = arr[1]; -//CHECK-NEXT: _t2 = x; -//CHECK-NEXT: arr[1] = x * _t2; +//CHECK-NEXT: arr[1] = x * x; //CHECK-NEXT: _EERepl_arr1 = arr[1]; -//CHECK-NEXT: _t3 = arr[2]; +//CHECK-NEXT: _t2 = arr[2]; //CHECK-NEXT: arr[2] = arr[0] + arr[1]; //CHECK-NEXT: _EERepl_arr2 = arr[2]; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_arr[2] += 1; //CHECK-NEXT: { -//CHECK-NEXT: arr[2] = _t3; +//CHECK-NEXT: arr[2] = _t2; //CHECK-NEXT: double _r_d2 = _d_arr[2]; //CHECK-NEXT: _d_arr[0] += _r_d2; //CHECK-NEXT: _d_arr[1] += _r_d2; @@ -167,7 +164,7 @@ float func3(float x, float y) { //CHECK-NEXT: { //CHECK-NEXT: arr[1] = _t1; //CHECK-NEXT: double _r_d1 = _d_arr[1]; -//CHECK-NEXT: double _r0 = _r_d1 * _t2; +//CHECK-NEXT: double _r0 = _r_d1 * x; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = x * _r_d1; //CHECK-NEXT: * _d_x += _r1; @@ -287,32 +284,20 @@ double func5(double* x, double* y, double* output) { //CHECK-NEXT: for (int i = 0; i < _d_output.size(); i++) { //CHECK-NEXT: _EERepl_output0[i] = output[i]; //CHECK-NEXT: } -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; //CHECK-NEXT: double _EERepl_output1; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: double _t4; -//CHECK-NEXT: double _t5; +//CHECK-NEXT: double _t1; //CHECK-NEXT: double _EERepl_output2; -//CHECK-NEXT: double _t6; -//CHECK-NEXT: double _t7; -//CHECK-NEXT: double _t8; +//CHECK-NEXT: double _t2; //CHECK-NEXT: double _EERepl_output3; //CHECK-NEXT: double _ret_value0 = 0; //CHECK-NEXT: _t0 = output[0]; -//CHECK-NEXT: _t1 = y[2]; -//CHECK-NEXT: _t2 = y[1]; -//CHECK-NEXT: output[0] = x[1] * _t1 - x[2] * _t2; +//CHECK-NEXT: output[0] = x[1] * y[2] - x[2] * y[1]; //CHECK-NEXT: _EERepl_output1 = output[0]; -//CHECK-NEXT: _t3 = output[1]; -//CHECK-NEXT: _t4 = y[0]; -//CHECK-NEXT: _t5 = y[2]; -//CHECK-NEXT: output[1] = x[2] * _t4 - x[0] * _t5; +//CHECK-NEXT: _t1 = output[1]; +//CHECK-NEXT: output[1] = x[2] * y[0] - x[0] * y[2]; //CHECK-NEXT: _EERepl_output2 = output[1]; -//CHECK-NEXT: _t6 = output[2]; -//CHECK-NEXT: _t7 = y[1]; -//CHECK-NEXT: _t8 = x[1]; -//CHECK-NEXT: output[2] = x[0] * _t7 - y[0] * _t8; +//CHECK-NEXT: _t2 = output[2]; +//CHECK-NEXT: output[2] = x[0] * y[1] - y[0] * x[1]; //CHECK-NEXT: _EERepl_output3 = output[2]; //CHECK-NEXT: _ret_value0 = output[0] + output[1] + output[2]; //CHECK-NEXT: goto _label0; @@ -323,13 +308,13 @@ double func5(double* x, double* y, double* output) { //CHECK-NEXT: _d_output[2] += 1; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: output[2] = _t6; +//CHECK-NEXT: output[2] = _t2; //CHECK-NEXT: double _r_d2 = _d_output[2]; -//CHECK-NEXT: double _r8 = _r_d2 * _t7; +//CHECK-NEXT: double _r8 = _r_d2 * y[1]; //CHECK-NEXT: _d_x[0] += _r8; //CHECK-NEXT: double _r9 = x[0] * _r_d2; //CHECK-NEXT: _d_y[1] += _r9; -//CHECK-NEXT: double _r10 = -_r_d2 * _t8; +//CHECK-NEXT: double _r10 = -_r_d2 * x[1]; //CHECK-NEXT: _d_y[0] += _r10; //CHECK-NEXT: double _r11 = y[0] * -_r_d2; //CHECK-NEXT: _d_x[1] += _r11; @@ -339,13 +324,13 @@ double func5(double* x, double* y, double* output) { //CHECK-NEXT: _d_output[2]; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: output[1] = _t3; +//CHECK-NEXT: output[1] = _t1; //CHECK-NEXT: double _r_d1 = _d_output[1]; -//CHECK-NEXT: double _r4 = _r_d1 * _t4; +//CHECK-NEXT: double _r4 = _r_d1 * y[0]; //CHECK-NEXT: _d_x[2] += _r4; //CHECK-NEXT: double _r5 = x[2] * _r_d1; //CHECK-NEXT: _d_y[0] += _r5; -//CHECK-NEXT: double _r6 = -_r_d1 * _t5; +//CHECK-NEXT: double _r6 = -_r_d1 * y[2]; //CHECK-NEXT: _d_x[0] += _r6; //CHECK-NEXT: double _r7 = x[0] * -_r_d1; //CHECK-NEXT: _d_y[2] += _r7; @@ -357,11 +342,11 @@ double func5(double* x, double* y, double* output) { //CHECK-NEXT: { //CHECK-NEXT: output[0] = _t0; //CHECK-NEXT: double _r_d0 = _d_output[0]; -//CHECK-NEXT: double _r0 = _r_d0 * _t1; +//CHECK-NEXT: double _r0 = _r_d0 * y[2]; //CHECK-NEXT: _d_x[1] += _r0; //CHECK-NEXT: double _r1 = x[1] * _r_d0; //CHECK-NEXT: _d_y[2] += _r1; -//CHECK-NEXT: double _r2 = -_r_d0 * _t2; +//CHECK-NEXT: double _r2 = -_r_d0 * y[1]; //CHECK-NEXT: _d_x[2] += _r2; //CHECK-NEXT: double _r3 = x[2] * -_r_d0; //CHECK-NEXT: _d_y[1] += _r3; @@ -373,22 +358,22 @@ double func5(double* x, double* y, double* output) { //CHECK-NEXT: clad::array _delta_x(_d_x.size()); //CHECK-NEXT: int i = 0; //CHECK-NEXT: for (; i < _d_x.size(); i++) { -//CHECK-NEXT: double _t9 = std::abs(_d_x[i] * x[i] * {{.+}}); -//CHECK-NEXT: _delta_x[i] += _t9; -//CHECK-NEXT: _final_error += _t9; +//CHECK-NEXT: double _t3 = std::abs(_d_x[i] * x[i] * {{.+}}); +//CHECK-NEXT: _delta_x[i] += _t3; +//CHECK-NEXT: _final_error += _t3; //CHECK-NEXT: } //CHECK-NEXT: clad::array _delta_y(_d_y.size()); //CHECK-NEXT: i = 0; //CHECK-NEXT: for (; i < _d_y.size(); i++) { -//CHECK-NEXT: double _t10 = std::abs(_d_y[i] * y[i] * {{.+}}); -//CHECK-NEXT: _delta_y[i] += _t10; -//CHECK-NEXT: _final_error += _t10; +//CHECK-NEXT: double _t4 = std::abs(_d_y[i] * y[i] * {{.+}}); +//CHECK-NEXT: _delta_y[i] += _t4; +//CHECK-NEXT: _final_error += _t4; //CHECK-NEXT: } //CHECK-NEXT: i = 0; //CHECK-NEXT: for (; i < _d_output.size(); i++) { -//CHECK-NEXT: double _t11 = std::abs(_d_output[i] * _EERepl_output0[i] * {{.+}}); -//CHECK-NEXT: _delta_output[i] += _t11; -//CHECK-NEXT: _final_error += _t11; +//CHECK-NEXT: double _t5 = std::abs(_d_output[i] * _EERepl_output0[i] * {{.+}}); +//CHECK-NEXT: _delta_output[i] += _t5; +//CHECK-NEXT: _final_error += _t5; //CHECK-NEXT: } //CHECK-NEXT: _final_error += std::abs(1. * _ret_value0 * {{.+}}); //CHECK-NEXT: } diff --git a/test/ErrorEstimation/LoopsAndArraysExec.C b/test/ErrorEstimation/LoopsAndArraysExec.C index f9f243371..addbcc48a 100644 --- a/test/ErrorEstimation/LoopsAndArraysExec.C +++ b/test/ErrorEstimation/LoopsAndArraysExec.C @@ -79,7 +79,6 @@ double mulSum(float* a, float* b, int n) { //CHECK-NEXT: int _d_j = 0; //CHECK-NEXT: int j = 0; //CHECK-NEXT: clad::tape _t3 = {}; -//CHECK-NEXT: clad::tape _t4 = {}; //CHECK-NEXT: clad::tape _EERepl_sum1 = {}; //CHECK-NEXT: double sum = 0; //CHECK-NEXT: _EERepl_sum0 = sum; @@ -90,7 +89,7 @@ double mulSum(float* a, float* b, int n) { //CHECK-NEXT: for (clad::push(_t2, j) , j = 0; j < n; j++) { //CHECK-NEXT: clad::back(_t1)++; //CHECK-NEXT: clad::push(_t3, sum); -//CHECK-NEXT: sum += a[i] * clad::push(_t4, b[j]); +//CHECK-NEXT: sum += a[i] * b[j]; //CHECK-NEXT: clad::push(_EERepl_sum1, sum); //CHECK-NEXT: } //CHECK-NEXT: } @@ -105,7 +104,7 @@ double mulSum(float* a, float* b, int n) { //CHECK-NEXT: sum = clad::pop(_t3); //CHECK-NEXT: double _r_d0 = _d_sum; //CHECK-NEXT: _d_sum += _r_d0; -//CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t4); +//CHECK-NEXT: double _r0 = _r_d0 * b[j]; //CHECK-NEXT: _d_a[i] += _r0; //CHECK-NEXT: double _r1 = a[i] * _r_d0; //CHECK-NEXT: _d_b[j] += _r1; @@ -124,16 +123,16 @@ double mulSum(float* a, float* b, int n) { //CHECK-NEXT: clad::array _delta_a(_d_a.size()); //CHECK-NEXT: int i = 0; //CHECK-NEXT: for (; i < _d_a.size(); i++) { -//CHECK-NEXT: double _t5 = std::abs(_d_a[i] * a[i] * {{.+}}); -//CHECK-NEXT: _delta_a[i] += _t5; -//CHECK-NEXT: _final_error += _t5; +//CHECK-NEXT: double _t4 = std::abs(_d_a[i] * a[i] * {{.+}}); +//CHECK-NEXT: _delta_a[i] += _t4; +//CHECK-NEXT: _final_error += _t4; //CHECK-NEXT: } //CHECK-NEXT: clad::array _delta_b(_d_b.size()); //CHECK-NEXT: i = 0; //CHECK-NEXT: for (; i < _d_b.size(); i++) { -//CHECK-NEXT: double _t6 = std::abs(_d_b[i] * b[i] * {{.+}}); -//CHECK-NEXT: _delta_b[i] += _t6; -//CHECK-NEXT: _final_error += _t6; +//CHECK-NEXT: double _t5 = std::abs(_d_b[i] * b[i] * {{.+}}); +//CHECK-NEXT: _delta_b[i] += _t5; +//CHECK-NEXT: _final_error += _t5; //CHECK-NEXT: } //CHECK-NEXT: _final_error += _delta_sum; //CHECK-NEXT: } diff --git a/test/FirstDerivative/FunctionCalls.C b/test/FirstDerivative/FunctionCalls.C index 639eb69bf..be8006bd7 100644 --- a/test/FirstDerivative/FunctionCalls.C +++ b/test/FirstDerivative/FunctionCalls.C @@ -136,7 +136,7 @@ double test_7(double i, double j) { // CHECK-NEXT: double res = 0; // CHECK-NEXT: { // CHECK-NEXT: int _d_i0 = 0; -// CHECK-NEXT: for (int i0 = 0; i < 5; increment_pushforward(i0, _d_i0)) { +// CHECK-NEXT: for (int i0 = 0; i0 < 5; increment_pushforward(i0, _d_i0)) { // CHECK-NEXT: _d_res += _d_i0 * j + i0 * _d_j; // CHECK-NEXT: res += i0 * j; // CHECK-NEXT: } diff --git a/test/Gradient/Assignments.C b/test/Gradient/Assignments.C index f40416939..d524f6ca8 100644 --- a/test/Gradient/Assignments.C +++ b/test/Gradient/Assignments.C @@ -70,32 +70,28 @@ double f3(double x, double y) { //CHECK-NEXT: double _t1; //CHECK-NEXT: double _t2; //CHECK-NEXT: double _t3; -//CHECK-NEXT: double _t4; -//CHECK-NEXT: double _t5; //CHECK-NEXT: _t0 = x; //CHECK-NEXT: x = x; //CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t2 = x; -//CHECK-NEXT: x = x * _t2; -//CHECK-NEXT: _t3 = y; -//CHECK-NEXT: _t4 = x; -//CHECK-NEXT: y = x * _t4; -//CHECK-NEXT: _t5 = x; +//CHECK-NEXT: x = x * x; +//CHECK-NEXT: _t2 = y; +//CHECK-NEXT: y = x * x; +//CHECK-NEXT: _t3 = x; //CHECK-NEXT: x = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: * _d_y += 1; //CHECK-NEXT: { -//CHECK-NEXT: x = _t5; +//CHECK-NEXT: x = _t3; //CHECK-NEXT: double _r_d3 = * _d_x; //CHECK-NEXT: * _d_y += _r_d3; //CHECK-NEXT: * _d_x -= _r_d3; //CHECK-NEXT: * _d_x; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: y = _t3; +//CHECK-NEXT: y = _t2; //CHECK-NEXT: double _r_d2 = * _d_y; -//CHECK-NEXT: double _r2 = _r_d2 * _t4; +//CHECK-NEXT: double _r2 = _r_d2 * x; //CHECK-NEXT: * _d_x += _r2; //CHECK-NEXT: double _r3 = x * _r_d2; //CHECK-NEXT: * _d_x += _r3; @@ -105,7 +101,7 @@ double f3(double x, double y) { //CHECK-NEXT: { //CHECK-NEXT: x = _t1; //CHECK-NEXT: double _r_d1 = * _d_x; -//CHECK-NEXT: double _r0 = _r_d1 * _t2; +//CHECK-NEXT: double _r0 = _r_d1 * x; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = x * _r_d1; //CHECK-NEXT: * _d_x += _r1; @@ -168,25 +164,23 @@ double f5(double x, double y) { } //CHECK: void f5_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; -//CHECK-NEXT: double _t1; +//CHECK-NEXT: double _t0; //CHECK-NEXT: bool _cond1; //CHECK-NEXT: double _d_z = 0; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: double t = x * _t0; +//CHECK-NEXT: double _t1; +//CHECK-NEXT: double t = x * x; //CHECK-NEXT: _cond0 = x < 0; //CHECK-NEXT: if (_cond0) { -//CHECK-NEXT: _t1 = t; +//CHECK-NEXT: _t0 = t; //CHECK-NEXT: t = -t; //CHECK-NEXT: goto _label0; //CHECK-NEXT: } //CHECK-NEXT: _cond1 = y < 0; //CHECK-NEXT: if (_cond1) { //CHECK-NEXT: double z = t; -//CHECK-NEXT: _t2 = t; +//CHECK-NEXT: _t1 = t; //CHECK-NEXT: t = -t; //CHECK-NEXT: } //CHECK-NEXT: goto _label1; @@ -194,7 +188,7 @@ double f5(double x, double y) { //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: if (_cond1) { //CHECK-NEXT: { -//CHECK-NEXT: t = _t2; +//CHECK-NEXT: t = _t1; //CHECK-NEXT: double _r_d1 = _d_t; //CHECK-NEXT: _d_t += -_r_d1; //CHECK-NEXT: _d_t -= _r_d1; @@ -205,14 +199,14 @@ double f5(double x, double y) { //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: { -//CHECK-NEXT: t = _t1; +//CHECK-NEXT: t = _t0; //CHECK-NEXT: double _r_d0 = _d_t; //CHECK-NEXT: _d_t += -_r_d0; //CHECK-NEXT: _d_t -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_t * _t0; +//CHECK-NEXT: double _r0 = _d_t * x; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = x * _d_t; //CHECK-NEXT: * _d_x += _r1; @@ -234,25 +228,23 @@ double f6(double x, double 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; -//CHECK-NEXT: double _t1; +//CHECK-NEXT: double _t0; //CHECK-NEXT: bool _cond1; //CHECK-NEXT: double _d_z = 0; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: double t = x * _t0; +//CHECK-NEXT: double _t1; +//CHECK-NEXT: double t = x * x; //CHECK-NEXT: _cond0 = x < 0; //CHECK-NEXT: if (_cond0) { -//CHECK-NEXT: _t1 = t; +//CHECK-NEXT: _t0 = t; //CHECK-NEXT: t = -t; //CHECK-NEXT: goto _label0; //CHECK-NEXT: } //CHECK-NEXT: _cond1 = y < 0; //CHECK-NEXT: if (_cond1) { //CHECK-NEXT: double z = t; -//CHECK-NEXT: _t2 = t; +//CHECK-NEXT: _t1 = t; //CHECK-NEXT: t = -t; //CHECK-NEXT: } //CHECK-NEXT: goto _label1; @@ -260,7 +252,7 @@ double f6(double x, double y) { //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: if (_cond1) { //CHECK-NEXT: { -//CHECK-NEXT: t = _t2; +//CHECK-NEXT: t = _t1; //CHECK-NEXT: double _r_d1 = _d_t; //CHECK-NEXT: _d_t += -_r_d1; //CHECK-NEXT: _d_t -= _r_d1; @@ -271,14 +263,14 @@ double f6(double x, double y) { //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: { -//CHECK-NEXT: t = _t1; +//CHECK-NEXT: t = _t0; //CHECK-NEXT: double _r_d0 = _d_t; //CHECK-NEXT: _d_t += -_r_d0; //CHECK-NEXT: _d_t -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_t * _t0; +//CHECK-NEXT: double _r0 = _d_t * x; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = x * _d_t; //CHECK-NEXT: * _d_x += _r1; @@ -302,8 +294,8 @@ double f7(double x, double 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 _t0; //CHECK-NEXT: double _t1; //CHECK-NEXT: double _t2; //CHECK-NEXT: double _t3; @@ -311,33 +303,31 @@ double f7(double x, double y) { //CHECK-NEXT: double _t5; //CHECK-NEXT: double _t6; //CHECK-NEXT: double _t7; -//CHECK-NEXT: double _t8; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: double t[3] = {1, x, x * _t0}; +//CHECK-NEXT: double t[3] = {1, x, x * x}; //CHECK-NEXT: t[0]++; //CHECK-NEXT: t[0]--; //CHECK-NEXT: ++t[0]; //CHECK-NEXT: --t[0]; -//CHECK-NEXT: _t1 = t[0]; +//CHECK-NEXT: _t0 = t[0]; //CHECK-NEXT: t[0] = x; -//CHECK-NEXT: _t2 = x; +//CHECK-NEXT: _t1 = x; //CHECK-NEXT: x = y; -//CHECK-NEXT: _t3 = t[0]; +//CHECK-NEXT: _t2 = t[0]; //CHECK-NEXT: t[0] += t[1]; -//CHECK-NEXT: _t4 = t[0]; +//CHECK-NEXT: _t3 = 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: _t4 = t[0]; +//CHECK-NEXT: _t5 = t[1]; +//CHECK-NEXT: t[0] /= _t5; +//CHECK-NEXT: _t6 = t[0]; //CHECK-NEXT: t[0] -= t[1]; -//CHECK-NEXT: _t8 = x; +//CHECK-NEXT: _t7 = x; //CHECK-NEXT: x = ++t[0]; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t[0] += 1; //CHECK-NEXT: { -//CHECK-NEXT: x = _t8; +//CHECK-NEXT: x = _t7; //CHECK-NEXT: double _r_d6 = * _d_x; //CHECK-NEXT: _d_t[0] += _r_d6; //CHECK-NEXT: --t[0]; @@ -345,7 +335,7 @@ double f7(double x, double y) { //CHECK-NEXT: * _d_x; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: t[0] = _t7; +//CHECK-NEXT: t[0] = _t6; //CHECK-NEXT: double _r_d5 = _d_t[0]; //CHECK-NEXT: _d_t[0] += _r_d5; //CHECK-NEXT: _d_t[1] += -_r_d5; @@ -353,16 +343,16 @@ double f7(double x, double y) { //CHECK-NEXT: _d_t[0]; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: t[0] = _t5; +//CHECK-NEXT: t[0] = _t4; //CHECK-NEXT: double _r_d4 = _d_t[0]; -//CHECK-NEXT: _d_t[0] += _r_d4 / _t6; -//CHECK-NEXT: double _r3 = _r_d4 * -t[0] / (_t6 * _t6); +//CHECK-NEXT: _d_t[0] += _r_d4 / _t5; +//CHECK-NEXT: double _r3 = _r_d4 * -t[0] / (_t5 * _t5); //CHECK-NEXT: _d_t[1] += _r3; //CHECK-NEXT: _d_t[0] -= _r_d4; //CHECK-NEXT: _d_t[0]; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: t[0] = _t4; +//CHECK-NEXT: t[0] = _t3; //CHECK-NEXT: double _r_d3 = _d_t[0]; //CHECK-NEXT: _d_t[0] += _r_d3 * t[1]; //CHECK-NEXT: double _r2 = t[0] * _r_d3; @@ -371,7 +361,7 @@ double f7(double x, double y) { //CHECK-NEXT: _d_t[0]; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: t[0] = _t3; +//CHECK-NEXT: t[0] = _t2; //CHECK-NEXT: double _r_d2 = _d_t[0]; //CHECK-NEXT: _d_t[0] += _r_d2; //CHECK-NEXT: _d_t[1] += _r_d2; @@ -379,14 +369,14 @@ double f7(double x, double y) { //CHECK-NEXT: _d_t[0]; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: x = _t2; +//CHECK-NEXT: x = _t1; //CHECK-NEXT: double _r_d1 = * _d_x; //CHECK-NEXT: * _d_y += _r_d1; //CHECK-NEXT: * _d_x -= _r_d1; //CHECK-NEXT: * _d_x; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: t[0] = _t1; +//CHECK-NEXT: t[0] = _t0; //CHECK-NEXT: double _r_d0 = _d_t[0]; //CHECK-NEXT: * _d_x += _r_d0; //CHECK-NEXT: _d_t[0] -= _r_d0; @@ -404,7 +394,7 @@ double f7(double x, double y) { //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: * _d_x += _d_t[1]; -//CHECK-NEXT: double _r0 = _d_t[2] * _t0; +//CHECK-NEXT: double _r0 = _d_t[2] * x; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = x * _d_t[2]; //CHECK-NEXT: * _d_x += _r1; @@ -612,15 +602,13 @@ double f13(double x, double y) { //CHECK-NEXT: double _t0; //CHECK-NEXT: double _t1; //CHECK-NEXT: double _d_t = 0; -//CHECK-NEXT: double _t2; //CHECK-NEXT: _t1 = y; //CHECK-NEXT: _t0 = (y = x); //CHECK-NEXT: double t = x * _t0; -//CHECK-NEXT: _t2 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r2 = 1 * _t2; +//CHECK-NEXT: double _r2 = 1 * y; //CHECK-NEXT: _d_t += _r2; //CHECK-NEXT: double _r3 = t * 1; //CHECK-NEXT: * _d_y += _r3; @@ -650,21 +638,19 @@ double f14(double i, double j) { // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; // CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; // CHECK-NEXT: _d_a = &* _d_i; // CHECK-NEXT: double &a = i; // CHECK-NEXT: _t0 = a; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: a = 2 * _t1; -// CHECK-NEXT: _t2 = a; +// CHECK-NEXT: a = 2 * i; +// CHECK-NEXT: _t1 = a; // CHECK-NEXT: a += i; -// CHECK-NEXT: _t3 = a; +// CHECK-NEXT: _t2 = a; // CHECK-NEXT: a *= i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: * _d_i += 1; // CHECK-NEXT: { -// CHECK-NEXT: a = _t3; +// CHECK-NEXT: a = _t2; // CHECK-NEXT: double _r_d2 = *_d_a; // CHECK-NEXT: *_d_a += _r_d2 * i; // CHECK-NEXT: double _r2 = a * _r_d2; @@ -672,7 +658,7 @@ double f14(double i, double j) { // CHECK-NEXT: *_d_a -= _r_d2; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: a = _t2; +// CHECK-NEXT: a = _t1; // CHECK-NEXT: double _r_d1 = *_d_a; // CHECK-NEXT: *_d_a += _r_d1; // CHECK-NEXT: * _d_i += _r_d1; @@ -681,7 +667,7 @@ double f14(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: a = _t0; // CHECK-NEXT: double _r_d0 = *_d_a; -// CHECK-NEXT: double _r0 = _r_d0 * _t1; +// CHECK-NEXT: double _r0 = _r_d0 * i; // CHECK-NEXT: double _r1 = 2 * _r_d0; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: *_d_a -= _r_d0; @@ -701,74 +687,66 @@ double f15(double i, double j) { } // CHECK: void f15_grad(double i, double j, clad::array_ref _d_i, clad::array_ref _d_j) { -// CHECK-NEXT: double _t0; // CHECK-NEXT: double _d_b = 0; // CHECK-NEXT: double *_d_a = 0; // CHECK-NEXT: double *_d_c = 0; // CHECK-NEXT: double *_d_d = 0; +// CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; // CHECK-NEXT: double _t2; // CHECK-NEXT: double _t3; -// CHECK-NEXT: double _t4; -// CHECK-NEXT: double _t5; -// CHECK-NEXT: double _t6; -// CHECK-NEXT: double _t7; -// CHECK-NEXT: _t0 = j; -// CHECK-NEXT: double b = i * _t0; +// CHECK-NEXT: double b = i * j; // CHECK-NEXT: _d_a = &_d_b; // CHECK-NEXT: double &a = b; // CHECK-NEXT: _d_c = &* _d_i; // CHECK-NEXT: double &c = i; // CHECK-NEXT: _d_d = &* _d_j; // CHECK-NEXT: double &d = j; -// CHECK-NEXT: _t1 = a; +// CHECK-NEXT: _t0 = a; // 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: _t1 = b; +// CHECK-NEXT: b += 2 * i; +// CHECK-NEXT: _t2 = c; +// CHECK-NEXT: c += 3 * i; +// CHECK-NEXT: _t3 = d; +// CHECK-NEXT: d *= 3 * j; // CHECK-NEXT: goto _label0; -// CHECK-NEXT: _label0: +// CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: *_d_a += 1; // CHECK-NEXT: *_d_c += 1; // CHECK-NEXT: *_d_d += 1; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: d = _t6; +// CHECK-NEXT: d = _t3; // CHECK-NEXT: double _r_d3 = *_d_d; -// CHECK-NEXT: *_d_d += _r_d3 * 3 * _t7; +// CHECK-NEXT: *_d_d += _r_d3 * 3 * j; // CHECK-NEXT: double _r7 = d * _r_d3; -// CHECK-NEXT: double _r8 = _r7 * _t7; +// CHECK-NEXT: double _r8 = _r7 * j; // CHECK-NEXT: double _r9 = 3 * _r7; // CHECK-NEXT: * _d_j += _r9; // CHECK-NEXT: *_d_d -= _r_d3; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: c = _t4; +// CHECK-NEXT: c = _t2; // CHECK-NEXT: double _r_d2 = *_d_c; // CHECK-NEXT: *_d_c += _r_d2; -// CHECK-NEXT: double _r5 = _r_d2 * _t5; +// CHECK-NEXT: double _r5 = _r_d2 * i; // 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 = _t2; +// CHECK-NEXT: b = _t1; // CHECK-NEXT: double _r_d1 = _d_b; // CHECK-NEXT: _d_b += _r_d1; -// CHECK-NEXT: double _r3 = _r_d1 * _t3; +// CHECK-NEXT: double _r3 = _r_d1 * i; // CHECK-NEXT: double _r4 = 2 * _r_d1; // CHECK-NEXT: * _d_i += _r4; // CHECK-NEXT: _d_b -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: a = _t1; +// CHECK-NEXT: a = _t0; // CHECK-NEXT: double _r_d0 = *_d_a; // CHECK-NEXT: *_d_a += _r_d0 * i; // CHECK-NEXT: double _r2 = a * _r_d0; @@ -776,7 +754,7 @@ double f15(double i, double j) { // CHECK-NEXT: *_d_a -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = _d_b * _t0; +// CHECK-NEXT: double _r0 = _d_b * j; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = i * _d_b; // CHECK-NEXT: * _d_j += _r1; @@ -796,7 +774,6 @@ double f16(double i, double j) { // CHECK-NEXT: double *_d_b = 0; // CHECK-NEXT: double *_d_c = 0; // CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; // CHECK-NEXT: _d_a = &* _d_i; // CHECK-NEXT: double &a = i; // CHECK-NEXT: _d_b = &*_d_a; @@ -804,17 +781,16 @@ double f16(double i, double j) { // CHECK-NEXT: _d_c = &*_d_b; // CHECK-NEXT: double &c = b; // CHECK-NEXT: _t0 = c; -// CHECK-NEXT: _t1 = j; -// CHECK-NEXT: c *= 4 * _t1; +// CHECK-NEXT: c *= 4 * j; // 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 * 4 * _t1; +// CHECK-NEXT: *_d_c += _r_d0 * 4 * j; // CHECK-NEXT: double _r0 = c * _r_d0; -// CHECK-NEXT: double _r1 = _r0 * _t1; +// CHECK-NEXT: double _r1 = _r0 * j; // CHECK-NEXT: double _r2 = 4 * _r0; // CHECK-NEXT: * _d_j += _r2; // CHECK-NEXT: *_d_c -= _r_d0; @@ -830,17 +806,15 @@ double f17(double i, double j, double k) { // CHECK-NEXT: double _d_j = 0; // CHECK-NEXT: double _d_k = 0; // CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; // CHECK-NEXT: _t0 = j; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: j = 2 * _t1; +// CHECK-NEXT: j = 2 * i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_j += 1; // CHECK-NEXT: { // CHECK-NEXT: j = _t0; // CHECK-NEXT: double _r_d0 = _d_j; -// CHECK-NEXT: double _r0 = _r_d0 * _t1; +// CHECK-NEXT: double _r0 = _r_d0 * i; // CHECK-NEXT: double _r1 = 2 * _r_d0; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: _d_j -= _r_d0; @@ -857,19 +831,15 @@ double f18(double i, double j, double k) { // CHECK-NEXT: double _d_k = 0; // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; // CHECK-NEXT: _t0 = k; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t2 = j; -// CHECK-NEXT: k = 2 * _t1 + 2 * _t2; -// CHECK-NEXT: _t3 = k; +// CHECK-NEXT: k = 2 * i + 2 * j; +// CHECK-NEXT: _t1 = k; // CHECK-NEXT: k += i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_k += 1; // CHECK-NEXT: { -// CHECK-NEXT: k = _t3; +// CHECK-NEXT: k = _t1; // CHECK-NEXT: double _r_d1 = _d_k; // CHECK-NEXT: _d_k += _r_d1; // CHECK-NEXT: * _d_i += _r_d1; @@ -878,10 +848,10 @@ double f18(double i, double j, double k) { // CHECK-NEXT: { // CHECK-NEXT: k = _t0; // CHECK-NEXT: double _r_d0 = _d_k; -// CHECK-NEXT: double _r0 = _r_d0 * _t1; +// CHECK-NEXT: double _r0 = _r_d0 * i; // CHECK-NEXT: double _r1 = 2 * _r_d0; // CHECK-NEXT: * _d_i += _r1; -// CHECK-NEXT: double _r2 = _r_d0 * _t2; +// CHECK-NEXT: double _r2 = _r_d0 * j; // CHECK-NEXT: double _r3 = 2 * _r_d0; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: _d_k -= _r_d0; @@ -920,21 +890,19 @@ double f20(double x, double y) { //CHECK-NEXT: double *_d_r = 0; //CHECK-NEXT: double _t0; //CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; //CHECK-NEXT: _d_r = &* _d_x; //CHECK-NEXT: double &r = x; //CHECK-NEXT: _t0 = r; //CHECK-NEXT: r = 3; //CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t2 = y; -//CHECK-NEXT: x = r * _t2; +//CHECK-NEXT: x = r * y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: * _d_x += 1; //CHECK-NEXT: { //CHECK-NEXT: x = _t1; //CHECK-NEXT: double _r_d1 = * _d_x; -//CHECK-NEXT: double _r0 = _r_d1 * _t2; +//CHECK-NEXT: double _r0 = _r_d1 * y; //CHECK-NEXT: *_d_r += _r0; //CHECK-NEXT: double _r1 = r * _r_d1; //CHECK-NEXT: * _d_y += _r1; diff --git a/test/Gradient/DiffInterface.C b/test/Gradient/DiffInterface.C index 38945356e..45d31eea9 100644 --- a/test/Gradient/DiffInterface.C +++ b/test/Gradient/DiffInterface.C @@ -15,22 +15,16 @@ double f_1(double x, double y, double z) { // all //CHECK: void f_1_grad(double x, double y, double z, clad::array_ref _d_x, clad::array_ref _d_y, clad::array_ref _d_z) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _t2 = z; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * x; //CHECK-NEXT: double _r1 = 0 * 1; //CHECK-NEXT: * _d_x += _r1; -//CHECK-NEXT: double _r2 = 1 * _t1; +//CHECK-NEXT: double _r2 = 1 * y; //CHECK-NEXT: double _r3 = 1 * 1; //CHECK-NEXT: * _d_y += _r3; -//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r4 = 1 * z; //CHECK-NEXT: double _r5 = 2 * 1; //CHECK-NEXT: * _d_z += _r5; //CHECK-NEXT: } @@ -40,22 +34,16 @@ double f_1(double x, double y, double z) { //CHECK: void f_1_grad_0(double x, double y, double z, clad::array_ref _d_x) { //CHECK-NEXT: double _d_y = 0; //CHECK-NEXT: double _d_z = 0; -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _t2 = z; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * x; //CHECK-NEXT: double _r1 = 0 * 1; //CHECK-NEXT: * _d_x += _r1; -//CHECK-NEXT: double _r2 = 1 * _t1; +//CHECK-NEXT: double _r2 = 1 * y; //CHECK-NEXT: double _r3 = 1 * 1; //CHECK-NEXT: _d_y += _r3; -//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r4 = 1 * z; //CHECK-NEXT: double _r5 = 2 * 1; //CHECK-NEXT: _d_z += _r5; //CHECK-NEXT: } @@ -65,22 +53,16 @@ double f_1(double x, double y, double z) { //CHECK: void f_1_grad_1(double x, double y, double z, clad::array_ref _d_y) { //CHECK-NEXT: double _d_x = 0; //CHECK-NEXT: double _d_z = 0; -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _t2 = z; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * x; //CHECK-NEXT: double _r1 = 0 * 1; //CHECK-NEXT: _d_x += _r1; -//CHECK-NEXT: double _r2 = 1 * _t1; +//CHECK-NEXT: double _r2 = 1 * y; //CHECK-NEXT: double _r3 = 1 * 1; //CHECK-NEXT: * _d_y += _r3; -//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r4 = 1 * z; //CHECK-NEXT: double _r5 = 2 * 1; //CHECK-NEXT: _d_z += _r5; //CHECK-NEXT: } @@ -90,22 +72,16 @@ double f_1(double x, double y, double z) { //CHECK: void f_1_grad_2(double x, double y, double z, clad::array_ref _d_z) { //CHECK-NEXT: double _d_x = 0; //CHECK-NEXT: double _d_y = 0; -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _t2 = z; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * x; //CHECK-NEXT: double _r1 = 0 * 1; //CHECK-NEXT: _d_x += _r1; -//CHECK-NEXT: double _r2 = 1 * _t1; +//CHECK-NEXT: double _r2 = 1 * y; //CHECK-NEXT: double _r3 = 1 * 1; -//CHECK-NEXT: _d_y += _r3; -//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: _d_y += _r3; +//CHECK-NEXT: double _r4 = 1 * z; //CHECK-NEXT: double _r5 = 2 * 1; //CHECK-NEXT: * _d_z += _r5; //CHECK-NEXT: } @@ -114,22 +90,16 @@ double f_1(double x, double y, double z) { // x, y //CHECK: void f_1_grad_0_1(double x, double y, double z, clad::array_ref _d_x, clad::array_ref _d_y) { //CHECK-NEXT: double _d_z = 0; -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _t2 = z; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * x; //CHECK-NEXT: double _r1 = 0 * 1; //CHECK-NEXT: * _d_x += _r1; -//CHECK-NEXT: double _r2 = 1 * _t1; +//CHECK-NEXT: double _r2 = 1 * y; //CHECK-NEXT: double _r3 = 1 * 1; //CHECK-NEXT: * _d_y += _r3; -//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r4 = 1 * z; //CHECK-NEXT: double _r5 = 2 * 1; //CHECK-NEXT: _d_z += _r5; //CHECK-NEXT: } @@ -137,23 +107,17 @@ double f_1(double x, double y, double z) { // y, z //CHECK: void f_1_grad_1_2(double x, double y, double z, clad::array_ref _d_y, clad::array_ref _d_z) { -// CHECK-NEXT: double _d_x = 0; -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _t2 = z; +//CHECK-NEXT: double _d_x = 0; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * x; //CHECK-NEXT: double _r1 = 0 * 1; -// CHECK-NEXT: _d_x += _r1; -//CHECK-NEXT: double _r2 = 1 * _t1; +//CHECK-NEXT: _d_x += _r1; +//CHECK-NEXT: double _r2 = 1 * y; //CHECK-NEXT: double _r3 = 1 * 1; //CHECK-NEXT: * _d_y += _r3; -//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r4 = 1 * z; //CHECK-NEXT: double _r5 = 2 * 1; //CHECK-NEXT: * _d_z += _r5; //CHECK-NEXT: } diff --git a/test/Gradient/FunctionCalls.C b/test/Gradient/FunctionCalls.C index bc1a43f88..8a157d4bb 100644 --- a/test/Gradient/FunctionCalls.C +++ b/test/Gradient/FunctionCalls.C @@ -28,16 +28,14 @@ double fn1(float i) { // CHECK: void fn1_grad(float i, clad::array_ref _d_i) { // CHECK-NEXT: float _d_res = 0; -// CHECK-NEXT: float _t0; // CHECK-NEXT: double _d_a = 0; // CHECK-NEXT: float res = A::constantFn(i); -// CHECK-NEXT: _t0 = i; -// CHECK-NEXT: double a = res * _t0; +// CHECK-NEXT: double a = res * i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_a += 1; // CHECK-NEXT: { -// CHECK-NEXT: double _r1 = _d_a * _t0; +// CHECK-NEXT: double _r1 = _d_a * i; // CHECK-NEXT: _d_res += _r1; // CHECK-NEXT: double _r2 = res * _d_a; // CHECK-NEXT: * _d_i += _r2; @@ -220,7 +218,6 @@ float sum(double* arr, int n) { // CHECK-NEXT: int _d_i = 0; // CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; // CHECK-NEXT: float res = 0; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: for (int i = 0; i < n; ++i) { @@ -229,8 +226,7 @@ float sum(double* arr, int n) { // CHECK-NEXT: res += arr[i]; // CHECK-NEXT: } // CHECK-NEXT: _t2 = arr[0]; -// CHECK-NEXT: _t3 = arr[0]; -// CHECK-NEXT: arr[0] += 10 * _t3; +// CHECK-NEXT: arr[0] += 10 * arr[0]; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += _d_y; @@ -238,7 +234,7 @@ float sum(double* arr, int n) { // CHECK-NEXT: arr[0] = _t2; // CHECK-NEXT: double _r_d1 = _d_arr[0]; // CHECK-NEXT: _d_arr[0] += _r_d1; -// CHECK-NEXT: double _r0 = _r_d1 * _t3; +// CHECK-NEXT: double _r0 = _r_d1 * arr[0]; // CHECK-NEXT: double _r1 = 10 * _r_d1; // CHECK-NEXT: _d_arr[0] += _r1; // CHECK-NEXT: _d_arr[0] -= _r_d1; @@ -260,14 +256,12 @@ void twice(double& d) { // CHECK: void twice_pullback(double &d, clad::array_ref _d_d) { // CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; // CHECK-NEXT: _t0 = d; -// CHECK-NEXT: _t1 = d; -// CHECK-NEXT: d = 2 * _t1; +// CHECK-NEXT: d = 2 * d; // CHECK-NEXT: { // CHECK-NEXT: d = _t0; // CHECK-NEXT: double _r_d0 = * _d_d; -// CHECK-NEXT: double _r0 = _r_d0 * _t1; +// CHECK-NEXT: double _r0 = _r_d0 * d; // CHECK-NEXT: double _r1 = 2 * _r_d0; // CHECK-NEXT: * _d_d += _r1; // CHECK-NEXT: * _d_d -= _r_d0; @@ -345,17 +339,15 @@ double modify2(double* arr) { // CHECK: void modify2_pullback(double *arr, double _d_y, clad::array_ref _d_arr) { // CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; // CHECK-NEXT: _t0 = arr[0]; -// CHECK-NEXT: _t1 = arr[0]; -// CHECK-NEXT: arr[0] = 5 * _t1 + arr[1]; +// CHECK-NEXT: arr[0] = 5 * arr[0] + arr[1]; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: ; // CHECK-NEXT: { // CHECK-NEXT: arr[0] = _t0; // CHECK-NEXT: double _r_d0 = _d_arr[0]; -// CHECK-NEXT: double _r0 = _r_d0 * _t1; +// CHECK-NEXT: double _r0 = _r_d0 * arr[0]; // CHECK-NEXT: double _r1 = 5 * _r_d0; // CHECK-NEXT: _d_arr[0] += _r1; // CHECK-NEXT: _d_arr[1] += _r_d0; @@ -408,12 +400,10 @@ double fn7(double i, double j) { } // CHECK: void fn6_grad(double i, double j, clad::array_ref _d_i, clad::array_ref _d_j) { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 1 * _t0; +// CHECK-NEXT: double _r0 = 1 * j; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = i * 1; // CHECK-NEXT: * _d_j += _r1; @@ -456,8 +446,6 @@ double fn7(double i, double j) { // CHECK-NEXT: double *_d_l = 0; // CHECK-NEXT: double _t4; // CHECK-NEXT: double _t5; -// CHECK-NEXT: double _t6; -// CHECK-NEXT: double _t7; // CHECK-NEXT: _t0 = i; // CHECK-NEXT: clad::ValueAndAdjoint _t1 = identity_forw(i, &* _d_i); // CHECK-NEXT: _d_k = &_t1.adjoint; @@ -467,11 +455,9 @@ double fn7(double i, double j) { // CHECK-NEXT: _d_l = &_t3.adjoint; // CHECK-NEXT: double &l = _t3.value; // CHECK-NEXT: _t4 = k; -// CHECK-NEXT: _t5 = j; -// CHECK-NEXT: k += 7 * _t5; -// CHECK-NEXT: _t6 = l; -// CHECK-NEXT: _t7 = i; -// CHECK-NEXT: l += 9 * _t7; +// CHECK-NEXT: k += 7 * j; +// CHECK-NEXT: _t5 = l; +// CHECK-NEXT: l += 9 * i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { @@ -479,10 +465,10 @@ double fn7(double i, double j) { // CHECK-NEXT: * _d_j += 1; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: l = _t6; +// CHECK-NEXT: l = _t5; // CHECK-NEXT: double _r_d1 = *_d_l; // CHECK-NEXT: *_d_l += _r_d1; -// CHECK-NEXT: double _r4 = _r_d1 * _t7; +// CHECK-NEXT: double _r4 = _r_d1 * i; // CHECK-NEXT: double _r5 = 9 * _r_d1; // CHECK-NEXT: * _d_i += _r5; // CHECK-NEXT: *_d_l -= _r_d1; @@ -491,7 +477,7 @@ double fn7(double i, double j) { // CHECK-NEXT: k = _t4; // CHECK-NEXT: double _r_d0 = *_d_k; // CHECK-NEXT: *_d_k += _r_d0; -// CHECK-NEXT: double _r2 = _r_d0 * _t5; +// CHECK-NEXT: double _r2 = _r_d0 * j; // CHECK-NEXT: double _r3 = 7 * _r_d0; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: *_d_k -= _r_d0; @@ -513,23 +499,16 @@ double fn8(double x, double y) { } // CHECK: void fn8_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: _t2 = y; -// CHECK-NEXT: _t1 = std::tanh(1.); -// CHECK-NEXT: _t0 = std::max(1., 2.); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 1 * _t0; -// CHECK-NEXT: double _r1 = _r0 * _t1; -// CHECK-NEXT: double _r2 = _r1 * _t2; +// CHECK-NEXT: double _r0 = 1 * std::max(1., 2.); +// CHECK-NEXT: double _r1 = _r0 * std::tanh(1.); +// CHECK-NEXT: double _r2 = _r1 * y; // CHECK-NEXT: * _d_x += _r2; // CHECK-NEXT: double _r3 = x * _r1; // CHECK-NEXT: * _d_y += _r3; -// CHECK-NEXT: double _r4 = x * _t2 * _r0; -// CHECK-NEXT: double _r5 = x * _t2 * _t1 * 1; +// CHECK-NEXT: double _r4 = x * y * _r0; // CHECK-NEXT: } // CHECK-NEXT: } @@ -554,17 +533,15 @@ double fn9(double x, double y) { // CHECK:void fn9_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { // CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; // CHECK-NEXT: _t0 = y; -// CHECK-NEXT: _t1 = y; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: y = _t1; +// CHECK-NEXT: y = _t0; // CHECK-NEXT: double _grad0 = 0.; -// CHECK-NEXT: custom_max_pullback(x * _t0, _t1, 1, &_grad0, &* _d_y); +// CHECK-NEXT: custom_max_pullback(x * y, _t0, 1, &_grad0, &* _d_y); // CHECK-NEXT: double _r0 = _grad0; -// CHECK-NEXT: double _r1 = _r0 * _t0; +// CHECK-NEXT: double _r1 = _r0 * y; // CHECK-NEXT: * _d_x += _r1; // CHECK-NEXT: double _r2 = x * _r0; // CHECK-NEXT: * _d_y += _r2; @@ -588,7 +565,6 @@ double fn10(double x, double y) { // CHECK-NEXT: double _t3; // CHECK-NEXT: double _t4; // CHECK-NEXT: double _t5; -// CHECK-NEXT: double _t6; // CHECK-NEXT: double out = x; // CHECK-NEXT: _t0 = out; // CHECK-NEXT: _t1 = out; @@ -599,11 +575,10 @@ double fn10(double x, double y) { // CHECK-NEXT: _t4 = out; // CHECK-NEXT: _t5 = out; // CHECK-NEXT: out = std::clamp(out, 3., 7.); -// CHECK-NEXT: _t6 = y; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r7 = 1 * _t6; +// CHECK-NEXT: double _r7 = 1 * y; // CHECK-NEXT: _d_out += _r7; // CHECK-NEXT: double _r8 = out * 1; // CHECK-NEXT: * _d_y += _r8; diff --git a/test/Gradient/Functors.C b/test/Gradient/Functors.C index 876a39737..6d65ba252 100644 --- a/test/Gradient/Functors.C +++ b/test/Gradient/Functors.C @@ -15,19 +15,15 @@ struct Experiment { Experiment& operator=(const Experiment& E) = default; // CHECK: void operator_call_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * i; // CHECK-NEXT: (* _d_this).x += _r1; // CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = this->x * _t1 * 1; + // CHECK-NEXT: double _r3 = this->x * i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -41,19 +37,15 @@ struct ExperimentConst { ExperimentConst& operator=(const ExperimentConst& E) = default; // CHECK: void operator_call_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * i; // CHECK-NEXT: (* _d_this).x += _r1; // CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = this->x * _t1 * 1; + // CHECK-NEXT: double _r3 = this->x * i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -73,19 +65,15 @@ struct ExperimentVolatile { }; // CHECK: void operator_call_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) volatile { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * i; // CHECK-NEXT: (* _d_this).x += _r1; // CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = this->x * _t1 * 1; + // CHECK-NEXT: double _r3 = this->x * i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -104,20 +92,16 @@ struct ExperimentConstVolatile { return (*this); }; - // CHECK-NEXT: void operator_call_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const volatile { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = j; + // CHECK: void operator_call_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const volatile { // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * i; // CHECK-NEXT: (* _d_this).x += _r1; // CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = this->x * _t1 * 1; + // CHECK-NEXT: double _r3 = this->x * i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -134,19 +118,15 @@ struct ExperimentNNS { ExperimentNNS& operator=(const ExperimentNNS& E) = default; // CHECK: void operator_call_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * i; // CHECK-NEXT: (* _d_this).x += _r1; // CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = this->x * _t1 * 1; + // CHECK-NEXT: double _r3 = this->x * i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -206,19 +186,15 @@ int main() { auto lambda = [](double i, double j) { return i * i * j; }; // CHECK: inline void operator_call_grad(double i, double j, clad::array_ref _d_i, clad::array_ref _d_j) const { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * i; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: double _r2 = i * _r0; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = i * _t1 * 1; + // CHECK-NEXT: double _r3 = i * i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -226,18 +202,14 @@ int main() { auto lambdaWithCapture = [&](double ii, double j) { return x * ii * j; }; // CHECK: inline void operator_call_grad(double ii, double j, clad::array_ref _d_ii, clad::array_ref _d_j) const { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t1 = ii; - // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * ii; // CHECK-NEXT: double _r2 = x * _r0; // CHECK-NEXT: * _d_ii += _r2; - // CHECK-NEXT: double _r3 = x * _t1 * 1; + // CHECK-NEXT: double _r3 = x * ii * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/Gradient/Gradients.C b/test/Gradient/Gradients.C index 818a15c90..6b91514ec 100644 --- a/test/Gradient/Gradients.C +++ b/test/Gradient/Gradients.C @@ -32,17 +32,13 @@ double f_add2(double x, double y) { } //CHECK: void f_add2_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * x; //CHECK-NEXT: double _r1 = 3 * 1; //CHECK-NEXT: * _d_x += _r1; -//CHECK-NEXT: double _r2 = 1 * _t1; +//CHECK-NEXT: double _r2 = 1 * y; //CHECK-NEXT: double _r3 = 4 * 1; //CHECK-NEXT: * _d_y += _r3; //CHECK-NEXT: } @@ -55,23 +51,16 @@ double f_add3(double x, double y) { } //CHECK: void f_add3_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t2 = y; -//CHECK-NEXT: _t1 = 4; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * x; //CHECK-NEXT: double _r1 = 3 * 1; //CHECK-NEXT: * _d_x += _r1; -//CHECK-NEXT: double _r2 = 1 * _t1; -//CHECK-NEXT: double _r3 = _r2 * _t2; +//CHECK-NEXT: double _r2 = 1 * 4; +//CHECK-NEXT: double _r3 = _r2 * y; //CHECK-NEXT: double _r4 = 4 * _r2; //CHECK-NEXT: * _d_y += _r4; -//CHECK-NEXT: double _r5 = 4 * _t2 * 1; //CHECK-NEXT: } //CHECK-NEXT: } @@ -96,17 +85,13 @@ double f_sub2(double x, double y) { } //CHECK: void f_sub2_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * x; //CHECK-NEXT: double _r1 = 3 * 1; //CHECK-NEXT: * _d_x += _r1; -//CHECK-NEXT: double _r2 = -1 * _t1; +//CHECK-NEXT: double _r2 = -1 * y; //CHECK-NEXT: double _r3 = 4 * -1; //CHECK-NEXT: * _d_y += _r3; //CHECK-NEXT: } @@ -119,12 +104,10 @@ double f_mult1(double x, double y) { } //CHECK: void f_mult1_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: _t0 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * y; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = x * 1; //CHECK-NEXT: * _d_y += _r1; @@ -138,23 +121,16 @@ double f_mult2(double x, double y) { } //CHECK: void f_mult2_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t2 = x; -//CHECK-NEXT: _t1 = 4; -//CHECK-NEXT: _t0 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; -//CHECK-NEXT: double _r1 = _r0 * _t1; -//CHECK-NEXT: double _r2 = _r1 * _t2; +//CHECK-NEXT: double _r0 = 1 * y; +//CHECK-NEXT: double _r1 = _r0 * 4; +//CHECK-NEXT: double _r2 = _r1 * x; //CHECK-NEXT: double _r3 = 3 * _r1; //CHECK-NEXT: * _d_x += _r3; -//CHECK-NEXT: double _r4 = 3 * _t2 * _r0; -//CHECK-NEXT: double _r5 = 3 * _t2 * _t1 * 1; -//CHECK-NEXT: * _d_y += _r5; +//CHECK-NEXT: double _r4 = 3 * x * 4 * 1; +//CHECK-NEXT: * _d_y += _r4; //CHECK-NEXT: } //CHECK-NEXT: } @@ -185,20 +161,16 @@ double f_div2(double x, double y) { //CHECK: void f_div2_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { //CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t2 = y; -//CHECK-NEXT: _t0 = (4 * _t2); +//CHECK-NEXT: _t0 = (4 * y); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 / _t0; -//CHECK-NEXT: double _r1 = _r0 * _t1; +//CHECK-NEXT: double _r1 = _r0 * x; //CHECK-NEXT: double _r2 = 3 * _r0; //CHECK-NEXT: * _d_x += _r2; -//CHECK-NEXT: double _r3 = 1 * -3 * _t1 / (_t0 * _t0); -//CHECK-NEXT: double _r4 = _r3 * _t2; +//CHECK-NEXT: double _r3 = 1 * -3 * x / (_t0 * _t0); +//CHECK-NEXT: double _r4 = _r3 * y; //CHECK-NEXT: double _r5 = 4 * _r3; //CHECK-NEXT: * _d_y += _r5; //CHECK-NEXT: } @@ -212,29 +184,23 @@ double f_c(double x, double y) { //CHECK: void f_c_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { //CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; //CHECK-NEXT: _t0 = y; -//CHECK-NEXT: _t2 = y; -//CHECK-NEXT: _t1 = (x / _t2); -//CHECK-NEXT: _t3 = x; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * y; //CHECK-NEXT: * _d_x += -_r0; //CHECK-NEXT: double _r1 = -x * 1; //CHECK-NEXT: * _d_y += _r1; -//CHECK-NEXT: double _r2 = 1 * _t1; +//CHECK-NEXT: double _r2 = 1 * (x / y); //CHECK-NEXT: * _d_x += _r2; //CHECK-NEXT: * _d_y += _r2; //CHECK-NEXT: double _r3 = (x + y) * 1; -//CHECK-NEXT: double _r4 = _r3 / _t2; +//CHECK-NEXT: double _r4 = _r3 / _t0; //CHECK-NEXT: * _d_x += _r4; -//CHECK-NEXT: double _r5 = _r3 * -x / (_t2 * _t2); +//CHECK-NEXT: double _r5 = _r3 * -x / (_t0 * _t0); //CHECK-NEXT: * _d_y += _r5; -//CHECK-NEXT: double _r6 = -1 * _t3; +//CHECK-NEXT: double _r6 = -1 * x; //CHECK-NEXT: * _d_x += _r6; //CHECK-NEXT: double _r7 = x * -1; //CHECK-NEXT: * _d_x += _r7; @@ -248,34 +214,24 @@ double f_rosenbrock(double x, double y) { } //CHECK: void f_rosenbrock_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: double _t4; -//CHECK-NEXT: _t0 = (x - 1); -//CHECK-NEXT: _t3 = x; -//CHECK-NEXT: _t2 = (y - x * _t3); -//CHECK-NEXT: _t4 = x; -//CHECK-NEXT: _t1 = (y - x * _t4); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * (x - 1); //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = (x - 1) * 1; //CHECK-NEXT: * _d_x += _r1; -//CHECK-NEXT: double _r2 = 1 * _t1; -//CHECK-NEXT: double _r3 = _r2 * _t2; +//CHECK-NEXT: double _r2 = 1 * (y - x * x); +//CHECK-NEXT: double _r3 = _r2 * (y - x * x); //CHECK-NEXT: double _r4 = 100 * _r2; //CHECK-NEXT: * _d_y += _r4; -//CHECK-NEXT: double _r5 = -_r4 * _t3; +//CHECK-NEXT: double _r5 = -_r4 * x; //CHECK-NEXT: * _d_x += _r5; //CHECK-NEXT: double _r6 = x * -_r4; //CHECK-NEXT: * _d_x += _r6; -//CHECK-NEXT: double _r7 = 100 * _t2 * 1; +//CHECK-NEXT: double _r7 = 100 * (y - x * x) * 1; //CHECK-NEXT: * _d_y += _r7; -//CHECK-NEXT: double _r8 = -_r7 * _t4; +//CHECK-NEXT: double _r8 = -_r7 * x; //CHECK-NEXT: * _d_x += _r8; //CHECK-NEXT: double _r9 = x * -_r7; //CHECK-NEXT: * _d_x += _r9; @@ -359,14 +315,12 @@ double f_cond4(double x, double y) { //CHECK-NEXT: clad::array _d_arr(2UL); //CHECK-NEXT: bool _cond0; //CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; //CHECK-NEXT: int i = 0; //CHECK-NEXT: double arr[2] = {x, y}; //CHECK-NEXT: _cond0 = x > 0; //CHECK-NEXT: if (_cond0) { //CHECK-NEXT: _t0 = y; -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: y = arr[i] * _t1; +//CHECK-NEXT: y = arr[i] * x; //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: @@ -375,7 +329,7 @@ double f_cond4(double x, double y) { //CHECK-NEXT: { //CHECK-NEXT: y = _t0; //CHECK-NEXT: double _r_d0 = * _d_y; -//CHECK-NEXT: double _r0 = _r_d0 * _t1; +//CHECK-NEXT: double _r0 = _r_d0 * x; //CHECK-NEXT: _d_arr[i] += _r0; //CHECK-NEXT: double _r1 = arr[i] * _r_d0; //CHECK-NEXT: * _d_x += _r1; @@ -458,18 +412,14 @@ struct S { } //CHECK: void f_grad(double x, double y, clad::array_ref _d_this, clad::array_ref _d_x, clad::array_ref _d_y) { - //CHECK-NEXT: double _t0; - //CHECK-NEXT: double _t1; - //CHECK-NEXT: _t0 = x; - //CHECK-NEXT: _t1 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { - //CHECK-NEXT: double _r0 = 1 * _t0; + //CHECK-NEXT: double _r0 = 1 * x; //CHECK-NEXT: (* _d_this).c1 += _r0; //CHECK-NEXT: double _r1 = this->c1 * 1; //CHECK-NEXT: * _d_x += _r1; - //CHECK-NEXT: double _r2 = 1 * _t1; + //CHECK-NEXT: double _r2 = 1 * y; //CHECK-NEXT: (* _d_this).c2 += _r2; //CHECK-NEXT: double _r3 = this->c2 * 1; //CHECK-NEXT: * _d_y += _r3; @@ -552,12 +502,10 @@ double f_sin(double x, double y) { void f_sin_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y); //CHECK: void f_sin_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: _t0 = (x + y); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * (x + y); //CHECK-NEXT: double _r1 = _r0 * clad::custom_derivatives::sin_pushforward(x, 1.).pushforward; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: double _r2 = _r0 * clad::custom_derivatives::sin_pushforward(y, 1.).pushforward; @@ -597,22 +545,16 @@ double f_decls1(double x, double y) { void f_decls1_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y); //CHECK: void f_decls1_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { -//CHECK-NEXT: double _t0; //CHECK-NEXT: double _d_a = 0; -//CHECK-NEXT: double _t1; //CHECK-NEXT: double _d_b = 0; //CHECK-NEXT: double _d_c = 0; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: double a = 3 * _t0; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: double b = 5 * _t1; +//CHECK-NEXT: double a = 3 * x; +//CHECK-NEXT: double b = 5 * y; //CHECK-NEXT: double c = a + b; -//CHECK-NEXT: _t2 = c; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r4 = 1 * c; //CHECK-NEXT: double _r5 = 2 * 1; //CHECK-NEXT: _d_c += _r5; //CHECK-NEXT: } @@ -621,12 +563,12 @@ void f_decls1_grad(double x, double y, clad::array_ref _d_x, clad::array //CHECK-NEXT: _d_b += _d_c; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r2 = _d_b * _t1; +//CHECK-NEXT: double _r2 = _d_b * y; //CHECK-NEXT: double _r3 = 5 * _d_b; //CHECK-NEXT: * _d_y += _r3; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_a * _t0; +//CHECK-NEXT: double _r0 = _d_a * x; //CHECK-NEXT: double _r1 = 3 * _d_a; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: } @@ -641,43 +583,35 @@ double f_decls2(double x, double y) { void f_decls2_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y); //CHECK: void f_decls2_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { -//CHECK-NEXT: double _t0; //CHECK-NEXT: double _d_a = 0; -//CHECK-NEXT: double _t1; //CHECK-NEXT: double _d_b = 0; -//CHECK-NEXT: double _t2; //CHECK-NEXT: double _d_c = 0; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: double a = x * _t0; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: double b = x * _t1; -//CHECK-NEXT: _t2 = y; -//CHECK-NEXT: double c = y * _t2; -//CHECK-NEXT: _t3 = b; +//CHECK-NEXT: double a = x * x; +//CHECK-NEXT: double b = x * y; +//CHECK-NEXT: double c = y * y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: _d_a += 1; -//CHECK-NEXT: double _r6 = 1 * _t3; +//CHECK-NEXT: double _r6 = 1 * b; //CHECK-NEXT: double _r7 = 2 * 1; //CHECK-NEXT: _d_b += _r7; //CHECK-NEXT: _d_c += 1; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = _d_c * _t2; +//CHECK-NEXT: double _r4 = _d_c * y; //CHECK-NEXT: * _d_y += _r4; //CHECK-NEXT: double _r5 = y * _d_c; //CHECK-NEXT: * _d_y += _r5; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r2 = _d_b * _t1; +//CHECK-NEXT: double _r2 = _d_b * y; //CHECK-NEXT: * _d_x += _r2; //CHECK-NEXT: double _r3 = x * _d_b; //CHECK-NEXT: * _d_y += _r3; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_a * _t0; +//CHECK-NEXT: double _r0 = _d_a * x; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = x * _d_a; //CHECK-NEXT: * _d_x += _r1; @@ -697,38 +631,27 @@ double f_decls3(double x, double y) { void f_decls3_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y); //CHECK: void f_decls3_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { -//CHECK-NEXT: double _t0; //CHECK-NEXT: double _d_a = 0; -//CHECK-NEXT: double _t1; //CHECK-NEXT: double _d_c = 0; //CHECK-NEXT: bool _cond0; -//CHECK-NEXT: double _t2; //CHECK-NEXT: bool _cond1; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: double _t4; //CHECK-NEXT: double _d_b = 0; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: double a = 3 * _t0; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: double c = 333 * _t1; +//CHECK-NEXT: double a = 3 * x; +//CHECK-NEXT: double c = 333 * y; //CHECK-NEXT: _cond0 = x > 1; -//CHECK-NEXT: if (_cond0) { -//CHECK-NEXT: _t2 = a; +//CHECK-NEXT: if (_cond0) //CHECK-NEXT: goto _label0; -//CHECK-NEXT: } else { +//CHECK-NEXT: else { //CHECK-NEXT: _cond1 = x < -1; -//CHECK-NEXT: if (_cond1) { -//CHECK-NEXT: _t3 = a; +//CHECK-NEXT: if (_cond1) //CHECK-NEXT: goto _label1; -//CHECK-NEXT: } //CHECK-NEXT: } -//CHECK-NEXT: _t4 = a; -//CHECK-NEXT: double b = a * _t4; +//CHECK-NEXT: double b = a * a; //CHECK-NEXT: goto _label2; //CHECK-NEXT: _label2: //CHECK-NEXT: _d_b += 1; //CHECK-NEXT: { -//CHECK-NEXT: double _r8 = _d_b * _t4; +//CHECK-NEXT: double _r8 = _d_b * a; //CHECK-NEXT: _d_a += _r8; //CHECK-NEXT: double _r9 = a * _d_b; //CHECK-NEXT: _d_a += _r9; @@ -736,24 +659,24 @@ void f_decls3_grad(double x, double y, clad::array_ref _d_x, clad::array //CHECK-NEXT: if (_cond0) //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r4 = 1 * a; //CHECK-NEXT: double _r5 = 2 * 1; //CHECK-NEXT: _d_a += _r5; //CHECK-NEXT: } //CHECK-NEXT: else if (_cond1) //CHECK-NEXT: _label1: //CHECK-NEXT: { -//CHECK-NEXT: double _r6 = 1 * _t3; +//CHECK-NEXT: double _r6 = 1 * a; //CHECK-NEXT: double _r7 = -2 * 1; //CHECK-NEXT: _d_a += _r7; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r2 = _d_c * _t1; +//CHECK-NEXT: double _r2 = _d_c * y; //CHECK-NEXT: double _r3 = 333 * _d_c; //CHECK-NEXT: * _d_y += _r3; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_a * _t0; +//CHECK-NEXT: double _r0 = _d_a * x; //CHECK-NEXT: double _r1 = 3 * _d_a; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: } @@ -767,41 +690,29 @@ double f_issue138(double x, double y) { void f_issue138_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y); //CHECK: void f_issue138_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { //CHECK-NEXT: double _d__t1 = 0; -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: double _t4; -//CHECK-NEXT: double _t5; //CHECK-NEXT: double _t10 = 1; -//CHECK-NEXT: _t2 = x; -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t5 = y; -//CHECK-NEXT: _t4 = y; -//CHECK-NEXT: _t3 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; -//CHECK-NEXT: double _r1 = _r0 * _t1; -//CHECK-NEXT: double _r2 = _r1 * _t2; +//CHECK-NEXT: double _r0 = 1 * x; +//CHECK-NEXT: double _r1 = _r0 * x; +//CHECK-NEXT: double _r2 = _r1 * x; //CHECK-NEXT: * _d_x += _r2; //CHECK-NEXT: double _r3 = x * _r1; //CHECK-NEXT: * _d_x += _r3; -//CHECK-NEXT: double _r4 = x * _t2 * _r0; +//CHECK-NEXT: double _r4 = x * x * _r0; //CHECK-NEXT: * _d_x += _r4; -//CHECK-NEXT: double _r5 = x * _t2 * _t1 * 1; +//CHECK-NEXT: double _r5 = x * x * x * 1; //CHECK-NEXT: * _d_x += _r5; -//CHECK-NEXT: double _r6 = 1 * _t3; -//CHECK-NEXT: double _r7 = _r6 * _t4; -//CHECK-NEXT: double _r8 = _r7 * _t5; +//CHECK-NEXT: double _r6 = 1 * y; +//CHECK-NEXT: double _r7 = _r6 * y; +//CHECK-NEXT: double _r8 = _r7 * y; //CHECK-NEXT: * _d_y += _r8; //CHECK-NEXT: double _r9 = y * _r7; //CHECK-NEXT: * _d_y += _r9; -//CHECK-NEXT: double _r10 = y * _t5 * _r6; +//CHECK-NEXT: double _r10 = y * y * _r6; //CHECK-NEXT: * _d_y += _r10; -//CHECK-NEXT: double _r11 = y * _t5 * _t4 * 1; +//CHECK-NEXT: double _r11 = y * y * y * 1; //CHECK-NEXT: * _d_y += _r11; //CHECK-NEXT: } //CHECK-NEXT: } @@ -812,12 +723,10 @@ double f_const(const double a, const double b) { void f_const_grad(const double a, const double b, clad::array_ref _d_a, clad::array_ref _d_b); //CHECK: void f_const_grad(const double a, const double b, clad::array_ref _d_a, clad::array_ref _d_b) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: _t0 = b; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * b; //CHECK-NEXT: * _d_a += _r0; //CHECK-NEXT: double _r1 = a * 1; //CHECK-NEXT: * _d_b += _r1; @@ -834,18 +743,16 @@ void f_const_reference_grad(double i, double j, clad::array_ref _d_i, cl //CHECK: void f_const_reference_grad(double i, double j, clad::array_ref _d_i, clad::array_ref _d_j) { //CHECK-NEXT: double _d_a = 0; //CHECK-NEXT: double *_d_ar = 0; -//CHECK-NEXT: double _t0; //CHECK-NEXT: double _d_res = 0; //CHECK-NEXT: double a = i; //CHECK-NEXT: _d_ar = &_d_a; //CHECK-NEXT: const double &ar = a; -//CHECK-NEXT: _t0 = ar; -//CHECK-NEXT: double res = 2 * _t0; +//CHECK-NEXT: double res = 2 * ar; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_res += 1; //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_res * _t0; +//CHECK-NEXT: double _r0 = _d_res * ar; //CHECK-NEXT: double _r1 = 2 * _d_res; //CHECK-NEXT: *_d_ar += _r1; //CHECK-NEXT: } @@ -911,13 +818,11 @@ double fn_global_var_use(double i, double j) { // CHECK: void fn_global_var_use_grad(double i, double j, clad::array_ref _d_i, clad::array_ref _d_j) { // CHECK-NEXT: double _d_ref = 0; -// CHECK-NEXT: double _t0; // CHECK-NEXT: double &ref = global; -// CHECK-NEXT: _t0 = i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 1 * _t0; +// CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: _d_ref += _r0; // CHECK-NEXT: double _r1 = ref * 1; // CHECK-NEXT: * _d_i += _r1; diff --git a/test/Gradient/Loops.C b/test/Gradient/Loops.C index a960a41c1..6f437c714 100644 --- a/test/Gradient/Loops.C +++ b/test/Gradient/Loops.C @@ -233,12 +233,10 @@ double f_sum(double *p, int n) { double sq(double x) { return x * x; } //CHECK: void sq_pullback(double x, double _d_y, clad::array_ref _d_x) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: _t0 = x; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_y * _t0; +//CHECK-NEXT: double _r0 = _d_y * x; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = x * _d_y; //CHECK-NEXT: * _d_x += _r1; @@ -302,9 +300,6 @@ double f_log_gaus(double* x, double* p /*means*/, double n, double sigma) { //CHECK-NEXT: double _t3; //CHECK-NEXT: double _t4; //CHECK-NEXT: double _t5; -//CHECK-NEXT: double _t6; -//CHECK-NEXT: double _t7; -//CHECK-NEXT: double _t8; //CHECK-NEXT: double _d_gaus = 0; //CHECK-NEXT: double power = 0; //CHECK-NEXT: _t0 = 0; @@ -317,36 +312,32 @@ double f_log_gaus(double* x, double* p /*means*/, double n, double sigma) { //CHECK-NEXT: _t4 = sq(sigma); //CHECK-NEXT: _t3 = (2 * _t4); //CHECK-NEXT: power = -power / _t3; -//CHECK-NEXT: _t8 = 3.1415926535897931; -//CHECK-NEXT: _t7 = sigma; -//CHECK-NEXT: _t6 = std::sqrt(std::pow(2 * _t8, n) * _t7); -//CHECK-NEXT: _t5 = std::exp(power); -//CHECK-NEXT: double gaus = 1. / _t6 * _t5; +//CHECK-NEXT: _t5 = std::sqrt(std::pow(2 * 3.1415926535897931, n) * sigma); +//CHECK-NEXT: double gaus = 1. / _t5 * std::exp(power); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r18 = 1 * clad::custom_derivatives::log_pushforward(gaus, 1.).pushforward; -//CHECK-NEXT: _d_gaus += _r18; +//CHECK-NEXT: double _r17 = 1 * clad::custom_derivatives::log_pushforward(gaus, 1.).pushforward; +//CHECK-NEXT: _d_gaus += _r17; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r6 = _d_gaus * _t5; -//CHECK-NEXT: double _r7 = _r6 / _t6; -//CHECK-NEXT: double _r8 = _r6 * -1. / (_t6 * _t6); -//CHECK-NEXT: double _r9 = _r8 * clad::custom_derivatives::sqrt_pushforward(std::pow(2 * _t8, n) * _t7, 1.).pushforward; -//CHECK-NEXT: double _r10 = _r9 * _t7; +//CHECK-NEXT: double _r6 = _d_gaus * std::exp(power); +//CHECK-NEXT: double _r7 = _r6 / _t5; +//CHECK-NEXT: double _r8 = _r6 * -1. / (_t5 * _t5); +//CHECK-NEXT: double _r9 = _r8 * clad::custom_derivatives::sqrt_pushforward(std::pow(2 * 3.1415926535897931, n) * sigma, 1.).pushforward; +//CHECK-NEXT: double _r10 = _r9 * sigma; //CHECK-NEXT: double _grad2 = 0.; //CHECK-NEXT: double _grad3 = 0.; -//CHECK-NEXT: clad::custom_derivatives::pow_pullback(2 * _t8, n, _r10, &_grad2, &_grad3); +//CHECK-NEXT: clad::custom_derivatives::pow_pullback(2 * 3.1415926535897931, n, _r10, &_grad2, &_grad3); //CHECK-NEXT: double _r11 = _grad2; -//CHECK-NEXT: double _r12 = _r11 * _t8; -//CHECK-NEXT: double _r13 = 2 * _r11; -//CHECK-NEXT: double _r14 = _grad3; -//CHECK-NEXT: _d_n += _r14; -//CHECK-NEXT: double _r15 = std::pow(2 * _t8, n) * _r9; -//CHECK-NEXT: _d_sigma += _r15; -//CHECK-NEXT: double _r16 = 1. / _t6 * _d_gaus; -//CHECK-NEXT: double _r17 = _r16 * clad::custom_derivatives::exp_pushforward(power, 1.).pushforward; -//CHECK-NEXT: _d_power += _r17; +//CHECK-NEXT: double _r12 = _r11 * 3.1415926535897931; +//CHECK-NEXT: double _r13 = _grad3; +//CHECK-NEXT: _d_n += _r13; +//CHECK-NEXT: double _r14 = std::pow(2 * 3.1415926535897931, n) * _r9; +//CHECK-NEXT: _d_sigma += _r14; +//CHECK-NEXT: double _r15 = 1. / _t5 * _d_gaus; +//CHECK-NEXT: double _r16 = _r15 * clad::custom_derivatives::exp_pushforward(power, 1.).pushforward; +//CHECK-NEXT: _d_power += _r16; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: power = _t2; @@ -389,17 +380,16 @@ void f_const_grad(const double, const double, clad::array_ref, clad::arr //CHECK-NEXT: int _d_r = 0; //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t1 = {}; -//CHECK-NEXT: clad::tape _t2 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: int _d_sq = 0; //CHECK-NEXT: int sq0 = 0; -//CHECK-NEXT: clad::tape _t3 = {}; +//CHECK-NEXT: clad::tape _t2 = {}; //CHECK-NEXT: int r = 0; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < a; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: clad::push(_t2, sq0) , sq0 = b * clad::push(_t1, b); -//CHECK-NEXT: clad::push(_t3, r); +//CHECK-NEXT: clad::push(_t1, sq0) , sq0 = b * b; +//CHECK-NEXT: clad::push(_t2, r); //CHECK-NEXT: r += sq0; //CHECK-NEXT: } //CHECK-NEXT: goto _label0; @@ -408,19 +398,19 @@ void f_const_grad(const double, const double, clad::array_ref, clad::arr //CHECK-NEXT: for (; _t0; _t0--) { //CHECK-NEXT: i--; //CHECK-NEXT: { -//CHECK-NEXT: r = clad::pop(_t3); +//CHECK-NEXT: r = clad::pop(_t2); //CHECK-NEXT: int _r_d0 = _d_r; //CHECK-NEXT: _d_r += _r_d0; //CHECK-NEXT: _d_sq += _r_d0; //CHECK-NEXT: _d_r -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_sq * clad::pop(_t1); +//CHECK-NEXT: double _r0 = _d_sq * b; //CHECK-NEXT: * _d_b += _r0; //CHECK-NEXT: double _r1 = b * _d_sq; //CHECK-NEXT: * _d_b += _r1; //CHECK-NEXT: _d_sq = 0; -//CHECK-NEXT: sq0 = clad::pop(_t2); +//CHECK-NEXT: sq0 = clad::pop(_t1); //CHECK-NEXT: } //CHECK-NEXT: } //CHECK-NEXT: } @@ -441,24 +431,22 @@ double f6 (double i, double j) { // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: int _d_counter = 0; // CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: double _d_b = 0; // CHECK-NEXT: double b = 0; -// CHECK-NEXT: clad::tape _t3 = {}; -// CHECK-NEXT: clad::tape _t4 = {}; +// CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: double _d_c = 0; // CHECK-NEXT: double c = 0; -// CHECK-NEXT: clad::tape _t5 = {}; -// CHECK-NEXT: clad::tape _t6 = {}; +// CHECK-NEXT: clad::tape _t3 = {}; +// CHECK-NEXT: clad::tape _t4 = {}; // CHECK-NEXT: double a = 0; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: for (int counter = 0; counter < 3; ++counter) { // CHECK-NEXT: _t0++; -// CHECK-NEXT: clad::push(_t2, b) , b = i * clad::push(_t1, i); -// CHECK-NEXT: clad::push(_t4, c) , c = j * clad::push(_t3, j); -// CHECK-NEXT: clad::push(_t5, b); +// CHECK-NEXT: clad::push(_t1, b) , b = i * i; +// CHECK-NEXT: clad::push(_t2, c) , c = j * j; +// CHECK-NEXT: clad::push(_t3, b); // CHECK-NEXT: b += j; -// CHECK-NEXT: clad::push(_t6, a); +// CHECK-NEXT: clad::push(_t4, a); // CHECK-NEXT: a += b + c + i; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; @@ -467,7 +455,7 @@ double f6 (double i, double j) { // CHECK-NEXT: for (; _t0; _t0--) { // CHECK-NEXT: --counter; // CHECK-NEXT: { -// CHECK-NEXT: a = clad::pop(_t6); +// CHECK-NEXT: a = clad::pop(_t4); // CHECK-NEXT: double _r_d1 = _d_a; // CHECK-NEXT: _d_a += _r_d1; // CHECK-NEXT: _d_b += _r_d1; @@ -476,27 +464,27 @@ double f6 (double i, double j) { // CHECK-NEXT: _d_a -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: b = clad::pop(_t5); +// CHECK-NEXT: b = clad::pop(_t3); // CHECK-NEXT: double _r_d0 = _d_b; // CHECK-NEXT: _d_b += _r_d0; // CHECK-NEXT: * _d_j += _r_d0; // CHECK-NEXT: _d_b -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: double _r2 = _d_c * clad::pop(_t3); +// CHECK-NEXT: double _r2 = _d_c * j; // CHECK-NEXT: * _d_j += _r2; // CHECK-NEXT: double _r3 = j * _d_c; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: _d_c = 0; -// CHECK-NEXT: c = clad::pop(_t4); +// CHECK-NEXT: c = clad::pop(_t2); // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = _d_b * clad::pop(_t1); +// CHECK-NEXT: double _r0 = _d_b * i; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = i * _d_b; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: _d_b = 0; -// CHECK-NEXT: b = clad::pop(_t2); +// CHECK-NEXT: b = clad::pop(_t1); // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } @@ -514,7 +502,6 @@ double fn7(double i, double j) { // CHECK-NEXT: int _d_counter = 0; // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: double a = 0; // CHECK-NEXT: int counter = 3; // CHECK-NEXT: _t0 = 0; @@ -522,7 +509,7 @@ double fn7(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: _t0++; // CHECK-NEXT: clad::push(_t1, a); -// CHECK-NEXT: a += i * clad::push(_t2, i) + j; +// CHECK-NEXT: a += i * i + j; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: @@ -533,7 +520,7 @@ double fn7(double i, double j) { // CHECK-NEXT: a = clad::pop(_t1); // CHECK-NEXT: double _r_d0 = _d_a; // CHECK-NEXT: _d_a += _r_d0; -// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t2); +// CHECK-NEXT: double _r0 = _r_d0 * i; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_i += _r1; @@ -560,7 +547,6 @@ double fn8(double i, double j) { // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: clad::tape _t2 = {}; -// CHECK-NEXT: clad::tape _t3 = {}; // CHECK-NEXT: double a = 0; // CHECK-NEXT: int counter = 3; // CHECK-NEXT: _t0 = 0; @@ -571,7 +557,7 @@ double fn8(double i, double j) { // CHECK-NEXT: do { // CHECK-NEXT: clad::back(_t1)++; // CHECK-NEXT: clad::push(_t2, a); -// CHECK-NEXT: a += i * clad::push(_t3, i) + j; +// CHECK-NEXT: a += i * i + j; // CHECK-NEXT: } while (--counter); // CHECK-NEXT: } // CHECK-NEXT: goto _label0; @@ -586,7 +572,7 @@ double fn8(double i, double j) { // CHECK-NEXT: a = clad::pop(_t2); // CHECK-NEXT: double _r_d0 = _d_a; // CHECK-NEXT: _d_a += _r_d0; -// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t3); +// CHECK-NEXT: double _r0 = _r_d0 * i; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_i += _r1; @@ -624,7 +610,6 @@ double fn9(double i, double j) { // CHECK-NEXT: clad::tape _t3 = {}; // CHECK-NEXT: clad::tape _t4 = {}; // CHECK-NEXT: clad::tape _t5 = {}; -// CHECK-NEXT: clad::tape _t6 = {}; // CHECK-NEXT: int counter, counter_again; // CHECK-NEXT: _t0 = counter; // CHECK-NEXT: _t1 = counter_again; @@ -641,7 +626,7 @@ double fn9(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: clad::back(_t4)++; // CHECK-NEXT: clad::push(_t5, a); -// CHECK-NEXT: a += i * clad::push(_t6, i) + j; +// CHECK-NEXT: a += i * i + j; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: goto _label0; @@ -658,7 +643,7 @@ double fn9(double i, double j) { // CHECK-NEXT: a = clad::pop(_t5); // CHECK-NEXT: double _r_d3 = _d_a; // CHECK-NEXT: _d_a += _r_d3; -// CHECK-NEXT: double _r0 = _r_d3 * clad::pop(_t6); +// CHECK-NEXT: double _r0 = _r_d3 * i; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = i * _r_d3; // CHECK-NEXT: * _d_i += _r1; @@ -709,8 +694,7 @@ double fn10(double i, double j) { // CHECK-NEXT: int b = 0; // CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: clad::tape _t3 = {}; -// CHECK-NEXT: clad::tape _t4 = {}; -// CHECK-NEXT: clad::tape _t5 = {}; +// CHECK-NEXT: clad::tape _t4 = {}; // CHECK-NEXT: double a = 0; // CHECK-NEXT: int counter = 3; // CHECK-NEXT: _t0 = 0; @@ -718,10 +702,10 @@ double fn10(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: _t0++; // CHECK-NEXT: clad::push(_t2, b); -// CHECK-NEXT: b += i * clad::push(_t3, i) + j; -// CHECK-NEXT: clad::push(_t4, a); +// CHECK-NEXT: b += i * i + j; +// CHECK-NEXT: clad::push(_t3, a); // CHECK-NEXT: a += b; -// CHECK-NEXT: clad::push(_t5, counter); +// CHECK-NEXT: clad::push(_t4, counter); // CHECK-NEXT: counter -= 1; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; @@ -731,13 +715,13 @@ double fn10(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: { // CHECK-NEXT: { -// CHECK-NEXT: counter = clad::pop(_t5); +// CHECK-NEXT: counter = clad::pop(_t4); // CHECK-NEXT: int _r_d2 = _d_counter; // CHECK-NEXT: _d_counter += _r_d2; // CHECK-NEXT: _d_counter -= _r_d2; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: a = clad::pop(_t4); +// CHECK-NEXT: a = clad::pop(_t3); // CHECK-NEXT: double _r_d1 = _d_a; // CHECK-NEXT: _d_a += _r_d1; // CHECK-NEXT: _d_b += _r_d1; @@ -747,7 +731,7 @@ double fn10(double i, double j) { // CHECK-NEXT: b = clad::pop(_t2); // CHECK-NEXT: int _r_d0 = _d_b; // CHECK-NEXT: _d_b += _r_d0; -// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t3); +// CHECK-NEXT: double _r0 = _r_d0 * i; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_i += _r1; @@ -779,16 +763,15 @@ double fn11(double i, double j) { // CHECK-NEXT: double _d_a = 0; // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: tape _t2 = {}; -// CHECK-NEXT: clad::tape _t3 = {}; +// CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: int counter = 3; // CHECK-NEXT: double a = 0; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: do { // CHECK-NEXT: _t0++; // CHECK-NEXT: clad::push(_t1, a); -// CHECK-NEXT: a += i * clad::push(_t2, i) + j; -// CHECK-NEXT: clad::push(_t3, counter); +// CHECK-NEXT: a += i * i + j; +// CHECK-NEXT: clad::push(_t2, counter); // CHECK-NEXT: counter -= 1; // CHECK-NEXT: } while (counter); // CHECK-NEXT: goto _label0; @@ -797,7 +780,7 @@ double fn11(double i, double j) { // CHECK-NEXT: do { // CHECK-NEXT: { // CHECK-NEXT: { -// CHECK-NEXT: counter = clad::pop(_t3); +// CHECK-NEXT: counter = clad::pop(_t2); // CHECK-NEXT: int _r_d1 = _d_counter; // CHECK-NEXT: _d_counter += _r_d1; // CHECK-NEXT: _d_counter -= _r_d1; @@ -806,7 +789,7 @@ double fn11(double i, double j) { // CHECK-NEXT: a = clad::pop(_t1); // CHECK-NEXT: double _r_d0 = _d_a; // CHECK-NEXT: _d_a += _r_d0; -// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t2); +// CHECK-NEXT: double _r0 = _r_d0 * i; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_i += _r1; @@ -844,11 +827,10 @@ double fn12(double i, double j) { // CHECK-NEXT: int counter_again = 0; // CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: clad::tape _t3 = {}; -// CHECK-NEXT: clad::tape _t4 = {}; -// CHECK-NEXT: clad::tape _t5 = {}; -// CHECK-NEXT: clad::tape _t6 = {}; -// CHECK-NEXT: clad::tape _t7 = {}; -// CHECK-NEXT: clad::tape _t8 = {}; +// CHECK-NEXT: clad::tape _t4 = {}; +// CHECK-NEXT: clad::tape _t5 = {}; +// CHECK-NEXT: clad::tape _t6 = {}; +// CHECK-NEXT: clad::tape _t7 = {}; // CHECK-NEXT: int counter = 3; // CHECK-NEXT: double a = 0; // CHECK-NEXT: _t0 = 0; @@ -859,17 +841,17 @@ double fn12(double i, double j) { // CHECK-NEXT: do { // CHECK-NEXT: clad::back(_t2)++; // CHECK-NEXT: clad::push(_t3, a); -// CHECK-NEXT: a += i * clad::push(_t4, i) + j; -// CHECK-NEXT: clad::push(_t5, counter_again); +// CHECK-NEXT: a += i * i + j; +// CHECK-NEXT: clad::push(_t4, counter_again); // CHECK-NEXT: counter_again -= 1; -// CHECK-NEXT: clad::push(_t6, 0UL); +// CHECK-NEXT: clad::push(_t5, 0UL); // CHECK-NEXT: do { -// CHECK-NEXT: clad::back(_t6)++; -// CHECK-NEXT: clad::push(_t7, a); +// CHECK-NEXT: clad::back(_t5)++; +// CHECK-NEXT: clad::push(_t6, a); // CHECK-NEXT: a += j; // CHECK-NEXT: } while (0); // CHECK-NEXT: } while (counter_again); -// CHECK-NEXT: clad::push(_t8, counter); +// CHECK-NEXT: clad::push(_t7, counter); // CHECK-NEXT: counter -= 1; // CHECK-NEXT: } while (counter); // CHECK-NEXT: goto _label0; @@ -878,7 +860,7 @@ double fn12(double i, double j) { // CHECK-NEXT: do { // CHECK-NEXT: { // CHECK-NEXT: { -// CHECK-NEXT: counter = clad::pop(_t8); +// CHECK-NEXT: counter = clad::pop(_t7); // CHECK-NEXT: int _r_d3 = _d_counter; // CHECK-NEXT: _d_counter += _r_d3; // CHECK-NEXT: _d_counter -= _r_d3; @@ -889,18 +871,18 @@ double fn12(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: do { // CHECK-NEXT: { -// CHECK-NEXT: a = clad::pop(_t7); +// CHECK-NEXT: a = clad::pop(_t6); // CHECK-NEXT: double _r_d2 = _d_a; // CHECK-NEXT: _d_a += _r_d2; // CHECK-NEXT: * _d_j += _r_d2; // CHECK-NEXT: _d_a -= _r_d2; // CHECK-NEXT: } -// CHECK-NEXT: clad::back(_t6)--; -// CHECK-NEXT: } while (clad::back(_t6)); -// CHECK-NEXT: clad::pop(_t6); +// CHECK-NEXT: clad::back(_t5)--; +// CHECK-NEXT: } while (clad::back(_t5)); +// CHECK-NEXT: clad::pop(_t5); // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: counter_again = clad::pop(_t5); +// CHECK-NEXT: counter_again = clad::pop(_t4); // CHECK-NEXT: int _r_d1 = _d_counter_again; // CHECK-NEXT: _d_counter_again += _r_d1; // CHECK-NEXT: _d_counter_again -= _r_d1; @@ -909,7 +891,7 @@ double fn12(double i, double j) { // CHECK-NEXT: a = clad::pop(_t3); // CHECK-NEXT: double _r_d0 = _d_a; // CHECK-NEXT: _d_a += _r_d0; -// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t4); +// CHECK-NEXT: double _r0 = _r_d0 * i; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_i += _r1; @@ -951,19 +933,18 @@ double fn13(double i, double j) { // CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: clad::tape _t3 = {}; // CHECK-NEXT: clad::tape _t4 = {}; -// CHECK-NEXT: clad::tape _t5 = {}; // CHECK-NEXT: double _d_temp = 0; // CHECK-NEXT: double temp = 0; -// CHECK-NEXT: clad::tape _t6 = {}; +// CHECK-NEXT: clad::tape _t5 = {}; // CHECK-NEXT: double res = 0; // CHECK-NEXT: int counter = 3; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: for (; clad::push(_t1, k) , k = counter; clad::push(_t2, counter) , (counter -= 1)) { // CHECK-NEXT: _t0++; // CHECK-NEXT: clad::push(_t3, k); -// CHECK-NEXT: k += i + 2 * clad::push(_t4, j); -// CHECK-NEXT: clad::push(_t5, temp) , temp = k; -// CHECK-NEXT: clad::push(_t6, res); +// CHECK-NEXT: k += i + 2 * j; +// CHECK-NEXT: clad::push(_t4, temp) , temp = k; +// CHECK-NEXT: clad::push(_t5, res); // CHECK-NEXT: res += temp; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; @@ -978,7 +959,7 @@ double fn13(double i, double j) { // CHECK-NEXT: _d_counter -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: res = clad::pop(_t6); +// CHECK-NEXT: res = clad::pop(_t5); // CHECK-NEXT: double _r_d2 = _d_res; // CHECK-NEXT: _d_res += _r_d2; // CHECK-NEXT: _d_temp += _r_d2; @@ -987,14 +968,14 @@ double fn13(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: _d_k += _d_temp; // CHECK-NEXT: _d_temp = 0; -// CHECK-NEXT: temp = clad::pop(_t5); +// CHECK-NEXT: temp = clad::pop(_t4); // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: k = clad::pop(_t3); // CHECK-NEXT: int _r_d1 = _d_k; // CHECK-NEXT: _d_k += _r_d1; // CHECK-NEXT: * _d_i += _r_d1; -// CHECK-NEXT: double _r0 = _r_d1 * clad::pop(_t4); +// CHECK-NEXT: double _r0 = _r_d1 * j; // CHECK-NEXT: int _r1 = 2 * _r_d1; // CHECK-NEXT: * _d_j += _r1; // CHECK-NEXT: _d_k -= _r_d1; @@ -1040,7 +1021,6 @@ double fn14(double i, double j) { // CHECK-NEXT: clad::tape _t7 = {}; // CHECK-NEXT: clad::tape _t9 = {}; // CHECK-NEXT: clad::tape _t10 = {}; -// CHECK-NEXT: clad::tape _t11 = {}; // CHECK-NEXT: int choice = 5; // CHECK-NEXT: double res = 0; // CHECK-NEXT: _t0 = 0; @@ -1075,7 +1055,7 @@ double fn14(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: if (_t8) { // CHECK-NEXT: clad::push(_t10, res); -// CHECK-NEXT: res += i * clad::push(_t11, j); +// CHECK-NEXT: res += i * j; // CHECK-NEXT: { // CHECK-NEXT: clad::push(_t4, 3UL); // CHECK-NEXT: continue; @@ -1100,7 +1080,7 @@ double fn14(double i, double j) { // CHECK-NEXT: res = clad::pop(_t10); // CHECK-NEXT: double _r_d2 = _d_res; // CHECK-NEXT: _d_res += _r_d2; -// CHECK-NEXT: double _r0 = _r_d2 * clad::pop(_t11); +// CHECK-NEXT: double _r0 = _r_d2 * j; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = i * _r_d2; // CHECK-NEXT: * _d_j += _r1; @@ -1287,12 +1267,10 @@ double fn16(double i, double j) { // CHECK-NEXT: int _d_ii = 0; // CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: clad::tape _t3 = {}; -// CHECK-NEXT: clad::tape _t4 = {}; -// CHECK-NEXT: clad::tape _t5 = {}; -// CHECK-NEXT: clad::tape _t7 = {}; +// CHECK-NEXT: clad::tape _t4 = {}; +// CHECK-NEXT: clad::tape _t6 = {}; +// CHECK-NEXT: clad::tape _t7 = {}; // CHECK-NEXT: clad::tape _t8 = {}; -// CHECK-NEXT: clad::tape _t9 = {}; -// CHECK-NEXT: clad::tape _t10 = {}; // CHECK-NEXT: int counter = 5; // CHECK-NEXT: double res = 0; // CHECK-NEXT: _t0 = 0; @@ -1302,54 +1280,54 @@ double fn16(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: if (_t1) { // CHECK-NEXT: clad::push(_t3, res); -// CHECK-NEXT: res += i * clad::push(_t4, j); +// CHECK-NEXT: res += i * j; // CHECK-NEXT: { -// CHECK-NEXT: clad::push(_t5, 1UL); +// CHECK-NEXT: clad::push(_t4, 1UL); // CHECK-NEXT: break; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: clad::push(_t2, _t1); // CHECK-NEXT: } -// CHECK-NEXT: bool _t6 = ii > 2; +// CHECK-NEXT: bool _t5 = ii > 2; // CHECK-NEXT: { -// CHECK-NEXT: if (_t6) { -// CHECK-NEXT: clad::push(_t8, res); -// CHECK-NEXT: res += 2 * clad::push(_t9, i); +// CHECK-NEXT: if (_t5) { +// CHECK-NEXT: clad::push(_t7, res); +// CHECK-NEXT: res += 2 * i; // CHECK-NEXT: { -// CHECK-NEXT: clad::push(_t5, 2UL); +// CHECK-NEXT: clad::push(_t4, 2UL); // CHECK-NEXT: continue; // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t7, _t6); +// CHECK-NEXT: clad::push(_t6, _t5); // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t10, res); +// CHECK-NEXT: clad::push(_t8, res); // CHECK-NEXT: res += i + j; -// CHECK-NEXT: clad::push(_t5, 3UL); +// CHECK-NEXT: clad::push(_t4, 3UL); // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += 1; // CHECK-NEXT: for (; _t0; _t0--) -// CHECK-NEXT: switch (clad::pop(_t5)) { +// CHECK-NEXT: switch (clad::pop(_t4)) { // CHECK-NEXT: case 3UL: // CHECK-NEXT: ; // CHECK-NEXT: --ii; // CHECK-NEXT: { -// CHECK-NEXT: res = clad::pop(_t10); +// CHECK-NEXT: res = clad::pop(_t8); // CHECK-NEXT: double _r_d2 = _d_res; // CHECK-NEXT: _d_res += _r_d2; // CHECK-NEXT: * _d_i += _r_d2; // CHECK-NEXT: * _d_j += _r_d2; // CHECK-NEXT: _d_res -= _r_d2; // CHECK-NEXT: } -// CHECK-NEXT: if (clad::pop(_t7)) { +// CHECK-NEXT: if (clad::pop(_t6)) { // CHECK-NEXT: case 2UL: // CHECK-NEXT: ; // CHECK-NEXT: { -// CHECK-NEXT: res = clad::pop(_t8); +// CHECK-NEXT: res = clad::pop(_t7); // CHECK-NEXT: double _r_d1 = _d_res; // CHECK-NEXT: _d_res += _r_d1; -// CHECK-NEXT: double _r2 = _r_d1 * clad::pop(_t9); +// CHECK-NEXT: double _r2 = _r_d1 * i; // CHECK-NEXT: double _r3 = 2 * _r_d1; // CHECK-NEXT: * _d_i += _r3; // CHECK-NEXT: _d_res -= _r_d1; @@ -1362,7 +1340,7 @@ double fn16(double i, double j) { // CHECK-NEXT: res = clad::pop(_t3); // CHECK-NEXT: double _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; -// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t4); +// CHECK-NEXT: double _r0 = _r_d0 * j; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_j += _r1; @@ -1405,12 +1383,8 @@ double fn17(double i, double j) { // CHECK-NEXT: clad::tape _t5 = {}; // CHECK-NEXT: clad::tape _t7 = {}; // CHECK-NEXT: clad::tape _t8 = {}; -// CHECK-NEXT: clad::tape _t9 = {}; -// CHECK-NEXT: clad::tape _t10 = {}; -// CHECK-NEXT: clad::tape _t11 = {}; -// CHECK-NEXT: clad::tape _t12 = {}; -// CHECK-NEXT: clad::tape _t13 = {}; -// CHECK-NEXT: clad::tape _t14 = {}; +// CHECK-NEXT: clad::tape _t9 = {}; +// CHECK-NEXT: clad::tape _t10 = {}; // CHECK-NEXT: int counter = 5; // CHECK-NEXT: double res = 0; // CHECK-NEXT: _t0 = 0; @@ -1433,22 +1407,22 @@ double fn17(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: if (_t6) { // CHECK-NEXT: clad::push(_t8, res); -// CHECK-NEXT: res += i * clad::push(_t9, j); +// CHECK-NEXT: res += i * j; // CHECK-NEXT: { -// CHECK-NEXT: clad::push(_t10, 1UL); +// CHECK-NEXT: clad::push(_t9, 1UL); // CHECK-NEXT: break; // CHECK-NEXT: } // CHECK-NEXT: } else { // CHECK-NEXT: { -// CHECK-NEXT: clad::push(_t10, 2UL); +// CHECK-NEXT: clad::push(_t9, 2UL); // CHECK-NEXT: continue; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: clad::push(_t7, _t6); // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t11, res); -// CHECK-NEXT: res += i * clad::push(_t14, i) * clad::push(_t13, j) * clad::push(_t12, j); -// CHECK-NEXT: clad::push(_t10, 3UL); +// CHECK-NEXT: clad::push(_t10, res); +// CHECK-NEXT: res += i * i * j * j; +// CHECK-NEXT: clad::push(_t9, 3UL); // CHECK-NEXT: } // CHECK-NEXT: clad::push(_t4, 2UL); // CHECK-NEXT: } @@ -1463,22 +1437,22 @@ double fn17(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: while (clad::back(_t5)) // CHECK-NEXT: { -// CHECK-NEXT: switch (clad::pop(_t10)) { +// CHECK-NEXT: switch (clad::pop(_t9)) { // CHECK-NEXT: case 3UL: // CHECK-NEXT: ; // CHECK-NEXT: { -// CHECK-NEXT: res = clad::pop(_t11); +// CHECK-NEXT: res = clad::pop(_t10); // CHECK-NEXT: double _r_d1 = _d_res; // CHECK-NEXT: _d_res += _r_d1; -// CHECK-NEXT: double _r2 = _r_d1 * clad::pop(_t12); -// CHECK-NEXT: double _r3 = _r2 * clad::pop(_t13); -// CHECK-NEXT: double _r4 = _r3 * clad::pop(_t14); +// CHECK-NEXT: double _r2 = _r_d1 * j; +// CHECK-NEXT: double _r3 = _r2 * j; +// CHECK-NEXT: double _r4 = _r3 * i; // CHECK-NEXT: * _d_i += _r4; // CHECK-NEXT: double _r5 = i * _r3; // CHECK-NEXT: * _d_i += _r5; -// CHECK-NEXT: double _r6 = i * clad::push(_t14, i) * _r2; +// CHECK-NEXT: double _r6 = i * i * _r2; // CHECK-NEXT: * _d_j += _r6; -// CHECK-NEXT: double _r7 = i * clad::push(_t14, i) * clad::push(_t13, j) * _r_d1; +// CHECK-NEXT: double _r7 = i * i * j * _r_d1; // CHECK-NEXT: * _d_j += _r7; // CHECK-NEXT: _d_res -= _r_d1; // CHECK-NEXT: } @@ -1489,7 +1463,7 @@ double fn17(double i, double j) { // CHECK-NEXT: res = clad::pop(_t8); // CHECK-NEXT: double _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; -// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t9); +// CHECK-NEXT: double _r0 = _r_d0 * j; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_j += _r1; @@ -1540,8 +1514,6 @@ double fn18(double i, double j) { // CHECK-NEXT: clad::tape _t5 = {}; // CHECK-NEXT: clad::tape _t6 = {}; // CHECK-NEXT: clad::tape _t7 = {}; -// CHECK-NEXT: clad::tape _t8 = {}; -// CHECK-NEXT: clad::tape _t9 = {}; // CHECK-NEXT: int choice = 5; // CHECK-NEXT: double res = 0; // CHECK-NEXT: _t0 = 0; @@ -1560,7 +1532,7 @@ double fn18(double i, double j) { // CHECK-NEXT: continue; // CHECK-NEXT: } else { // CHECK-NEXT: clad::push(_t7, res); -// CHECK-NEXT: res += 2 * clad::push(_t8, i) + 2 * clad::push(_t9, j); +// CHECK-NEXT: res += 2 * i + 2 * j; // CHECK-NEXT: { // CHECK-NEXT: clad::push(_t6, 2UL); // CHECK-NEXT: break; @@ -1598,10 +1570,10 @@ double fn18(double i, double j) { // CHECK-NEXT: res = clad::pop(_t7); // CHECK-NEXT: double _r_d1 = _d_res; // CHECK-NEXT: _d_res += _r_d1; -// CHECK-NEXT: double _r0 = _r_d1 * clad::pop(_t8); +// CHECK-NEXT: double _r0 = _r_d1 * i; // CHECK-NEXT: double _r1 = 2 * _r_d1; // CHECK-NEXT: * _d_i += _r1; -// CHECK-NEXT: double _r2 = _r_d1 * clad::pop(_t9); +// CHECK-NEXT: double _r2 = _r_d1 * j; // CHECK-NEXT: double _r3 = 2 * _r_d1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: _d_res -= _r_d1; @@ -1672,8 +1644,6 @@ double f_loop_init_var(double lower, double upper) { // CHECK-NEXT: double _d_x = 0; // CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: clad::tape _t3 = {}; -// CHECK-NEXT: clad::tape _t4 = {}; -// CHECK-NEXT: clad::tape _t5 = {}; // CHECK-NEXT: double sum = 0; // CHECK-NEXT: double num_points = 10000; // CHECK-NEXT: _t0 = num_points; @@ -1682,7 +1652,7 @@ double f_loop_init_var(double lower, double upper) { // CHECK-NEXT: for (double x = lower; x <= upper; clad::push(_t2, x) , (x += interval)) { // CHECK-NEXT: _t1++; // CHECK-NEXT: clad::push(_t3, sum); -// CHECK-NEXT: sum += x * clad::push(_t5, x) * clad::push(_t4, interval); +// CHECK-NEXT: sum += x * x * interval; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: @@ -1700,12 +1670,12 @@ double f_loop_init_var(double lower, double upper) { // CHECK-NEXT: sum = clad::pop(_t3); // CHECK-NEXT: double _r_d1 = _d_sum; // CHECK-NEXT: _d_sum += _r_d1; -// CHECK-NEXT: double _r2 = _r_d1 * clad::pop(_t4); -// CHECK-NEXT: double _r3 = _r2 * clad::pop(_t5); +// CHECK-NEXT: double _r2 = _r_d1 * interval; +// CHECK-NEXT: double _r3 = _r2 * x; // CHECK-NEXT: _d_x += _r3; // CHECK-NEXT: double _r4 = x * _r2; // CHECK-NEXT: _d_x += _r4; -// CHECK-NEXT: double _r5 = x * clad::push(_t5, x) * _r_d1; +// CHECK-NEXT: double _r5 = x * x * _r_d1; // CHECK-NEXT: _d_interval += _r5; // CHECK-NEXT: _d_sum -= _r_d1; // CHECK-NEXT: } diff --git a/test/Gradient/MemberFunctions.C b/test/Gradient/MemberFunctions.C index 4b78f33ae..cac4a8c18 100644 --- a/test/Gradient/MemberFunctions.C +++ b/test/Gradient/MemberFunctions.C @@ -23,19 +23,15 @@ public: double mem_fn(double i, double j) { return (x + y) * i + i * j; } // CHECK: void mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -45,19 +41,15 @@ public: double const_mem_fn(double i, double j) const { return (x + y) * i + i * j; } // CHECK: void const_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -69,19 +61,15 @@ public: } // CHECK: void volatile_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) volatile { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -93,19 +81,15 @@ public: } // CHECK: void const_volatile_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const volatile { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -115,19 +99,15 @@ public: double lval_ref_mem_fn(double i, double j) & { return (x + y) * i + i * j; } // CHECK: void lval_ref_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) & { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -139,19 +119,15 @@ public: } // CHECK: void const_lval_ref_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const & { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -163,19 +139,15 @@ public: } // CHECK: void volatile_lval_ref_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) volatile & { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -187,19 +159,15 @@ public: } // CHECK: void const_volatile_lval_ref_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const volatile & { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -209,19 +177,15 @@ public: double rval_ref_mem_fn(double i, double j) && { return (x + y) * i + i * j; } // CHECK: void rval_ref_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) && { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -233,19 +197,15 @@ public: } // CHECK: void const_rval_ref_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const && { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -257,19 +217,15 @@ public: } // CHECK: void volatile_rval_ref_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) volatile && { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -281,19 +237,15 @@ public: } // CHECK: void const_volatile_rval_ref_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const volatile && { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -305,19 +257,15 @@ public: } // CHECK: void noexcept_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) noexcept { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -329,19 +277,15 @@ public: } // CHECK: void const_noexcept_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const noexcept { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -353,19 +297,15 @@ public: } // CHECK: void volatile_noexcept_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) volatile noexcept { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -377,19 +317,15 @@ public: } // CHECK: void const_volatile_noexcept_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const volatile noexcept { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -401,19 +337,15 @@ public: } // CHECK: void lval_ref_noexcept_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) & noexcept { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -425,19 +357,15 @@ public: } // CHECK: void const_lval_ref_noexcept_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const & noexcept { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -449,19 +377,15 @@ public: } // CHECK: void volatile_lval_ref_noexcept_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) volatile & noexcept { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -473,19 +397,15 @@ public: } // CHECK: void const_volatile_lval_ref_noexcept_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const volatile & noexcept { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -497,19 +417,15 @@ public: } // CHECK: void rval_ref_noexcept_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) && noexcept { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -521,19 +437,15 @@ public: } // CHECK: void const_rval_ref_noexcept_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const && noexcept { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -545,19 +457,15 @@ public: } // CHECK: void volatile_rval_ref_noexcept_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) volatile && noexcept { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -569,19 +477,15 @@ public: } // CHECK: void const_volatile_rval_ref_noexcept_mem_fn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const volatile && noexcept { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; @@ -592,19 +496,15 @@ public: // CHECK: void partial_mem_fn_grad_0(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i) { // CHECK-NEXT: double _d_j = 0; - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: _d_j += _r3; @@ -657,19 +557,15 @@ double fn(double i,double j) { } // CHECK: void fn_grad(double i, double j, clad::array_ref _d_i, clad::array_ref _d_j) { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 1 * _t0; -// CHECK-NEXT: double _r1 = _r0 * _t1; +// CHECK-NEXT: double _r0 = 1 * j; +// CHECK-NEXT: double _r1 = _r0 * i; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: double _r2 = i * _r0; // CHECK-NEXT: * _d_i += _r2; -// CHECK-NEXT: double _r3 = i * _t1 * 1; +// CHECK-NEXT: double _r3 = i * i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -864,19 +760,15 @@ int main() { // CHECK: void const_volatile_lval_ref_mem_fn_grad_0(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i) const volatile & { // CHECK-NEXT: double _d_j = 0; - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: _d_j += _r3; @@ -887,19 +779,15 @@ int main() { // CHECK: void const_volatile_rval_ref_mem_fn_grad_1(double i, double j, clad::array_ref _d_this, clad::array_ref _d_j) const volatile && { // CHECK-NEXT: double _d_i = 0; - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; + // CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t1; + // CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; diff --git a/test/Gradient/Pointers.C b/test/Gradient/Pointers.C index 22ec72a94..199c3041e 100644 --- a/test/Gradient/Pointers.C +++ b/test/Gradient/Pointers.C @@ -10,12 +10,10 @@ double nonMemFn(double i) { return i*i; } // CHECK: void nonMemFn_grad(double i, clad::array_ref _d_i) { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: _t0 = i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 1 * _t0; +// CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = i * 1; // CHECK-NEXT: * _d_i += _r1; diff --git a/test/Gradient/TemplateFunctors.C b/test/Gradient/TemplateFunctors.C index f4b511d2e..2cbb65eeb 100644 --- a/test/Gradient/TemplateFunctors.C +++ b/test/Gradient/TemplateFunctors.C @@ -15,23 +15,17 @@ template struct Experiment { }; // CHECK: void operator_call_grad(double i, double j, clad::array_ref > _d_this, clad::array_ref _d_i, clad::array_ref _d_j) { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t2 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 1 * _t0; -// CHECK-NEXT: double _r1 = _r0 * _t1; +// CHECK-NEXT: double _r0 = 1 * i; +// CHECK-NEXT: double _r1 = _r0 * i; // CHECK-NEXT: (* _d_this).x += _r1; // CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; -// CHECK-NEXT: double _r3 = this->x * _t1 * 1; +// CHECK-NEXT: double _r3 = this->x * i * 1; // CHECK-NEXT: * _d_i += _r3; -// CHECK-NEXT: double _r4 = 1 * _t2; +// CHECK-NEXT: double _r4 = 1 * j; // CHECK-NEXT: (* _d_this).y += _r4; // CHECK-NEXT: double _r5 = this->y * 1; // CHECK-NEXT: * _d_j += _r5; @@ -49,35 +43,25 @@ template <> struct Experiment { }; // CHECK: void operator_call_grad(long double i, long double j, clad::array_ref > _d_this, clad::array_ref _d_i, clad::array_ref _d_j) { -// CHECK-NEXT: long double _t0; -// CHECK-NEXT: long double _t1; -// CHECK-NEXT: long double _t2; -// CHECK-NEXT: long double _t3; -// CHECK-NEXT: long double _t4; -// CHECK-NEXT: _t2 = i; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t0 = j; -// CHECK-NEXT: _t4 = j; -// CHECK-NEXT: _t3 = i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: long double _r0 = 1 * _t0; -// CHECK-NEXT: long double _r1 = _r0 * _t1; -// CHECK-NEXT: long double _r2 = _r1 * _t2; +// CHECK-NEXT: long double _r0 = 1 * j; +// CHECK-NEXT: long double _r1 = _r0 * i; +// CHECK-NEXT: long double _r2 = _r1 * i; // CHECK-NEXT: (* _d_this).x += _r2; // CHECK-NEXT: long double _r3 = this->x * _r1; // CHECK-NEXT: * _d_i += _r3; -// CHECK-NEXT: long double _r4 = this->x * _t2 * _r0; +// CHECK-NEXT: long double _r4 = this->x * i * _r0; // CHECK-NEXT: * _d_i += _r4; -// CHECK-NEXT: long double _r5 = this->x * _t2 * _t1 * 1; +// CHECK-NEXT: long double _r5 = this->x * i * i * 1; // CHECK-NEXT: * _d_j += _r5; -// CHECK-NEXT: long double _r6 = 1 * _t3; -// CHECK-NEXT: long double _r7 = _r6 * _t4; +// CHECK-NEXT: long double _r6 = 1 * i; +// CHECK-NEXT: long double _r7 = _r6 * j; // CHECK-NEXT: (* _d_this).y += _r7; // CHECK-NEXT: long double _r8 = this->y * _r6; // CHECK-NEXT: * _d_j += _r8; -// CHECK-NEXT: long double _r9 = this->y * _t4 * 1; +// CHECK-NEXT: long double _r9 = this->y * j * 1; // CHECK-NEXT: * _d_i += _r9; // CHECK-NEXT: } // CHECK-NEXT: } @@ -91,23 +75,17 @@ template struct ExperimentConstVolatile { }; // CHECK: void operator_call_grad(double i, double j, clad::array_ref > _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const volatile { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t2 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 1 * _t0; -// CHECK-NEXT: double _r1 = _r0 * _t1; +// CHECK-NEXT: double _r0 = 1 * i; +// CHECK-NEXT: double _r1 = _r0 * i; // CHECK-NEXT: (* _d_this).x += _r1; // CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; -// CHECK-NEXT: double _r3 = this->x * _t1 * 1; +// CHECK-NEXT: double _r3 = this->x * i * 1; // CHECK-NEXT: * _d_i += _r3; -// CHECK-NEXT: double _r4 = 1 * _t2; +// CHECK-NEXT: double _r4 = 1 * j; // CHECK-NEXT: (* _d_this).y += _r4; // CHECK-NEXT: double _r5 = this->y * 1; // CHECK-NEXT: * _d_j += _r5; @@ -125,35 +103,25 @@ template <> struct ExperimentConstVolatile { }; // CHECK: void operator_call_grad(long double i, long double j, clad::array_ref > _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const volatile { -// CHECK-NEXT: long double _t0; -// CHECK-NEXT: long double _t1; -// CHECK-NEXT: long double _t2; -// CHECK-NEXT: long double _t3; -// CHECK-NEXT: long double _t4; -// CHECK-NEXT: _t2 = i; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t0 = j; -// CHECK-NEXT: _t4 = j; -// CHECK-NEXT: _t3 = i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: long double _r0 = 1 * _t0; -// CHECK-NEXT: long double _r1 = _r0 * _t1; -// CHECK-NEXT: long double _r2 = _r1 * _t2; +// CHECK-NEXT: long double _r0 = 1 * j; +// CHECK-NEXT: long double _r1 = _r0 * i; +// CHECK-NEXT: long double _r2 = _r1 * i; // CHECK-NEXT: (* _d_this).x += _r2; // CHECK-NEXT: long double _r3 = this->x * _r1; // CHECK-NEXT: * _d_i += _r3; -// CHECK-NEXT: long double _r4 = this->x * _t2 * _r0; +// CHECK-NEXT: long double _r4 = this->x * i * _r0; // CHECK-NEXT: * _d_i += _r4; -// CHECK-NEXT: long double _r5 = this->x * _t2 * _t1 * 1; +// CHECK-NEXT: long double _r5 = this->x * i * i * 1; // CHECK-NEXT: * _d_j += _r5; -// CHECK-NEXT: long double _r6 = 1 * _t3; -// CHECK-NEXT: long double _r7 = _r6 * _t4; +// CHECK-NEXT: long double _r6 = 1 * i; +// CHECK-NEXT: long double _r7 = _r6 * j; // CHECK-NEXT: (* _d_this).y += _r7; // CHECK-NEXT: long double _r8 = this->y * _r6; // CHECK-NEXT: * _d_j += _r8; -// CHECK-NEXT: long double _r9 = this->y * _t4 * 1; +// CHECK-NEXT: long double _r9 = this->y * j * 1; // CHECK-NEXT: * _d_i += _r9; // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/Gradient/TestTypeConversion.C b/test/Gradient/TestTypeConversion.C index d51630880..bccbf2d91 100644 --- a/test/Gradient/TestTypeConversion.C +++ b/test/Gradient/TestTypeConversion.C @@ -22,12 +22,11 @@ void fn_type_conversion_grad(float z, int a, clad::array_ref _d_z, clad:: // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: int _d_i = 0; // CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: for (int i = 1; i < a; i++) { // CHECK-NEXT: _t0++; // CHECK-NEXT: clad::push(_t1, z); -// CHECK-NEXT: z = z * clad::push(_t2, a); +// CHECK-NEXT: z = z * a; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: @@ -37,7 +36,7 @@ void fn_type_conversion_grad(float z, int a, clad::array_ref _d_z, clad:: // CHECK-NEXT: { // CHECK-NEXT: z = clad::pop(_t1); // CHECK-NEXT: float _r_d0 = * _d_z; -// CHECK-NEXT: float _r0 = _r_d0 * clad::pop(_t2); +// CHECK-NEXT: float _r0 = _r_d0 * a; // CHECK-NEXT: * _d_z += _r0; // CHECK-NEXT: float _r1 = z * _r_d0; // CHECK-NEXT: * _d_a += _r1; diff --git a/test/Gradient/UserDefinedTypes.C b/test/Gradient/UserDefinedTypes.C index 26c1b83ad..0661a7060 100644 --- a/test/Gradient/UserDefinedTypes.C +++ b/test/Gradient/UserDefinedTypes.C @@ -20,21 +20,17 @@ double fn1(pairdd p, double i) { } // CHECK: void fn1_grad(pairdd p, double i, clad::array_ref _d_p, clad::array_ref _d_i) { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; // CHECK-NEXT: double _d_res = 0; -// CHECK-NEXT: _t0 = p.second; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: double res = p.first + 2 * _t0 + 3 * _t1; +// CHECK-NEXT: double res = p.first + 2 * p.second + 3 * i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += 1; // CHECK-NEXT: { // CHECK-NEXT: (* _d_p).first += _d_res; -// CHECK-NEXT: double _r0 = _d_res * _t0; +// CHECK-NEXT: double _r0 = _d_res * p.second; // CHECK-NEXT: double _r1 = 2 * _d_res; // CHECK-NEXT: (* _d_p).second += _r1; -// CHECK-NEXT: double _r2 = _d_res * _t1; +// CHECK-NEXT: double _r2 = _d_res * i; // CHECK-NEXT: double _r3 = 3 * _d_res; // CHECK-NEXT: * _d_i += _r3; // CHECK-NEXT: } @@ -130,12 +126,10 @@ double fn2(Tangent t, double i) { // CHECK-NEXT: Tangent _t0; // CHECK-NEXT: double _d_res = 0; // CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t3; // CHECK-NEXT: _t0 = t; // CHECK-NEXT: double res = sum(t); // CHECK-NEXT: _t1 = res; -// CHECK-NEXT: _t3 = t.data[0]; -// CHECK-NEXT: res += sum(t.data) + i + 2 * _t3; +// CHECK-NEXT: res += sum(t.data) + i + 2 * t.data[0]; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += 1; @@ -147,7 +141,7 @@ double fn2(Tangent t, double i) { // CHECK-NEXT: sum_pullback(t.data, _r_d0, _t2); // CHECK-NEXT: clad::array _r1({(* _d_t).data, 5UL}); // CHECK-NEXT: * _d_i += _r_d0; -// CHECK-NEXT: double _r2 = _r_d0 * _t3; +// CHECK-NEXT: double _r2 = _r_d0 * t.data[0]; // CHECK-NEXT: double _r3 = 2 * _r_d0; // CHECK-NEXT: (* _d_t).data[0] += _r3; // CHECK-NEXT: _d_res -= _r_d0; @@ -170,33 +164,27 @@ double fn3(double i, double j) { // CHECK-NEXT: Tangent _d_t({}); // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; -// CHECK-NEXT: double _t4; -// CHECK-NEXT: Tangent _t5; +// CHECK-NEXT: Tangent _t2; // CHECK-NEXT: Tangent t; // CHECK-NEXT: _t0 = t.data[0]; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: t.data[0] = 2 * _t1; -// CHECK-NEXT: _t2 = t.data[1]; -// CHECK-NEXT: _t3 = i; -// CHECK-NEXT: _t4 = j; -// CHECK-NEXT: t.data[1] = 5 * _t3 + 3 * _t4; -// CHECK-NEXT: _t5 = t; +// CHECK-NEXT: t.data[0] = 2 * i; +// CHECK-NEXT: _t1 = t.data[1]; +// CHECK-NEXT: t.data[1] = 5 * i + 3 * j; +// CHECK-NEXT: _t2 = t; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: t = _t5; -// CHECK-NEXT: sum_pullback(_t5, 1, &_d_t); +// CHECK-NEXT: t = _t2; +// CHECK-NEXT: sum_pullback(_t2, 1, &_d_t); // CHECK-NEXT: Tangent _r6 = _d_t; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: t.data[1] = _t2; +// CHECK-NEXT: t.data[1] = _t1; // CHECK-NEXT: double _r_d1 = _d_t.data[1]; -// CHECK-NEXT: double _r2 = _r_d1 * _t3; +// CHECK-NEXT: double _r2 = _r_d1 * i; // CHECK-NEXT: double _r3 = 5 * _r_d1; // CHECK-NEXT: * _d_i += _r3; -// CHECK-NEXT: double _r4 = _r_d1 * _t4; +// CHECK-NEXT: double _r4 = _r_d1 * j; // CHECK-NEXT: double _r5 = 3 * _r_d1; // CHECK-NEXT: * _d_j += _r5; // CHECK-NEXT: _d_t.data[1] -= _r_d1; @@ -204,7 +192,7 @@ double fn3(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: t.data[0] = _t0; // CHECK-NEXT: double _r_d0 = _d_t.data[0]; -// CHECK-NEXT: double _r0 = _r_d0 * _t1; +// CHECK-NEXT: double _r0 = _r_d0 * i; // CHECK-NEXT: double _r1 = 2 * _r_d0; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: _d_t.data[0] -= _r_d0; @@ -220,32 +208,24 @@ double fn4(double i, double j) { // CHECK: void fn4_grad(double i, double j, clad::array_ref _d_i, clad::array_ref _d_j) { // CHECK-NEXT: pairdd _d_p({}); // CHECK-NEXT: pairdd _d_q({}); -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; // CHECK-NEXT: pairdd p(1, 3); // CHECK-NEXT: pairdd q({7, 5}); -// CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t1 = j; -// CHECK-NEXT: _t2 = i; -// CHECK-NEXT: _t3 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 1 * _t0; +// CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: _d_p.first += _r0; // CHECK-NEXT: double _r1 = p.first * 1; // CHECK-NEXT: * _d_i += _r1; -// CHECK-NEXT: double _r2 = 1 * _t1; +// CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: _d_p.second += _r2; // CHECK-NEXT: double _r3 = p.second * 1; // CHECK-NEXT: * _d_j += _r3; -// CHECK-NEXT: double _r4 = 1 * _t2; +// CHECK-NEXT: double _r4 = 1 * i; // CHECK-NEXT: _d_q.first += _r4; // CHECK-NEXT: double _r5 = q.first * 1; // CHECK-NEXT: * _d_i += _r5; -// CHECK-NEXT: double _r6 = 1 * _t3; +// CHECK-NEXT: double _r6 = 1 * j; // CHECK-NEXT: _d_q.second += _r6; // CHECK-NEXT: double _r7 = q.second * 1; // CHECK-NEXT: * _d_j += _r7; @@ -253,29 +233,21 @@ double fn4(double i, double j) { // CHECK-NEXT: } // CHECK: void someMemFn_grad(double i, double j, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; -// CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t1 = j; -// CHECK-NEXT: _t2 = this->data[2]; -// CHECK-NEXT: _t3 = this->data[4]; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 1 * _t0; +// CHECK-NEXT: double _r0 = 1 * i; // CHECK-NEXT: (* _d_this).data[0] += _r0; // CHECK-NEXT: double _r1 = this->data[0] * 1; // CHECK-NEXT: * _d_i += _r1; -// CHECK-NEXT: double _r2 = 1 * _t1; +// CHECK-NEXT: double _r2 = 1 * j; // CHECK-NEXT: (* _d_this).data[1] += _r2; // CHECK-NEXT: double _r3 = this->data[1] * 1; // CHECK-NEXT: * _d_j += _r3; -// CHECK-NEXT: double _r4 = 1 * _t2; +// CHECK-NEXT: double _r4 = 1 * this->data[2]; // CHECK-NEXT: double _r5 = 3 * 1; // CHECK-NEXT: (* _d_this).data[2] += _r5; -// CHECK-NEXT: double _r6 = 1 * _t3; +// CHECK-NEXT: double _r6 = 1 * this->data[4]; // CHECK-NEXT: (* _d_this).data[3] += _r6; // CHECK-NEXT: double _r7 = this->data[3] * 1; // CHECK-NEXT: (* _d_this).data[4] += _r7; @@ -287,25 +259,19 @@ double fn5(const Tangent& t, double i) { } // CHECK: void someMemFn2_pullback(double i, double j, double _d_y, clad::array_ref _d_this, clad::array_ref _d_i, clad::array_ref _d_j) const { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t2 = i; -// CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = _d_y * _t0; +// CHECK-NEXT: double _r0 = _d_y * i; // CHECK-NEXT: (* _d_this).data[0] += _r0; // CHECK-NEXT: double _r1 = this->data[0] * _d_y; // CHECK-NEXT: * _d_i += _r1; -// CHECK-NEXT: double _r2 = _d_y * _t1; -// CHECK-NEXT: double _r3 = _r2 * _t2; +// CHECK-NEXT: double _r2 = _d_y * j; +// CHECK-NEXT: double _r3 = _r2 * i; // CHECK-NEXT: (* _d_this).data[1] += _r3; // CHECK-NEXT: double _r4 = this->data[1] * _r2; // CHECK-NEXT: * _d_i += _r4; -// CHECK-NEXT: double _r5 = this->data[1] * _t2 * _d_y; +// CHECK-NEXT: double _r5 = this->data[1] * i * _d_y; // CHECK-NEXT: * _d_j += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -359,54 +325,50 @@ double fn6(dcomplex c, double i) { // CHECK-NEXT: } // CHECK: void fn6_grad(dcomplex c, double i, clad::array_ref _d_c, clad::array_ref _d_i) { -// CHECK-NEXT: double _t0; +// CHECK-NEXT: dcomplex _t0; // CHECK-NEXT: dcomplex _t1; -// CHECK-NEXT: dcomplex _t2; -// CHECK-NEXT: double _t3; -// CHECK-NEXT: dcomplex _t4; -// CHECK-NEXT: double _t5; +// CHECK-NEXT: double _t2; +// CHECK-NEXT: dcomplex _t3; // CHECK-NEXT: double _d_res = 0; -// CHECK-NEXT: double _t6; -// CHECK-NEXT: double _t7; -// CHECK-NEXT: dcomplex _t8; -// CHECK-NEXT: _t0 = i; +// CHECK-NEXT: double _t4; +// CHECK-NEXT: double _t5; +// CHECK-NEXT: dcomplex _t6; +// CHECK-NEXT: _t0 = c; +// CHECK-NEXT: c.real(5 * i); // CHECK-NEXT: _t1 = c; -// CHECK-NEXT: c.real(5 * _t0); -// CHECK-NEXT: _t2 = c; -// CHECK-NEXT: _t4 = c; -// CHECK-NEXT: _t3 = c.imag(); -// CHECK-NEXT: _t5 = i; -// CHECK-NEXT: double res = c.real() + 3 * _t3 + 6 * _t5; -// CHECK-NEXT: _t6 = res; -// CHECK-NEXT: _t8 = c; -// CHECK-NEXT: _t7 = c.real(); -// CHECK-NEXT: res += 4 * _t7; +// CHECK-NEXT: _t3 = c; +// CHECK-NEXT: _t2 = c.imag(); +// CHECK-NEXT: double res = c.real() + 3 * _t2 + 6 * i; +// CHECK-NEXT: _t4 = res; +// CHECK-NEXT: _t6 = c; +// CHECK-NEXT: _t5 = c.real(); +// CHECK-NEXT: res += 4 * _t5; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += 1; // CHECK-NEXT: { -// CHECK-NEXT: res = _t6; +// CHECK-NEXT: res = _t4; // CHECK-NEXT: double _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; -// CHECK-NEXT: double _r7 = _r_d0 * _t7; +// CHECK-NEXT: double _r7 = _r_d0 * _t5; // CHECK-NEXT: double _r8 = 4 * _r_d0; -// CHECK-NEXT: _t8.real_pullback(_r8, &(* _d_c)); +// CHECK-NEXT: _t6.real_pullback(_r8, &(* _d_c)); // CHECK-NEXT: _d_res -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: _t2.real_pullback(_d_res, &(* _d_c)); -// CHECK-NEXT: double _r3 = _d_res * _t3; +// CHECK-NEXT: _t1.real_pullback(_d_res, &(* _d_c)); +// CHECK-NEXT: double _r3 = _d_res * _t2; // CHECK-NEXT: double _r4 = 3 * _d_res; -// CHECK-NEXT: _t4.imag_pullback(_r4, &(* _d_c)); -// CHECK-NEXT: double _r5 = _d_res * _t5; +// CHECK-NEXT: _t3.imag_pullback(_r4, &(* _d_c)); +// CHECK-NEXT: double _r5 = _d_res * i; // CHECK-NEXT: double _r6 = 6 * _d_res; // CHECK-NEXT: * _d_i += _r6; // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: {{.*}} _grad0 = 0.; -// CHECK-NEXT: _t1.real_pullback(5 * _t0, &(* _d_c), &_grad0); +// CHECK-NEXT: _t0.real_pullback(5 * i, &(* _d_c), &_grad0); // CHECK-NEXT: double _r0 = _grad0; -// CHECK-NEXT: double _r1 = _r0 * _t0; +// CHECK-NEXT: double _r1 = _r0 * i; // CHECK-NEXT: double _r2 = 5 * _r0; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: } diff --git a/test/Gradient/constexprTest.C b/test/Gradient/constexprTest.C index 6ca974e39..c874681da 100644 --- a/test/Gradient/constexprTest.C +++ b/test/Gradient/constexprTest.C @@ -13,22 +13,18 @@ constexpr double mul (double a, double b, double c) { } //CHECK: constexpr void mul_grad(double a, double b, double c, clad::array_ref _d_a, clad::array_ref _d_b, clad::array_ref _d_c) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; //CHECK-NEXT: double _d_result = 0; -//CHECK-NEXT: _t1 = b; -//CHECK-NEXT: _t0 = c; -//CHECK-NEXT: double result = a * _t1 * _t0; +//CHECK-NEXT: double result = a * b * c; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_result += 1; //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_result * _t0; -//CHECK-NEXT: double _r1 = _r0 * _t1; +//CHECK-NEXT: double _r0 = _d_result * c; +//CHECK-NEXT: double _r1 = _r0 * b; //CHECK-NEXT: * _d_a += _r1; //CHECK-NEXT: double _r2 = a * _r0; //CHECK-NEXT: * _d_b += _r2; -//CHECK-NEXT: double _r3 = a * _t1 * _d_result; +//CHECK-NEXT: double _r3 = a * b * _d_result; //CHECK-NEXT: * _d_c += _r3; //CHECK-NEXT: } //CHECK-NEXT: } @@ -42,33 +38,26 @@ constexpr double fn( double a, double b, double c) { //CHECK: constexpr void fn_grad(double a, double b, double c, clad::array_ref _d_a, clad::array_ref _d_b, clad::array_ref _d_c) { //CHECK-NEXT: double _d_val = 0; //CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; //CHECK-NEXT: double _d_result = 0; //CHECK-NEXT: double val = 98.; -//CHECK-NEXT: _t3 = b; -//CHECK-NEXT: _t2 = c; -//CHECK-NEXT: _t1 = (a + b); -//CHECK-NEXT: _t0 = 100; -//CHECK-NEXT: double result = a * _t3 / _t2 * _t1 * _t0 + c; +//CHECK-NEXT: _t0 = c; +//CHECK-NEXT: double result = a * b / _t0 * (a + b) * 100 + c; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_result += 1; //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_result * _t0; -//CHECK-NEXT: double _r1 = _r0 * _t1; -//CHECK-NEXT: double _r2 = _r1 / _t2; -//CHECK-NEXT: double _r3 = _r2 * _t3; +//CHECK-NEXT: double _r0 = _d_result * 100; +//CHECK-NEXT: double _r1 = _r0 * (a + b); +//CHECK-NEXT: double _r2 = _r1 / _t0; +//CHECK-NEXT: double _r3 = _r2 * b; //CHECK-NEXT: * _d_a += _r3; //CHECK-NEXT: double _r4 = a * _r2; //CHECK-NEXT: * _d_b += _r4; -//CHECK-NEXT: double _r5 = _r1 * -a * _t3 / (_t2 * _t2); +//CHECK-NEXT: double _r5 = _r1 * -a * b / (_t0 * _t0); //CHECK-NEXT: * _d_c += _r5; -//CHECK-NEXT: double _r6 = a * _t3 / _t2 * _r0; +//CHECK-NEXT: double _r6 = a * b / _t0 * _r0; //CHECK-NEXT: * _d_a += _r6; //CHECK-NEXT: * _d_b += _r6; -//CHECK-NEXT: double _r7 = a * _t3 / _t2 * _t1 * _d_result; //CHECK-NEXT: * _d_c += _d_result; //CHECK-NEXT: } //CHECK-NEXT:} diff --git a/test/Hessian/BuiltinDerivatives.C b/test/Hessian/BuiltinDerivatives.C index 17be5a1ab..0615d0000 100644 --- a/test/Hessian/BuiltinDerivatives.C +++ b/test/Hessian/BuiltinDerivatives.C @@ -21,14 +21,12 @@ float f1(float x) { // CHECK-NEXT: } // CHECK: void sin_pushforward_pullback(float x, float d_x, ValueAndPushforward _d_y, clad::array_ref _d_x, clad::array_ref _d_d_x) { -// CHECK-NEXT: float _t0; -// CHECK-NEXT: _t0 = d_x; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: float _r0 = _d_y.value * clad::custom_derivatives{{(::std)?}}::sin_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r0; -// CHECK-NEXT: float _r1 = _d_y.pushforward * _t0; +// CHECK-NEXT: float _r1 = _d_y.pushforward * d_x; // CHECK-NEXT: float _r2 = _r1 * clad::custom_derivatives{{(::std)?}}::cos_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r2; // CHECK-NEXT: float _r3 = ::std::cos(x) * _d_y.pushforward; @@ -38,20 +36,18 @@ float f1(float x) { // CHECK: void cos_pushforward_pullback(float x, float d_x, ValueAndPushforward _d_y, clad::array_ref _d_x, clad::array_ref _d_d_x) { // CHECK-NEXT: float _t0; -// CHECK-NEXT: float _t1; -// CHECK-NEXT: _t1 = ::std::sin(x); -// CHECK-NEXT: _t0 = d_x; +// CHECK-NEXT: _t0 = ::std::sin(x); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: float _r0 = _d_y.value * clad::custom_derivatives{{(::std)?}}::cos_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r0; -// CHECK-NEXT: float _r1 = _d_y.pushforward * _t0; -// CHECK-NEXT: float _r2 = _r1 * _t1; +// CHECK-NEXT: float _r1 = _d_y.pushforward * d_x; +// CHECK-NEXT: float _r2 = _r1 * _t0; // CHECK-NEXT: float _r3 = -1 * _r1; // CHECK-NEXT: float _r4 = _r3 * clad::custom_derivatives{{(::std)?}}::sin_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r4; -// CHECK-NEXT: float _r5 = -1 * _t1 * _d_y.pushforward; +// CHECK-NEXT: float _r5 = -1 * _t0 * _d_y.pushforward; // CHECK-NEXT: * _d_d_x += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -104,14 +100,12 @@ float f2(float x) { // CHECK-NEXT: } // CHECK: void exp_pushforward_pullback(float x, float d_x, ValueAndPushforward _d_y, clad::array_ref _d_x, clad::array_ref _d_d_x) { -// CHECK-NEXT: float _t0; -// CHECK-NEXT: _t0 = d_x; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: float _r0 = _d_y.value * clad::custom_derivatives{{(::std)?}}::exp_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r0; -// CHECK-NEXT: float _r1 = _d_y.pushforward * _t0; +// CHECK-NEXT: float _r1 = _d_y.pushforward * d_x; // CHECK-NEXT: float _r2 = _r1 * clad::custom_derivatives{{(::std)?}}::exp_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r2; // CHECK-NEXT: float _r3 = ::std::exp(x) * _d_y.pushforward; @@ -155,19 +149,17 @@ float f3(float x) { // CHECK: void log_pushforward_pullback(float x, float d_x, ValueAndPushforward _d_y, clad::array_ref _d_x, clad::array_ref _d_d_x) { // CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: _t1 = x; -// CHECK-NEXT: _t0 = d_x; +// CHECK-NEXT: _t0 = x; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: float _r0 = _d_y.value * clad::custom_derivatives{{(::std)?}}::log_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r0; -// CHECK-NEXT: double _r1 = _d_y.pushforward * _t0; -// CHECK-NEXT: double _r2 = _r1 / _t1; -// CHECK-NEXT: double _r3 = _r1 * -1. / (_t1 * _t1); +// CHECK-NEXT: double _r1 = _d_y.pushforward * d_x; +// CHECK-NEXT: double _r2 = _r1 / _t0; +// CHECK-NEXT: double _r3 = _r1 * -1. / (_t0 * _t0); // CHECK-NEXT: * _d_x += _r3; -// CHECK-NEXT: double _r4 = (1. / _t1) * _d_y.pushforward; +// CHECK-NEXT: double _r4 = (1. / _t0) * _d_y.pushforward; // CHECK-NEXT: * _d_d_x += _r4; // CHECK-NEXT: } // CHECK-NEXT: } @@ -209,22 +201,18 @@ float f4(float x) { // CHECK: void pow_pushforward_pullback(float x, float exponent, float d_x, float d_exponent, ValueAndPushforward _d_y, clad::array_ref _d_x, clad::array_ref _d_exponent, clad::array_ref _d_d_x, clad::array_ref _d_d_exponent) { // CHECK-NEXT: float _d_val = 0; // CHECK-NEXT: float _t0; -// CHECK-NEXT: float _t1; // CHECK-NEXT: float _d_derivative = 0; // CHECK-NEXT: float _cond0; +// CHECK-NEXT: float _t1; // CHECK-NEXT: float _t2; -// CHECK-NEXT: float _t3; -// CHECK-NEXT: float _t4; // CHECK-NEXT: float val = ::std::pow(x, exponent); -// CHECK-NEXT: _t1 = ::std::pow(x, exponent - 1); -// CHECK-NEXT: _t0 = d_x; -// CHECK-NEXT: float derivative = (exponent * _t1) * _t0; +// CHECK-NEXT: _t0 = ::std::pow(x, exponent - 1); +// CHECK-NEXT: float derivative = (exponent * _t0) * d_x; // CHECK-NEXT: _cond0 = d_exponent; // CHECK-NEXT: if (_cond0) { -// CHECK-NEXT: _t2 = derivative; -// CHECK-NEXT: _t4 = ::std::log(x); -// CHECK-NEXT: _t3 = d_exponent; -// CHECK-NEXT: derivative += (::std::pow(x, exponent) * _t4) * _t3; +// CHECK-NEXT: _t1 = derivative; +// CHECK-NEXT: _t2 = ::std::log(x); +// CHECK-NEXT: derivative += (::std::pow(x, exponent) * _t2) * d_exponent; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: @@ -233,11 +221,11 @@ float f4(float x) { // CHECK-NEXT: _d_derivative += _d_y.pushforward; // CHECK-NEXT: } // CHECK-NEXT: if (_cond0) { -// CHECK-NEXT: derivative = _t2; +// CHECK-NEXT: derivative = _t1; // CHECK-NEXT: float _r_d0 = _d_derivative; // CHECK-NEXT: _d_derivative += _r_d0; -// CHECK-NEXT: float _r8 = _r_d0 * _t3; -// CHECK-NEXT: float _r9 = _r8 * _t4; +// CHECK-NEXT: float _r8 = _r_d0 * d_exponent; +// CHECK-NEXT: float _r9 = _r8 * _t2; // CHECK-NEXT: float _grad4 = 0.F; // CHECK-NEXT: float _grad5 = 0.F; // CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(x, exponent, _r9, &_grad4, &_grad5); @@ -248,13 +236,13 @@ float f4(float x) { // CHECK-NEXT: float _r12 = ::std::pow(x, exponent) * _r8; // CHECK-NEXT: float _r13 = _r12 * clad::custom_derivatives{{(::std)?}}::log_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r13; -// CHECK-NEXT: float _r14 = (::std::pow(x, exponent) * _t4) * _r_d0; +// CHECK-NEXT: float _r14 = (::std::pow(x, exponent) * _t2) * _r_d0; // CHECK-NEXT: * _d_d_exponent += _r14; // CHECK-NEXT: _d_derivative -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: float _r2 = _d_derivative * _t0; -// CHECK-NEXT: float _r3 = _r2 * _t1; +// CHECK-NEXT: float _r2 = _d_derivative * d_x; +// CHECK-NEXT: float _r3 = _r2 * _t0; // CHECK-NEXT: * _d_exponent += _r3; // CHECK-NEXT: float _r4 = exponent * _r2; // CHECK-NEXT: float _grad2 = 0.F; @@ -264,7 +252,7 @@ float f4(float x) { // CHECK-NEXT: * _d_x += _r5; // CHECK-NEXT: float _r6 = _grad3; // CHECK-NEXT: * _d_exponent += _r6; -// CHECK-NEXT: float _r7 = (exponent * _t1) * _d_derivative; +// CHECK-NEXT: float _r7 = (exponent * _t0) * _d_derivative; // CHECK-NEXT: * _d_d_x += _r7; // CHECK-NEXT: } // CHECK-NEXT: { diff --git a/test/Hessian/Hessians.C b/test/Hessian/Hessians.C index 672de6474..c09b5d16c 100644 --- a/test/Hessian/Hessians.C +++ b/test/Hessian/Hessians.C @@ -15,74 +15,54 @@ void f_cubed_add1_darg0_grad(double a, double b, clad::array_ref _d_a, c //CHECK:void f_cubed_add1_darg0_grad(double a, double b, clad::array_ref _d_a, clad::array_ref _d_b) __attribute__((always_inline)) { //CHECK-NEXT: double _d__d_a = 0; //CHECK-NEXT: double _d__d_b = 0; -//CHECK-NEXT: double _t0; //CHECK-NEXT: double _d__t0 = 0; -//CHECK-NEXT: double _t1; //CHECK-NEXT: double _d__t1 = 0; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: double _t4; -//CHECK-NEXT: double _t5; -//CHECK-NEXT: double _t6; -//CHECK-NEXT: double _t7; -//CHECK-NEXT: double _t8; -//CHECK-NEXT: double _t9; //CHECK-NEXT: double _d_a0 = 1; //CHECK-NEXT: double _d_b0 = 0; -//CHECK-NEXT: _t0 = a; -//CHECK-NEXT: double _t00 = a * _t0; -//CHECK-NEXT: _t1 = b; -//CHECK-NEXT: double _t10 = b * _t1; -//CHECK-NEXT: _t3 = a; -//CHECK-NEXT: _t4 = _d_a0; -//CHECK-NEXT: _t2 = a; -//CHECK-NEXT: _t5 = _d_a0; -//CHECK-NEXT: _t7 = b; -//CHECK-NEXT: _t8 = _d_b0; -//CHECK-NEXT: _t6 = b; -//CHECK-NEXT: _t9 = _d_b0; +//CHECK-NEXT: double _t00 = a * a; +//CHECK-NEXT: double _t10 = b * b; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t2; -//CHECK-NEXT: double _r5 = _r4 * _t3; +//CHECK-NEXT: double _r4 = 1 * a; +//CHECK-NEXT: double _r5 = _r4 * a; //CHECK-NEXT: _d__d_a += _r5; //CHECK-NEXT: double _r6 = _d_a0 * _r4; //CHECK-NEXT: * _d_a += _r6; -//CHECK-NEXT: double _r7 = _r4 * _t4; +//CHECK-NEXT: double _r7 = _r4 * _d_a0; //CHECK-NEXT: * _d_a += _r7; //CHECK-NEXT: double _r8 = a * _r4; //CHECK-NEXT: _d__d_a += _r8; -//CHECK-NEXT: double _r9 = (_d_a0 * _t3 + a * _t4) * 1; +//CHECK-NEXT: double _r9 = (_d_a0 * a + a * _d_a0) * 1; //CHECK-NEXT: * _d_a += _r9; -//CHECK-NEXT: double _r10 = 1 * _t5; +//CHECK-NEXT: double _r10 = 1 * _d_a0; //CHECK-NEXT: _d__t0 += _r10; //CHECK-NEXT: double _r11 = _t00 * 1; //CHECK-NEXT: _d__d_a += _r11; -//CHECK-NEXT: double _r12 = 1 * _t6; -//CHECK-NEXT: double _r13 = _r12 * _t7; +//CHECK-NEXT: double _r12 = 1 * b; +//CHECK-NEXT: double _r13 = _r12 * b; //CHECK-NEXT: _d__d_b += _r13; //CHECK-NEXT: double _r14 = _d_b0 * _r12; //CHECK-NEXT: * _d_b += _r14; -//CHECK-NEXT: double _r15 = _r12 * _t8; +//CHECK-NEXT: double _r15 = _r12 * _d_b0; //CHECK-NEXT: * _d_b += _r15; //CHECK-NEXT: double _r16 = b * _r12; //CHECK-NEXT: _d__d_b += _r16; -//CHECK-NEXT: double _r17 = (_d_b0 * _t7 + b * _t8) * 1; +//CHECK-NEXT: double _r17 = (_d_b0 * b + b * _d_b0) * 1; //CHECK-NEXT: * _d_b += _r17; -//CHECK-NEXT: double _r18 = 1 * _t9; +//CHECK-NEXT: double _r18 = 1 * _d_b0; //CHECK-NEXT: _d__t1 += _r18; //CHECK-NEXT: double _r19 = _t10 * 1; //CHECK-NEXT: _d__d_b += _r19; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r2 = _d__t1 * _t1; +//CHECK-NEXT: double _r2 = _d__t1 * b; //CHECK-NEXT: * _d_b += _r2; //CHECK-NEXT: double _r3 = b * _d__t1; //CHECK-NEXT: * _d_b += _r3; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d__t0 * _t0; +//CHECK-NEXT: double _r0 = _d__t0 * a; //CHECK-NEXT: * _d_a += _r0; //CHECK-NEXT: double _r1 = a * _d__t0; //CHECK-NEXT: * _d_a += _r1; @@ -93,74 +73,54 @@ void f_cubed_add1_darg1_grad(double a, double b, clad::array_ref _d_a, c //CHECK:void f_cubed_add1_darg1_grad(double a, double b, clad::array_ref _d_a, clad::array_ref _d_b) __attribute__((always_inline)) { //CHECK-NEXT: double _d__d_a = 0; //CHECK-NEXT: double _d__d_b = 0; -//CHECK-NEXT: double _t0; //CHECK-NEXT: double _d__t0 = 0; -//CHECK-NEXT: double _t1; //CHECK-NEXT: double _d__t1 = 0; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: double _t4; -//CHECK-NEXT: double _t5; -//CHECK-NEXT: double _t6; -//CHECK-NEXT: double _t7; -//CHECK-NEXT: double _t8; -//CHECK-NEXT: double _t9; //CHECK-NEXT: double _d_a0 = 0; //CHECK-NEXT: double _d_b0 = 1; -//CHECK-NEXT: _t0 = a; -//CHECK-NEXT: double _t00 = a * _t0; -//CHECK-NEXT: _t1 = b; -//CHECK-NEXT: double _t10 = b * _t1; -//CHECK-NEXT: _t3 = a; -//CHECK-NEXT: _t4 = _d_a0; -//CHECK-NEXT: _t2 = a; -//CHECK-NEXT: _t5 = _d_a0; -//CHECK-NEXT: _t7 = b; -//CHECK-NEXT: _t8 = _d_b0; -//CHECK-NEXT: _t6 = b; -//CHECK-NEXT: _t9 = _d_b0; +//CHECK-NEXT: double _t00 = a * a; +//CHECK-NEXT: double _t10 = b * b; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t2; -//CHECK-NEXT: double _r5 = _r4 * _t3; +//CHECK-NEXT: double _r4 = 1 * a; +//CHECK-NEXT: double _r5 = _r4 * a; //CHECK-NEXT: _d__d_a += _r5; //CHECK-NEXT: double _r6 = _d_a0 * _r4; //CHECK-NEXT: * _d_a += _r6; -//CHECK-NEXT: double _r7 = _r4 * _t4; +//CHECK-NEXT: double _r7 = _r4 * _d_a0; //CHECK-NEXT: * _d_a += _r7; //CHECK-NEXT: double _r8 = a * _r4; //CHECK-NEXT: _d__d_a += _r8; -//CHECK-NEXT: double _r9 = (_d_a0 * _t3 + a * _t4) * 1; +//CHECK-NEXT: double _r9 = (_d_a0 * a + a * _d_a0) * 1; //CHECK-NEXT: * _d_a += _r9; -//CHECK-NEXT: double _r10 = 1 * _t5; +//CHECK-NEXT: double _r10 = 1 * _d_a0; //CHECK-NEXT: _d__t0 += _r10; //CHECK-NEXT: double _r11 = _t00 * 1; //CHECK-NEXT: _d__d_a += _r11; -//CHECK-NEXT: double _r12 = 1 * _t6; -//CHECK-NEXT: double _r13 = _r12 * _t7; +//CHECK-NEXT: double _r12 = 1 * b; +//CHECK-NEXT: double _r13 = _r12 * b; //CHECK-NEXT: _d__d_b += _r13; //CHECK-NEXT: double _r14 = _d_b0 * _r12; //CHECK-NEXT: * _d_b += _r14; -//CHECK-NEXT: double _r15 = _r12 * _t8; +//CHECK-NEXT: double _r15 = _r12 * _d_b0; //CHECK-NEXT: * _d_b += _r15; //CHECK-NEXT: double _r16 = b * _r12; //CHECK-NEXT: _d__d_b += _r16; -//CHECK-NEXT: double _r17 = (_d_b0 * _t7 + b * _t8) * 1; +//CHECK-NEXT: double _r17 = (_d_b0 * b + b * _d_b0) * 1; //CHECK-NEXT: * _d_b += _r17; -//CHECK-NEXT: double _r18 = 1 * _t9; +//CHECK-NEXT: double _r18 = 1 * _d_b0; //CHECK-NEXT: _d__t1 += _r18; //CHECK-NEXT: double _r19 = _t10 * 1; //CHECK-NEXT: _d__d_b += _r19; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r2 = _d__t1 * _t1; +//CHECK-NEXT: double _r2 = _d__t1 * b; //CHECK-NEXT: * _d_b += _r2; //CHECK-NEXT: double _r3 = b * _d__t1; //CHECK-NEXT: * _d_b += _r3; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d__t0 * _t0; +//CHECK-NEXT: double _r0 = _d__t0 * a; //CHECK-NEXT: * _d_a += _r0; //CHECK-NEXT: double _r1 = a * _d__t0; //CHECK-NEXT: * _d_a += _r1; diff --git a/test/Hessian/NestedFunctionCalls.C b/test/Hessian/NestedFunctionCalls.C index d848ff1c7..6518f4313 100644 --- a/test/Hessian/NestedFunctionCalls.C +++ b/test/Hessian/NestedFunctionCalls.C @@ -31,42 +31,30 @@ double f2(double x, double y){ // CHECK-NEXT: } // CHECK: void f_pushforward_pullback(double x, double y, double _d_x, double _d_y, clad::ValueAndPushforward _d_y0, clad::array_ref _d_x, clad::array_ref _d_y, clad::array_ref _d__d_x, clad::array_ref _d__d_y) { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; -// CHECK-NEXT: double _t4; -// CHECK-NEXT: double _t5; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t1 = y; -// CHECK-NEXT: _t2 = x; -// CHECK-NEXT: _t3 = _d_x; -// CHECK-NEXT: _t4 = y; -// CHECK-NEXT: _t5 = _d_y; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = _d_y0.value * _t0; +// CHECK-NEXT: double _r0 = _d_y0.value * x; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: double _r1 = x * _d_y0.value; // CHECK-NEXT: * _d_x += _r1; -// CHECK-NEXT: double _r2 = _d_y0.value * _t1; +// CHECK-NEXT: double _r2 = _d_y0.value * y; // CHECK-NEXT: * _d_y += _r2; // CHECK-NEXT: double _r3 = y * _d_y0.value; // CHECK-NEXT: * _d_y += _r3; -// CHECK-NEXT: double _r4 = _d_y0.pushforward * _t2; +// CHECK-NEXT: double _r4 = _d_y0.pushforward * x; // CHECK-NEXT: * _d__d_x += _r4; // CHECK-NEXT: double _r5 = _d_x * _d_y0.pushforward; // CHECK-NEXT: * _d_x += _r5; -// CHECK-NEXT: double _r6 = _d_y0.pushforward * _t3; +// CHECK-NEXT: double _r6 = _d_y0.pushforward * _d_x; // CHECK-NEXT: * _d_x += _r6; // CHECK-NEXT: double _r7 = x * _d_y0.pushforward; // CHECK-NEXT: * _d__d_x += _r7; -// CHECK-NEXT: double _r8 = _d_y0.pushforward * _t4; +// CHECK-NEXT: double _r8 = _d_y0.pushforward * y; // CHECK-NEXT: * _d__d_y += _r8; // CHECK-NEXT: double _r9 = _d_y * _d_y0.pushforward; // CHECK-NEXT: * _d_y += _r9; -// CHECK-NEXT: double _r10 = _d_y0.pushforward * _t5; +// CHECK-NEXT: double _r10 = _d_y0.pushforward * _d_y; // CHECK-NEXT: * _d_y += _r10; // CHECK-NEXT: double _r11 = y * _d_y0.pushforward; // CHECK-NEXT: * _d__d_y += _r11; diff --git a/test/Hessian/Pointers.C b/test/Hessian/Pointers.C index cf5f4883e..bfc2af21f 100644 --- a/test/Hessian/Pointers.C +++ b/test/Hessian/Pointers.C @@ -19,20 +19,16 @@ double nonMemFn(double i, double j) { // CHECK: void nonMemFn_darg0_grad(double i, double j, clad::array_ref _d_i, clad::array_ref _d_j) { // CHECK-NEXT: double _d__d_i = 0; // CHECK-NEXT: double _d__d_j = 0; -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; // CHECK-NEXT: double _d_i0 = 1; // CHECK-NEXT: double _d_j0 = 0; -// CHECK-NEXT: _t0 = j; -// CHECK-NEXT: _t1 = _d_j0; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 1 * _t0; +// CHECK-NEXT: double _r0 = 1 * j; // CHECK-NEXT: _d__d_i += _r0; // CHECK-NEXT: double _r1 = _d_i0 * 1; // CHECK-NEXT: * _d_j += _r1; -// CHECK-NEXT: double _r2 = 1 * _t1; +// CHECK-NEXT: double _r2 = 1 * _d_j0; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: _d__d_j += _r3; @@ -48,20 +44,16 @@ double nonMemFn(double i, double j) { // CHECK: void nonMemFn_darg1_grad(double i, double j, clad::array_ref _d_i, clad::array_ref _d_j) { // CHECK-NEXT: double _d__d_i = 0; // CHECK-NEXT: double _d__d_j = 0; -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; // CHECK-NEXT: double _d_i0 = 0; // CHECK-NEXT: double _d_j0 = 1; -// CHECK-NEXT: _t0 = j; -// CHECK-NEXT: _t1 = _d_j0; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 1 * _t0; +// CHECK-NEXT: double _r0 = 1 * j; // CHECK-NEXT: _d__d_i += _r0; // CHECK-NEXT: double _r1 = _d_i0 * 1; // CHECK-NEXT: * _d_j += _r1; -// CHECK-NEXT: double _r2 = 1 * _t1; +// CHECK-NEXT: double _r2 = 1 * _d_j0; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: _d__d_j += _r3; diff --git a/test/Jacobian/Functors.C b/test/Jacobian/Functors.C index c4db0d705..d3b0953f8 100644 --- a/test/Jacobian/Functors.C +++ b/test/Jacobian/Functors.C @@ -18,40 +18,28 @@ struct Experiment { } // CHECK: void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: double _t4; - // CHECK-NEXT: double _t5; - // CHECK-NEXT: _t2 = i; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * i * i * j; - // CHECK-NEXT: _t5 = i; - // CHECK-NEXT: _t4 = j; - // CHECK-NEXT: _t3 = j; // CHECK-NEXT: output[1] = this->y * i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: double _r6 = 1 * _t3; - // CHECK-NEXT: double _r7 = _r6 * _t4; - // CHECK-NEXT: double _r8 = _r7 * _t5; + // CHECK-NEXT: double _r6 = 1 * j; + // CHECK-NEXT: double _r7 = _r6 * j; + // CHECK-NEXT: double _r8 = _r7 * i; // CHECK-NEXT: double _r9 = this->y * _r7; // CHECK-NEXT: jacobianMatrix[2UL] += _r9; - // CHECK-NEXT: double _r10 = this->y * _t5 * _r6; + // CHECK-NEXT: double _r10 = this->y * i * _r6; // CHECK-NEXT: jacobianMatrix[3UL] += _r10; - // CHECK-NEXT: double _r11 = this->y * _t5 * _t4 * 1; + // CHECK-NEXT: double _r11 = this->y * i * j * 1; // CHECK-NEXT: jacobianMatrix[3UL] += _r11; // CHECK-NEXT: } // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; - // CHECK-NEXT: double _r2 = _r1 * _t2; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * i; + // CHECK-NEXT: double _r2 = _r1 * i; // CHECK-NEXT: double _r3 = this->x * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; - // CHECK-NEXT: double _r4 = this->x * _t2 * _r0; + // CHECK-NEXT: double _r4 = this->x * i * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; - // CHECK-NEXT: double _r5 = this->x * _t2 * _t1 * 1; + // CHECK-NEXT: double _r5 = this->x * i * i * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -69,40 +57,28 @@ struct ExperimentConst { } // CHECK: void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) const { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: double _t4; - // CHECK-NEXT: double _t5; - // CHECK-NEXT: _t2 = i; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * i * i * j; - // CHECK-NEXT: _t5 = i; - // CHECK-NEXT: _t4 = j; - // CHECK-NEXT: _t3 = j; // CHECK-NEXT: output[1] = this->y * i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: double _r6 = 1 * _t3; - // CHECK-NEXT: double _r7 = _r6 * _t4; - // CHECK-NEXT: double _r8 = _r7 * _t5; + // CHECK-NEXT: double _r6 = 1 * j; + // CHECK-NEXT: double _r7 = _r6 * j; + // CHECK-NEXT: double _r8 = _r7 * i; // CHECK-NEXT: double _r9 = this->y * _r7; // CHECK-NEXT: jacobianMatrix[2UL] += _r9; - // CHECK-NEXT: double _r10 = this->y * _t5 * _r6; + // CHECK-NEXT: double _r10 = this->y * i * _r6; // CHECK-NEXT: jacobianMatrix[3UL] += _r10; - // CHECK-NEXT: double _r11 = this->y * _t5 * _t4 * 1; + // CHECK-NEXT: double _r11 = this->y * i * j * 1; // CHECK-NEXT: jacobianMatrix[3UL] += _r11; // CHECK-NEXT: } // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; - // CHECK-NEXT: double _r2 = _r1 * _t2; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * i; + // CHECK-NEXT: double _r2 = _r1 * i; // CHECK-NEXT: double _r3 = this->x * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; - // CHECK-NEXT: double _r4 = this->x * _t2 * _r0; + // CHECK-NEXT: double _r4 = this->x * i * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; - // CHECK-NEXT: double _r5 = this->x * _t2 * _t1 * 1; + // CHECK-NEXT: double _r5 = this->x * i * i * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -120,40 +96,28 @@ struct ExperimentVolatile { } // CHECK: void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) volatile { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: double _t4; - // CHECK-NEXT: double _t5; - // CHECK-NEXT: _t2 = i; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * i * i * j; - // CHECK-NEXT: _t5 = i; - // CHECK-NEXT: _t4 = j; - // CHECK-NEXT: _t3 = j; // CHECK-NEXT: output[1] = this->y * i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: double _r6 = 1 * _t3; - // CHECK-NEXT: double _r7 = _r6 * _t4; - // CHECK-NEXT: double _r8 = _r7 * _t5; + // CHECK-NEXT: double _r6 = 1 * j; + // CHECK-NEXT: double _r7 = _r6 * j; + // CHECK-NEXT: double _r8 = _r7 * i; // CHECK-NEXT: double _r9 = this->y * _r7; // CHECK-NEXT: jacobianMatrix[2UL] += _r9; - // CHECK-NEXT: double _r10 = this->y * _t5 * _r6; + // CHECK-NEXT: double _r10 = this->y * i * _r6; // CHECK-NEXT: jacobianMatrix[3UL] += _r10; - // CHECK-NEXT: double _r11 = this->y * _t5 * _t4 * 1; + // CHECK-NEXT: double _r11 = this->y * i * j * 1; // CHECK-NEXT: jacobianMatrix[3UL] += _r11; // CHECK-NEXT: } // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; - // CHECK-NEXT: double _r2 = _r1 * _t2; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * i; + // CHECK-NEXT: double _r2 = _r1 * i; // CHECK-NEXT: double _r3 = this->x * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; - // CHECK-NEXT: double _r4 = this->x * _t2 * _r0; + // CHECK-NEXT: double _r4 = this->x * i * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; - // CHECK-NEXT: double _r5 = this->x * _t2 * _t1 * 1; + // CHECK-NEXT: double _r5 = this->x * i * i * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -171,40 +135,28 @@ struct ExperimentConstVolatile { } // CHECK: void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) const volatile { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: double _t4; - // CHECK-NEXT: double _t5; - // CHECK-NEXT: _t2 = i; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * i * i * j; - // CHECK-NEXT: _t5 = i; - // CHECK-NEXT: _t4 = j; - // CHECK-NEXT: _t3 = j; // CHECK-NEXT: output[1] = this->y * i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: double _r6 = 1 * _t3; - // CHECK-NEXT: double _r7 = _r6 * _t4; - // CHECK-NEXT: double _r8 = _r7 * _t5; + // CHECK-NEXT: double _r6 = 1 * j; + // CHECK-NEXT: double _r7 = _r6 * j; + // CHECK-NEXT: double _r8 = _r7 * i; // CHECK-NEXT: double _r9 = this->y * _r7; // CHECK-NEXT: jacobianMatrix[2UL] += _r9; - // CHECK-NEXT: double _r10 = this->y * _t5 * _r6; + // CHECK-NEXT: double _r10 = this->y * i * _r6; // CHECK-NEXT: jacobianMatrix[3UL] += _r10; - // CHECK-NEXT: double _r11 = this->y * _t5 * _t4 * 1; + // CHECK-NEXT: double _r11 = this->y * i * j * 1; // CHECK-NEXT: jacobianMatrix[3UL] += _r11; // CHECK-NEXT: } // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; - // CHECK-NEXT: double _r2 = _r1 * _t2; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * i; + // CHECK-NEXT: double _r2 = _r1 * i; // CHECK-NEXT: double _r3 = this->x * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; - // CHECK-NEXT: double _r4 = this->x * _t2 * _r0; + // CHECK-NEXT: double _r4 = this->x * i * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; - // CHECK-NEXT: double _r5 = this->x * _t2 * _t1 * 1; + // CHECK-NEXT: double _r5 = this->x * i * i * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -224,40 +176,28 @@ namespace outer { } // CHECK: void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: double _t4; - // CHECK-NEXT: double _t5; - // CHECK-NEXT: _t2 = i; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * i * i * j; - // CHECK-NEXT: _t5 = i; - // CHECK-NEXT: _t4 = j; - // CHECK-NEXT: _t3 = j; // CHECK-NEXT: output[1] = this->y * i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: double _r6 = 1 * _t3; - // CHECK-NEXT: double _r7 = _r6 * _t4; - // CHECK-NEXT: double _r8 = _r7 * _t5; + // CHECK-NEXT: double _r6 = 1 * j; + // CHECK-NEXT: double _r7 = _r6 * j; + // CHECK-NEXT: double _r8 = _r7 * i; // CHECK-NEXT: double _r9 = this->y * _r7; // CHECK-NEXT: jacobianMatrix[2UL] += _r9; - // CHECK-NEXT: double _r10 = this->y * _t5 * _r6; + // CHECK-NEXT: double _r10 = this->y * i * _r6; // CHECK-NEXT: jacobianMatrix[3UL] += _r10; - // CHECK-NEXT: double _r11 = this->y * _t5 * _t4 * 1; + // CHECK-NEXT: double _r11 = this->y * i * j * 1; // CHECK-NEXT: jacobianMatrix[3UL] += _r11; // CHECK-NEXT: } // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; - // CHECK-NEXT: double _r2 = _r1 * _t2; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * i; + // CHECK-NEXT: double _r2 = _r1 * i; // CHECK-NEXT: double _r3 = this->x * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; - // CHECK-NEXT: double _r4 = this->x * _t2 * _r0; + // CHECK-NEXT: double _r4 = this->x * i * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; - // CHECK-NEXT: double _r5 = this->x * _t2 * _t1 * 1; + // CHECK-NEXT: double _r5 = this->x * i * i * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -269,32 +209,24 @@ namespace outer { }; // CHECK: inline void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) const { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = i * i * j; - // CHECK-NEXT: _t3 = j; - // CHECK-NEXT: _t2 = j; // CHECK-NEXT: output[1] = i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: double _r4 = 1 * _t2; - // CHECK-NEXT: double _r5 = _r4 * _t3; + // CHECK-NEXT: double _r4 = 1 * j; + // CHECK-NEXT: double _r5 = _r4 * j; // CHECK-NEXT: jacobianMatrix[2UL] += _r5; // CHECK-NEXT: double _r6 = i * _r4; // CHECK-NEXT: jacobianMatrix[3UL] += _r6; - // CHECK-NEXT: double _r7 = i * _t3 * 1; + // CHECK-NEXT: double _r7 = i * j * 1; // CHECK-NEXT: jacobianMatrix[3UL] += _r7; // CHECK-NEXT: } // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * i; // CHECK-NEXT: jacobianMatrix[0UL] += _r1; // CHECK-NEXT: double _r2 = i * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r2; - // CHECK-NEXT: double _r3 = i * _t1 * 1; + // CHECK-NEXT: double _r3 = i * i * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -334,32 +266,24 @@ int main() { }; // CHECK: inline void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) const { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = i * i * j; - // CHECK-NEXT: _t3 = j; - // CHECK-NEXT: _t2 = j; // CHECK-NEXT: output[1] = i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: double _r4 = 1 * _t2; - // CHECK-NEXT: double _r5 = _r4 * _t3; + // CHECK-NEXT: double _r4 = 1 * j; + // CHECK-NEXT: double _r5 = _r4 * j; // CHECK-NEXT: jacobianMatrix[2UL] += _r5; // CHECK-NEXT: double _r6 = i * _r4; // CHECK-NEXT: jacobianMatrix[3UL] += _r6; - // CHECK-NEXT: double _r7 = i * _t3 * 1; + // CHECK-NEXT: double _r7 = i * j * 1; // CHECK-NEXT: jacobianMatrix[3UL] += _r7; // CHECK-NEXT: } // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; + // CHECK-NEXT: double _r0 = 1 * j; + // CHECK-NEXT: double _r1 = _r0 * i; // CHECK-NEXT: jacobianMatrix[0UL] += _r1; // CHECK-NEXT: double _r2 = i * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r2; - // CHECK-NEXT: double _r3 = i * _t1 * 1; + // CHECK-NEXT: double _r3 = i * i * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -370,40 +294,28 @@ int main() { }; // CHECK: inline void operator_call_jac(double i, double jj, double *output, double *jacobianMatrix) const { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: double _t4; - // CHECK-NEXT: double _t5; - // CHECK-NEXT: _t2 = i; - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t0 = jj; // CHECK-NEXT: output[0] = x * i * i * jj; - // CHECK-NEXT: _t5 = i; - // CHECK-NEXT: _t4 = jj; - // CHECK-NEXT: _t3 = jj; // CHECK-NEXT: output[1] = y * i * jj * jj; // CHECK-NEXT: { - // CHECK-NEXT: double _r6 = 1 * _t3; - // CHECK-NEXT: double _r7 = _r6 * _t4; - // CHECK-NEXT: double _r8 = _r7 * _t5; + // CHECK-NEXT: double _r6 = 1 * jj; + // CHECK-NEXT: double _r7 = _r6 * jj; + // CHECK-NEXT: double _r8 = _r7 * i; // CHECK-NEXT: double _r9 = y * _r7; // CHECK-NEXT: jacobianMatrix[2UL] += _r9; - // CHECK-NEXT: double _r10 = y * _t5 * _r6; + // CHECK-NEXT: double _r10 = y * i * _r6; // CHECK-NEXT: jacobianMatrix[3UL] += _r10; - // CHECK-NEXT: double _r11 = y * _t5 * _t4 * 1; + // CHECK-NEXT: double _r11 = y * i * jj * 1; // CHECK-NEXT: jacobianMatrix[3UL] += _r11; // CHECK-NEXT: } // CHECK-NEXT: { - // CHECK-NEXT: double _r0 = 1 * _t0; - // CHECK-NEXT: double _r1 = _r0 * _t1; - // CHECK-NEXT: double _r2 = _r1 * _t2; + // CHECK-NEXT: double _r0 = 1 * jj; + // CHECK-NEXT: double _r1 = _r0 * i; + // CHECK-NEXT: double _r2 = _r1 * i; // CHECK-NEXT: double _r3 = x * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; - // CHECK-NEXT: double _r4 = x * _t2 * _r0; + // CHECK-NEXT: double _r4 = x * i * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; - // CHECK-NEXT: double _r5 = x * _t2 * _t1 * 1; + // CHECK-NEXT: double _r5 = x * i * i * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/Jacobian/Jacobian.C b/test/Jacobian/Jacobian.C index d8b52062b..53196e949 100644 --- a/test/Jacobian/Jacobian.C +++ b/test/Jacobian/Jacobian.C @@ -16,62 +16,43 @@ void f_1(double a, double b, double c, double output[]) { void f_1_jac(double a, double b, double c, double output[], double *_result); //CHECK:void f_1_jac(double a, double b, double c, double output[], double *jacobianMatrix) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: double _t4; -//CHECK-NEXT: double _t5; -//CHECK-NEXT: double _t6; -//CHECK-NEXT: double _t7; -//CHECK-NEXT: double _t8; -//CHECK-NEXT: _t1 = a; -//CHECK-NEXT: _t0 = a; //CHECK-NEXT: output[0] = a * a * a; -//CHECK-NEXT: _t3 = a; -//CHECK-NEXT: _t2 = a; -//CHECK-NEXT: _t5 = b; -//CHECK-NEXT: _t4 = b; //CHECK-NEXT: output[1] = a * a * a + b * b * b; -//CHECK-NEXT: _t7 = c; -//CHECK-NEXT: _t6 = 10; -//CHECK-NEXT: _t8 = a; //CHECK-NEXT: output[2] = c * c * 10 - a * a; //CHECK-NEXT: { -//CHECK-NEXT: double _r12 = 1 * _t6; -//CHECK-NEXT: double _r13 = _r12 * _t7; +//CHECK-NEXT: double _r12 = 1 * 10; +//CHECK-NEXT: double _r13 = _r12 * c; //CHECK-NEXT: jacobianMatrix[8UL] += _r13; //CHECK-NEXT: double _r14 = c * _r12; //CHECK-NEXT: jacobianMatrix[8UL] += _r14; -//CHECK-NEXT: double _r15 = c * _t7 * 1; -//CHECK-NEXT: double _r16 = -1 * _t8; +//CHECK-NEXT: double _r15 = -1 * a; +//CHECK-NEXT: jacobianMatrix[6UL] += _r15; +//CHECK-NEXT: double _r16 = a * -1; //CHECK-NEXT: jacobianMatrix[6UL] += _r16; -//CHECK-NEXT: double _r17 = a * -1; -//CHECK-NEXT: jacobianMatrix[6UL] += _r17; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t2; -//CHECK-NEXT: double _r5 = _r4 * _t3; +//CHECK-NEXT: double _r4 = 1 * a; +//CHECK-NEXT: double _r5 = _r4 * a; //CHECK-NEXT: jacobianMatrix[3UL] += _r5; //CHECK-NEXT: double _r6 = a * _r4; //CHECK-NEXT: jacobianMatrix[3UL] += _r6; -//CHECK-NEXT: double _r7 = a * _t3 * 1; +//CHECK-NEXT: double _r7 = a * a * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r7; -//CHECK-NEXT: double _r8 = 1 * _t4; -//CHECK-NEXT: double _r9 = _r8 * _t5; +//CHECK-NEXT: double _r8 = 1 * b; +//CHECK-NEXT: double _r9 = _r8 * b; //CHECK-NEXT: jacobianMatrix[4UL] += _r9; //CHECK-NEXT: double _r10 = b * _r8; //CHECK-NEXT: jacobianMatrix[4UL] += _r10; -//CHECK-NEXT: double _r11 = b * _t5 * 1; +//CHECK-NEXT: double _r11 = b * b * 1; //CHECK-NEXT: jacobianMatrix[4UL] += _r11; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; -//CHECK-NEXT: double _r1 = _r0 * _t1; +//CHECK-NEXT: double _r0 = 1 * a; +//CHECK-NEXT: double _r1 = _r0 * a; //CHECK-NEXT: jacobianMatrix[0UL] += _r1; //CHECK-NEXT: double _r2 = a * _r0; //CHECK-NEXT: jacobianMatrix[0UL] += _r2; -//CHECK-NEXT: double _r3 = a * _t1 * 1; +//CHECK-NEXT: double _r3 = a * a * 1; //CHECK-NEXT: jacobianMatrix[0UL] += _r3; //CHECK-NEXT: } //CHECK-NEXT:} @@ -88,30 +69,24 @@ void f_3(double x, double y, double z, double *_result) { void f_3_jac(double x, double y, double z, double *_result, double *jacobianMatrix); //CHECK: void f_3_jac(double x, double y, double z, double *_result, double *jacobianMatrix) { //CHECK-NEXT: double _d_constant = 0; -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; //CHECK-NEXT: double constant = 42; -//CHECK-NEXT: _t0 = constant; //CHECK-NEXT: _result[0] = sin(x) * constant; -//CHECK-NEXT: _t1 = constant; //CHECK-NEXT: _result[1] = sin(y) * constant; -//CHECK-NEXT: _t2 = constant; //CHECK-NEXT: _result[2] = sin(z) * constant; //CHECK-NEXT: { -//CHECK-NEXT: double _r6 = 1 * _t2; +//CHECK-NEXT: double _r6 = 1 * constant; //CHECK-NEXT: double _r7 = _r6 * clad::custom_derivatives::sin_pushforward(z, 1.).pushforward; //CHECK-NEXT: jacobianMatrix[8UL] += _r7; //CHECK-NEXT: double _r8 = sin(z) * 1; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r3 = 1 * _t1; +//CHECK-NEXT: double _r3 = 1 * constant; //CHECK-NEXT: double _r4 = _r3 * clad::custom_derivatives::sin_pushforward(y, 1.).pushforward; //CHECK-NEXT: jacobianMatrix[4UL] += _r4; //CHECK-NEXT: double _r5 = sin(y) * 1; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * constant; //CHECK-NEXT: double _r1 = _r0 * clad::custom_derivatives::sin_pushforward(x, 1.).pushforward; //CHECK-NEXT: jacobianMatrix[0UL] += _r1; //CHECK-NEXT: double _r2 = sin(x) * 1; @@ -120,12 +95,10 @@ void f_3_jac(double x, double y, double z, double *_result, double *jacobianMatr double multiply(double x, double y) { return x * y; } //CHECK: void multiply_pullback(double x, double y, double _d_y0, clad::array_ref _d_x, clad::array_ref _d_y) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: _t0 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_y0 * _t0; +//CHECK-NEXT: double _r0 = _d_y0 * y; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = x * _d_y0; //CHECK-NEXT: * _d_y += _r1; @@ -143,18 +116,12 @@ void f_4(double x, double y, double z, double *_result) { void f_4_jac(double x, double y, double z, double *_result, double *jacobianMatrix); //CHECK: void f_4_jac(double x, double y, double z, double *_result, double *jacobianMatrix) { //CHECK-NEXT: double _d_constant = 0; -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; //CHECK-NEXT: double constant = 42; -//CHECK-NEXT: _t0 = constant; //CHECK-NEXT: _result[0] = multiply(x, y) * constant; -//CHECK-NEXT: _t1 = constant; //CHECK-NEXT: _result[1] = multiply(y, z) * constant; -//CHECK-NEXT: _t2 = constant; //CHECK-NEXT: _result[2] = multiply(z, x) * constant; //CHECK-NEXT: { -//CHECK-NEXT: double _r8 = 1 * _t2; +//CHECK-NEXT: double _r8 = 1 * constant; //CHECK-NEXT: double _jac4 = 0.; //CHECK-NEXT: double _jac5 = 0.; //CHECK-NEXT: multiply_pullback(z, x, _r8, &_jac4, &_jac5); @@ -165,7 +132,7 @@ void f_4_jac(double x, double y, double z, double *_result, double *jacobianMatr //CHECK-NEXT: double _r11 = multiply(z, x) * 1; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t1; +//CHECK-NEXT: double _r4 = 1 * constant; //CHECK-NEXT: double _jac2 = 0.; //CHECK-NEXT: double _jac3 = 0.; //CHECK-NEXT: multiply_pullback(y, z, _r4, &_jac2, &_jac3); @@ -176,7 +143,7 @@ void f_4_jac(double x, double y, double z, double *_result, double *jacobianMatr //CHECK-NEXT: double _r7 = multiply(y, z) * 1; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * constant; //CHECK-NEXT: double _jac0 = 0.; //CHECK-NEXT: double _jac1 = 0.; //CHECK-NEXT: multiply_pullback(x, y, _r0, &_jac0, &_jac1); @@ -192,57 +159,38 @@ void f_1_jac_0(double a, double b, double c, double output[], double *jacobianMa // CHECK: void f_1_jac_0(double a, double b, double c, double output[], double *jacobianMatrix) { // CHECK-NEXT: double _d_b = 0; // CHECK-NEXT: double _d_c = 0; -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; -// CHECK-NEXT: double _t4; -// CHECK-NEXT: double _t5; -// CHECK-NEXT: double _t6; -// CHECK-NEXT: double _t7; -// CHECK-NEXT: double _t8; -// CHECK-NEXT: _t1 = a; -// CHECK-NEXT: _t0 = a; // CHECK-NEXT: output[0] = a * a * a; -// CHECK-NEXT: _t3 = a; -// CHECK-NEXT: _t2 = a; -// CHECK-NEXT: _t5 = b; -// CHECK-NEXT: _t4 = b; // CHECK-NEXT: output[1] = a * a * a + b * b * b; -// CHECK-NEXT: _t7 = c; -// CHECK-NEXT: _t6 = 10; -// CHECK-NEXT: _t8 = a; // CHECK-NEXT: output[2] = c * c * 10 - a * a; // CHECK-NEXT: { -// CHECK-NEXT: double _r12 = 1 * _t6; -// CHECK-NEXT: double _r13 = _r12 * _t7; +// CHECK-NEXT: double _r12 = 1 * 10; +// CHECK-NEXT: double _r13 = _r12 * c; // CHECK-NEXT: double _r14 = c * _r12; -// CHECK-NEXT: double _r15 = c * _t7 * 1; -// CHECK-NEXT: double _r16 = -1 * _t8; +// CHECK-NEXT: double _r15 = -1 * a; +// CHECK-NEXT: jacobianMatrix[2UL] += _r15; +// CHECK-NEXT: double _r16 = a * -1; // CHECK-NEXT: jacobianMatrix[2UL] += _r16; -// CHECK-NEXT: double _r17 = a * -1; -// CHECK-NEXT: jacobianMatrix[2UL] += _r17; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: double _r4 = 1 * _t2; -// CHECK-NEXT: double _r5 = _r4 * _t3; +// CHECK-NEXT: double _r4 = 1 * a; +// CHECK-NEXT: double _r5 = _r4 * a; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: double _r6 = a * _r4; // CHECK-NEXT: jacobianMatrix[1UL] += _r6; -// CHECK-NEXT: double _r7 = a * _t3 * 1; +// CHECK-NEXT: double _r7 = a * a * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r7; -// CHECK-NEXT: double _r8 = 1 * _t4; -// CHECK-NEXT: double _r9 = _r8 * _t5; +// CHECK-NEXT: double _r8 = 1 * b; +// CHECK-NEXT: double _r9 = _r8 * b; // CHECK-NEXT: double _r10 = b * _r8; -// CHECK-NEXT: double _r11 = b * _t5 * 1; +// CHECK-NEXT: double _r11 = b * b * 1; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 1 * _t0; -// CHECK-NEXT: double _r1 = _r0 * _t1; +// CHECK-NEXT: double _r0 = 1 * a; +// CHECK-NEXT: double _r1 = _r0 * a; // CHECK-NEXT: jacobianMatrix[0UL] += _r1; // CHECK-NEXT: double _r2 = a * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r2; -// CHECK-NEXT: double _r3 = a * _t1 * 1; +// CHECK-NEXT: double _r3 = a * a * 1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; // CHECK-NEXT: } // CHECK-NEXT:} diff --git a/test/Jacobian/TemplateFunctors.C b/test/Jacobian/TemplateFunctors.C index 3486b9280..ed1e3ce8d 100644 --- a/test/Jacobian/TemplateFunctors.C +++ b/test/Jacobian/TemplateFunctors.C @@ -17,42 +17,28 @@ template struct Experiment { }; // CHECK: void operator_call_jac(double i, double j, double *output, double *jacobianMatrix) { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; -// CHECK-NEXT: double _t4; -// CHECK-NEXT: double _t5; -// CHECK-NEXT: double _t6; -// CHECK-NEXT: _t2 = this->y; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * this->y * i * j; -// CHECK-NEXT: _t6 = this->x; -// CHECK-NEXT: _t5 = this->y; -// CHECK-NEXT: _t4 = i; -// CHECK-NEXT: _t3 = j; // CHECK-NEXT: output[1] = 2 * this->x * this->y * i * j; // CHECK-NEXT: { -// CHECK-NEXT: double _r6 = 1 * _t3; -// CHECK-NEXT: double _r7 = _r6 * _t4; -// CHECK-NEXT: double _r8 = _r7 * _t5; -// CHECK-NEXT: double _r9 = _r8 * _t6; +// CHECK-NEXT: double _r6 = 1 * j; +// CHECK-NEXT: double _r7 = _r6 * i; +// CHECK-NEXT: double _r8 = _r7 * this->y; +// CHECK-NEXT: double _r9 = _r8 * this->x; // CHECK-NEXT: double _r10 = 2 * _r8; -// CHECK-NEXT: double _r11 = 2 * _t6 * _r7; -// CHECK-NEXT: double _r12 = 2 * _t6 * _t5 * _r6; +// CHECK-NEXT: double _r11 = 2 * this->x * _r7; +// CHECK-NEXT: double _r12 = 2 * this->x * this->y * _r6; // CHECK-NEXT: jacobianMatrix[2UL] += _r12; -// CHECK-NEXT: double _r13 = 2 * _t6 * _t5 * _t4 * 1; +// CHECK-NEXT: double _r13 = 2 * this->x * this->y * i * 1; // CHECK-NEXT: jacobianMatrix[3UL] += _r13; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: double _r0 = 1 * _t0; -// CHECK-NEXT: double _r1 = _r0 * _t1; -// CHECK-NEXT: double _r2 = _r1 * _t2; +// CHECK-NEXT: double _r0 = 1 * j; +// CHECK-NEXT: double _r1 = _r0 * i; +// CHECK-NEXT: double _r2 = _r1 * this->y; // CHECK-NEXT: double _r3 = this->x * _r1; -// CHECK-NEXT: double _r4 = this->x * _t2 * _r0; +// CHECK-NEXT: double _r4 = this->x * this->y * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; -// CHECK-NEXT: double _r5 = this->x * _t2 * _t1 * 1; +// CHECK-NEXT: double _r5 = this->x * this->y * i * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -68,52 +54,34 @@ template <> struct Experiment { }; // CHECK: void operator_call_jac(long double i, long double j, long double *output, long double *jacobianMatrix) { -// CHECK-NEXT: long double _t0; -// CHECK-NEXT: long double _t1; -// CHECK-NEXT: long double _t2; -// CHECK-NEXT: long double _t3; -// CHECK-NEXT: long double _t4; -// CHECK-NEXT: long double _t5; -// CHECK-NEXT: long double _t6; -// CHECK-NEXT: long double _t7; -// CHECK-NEXT: long double _t8; -// CHECK-NEXT: _t3 = this->y; -// CHECK-NEXT: _t2 = i; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * this->y * i * i * j; -// CHECK-NEXT: _t8 = this->x; -// CHECK-NEXT: _t7 = this->y; -// CHECK-NEXT: _t6 = i; -// CHECK-NEXT: _t5 = i; -// CHECK-NEXT: _t4 = j; // CHECK-NEXT: output[1] = 2 * this->x * this->y * i * i * j; // CHECK-NEXT: { -// CHECK-NEXT: long double _r8 = 1 * _t4; -// CHECK-NEXT: long double _r9 = _r8 * _t5; -// CHECK-NEXT: long double _r10 = _r9 * _t6; -// CHECK-NEXT: long double _r11 = _r10 * _t7; -// CHECK-NEXT: long double _r12 = _r11 * _t8; +// CHECK-NEXT: long double _r8 = 1 * j; +// CHECK-NEXT: long double _r9 = _r8 * i; +// CHECK-NEXT: long double _r10 = _r9 * i; +// CHECK-NEXT: long double _r11 = _r10 * this->y; +// CHECK-NEXT: long double _r12 = _r11 * this->x; // CHECK-NEXT: long double _r13 = 2 * _r11; -// CHECK-NEXT: long double _r14 = 2 * _t8 * _r10; -// CHECK-NEXT: long double _r15 = 2 * _t8 * _t7 * _r9; +// CHECK-NEXT: long double _r14 = 2 * this->x * _r10; +// CHECK-NEXT: long double _r15 = 2 * this->x * this->y * _r9; // CHECK-NEXT: jacobianMatrix[2UL] += _r15; -// CHECK-NEXT: long double _r16 = 2 * _t8 * _t7 * _t6 * _r8; +// CHECK-NEXT: long double _r16 = 2 * this->x * this->y * i * _r8; // CHECK-NEXT: jacobianMatrix[2UL] += _r16; -// CHECK-NEXT: long double _r17 = 2 * _t8 * _t7 * _t6 * _t5 * 1; +// CHECK-NEXT: long double _r17 = 2 * this->x * this->y * i * i * 1; // CHECK-NEXT: jacobianMatrix[3UL] += _r17; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: long double _r0 = 1 * _t0; -// CHECK-NEXT: long double _r1 = _r0 * _t1; -// CHECK-NEXT: long double _r2 = _r1 * _t2; -// CHECK-NEXT: long double _r3 = _r2 * _t3; +// CHECK-NEXT: long double _r0 = 1 * j; +// CHECK-NEXT: long double _r1 = _r0 * i; +// CHECK-NEXT: long double _r2 = _r1 * i; +// CHECK-NEXT: long double _r3 = _r2 * this->y; // CHECK-NEXT: long double _r4 = this->x * _r2; -// CHECK-NEXT: long double _r5 = this->x * _t3 * _r1; +// CHECK-NEXT: long double _r5 = this->x * this->y * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r5; -// CHECK-NEXT: long double _r6 = this->x * _t3 * _t2 * _r0; +// CHECK-NEXT: long double _r6 = this->x * this->y * i * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r6; -// CHECK-NEXT: long double _r7 = this->x * _t3 * _t2 * _t1 * 1; +// CHECK-NEXT: long double _r7 = this->x * this->y * i * i * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r7; // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/Jacobian/constexprTest.C b/test/Jacobian/constexprTest.C index 68f9579f6..65f680ee4 100644 --- a/test/Jacobian/constexprTest.C +++ b/test/Jacobian/constexprTest.C @@ -20,29 +20,23 @@ constexpr void fn_mul(double i, double j, double *res) { } //CHECK: constexpr void fn_mul_jac(double i, double j, double *res, double *jacobianMatrix) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = i; //CHECK-NEXT: res[0] = i * i; -//CHECK-NEXT: _t1 = j; //CHECK-NEXT: res[1] = j * j; -//CHECK-NEXT: _t2 = j; //CHECK-NEXT: res[2] = i * j; //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r4 = 1 * j; //CHECK-NEXT: jacobianMatrix[4UL] += _r4; //CHECK-NEXT: double _r5 = i * 1; //CHECK-NEXT: jacobianMatrix[5UL] += _r5; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r2 = 1 * _t1; +//CHECK-NEXT: double _r2 = 1 * j; //CHECK-NEXT: jacobianMatrix[3UL] += _r2; //CHECK-NEXT: double _r3 = j * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r3; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * i; //CHECK-NEXT: jacobianMatrix[0UL] += _r0; //CHECK-NEXT: double _r1 = i * 1; //CHECK-NEXT: jacobianMatrix[0UL] += _r1; @@ -56,62 +50,43 @@ constexpr void f_1(double x, double y, double z, double output[]) { } //CHECK: constexpr void f_1_jac(double x, double y, double z, double output[], double *jacobianMatrix) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: double _t4; -//CHECK-NEXT: double _t5; -//CHECK-NEXT: double _t6; -//CHECK-NEXT: double _t7; -//CHECK-NEXT: double _t8; -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t0 = x; //CHECK-NEXT: output[0] = x * x * x; -//CHECK-NEXT: _t3 = y; -//CHECK-NEXT: _t2 = x; -//CHECK-NEXT: _t5 = x; -//CHECK-NEXT: _t4 = x; //CHECK-NEXT: output[1] = x * y * x + y * x * x; -//CHECK-NEXT: _t7 = x; -//CHECK-NEXT: _t6 = 10; -//CHECK-NEXT: _t8 = z; //CHECK-NEXT: output[2] = z * x * 10 - y * z; //CHECK-NEXT: { -//CHECK-NEXT: double _r12 = 1 * _t6; -//CHECK-NEXT: double _r13 = _r12 * _t7; +//CHECK-NEXT: double _r12 = 1 * 10; +//CHECK-NEXT: double _r13 = _r12 * x; //CHECK-NEXT: jacobianMatrix[8UL] += _r13; //CHECK-NEXT: double _r14 = z * _r12; //CHECK-NEXT: jacobianMatrix[6UL] += _r14; -//CHECK-NEXT: double _r15 = z * _t7 * 1; -//CHECK-NEXT: double _r16 = -1 * _t8; -//CHECK-NEXT: jacobianMatrix[7UL] += _r16; -//CHECK-NEXT: double _r17 = y * -1; -//CHECK-NEXT: jacobianMatrix[8UL] += _r17; +//CHECK-NEXT: double _r15 = -1 * z; +//CHECK-NEXT: jacobianMatrix[7UL] += _r15; +//CHECK-NEXT: double _r16 = y * -1; +//CHECK-NEXT: jacobianMatrix[8UL] += _r16; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t2; -//CHECK-NEXT: double _r5 = _r4 * _t3; +//CHECK-NEXT: double _r4 = 1 * x; +//CHECK-NEXT: double _r5 = _r4 * y; //CHECK-NEXT: jacobianMatrix[3UL] += _r5; //CHECK-NEXT: double _r6 = x * _r4; //CHECK-NEXT: jacobianMatrix[4UL] += _r6; -//CHECK-NEXT: double _r7 = x * _t3 * 1; +//CHECK-NEXT: double _r7 = x * y * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r7; -//CHECK-NEXT: double _r8 = 1 * _t4; -//CHECK-NEXT: double _r9 = _r8 * _t5; +//CHECK-NEXT: double _r8 = 1 * x; +//CHECK-NEXT: double _r9 = _r8 * x; //CHECK-NEXT: jacobianMatrix[4UL] += _r9; //CHECK-NEXT: double _r10 = y * _r8; //CHECK-NEXT: jacobianMatrix[3UL] += _r10; -//CHECK-NEXT: double _r11 = y * _t5 * 1; +//CHECK-NEXT: double _r11 = y * x * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r11; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; -//CHECK-NEXT: double _r1 = _r0 * _t1; +//CHECK-NEXT: double _r0 = 1 * x; +//CHECK-NEXT: double _r1 = _r0 * x; //CHECK-NEXT: jacobianMatrix[0UL] += _r1; //CHECK-NEXT: double _r2 = x * _r0; //CHECK-NEXT: jacobianMatrix[0UL] += _r2; -//CHECK-NEXT: double _r3 = x * _t1 * 1; +//CHECK-NEXT: double _r3 = x * x * 1; //CHECK-NEXT: jacobianMatrix[0UL] += _r3; //CHECK-NEXT: } //CHECK-NEXT:} diff --git a/test/Jacobian/testUtility.C b/test/Jacobian/testUtility.C index a3e404d6b..1d43ca589 100644 --- a/test/Jacobian/testUtility.C +++ b/test/Jacobian/testUtility.C @@ -20,29 +20,23 @@ void fn_mul(double i, double j, double *res) { } //CHECK: void fn_mul_jac(double i, double j, double *res, double *jacobianMatrix) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = i; //CHECK-NEXT: res[0] = i * i; -//CHECK-NEXT: _t1 = j; //CHECK-NEXT: res[1] = j * j; -//CHECK-NEXT: _t2 = j; //CHECK-NEXT: res[2] = i * j; //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r4 = 1 * j; //CHECK-NEXT: jacobianMatrix[4UL] += _r4; //CHECK-NEXT: double _r5 = i * 1; //CHECK-NEXT: jacobianMatrix[5UL] += _r5; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r2 = 1 * _t1; +//CHECK-NEXT: double _r2 = 1 * j; //CHECK-NEXT: jacobianMatrix[3UL] += _r2; //CHECK-NEXT: double _r3 = j * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r3; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; +//CHECK-NEXT: double _r0 = 1 * i; //CHECK-NEXT: jacobianMatrix[0UL] += _r0; //CHECK-NEXT: double _r1 = i * 1; //CHECK-NEXT: jacobianMatrix[0UL] += _r1; @@ -57,62 +51,43 @@ void f_1(double x, double y, double z, double output[]) { } //CHECK: void f_1_jac(double x, double y, double z, double output[], double *jacobianMatrix) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: double _t4; -//CHECK-NEXT: double _t5; -//CHECK-NEXT: double _t6; -//CHECK-NEXT: double _t7; -//CHECK-NEXT: double _t8; -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t0 = x; //CHECK-NEXT: output[0] = x * x * x; -//CHECK-NEXT: _t3 = y; -//CHECK-NEXT: _t2 = x; -//CHECK-NEXT: _t5 = x; -//CHECK-NEXT: _t4 = x; //CHECK-NEXT: output[1] = x * y * x + y * x * x; -//CHECK-NEXT: _t7 = x; -//CHECK-NEXT: _t6 = 10; -//CHECK-NEXT: _t8 = z; //CHECK-NEXT: output[2] = z * x * 10 - y * z; //CHECK-NEXT: { -//CHECK-NEXT: double _r12 = 1 * _t6; -//CHECK-NEXT: double _r13 = _r12 * _t7; +//CHECK-NEXT: double _r12 = 1 * 10; +//CHECK-NEXT: double _r13 = _r12 * x; //CHECK-NEXT: jacobianMatrix[8UL] += _r13; //CHECK-NEXT: double _r14 = z * _r12; //CHECK-NEXT: jacobianMatrix[6UL] += _r14; -//CHECK-NEXT: double _r15 = z * _t7 * 1; -//CHECK-NEXT: double _r16 = -1 * _t8; -//CHECK-NEXT: jacobianMatrix[7UL] += _r16; -//CHECK-NEXT: double _r17 = y * -1; -//CHECK-NEXT: jacobianMatrix[8UL] += _r17; +//CHECK-NEXT: double _r15 = -1 * z; +//CHECK-NEXT: jacobianMatrix[7UL] += _r15; +//CHECK-NEXT: double _r16 = y * -1; +//CHECK-NEXT: jacobianMatrix[8UL] += _r16; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t2; -//CHECK-NEXT: double _r5 = _r4 * _t3; +//CHECK-NEXT: double _r4 = 1 * x; +//CHECK-NEXT: double _r5 = _r4 * y; //CHECK-NEXT: jacobianMatrix[3UL] += _r5; //CHECK-NEXT: double _r6 = x * _r4; //CHECK-NEXT: jacobianMatrix[4UL] += _r6; -//CHECK-NEXT: double _r7 = x * _t3 * 1; +//CHECK-NEXT: double _r7 = x * y * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r7; -//CHECK-NEXT: double _r8 = 1 * _t4; -//CHECK-NEXT: double _r9 = _r8 * _t5; +//CHECK-NEXT: double _r8 = 1 * x; +//CHECK-NEXT: double _r9 = _r8 * x; //CHECK-NEXT: jacobianMatrix[4UL] += _r9; //CHECK-NEXT: double _r10 = y * _r8; //CHECK-NEXT: jacobianMatrix[3UL] += _r10; -//CHECK-NEXT: double _r11 = y * _t5 * 1; +//CHECK-NEXT: double _r11 = y * x * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r11; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = 1 * _t0; -//CHECK-NEXT: double _r1 = _r0 * _t1; +//CHECK-NEXT: double _r0 = 1 * x; +//CHECK-NEXT: double _r1 = _r0 * x; //CHECK-NEXT: jacobianMatrix[0UL] += _r1; //CHECK-NEXT: double _r2 = x * _r0; //CHECK-NEXT: jacobianMatrix[0UL] += _r2; -//CHECK-NEXT: double _r3 = x * _t1 * 1; +//CHECK-NEXT: double _r3 = x * x * 1; //CHECK-NEXT: jacobianMatrix[0UL] += _r3; //CHECK-NEXT: } //CHECK-NEXT:} diff --git a/test/Misc/RunDemos.C b/test/Misc/RunDemos.C index 0fbbe53ca..dbdbbd774 100644 --- a/test/Misc/RunDemos.C +++ b/test/Misc/RunDemos.C @@ -236,13 +236,11 @@ // RUN: %cladclang %S/../../demos/GradientDescent.cpp -I%S/../../include -oGradientDescent.out | FileCheck -check-prefix CHECK_GRADIENT_DESCENT %s //CHECK_GRADIENT_DESCENT: void f_pullback(double theta_0, double theta_1, double x, double _d_y, clad::array_ref _d_theta_0, clad::array_ref _d_theta_1, clad::array_ref _d_x) { -//CHECK_GRADIENT_DESCENT-NEXT: double _t0; -//CHECK_GRADIENT_DESCENT-NEXT: _t0 = x; //CHECK_GRADIENT_DESCENT-NEXT: goto _label0; //CHECK_GRADIENT_DESCENT-NEXT: _label0: //CHECK_GRADIENT_DESCENT-NEXT: { //CHECK_GRADIENT_DESCENT-NEXT: * _d_theta_0 += _d_y; -//CHECK_GRADIENT_DESCENT-NEXT: double _r0 = _d_y * _t0; +//CHECK_GRADIENT_DESCENT-NEXT: double _r0 = _d_y * x; //CHECK_GRADIENT_DESCENT-NEXT: * _d_theta_1 += _r0; //CHECK_GRADIENT_DESCENT-NEXT: double _r1 = theta_1 * _d_y; //CHECK_GRADIENT_DESCENT-NEXT: * _d_x += _r1; @@ -251,13 +249,11 @@ //CHECK_GRADIENT_DESCENT-NEXT: void cost_grad(double theta_0, double theta_1, double x, double y, clad::array_ref _d_theta_0, clad::array_ref _d_theta_1, clad::array_ref _d_x, clad::array_ref _d_y) { //CHECK_GRADIENT_DESCENT-NEXT: double _d_f_x = 0; -//CHECK_GRADIENT_DESCENT-NEXT: double _t0; //CHECK_GRADIENT_DESCENT-NEXT: double f_x = f(theta_0, theta_1, x); -//CHECK_GRADIENT_DESCENT-NEXT: _t0 = (f_x - y); //CHECK_GRADIENT_DESCENT-NEXT: goto _label0; //CHECK_GRADIENT_DESCENT-NEXT: _label0: //CHECK_GRADIENT_DESCENT-NEXT: { -//CHECK_GRADIENT_DESCENT-NEXT: double _r3 = 1 * _t0; +//CHECK_GRADIENT_DESCENT-NEXT: double _r3 = 1 * (f_x - y); //CHECK_GRADIENT_DESCENT-NEXT: _d_f_x += _r3; //CHECK_GRADIENT_DESCENT-NEXT: * _d_y += -_r3; //CHECK_GRADIENT_DESCENT-NEXT: double _r4 = (f_x - y) * 1; diff --git a/test/NestedCalls/NestedCalls.C b/test/NestedCalls/NestedCalls.C index 91d82811e..42c9e856a 100644 --- a/test/NestedCalls/NestedCalls.C +++ b/test/NestedCalls/NestedCalls.C @@ -40,12 +40,10 @@ double f(double x, double y) { // CHECK-NEXT: } //CHECK: void sq_pullback(double x, double _d_y, clad::array_ref _d_x) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: _t0 = x; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_y * _t0; +//CHECK-NEXT: double _r0 = _d_y * x; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = x * _d_y; //CHECK-NEXT: * _d_x += _r1; @@ -71,13 +69,11 @@ double f(double x, double y) { //CHECK: void f_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 t = one(x); -//CHECK-NEXT: _t0 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r1 = 1 * _t0; +//CHECK-NEXT: double _r1 = 1 * y; //CHECK-NEXT: _d_t += _r1; //CHECK-NEXT: double _r2 = t * 1; //CHECK-NEXT: * _d_y += _r2; diff --git a/test/ROOT/Interface.C b/test/ROOT/Interface.C index 53da1e5eb..863566adc 100644 --- a/test/ROOT/Interface.C +++ b/test/ROOT/Interface.C @@ -23,13 +23,11 @@ Double_t f(Double_t* x, Double_t* p) { void f_grad_1(Double_t* x, Double_t* p, clad::array_ref _d_p); // CHECK: void f_grad_1(Double_t *x, Double_t *p, clad::array_ref _d_p) { -// CHECK-NEXT: Double_t _t0; -// CHECK-NEXT: _t0 = p[1]; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: _d_p[0] += 1; -// CHECK-NEXT: {{double|Double_t}} _r0 = 1 * _t0; +// CHECK-NEXT: {{double|Double_t}} _r0 = 1 * p[1]; // CHECK-NEXT: {{double|Double_t}} _r1 = x[0] * 1; // CHECK-NEXT: _d_p[1] += _r1; // CHECK-NEXT: } diff --git a/test/ROOT/TFormula.C b/test/ROOT/TFormula.C index cd443ef41..4c052c907 100644 --- a/test/ROOT/TFormula.C +++ b/test/ROOT/TFormula.C @@ -41,12 +41,10 @@ Double_t TFormula_example(Double_t* x, Double_t* p) { void TFormula_example_grad_1(Double_t* x, Double_t* p, Double_t* _d_p); //CHECK: void TFormula_example_grad_1(Double_t *x, Double_t *p, clad::array_ref _d_p) { -//CHECK-NEXT: {{double|Double_t}} _t0; -//CHECK-NEXT: _t0 = (p[0] + p[1] + p[2]); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: {{double|Double_t}} _r0 = 1 * _t0; +//CHECK-NEXT: {{double|Double_t}} _r0 = 1 * (p[0] + p[1] + p[2]); //CHECK-NEXT: {{double|Double_t}} _r1 = x[0] * 1; //CHECK-NEXT: _d_p[0] += _r1; //CHECK-NEXT: _d_p[1] += _r1;