From ec8682fc166cd7644a023d2d837916075d6531cc Mon Sep 17 00:00:00 2001 From: "petro.zarytskyi" Date: Fri, 17 Nov 2023 17:05:47 +0200 Subject: [PATCH] Update and enable tests. --- lib/Differentiator/ReverseModeVisitor.cpp | 4 +- test/Arrays/ArrayInputsReverseMode.C | 182 ++--- test/Arrays/Arrays.C | 22 +- test/ErrorEstimation/Assignments.C | 38 +- test/ErrorEstimation/BasicOps.C | 193 +++--- test/ErrorEstimation/ConditonalStatements.C | 77 ++- test/ErrorEstimation/LoopsAndArrays.C | 172 ++--- test/ErrorEstimation/LoopsAndArraysExec.C | 96 +-- test/FirstDerivative/BuiltinDerivatives.C | 40 +- test/FirstDerivative/UnsupportedOpsWarn.C | 1 + test/Gradient/Assignments.C | 350 ++++++---- test/Gradient/DiffInterface.C | 2 + test/Gradient/FunctionCalls.C | 334 +++------ test/Gradient/Functors.C | 121 ++-- test/Gradient/Gradients.C | 256 +++---- test/Gradient/Loops.C | 712 ++++++++++++-------- test/Gradient/MemberFunctions.C | 394 +++++------ test/Gradient/Pointers.C | 7 +- test/Gradient/TemplateFunctors.C | 94 +-- test/Gradient/TestAgainstDiff.C | 2 + test/Gradient/TestTypeConversion.C | 15 +- test/Gradient/UserDefinedTypes.C | 272 ++++---- test/Gradient/constexprTest.C | 43 +- test/Hessian/Arrays.C | 2 + test/Hessian/BuiltinDerivatives.C | 249 +++---- test/Hessian/Functors.C | 2 + test/Hessian/Hessians.C | 170 ++--- test/Hessian/NestedFunctionCalls.C | 70 +- test/Hessian/Pointers.C | 26 +- test/Hessian/TemplateFunctors.C | 2 + test/Hessian/constexprTest.C | 2 + test/Hessian/testhessUtility.C | 2 + test/Jacobian/FunctionCalls.C | 14 +- test/Jacobian/Functors.C | 270 +++----- test/Jacobian/Jacobian.C | 200 ++---- test/Jacobian/Pointers.C | 2 + test/Jacobian/TemplateFunctors.C | 94 +-- test/Jacobian/constexprTest.C | 83 +-- test/Jacobian/testUtility.C | 83 +-- test/Misc/RunDemos.C | 39 +- test/NestedCalls/NestedCalls.C | 38 +- test/NumericalDiff/GradientMultiArg.C | 14 +- test/NumericalDiff/NoNumDiff.C | 2 - test/NumericalDiff/NumDiff.C | 4 +- test/NumericalDiff/PrintErrorNumDiff.C | 8 +- test/ROOT/Hessian.C | 2 + test/ROOT/Interface.C | 6 +- test/ROOT/TFormula.C | 14 +- 48 files changed, 2171 insertions(+), 2654 deletions(-) diff --git a/lib/Differentiator/ReverseModeVisitor.cpp b/lib/Differentiator/ReverseModeVisitor.cpp index b7014a3e1..218218158 100644 --- a/lib/Differentiator/ReverseModeVisitor.cpp +++ b/lib/Differentiator/ReverseModeVisitor.cpp @@ -2214,9 +2214,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, if (!RDelayed.isConstant) { Expr* dr = nullptr; if (dfdx()) { - StmtDiff LResult = GlobalStoreAndRef(LStored); - LStored = LResult.getExpr(); - dr = BuildOp(BO_Mul, LResult.getExpr_dx(), dfdx()); + dr = BuildOp(BO_Mul, Ldiff.getRevSweepAsExpr(), dfdx()); dr = StoreAndRef(dr, direction::reverse); } Rdiff = Visit(R, dr); diff --git a/test/Arrays/ArrayInputsReverseMode.C b/test/Arrays/ArrayInputsReverseMode.C index aaa2d5a63..a52144c63 100644 --- a/test/Arrays/ArrayInputsReverseMode.C +++ b/test/Arrays/ArrayInputsReverseMode.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -Wno-unused-value -oArrayInputsReverseMode.out 2>&1 | FileCheck %s // RUN: ./ArrayInputsReverseMode.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -Wno-unused-value -oArrayInputsReverseMode.out +// RUN: ./ArrayInputsReverseMode.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -17,22 +19,24 @@ double addArr(const double *arr, int n) { //CHECK-NEXT: double _d_ret = 0; //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t1 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: double ret = 0; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < n; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: ret += arr[clad::push(_t1, i)]; +//CHECK-NEXT: clad::push(_t1, ret); +//CHECK-NEXT: ret += arr[i]; //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_ret += _d_y; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; //CHECK-NEXT: { +//CHECK-NEXT: ret = clad::pop(_t1); //CHECK-NEXT: double _r_d0 = _d_ret; //CHECK-NEXT: _d_ret += _r_d0; -//CHECK-NEXT: int _t2 = clad::pop(_t1); -//CHECK-NEXT: _d_arr[_t2] += _r_d0; +//CHECK-NEXT: _d_arr[i] += _r_d0; //CHECK-NEXT: _d_ret -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: } @@ -48,6 +52,7 @@ double f(double *arr) { //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { +//CHECK-NEXT: arr = _t0; //CHECK-NEXT: int _grad1 = 0; //CHECK-NEXT: addArr_pullback(_t0, 3, 1, _d_arr, &_grad1); //CHECK-NEXT: clad::array _r0(_d_arr); @@ -68,40 +73,38 @@ float func(float* a, float* b) { //CHECK-NEXT: float _d_sum = 0; //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t1 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; +//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: float sum = 0; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < 3; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: float _ref0 = a[clad::push(_t1, i)]; -//CHECK-NEXT: clad::push(_t4, _ref0); -//CHECK-NEXT: _ref0 *= clad::push(_t3, b[clad::push(_t5, i)]); -//CHECK-NEXT: sum += a[clad::push(_t7, i)]; +//CHECK-NEXT: clad::push(_t1, a[i]); +//CHECK-NEXT: a[i] *= clad::push(_t2, b[i]); +//CHECK-NEXT: clad::push(_t3, sum); +//CHECK-NEXT: sum += a[i]; //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_sum += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; //CHECK-NEXT: { +//CHECK-NEXT: sum = clad::pop(_t3); //CHECK-NEXT: float _r_d1 = _d_sum; //CHECK-NEXT: _d_sum += _r_d1; -//CHECK-NEXT: int _t8 = clad::pop(_t7); -//CHECK-NEXT: _d_a[_t8] += _r_d1; +//CHECK-NEXT: _d_a[i] += _r_d1; //CHECK-NEXT: _d_sum -= _r_d1; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: int _t2 = clad::pop(_t1); -//CHECK-NEXT: float _r_d0 = _d_a[_t2]; -//CHECK-NEXT: _d_a[_t2] += _r_d0 * clad::pop(_t3); -//CHECK-NEXT: float _r0 = clad::pop(_t4) * _r_d0; -//CHECK-NEXT: int _t6 = clad::pop(_t5); -//CHECK-NEXT: _d_b[_t6] += _r0; -//CHECK-NEXT: _d_a[_t2] -= _r_d0; -//CHECK-NEXT: _d_a[_t2]; +//CHECK-NEXT: a[i] = clad::pop(_t1); +//CHECK-NEXT: float _r_d0 = _d_a[i]; +//CHECK-NEXT: _d_a[i] += _r_d0 * clad::pop(_t2); +//CHECK-NEXT: float _r0 = a[i] * _r_d0; +//CHECK-NEXT: _d_b[i] += _r0; +//CHECK-NEXT: _d_a[i] -= _r_d0; +//CHECK-NEXT: _d_a[i]; //CHECK-NEXT: } //CHECK-NEXT: } //CHECK-NEXT: } @@ -133,25 +136,26 @@ float func2(float* a) { //CHECK-NEXT: float _d_sum = 0; //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t1 = {}; -//CHECK-NEXT: clad::tape _t3 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: float sum = 0; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < 3; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: sum += helper(clad::push(_t3, a[clad::push(_t1, i)])); +//CHECK-NEXT: clad::push(_t1, sum); +//CHECK-NEXT: sum += helper(a[i]); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_sum += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; +//CHECK-NEXT: sum = clad::pop(_t1); //CHECK-NEXT: float _r_d0 = _d_sum; //CHECK-NEXT: _d_sum += _r_d0; //CHECK-NEXT: float _grad0 = 0.F; -//CHECK-NEXT: helper_pullback(clad::pop(_t3), _r_d0, &_grad0); +//CHECK-NEXT: helper_pullback(a[i], _r_d0, &_grad0); //CHECK-NEXT: float _r0 = _grad0; -//CHECK-NEXT: int _t2 = clad::pop(_t1); -//CHECK-NEXT: _d_a[_t2] += _r0; +//CHECK-NEXT: _d_a[i] += _r0; //CHECK-NEXT: _d_sum -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: } @@ -167,27 +171,30 @@ float func3(float* a, float* b) { //CHECK-NEXT: float _d_sum = 0; //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t1 = {}; -//CHECK-NEXT: clad::tape _t3 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; +//CHECK-NEXT: clad::tape _t2 = {}; //CHECK-NEXT: float sum = 0; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < 3; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: sum += (a[clad::push(_t1, i)] += b[clad::push(_t3, i)]); +//CHECK-NEXT: clad::push(_t1, sum); +//CHECK-NEXT: clad::push(_t2, a[i]); +//CHECK-NEXT: sum += (a[i] += b[i]); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_sum += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; +//CHECK-NEXT: sum = clad::pop(_t1); //CHECK-NEXT: float _r_d0 = _d_sum; //CHECK-NEXT: _d_sum += _r_d0; -//CHECK-NEXT: int _t2 = clad::pop(_t1); -//CHECK-NEXT: float _r_d1 = _d_a[_t2]; -//CHECK-NEXT: _d_a[_t2] += _r_d1; -//CHECK-NEXT: int _t4 = clad::pop(_t3); -//CHECK-NEXT: _d_b[_t4] += _r_d1; -//CHECK-NEXT: _d_a[_t2] -= _r_d1; -//CHECK-NEXT: _d_a[_t2] += _r_d0; +//CHECK-NEXT: _d_a[i] += _r_d0; +//CHECK-NEXT: a[i] = clad::pop(_t2); +//CHECK-NEXT: float _r_d1 = _d_a[i]; +//CHECK-NEXT: _d_a[i] += _r_d1; +//CHECK-NEXT: _d_b[i] += _r_d1; +//CHECK-NEXT: _d_a[i] -= _r_d1; //CHECK-NEXT: _d_sum -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: } @@ -204,35 +211,34 @@ 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: double _t2; //CHECK-NEXT: clad::array _d_arr(3UL); //CHECK-NEXT: double _d_sum = 0; -//CHECK-NEXT: unsigned long _t3; +//CHECK-NEXT: unsigned long _t2; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape > _t4 = {}; +//CHECK-NEXT: clad::tape _t3 = {}; //CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t2 = x; //CHECK-NEXT: _t1 = x; -//CHECK-NEXT: double arr[3] = {x, 2 * _t0, _t2 * _t1}; +//CHECK-NEXT: double arr[3] = {x, 2 * _t0, x * _t1}; //CHECK-NEXT: double sum = 0; -//CHECK-NEXT: _t3 = 0; +//CHECK-NEXT: _t2 = 0; //CHECK-NEXT: for (int i = 0; i < 3; i++) { -//CHECK-NEXT: _t3++; -//CHECK-NEXT: clad::push(_t4, clad::array(arr, 3UL)); +//CHECK-NEXT: _t2++; +//CHECK-NEXT: clad::push(_t3, sum); //CHECK-NEXT: sum += addArr(arr, 3); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_sum += 1; -//CHECK-NEXT: for (; _t3; _t3--) { +//CHECK-NEXT: for (; _t2; _t2--) { +//CHECK-NEXT: i--; //CHECK-NEXT: { +//CHECK-NEXT: sum = clad::pop(_t3); //CHECK-NEXT: double _r_d0 = _d_sum; //CHECK-NEXT: _d_sum += _r_d0; -//CHECK-NEXT: clad::array _r5 = clad::pop(_t4); //CHECK-NEXT: int _grad1 = 0; -//CHECK-NEXT: addArr_pullback(_r5, 3, _r_d0, _d_arr, &_grad1); +//CHECK-NEXT: addArr_pullback(arr, 3, _r_d0, _d_arr, &_grad1); //CHECK-NEXT: clad::array _r4(_d_arr); -//CHECK-NEXT: int _r6 = _grad1; +//CHECK-NEXT: int _r5 = _grad1; //CHECK-NEXT: _d_sum -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: } @@ -243,7 +249,7 @@ double func4(double x) { //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: double _r2 = _d_arr[2] * _t1; //CHECK-NEXT: * _d_x += _r2; -//CHECK-NEXT: double _r3 = _t2 * _d_arr[2]; +//CHECK-NEXT: double _r3 = x * _d_arr[2]; //CHECK-NEXT: * _d_x += _r3; //CHECK-NEXT: } //CHECK-NEXT: } @@ -265,50 +271,52 @@ double func5(int k) { //CHECK-NEXT: int _d_n = 0; //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t1 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: double _d_sum = 0; -//CHECK-NEXT: unsigned long _t3; +//CHECK-NEXT: unsigned long _t2; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape > _t4 = {}; -//CHECK-NEXT: clad::tape _t5 = {}; +//CHECK-NEXT: clad::tape _t3 = {}; //CHECK-NEXT: int n = k; //CHECK-NEXT: clad::array _d_arr(n); //CHECK-NEXT: double arr[n]; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < n; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: arr[clad::push(_t1, i)] = k; +//CHECK-NEXT: clad::push(_t1, arr[i]); +//CHECK-NEXT: arr[i] = k; //CHECK-NEXT: } //CHECK-NEXT: double sum = 0; -//CHECK-NEXT: _t3 = 0; +//CHECK-NEXT: _t2 = 0; //CHECK-NEXT: for (int i = 0; i < 3; i++) { -//CHECK-NEXT: _t3++; -//CHECK-NEXT: clad::push(_t4, clad::array(arr, n)); -//CHECK-NEXT: sum += addArr(arr, clad::push(_t5, n)); +//CHECK-NEXT: _t2++; +//CHECK-NEXT: clad::push(_t3, sum); +//CHECK-NEXT: sum += addArr(arr, n); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_sum += 1; -//CHECK-NEXT: for (; _t3; _t3--) { +//CHECK-NEXT: for (; _t2; _t2--) { +//CHECK-NEXT: i--; //CHECK-NEXT: { +//CHECK-NEXT: sum = clad::pop(_t3); //CHECK-NEXT: double _r_d1 = _d_sum; //CHECK-NEXT: _d_sum += _r_d1; -//CHECK-NEXT: clad::array _r1 = clad::pop(_t4); //CHECK-NEXT: int _grad1 = 0; -//CHECK-NEXT: addArr_pullback(_r1, clad::pop(_t5), _r_d1, _d_arr, &_grad1); +//CHECK-NEXT: addArr_pullback(arr, n, _r_d1, _d_arr, &_grad1); //CHECK-NEXT: clad::array _r0(_d_arr); -//CHECK-NEXT: int _r2 = _grad1; -//CHECK-NEXT: _d_n += _r2; +//CHECK-NEXT: int _r1 = _grad1; +//CHECK-NEXT: _d_n += _r1; //CHECK-NEXT: _d_sum -= _r_d1; //CHECK-NEXT: } //CHECK-NEXT: } //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; //CHECK-NEXT: { -//CHECK-NEXT: int _t2 = clad::pop(_t1); -//CHECK-NEXT: double _r_d0 = _d_arr[_t2]; +//CHECK-NEXT: arr[i] = clad::pop(_t1); +//CHECK-NEXT: double _r_d0 = _d_arr[i]; //CHECK-NEXT: * _d_k += _r_d0; -//CHECK-NEXT: _d_arr[_t2] -= _r_d0; -//CHECK-NEXT: _d_arr[_t2]; +//CHECK-NEXT: _d_arr[i] -= _r_d0; +//CHECK-NEXT: _d_arr[i]; //CHECK-NEXT: } //CHECK-NEXT: } //CHECK-NEXT: * _d_k += _d_n; @@ -328,36 +336,36 @@ double func6(double seed) { //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; //CHECK-NEXT: clad::tape _t1 = {}; -//CHECK-NEXT: clad::tape _t2 = {}; //CHECK-NEXT: clad::array _d_arr(3UL); -//CHECK-NEXT: clad::tape > _t3 = {}; +//CHECK-NEXT: clad::tape _t2 = {}; //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, clad::push(_t2, seed) * clad::push(_t1, i), seed + i}; -//CHECK-NEXT: clad::push(_t3, clad::array(arr, 3UL)); +//CHECK-NEXT: double arr[3] = {seed, seed * clad::push(_t1, i), seed + i}; +//CHECK-NEXT: clad::push(_t2, sum); //CHECK-NEXT: sum += addArr(arr, 3); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_sum += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; //CHECK-NEXT: { +//CHECK-NEXT: sum = clad::pop(_t2); //CHECK-NEXT: double _r_d0 = _d_sum; //CHECK-NEXT: _d_sum += _r_d0; -//CHECK-NEXT: clad::array _r3 = clad::pop(_t3); //CHECK-NEXT: int _grad1 = 0; -//CHECK-NEXT: addArr_pullback(_r3, 3, _r_d0, _d_arr, &_grad1); +//CHECK-NEXT: addArr_pullback(arr, 3, _r_d0, _d_arr, &_grad1); //CHECK-NEXT: clad::array _r2(_d_arr); -//CHECK-NEXT: int _r4 = _grad1; +//CHECK-NEXT: int _r3 = _grad1; //CHECK-NEXT: _d_sum -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: * _d_seed += _d_arr[0]; //CHECK-NEXT: double _r0 = _d_arr[1] * clad::pop(_t1); //CHECK-NEXT: * _d_seed += _r0; -//CHECK-NEXT: double _r1 = clad::pop(_t2) * _d_arr[1]; +//CHECK-NEXT: double _r1 = seed * _d_arr[1]; //CHECK-NEXT: _d_i += _r1; //CHECK-NEXT: * _d_seed += _d_arr[2]; //CHECK-NEXT: _d_i += _d_arr[2]; @@ -373,10 +381,8 @@ 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: double _t2; -//CHECK-NEXT: _t2 = params[0]; //CHECK-NEXT: _t1 = params[0]; -//CHECK-NEXT: _t0 = (_t2 * _t1); +//CHECK-NEXT: _t0 = (params[0] * _t1); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { @@ -384,7 +390,7 @@ double inv_square(double *params) { //CHECK-NEXT: double _r1 = _d_y * -1 / (_t0 * _t0); //CHECK-NEXT: double _r2 = _r1 * _t1; //CHECK-NEXT: _d_params[0] += _r2; -//CHECK-NEXT: double _r3 = _t2 * _r1; +//CHECK-NEXT: double _r3 = params[0] * _r1; //CHECK-NEXT: _d_params[0] += _r3; //CHECK-NEXT: } //CHECK-NEXT: } @@ -403,30 +409,30 @@ double func7(double *params) { //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: std::size_t _d_i = 0; //CHECK-NEXT: clad::array _d_paramsPrime(1UL); -//CHECK-NEXT: clad::tape > _t2 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: double out = 0.; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (std::size_t i = 0; i < 1; ++i) { //CHECK-NEXT: _t0++; //CHECK-NEXT: double paramsPrime[1] = {params[0]}; -//CHECK-NEXT: clad::push(_t2, clad::array(paramsPrime, 1UL)); +//CHECK-NEXT: clad::push(_t1, out); //CHECK-NEXT: out = out + inv_square(paramsPrime); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_out += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: --i; //CHECK-NEXT: { +//CHECK-NEXT: out = clad::pop(_t1); //CHECK-NEXT: double _r_d0 = _d_out; //CHECK-NEXT: _d_out += _r_d0; -//CHECK-NEXT: clad::array _r1 = clad::pop(_t2); -//CHECK-NEXT: inv_square_pullback(_r1, _r_d0, _d_paramsPrime); +//CHECK-NEXT: inv_square_pullback(paramsPrime, _r_d0, _d_paramsPrime); //CHECK-NEXT: clad::array _r0(_d_paramsPrime); //CHECK-NEXT: _d_out -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: int _t1 = 0; -//CHECK-NEXT: _d_params[_t1] += _d_paramsPrime[0]; +//CHECK-NEXT: _d_params[0] += _d_paramsPrime[0]; //CHECK-NEXT: _d_paramsPrime = {}; //CHECK-NEXT: } //CHECK-NEXT: } @@ -456,7 +462,7 @@ int main() { auto nested = clad::gradient(func3); nested.execute(a3, b, da3, db2); - printf("Result (b) = {%.2f, %.2f, %.2f}\n", db2[0], db2[1], db2[2]); // CHECK-EXEC: Result (b) = {0.00, 0.00, 0.00} + printf("Result (b) = {%.2f, %.2f, %.2f}\n", db2[0], db2[1], db2[2]); // CHECK-EXEC: Result (b) = {1.00, 1.00, 1.00} auto constArray = clad::gradient(func4); double _dx = 0; diff --git a/test/Arrays/Arrays.C b/test/Arrays/Arrays.C index 9718498b5..913985108 100644 --- a/test/Arrays/Arrays.C +++ b/test/Arrays/Arrays.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oArrays.out 2>&1 | FileCheck %s // RUN: ./Arrays.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oArrays.out +// RUN: ./Arrays.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -95,31 +97,25 @@ double const_dot_product(double x, double y, double z) { //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 vars[3] = {x, y, z}; //CHECK-NEXT: double consts[3] = {1, 2, 3}; -//CHECK-NEXT: _t1 = vars[0]; //CHECK-NEXT: _t0 = consts[0]; -//CHECK-NEXT: _t3 = vars[1]; -//CHECK-NEXT: _t2 = consts[1]; -//CHECK-NEXT: _t5 = vars[2]; -//CHECK-NEXT: _t4 = consts[2]; +//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: _d_vars[0] += _r0; -//CHECK-NEXT: double _r1 = _t1 * 1; +//CHECK-NEXT: double _r1 = vars[0] * 1; //CHECK-NEXT: _d_consts[0] += _r1; -//CHECK-NEXT: double _r2 = 1 * _t2; +//CHECK-NEXT: double _r2 = 1 * _t1; //CHECK-NEXT: _d_vars[1] += _r2; -//CHECK-NEXT: double _r3 = _t3 * 1; +//CHECK-NEXT: double _r3 = vars[1] * 1; //CHECK-NEXT: _d_consts[1] += _r3; -//CHECK-NEXT: double _r4 = 1 * _t4; +//CHECK-NEXT: double _r4 = 1 * _t2; //CHECK-NEXT: _d_vars[2] += _r4; -//CHECK-NEXT: double _r5 = _t5 * 1; +//CHECK-NEXT: double _r5 = vars[2] * 1; //CHECK-NEXT: _d_consts[2] += _r5; //CHECK-NEXT: } //CHECK-NEXT: { diff --git a/test/ErrorEstimation/Assignments.C b/test/ErrorEstimation/Assignments.C index 97f3b638f..610ce02f7 100644 --- a/test/ErrorEstimation/Assignments.C +++ b/test/ErrorEstimation/Assignments.C @@ -13,22 +13,28 @@ float func(float x, float y) { } //CHECK: void func_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 _delta_x = 0; //CHECK-NEXT: float _EERepl_x0 = x; //CHECK-NEXT: float _EERepl_x1; +//CHECK-NEXT: float _t1; +//CHECK-NEXT: _t0 = x; //CHECK-NEXT: x = x + y; //CHECK-NEXT: _EERepl_x1 = x; +//CHECK-NEXT: _t1 = y; //CHECK-NEXT: y = x; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: * _d_y += 1; //CHECK-NEXT: { +//CHECK-NEXT: y = _t1; //CHECK-NEXT: float _r_d1 = * _d_y; //CHECK-NEXT: * _d_x += _r_d1; //CHECK-NEXT: * _d_y -= _r_d1; //CHECK-NEXT: * _d_y; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: x = _t0; //CHECK-NEXT: float _r_d0 = * _d_x; //CHECK-NEXT: * _d_x += _r_d0; //CHECK-NEXT: * _d_y += _r_d0; @@ -48,31 +54,30 @@ float func2(float x, int y) { } //CHECK: void func2_grad(float x, int y, clad::array_ref _d_x, clad::array_ref _d_y, double &_final_error) { +//CHECK-NEXT: float _t0; //CHECK-NEXT: double _delta_x = 0; //CHECK-NEXT: float _EERepl_x0 = x; -//CHECK-NEXT: float _t0; -//CHECK-NEXT: int _t1; +//CHECK-NEXT: float _t1; //CHECK-NEXT: float _t2; -//CHECK-NEXT: float _t3; //CHECK-NEXT: float _EERepl_x1; -//CHECK-NEXT: _t1 = y; //CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t3 = x; +//CHECK-NEXT: _t1 = x; //CHECK-NEXT: _t2 = x; -//CHECK-NEXT: x = _t1 * _t0 + _t3 * _t2; +//CHECK-NEXT: x = y * _t1 + x * _t2; //CHECK-NEXT: _EERepl_x1 = x; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: * _d_x += 1; //CHECK-NEXT: { +//CHECK-NEXT: x = _t0; //CHECK-NEXT: float _r_d0 = * _d_x; -//CHECK-NEXT: float _r0 = _r_d0 * _t0; +//CHECK-NEXT: float _r0 = _r_d0 * _t1; //CHECK-NEXT: * _d_y += _r0; -//CHECK-NEXT: float _r1 = _t1 * _r_d0; +//CHECK-NEXT: float _r1 = y * _r_d0; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: float _r2 = _r_d0 * _t2; //CHECK-NEXT: * _d_x += _r2; -//CHECK-NEXT: float _r3 = _t3 * _r_d0; +//CHECK-NEXT: float _r3 = x * _r_d0; //CHECK-NEXT: * _d_x += _r3; //CHECK-NEXT: _delta_x += std::abs(_r_d0 * _EERepl_x1 * {{.+}}); //CHECK-NEXT: * _d_x -= _r_d0; @@ -88,11 +93,14 @@ float func3(int x, int y) { } //CHECK: void func3_grad(int x, int y, clad::array_ref _d_x, clad::array_ref _d_y, double &_final_error) { +//CHECK-NEXT: int _t0; +//CHECK-NEXT: _t0 = x; //CHECK-NEXT: x = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: * _d_y += 1; //CHECK-NEXT: { +//CHECK-NEXT: x = _t0; //CHECK-NEXT: int _r_d0 = * _d_x; //CHECK-NEXT: * _d_y += _r_d0; //CHECK-NEXT: * _d_x -= _r_d0; @@ -110,17 +118,20 @@ float func4(float x, float y) { //CHECK-NEXT: double _d_z = 0; //CHECK-NEXT: double _delta_z = 0; //CHECK-NEXT: double _EERepl_z0; +//CHECK-NEXT: float _t0; //CHECK-NEXT: double _delta_x = 0; //CHECK-NEXT: float _EERepl_x0 = x; //CHECK-NEXT: float _EERepl_x1; //CHECK-NEXT: double z = y; //CHECK-NEXT: _EERepl_z0 = z; +//CHECK-NEXT: _t0 = x; //CHECK-NEXT: x = z + y; //CHECK-NEXT: _EERepl_x1 = x; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: * _d_x += 1; //CHECK-NEXT: { +//CHECK-NEXT: x = _t0; //CHECK-NEXT: float _r_d0 = * _d_x; //CHECK-NEXT: _d_z += _r_d0; //CHECK-NEXT: * _d_y += _r_d0; @@ -143,16 +154,19 @@ float func5(float x, float y) { //CHECK: void func5_grad(float x, float y, clad::array_ref _d_x, clad::array_ref _d_y, double &_final_error) { //CHECK-NEXT: int _d_z = 0; +//CHECK-NEXT: float _t0; //CHECK-NEXT: double _delta_x = 0; //CHECK-NEXT: float _EERepl_x0 = x; //CHECK-NEXT: float _EERepl_x1; //CHECK-NEXT: int z = 56; +//CHECK-NEXT: _t0 = x; //CHECK-NEXT: x = z + y; //CHECK-NEXT: _EERepl_x1 = x; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: * _d_x += 1; //CHECK-NEXT: { +//CHECK-NEXT: x = _t0; //CHECK-NEXT: float _r_d0 = * _d_x; //CHECK-NEXT: _d_z += _r_d0; //CHECK-NEXT: * _d_y += _r_d0; @@ -181,17 +195,15 @@ 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: float _t1; //CHECK-NEXT: double _ret_value0 = 0; -//CHECK-NEXT: _t1 = x; //CHECK-NEXT: _t0 = y; -//CHECK-NEXT: _ret_value0 = (_t1 * _t0); +//CHECK-NEXT: _ret_value0 = (x * _t0); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: float _r0 = 1 * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: float _r1 = _t1 * 1; +//CHECK-NEXT: float _r1 = x * 1; //CHECK-NEXT: * _d_y += _r1; //CHECK-NEXT: } //CHECK-NEXT: double _delta_x = 0; diff --git a/test/ErrorEstimation/BasicOps.C b/test/ErrorEstimation/BasicOps.C index 64057c056..b365891f5 100644 --- a/test/ErrorEstimation/BasicOps.C +++ b/test/ErrorEstimation/BasicOps.C @@ -14,41 +14,45 @@ float func(float x, float y) { } //CHECK: void func_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 _delta_x = 0; //CHECK-NEXT: float _EERepl_x0 = x; //CHECK-NEXT: float _EERepl_x1; +//CHECK-NEXT: float _t1; //CHECK-NEXT: double _delta_y = 0; //CHECK-NEXT: float _EERepl_y0 = y; //CHECK-NEXT: float _EERepl_y1; //CHECK-NEXT: float _EERepl_y2; -//CHECK-NEXT: float _t0; -//CHECK-NEXT: float _t1; +//CHECK-NEXT: float _t2; //CHECK-NEXT: float _d_z = 0; //CHECK-NEXT: double _delta_z = 0; //CHECK-NEXT: float _EERepl_z0; +//CHECK-NEXT: _t0 = x; //CHECK-NEXT: x = x + y; //CHECK-NEXT: _EERepl_x1 = x; +//CHECK-NEXT: _t1 = y; //CHECK-NEXT: _EERepl_y1 = y; //CHECK-NEXT: y = y + y++ + y; //CHECK-NEXT: _EERepl_y2 = y; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: float z = _t1 * _t0; +//CHECK-NEXT: _t2 = x; +//CHECK-NEXT: float z = y * _t2; //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 * _t0; +//CHECK-NEXT: float _r0 = _d_z * _t2; //CHECK-NEXT: * _d_y += _r0; -//CHECK-NEXT: float _r1 = _t1 * _d_z; +//CHECK-NEXT: float _r1 = y * _d_z; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: _delta_z += std::abs(_d_z * _EERepl_z0 * {{.+}}); //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: y = _t1; //CHECK-NEXT: float _r_d1 = * _d_y; //CHECK-NEXT: * _d_y += _r_d1; //CHECK-NEXT: * _d_y += _r_d1; +//CHECK-NEXT: y--; //CHECK-NEXT: _delta_y += std::abs(* _d_y * _EERepl_y1 * {{.+}}); //CHECK-NEXT: * _d_y += _r_d1; //CHECK-NEXT: _delta_y += std::abs(_r_d1 * _EERepl_y2 * {{.+}}); @@ -56,6 +60,7 @@ float func(float x, float y) { //CHECK-NEXT: * _d_y; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: x = _t0; //CHECK-NEXT: float _r_d0 = * _d_x; //CHECK-NEXT: * _d_x += _r_d0; //CHECK-NEXT: * _d_y += _r_d0; @@ -77,23 +82,21 @@ float func2(float x, float y) { } //CHECK: void func2_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 _delta_x = 0; //CHECK-NEXT: float _EERepl_x0 = x; -//CHECK-NEXT: float _t0; //CHECK-NEXT: float _t1; //CHECK-NEXT: float _EERepl_x1; //CHECK-NEXT: float _t2; -//CHECK-NEXT: float _t3; //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: _t0 = y; -//CHECK-NEXT: x = x - y - _t1 * _t0; +//CHECK-NEXT: x = x - y - y * _t1; //CHECK-NEXT: _EERepl_x1 = x; -//CHECK-NEXT: _t3 = y; //CHECK-NEXT: _t2 = x; -//CHECK-NEXT: float z = _t3 / _t2; +//CHECK-NEXT: float z = y / _t2; //CHECK-NEXT: _EERepl_z0 = z; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: @@ -101,17 +104,18 @@ float func2(float x, float y) { //CHECK-NEXT: { //CHECK-NEXT: float _r2 = _d_z / _t2; //CHECK-NEXT: * _d_y += _r2; -//CHECK-NEXT: float _r3 = _d_z * -_t3 / (_t2 * _t2); +//CHECK-NEXT: float _r3 = _d_z * -y / (_t2 * _t2); //CHECK-NEXT: * _d_x += _r3; //CHECK-NEXT: _delta_z += std::abs(_d_z * _EERepl_z0 * {{.+}}); //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: x = _t0; //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 * _t0; +//CHECK-NEXT: float _r0 = -_r_d0 * _t1; //CHECK-NEXT: * _d_y += _r0; -//CHECK-NEXT: float _r1 = _t1 * -_r_d0; +//CHECK-NEXT: float _r1 = y * -_r_d0; //CHECK-NEXT: * _d_y += _r1; //CHECK-NEXT: _delta_x += std::abs(_r_d0 * _EERepl_x1 * {{.+}}); //CHECK-NEXT: * _d_x -= _r_d0; @@ -133,9 +137,9 @@ float func3(float x, float y) { } //CHECK: void func3_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 _delta_x = 0; //CHECK-NEXT: float _EERepl_x0 = x; -//CHECK-NEXT: float _t0; //CHECK-NEXT: float _t1; //CHECK-NEXT: float _EERepl_x1; //CHECK-NEXT: float _d_z = 0; @@ -144,24 +148,22 @@ float func3(float x, float y) { //CHECK-NEXT: float _t2; //CHECK-NEXT: float _t3; //CHECK-NEXT: float _t4; -//CHECK-NEXT: float _t5; //CHECK-NEXT: double _delta_y = 0; //CHECK-NEXT: float _EERepl_y0 = y; //CHECK-NEXT: float _EERepl_y1; //CHECK-NEXT: float _d_t = 0; //CHECK-NEXT: double _delta_t = 0; //CHECK-NEXT: float _EERepl_t0; +//CHECK-NEXT: _t0 = x; //CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _t0 = y; -//CHECK-NEXT: x = x - y - _t1 * _t0; +//CHECK-NEXT: x = x - y - y * _t1; //CHECK-NEXT: _EERepl_x1 = x; //CHECK-NEXT: float z = y; //CHECK-NEXT: _EERepl_z0 = z; -//CHECK-NEXT: _t4 = x; //CHECK-NEXT: _t3 = z; -//CHECK-NEXT: _t5 = _t4 * _t3; +//CHECK-NEXT: _t4 = y; //CHECK-NEXT: _t2 = (y = x + x); -//CHECK-NEXT: float t = _t5 * _t2; +//CHECK-NEXT: float t = x * _t3 * _t2; //CHECK-NEXT: _EERepl_t0 = t; //CHECK-NEXT: _EERepl_y1 = y; //CHECK-NEXT: goto _label0; @@ -171,10 +173,11 @@ float func3(float x, float y) { //CHECK-NEXT: float _r2 = _d_t * _t2; //CHECK-NEXT: float _r3 = _r2 * _t3; //CHECK-NEXT: * _d_x += _r3; -//CHECK-NEXT: float _r4 = _t4 * _r2; +//CHECK-NEXT: float _r4 = x * _r2; //CHECK-NEXT: _d_z += _r4; -//CHECK-NEXT: float _r5 = _t5 * _d_t; +//CHECK-NEXT: float _r5 = x * _t3 * _d_t; //CHECK-NEXT: * _d_y += _r5; +//CHECK-NEXT: y = _t4; //CHECK-NEXT: float _r_d1 = * _d_y; //CHECK-NEXT: * _d_x += _r_d1; //CHECK-NEXT: * _d_x += _r_d1; @@ -184,12 +187,13 @@ float func3(float x, float y) { //CHECK-NEXT: } //CHECK-NEXT: * _d_y += _d_z; //CHECK-NEXT: { +//CHECK-NEXT: x = _t0; //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 * _t0; +//CHECK-NEXT: float _r0 = -_r_d0 * _t1; //CHECK-NEXT: * _d_y += _r0; -//CHECK-NEXT: float _r1 = _t1 * -_r_d0; +//CHECK-NEXT: float _r1 = y * -_r_d0; //CHECK-NEXT: * _d_y += _r1; //CHECK-NEXT: _delta_x += std::abs(_r_d0 * _EERepl_x1 * {{.+}}); //CHECK-NEXT: * _d_x -= _r_d0; @@ -204,18 +208,14 @@ float func3(float x, float y) { float func4(float x, float y) { return std::pow(x, y); } //CHECK: void func4_grad(float x, float y, clad::array_ref _d_x, clad::array_ref _d_y, double &_final_error) { -//CHECK-NEXT: float _t0; -//CHECK-NEXT: float _t1; //CHECK-NEXT: double _ret_value0 = 0; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _ret_value0 = std::pow(_t0, _t1); +//CHECK-NEXT: _ret_value0 = std::pow(x, y); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: float _grad0 = 0.F; //CHECK-NEXT: float _grad1 = 0.F; -//CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(_t0, _t1, 1, &_grad0, &_grad1); +//CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(x, y, 1, &_grad0, &_grad1); //CHECK-NEXT: float _r0 = _grad0; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: float _r1 = _grad1; @@ -235,32 +235,31 @@ float func5(float x, float y) { } //CHECK: void func5_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 _delta_y = 0; //CHECK-NEXT: float _EERepl_y0 = y; -//CHECK-NEXT: float _t0; //CHECK-NEXT: float _EERepl_y1; //CHECK-NEXT: float _t1; -//CHECK-NEXT: float _t2; //CHECK-NEXT: double _ret_value0 = 0; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: y = std::sin(_t0); +//CHECK-NEXT: _t0 = y; +//CHECK-NEXT: y = std::sin(x); //CHECK-NEXT: _EERepl_y1 = y; -//CHECK-NEXT: _t2 = y; //CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _ret_value0 = _t2 * _t1; +//CHECK-NEXT: _ret_value0 = y * _t1; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: float _r1 = 1 * _t1; //CHECK-NEXT: * _d_y += _r1; -//CHECK-NEXT: float _r2 = _t2 * 1; +//CHECK-NEXT: float _r2 = y * 1; //CHECK-NEXT: * _d_y += _r2; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: y = _t0; //CHECK-NEXT: float _r_d0 = * _d_y; -//CHECK-NEXT: float _r0 = _r_d0 * clad::custom_derivatives{{(::std)?}}::sin_pushforward(_t0, 1.F).pushforward; +//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 * {{.+}}); +//CHECK-NEXT: _delta_y += std::abs(_r_d0 * _EERepl_y1 * 1.1920928955078125E-7); //CHECK-NEXT: * _d_y -= _r_d0; //CHECK-NEXT: * _d_y; //CHECK-NEXT: } @@ -275,17 +274,15 @@ 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 _t1; //CHECK-NEXT: double _ret_value0 = 0; -//CHECK-NEXT: _t1 = x; //CHECK-NEXT: _t0 = y; -//CHECK-NEXT: _ret_value0 = _t1 * _t0; +//CHECK-NEXT: _ret_value0 = x * _t0; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r0 = _d_y0 * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * _d_y0; +//CHECK-NEXT: double _r1 = x * _d_y0; //CHECK-NEXT: * _d_y += _r1; //CHECK-NEXT: } //CHECK-NEXT: double _delta_x = 0; @@ -301,39 +298,33 @@ float func6(float x, float y) { } //CHECK: void func6_grad(float x, float y, clad::array_ref _d_x, clad::array_ref _d_y, double &_final_error) { -//CHECK-NEXT: float _t0; -//CHECK-NEXT: float _t1; //CHECK-NEXT: float _d_z = 0; //CHECK-NEXT: double _delta_z = 0; //CHECK-NEXT: float _EERepl_z0; -//CHECK-NEXT: float _t3; -//CHECK-NEXT: float _t4; +//CHECK-NEXT: float _t1; //CHECK-NEXT: double _ret_value0 = 0; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: float z = helper(_t0, _t1); +//CHECK-NEXT: float z = helper(x, y); //CHECK-NEXT: _EERepl_z0 = z; -//CHECK-NEXT: _t4 = z; -//CHECK-NEXT: _t3 = z; -//CHECK-NEXT: _ret_value0 = _t4 * _t3; +//CHECK-NEXT: _t1 = z; +//CHECK-NEXT: _ret_value0 = z * _t1; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: float _r2 = 1 * _t3; +//CHECK-NEXT: float _r2 = 1 * _t1; //CHECK-NEXT: _d_z += _r2; -//CHECK-NEXT: float _r3 = _t4 * 1; +//CHECK-NEXT: float _r3 = z * 1; //CHECK-NEXT: _d_z += _r3; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: double _grad0 = 0.; //CHECK-NEXT: double _grad1 = 0.; -//CHECK-NEXT: double _t2 = 0; -//CHECK-NEXT: helper_pullback(_t0, _t1, _d_z, &_grad0, &_grad1, _t2); +//CHECK-NEXT: double _t0 = 0; +//CHECK-NEXT: helper_pullback(x, y, _d_z, &_grad0, &_grad1, _t0); //CHECK-NEXT: double _r0 = _grad0; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = _grad1; //CHECK-NEXT: * _d_y += _r1; -//CHECK-NEXT: _delta_z += _t2; +//CHECK-NEXT: _delta_z += _t0; //CHECK-NEXT: } //CHECK-NEXT: double _delta_x = 0; //CHECK-NEXT: _delta_x += std::abs(* _d_x * x * {{.+}}); @@ -367,17 +358,15 @@ 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: float _t1; //CHECK-NEXT: double _ret_value0 = 0; -//CHECK-NEXT: _t1 = x; //CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _ret_value0 = _t1 * _t0; +//CHECK-NEXT: _ret_value0 = x * _t0; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r0 = _d_y * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * _d_y; +//CHECK-NEXT: double _r1 = x * _d_y; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: } //CHECK-NEXT: _final_error += std::abs(1. * _ret_value0 * {{.+}}); @@ -394,23 +383,27 @@ float func8(float x, float y) { //CHECK-NEXT: double _delta_z = 0; //CHECK-NEXT: float _EERepl_z0; //CHECK-NEXT: float _t0; +//CHECK-NEXT: float _t1; //CHECK-NEXT: float _EERepl_z1; //CHECK-NEXT: float z; //CHECK-NEXT: _EERepl_z0 = z; -//CHECK-NEXT: _t0 = x; +//CHECK-NEXT: _t0 = z; +//CHECK-NEXT: _t1 = x; //CHECK-NEXT: z = y + helper2(x); //CHECK-NEXT: _EERepl_z1 = z; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_z += 1; //CHECK-NEXT: { +//CHECK-NEXT: z = _t0; //CHECK-NEXT: float _r_d0 = _d_z; //CHECK-NEXT: * _d_y += _r_d0; -//CHECK-NEXT: double _t1 = 0; -//CHECK-NEXT: helper2_pullback(_t0, _r_d0, &* _d_x, _t1); +//CHECK-NEXT: x = _t1; +//CHECK-NEXT: double _t2 = 0; +//CHECK-NEXT: helper2_pullback(_t1, _r_d0, &* _d_x, _t2); //CHECK-NEXT: float _r0 = * _d_x; -//CHECK-NEXT: _delta_z += _t1; -//CHECK-NEXT: _final_error += std::abs(_r0 * _t0 * {{.+}}); +//CHECK-NEXT: _delta_z += _t2; +//CHECK-NEXT: _final_error += std::abs(_r0 * _t1 * {{.+}}); //CHECK-NEXT: _d_z -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: double _delta_x = 0; @@ -427,61 +420,61 @@ float func9(float x, float y) { } //CHECK: void func9_grad(float x, float y, clad::array_ref _d_x, clad::array_ref _d_y, double &_final_error) { -//CHECK-NEXT: float _t0; //CHECK-NEXT: float _t1; -//CHECK-NEXT: float _t3; //CHECK-NEXT: float _d_z = 0; //CHECK-NEXT: double _delta_z = 0; //CHECK-NEXT: float _EERepl_z0; -//CHECK-NEXT: double _t5; -//CHECK-NEXT: float _t6; -//CHECK-NEXT: double _t8; -//CHECK-NEXT: float _t9; +//CHECK-NEXT: float _t3; +//CHECK-NEXT: double _t4; +//CHECK-NEXT: float _t5; +//CHECK-NEXT: float _t7; //CHECK-NEXT: float _EERepl_z1; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _t3 = x; -//CHECK-NEXT: float z = helper(_t0, _t1) + helper2(x); +//CHECK-NEXT: _t1 = x; +//CHECK-NEXT: float z = helper(x, y) + helper2(x); //CHECK-NEXT: _EERepl_z0 = z; -//CHECK-NEXT: _t6 = x; -//CHECK-NEXT: _t8 = helper2(x); -//CHECK-NEXT: _t9 = y; -//CHECK-NEXT: _t5 = helper2(y); -//CHECK-NEXT: z += _t8 * _t5; +//CHECK-NEXT: _t3 = z; +//CHECK-NEXT: _t5 = x; +//CHECK-NEXT: _t7 = y; +//CHECK-NEXT: _t4 = helper2(y); +//CHECK-NEXT: z += helper2(x) * _t4; //CHECK-NEXT: _EERepl_z1 = z; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_z += 1; //CHECK-NEXT: { +//CHECK-NEXT: z = _t3; //CHECK-NEXT: float _r_d0 = _d_z; //CHECK-NEXT: _d_z += _r_d0; -//CHECK-NEXT: double _r3 = _r_d0 * _t5; -//CHECK-NEXT: double _t7 = 0; -//CHECK-NEXT: helper2_pullback(_t6, _r3, &* _d_x, _t7); +//CHECK-NEXT: double _r3 = _r_d0 * _t4; +//CHECK-NEXT: x = _t5; +//CHECK-NEXT: double _t6 = 0; +//CHECK-NEXT: helper2_pullback(_t5, _r3, &* _d_x, _t6); //CHECK-NEXT: float _r4 = * _d_x; -//CHECK-NEXT: double _r5 = _t8 * _r_d0; -//CHECK-NEXT: double _t10 = 0; -//CHECK-NEXT: helper2_pullback(_t9, _r5, &* _d_y, _t10); +//CHECK-NEXT: double _r5 = helper2(x) * _r_d0; +//CHECK-NEXT: y = _t7; +//CHECK-NEXT: double _t8 = 0; +//CHECK-NEXT: helper2_pullback(_t7, _r5, &* _d_y, _t8); //CHECK-NEXT: float _r6 = * _d_y; -//CHECK-NEXT: _delta_z += _t7 + _t10; -//CHECK-NEXT: _final_error += std::abs(_r6 * _t9 * {{.+}}); -//CHECK-NEXT: _final_error += std::abs(_r4 * _t6 * {{.+}}); +//CHECK-NEXT: _delta_z += _t6 + _t8; +//CHECK-NEXT: _final_error += std::abs(_r6 * _t7 * {{.+}}); +//CHECK-NEXT: _final_error += std::abs(_r4 * _t5 * {{.+}}); //CHECK-NEXT: _d_z -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: double _grad0 = 0.; //CHECK-NEXT: double _grad1 = 0.; -//CHECK-NEXT: double _t2 = 0; -//CHECK-NEXT: helper_pullback(_t0, _t1, _d_z, &_grad0, &_grad1, _t2); +//CHECK-NEXT: double _t0 = 0; +//CHECK-NEXT: helper_pullback(x, y, _d_z, &_grad0, &_grad1, _t0); //CHECK-NEXT: double _r0 = _grad0; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: double _r1 = _grad1; //CHECK-NEXT: * _d_y += _r1; -//CHECK-NEXT: double _t4 = 0; -//CHECK-NEXT: helper2_pullback(_t3, _d_z, &* _d_x, _t4); +//CHECK-NEXT: x = _t1; +//CHECK-NEXT: double _t2 = 0; +//CHECK-NEXT: helper2_pullback(_t1, _d_z, &* _d_x, _t2); //CHECK-NEXT: float _r2 = * _d_x; -//CHECK-NEXT: _delta_z += _t2 + _t4; -//CHECK-NEXT: _final_error += std::abs(_r2 * _t3 * {{.+}}); +//CHECK-NEXT: _delta_z += _t0 + _t2; +//CHECK-NEXT: _final_error += std::abs(_r2 * _t1 * {{.+}}); //CHECK-NEXT: } //CHECK-NEXT: double _delta_x = 0; //CHECK-NEXT: _delta_x += std::abs(* _d_x * x * {{.+}}); diff --git a/test/ErrorEstimation/ConditonalStatements.C b/test/ErrorEstimation/ConditonalStatements.C index 0b3b3392e..c66c32844 100644 --- a/test/ErrorEstimation/ConditonalStatements.C +++ b/test/ErrorEstimation/ConditonalStatements.C @@ -19,9 +19,9 @@ float func(float x, float y) { //CHECK: void func_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 _delta_y = 0; //CHECK-NEXT: float _EERepl_y0 = y; -//CHECK-NEXT: float _t0; //CHECK-NEXT: float _t1; //CHECK-NEXT: float _EERepl_y1; //CHECK-NEXT: float _d_temp = 0; @@ -30,20 +30,22 @@ float func(float x, float y) { //CHECK-NEXT: float _t2; //CHECK-NEXT: float _t3; //CHECK-NEXT: float _EERepl_temp1; +//CHECK-NEXT: float _t4; //CHECK-NEXT: double _ret_value0 = 0; //CHECK-NEXT: _cond0 = x > y; //CHECK-NEXT: if (_cond0) { -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: y = _t1 * _t0; +//CHECK-NEXT: _t0 = y; +//CHECK-NEXT: _t1 = x; +//CHECK-NEXT: y = y * _t1; //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: _t2 = y; -//CHECK-NEXT: temp = _t3 * _t2; +//CHECK-NEXT: temp = y * _t3; //CHECK-NEXT: _EERepl_temp1 = temp; +//CHECK-NEXT: _t4 = x; //CHECK-NEXT: x = y; //CHECK-NEXT: } //CHECK-NEXT: _ret_value0 = x + y; @@ -55,10 +57,11 @@ float func(float x, float y) { //CHECK-NEXT: } //CHECK-NEXT: if (_cond0) { //CHECK-NEXT: { +//CHECK-NEXT: y = _t0; //CHECK-NEXT: float _r_d0 = * _d_y; -//CHECK-NEXT: float _r0 = _r_d0 * _t0; +//CHECK-NEXT: float _r0 = _r_d0 * _t1; //CHECK-NEXT: * _d_y += _r0; -//CHECK-NEXT: float _r1 = _t1 * _r_d0; +//CHECK-NEXT: float _r1 = y * _r_d0; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: _delta_y += std::abs(_r_d0 * _EERepl_y1 * {{.+}}); //CHECK-NEXT: * _d_y -= _r_d0; @@ -66,16 +69,18 @@ float func(float x, float y) { //CHECK-NEXT: } //CHECK-NEXT: } else { //CHECK-NEXT: { +//CHECK-NEXT: x = _t4; //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: float _r_d1 = _d_temp; -//CHECK-NEXT: float _r2 = _r_d1 * _t2; +//CHECK-NEXT: float _r2 = _r_d1 * _t3; //CHECK-NEXT: * _d_y += _r2; -//CHECK-NEXT: float _r3 = _t3 * _r_d1; +//CHECK-NEXT: float _r3 = y * _r_d1; //CHECK-NEXT: * _d_y += _r3; //CHECK-NEXT: _delta_temp += std::abs(_r_d1 * _EERepl_temp1 * {{.+}}); //CHECK-NEXT: _d_temp -= _r_d1; @@ -99,26 +104,22 @@ 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 _t1; //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 _t2; -//CHECK-NEXT: float _t3; -//CHECK-NEXT: _t1 = x; +//CHECK-NEXT: float _t1; //CHECK-NEXT: _t0 = x; -//CHECK-NEXT: float z = _t1 * _t0; +//CHECK-NEXT: float z = x * _t0; //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: _t3 = x; -//CHECK-NEXT: _t2 = x; -//CHECK-NEXT: _ret_value0 = _t3 * _t2; +//CHECK-NEXT: _t1 = x; +//CHECK-NEXT: _ret_value0 = x * _t1; //CHECK-NEXT: goto _label1; //CHECK-NEXT: } //CHECK-NEXT: if (_cond0) @@ -130,15 +131,15 @@ float func2(float x) { //CHECK-NEXT: else //CHECK-NEXT: _label1: //CHECK-NEXT: { -//CHECK-NEXT: float _r2 = 1 * _t2; +//CHECK-NEXT: float _r2 = 1 * _t1; //CHECK-NEXT: * _d_x += _r2; -//CHECK-NEXT: float _r3 = _t3 * 1; +//CHECK-NEXT: float _r3 = x * 1; //CHECK-NEXT: * _d_x += _r3; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: float _r0 = _d_z * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: float _r1 = _t1 * _d_z; +//CHECK-NEXT: float _r1 = x * _d_z; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: _delta_z += std::abs(_d_z * _EERepl_z0 * {{.+}}); //CHECK-NEXT: } @@ -152,20 +153,17 @@ 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: float _t1; //CHECK-NEXT: double _ret_value0 = 0; //CHECK-NEXT: _cond0 = x > 30; -//CHECK-NEXT: if (_cond0) { -//CHECK-NEXT: _t1 = x; +//CHECK-NEXT: if (_cond0) //CHECK-NEXT: _t0 = y; -//CHECK-NEXT: } -//CHECK-NEXT: _ret_value0 = _cond0 ? _t1 * _t0 : x + y; +//CHECK-NEXT: _ret_value0 = _cond0 ? x * _t0 : x + y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: if (_cond0) { //CHECK-NEXT: float _r0 = 1 * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: float _r1 = _t1 * 1; +//CHECK-NEXT: float _r1 = x * 1; //CHECK-NEXT: * _d_y += _r1; //CHECK-NEXT: } else { //CHECK-NEXT: * _d_x += 1; @@ -185,46 +183,47 @@ float func4(float x, float y) { //CHECK: void func4_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 _delta_x = 0; //CHECK-NEXT: float _EERepl_x0 = x; //CHECK-NEXT: float _EERepl_x1; -//CHECK-NEXT: float _t0; //CHECK-NEXT: float _t1; -//CHECK-NEXT: float _EERepl_x2; //CHECK-NEXT: float _t2; +//CHECK-NEXT: float _EERepl_x2; //CHECK-NEXT: float _t3; //CHECK-NEXT: double _ret_value0 = 0; //CHECK-NEXT: _cond0 = !x; //CHECK-NEXT: if (_cond0) -//CHECK-NEXT: ; +//CHECK-NEXT: _t0 = x; //CHECK-NEXT: else { //CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t0 = x; +//CHECK-NEXT: _t2 = x; //CHECK-NEXT: } -//CHECK-NEXT: _cond0 ? (x += 1) : (x *= _t0); +//CHECK-NEXT: _cond0 ? (x += 1) : (x *= _t2); //CHECK-NEXT: _EERepl_x2 = x; //CHECK-NEXT: _EERepl_x1 = x; -//CHECK-NEXT: _t3 = y; -//CHECK-NEXT: _t2 = x; -//CHECK-NEXT: _ret_value0 = _t3 / _t2; +//CHECK-NEXT: _t3 = x; +//CHECK-NEXT: _ret_value0 = y / _t3; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: float _r1 = 1 / _t2; +//CHECK-NEXT: float _r1 = 1 / _t3; //CHECK-NEXT: * _d_y += _r1; -//CHECK-NEXT: float _r2 = 1 * -_t3 / (_t2 * _t2); +//CHECK-NEXT: float _r2 = 1 * -y / (_t3 * _t3); //CHECK-NEXT: * _d_x += _r2; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: if (_cond0) { +//CHECK-NEXT: x = _t0; //CHECK-NEXT: float _r_d0 = * _d_x; //CHECK-NEXT: * _d_x += _r_d0; //CHECK-NEXT: _delta_x += std::abs(_r_d0 * _EERepl_x1 * {{.+}}); //CHECK-NEXT: * _d_x -= _r_d0; //CHECK-NEXT: } else { +//CHECK-NEXT: x = _t1; //CHECK-NEXT: float _r_d1 = * _d_x; -//CHECK-NEXT: * _d_x += _r_d1 * _t0; -//CHECK-NEXT: float _r0 = _t1 * _r_d1; +//CHECK-NEXT: * _d_x += _r_d1 * _t2; +//CHECK-NEXT: float _r0 = x * _r_d1; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: _delta_x += std::abs(_r_d1 * _EERepl_x2 * {{.+}}); //CHECK-NEXT: * _d_x -= _r_d1; diff --git a/test/ErrorEstimation/LoopsAndArrays.C b/test/ErrorEstimation/LoopsAndArrays.C index db6d329fd..fa80f82a3 100644 --- a/test/ErrorEstimation/LoopsAndArrays.C +++ b/test/ErrorEstimation/LoopsAndArrays.C @@ -20,25 +20,27 @@ float func(float* p, int n) { //CHECK-NEXT: float _EERepl_sum0; //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t1 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: clad::tape _EERepl_sum1 = {}; //CHECK-NEXT: float sum = 0; //CHECK-NEXT: _EERepl_sum0 = sum; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < n; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: sum += p[clad::push(_t1, i)]; +//CHECK-NEXT: clad::push(_t1, sum); +//CHECK-NEXT: sum += p[i]; //CHECK-NEXT: clad::push(_EERepl_sum1, sum); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_sum += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; //CHECK-NEXT: { +//CHECK-NEXT: sum = clad::pop(_t1); //CHECK-NEXT: float _r_d0 = _d_sum; //CHECK-NEXT: _d_sum += _r_d0; -//CHECK-NEXT: int _t2 = clad::pop(_t1); -//CHECK-NEXT: _d_p[_t2] += _r_d0; +//CHECK-NEXT: _d_p[i] += _r_d0; //CHECK-NEXT: float _r0 = clad::pop(_EERepl_sum1); //CHECK-NEXT: _delta_sum += std::abs(_r_d0 * _r0 * {{.+}}); //CHECK-NEXT: _d_sum -= _r_d0; @@ -48,9 +50,9 @@ float func(float* p, int n) { //CHECK-NEXT: clad::array _delta_p(_d_p.size()); //CHECK-NEXT: int i = 0; //CHECK-NEXT: for (; i < _d_p.size(); i++) { -//CHECK-NEXT: double _t3 = std::abs(_d_p[i] * p[i] * {{.+}}); -//CHECK-NEXT: _delta_p[i] += _t3; -//CHECK-NEXT: _final_error += _t3; +//CHECK-NEXT: double _t2 = std::abs(_d_p[i] * p[i] * {{.+}}); +//CHECK-NEXT: _delta_p[i] += _t2; +//CHECK-NEXT: _final_error += _t2; //CHECK-NEXT: } //CHECK-NEXT: _final_error += _delta_sum; //CHECK-NEXT: } @@ -76,14 +78,17 @@ float func2(float x) { //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 _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: float m = clad::push(_t2, x) * clad::push(_t1, x); +//CHECK-NEXT: clad::push(_t2, m) , m = x * clad::push(_t1, x); //CHECK-NEXT: clad::push(_EERepl_m0, m); +//CHECK-NEXT: clad::push(_t3, z); //CHECK-NEXT: z = m + m; //CHECK-NEXT: clad::push(_EERepl_z1, z); //CHECK-NEXT: } @@ -91,7 +96,9 @@ float func2(float x) { //CHECK-NEXT: _label0: //CHECK-NEXT: _d_z += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; //CHECK-NEXT: { +//CHECK-NEXT: z = clad::pop(_t3); //CHECK-NEXT: float _r_d0 = _d_z; //CHECK-NEXT: _d_m += _r_d0; //CHECK-NEXT: _d_m += _r_d0; @@ -102,9 +109,10 @@ float func2(float x) { //CHECK-NEXT: { //CHECK-NEXT: float _r0 = _d_m * clad::pop(_t1); //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: float _r1 = clad::pop(_t2) * _d_m; +//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: float _r2 = clad::pop(_EERepl_m0); //CHECK-NEXT: _delta_m += std::abs(_d_m * _r2 * {{.+}}); //CHECK-NEXT: } @@ -125,24 +133,29 @@ float func3(float x, float y) { //CHECK: void func3_grad(float x, float y, clad::array_ref _d_x, clad::array_ref _d_y, double &_final_error) { //CHECK-NEXT: clad::array _d_arr(3UL); //CHECK-NEXT: clad::array _delta_arr(_d_arr.size()); +//CHECK-NEXT: double _t0; //CHECK-NEXT: double _EERepl_arr0; -//CHECK-NEXT: float _t0; -//CHECK-NEXT: float _t1; +//CHECK-NEXT: double _t1; +//CHECK-NEXT: float _t2; //CHECK-NEXT: double _EERepl_arr1; +//CHECK-NEXT: double _t3; //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 = x; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: arr[1] = _t1 * _t0; +//CHECK-NEXT: _t1 = arr[1]; +//CHECK-NEXT: _t2 = x; +//CHECK-NEXT: arr[1] = x * _t2; //CHECK-NEXT: _EERepl_arr1 = arr[1]; +//CHECK-NEXT: _t3 = 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: double _r_d2 = _d_arr[2]; //CHECK-NEXT: _d_arr[0] += _r_d2; //CHECK-NEXT: _d_arr[1] += _r_d2; @@ -152,10 +165,11 @@ float func3(float x, float y) { //CHECK-NEXT: _d_arr[2]; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: arr[1] = _t1; //CHECK-NEXT: double _r_d1 = _d_arr[1]; -//CHECK-NEXT: double _r0 = _r_d1 * _t0; +//CHECK-NEXT: double _r0 = _r_d1 * _t2; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * _r_d1; +//CHECK-NEXT: double _r1 = x * _r_d1; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: _delta_arr[1] += std::abs(_r_d1 * _EERepl_arr1 * {{.+}}); //CHECK-NEXT: _final_error += _delta_arr[1]; @@ -163,6 +177,7 @@ float func3(float x, float y) { //CHECK-NEXT: _d_arr[1]; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: arr[0] = _t0; //CHECK-NEXT: double _r_d0 = _d_arr[0]; //CHECK-NEXT: * _d_x += _r_d0; //CHECK-NEXT: * _d_y += _r_d0; @@ -193,66 +208,66 @@ float func4(float x[10], float y[10]) { //CHECK-NEXT: float _EERepl_sum0; //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t1 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: clad::array _delta_x(_d_x.size()); //CHECK-NEXT: clad::array _EERepl_x0(_d_x.size()); //CHECK-NEXT: for (int i0 = 0; i0 < _d_x.size(); i0++) { //CHECK-NEXT: _EERepl_x0[i0] = x[i0]; //CHECK-NEXT: } -//CHECK-NEXT: clad::tape _t3 = {}; //CHECK-NEXT: clad::tape _EERepl_x1 = {}; -//CHECK-NEXT: clad::tape _t5 = {}; +//CHECK-NEXT: clad::tape _t2 = {}; //CHECK-NEXT: clad::tape _EERepl_sum1 = {}; //CHECK-NEXT: float sum = 0; //CHECK-NEXT: _EERepl_sum0 = sum; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < 10; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: x[clad::push(_t1, i)] += y[clad::push(_t3, i)]; -//CHECK-NEXT: clad::push(_EERepl_x1, x[clad::push(_t1, i)]); -//CHECK-NEXT: sum += x[clad::push(_t5, i)]; +//CHECK-NEXT: clad::push(_t1, x[i]); +//CHECK-NEXT: x[i] += y[i]; +//CHECK-NEXT: clad::push(_EERepl_x1, x[i]); +//CHECK-NEXT: clad::push(_t2, sum); +//CHECK-NEXT: sum += x[i]; //CHECK-NEXT: clad::push(_EERepl_sum1, sum); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_sum += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; //CHECK-NEXT: { +//CHECK-NEXT: sum = clad::pop(_t2); //CHECK-NEXT: float _r_d1 = _d_sum; //CHECK-NEXT: _d_sum += _r_d1; -//CHECK-NEXT: int _t6 = clad::pop(_t5); -//CHECK-NEXT: _d_x[_t6] += _r_d1; -//CHECK-NEXT: float _r2 = clad::pop(_EERepl_sum1); -//CHECK-NEXT: _delta_sum += std::abs(_r_d1 * _r2 * {{.+}}); +//CHECK-NEXT: _d_x[i] += _r_d1; +//CHECK-NEXT: float _r1 = clad::pop(_EERepl_sum1); +//CHECK-NEXT: _delta_sum += std::abs(_r_d1 * _r1 * {{.+}}); //CHECK-NEXT: _d_sum -= _r_d1; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: int _t2 = clad::pop(_t1); -//CHECK-NEXT: float _r_d0 = _d_x[_t2]; -//CHECK-NEXT: _d_x[_t2] += _r_d0; -//CHECK-NEXT: int _t4 = clad::pop(_t3); -//CHECK-NEXT: _d_y[_t4] += _r_d0; +//CHECK-NEXT: x[i] = clad::pop(_t1); +//CHECK-NEXT: float _r_d0 = _d_x[i]; +//CHECK-NEXT: _d_x[i] += _r_d0; +//CHECK-NEXT: _d_y[i] += _r_d0; //CHECK-NEXT: float _r0 = clad::pop(_EERepl_x1); -//CHECK-NEXT: int _r1 = clad::pop(_t1); -//CHECK-NEXT: _delta_x[_r1] += std::abs(_r_d0 * _r0 * {{.+}}); -//CHECK-NEXT: _final_error += _delta_x[_r1]; -//CHECK-NEXT: _d_x[_t2] -= _r_d0; -//CHECK-NEXT: _d_x[_t2]; +//CHECK-NEXT: _delta_x[i] += std::abs(_r_d0 * _r0 * {{.+}}); +//CHECK-NEXT: _final_error += _delta_x[i]; +//CHECK-NEXT: _d_x[i] -= _r_d0; +//CHECK-NEXT: _d_x[i]; //CHECK-NEXT: } //CHECK-NEXT: } //CHECK-NEXT: _delta_sum += std::abs(_d_sum * _EERepl_sum0 * {{.+}}); //CHECK-NEXT: int i = 0; //CHECK-NEXT: for (; i < _d_x.size(); i++) { -//CHECK-NEXT: double _t7 = std::abs(_d_x[i] * _EERepl_x0[i] * {{.+}}); -//CHECK-NEXT: _delta_x[i] += _t7; -//CHECK-NEXT: _final_error += _t7; +//CHECK-NEXT: double _t3 = std::abs(_d_x[i] * _EERepl_x0[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 _t8 = std::abs(_d_y[i] * y[i] * {{.+}}); -//CHECK-NEXT: _delta_y[i] += _t8; -//CHECK-NEXT: _final_error += _t8; +//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: _final_error += _delta_sum; //CHECK-NEXT: } @@ -266,44 +281,38 @@ double func5(double* x, double* y, double* output) { } //CHECK: void func5_grad(double *x, double *y, double *output, clad::array_ref _d_x, clad::array_ref _d_y, clad::array_ref _d_output, double &_final_error) { +//CHECK-NEXT: double _t0; //CHECK-NEXT: clad::array _delta_output(_d_output.size()); //CHECK-NEXT: clad::array _EERepl_output0(_d_output.size()); //CHECK-NEXT: for (int i = 0; i < _d_output.size(); i++) { //CHECK-NEXT: _EERepl_output0[i] = output[i]; //CHECK-NEXT: } -//CHECK-NEXT: double _t0; //CHECK-NEXT: double _t1; //CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; //CHECK-NEXT: double _EERepl_output1; +//CHECK-NEXT: double _t3; //CHECK-NEXT: double _t4; //CHECK-NEXT: double _t5; +//CHECK-NEXT: double _EERepl_output2; //CHECK-NEXT: double _t6; //CHECK-NEXT: double _t7; -//CHECK-NEXT: double _EERepl_output2; //CHECK-NEXT: double _t8; -//CHECK-NEXT: double _t9; -//CHECK-NEXT: double _t10; -//CHECK-NEXT: double _t11; //CHECK-NEXT: double _EERepl_output3; //CHECK-NEXT: double _ret_value0 = 0; -//CHECK-NEXT: _t1 = x[1]; -//CHECK-NEXT: _t0 = y[2]; -//CHECK-NEXT: _t3 = x[2]; +//CHECK-NEXT: _t0 = output[0]; +//CHECK-NEXT: _t1 = y[2]; //CHECK-NEXT: _t2 = y[1]; -//CHECK-NEXT: output[0] = _t1 * _t0 - _t3 * _t2; +//CHECK-NEXT: output[0] = x[1] * _t1 - x[2] * _t2; //CHECK-NEXT: _EERepl_output1 = output[0]; -//CHECK-NEXT: _t5 = x[2]; +//CHECK-NEXT: _t3 = output[1]; //CHECK-NEXT: _t4 = y[0]; -//CHECK-NEXT: _t7 = x[0]; -//CHECK-NEXT: _t6 = y[2]; -//CHECK-NEXT: output[1] = _t5 * _t4 - _t7 * _t6; +//CHECK-NEXT: _t5 = y[2]; +//CHECK-NEXT: output[1] = x[2] * _t4 - x[0] * _t5; //CHECK-NEXT: _EERepl_output2 = output[1]; -//CHECK-NEXT: _t9 = x[0]; -//CHECK-NEXT: _t8 = y[1]; -//CHECK-NEXT: _t11 = y[0]; -//CHECK-NEXT: _t10 = x[1]; -//CHECK-NEXT: output[2] = _t9 * _t8 - _t11 * _t10; +//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: _EERepl_output3 = output[2]; //CHECK-NEXT: _ret_value0 = output[0] + output[1] + output[2]; //CHECK-NEXT: goto _label0; @@ -314,14 +323,15 @@ 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: double _r_d2 = _d_output[2]; -//CHECK-NEXT: double _r8 = _r_d2 * _t8; +//CHECK-NEXT: double _r8 = _r_d2 * _t7; //CHECK-NEXT: _d_x[0] += _r8; -//CHECK-NEXT: double _r9 = _t9 * _r_d2; +//CHECK-NEXT: double _r9 = x[0] * _r_d2; //CHECK-NEXT: _d_y[1] += _r9; -//CHECK-NEXT: double _r10 = -_r_d2 * _t10; +//CHECK-NEXT: double _r10 = -_r_d2 * _t8; //CHECK-NEXT: _d_y[0] += _r10; -//CHECK-NEXT: double _r11 = _t11 * -_r_d2; +//CHECK-NEXT: double _r11 = y[0] * -_r_d2; //CHECK-NEXT: _d_x[1] += _r11; //CHECK-NEXT: _delta_output[2] += std::abs(_r_d2 * _EERepl_output3 * {{.+}}); //CHECK-NEXT: _final_error += _delta_output[2]; @@ -329,14 +339,15 @@ double func5(double* x, double* y, double* output) { //CHECK-NEXT: _d_output[2]; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: output[1] = _t3; //CHECK-NEXT: double _r_d1 = _d_output[1]; //CHECK-NEXT: double _r4 = _r_d1 * _t4; //CHECK-NEXT: _d_x[2] += _r4; -//CHECK-NEXT: double _r5 = _t5 * _r_d1; +//CHECK-NEXT: double _r5 = x[2] * _r_d1; //CHECK-NEXT: _d_y[0] += _r5; -//CHECK-NEXT: double _r6 = -_r_d1 * _t6; +//CHECK-NEXT: double _r6 = -_r_d1 * _t5; //CHECK-NEXT: _d_x[0] += _r6; -//CHECK-NEXT: double _r7 = _t7 * -_r_d1; +//CHECK-NEXT: double _r7 = x[0] * -_r_d1; //CHECK-NEXT: _d_y[2] += _r7; //CHECK-NEXT: _delta_output[1] += std::abs(_r_d1 * _EERepl_output2 * {{.+}}); //CHECK-NEXT: _final_error += _delta_output[1]; @@ -344,14 +355,15 @@ double func5(double* x, double* y, double* output) { //CHECK-NEXT: _d_output[1]; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: output[0] = _t0; //CHECK-NEXT: double _r_d0 = _d_output[0]; -//CHECK-NEXT: double _r0 = _r_d0 * _t0; +//CHECK-NEXT: double _r0 = _r_d0 * _t1; //CHECK-NEXT: _d_x[1] += _r0; -//CHECK-NEXT: double _r1 = _t1 * _r_d0; +//CHECK-NEXT: double _r1 = x[1] * _r_d0; //CHECK-NEXT: _d_y[2] += _r1; //CHECK-NEXT: double _r2 = -_r_d0 * _t2; //CHECK-NEXT: _d_x[2] += _r2; -//CHECK-NEXT: double _r3 = _t3 * -_r_d0; +//CHECK-NEXT: double _r3 = x[2] * -_r_d0; //CHECK-NEXT: _d_y[1] += _r3; //CHECK-NEXT: _delta_output[0] += std::abs(_r_d0 * _EERepl_output1 * {{.+}}); //CHECK-NEXT: _final_error += _delta_output[0]; @@ -361,22 +373,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 _t12 = std::abs(_d_x[i] * x[i] * {{.+}}); -//CHECK-NEXT: _delta_x[i] += _t12; -//CHECK-NEXT: _final_error += _t12; +//CHECK-NEXT: double _t9 = std::abs(_d_x[i] * x[i] * {{.+}}); +//CHECK-NEXT: _delta_x[i] += _t9; +//CHECK-NEXT: _final_error += _t9; //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 _t13 = std::abs(_d_y[i] * y[i] * {{.+}}); -//CHECK-NEXT: _delta_y[i] += _t13; -//CHECK-NEXT: _final_error += _t13; +//CHECK-NEXT: double _t10 = std::abs(_d_y[i] * y[i] * {{.+}}); +//CHECK-NEXT: _delta_y[i] += _t10; +//CHECK-NEXT: _final_error += _t10; //CHECK-NEXT: } //CHECK-NEXT: i = 0; //CHECK-NEXT: for (; i < _d_output.size(); i++) { -//CHECK-NEXT: double _t14 = std::abs(_d_output[i] * _EERepl_output0[i] * {{.+}}); -//CHECK-NEXT: _delta_output[i] += _t14; -//CHECK-NEXT: _final_error += _t14; +//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: } //CHECK-NEXT: _final_error += std::abs(1. * _ret_value0 * {{.+}}); //CHECK-NEXT: } diff --git a/test/ErrorEstimation/LoopsAndArraysExec.C b/test/ErrorEstimation/LoopsAndArraysExec.C index 7def734d1..f9f243371 100644 --- a/test/ErrorEstimation/LoopsAndArraysExec.C +++ b/test/ErrorEstimation/LoopsAndArraysExec.C @@ -21,28 +21,28 @@ double runningSum(float* f, int n) { //CHECK-NEXT: double _EERepl_sum0; //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t1 = {}; -//CHECK-NEXT: clad::tape _t3 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: clad::tape _EERepl_sum1 = {}; //CHECK-NEXT: double sum = 0; //CHECK-NEXT: _EERepl_sum0 = sum; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 1; i < n; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: sum += f[clad::push(_t1, i)] + f[clad::push(_t3, i - 1)]; +//CHECK-NEXT: clad::push(_t1, sum); +//CHECK-NEXT: sum += f[i] + f[i - 1]; //CHECK-NEXT: clad::push(_EERepl_sum1, sum); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_sum += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; //CHECK-NEXT: { +//CHECK-NEXT: sum = clad::pop(_t1); //CHECK-NEXT: double _r_d0 = _d_sum; //CHECK-NEXT: _d_sum += _r_d0; -//CHECK-NEXT: int _t2 = clad::pop(_t1); -//CHECK-NEXT: _d_f[_t2] += _r_d0; -//CHECK-NEXT: int _t4 = clad::pop(_t3); -//CHECK-NEXT: _d_f[_t4] += _r_d0; +//CHECK-NEXT: _d_f[i] += _r_d0; +//CHECK-NEXT: _d_f[i - 1] += _r_d0; //CHECK-NEXT: double _r0 = clad::pop(_EERepl_sum1); //CHECK-NEXT: _delta_sum += std::abs(_r_d0 * _r0 * {{.+}}); //CHECK-NEXT: _d_sum -= _r_d0; @@ -52,9 +52,9 @@ double runningSum(float* f, int n) { //CHECK-NEXT: clad::array _delta_f(_d_f.size()); //CHECK-NEXT: int i = 0; //CHECK-NEXT: for (; i < _d_f.size(); i++) { -//CHECK-NEXT: double _t5 = std::abs(_d_f[i] * f[i] * {{.+}}); -//CHECK-NEXT: _delta_f[i] += _t5; -//CHECK-NEXT: _final_error += _t5; +//CHECK-NEXT: double _t2 = std::abs(_d_f[i] * f[i] * {{.+}}); +//CHECK-NEXT: _delta_f[i] += _t2; +//CHECK-NEXT: _final_error += _t2; //CHECK-NEXT: } //CHECK-NEXT: _final_error += _delta_sum; //CHECK-NEXT: } @@ -75,11 +75,11 @@ double mulSum(float* a, float* b, int n) { //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; //CHECK-NEXT: clad::tape _t1 = {}; +//CHECK-NEXT: clad::tape _t2 = {}; //CHECK-NEXT: int _d_j = 0; -//CHECK-NEXT: clad::tape _t2 = {}; -//CHECK-NEXT: clad::tape _t3 = {}; -//CHECK-NEXT: clad::tape _t5 = {}; -//CHECK-NEXT: clad::tape _t6 = {}; +//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; @@ -87,9 +87,10 @@ double mulSum(float* a, float* b, int n) { //CHECK-NEXT: for (int i = 0; i < n; i++) { //CHECK-NEXT: _t0++; //CHECK-NEXT: clad::push(_t1, 0UL); -//CHECK-NEXT: for (int j = 0; j < n; j++) { +//CHECK-NEXT: for (clad::push(_t2, j) , j = 0; j < n; j++) { //CHECK-NEXT: clad::back(_t1)++; -//CHECK-NEXT: sum += clad::push(_t5, a[clad::push(_t3, i)]) * clad::push(_t2, b[clad::push(_t6, j)]); +//CHECK-NEXT: clad::push(_t3, sum); +//CHECK-NEXT: sum += a[i] * clad::push(_t4, b[j]); //CHECK-NEXT: clad::push(_EERepl_sum1, sum); //CHECK-NEXT: } //CHECK-NEXT: } @@ -97,21 +98,25 @@ double mulSum(float* a, float* b, int n) { //CHECK-NEXT: _label0: //CHECK-NEXT: _d_sum += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; //CHECK-NEXT: { //CHECK-NEXT: for (; clad::back(_t1); clad::back(_t1)--) { +//CHECK-NEXT: j--; +//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(_t2); -//CHECK-NEXT: int _t4 = clad::pop(_t3); -//CHECK-NEXT: _d_a[_t4] += _r0; -//CHECK-NEXT: double _r1 = clad::pop(_t5) * _r_d0; -//CHECK-NEXT: int _t7 = clad::pop(_t6); -//CHECK-NEXT: _d_b[_t7] += _r1; +//CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t4); +//CHECK-NEXT: _d_a[i] += _r0; +//CHECK-NEXT: double _r1 = a[i] * _r_d0; +//CHECK-NEXT: _d_b[j] += _r1; //CHECK-NEXT: double _r2 = clad::pop(_EERepl_sum1); //CHECK-NEXT: _delta_sum += std::abs(_r_d0 * _r2 * {{.+}}); //CHECK-NEXT: _d_sum -= _r_d0; //CHECK-NEXT: } -//CHECK-NEXT: _d_j = 0; +//CHECK-NEXT: { +//CHECK-NEXT: _d_j = 0; +//CHECK-NEXT: j = clad::pop(_t2); +//CHECK-NEXT: } //CHECK-NEXT: clad::pop(_t1); //CHECK-NEXT: } //CHECK-NEXT: } @@ -119,16 +124,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 _t8 = std::abs(_d_a[i] * a[i] * {{.+}}); -//CHECK-NEXT: _delta_a[i] += _t8; -//CHECK-NEXT: _final_error += _t8; +//CHECK-NEXT: double _t5 = std::abs(_d_a[i] * a[i] * {{.+}}); +//CHECK-NEXT: _delta_a[i] += _t5; +//CHECK-NEXT: _final_error += _t5; //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 _t9 = std::abs(_d_b[i] * b[i] * {{.+}}); -//CHECK-NEXT: _delta_b[i] += _t9; -//CHECK-NEXT: _final_error += _t9; +//CHECK-NEXT: double _t6 = std::abs(_d_b[i] * b[i] * {{.+}}); +//CHECK-NEXT: _delta_b[i] += _t6; +//CHECK-NEXT: _final_error += _t6; //CHECK-NEXT: } //CHECK-NEXT: _final_error += _delta_sum; //CHECK-NEXT: } @@ -147,33 +152,32 @@ double divSum(float* a, float* b, int n) { //CHECK-NEXT: double _EERepl_sum0; //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 _t4 = {}; -//CHECK-NEXT: clad::tape _t5 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; +//CHECK-NEXT: clad::tape _t2 = {}; //CHECK-NEXT: clad::tape _EERepl_sum1 = {}; //CHECK-NEXT: double sum = 0; //CHECK-NEXT: _EERepl_sum0 = sum; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < n; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: sum += clad::push(_t4, a[clad::push(_t2, i)]) / clad::push(_t1, b[clad::push(_t5, i)]); +//CHECK-NEXT: clad::push(_t1, sum); +//CHECK-NEXT: sum += a[i] / clad::push(_t2, b[i]); //CHECK-NEXT: clad::push(_EERepl_sum1, sum); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_sum += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; //CHECK-NEXT: { +//CHECK-NEXT: sum = clad::pop(_t1); //CHECK-NEXT: double _r_d0 = _d_sum; //CHECK-NEXT: _d_sum += _r_d0; -//CHECK-NEXT: float _r0 = clad::pop(_t1); +//CHECK-NEXT: float _r0 = clad::pop(_t2); //CHECK-NEXT: double _r1 = _r_d0 / _r0; -//CHECK-NEXT: int _t3 = clad::pop(_t2); -//CHECK-NEXT: _d_a[_t3] += _r1; -//CHECK-NEXT: double _r2 = _r_d0 * -clad::pop(_t4) / (_r0 * _r0); -//CHECK-NEXT: int _t6 = clad::pop(_t5); -//CHECK-NEXT: _d_b[_t6] += _r2; +//CHECK-NEXT: _d_a[i] += _r1; +//CHECK-NEXT: double _r2 = _r_d0 * -a[i] / (_r0 * _r0); +//CHECK-NEXT: _d_b[i] += _r2; //CHECK-NEXT: double _r3 = clad::pop(_EERepl_sum1); //CHECK-NEXT: _delta_sum += std::abs(_r_d0 * _r3 * {{.+}}); //CHECK-NEXT: _d_sum -= _r_d0; @@ -183,16 +187,16 @@ double divSum(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 _t7 = std::abs(_d_a[i] * a[i] * {{.+}}); -//CHECK-NEXT: _delta_a[i] += _t7; -//CHECK-NEXT: _final_error += _t7; +//CHECK-NEXT: double _t3 = std::abs(_d_a[i] * a[i] * {{.+}}); +//CHECK-NEXT: _delta_a[i] += _t3; +//CHECK-NEXT: _final_error += _t3; //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 _t8 = std::abs(_d_b[i] * b[i] * {{.+}}); -//CHECK-NEXT: _delta_b[i] += _t8; -//CHECK-NEXT: _final_error += _t8; +//CHECK-NEXT: double _t4 = std::abs(_d_b[i] * b[i] * {{.+}}); +//CHECK-NEXT: _delta_b[i] += _t4; +//CHECK-NEXT: _final_error += _t4; //CHECK-NEXT: } //CHECK-NEXT: _final_error += _delta_sum; //CHECK-NEXT: } diff --git a/test/FirstDerivative/BuiltinDerivatives.C b/test/FirstDerivative/BuiltinDerivatives.C index 34d7b15ef..de59f71b9 100644 --- a/test/FirstDerivative/BuiltinDerivatives.C +++ b/test/FirstDerivative/BuiltinDerivatives.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -Xclang -verify -oBuiltinDerivatives.out 2>&1 | FileCheck %s // RUN: ./BuiltinDerivatives.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -Xclang -verify -oBuiltinDerivatives.out +// RUN: ./BuiltinDerivatives.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -100,14 +102,12 @@ float f7(float x) { void f7_grad(float x, clad::array_ref _d_x); // CHECK: void f7_grad(float x, 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 _grad0 = 0.F; // CHECK-NEXT: double _grad1 = 0.; -// CHECK-NEXT: {{(clad::)?}}custom_derivatives{{(::std)?}}::pow_pullback(_t0, 2., 1, &_grad0, &_grad1); +// CHECK-NEXT: clad::custom_derivatives::pow_pullback(x, 2., 1, &_grad0, &_grad1); // CHECK-NEXT: float _r0 = _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: double _r1 = _grad1; @@ -127,14 +127,12 @@ double f8(float x) { void f8_grad(float x, clad::array_ref _d_x); // CHECK: void f8_grad(float x, 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 _grad0 = 0.F; // CHECK-NEXT: int _grad1 = 0; -// CHECK-NEXT: {{(clad::)?}}custom_derivatives{{(::std)?}}::pow_pullback(_t0, 2, 1, &_grad0, &_grad1); +// CHECK-NEXT: clad::custom_derivatives::pow_pullback(x, 2, 1, &_grad0, &_grad1); // CHECK-NEXT: float _r0 = _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: int _r1 = _grad1; @@ -155,16 +153,12 @@ float f9(float x, float y) { void f9_grad(float x, float y, clad::array_ref _d_x, clad::array_ref _d_y); // CHECK: void f9_grad(float x, float y, clad::array_ref _d_x, clad::array_ref _d_y) { -// CHECK-NEXT: float _t0; -// CHECK-NEXT: float _t1; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t1 = y; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: float _grad0 = 0.F; // CHECK-NEXT: float _grad1 = 0.F; -// CHECK-NEXT: {{(clad::)?}}custom_derivatives{{(::std)?}}::pow_pullback(_t0, _t1, 1, &_grad0, &_grad1); +// CHECK-NEXT: clad::custom_derivatives::pow_pullback(x, y, 1, &_grad0, &_grad1); // CHECK-NEXT: float _r0 = _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: float _r1 = _grad1; @@ -186,16 +180,12 @@ double f10(float x, int y) { void f10_grad(float x, int y, clad::array_ref _d_x, clad::array_ref _d_y); // CHECK: void f10_grad(float x, int y, clad::array_ref _d_x, clad::array_ref _d_y) { -// CHECK-NEXT: float _t0; -// CHECK-NEXT: int _t1; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t1 = y; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: float _grad0 = 0.F; // CHECK-NEXT: int _grad1 = 0; -// CHECK-NEXT: {{(clad::)?}}custom_derivatives{{(::std)?}}::pow_pullback(_t0, _t1, 1, &_grad0, &_grad1); +// CHECK-NEXT: clad::custom_derivatives::pow_pullback(x, y, 1, &_grad0, &_grad1); // CHECK-NEXT: float _r0 = _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: int _r1 = _grad1; @@ -208,33 +198,27 @@ double f11(double x, double y) { } // CHECK: void f11_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: typename {{.*}} _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; -// CHECK-NEXT: _t0 = (1. - x); -// CHECK-NEXT: _t2 = x; -// CHECK-NEXT: _t3 = y - std::pow(_t2, 2); -// CHECK-NEXT: _t1 = std::pow(_t3, 2); +// CHECK-NEXT: typename {{.*}} _t0; +// CHECK-NEXT: _t0 = std::pow(y - std::pow(x, 2), 2); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _grad0 = 0.; // CHECK-NEXT: int _grad1 = 0; -// CHECK-NEXT: {{(clad::)?}}custom_derivatives{{(::std)?}}::pow_pullback(_t0, 2, 1, &_grad0, &_grad1); +// CHECK-NEXT: clad::custom_derivatives::pow_pullback((1. - x), 2, 1, &_grad0, &_grad1); // CHECK-NEXT: double _r0 = _grad0; // CHECK-NEXT: * _d_x += -_r0; // CHECK-NEXT: int _r1 = _grad1; -// CHECK-NEXT: double _r2 = 1 * _t1; +// CHECK-NEXT: double _r2 = 1 * _t0; // CHECK-NEXT: double _r3 = 100. * 1; // CHECK-NEXT: double _grad4 = 0.; // CHECK-NEXT: int _grad5 = 0; -// CHECK-NEXT: {{(clad::)?}}custom_derivatives{{(::std)?}}::pow_pullback(_t3, 2, _r3, &_grad4, &_grad5); +// CHECK-NEXT: clad::custom_derivatives::pow_pullback(y - std::pow(x, 2), 2, _r3, &_grad4, &_grad5); // CHECK-NEXT: double _r4 = _grad4; // CHECK-NEXT: * _d_y += _r4; // CHECK-NEXT: double _grad2 = 0.; // CHECK-NEXT: int _grad3 = 0; -// CHECK-NEXT: {{(clad::)?}}custom_derivatives{{(::std)?}}::pow_pullback(_t2, 2, -_r4, &_grad2, &_grad3); +// CHECK-NEXT: clad::custom_derivatives::pow_pullback(x, 2, -_r4, &_grad2, &_grad3); // CHECK-NEXT: double _r5 = _grad2; // CHECK-NEXT: * _d_x += _r5; // CHECK-NEXT: int _r6 = _grad3; diff --git a/test/FirstDerivative/UnsupportedOpsWarn.C b/test/FirstDerivative/UnsupportedOpsWarn.C index fba84186c..2a618c54d 100644 --- a/test/FirstDerivative/UnsupportedOpsWarn.C +++ b/test/FirstDerivative/UnsupportedOpsWarn.C @@ -1,4 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -fsyntax-only -Xclang -verify 2>&1 | FileCheck %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -fsyntax-only -Xclang -verify #include "clad/Differentiator/Differentiator.h" diff --git a/test/Gradient/Assignments.C b/test/Gradient/Assignments.C index bf0514afd..cc180b021 100644 --- a/test/Gradient/Assignments.C +++ b/test/Gradient/Assignments.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oReverseAssignments.out 2>&1 | FileCheck %s // RUN: ./ReverseAssignments.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oReverseAssignments.out +// RUN: ./ReverseAssignments.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -12,11 +14,14 @@ double f1(double x, double y) { } //CHECK: void f1_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { +//CHECK-NEXT: double _t0; +//CHECK-NEXT: _t0 = x; //CHECK-NEXT: x = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: * _d_y += 1; //CHECK-NEXT: { +//CHECK-NEXT: x = _t0; //CHECK-NEXT: double _r_d0 = * _d_x; //CHECK-NEXT: * _d_y += _r_d0; //CHECK-NEXT: * _d_x -= _r_d0; @@ -33,13 +38,17 @@ double f2(double x, double y) { //CHECK: void f2_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { //CHECK-NEXT: bool _cond0; +//CHECK-NEXT: double _t0; //CHECK-NEXT: _cond0 = x < y; -//CHECK-NEXT: if (_cond0) +//CHECK-NEXT: if (_cond0) { +//CHECK-NEXT: _t0 = x; //CHECK-NEXT: x = y; +//CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: * _d_x += 1; //CHECK-NEXT: if (_cond0) { +//CHECK-NEXT: x = _t0; //CHECK-NEXT: double _r_d0 = * _d_x; //CHECK-NEXT: * _d_y += _r_d0; //CHECK-NEXT: * _d_x -= _r_d0; @@ -61,42 +70,50 @@ 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: _t0 = x; -//CHECK-NEXT: x = _t1 * _t0; -//CHECK-NEXT: _t3 = x; //CHECK-NEXT: _t2 = x; -//CHECK-NEXT: y = _t3 * _t2; +//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 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: * _d_y += 1; //CHECK-NEXT: { +//CHECK-NEXT: x = _t5; //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: double _r_d2 = * _d_y; -//CHECK-NEXT: double _r2 = _r_d2 * _t2; +//CHECK-NEXT: double _r2 = _r_d2 * _t4; //CHECK-NEXT: * _d_x += _r2; -//CHECK-NEXT: double _r3 = _t3 * _r_d2; +//CHECK-NEXT: double _r3 = x * _r_d2; //CHECK-NEXT: * _d_x += _r3; //CHECK-NEXT: * _d_y -= _r_d2; //CHECK-NEXT: * _d_y; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: x = _t1; //CHECK-NEXT: double _r_d1 = * _d_x; -//CHECK-NEXT: double _r0 = _r_d1 * _t0; +//CHECK-NEXT: double _r0 = _r_d1 * _t2; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * _r_d1; +//CHECK-NEXT: double _r1 = x * _r_d1; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: * _d_x -= _r_d1; //CHECK-NEXT: * _d_x; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: x = _t0; //CHECK-NEXT: double _r_d0 = * _d_x; //CHECK-NEXT: * _d_x += _r_d0; //CHECK-NEXT: * _d_x -= _r_d0; @@ -112,17 +129,23 @@ double f4(double x, double y) { } //CHECK: void f4_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: y = x; +//CHECK-NEXT: _t1 = x; //CHECK-NEXT: x = 0; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: * _d_y += 1; //CHECK-NEXT: { +//CHECK-NEXT: x = _t1; //CHECK-NEXT: double _r_d1 = * _d_x; //CHECK-NEXT: * _d_x -= _r_d1; //CHECK-NEXT: * _d_x; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: y = _t0; //CHECK-NEXT: double _r_d0 = * _d_y; //CHECK-NEXT: * _d_x += _r_d0; //CHECK-NEXT: * _d_y -= _r_d0; @@ -146,22 +169,24 @@ 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 _t1; //CHECK-NEXT: double _d_t = 0; //CHECK-NEXT: bool _cond0; +//CHECK-NEXT: double _t1; //CHECK-NEXT: bool _cond1; //CHECK-NEXT: double _d_z = 0; -//CHECK-NEXT: _t1 = x; +//CHECK-NEXT: double _t2; //CHECK-NEXT: _t0 = x; -//CHECK-NEXT: double t = _t1 * _t0; +//CHECK-NEXT: double t = x * _t0; //CHECK-NEXT: _cond0 = x < 0; //CHECK-NEXT: if (_cond0) { +//CHECK-NEXT: _t1 = 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: t = -t; //CHECK-NEXT: } //CHECK-NEXT: goto _label1; @@ -169,6 +194,7 @@ double f5(double x, double y) { //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: if (_cond1) { //CHECK-NEXT: { +//CHECK-NEXT: t = _t2; //CHECK-NEXT: double _r_d1 = _d_t; //CHECK-NEXT: _d_t += -_r_d1; //CHECK-NEXT: _d_t -= _r_d1; @@ -179,6 +205,7 @@ double f5(double x, double y) { //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: { +//CHECK-NEXT: t = _t1; //CHECK-NEXT: double _r_d0 = _d_t; //CHECK-NEXT: _d_t += -_r_d0; //CHECK-NEXT: _d_t -= _r_d0; @@ -187,7 +214,7 @@ double f5(double x, double y) { //CHECK-NEXT: { //CHECK-NEXT: double _r0 = _d_t * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * _d_t; +//CHECK-NEXT: double _r1 = x * _d_t; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: } //CHECK-NEXT: } @@ -206,24 +233,26 @@ double f6(double x, double y) { return t; } -//CHECK: void f6_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { +//CHECK-NEXT: void f6_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 _d_t = 0; //CHECK-NEXT: bool _cond0; +//CHECK-NEXT: double _t1; //CHECK-NEXT: bool _cond1; //CHECK-NEXT: double _d_z = 0; -//CHECK-NEXT: _t1 = x; +//CHECK-NEXT: double _t2; //CHECK-NEXT: _t0 = x; -//CHECK-NEXT: double t = _t1 * _t0; +//CHECK-NEXT: double t = x * _t0; //CHECK-NEXT: _cond0 = x < 0; //CHECK-NEXT: if (_cond0) { +//CHECK-NEXT: _t1 = 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: t = -t; //CHECK-NEXT: } //CHECK-NEXT: goto _label1; @@ -231,6 +260,7 @@ double f6(double x, double y) { //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: if (_cond1) { //CHECK-NEXT: { +//CHECK-NEXT: t = _t2; //CHECK-NEXT: double _r_d1 = _d_t; //CHECK-NEXT: _d_t += -_r_d1; //CHECK-NEXT: _d_t -= _r_d1; @@ -241,6 +271,7 @@ double f6(double x, double y) { //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: { +//CHECK-NEXT: t = _t1; //CHECK-NEXT: double _r_d0 = _d_t; //CHECK-NEXT: _d_t += -_r_d0; //CHECK-NEXT: _d_t -= _r_d0; @@ -249,7 +280,7 @@ double f6(double x, double y) { //CHECK-NEXT: { //CHECK-NEXT: double _r0 = _d_t * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * _d_t; +//CHECK-NEXT: double _r1 = x * _d_t; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: } //CHECK-NEXT: } @@ -270,42 +301,53 @@ double f7(double x, double y) { return t[0]; // == x } -//CHECK: void f7_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { +//CHECK-NEXT: void f7_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: clad::array _d_t(3UL); +//CHECK-NEXT: double _t1; //CHECK-NEXT: double _t2; //CHECK-NEXT: double _t3; //CHECK-NEXT: double _t4; //CHECK-NEXT: double _t5; -//CHECK-NEXT: _t1 = x; +//CHECK-NEXT: double _t6; +//CHECK-NEXT: double _t7; +//CHECK-NEXT: double _t8; +//CHECK-NEXT: double _t9; //CHECK-NEXT: _t0 = x; -//CHECK-NEXT: double t[3] = {1, x, _t1 * _t0}; +//CHECK-NEXT: double t[3] = {1, x, x * _t0}; //CHECK-NEXT: t[0]++; //CHECK-NEXT: t[0]--; //CHECK-NEXT: ++t[0]; //CHECK-NEXT: --t[0]; +//CHECK-NEXT: _t1 = t[0]; //CHECK-NEXT: t[0] = x; +//CHECK-NEXT: _t2 = x; //CHECK-NEXT: x = y; -//CHECK-NEXT: t[0] += t[1]; //CHECK-NEXT: _t3 = t[0]; -//CHECK-NEXT: _t2 = t[1]; -//CHECK-NEXT: t[0] *= _t2; -//CHECK-NEXT: _t5 = t[0]; -//CHECK-NEXT: _t4 = t[1]; -//CHECK-NEXT: t[0] /= _t4; +//CHECK-NEXT: t[0] += t[1]; +//CHECK-NEXT: _t4 = t[0]; +//CHECK-NEXT: _t5 = t[1]; +//CHECK-NEXT: t[0] *= _t5; +//CHECK-NEXT: _t6 = t[0]; +//CHECK-NEXT: _t7 = t[1]; +//CHECK-NEXT: t[0] /= _t7; +//CHECK-NEXT: _t8 = t[0]; //CHECK-NEXT: t[0] -= t[1]; +//CHECK-NEXT: _t9 = x; //CHECK-NEXT: x = ++t[0]; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t[0] += 1; //CHECK-NEXT: { +//CHECK-NEXT: x = _t9; //CHECK-NEXT: double _r_d6 = * _d_x; //CHECK-NEXT: _d_t[0] += _r_d6; +//CHECK-NEXT: --t[0]; //CHECK-NEXT: * _d_x -= _r_d6; //CHECK-NEXT: * _d_x; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: t[0] = _t8; //CHECK-NEXT: double _r_d5 = _d_t[0]; //CHECK-NEXT: _d_t[0] += _r_d5; //CHECK-NEXT: _d_t[1] += -_r_d5; @@ -313,22 +355,25 @@ double f7(double x, double y) { //CHECK-NEXT: _d_t[0]; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: t[0] = _t6; //CHECK-NEXT: double _r_d4 = _d_t[0]; -//CHECK-NEXT: _d_t[0] += _r_d4 / _t4; -//CHECK-NEXT: double _r3 = _r_d4 * -_t5 / (_t4 * _t4); +//CHECK-NEXT: _d_t[0] += _r_d4 / _t7; +//CHECK-NEXT: double _r3 = _r_d4 * -t[0] / (_t7 * _t7); //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: double _r_d3 = _d_t[0]; -//CHECK-NEXT: _d_t[0] += _r_d3 * _t2; -//CHECK-NEXT: double _r2 = _t3 * _r_d3; +//CHECK-NEXT: _d_t[0] += _r_d3 * _t5; +//CHECK-NEXT: double _r2 = t[0] * _r_d3; //CHECK-NEXT: _d_t[1] += _r2; //CHECK-NEXT: _d_t[0] -= _r_d3; //CHECK-NEXT: _d_t[0]; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: t[0] = _t3; //CHECK-NEXT: double _r_d2 = _d_t[0]; //CHECK-NEXT: _d_t[0] += _r_d2; //CHECK-NEXT: _d_t[1] += _r_d2; @@ -336,24 +381,34 @@ double f7(double x, double y) { //CHECK-NEXT: _d_t[0]; //CHECK-NEXT: } //CHECK-NEXT: { +//CHECK-NEXT: x = _t2; //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: double _r_d0 = _d_t[0]; //CHECK-NEXT: * _d_x += _r_d0; //CHECK-NEXT: _d_t[0] -= _r_d0; //CHECK-NEXT: _d_t[0]; //CHECK-NEXT: } -//CHECK-NEXT: _d_t[0]; -//CHECK-NEXT: _d_t[0]; +//CHECK-NEXT: ++t[0]; +//CHECK-NEXT: --t[0]; +//CHECK-NEXT: { +//CHECK-NEXT: t[0]++; +//CHECK-NEXT: _d_t[0]; +//CHECK-NEXT: } +//CHECK-NEXT: { +//CHECK-NEXT: t[0]--; +//CHECK-NEXT: _d_t[0]; +//CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: * _d_x += _d_t[1]; //CHECK-NEXT: double _r0 = _d_t[2] * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * _d_t[2]; +//CHECK-NEXT: double _r1 = x * _d_t[2]; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: } //CHECK-NEXT: } @@ -364,26 +419,36 @@ double f8(double x, double y) { return t[3]; // == y * y } -//CHECK: void f8_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { +//CHECK-NEXT: void f8_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { //CHECK-NEXT: clad::array _d_t(4UL); //CHECK-NEXT: double _t0; //CHECK-NEXT: double _t1; +//CHECK-NEXT: double _t2; +//CHECK-NEXT: double _t3; +//CHECK-NEXT: double _t4; //CHECK-NEXT: double t[4] = {1, x, y, 1}; +//CHECK-NEXT: _t0 = t[3]; //CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _t0 = (t[0] = t[1] = t[2]); -//CHECK-NEXT: t[3] = (y *= _t0); +//CHECK-NEXT: _t3 = t[0]; +//CHECK-NEXT: _t4 = t[1]; +//CHECK-NEXT: _t2 = (t[0] = t[1] = t[2]); +//CHECK-NEXT: t[3] = (y *= _t2); //CHECK-NEXT: goto _label0; -//CHECK-NEXT: _label0: +//CHECK-NEXT: _label0: //CHECK-NEXT: _d_t[3] += 1; //CHECK-NEXT: { +//CHECK-NEXT: t[3] = _t0; //CHECK-NEXT: double _r_d0 = _d_t[3]; //CHECK-NEXT: * _d_y += _r_d0; +//CHECK-NEXT: y = _t1; //CHECK-NEXT: double _r_d1 = * _d_y; -//CHECK-NEXT: * _d_y += _r_d1 * _t0; -//CHECK-NEXT: double _r0 = _t1 * _r_d1; +//CHECK-NEXT: * _d_y += _r_d1 * _t2; +//CHECK-NEXT: double _r0 = y * _r_d1; //CHECK-NEXT: _d_t[0] += _r0; +//CHECK-NEXT: t[0] = _t3; //CHECK-NEXT: double _r_d2 = _d_t[0]; //CHECK-NEXT: _d_t[1] += _r_d2; +//CHECK-NEXT: t[1] = _t4; //CHECK-NEXT: double _r_d3 = _d_t[1]; //CHECK-NEXT: _d_t[2] += _r_d3; //CHECK-NEXT: _d_t[1] -= _r_d3; @@ -396,7 +461,7 @@ double f8(double x, double y) { //CHECK-NEXT: * _d_x += _d_t[1]; //CHECK-NEXT: * _d_y += _d_t[2]; //CHECK-NEXT: } -//CHECK-NEXT: } +//CHECK-NEXT: } double f9(double x, double y) { double t = x; @@ -408,27 +473,29 @@ double f9(double x, double y) { //CHECK-NEXT: double _d_t = 0; //CHECK-NEXT: double _t0; //CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; //CHECK-NEXT: double _t3; +//CHECK-NEXT: double _t4; //CHECK-NEXT: double t = x; -//CHECK-NEXT: _t1 = t; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: double _ref0 = (t *= _t0); -//CHECK-NEXT: _t3 = _ref0; -//CHECK-NEXT: _t2 = y; -//CHECK-NEXT: _ref0 *= _t2; +//CHECK-NEXT: _t0 = t; +//CHECK-NEXT: _t1 = x; +//CHECK-NEXT: double &_t2 = (t *= _t1); +//CHECK-NEXT: _t3 = t; +//CHECK-NEXT: _t4 = y; +//CHECK-NEXT: _t2 *= _t4; //CHECK-NEXT: goto _label0; -//CHECK-NEXT: _label0: +//CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: { +//CHECK-NEXT: t = _t3; //CHECK-NEXT: double _r_d1 = _d_t; -//CHECK-NEXT: _d_t += _r_d1 * _t2; -//CHECK-NEXT: double _r1 = _t3 * _r_d1; +//CHECK-NEXT: _d_t += _r_d1 * _t4; +//CHECK-NEXT: double _r1 = _t2 * _r_d1; //CHECK-NEXT: * _d_y += _r1; //CHECK-NEXT: _d_t -= _r_d1; +//CHECK-NEXT: t = _t0; //CHECK-NEXT: double _r_d0 = _d_t; -//CHECK-NEXT: _d_t += _r_d0 * _t0; -//CHECK-NEXT: double _r0 = _t1 * _r_d0; +//CHECK-NEXT: _d_t += _r_d0 * _t1; +//CHECK-NEXT: double _r0 = t * _r_d0; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: _d_t -= _r_d0; //CHECK-NEXT: } @@ -443,14 +510,20 @@ double f10(double x, double y) { //CHECK: void f10_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { //CHECK-NEXT: double _d_t = 0; +//CHECK-NEXT: double _t0; +//CHECK-NEXT: double _t1; //CHECK-NEXT: double t = x; +//CHECK-NEXT: _t0 = t; +//CHECK-NEXT: _t1 = x; //CHECK-NEXT: t = x = y; //CHECK-NEXT: goto _label0; -//CHECK-NEXT: _label0: +//CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: { +//CHECK-NEXT: t = _t0; //CHECK-NEXT: double _r_d0 = _d_t; //CHECK-NEXT: * _d_x += _r_d0; +//CHECK-NEXT: x = _t1; //CHECK-NEXT: double _r_d1 = * _d_x; //CHECK-NEXT: * _d_y += _r_d1; //CHECK-NEXT: * _d_x -= _r_d1; @@ -467,15 +540,22 @@ double f11(double x, double y) { //CHECK: void f11_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 _t2; //CHECK-NEXT: double t = x; -//CHECK-NEXT: (t = x) = y; +//CHECK-NEXT: _t0 = t; +//CHECK-NEXT: double &_t1 = (t = x); +//CHECK-NEXT: _t2 = t; +//CHECK-NEXT: _t1 = y; //CHECK-NEXT: goto _label0; -//CHECK-NEXT: _label0: +//CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: { +//CHECK-NEXT: t = _t2; //CHECK-NEXT: double _r_d1 = _d_t; //CHECK-NEXT: * _d_y += _r_d1; //CHECK-NEXT: _d_t -= _r_d1; +//CHECK-NEXT: t = _t0; //CHECK-NEXT: double _r_d0 = _d_t; //CHECK-NEXT: * _d_x += _r_d0; //CHECK-NEXT: _d_t -= _r_d0; @@ -494,26 +574,38 @@ double f12(double x, double y) { //CHECK-NEXT: bool _cond0; //CHECK-NEXT: double _t0; //CHECK-NEXT: double _t1; +//CHECK-NEXT: double _t3; +//CHECK-NEXT: double _t4; +//CHECK-NEXT: double _t5; //CHECK-NEXT: double t; //CHECK-NEXT: _cond0 = x > y; -//CHECK-NEXT: double _ref0 = (_cond0 ? (t = x) : (t = y)); -//CHECK-NEXT: _t1 = _ref0; -//CHECK-NEXT: _t0 = y; -//CHECK-NEXT: _ref0 *= _t0; +//CHECK-NEXT: if (_cond0) +//CHECK-NEXT: _t0 = t; +//CHECK-NEXT: else +//CHECK-NEXT: _t1 = t; +//CHECK-NEXT: double &_t2 = (_cond0 ? (t = x) : (t = y)); +//CHECK-NEXT: _t3 = t; +//CHECK-NEXT: _t4 = t; +//CHECK-NEXT: _t5 = y; +//CHECK-NEXT: _t2 *= _t5; //CHECK-NEXT: goto _label0; -//CHECK-NEXT: _label0: +//CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: { +//CHECK-NEXT: t = _t3; +//CHECK-NEXT: t = _t4; //CHECK-NEXT: double _r_d2 = (_cond0 ? _d_t : _d_t); -//CHECK-NEXT: (_cond0 ? _d_t : _d_t) += _r_d2 * _t0; -//CHECK-NEXT: double _r0 = _t1 * _r_d2; +//CHECK-NEXT: (_cond0 ? _d_t : _d_t) += _r_d2 * _t5; +//CHECK-NEXT: double _r0 = _t2 * _r_d2; //CHECK-NEXT: * _d_y += _r0; //CHECK-NEXT: (_cond0 ? _d_t : _d_t) -= _r_d2; //CHECK-NEXT: if (_cond0) { +//CHECK-NEXT: t = _t0; //CHECK-NEXT: double _r_d0 = _d_t; //CHECK-NEXT: * _d_x += _r_d0; //CHECK-NEXT: _d_t -= _r_d0; //CHECK-NEXT: } else { +//CHECK-NEXT: t = _t1; //CHECK-NEXT: double _r_d1 = _d_t; //CHECK-NEXT: * _d_y += _r_d1; //CHECK-NEXT: _d_t -= _r_d1; @@ -531,25 +623,24 @@ double f13(double x, double y) { //CHECK-NEXT: double _t1; //CHECK-NEXT: double _d_t = 0; //CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: _t1 = x; +//CHECK-NEXT: _t1 = y; //CHECK-NEXT: _t0 = (y = x); -//CHECK-NEXT: double t = _t1 * _t0; -//CHECK-NEXT: _t3 = t; +//CHECK-NEXT: double t = x * _t0; //CHECK-NEXT: _t2 = y; //CHECK-NEXT: goto _label0; -//CHECK-NEXT: _label0: +//CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r2 = 1 * _t2; //CHECK-NEXT: _d_t += _r2; -//CHECK-NEXT: double _r3 = _t3 * 1; +//CHECK-NEXT: double _r3 = t * 1; //CHECK-NEXT: * _d_y += _r3; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: double _r0 = _d_t * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * _d_t; +//CHECK-NEXT: double _r1 = x * _d_t; //CHECK-NEXT: * _d_y += _r1; +//CHECK-NEXT: y = _t1; //CHECK-NEXT: double _r_d0 = * _d_y; //CHECK-NEXT: * _d_x += _r_d0; //CHECK-NEXT: * _d_y -= _r_d0; @@ -569,33 +660,40 @@ double f14(double i, double j) { // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; // CHECK-NEXT: double _t2; +// CHECK-NEXT: double _t3; +// CHECK-NEXT: double _t4; // CHECK-NEXT: _d_a = &* _d_i; // CHECK-NEXT: double &a = i; -// CHECK-NEXT: _t0 = i; -// CHECK-NEXT: a = 2 * _t0; -// CHECK-NEXT: a += i; -// CHECK-NEXT: _t2 = a; +// CHECK-NEXT: _t0 = a; // CHECK-NEXT: _t1 = i; -// CHECK-NEXT: a *= _t1; +// CHECK-NEXT: a = 2 * _t1; +// CHECK-NEXT: _t2 = a; +// CHECK-NEXT: a += i; +// CHECK-NEXT: _t3 = a; +// CHECK-NEXT: _t4 = i; +// CHECK-NEXT: a *= _t4; // CHECK-NEXT: goto _label0; -// CHECK-NEXT: _label0: +// CHECK-NEXT: _label0: // CHECK-NEXT: * _d_i += 1; // CHECK-NEXT: { +// CHECK-NEXT: a = _t3; // CHECK-NEXT: double _r_d2 = *_d_a; -// CHECK-NEXT: *_d_a += _r_d2 * _t1; -// CHECK-NEXT: double _r2 = _t2 * _r_d2; +// CHECK-NEXT: *_d_a += _r_d2 * _t4; +// CHECK-NEXT: double _r2 = a * _r_d2; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: *_d_a -= _r_d2; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: a = _t2; // CHECK-NEXT: double _r_d1 = *_d_a; // CHECK-NEXT: *_d_a += _r_d1; // CHECK-NEXT: * _d_i += _r_d1; // CHECK-NEXT: *_d_a -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: a = _t0; // CHECK-NEXT: double _r_d0 = *_d_a; -// CHECK-NEXT: double _r0 = _r_d0 * _t0; +// CHECK-NEXT: double _r0 = _r_d0 * _t1; // CHECK-NEXT: double _r1 = 2 * _r_d0; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: *_d_a -= _r_d0; @@ -616,11 +714,11 @@ 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 _t1; // 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 _t1; // CHECK-NEXT: double _t2; // CHECK-NEXT: double _t3; // CHECK-NEXT: double _t4; @@ -628,51 +726,56 @@ double f15(double i, double j) { // CHECK-NEXT: double _t6; // CHECK-NEXT: double _t7; // CHECK-NEXT: double _t8; -// CHECK-NEXT: _t1 = i; +// CHECK-NEXT: double _t9; // CHECK-NEXT: _t0 = j; -// CHECK-NEXT: double b = _t1 * _t0; +// CHECK-NEXT: double b = i * _t0; // 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: _t3 = a; +// CHECK-NEXT: _t1 = a; // CHECK-NEXT: _t2 = i; // CHECK-NEXT: a *= _t2; +// CHECK-NEXT: _t3 = b; // CHECK-NEXT: _t4 = i; // CHECK-NEXT: b += 2 * _t4; -// CHECK-NEXT: _t5 = i; -// CHECK-NEXT: c += 3 * _t5; +// CHECK-NEXT: _t5 = c; +// CHECK-NEXT: _t6 = i; +// CHECK-NEXT: c += 3 * _t6; // CHECK-NEXT: _t7 = d; -// CHECK-NEXT: _t8 = j; -// CHECK-NEXT: _t6 = 3 * _t8; -// CHECK-NEXT: d *= _t6; +// CHECK-NEXT: _t9 = j; +// CHECK-NEXT: _t8 = 3 * _t9; +// CHECK-NEXT: d *= _t8; // 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 = _t7; // CHECK-NEXT: double _r_d3 = *_d_d; -// CHECK-NEXT: *_d_d += _r_d3 * _t6; -// CHECK-NEXT: double _r7 = _t7 * _r_d3; -// CHECK-NEXT: double _r8 = _r7 * _t8; +// CHECK-NEXT: *_d_d += _r_d3 * _t8; +// CHECK-NEXT: double _r7 = d * _r_d3; +// CHECK-NEXT: double _r8 = _r7 * _t9; // CHECK-NEXT: double _r9 = 3 * _r7; // CHECK-NEXT: * _d_j += _r9; // CHECK-NEXT: *_d_d -= _r_d3; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: c = _t5; // CHECK-NEXT: double _r_d2 = *_d_c; // CHECK-NEXT: *_d_c += _r_d2; -// CHECK-NEXT: double _r5 = _r_d2 * _t5; +// CHECK-NEXT: double _r5 = _r_d2 * _t6; // CHECK-NEXT: double _r6 = 3 * _r_d2; // CHECK-NEXT: * _d_i += _r6; // CHECK-NEXT: *_d_c -= _r_d2; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: b = _t3; // CHECK-NEXT: double _r_d1 = _d_b; // CHECK-NEXT: _d_b += _r_d1; // CHECK-NEXT: double _r3 = _r_d1 * _t4; @@ -681,16 +784,17 @@ double f15(double i, double j) { // CHECK-NEXT: _d_b -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: a = _t1; // CHECK-NEXT: double _r_d0 = *_d_a; // CHECK-NEXT: *_d_a += _r_d0 * _t2; -// CHECK-NEXT: double _r2 = _t3 * _r_d0; +// CHECK-NEXT: double _r2 = a * _r_d0; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: *_d_a -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: double _r0 = _d_b * _t0; // CHECK-NEXT: * _d_i += _r0; -// CHECK-NEXT: double _r1 = _t1 * _d_b; +// CHECK-NEXT: double _r1 = i * _d_b; // CHECK-NEXT: * _d_j += _r1; // CHECK-NEXT: } // CHECK-NEXT: } @@ -716,17 +820,18 @@ double f16(double i, double j) { // CHECK-NEXT: double &b = a; // CHECK-NEXT: _d_c = &*_d_b; // CHECK-NEXT: double &c = b; -// CHECK-NEXT: _t1 = c; +// CHECK-NEXT: _t0 = c; // CHECK-NEXT: _t2 = j; -// CHECK-NEXT: _t0 = 4 * _t2; -// CHECK-NEXT: c *= _t0; +// CHECK-NEXT: _t1 = 4 * _t2; +// CHECK-NEXT: c *= _t1; // CHECK-NEXT: goto _label0; -// CHECK-NEXT: _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 * _t0; -// CHECK-NEXT: double _r0 = _t1 * _r_d0; +// CHECK-NEXT: *_d_c += _r_d0 * _t1; +// CHECK-NEXT: double _r0 = c * _r_d0; // CHECK-NEXT: double _r1 = _r0 * _t2; // CHECK-NEXT: double _r2 = 4 * _r0; // CHECK-NEXT: * _d_j += _r2; @@ -743,14 +848,17 @@ 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: _t0 = i; -// CHECK-NEXT: j = 2 * _t0; +// CHECK-NEXT: double _t1; +// CHECK-NEXT: _t0 = j; +// CHECK-NEXT: _t1 = i; +// CHECK-NEXT: j = 2 * _t1; // CHECK-NEXT: goto _label0; -// CHECK-NEXT: _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 * _t0; +// CHECK-NEXT: double _r0 = _r_d0 * _t1; // CHECK-NEXT: double _r1 = 2 * _r_d0; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: _d_j -= _r_d0; @@ -767,25 +875,31 @@ double f18(double i, double j, double k) { // CHECK-NEXT: double _d_k = 0; // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; -// CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t1 = j; -// CHECK-NEXT: k = 2 * _t0 + 2 * _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 += i; // CHECK-NEXT: goto _label0; -// CHECK-NEXT: _label0: +// CHECK-NEXT: _label0: // CHECK-NEXT: _d_k += 1; // CHECK-NEXT: { +// CHECK-NEXT: k = _t3; // CHECK-NEXT: double _r_d1 = _d_k; // CHECK-NEXT: _d_k += _r_d1; // CHECK-NEXT: * _d_i += _r_d1; // CHECK-NEXT: _d_k -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: k = _t0; // CHECK-NEXT: double _r_d0 = _d_k; -// CHECK-NEXT: double _r0 = _r_d0 * _t0; +// CHECK-NEXT: double _r0 = _r_d0 * _t1; // CHECK-NEXT: double _r1 = 2 * _r_d0; // CHECK-NEXT: * _d_i += _r1; -// CHECK-NEXT: double _r2 = _r_d0 * _t1; +// CHECK-NEXT: double _r2 = _r_d0 * _t2; // CHECK-NEXT: double _r3 = 2 * _r_d0; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: _d_k -= _r_d0; @@ -796,20 +910,14 @@ double f19(double a, double b) { return std::fma(a, b, b); } -//CHECK: void f19_grad(double a, double b, clad::array_ref _d_a, clad::array_ref _d_b) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = a; -//CHECK-NEXT: _t1 = b; -//CHECK-NEXT: _t2 = b; +//CHECK-NEXT: void f19_grad(double a, double b, clad::array_ref _d_a, clad::array_ref _d_b) { //CHECK-NEXT: goto _label0; -//CHECK-NEXT: _label0: +//CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _grad0 = 0.; //CHECK-NEXT: double _grad1 = 0.; //CHECK-NEXT: double _grad2 = 0.; -//CHECK-NEXT: clad::custom_derivatives::fma_pullback(_t0, _t1, _t2, 1, &_grad0, &_grad1, &_grad2); +//CHECK-NEXT: clad::custom_derivatives::fma_pullback(a, b, b, 1, &_grad0, &_grad1, &_grad2); //CHECK-NEXT: double _r0 = _grad0; //CHECK-NEXT: * _d_a += _r0; //CHECK-NEXT: double _r1 = _grad1; diff --git a/test/Gradient/DiffInterface.C b/test/Gradient/DiffInterface.C index 6c245b710..38945356e 100644 --- a/test/Gradient/DiffInterface.C +++ b/test/Gradient/DiffInterface.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oGradientDiffInterface.out 2>&1 | FileCheck %s // RUN: ./GradientDiffInterface.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oGradientDiffInterface.out +// RUN: ./GradientDiffInterface.out | FileCheck -check-prefix=CHECK-EXEC %s #include "clad/Differentiator/Differentiator.h" diff --git a/test/Gradient/FunctionCalls.C b/test/Gradient/FunctionCalls.C index f3b6f6a2e..a93c4f02c 100644 --- a/test/Gradient/FunctionCalls.C +++ b/test/Gradient/FunctionCalls.C @@ -1,5 +1,7 @@ // RUN: %cladnumdiffclang -std=c++17 %s -I%S/../../include -oFunctionCalls.out 2>&1 | FileCheck %s // RUN: ./FunctionCalls.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladnumdiffclang -Xclang -plugin-arg-clad -Xclang -enable-tbr -std=c++17 %s -I%S/../../include -oFunctionCalls.out +// RUN: ./FunctionCalls.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -25,28 +27,24 @@ double fn1(float i) { } // CHECK: void fn1_grad(float i, clad::array_ref _d_i) { -// CHECK-NEXT: float _t0; // CHECK-NEXT: float _d_res = 0; -// CHECK-NEXT: float _t1; -// CHECK-NEXT: float _t2; +// CHECK-NEXT: float _t0; // CHECK-NEXT: double _d_a = 0; +// CHECK-NEXT: float res = A::constantFn(i); // CHECK-NEXT: _t0 = i; -// CHECK-NEXT: float res = A::constantFn(_t0); -// CHECK-NEXT: _t2 = res; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: double a = _t2 * _t1; +// CHECK-NEXT: double a = res * _t0; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_a += 1; // CHECK-NEXT: { -// CHECK-NEXT: double _r1 = _d_a * _t1; +// CHECK-NEXT: double _r1 = _d_a * _t0; // CHECK-NEXT: _d_res += _r1; -// CHECK-NEXT: double _r2 = _t2 * _d_a; +// CHECK-NEXT: double _r2 = res * _d_a; // CHECK-NEXT: * _d_i += _r2; // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: float _grad0 = 0.F; -// CHECK-NEXT: constantFn_pullback(_t0, _d_res, &_grad0); +// CHECK-NEXT: constantFn_pullback(i, _d_res, &_grad0); // CHECK-NEXT: float _r0 = _grad0; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: } @@ -60,8 +58,12 @@ double modify1(double& i, double& j) { } // CHECK: void modify1_pullback(double &i, double &j, double _d_y, clad::array_ref _d_i, clad::array_ref _d_j) { +// CHECK-NEXT: double _t0; +// CHECK-NEXT: double _t1; // CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: _t0 = i; // CHECK-NEXT: i += j; +// CHECK-NEXT: _t1 = j; // CHECK-NEXT: j += j; // CHECK-NEXT: double res = i + j; // CHECK-NEXT: goto _label0; @@ -72,6 +74,7 @@ double modify1(double& i, double& j) { // CHECK-NEXT: * _d_j += _d_res; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: j = _t1; // CHECK-NEXT: double _r_d1 = * _d_j; // CHECK-NEXT: * _d_j += _r_d1; // CHECK-NEXT: * _d_j += _r_d1; @@ -79,6 +82,7 @@ double modify1(double& i, double& j) { // CHECK-NEXT: * _d_j; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: i = _t0; // CHECK-NEXT: double _r_d0 = * _d_i; // CHECK-NEXT: * _d_i += _r_d0; // CHECK-NEXT: * _d_j += _r_d0; @@ -100,26 +104,36 @@ double fn2(double i, double j) { // CHECK-NEXT: double _t1; // CHECK-NEXT: double _t2; // CHECK-NEXT: double _t3; +// CHECK-NEXT: double _t4; +// CHECK-NEXT: double _t5; // CHECK-NEXT: double temp = 0; -// CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t1 = j; +// CHECK-NEXT: _t0 = temp; +// CHECK-NEXT: _t1 = i; +// CHECK-NEXT: _t2 = j; // CHECK-NEXT: temp = modify1(i, j); -// CHECK-NEXT: _t2 = i; -// CHECK-NEXT: _t3 = j; +// CHECK-NEXT: _t3 = temp; +// CHECK-NEXT: _t4 = i; +// CHECK-NEXT: _t5 = j; // CHECK-NEXT: temp = modify1(i, j); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: * _d_i += 1; // CHECK-NEXT: { +// CHECK-NEXT: temp = _t3; // CHECK-NEXT: double _r_d1 = _d_temp; -// CHECK-NEXT: modify1_pullback(_t2, _t3, _r_d1, &* _d_i, &* _d_j); +// CHECK-NEXT: i = _t4; +// CHECK-NEXT: j = _t5; +// CHECK-NEXT: modify1_pullback(_t4, _t5, _r_d1, &* _d_i, &* _d_j); // CHECK-NEXT: double _r2 = * _d_i; // CHECK-NEXT: double _r3 = * _d_j; // CHECK-NEXT: _d_temp -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: temp = _t0; // CHECK-NEXT: double _r_d0 = _d_temp; -// CHECK-NEXT: modify1_pullback(_t0, _t1, _r_d0, &* _d_i, &* _d_j); +// CHECK-NEXT: i = _t1; +// CHECK-NEXT: j = _t2; +// CHECK-NEXT: modify1_pullback(_t1, _t2, _r_d0, &* _d_i, &* _d_j); // CHECK-NEXT: double _r0 = * _d_i; // CHECK-NEXT: double _r1 = * _d_j; // CHECK-NEXT: _d_temp -= _r_d0; @@ -132,9 +146,14 @@ void update1(double& i, double& j) { } // CHECK: void update1_pullback(double &i, double &j, clad::array_ref _d_i, clad::array_ref _d_j) { +// CHECK-NEXT: double _t0; +// CHECK-NEXT: double _t1; +// CHECK-NEXT: _t0 = i; // CHECK-NEXT: i += j; +// CHECK-NEXT: _t1 = j; // CHECK-NEXT: j += j; // CHECK-NEXT: { +// CHECK-NEXT: j = _t1; // CHECK-NEXT: double _r_d1 = * _d_j; // CHECK-NEXT: * _d_j += _r_d1; // CHECK-NEXT: * _d_j += _r_d1; @@ -142,6 +161,7 @@ void update1(double& i, double& j) { // CHECK-NEXT: * _d_j; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: i = _t0; // CHECK-NEXT: double _r_d0 = * _d_i; // CHECK-NEXT: * _d_i += _r_d0; // CHECK-NEXT: * _d_j += _r_d0; @@ -171,11 +191,15 @@ double fn3(double i, double j) { // CHECK-NEXT: _label0: // CHECK-NEXT: * _d_i += 1; // CHECK-NEXT: { +// CHECK-NEXT: i = _t2; +// CHECK-NEXT: j = _t3; // CHECK-NEXT: update1_pullback(_t2, _t3, &* _d_i, &* _d_j); // CHECK-NEXT: double _r2 = * _d_i; // CHECK-NEXT: double _r3 = * _d_j; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: i = _t0; +// CHECK-NEXT: j = _t1; // CHECK-NEXT: update1_pullback(_t0, _t1, &* _d_i, &* _d_j); // CHECK-NEXT: double _r0 = * _d_i; // CHECK-NEXT: double _r1 = * _d_j; @@ -194,20 +218,24 @@ float sum(double* arr, int n) { // CHECK-NEXT: float _d_res = 0; // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: int _d_i = 0; -// CHECK-NEXT: clad::tape _t1 = {}; +// 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) { // CHECK-NEXT: _t0++; -// CHECK-NEXT: res += arr[clad::push(_t1, i)]; +// CHECK-NEXT: clad::push(_t1, res); +// 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: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += _d_y; // CHECK-NEXT: { +// 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; @@ -217,10 +245,11 @@ float sum(double* arr, int n) { // CHECK-NEXT: _d_arr[0]; // CHECK-NEXT: } // CHECK-NEXT: for (; _t0; _t0--) { +// CHECK-NEXT: --i; +// CHECK-NEXT: res = clad::pop(_t1); // CHECK-NEXT: float _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; -// CHECK-NEXT: int _t2 = clad::pop(_t1); -// CHECK-NEXT: _d_arr[_t2] += _r_d0; +// CHECK-NEXT: _d_arr[i] += _r_d0; // CHECK-NEXT: _d_res -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: } @@ -231,11 +260,14 @@ 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: d = 2 * _t0; +// CHECK-NEXT: _t1 = d; +// CHECK-NEXT: d = 2 * _t1; // CHECK-NEXT: { +// CHECK-NEXT: d = _t0; // CHECK-NEXT: double _r_d0 = * _d_d; -// CHECK-NEXT: double _r0 = _r_d0 * _t0; +// CHECK-NEXT: double _r0 = _r_d0 * _t1; // CHECK-NEXT: double _r1 = 2 * _r_d0; // CHECK-NEXT: * _d_d += _r1; // CHECK-NEXT: * _d_d -= _r_d0; @@ -255,49 +287,50 @@ double fn4(double* arr, int n) { // CHECK: void fn4_grad(double *arr, int n, clad::array_ref _d_arr, clad::array_ref _d_n) { // CHECK-NEXT: double _d_res = 0; -// CHECK-NEXT: double *_t0; -// CHECK-NEXT: int _t1; +// CHECK-NEXT: double _t0; +// CHECK-NEXT: double *_t1; // CHECK-NEXT: unsigned long _t2; // CHECK-NEXT: int _d_i = 0; -// CHECK-NEXT: clad::tape _t3 = {}; -// CHECK-NEXT: clad::tape _t5 = {}; -// CHECK-NEXT: clad::tape _t6 = {}; -// CHECK-NEXT: clad::tape _t8 = {}; +// CHECK-NEXT: clad::tape _t3 = {}; +// CHECK-NEXT: clad::tape _t4 = {}; // CHECK-NEXT: double res = 0; -// CHECK-NEXT: _t0 = arr; -// CHECK-NEXT: _t1 = n; -// CHECK-NEXT: res += sum(arr, _t1); +// CHECK-NEXT: _t0 = res; +// CHECK-NEXT: _t1 = arr; +// CHECK-NEXT: res += sum(arr, n); // CHECK-NEXT: _t2 = 0; // CHECK-NEXT: for (int i = 0; i < n; ++i) { // CHECK-NEXT: _t2++; -// CHECK-NEXT: clad::push(_t5, arr[clad::push(_t3, i)]); -// CHECK-NEXT: twice(arr[clad::push(_t6, i)]); -// CHECK-NEXT: res += arr[clad::push(_t8, i)]; +// CHECK-NEXT: clad::push(_t3, arr[i]); +// CHECK-NEXT: twice(arr[i]); +// CHECK-NEXT: clad::push(_t4, res); +// CHECK-NEXT: res += arr[i]; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += 1; // CHECK-NEXT: for (; _t2; _t2--) { +// CHECK-NEXT: --i; // CHECK-NEXT: { -// CHECK-NEXT: int _t7 = clad::pop(_t6); -// CHECK-NEXT: int _t4 = clad::pop(_t3); +// CHECK-NEXT: res = clad::pop(_t4); // CHECK-NEXT: double _r_d1 = _d_res; // CHECK-NEXT: _d_res += _r_d1; -// CHECK-NEXT: int _t9 = clad::pop(_t8); -// CHECK-NEXT: _d_arr[_t9] += _r_d1; +// CHECK-NEXT: _d_arr[i] += _r_d1; // CHECK-NEXT: _d_res -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: double _r3 = clad::pop(_t5); -// CHECK-NEXT: twice_pullback(_r3, &_d_arr[_t4]); -// CHECK-NEXT: double _r2 = _d_arr[_t4]; +// CHECK-NEXT: double _r3 = clad::pop(_t3); +// CHECK-NEXT: arr[i] = _r3; +// CHECK-NEXT: twice_pullback(_r3, &_d_arr[i]); +// CHECK-NEXT: double _r2 = _d_arr[i]; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: res = _t0; // CHECK-NEXT: double _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; +// CHECK-NEXT: arr = _t1; // CHECK-NEXT: int _grad1 = 0; -// CHECK-NEXT: sum_pullback(_t0, _t1, _r_d0, _d_arr, &_grad1); +// CHECK-NEXT: sum_pullback(_t1, n, _r_d0, _d_arr, &_grad1); // CHECK-NEXT: clad::array _r0(_d_arr); // CHECK-NEXT: int _r1 = _grad1; // CHECK-NEXT: * _d_n += _r1; @@ -312,14 +345,17 @@ 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: arr[0] = 5 * _t0 + arr[1]; +// CHECK-NEXT: _t1 = arr[0]; +// CHECK-NEXT: arr[0] = 5 * _t1 + 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 * _t0; +// CHECK-NEXT: double _r0 = _r_d0 * _t1; // CHECK-NEXT: double _r1 = 5 * _r_d0; // CHECK-NEXT: _d_arr[0] += _r1; // CHECK-NEXT: _d_arr[1] += _r_d0; @@ -342,6 +378,7 @@ double fn5(double* arr, int n) { // CHECK-NEXT: _label0: // CHECK-NEXT: _d_arr[0] += 1; // CHECK-NEXT: { +// CHECK-NEXT: arr = _t0; // CHECK-NEXT: modify2_pullback(_t0, _d_temp, _d_arr); // CHECK-NEXT: clad::array _r0(_d_arr); // CHECK-NEXT: } @@ -372,28 +409,29 @@ 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: 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: * _d_i += _r0; -// CHECK-NEXT: double _r1 = _t1 * 1; +// CHECK-NEXT: double _r1 = i * 1; // CHECK-NEXT: * _d_j += _r1; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK: void identity_pullback(double &i, double _d_y, clad::array_ref _d_i) { // CHECK-NEXT: double _d__d_i = 0; +// CHECK-NEXT: double _t0; // CHECK-NEXT: MyStruct::myFunction(); // CHECK-NEXT: double _d_i0 = i; +// CHECK-NEXT: _t0 = _d_i0; // CHECK-NEXT: _d_i0 += 1; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: * _d_i += _d_y; // CHECK-NEXT: { +// CHECK-NEXT: _d_i0 = _t0; // CHECK-NEXT: double _r_d0 = _d__d_i; // CHECK-NEXT: _d__d_i += _r_d0; // CHECK-NEXT: _d__d_i -= _r_d0; @@ -403,8 +441,10 @@ double fn7(double i, double j) { // CHECK: clad::ValueAndAdjoint identity_forw(double &i, clad::array_ref _d_i) { // CHECK-NEXT: double _d__d_i = 0; +// CHECK-NEXT: double _t0; // CHECK-NEXT: MyStruct::myFunction(); // CHECK-NEXT: double _d_i0 = i; +// CHECK-NEXT: _t0 = _d_i0; // CHECK-NEXT: _d_i0 += 1; // CHECK-NEXT: return {i, * _d_i}; // CHECK-NEXT: } @@ -416,6 +456,8 @@ 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; @@ -424,10 +466,12 @@ double fn7(double i, double j) { // CHECK-NEXT: clad::ValueAndAdjoint _t3 = identity_forw(j, &* _d_j); // CHECK-NEXT: _d_l = &_t3.adjoint; // CHECK-NEXT: double &l = _t3.value; -// CHECK-NEXT: _t4 = j; -// CHECK-NEXT: k += 7 * _t4; -// CHECK-NEXT: _t5 = i; -// CHECK-NEXT: l += 9 * _t5; +// 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: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { @@ -435,203 +479,35 @@ double fn7(double i, double j) { // CHECK-NEXT: * _d_j += 1; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: l = _t6; // CHECK-NEXT: double _r_d1 = *_d_l; // CHECK-NEXT: *_d_l += _r_d1; -// CHECK-NEXT: double _r4 = _r_d1 * _t5; +// CHECK-NEXT: double _r4 = _r_d1 * _t7; // CHECK-NEXT: double _r5 = 9 * _r_d1; // CHECK-NEXT: * _d_i += _r5; // CHECK-NEXT: *_d_l -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: k = _t4; // CHECK-NEXT: double _r_d0 = *_d_k; // CHECK-NEXT: *_d_k += _r_d0; -// CHECK-NEXT: double _r2 = _r_d0 * _t4; +// CHECK-NEXT: double _r2 = _r_d0 * _t5; // CHECK-NEXT: double _r3 = 7 * _r_d0; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: *_d_k -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: j = _t2; // CHECK-NEXT: identity_pullback(_t2, 0, &* _d_j); // CHECK-NEXT: double _r1 = * _d_j; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: i = _t0; // CHECK-NEXT: identity_pullback(_t0, 0, &* _d_i); // CHECK-NEXT: double _r0 = * _d_i; // CHECK-NEXT: } // CHECK-NEXT: } -double fn8(double x, double y) { - return x*y*std::tanh(1.0)*std::max(1.0, 2.0); -} - -// 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: double _t3; -// CHECK-NEXT: double _t4; -// CHECK-NEXT: double _t5; -// CHECK-NEXT: _t3 = x; -// CHECK-NEXT: _t2 = y; -// CHECK-NEXT: _t4 = _t3 * _t2; -// CHECK-NEXT: _t1 = std::tanh(1.); -// CHECK-NEXT: _t5 = _t4 * _t1; -// 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: * _d_x += _r2; -// CHECK-NEXT: double _r3 = _t3 * _r1; -// CHECK-NEXT: * _d_y += _r3; -// CHECK-NEXT: double _r4 = _t4 * _r0; -// CHECK-NEXT: double _r5 = _t5 * 1; -// CHECK-NEXT: } -// CHECK-NEXT: } - -double custom_max(const double& a, const double& b) { - return a > b ? a : b; -} - -// CHECK: void custom_max_pullback(const double &a, const double &b, double _d_y, clad::array_ref _d_a, clad::array_ref _d_b) { -// CHECK-NEXT: bool _cond0; -// CHECK-NEXT: _cond0 = a > b; -// CHECK-NEXT: goto _label0; -// CHECK-NEXT: _label0: -// CHECK-NEXT: if (_cond0) -// CHECK-NEXT: * _d_a += _d_y; -// CHECK-NEXT: else -// CHECK-NEXT: * _d_b += _d_y; -// CHECK-NEXT: } - -double fn9(double x, double y) { - return custom_max(x*y, 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: double _t2; -// CHECK-NEXT: double _t3; -// CHECK-NEXT: _t1 = x; -// CHECK-NEXT: _t0 = y; -// CHECK-NEXT: _t2 = _t1 * _t0; -// CHECK-NEXT: _t3 = y; -// CHECK-NEXT: goto _label0; -// CHECK-NEXT: _label0: -// CHECK-NEXT: { -// CHECK-NEXT: double _grad0 = 0.; -// CHECK-NEXT: custom_max_pullback(_t2, _t3, 1, &_grad0, &* _d_y); -// CHECK-NEXT: double _r0 = _grad0; -// CHECK-NEXT: double _r1 = _r0 * _t0; -// CHECK-NEXT: * _d_x += _r1; -// CHECK-NEXT: double _r2 = _t1 * _r0; -// CHECK-NEXT: * _d_y += _r2; -// CHECK-NEXT: double _r3 = * _d_y; -// CHECK-NEXT: } -// CHECK-NEXT: } - -double fn10(double x, double y) { - double out = x; - out = std::max(out, 0.0); - out = std::min(out, 10.0); - out = std::clamp(out, 3.0, 7.0); - return out * y; -} - -// CHECK: void fn10_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { -// CHECK-NEXT: double _d_out = 0; -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; -// CHECK-NEXT: double _t4; -// CHECK-NEXT: double out = x; -// CHECK-NEXT: _t0 = out; -// CHECK-NEXT: out = std::max(out, 0.); -// CHECK-NEXT: _t1 = out; -// CHECK-NEXT: out = std::min(out, 10.); -// CHECK-NEXT: _t2 = out; -// CHECK-NEXT: out = std::clamp(out, 3., 7.); -// CHECK-NEXT: _t4 = out; -// CHECK-NEXT: _t3 = y; -// CHECK-NEXT: goto _label0; -// CHECK-NEXT: _label0: -// CHECK-NEXT: { -// CHECK-NEXT: double _r7 = 1 * _t3; -// CHECK-NEXT: _d_out += _r7; -// CHECK-NEXT: double _r8 = _t4 * 1; -// CHECK-NEXT: * _d_y += _r8; -// CHECK-NEXT: } -// CHECK-NEXT: { -// CHECK-NEXT: double _r_d2 = _d_out; -// CHECK-NEXT: double _grad5 = 0.; -// CHECK-NEXT: double _grad6 = 0.; -// CHECK-NEXT: clad::custom_derivatives::std::clamp_pullback(_t2, 3., 7., _r_d2, &_d_out, &_grad5, &_grad6); -// CHECK-NEXT: double _r4 = _d_out; -// CHECK-NEXT: double _r5 = _grad5; -// CHECK-NEXT: double _r6 = _grad6; -// CHECK-NEXT: _d_out -= _r_d2; -// CHECK-NEXT: } -// CHECK-NEXT: { -// CHECK-NEXT: double _r_d1 = _d_out; -// CHECK-NEXT: double _grad3 = 0.; -// CHECK-NEXT: clad::custom_derivatives::std::min_pullback(_t1, 10., _r_d1, &_d_out, &_grad3); -// CHECK-NEXT: double _r2 = _d_out; -// CHECK-NEXT: double _r3 = _grad3; -// CHECK-NEXT: _d_out -= _r_d1; -// CHECK-NEXT: } -// CHECK-NEXT: { -// CHECK-NEXT: double _r_d0 = _d_out; -// CHECK-NEXT: double _grad1 = 0.; -// CHECK-NEXT: clad::custom_derivatives::std::max_pullback(_t0, 0., _r_d0, &_d_out, &_grad1); -// CHECK-NEXT: double _r0 = _d_out; -// CHECK-NEXT: double _r1 = _grad1; -// CHECK-NEXT: _d_out -= _r_d0; -// CHECK-NEXT: } -// CHECK-NEXT: * _d_x += _d_out; -// CHECK-NEXT: } - -namespace n1{ - inline namespace n2{ - double sum(const double& x, const double& y) { - return x + y; - } - } -} - -namespace clad{ -namespace custom_derivatives{ - namespace n1{ - inline namespace n2{ - void sum_pullback(const double& x, const double& y, double _d_y0, clad::array_ref _d_x, clad::array_ref _d_y) { - * _d_x += _d_y0; - * _d_y += _d_y0; - } - } - } -} -} - -double fn11(double x, double y) { - return n1::n2::sum(x, y); -} - -// CHECK: void fn11_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: clad::custom_derivatives::n1::sum_pullback(_t0, _t1, 1, &* _d_x, &* _d_y); -// CHECK-NEXT: double _r0 = * _d_x; -// CHECK-NEXT: double _r1 = * _d_y; -// CHECK-NEXT: } -// CHECK-NEXT: } template void reset(T* arr, int n) { @@ -685,10 +561,6 @@ int main() { INIT(fn5); INIT(fn6); INIT(fn7); - INIT(fn8); - INIT(fn9); - INIT(fn10); - INIT(fn11); TEST1_float(fn1, 11); // CHECK-EXEC: {3.00} TEST2(fn2, 3, 5); // CHECK-EXEC: {1.00, 3.00} @@ -698,8 +570,4 @@ int main() { TEST_ARR5(fn5, arr, 5); // CHECK-EXEC: {5.00, 1.00, 0.00, 0.00, 0.00} TEST2(fn6, 3, 5); // CHECK-EXEC: {5.00, 3.00} TEST2(fn7, 3, 5); // CHECK-EXEC: {10.00, 71.00} - TEST2(fn8, 3, 5); // CHECK-EXEC: {7.62, 4.57} - TEST2(fn9, 3, 5); // CHECK-EXEC: {5.00, 3.00} - TEST2(fn10, 8, 5); // CHECK-EXEC: {0.00, 7.00} - TEST2(fn11, 3, 5); // CHECK-EXEC: {1.00, 1.00} } diff --git a/test/Gradient/Functors.C b/test/Gradient/Functors.C index e663fe409..876a39737 100644 --- a/test/Gradient/Functors.C +++ b/test/Gradient/Functors.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oFunctors.out 2>&1 | FileCheck %s // RUN: ./Functors.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oFunctors.out +// RUN: ./Functors.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -15,21 +17,17 @@ 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: double _t3; - // CHECK-NEXT: _t2 = this->x; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t3 = _t2 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; - // CHECK-NEXT: _label0: + // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: double _r1 = _r0 * _t1; // CHECK-NEXT: (* _d_this).x += _r1; - // CHECK-NEXT: double _r2 = _t2 * _r0; + // CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = this->x * _t1 * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -42,25 +40,20 @@ struct ExperimentConst { void setX(double val) const { x = val; } 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t2 = this->x; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t3 = _t2 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; - // CHECK-NEXT: _label0: + // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: double _r1 = _r0 * _t1; // CHECK-NEXT: (* _d_this).x += _r1; - // CHECK-NEXT: double _r2 = _t2 * _r0; + // CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = this->x * _t1 * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -82,21 +75,17 @@ 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: volatile double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t2 = this->x; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t3 = _t2 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; - // CHECK-NEXT: _label0: + // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: double _r1 = _r0 * _t1; // CHECK-NEXT: (* _d_this).x += _r1; - // CHECK-NEXT: double _r2 = _t2 * _r0; + // CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = this->x * _t1 * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -115,24 +104,20 @@ struct ExperimentConstVolatile { return (*this); }; - // 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: 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: volatile double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t2 = this->x; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t3 = _t2 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; - // CHECK-NEXT: _label0: + // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: double _r1 = _r0 * _t1; // CHECK-NEXT: (* _d_this).x += _r1; - // CHECK-NEXT: double _r2 = _t2 * _r0; + // CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = this->x * _t1 * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -151,21 +136,17 @@ struct ExperimentNNS { // 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: double _t3; - // CHECK-NEXT: _t2 = this->x; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t3 = _t2 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; - // CHECK-NEXT: _label0: + // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: double _r1 = _r0 * _t1; // CHECK-NEXT: (* _d_this).x += _r1; - // CHECK-NEXT: double _r2 = _t2 * _r0; + // CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = this->x * _t1 * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -227,21 +208,17 @@ int main() { // 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t2 = i; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t3 = _t2 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; - // CHECK-NEXT: _label0: + // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: double _r1 = _r0 * _t1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = _t2 * _r0; + // CHECK-NEXT: double _r2 = i * _r0; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * _t1 * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -251,20 +228,16 @@ int main() { // 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t2 = x; // CHECK-NEXT: _t1 = ii; - // CHECK-NEXT: _t3 = _t2 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; - // CHECK-NEXT: _label0: + // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: double _r1 = _r0 * _t1; - // CHECK-NEXT: double _r2 = _t2 * _r0; + // CHECK-NEXT: double _r2 = x * _r0; // CHECK-NEXT: * _d_ii += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = x * _t1 * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -319,19 +292,15 @@ int main() { // CHECK: void CallFunctor_grad(double i, double j, clad::array_ref _d_i, clad::array_ref _d_j) { // CHECK-NEXT: Experiment _d_E({}); - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: Experiment _t2; + // CHECK-NEXT: Experiment _t0; // CHECK-NEXT: Experiment E(3, 5); - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; - // CHECK-NEXT: _t2 = E; + // CHECK-NEXT: _t0 = E; // CHECK-NEXT: goto _label0; - // CHECK-NEXT: _label0: + // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _grad0 = 0.; // CHECK-NEXT: double _grad1 = 0.; - // CHECK-NEXT: _t2.operator_call_pullback(_t0, _t1, 1, &_d_E, &_grad0, &_grad1); + // CHECK-NEXT: _t0.operator_call_pullback(i, j, 1, &_d_E, &_grad0, &_grad1); // CHECK-NEXT: double _r0 = _grad0; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = _grad1; @@ -346,18 +315,14 @@ int main() { printf("%.2f %.2f\n", di, dj); // CHECK-EXEC: 27.00 21.00 // CHECK: void FunctorAsArg_grad(Experiment fn, double i, double j, clad::array_ref _d_fn, clad::array_ref _d_i, clad::array_ref _d_j) { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: Experiment _t2; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; - // CHECK-NEXT: _t2 = fn; + // CHECK-NEXT: Experiment _t0; + // CHECK-NEXT: _t0 = fn; // CHECK-NEXT: goto _label0; - // CHECK-NEXT: _label0: + // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _grad0 = 0.; // CHECK-NEXT: double _grad1 = 0.; - // CHECK-NEXT: _t2.operator_call_pullback(_t0, _t1, 1, &(* _d_fn), &_grad0, &_grad1); + // CHECK-NEXT: _t0.operator_call_pullback(i, j, 1, &(* _d_fn), &_grad0, &_grad1); // CHECK-NEXT: double _r0 = _grad0; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = _grad1; @@ -373,18 +338,14 @@ int main() { printf("%.2f %.2f\n", di, dj); // CHECK-EXEC: 27.00 21.00 // CHECK: void FunctorAsArg_pullback(Experiment fn, double i, double j, double _d_y, clad::array_ref _d_fn, clad::array_ref _d_i, clad::array_ref _d_j) { - // CHECK-NEXT: double _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: Experiment _t2; - // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t1 = j; - // CHECK-NEXT: _t2 = fn; + // CHECK-NEXT: Experiment _t0; + // CHECK-NEXT: _t0 = fn; // CHECK-NEXT: goto _label0; - // CHECK-NEXT: _label0: + // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _grad0 = 0.; // CHECK-NEXT: double _grad1 = 0.; - // CHECK-NEXT: _t2.operator_call_pullback(_t0, _t1, _d_y, &(* _d_fn), &_grad0, &_grad1); + // CHECK-NEXT: _t0.operator_call_pullback(i, j, _d_y, &(* _d_fn), &_grad0, &_grad1); // CHECK-NEXT: double _r0 = _grad0; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = _grad1; @@ -394,20 +355,14 @@ int main() { // CHECK: void FunctorAsArgWrapper_grad(double i, double j, clad::array_ref _d_i, clad::array_ref _d_j) { // CHECK-NEXT: Experiment _d_E({}); - // CHECK-NEXT: Experiment _t0; - // CHECK-NEXT: double _t1; - // CHECK-NEXT: double _t2; // CHECK-NEXT: Experiment E(3, 5); - // CHECK-NEXT: _t0 = E - // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t2 = j; // CHECK-NEXT: goto _label0; - // CHECK-NEXT: _label0: + // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: Experiment _grad0; // CHECK-NEXT: double _grad1 = 0.; // CHECK-NEXT: double _grad2 = 0.; - // CHECK-NEXT: FunctorAsArg_pullback(_t0, _t1, _t2, 1, &_grad0, &_grad1, &_grad2); + // CHECK-NEXT: FunctorAsArg_pullback(E, i, j, 1, &_grad0, &_grad1, &_grad2); // CHECK-NEXT: Experiment _r0(_grad0); // CHECK-NEXT: double _r1 = _grad1; // CHECK-NEXT: * _d_i += _r1; diff --git a/test/Gradient/Gradients.C b/test/Gradient/Gradients.C index 8ac9fed7d..1bd58a186 100644 --- a/test/Gradient/Gradients.C +++ b/test/Gradient/Gradients.C @@ -1,5 +1,7 @@ // RUN: %cladnumdiffclang %s -I%S/../../include -oGradients.out 2>&1 | FileCheck %s // RUN: ./Gradients.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladnumdiffclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oGradients.out +// RUN: ./Gradients.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -55,18 +57,21 @@ 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: _t1 = y; +//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 _r1 = 3 * 1; //CHECK-NEXT: * _d_x += _r1; -//CHECK-NEXT: double _r2 = 1 * 4; -//CHECK-NEXT: double _r3 = _r2 * _t1; +//CHECK-NEXT: double _r2 = 1 * _t1; +//CHECK-NEXT: double _r3 = _r2 * _t2; //CHECK-NEXT: double _r4 = 4 * _r2; //CHECK-NEXT: * _d_y += _r4; +//CHECK-NEXT: double _r5 = 4 * _t2 * 1; //CHECK-NEXT: } //CHECK-NEXT: } @@ -115,15 +120,13 @@ 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: double _t1; -//CHECK-NEXT: _t1 = x; //CHECK-NEXT: _t0 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * 1; +//CHECK-NEXT: double _r1 = x * 1; //CHECK-NEXT: * _d_y += _r1; //CHECK-NEXT: } //CHECK-NEXT: } @@ -138,19 +141,20 @@ double f_mult2(double x, double y) { //CHECK-NEXT: double _t0; //CHECK-NEXT: double _t1; //CHECK-NEXT: double _t2; -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t2 = 3 * _t1 * 4; +//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 * 4; -//CHECK-NEXT: double _r2 = _r1 * _t1; +//CHECK-NEXT: double _r1 = _r0 * _t1; +//CHECK-NEXT: double _r2 = _r1 * _t2; //CHECK-NEXT: double _r3 = 3 * _r1; //CHECK-NEXT: * _d_x += _r3; -//CHECK-NEXT: double _r4 = _t2 * 1; -//CHECK-NEXT: * _d_y += _r4; +//CHECK-NEXT: double _r4 = 3 * _t2 * _r0; +//CHECK-NEXT: double _r5 = 3 * _t2 * _t1 * 1; +//CHECK-NEXT: * _d_y += _r5; //CHECK-NEXT: } //CHECK-NEXT: } @@ -162,15 +166,13 @@ double f_div1(double x, double y) { //CHECK: void f_div1_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: _t1 = x; //CHECK-NEXT: _t0 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 / _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = 1 * -_t1 / (_t0 * _t0); +//CHECK-NEXT: double _r1 = 1 * -x / (_t0 * _t0); //CHECK-NEXT: * _d_y += _r1; //CHECK-NEXT: } //CHECK-NEXT: } @@ -185,11 +187,9 @@ double f_div2(double x, double y) { //CHECK-NEXT: double _t0; //CHECK-NEXT: double _t1; //CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; //CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t2 = 3 * _t1; -//CHECK-NEXT: _t3 = y; -//CHECK-NEXT: _t0 = (4 * _t3); +//CHECK-NEXT: _t2 = y; +//CHECK-NEXT: _t0 = (4 * _t2); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { @@ -197,8 +197,8 @@ double f_div2(double x, double y) { //CHECK-NEXT: double _r1 = _r0 * _t1; //CHECK-NEXT: double _r2 = 3 * _r0; //CHECK-NEXT: * _d_x += _r2; -//CHECK-NEXT: double _r3 = 1 * -_t2 / (_t0 * _t0); -//CHECK-NEXT: double _r4 = _r3 * _t3; +//CHECK-NEXT: double _r3 = 1 * -3 * _t1 / (_t0 * _t0); +//CHECK-NEXT: double _r4 = _r3 * _t2; //CHECK-NEXT: double _r5 = 4 * _r3; //CHECK-NEXT: * _d_y += _r5; //CHECK-NEXT: } @@ -215,36 +215,28 @@ double f_c(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: double _t6; -//CHECK-NEXT: double _t7; -//CHECK-NEXT: _t1 = -x; //CHECK-NEXT: _t0 = y; -//CHECK-NEXT: _t3 = (x + y); -//CHECK-NEXT: _t5 = x; -//CHECK-NEXT: _t4 = y; -//CHECK-NEXT: _t2 = (_t5 / _t4); -//CHECK-NEXT: _t7 = x; -//CHECK-NEXT: _t6 = x; +//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: * _d_x += -_r0; -//CHECK-NEXT: double _r1 = _t1 * 1; +//CHECK-NEXT: double _r1 = -x * 1; //CHECK-NEXT: * _d_y += _r1; -//CHECK-NEXT: double _r2 = 1 * _t2; +//CHECK-NEXT: double _r2 = 1 * _t1; //CHECK-NEXT: * _d_x += _r2; //CHECK-NEXT: * _d_y += _r2; -//CHECK-NEXT: double _r3 = _t3 * 1; -//CHECK-NEXT: double _r4 = _r3 / _t4; +//CHECK-NEXT: double _r3 = (x + y) * 1; +//CHECK-NEXT: double _r4 = _r3 / _t2; //CHECK-NEXT: * _d_x += _r4; -//CHECK-NEXT: double _r5 = _r3 * -_t5 / (_t4 * _t4); +//CHECK-NEXT: double _r5 = _r3 * -x / (_t2 * _t2); //CHECK-NEXT: * _d_y += _r5; -//CHECK-NEXT: double _r6 = -1 * _t6; +//CHECK-NEXT: double _r6 = -1 * _t3; //CHECK-NEXT: * _d_x += _r6; -//CHECK-NEXT: double _r7 = _t7 * -1; +//CHECK-NEXT: double _r7 = x * -1; //CHECK-NEXT: * _d_x += _r7; //CHECK-NEXT: } //CHECK-NEXT: } @@ -261,39 +253,31 @@ double f_rosenbrock(double x, double y) { //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 - 1); //CHECK-NEXT: _t0 = (x - 1); -//CHECK-NEXT: _t5 = x; +//CHECK-NEXT: _t3 = x; +//CHECK-NEXT: _t2 = (y - x * _t3); //CHECK-NEXT: _t4 = x; -//CHECK-NEXT: _t3 = (y - _t5 * _t4); -//CHECK-NEXT: _t6 = 100 * _t3; -//CHECK-NEXT: _t8 = x; -//CHECK-NEXT: _t7 = x; -//CHECK-NEXT: _t2 = (y - _t8 * _t7); +//CHECK-NEXT: _t1 = (y - x * _t4); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * 1; +//CHECK-NEXT: double _r1 = (x - 1) * 1; //CHECK-NEXT: * _d_x += _r1; -//CHECK-NEXT: double _r2 = 1 * _t2; -//CHECK-NEXT: double _r3 = _r2 * _t3; +//CHECK-NEXT: double _r2 = 1 * _t1; +//CHECK-NEXT: double _r3 = _r2 * _t2; //CHECK-NEXT: double _r4 = 100 * _r2; //CHECK-NEXT: * _d_y += _r4; -//CHECK-NEXT: double _r5 = -_r4 * _t4; +//CHECK-NEXT: double _r5 = -_r4 * _t3; //CHECK-NEXT: * _d_x += _r5; -//CHECK-NEXT: double _r6 = _t5 * -_r4; +//CHECK-NEXT: double _r6 = x * -_r4; //CHECK-NEXT: * _d_x += _r6; -//CHECK-NEXT: double _r7 = _t6 * 1; +//CHECK-NEXT: double _r7 = 100 * _t2 * 1; //CHECK-NEXT: * _d_y += _r7; -//CHECK-NEXT: double _r8 = -_r7 * _t7; +//CHECK-NEXT: double _r8 = -_r7 * _t4; //CHECK-NEXT: * _d_x += _r8; -//CHECK-NEXT: double _r9 = _t8 * -_r7; +//CHECK-NEXT: double _r9 = x * -_r7; //CHECK-NEXT: * _d_x += _r9; //CHECK-NEXT: } //CHECK-NEXT: } @@ -430,22 +414,18 @@ 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: double _t2; - //CHECK-NEXT: double _t3; - //CHECK-NEXT: _t1 = this->c1; //CHECK-NEXT: _t0 = x; - //CHECK-NEXT: _t3 = this->c2; - //CHECK-NEXT: _t2 = y; + //CHECK-NEXT: _t1 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 * _t0; //CHECK-NEXT: (* _d_this).c1 += _r0; - //CHECK-NEXT: double _r1 = _t1 * 1; + //CHECK-NEXT: double _r1 = this->c1 * 1; //CHECK-NEXT: * _d_x += _r1; - //CHECK-NEXT: double _r2 = 1 * _t2; + //CHECK-NEXT: double _r2 = 1 * _t1; //CHECK-NEXT: (* _d_this).c2 += _r2; - //CHECK-NEXT: double _r3 = _t3 * 1; + //CHECK-NEXT: double _r3 = this->c2 * 1; //CHECK-NEXT: * _d_y += _r3; //CHECK-NEXT: } //CHECK-NEXT: } @@ -492,31 +472,19 @@ void f_norm_grad(double x, double* _d_d); //CHECK: void f_norm_grad(double x, double y, double z, double d, clad::array_ref _d_x, clad::array_ref _d_y, clad::array_ref _d_z, clad::array_ref _d_d) { //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: _t0 = x; -//CHECK-NEXT: _t1 = y; -//CHECK-NEXT: _t2 = z; -//CHECK-NEXT: _t3 = d; -//CHECK-NEXT: _t4 = sum_of_powers(_t0, _t1, _t2, _t3); -//CHECK-NEXT: _t5 = d; -//CHECK-NEXT: _t6 = 1 / _t5; +//CHECK-NEXT: _t0 = d; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _grad4 = 0.; //CHECK-NEXT: double _grad5 = 0.; -//CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(_t4, _t6, 1, &_grad4, &_grad5); +//CHECK-NEXT: clad::custom_derivatives::pow_pullback(sum_of_powers(x, y, z, d), 1 / _t0, 1, &_grad4, &_grad5); //CHECK-NEXT: double _r0 = _grad4; //CHECK-NEXT: double _grad0 = 0.; //CHECK-NEXT: double _grad1 = 0.; //CHECK-NEXT: double _grad2 = 0.; //CHECK-NEXT: double _grad3 = 0.; -//CHECK-NEXT: clad::custom_derivatives::sum_of_powers_pullback(_t0, _t1, _t2, _t3, _r0, &_grad0, &_grad1, &_grad2, &_grad3); +//CHECK-NEXT: clad::custom_derivatives::sum_of_powers_pullback(x, y, z, d, _r0, &_grad0, &_grad1, &_grad2, &_grad3); //CHECK-NEXT: double _r1 = _grad0; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: double _r2 = _grad1; @@ -526,8 +494,8 @@ void f_norm_grad(double x, //CHECK-NEXT: double _r4 = _grad3; //CHECK-NEXT: * _d_d += _r4; //CHECK-NEXT: double _r5 = _grad5; -//CHECK-NEXT: double _r6 = _r5 / _t5; -//CHECK-NEXT: double _r7 = _r5 * -1 / (_t5 * _t5); +//CHECK-NEXT: double _r6 = _r5 / _t0; +//CHECK-NEXT: double _r7 = _r5 * -1 / (_t0 * _t0); //CHECK-NEXT: * _d_d += _r7; //CHECK-NEXT: } //CHECK-NEXT: } @@ -539,22 +507,16 @@ 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: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t2 = y; -//CHECK-NEXT: _t3 = (std::sin(_t1) + std::sin(_t2)); //CHECK-NEXT: _t0 = (x + y); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 * _t0; -// CHECK-NEXT: double _r1 = _r0 * clad::custom_derivatives{{(::std)?}}::sin_pushforward(_t1, 1.).pushforward; +//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{{(::std)?}}::sin_pushforward(_t2, 1.).pushforward; +//CHECK-NEXT: double _r2 = _r0 * clad::custom_derivatives::sin_pushforward(y, 1.).pushforward; //CHECK-NEXT: * _d_y += _r2; -//CHECK-NEXT: double _r3 = _t3 * 1; +//CHECK-NEXT: double _r3 = (std::sin(x) + std::sin(y)) * 1; //CHECK-NEXT: * _d_x += _r3; //CHECK-NEXT: * _d_y += _r3; //CHECK-NEXT: } @@ -634,50 +596,44 @@ 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 _t1; //CHECK-NEXT: double _d_a = 0; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; +//CHECK-NEXT: double _t1; //CHECK-NEXT: double _d_b = 0; -//CHECK-NEXT: double _t4; -//CHECK-NEXT: double _t5; +//CHECK-NEXT: double _t2; //CHECK-NEXT: double _d_c = 0; -//CHECK-NEXT: double _t6; -//CHECK-NEXT: _t1 = x; +//CHECK-NEXT: double _t3; //CHECK-NEXT: _t0 = x; -//CHECK-NEXT: double a = _t1 * _t0; -//CHECK-NEXT: _t3 = x; +//CHECK-NEXT: double a = x * _t0; +//CHECK-NEXT: _t1 = y; +//CHECK-NEXT: double b = x * _t1; //CHECK-NEXT: _t2 = y; -//CHECK-NEXT: double b = _t3 * _t2; -//CHECK-NEXT: _t5 = y; -//CHECK-NEXT: _t4 = y; -//CHECK-NEXT: double c = _t5 * _t4; -//CHECK-NEXT: _t6 = b; +//CHECK-NEXT: double c = y * _t2; +//CHECK-NEXT: _t3 = b; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: _d_a += 1; -//CHECK-NEXT: double _r6 = 1 * _t6; +//CHECK-NEXT: double _r6 = 1 * _t3; //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 * _t4; +//CHECK-NEXT: double _r4 = _d_c * _t2; //CHECK-NEXT: * _d_y += _r4; -//CHECK-NEXT: double _r5 = _t5 * _d_c; +//CHECK-NEXT: double _r5 = y * _d_c; //CHECK-NEXT: * _d_y += _r5; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r2 = _d_b * _t2; +//CHECK-NEXT: double _r2 = _d_b * _t1; //CHECK-NEXT: * _d_x += _r2; -//CHECK-NEXT: double _r3 = _t3 * _d_b; +//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: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * _d_a; +//CHECK-NEXT: double _r1 = x * _d_a; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: } //CHECK-NEXT: } @@ -704,7 +660,6 @@ void f_decls3_grad(double x, double y, clad::array_ref _d_x, clad::array //CHECK-NEXT: bool _cond1; //CHECK-NEXT: double _t3; //CHECK-NEXT: double _t4; -//CHECK-NEXT: double _t5; //CHECK-NEXT: double _d_b = 0; //CHECK-NEXT: _t0 = x; //CHECK-NEXT: double a = 3 * _t0; @@ -721,16 +676,15 @@ void f_decls3_grad(double x, double y, clad::array_ref _d_x, clad::array //CHECK-NEXT: goto _label1; //CHECK-NEXT: } //CHECK-NEXT: } -//CHECK-NEXT: _t5 = a; //CHECK-NEXT: _t4 = a; -//CHECK-NEXT: double b = _t5 * _t4; +//CHECK-NEXT: double b = a * _t4; //CHECK-NEXT: goto _label2; //CHECK-NEXT: _label2: //CHECK-NEXT: _d_b += 1; //CHECK-NEXT: { //CHECK-NEXT: double _r8 = _d_b * _t4; //CHECK-NEXT: _d_a += _r8; -//CHECK-NEXT: double _r9 = _t5 * _d_b; +//CHECK-NEXT: double _r9 = a * _d_b; //CHECK-NEXT: _d_a += _r9; //CHECK-NEXT: } //CHECK-NEXT: if (_cond0) @@ -773,25 +727,13 @@ void f_issue138_grad(double x, double y, clad::array_ref _d_x, clad::arr //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 _t11; -//CHECK-NEXT: double _t12; //CHECK-NEXT: double _t10 = 1; -//CHECK-NEXT: _t3 = x; //CHECK-NEXT: _t2 = x; -//CHECK-NEXT: _t4 = _t3 * _t2; //CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t5 = _t4 * _t1; //CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t9 = y; -//CHECK-NEXT: _t8 = y; -//CHECK-NEXT: _t11 = _t9 * _t8; -//CHECK-NEXT: _t7 = y; -//CHECK-NEXT: _t12 = _t11 * _t7; -//CHECK-NEXT: _t6 = y; +//CHECK-NEXT: _t5 = y; +//CHECK-NEXT: _t4 = y; +//CHECK-NEXT: _t3 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { @@ -799,21 +741,21 @@ void f_issue138_grad(double x, double y, clad::array_ref _d_x, clad::arr //CHECK-NEXT: double _r1 = _r0 * _t1; //CHECK-NEXT: double _r2 = _r1 * _t2; //CHECK-NEXT: * _d_x += _r2; -//CHECK-NEXT: double _r3 = _t3 * _r1; +//CHECK-NEXT: double _r3 = x * _r1; //CHECK-NEXT: * _d_x += _r3; -//CHECK-NEXT: double _r4 = _t4 * _r0; +//CHECK-NEXT: double _r4 = x * _t2 * _r0; //CHECK-NEXT: * _d_x += _r4; -//CHECK-NEXT: double _r5 = _t5 * 1; +//CHECK-NEXT: double _r5 = x * _t2 * _t1 * 1; //CHECK-NEXT: * _d_x += _r5; -//CHECK-NEXT: double _r6 = 1 * _t6; -//CHECK-NEXT: double _r7 = _r6 * _t7; -//CHECK-NEXT: double _r8 = _r7 * _t8; +//CHECK-NEXT: double _r6 = 1 * _t3; +//CHECK-NEXT: double _r7 = _r6 * _t4; +//CHECK-NEXT: double _r8 = _r7 * _t5; //CHECK-NEXT: * _d_y += _r8; -//CHECK-NEXT: double _r9 = _t9 * _r7; +//CHECK-NEXT: double _r9 = y * _r7; //CHECK-NEXT: * _d_y += _r9; -//CHECK-NEXT: double _r10 = _t11 * _r6; +//CHECK-NEXT: double _r10 = y * _t5 * _r6; //CHECK-NEXT: * _d_y += _r10; -//CHECK-NEXT: double _r11 = _t12 * 1; +//CHECK-NEXT: double _r11 = y * _t5 * _t4 * 1; //CHECK-NEXT: * _d_y += _r11; //CHECK-NEXT: } //CHECK-NEXT: } @@ -823,17 +765,15 @@ 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: 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: double _t1; -//CHECK-NEXT: _t1 = a; //CHECK-NEXT: _t0 = b; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 * _t0; //CHECK-NEXT: * _d_a += _r0; -//CHECK-NEXT: double _r1 = _t1 * 1; +//CHECK-NEXT: double _r1 = a * 1; //CHECK-NEXT: * _d_b += _r1; //CHECK-NEXT: } //CHECK-NEXT: } @@ -893,27 +833,25 @@ float running_sum(float* p, int n) { // CHECK: void running_sum_grad(float *p, int n, clad::array_ref _d_p, clad::array_ref _d_n) { // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: int _d_i = 0; -// CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: clad::tape _t3 = {}; -// CHECK-NEXT: int _t5; +// CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: for (int i = 1; i < n; i++) { // CHECK-NEXT: _t0++; -// CHECK-NEXT: p[clad::push(_t1, i)] += p[clad::push(_t3, i - 1)]; +// CHECK-NEXT: clad::push(_t1, p[i]); +// CHECK-NEXT: p[i] += p[i - 1]; // CHECK-NEXT: } -// CHECK-NEXT: _t5 = n - 1; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: -// CHECK-NEXT: _d_p[_t5] += 1; +// CHECK-NEXT: _d_p[n - 1] += 1; // CHECK-NEXT: for (; _t0; _t0--) { +// CHECK-NEXT: i--; // CHECK-NEXT: { -// CHECK-NEXT: int _t2 = clad::pop(_t1); -// CHECK-NEXT: float _r_d0 = _d_p[_t2]; -// CHECK-NEXT: _d_p[_t2] += _r_d0; -// CHECK-NEXT: int _t4 = clad::pop(_t3); -// CHECK-NEXT: _d_p[_t4] += _r_d0; -// CHECK-NEXT: _d_p[_t2] -= _r_d0; -// CHECK-NEXT: _d_p[_t2]; +// CHECK-NEXT: p[i] = clad::pop(_t1); +// CHECK-NEXT: float _r_d0 = _d_p[i]; +// CHECK-NEXT: _d_p[i] += _r_d0; +// CHECK-NEXT: _d_p[i - 1] += _r_d0; +// CHECK-NEXT: _d_p[i] -= _r_d0; +// CHECK-NEXT: _d_p[i]; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } @@ -928,16 +866,14 @@ 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 _t1; // CHECK-NEXT: double &ref = global; -// CHECK-NEXT: _t1 = ref; // CHECK-NEXT: _t0 = i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: _d_ref += _r0; -// CHECK-NEXT: double _r1 = _t1 * 1; +// CHECK-NEXT: double _r1 = ref * 1; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/Gradient/Loops.C b/test/Gradient/Loops.C index 0b4be619c..86f074a72 100644 --- a/test/Gradient/Loops.C +++ b/test/Gradient/Loops.C @@ -1,4 +1,7 @@ -// RUN: %cladclang %s -I%S/../../include -oReverseLoops.out 2>&1 | FileCheck %s +/// FIXME: Enable FileCheck for this test. +// RUN: %cladclang %s -I%S/../../include -oReverseLoops.out +// RUN: ./ReverseLoops.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oReverseLoops.out // RUN: ./ReverseLoops.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -24,16 +27,18 @@ double f1(double x) { //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < 3; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: clad::push(_t2, t); -//CHECK-NEXT: t *= clad::push(_t1, x); +//CHECK-NEXT: clad::push(_t1, t); +//CHECK-NEXT: t *= clad::push(_t2, x); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; +//CHECK-NEXT: t = clad::pop(_t1); //CHECK-NEXT: double _r_d0 = _d_t; -//CHECK-NEXT: _d_t += _r_d0 * clad::pop(_t1); -//CHECK-NEXT: double _r0 = clad::pop(_t2) * _r_d0; +//CHECK-NEXT: _d_t += _r_d0 * clad::pop(_t2); +//CHECK-NEXT: double _r0 = t * _r_d0; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: _d_t -= _r_d0; //CHECK-NEXT: } @@ -52,32 +57,40 @@ double f2(double x) { //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; //CHECK-NEXT: clad::tape _t1 = {}; +//CHECK-NEXT: clad::tape _t2 = {}; //CHECK-NEXT: int _d_j = 0; -//CHECK-NEXT: clad::tape _t2 = {}; +//CHECK-NEXT: int j = 0; //CHECK-NEXT: clad::tape _t3 = {}; +//CHECK-NEXT: clad::tape _t4 = {}; //CHECK-NEXT: double t = 1; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < 3; i++) { //CHECK-NEXT: _t0++; //CHECK-NEXT: clad::push(_t1, 0UL); -//CHECK-NEXT: for (int j = 0; j < 3; j++) { +//CHECK-NEXT: for (clad::push(_t2, j) , j = 0; j < 3; j++) { //CHECK-NEXT: clad::back(_t1)++; //CHECK-NEXT: clad::push(_t3, t); -//CHECK-NEXT: t *= clad::push(_t2, x); +//CHECK-NEXT: t *= clad::push(_t4, x); //CHECK-NEXT: } //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; //CHECK-NEXT: for (; clad::back(_t1); clad::back(_t1)--) { +//CHECK-NEXT: j--; +//CHECK-NEXT: t = clad::pop(_t3); //CHECK-NEXT: double _r_d0 = _d_t; -//CHECK-NEXT: _d_t += _r_d0 * clad::pop(_t2); -//CHECK-NEXT: double _r0 = clad::pop(_t3) * _r_d0; +//CHECK-NEXT: _d_t += _r_d0 * clad::pop(_t4); +//CHECK-NEXT: double _r0 = t * _r_d0; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: _d_t -= _r_d0; //CHECK-NEXT: } -//CHECK-NEXT: _d_j = 0; +//CHECK-NEXT: { +//CHECK-NEXT: _d_j = 0; +//CHECK-NEXT: j = clad::pop(_t2); +//CHECK-NEXT: } //CHECK-NEXT: clad::pop(_t1); //CHECK-NEXT: } //CHECK-NEXT: } @@ -103,8 +116,8 @@ double f3(double x) { //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < 3; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: clad::push(_t2, t); -//CHECK-NEXT: t *= clad::push(_t1, x); +//CHECK-NEXT: clad::push(_t1, t); +//CHECK-NEXT: t *= clad::push(_t2, x); //CHECK-NEXT: bool _t3 = i == 1; //CHECK-NEXT: { //CHECK-NEXT: if (_t3) @@ -116,13 +129,15 @@ double f3(double x) { //CHECK-NEXT: _label1: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; //CHECK-NEXT: if (clad::pop(_t4)) //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: { +//CHECK-NEXT: t = clad::pop(_t1); //CHECK-NEXT: double _r_d0 = _d_t; -//CHECK-NEXT: _d_t += _r_d0 * clad::pop(_t1); -//CHECK-NEXT: double _r0 = clad::pop(_t2) * _r_d0; +//CHECK-NEXT: _d_t += _r_d0 * clad::pop(_t2); +//CHECK-NEXT: double _r0 = t * _r_d0; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: _d_t -= _r_d0; //CHECK-NEXT: } @@ -144,7 +159,7 @@ double f4(double x) { //CHECK-NEXT: clad::tape _t2 = {}; //CHECK-NEXT: double t = 1; //CHECK-NEXT: _t0 = 0; -//CHECK-NEXT: for (int i = 0; i < 3; clad::push(_t2, t) , (t *= clad::push(_t1, x))) { +//CHECK-NEXT: for (int i = 0; i < 3; clad::push(_t1, t) , (t *= clad::push(_t2, x))) { //CHECK-NEXT: _t0++; //CHECK-NEXT: i++; //CHECK-NEXT: } @@ -152,11 +167,15 @@ double f4(double x) { //CHECK-NEXT: _label0: //CHECK-NEXT: _d_t += 1; //CHECK-NEXT: for (; _t0; _t0--) { -//CHECK-NEXT: double _r_d0 = _d_t; -//CHECK-NEXT: _d_t += _r_d0 * clad::pop(_t1); -//CHECK-NEXT: double _r0 = clad::pop(_t2) * _r_d0; -//CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: _d_t -= _r_d0; +//CHECK-NEXT: { +//CHECK-NEXT: t = clad::pop(_t1); +//CHECK-NEXT: double _r_d0 = _d_t; +//CHECK-NEXT: _d_t += _r_d0 * clad::pop(_t2); +//CHECK-NEXT: double _r0 = t * _r_d0; +//CHECK-NEXT: * _d_x += _r0; +//CHECK-NEXT: _d_t -= _r_d0; +//CHECK-NEXT: } +//CHECK-NEXT: i--; //CHECK-NEXT: } //CHECK-NEXT: } @@ -177,8 +196,11 @@ double f5(double x){ //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: * _d_x += 1; -//CHECK-NEXT: for (; _t0; _t0--) -//CHECK-NEXT: ; +//CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; +//CHECK-NEXT: x--; +//CHECK-NEXT: * _d_x; +//CHECK-NEXT: } //CHECK-NEXT: } double f_sum(double *p, int n) { @@ -193,21 +215,23 @@ double f_sum(double *p, int n) { //CHECK-NEXT: double _d_s = 0; //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t1 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: double s = 0; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < n; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: s += p[clad::push(_t1, i)]; +//CHECK-NEXT: clad::push(_t1, s); +//CHECK-NEXT: s += p[i]; //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_s += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; +//CHECK-NEXT: s = clad::pop(_t1); //CHECK-NEXT: double _r_d0 = _d_s; //CHECK-NEXT: _d_s += _r_d0; -//CHECK-NEXT: int _t2 = clad::pop(_t1); -//CHECK-NEXT: _d_p[_t2] += _r_d0; +//CHECK-NEXT: _d_p[i] += _r_d0; //CHECK-NEXT: _d_s -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: } @@ -215,15 +239,13 @@ 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: double _t1; -//CHECK-NEXT: _t1 = x; //CHECK-NEXT: _t0 = x; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r0 = _d_y * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * _d_y; +//CHECK-NEXT: double _r1 = x * _d_y; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: } //CHECK-NEXT: } @@ -240,25 +262,26 @@ double f_sum_squares(double *p, int n) { //CHECK-NEXT: double _d_s = 0; //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t1 = {}; -//CHECK-NEXT: clad::tape _t3 = {}; +//CHECK-NEXT: clad::tape _t1 = {}; //CHECK-NEXT: double s = 0; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < n; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: s += sq(clad::push(_t3, p[clad::push(_t1, i)])); +//CHECK-NEXT: clad::push(_t1, s); +//CHECK-NEXT: s += sq(p[i]); //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_s += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; +//CHECK-NEXT: s = clad::pop(_t1); //CHECK-NEXT: double _r_d0 = _d_s; //CHECK-NEXT: _d_s += _r_d0; //CHECK-NEXT: double _grad0 = 0.; -//CHECK-NEXT: sq_pullback(clad::pop(_t3), _r_d0, &_grad0); +//CHECK-NEXT: sq_pullback(p[i], _r_d0, &_grad0); //CHECK-NEXT: double _r0 = _grad0; -//CHECK-NEXT: int _t2 = clad::pop(_t1); -//CHECK-NEXT: _d_p[_t2] += _r0; +//CHECK-NEXT: _d_p[i] += _r0; //CHECK-NEXT: _d_s -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: } @@ -279,93 +302,80 @@ double f_log_gaus(double* x, double* p /*means*/, double n, double sigma) { //CHECK-NEXT: double _d_power = 0; //CHECK-NEXT: unsigned long _t0; //CHECK-NEXT: int _d_i = 0; -//CHECK-NEXT: clad::tape _t1 = {}; -//CHECK-NEXT: clad::tape _t3 = {}; -//CHECK-NEXT: clad::tape _t5 = {}; +//CHECK-NEXT: clad::tape _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: double _t9; -//CHECK-NEXT: double _t10; -//CHECK-NEXT: double _t11; -//CHECK-NEXT: double _t12; -//CHECK-NEXT: double _t13; -//CHECK-NEXT: double _t14; -//CHECK-NEXT: double _t15; -//CHECK-NEXT: double _t16; -//CHECK-NEXT: double _t17; -//CHECK-NEXT: double _t18; //CHECK-NEXT: double _d_gaus = 0; -//CHECK-NEXT: double _t19; //CHECK-NEXT: double power = 0; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < n; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: power += sq(clad::push(_t5, x[clad::push(_t1, i)] - p[clad::push(_t3, i)])); +//CHECK-NEXT: clad::push(_t1, power); +//CHECK-NEXT: power += sq(x[i] - p[i]); //CHECK-NEXT: } -//CHECK-NEXT: _t7 = -power; -//CHECK-NEXT: _t9 = sigma; -//CHECK-NEXT: _t8 = sq(_t9); -//CHECK-NEXT: _t6 = (2 * _t8); -//CHECK-NEXT: power = _t7 / _t6; -//CHECK-NEXT: _t13 = 2 * 3.1415926535897931; -//CHECK-NEXT: _t14 = n; -//CHECK-NEXT: _t15 = std::pow(_t13, _t14); -//CHECK-NEXT: _t12 = sigma; -//CHECK-NEXT: _t16 = _t15 * _t12; -//CHECK-NEXT: _t11 = std::sqrt(_t16); -//CHECK-NEXT: _t17 = 1. / _t11; -//CHECK-NEXT: _t18 = power; -//CHECK-NEXT: _t10 = std::exp(_t18); -//CHECK-NEXT: double gaus = _t17 * _t10; -//CHECK-NEXT: _t19 = gaus; +//CHECK-NEXT: _t2 = power; +//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: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r17 = 1 * clad::custom_derivatives::log_pushforward(_t19, 1.).pushforward; -//CHECK-NEXT: _d_gaus += _r17; +//CHECK-NEXT: double _r18 = 1 * clad::custom_derivatives::log_pushforward(gaus, 1.).pushforward; +//CHECK-NEXT: _d_gaus += _r18; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r6 = _d_gaus * _t10; -//CHECK-NEXT: double _r7 = _r6 / _t11; -//CHECK-NEXT: double _r8 = _r6 * -1. / (_t11 * _t11); -//CHECK-NEXT: double _r9 = _r8 * clad::custom_derivatives::sqrt_pushforward(_t16, 1.).pushforward; -//CHECK-NEXT: double _r10 = _r9 * _t12; +//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 _grad2 = 0.; //CHECK-NEXT: double _grad3 = 0.; -//CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(_t13, _t14, _r10, &_grad2, &_grad3); +//CHECK-NEXT: clad::custom_derivatives::pow_pullback(2 * _t8, n, _r10, &_grad2, &_grad3); //CHECK-NEXT: double _r11 = _grad2; -//CHECK-NEXT: double _r12 = _r11 * 3.1415926535897931; -//CHECK-NEXT: double _r13 = _grad3; -//CHECK-NEXT: _d_n += _r13; -//CHECK-NEXT: double _r14 = _t15 * _r9; -//CHECK-NEXT: _d_sigma += _r14; -//CHECK-NEXT: double _r15 = _t17 * _d_gaus; -//CHECK-NEXT: double _r16 = _r15 * clad::custom_derivatives::exp_pushforward(_t18, 1.).pushforward; -//CHECK-NEXT: _d_power += _r16; +//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: } //CHECK-NEXT: { +//CHECK-NEXT: power = _t2; //CHECK-NEXT: double _r_d1 = _d_power; -//CHECK-NEXT: double _r1 = _r_d1 / _t6; +//CHECK-NEXT: double _r1 = _r_d1 / _t3; //CHECK-NEXT: _d_power += -_r1; -//CHECK-NEXT: double _r2 = _r_d1 * -_t7 / (_t6 * _t6); -//CHECK-NEXT: double _r3 = _r2 * _t8; +//CHECK-NEXT: double _r2 = _r_d1 * --power / (_t3 * _t3); +//CHECK-NEXT: double _r3 = _r2 * _t4; //CHECK-NEXT: double _r4 = 2 * _r2; //CHECK-NEXT: double _grad1 = 0.; -//CHECK-NEXT: sq_pullback(_t9, _r4, &_grad1); +//CHECK-NEXT: sq_pullback(sigma, _r4, &_grad1); //CHECK-NEXT: double _r5 = _grad1; //CHECK-NEXT: _d_sigma += _r5; //CHECK-NEXT: _d_power -= _r_d1; //CHECK-NEXT: } //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; +//CHECK-NEXT: power = clad::pop(_t1); //CHECK-NEXT: double _r_d0 = _d_power; //CHECK-NEXT: _d_power += _r_d0; //CHECK-NEXT: double _grad0 = 0.; -//CHECK-NEXT: sq_pullback(clad::pop(_t5), _r_d0, &_grad0); +//CHECK-NEXT: sq_pullback(x[i] - p[i], _r_d0, &_grad0); //CHECK-NEXT: double _r0 = _grad0; -//CHECK-NEXT: int _t2 = clad::pop(_t1); -//CHECK-NEXT: int _t4 = clad::pop(_t3); -//CHECK-NEXT: _d_p[_t4] += -_r0; +//CHECK-NEXT: _d_p[i] += -_r0; //CHECK-NEXT: _d_power -= _r_d0; //CHECK-NEXT: } //CHECK-NEXT: } @@ -385,20 +395,25 @@ void f_const_grad(const double, const double, clad::array_ref, clad::arr //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 _t2 = {}; //CHECK-NEXT: int _d_sq = 0; +//CHECK-NEXT: int sq0 = 0; +//CHECK-NEXT: clad::tape _t3 = {}; //CHECK-NEXT: int r = 0; //CHECK-NEXT: _t0 = 0; //CHECK-NEXT: for (int i = 0; i < a; i++) { //CHECK-NEXT: _t0++; -//CHECK-NEXT: int sq0 = clad::push(_t2, b) * clad::push(_t1, b); +//CHECK-NEXT: clad::push(_t2, sq0) , sq0 = b * clad::push(_t1, b); +//CHECK-NEXT: clad::push(_t3, r); //CHECK-NEXT: r += sq0; //CHECK-NEXT: } //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_r += 1; //CHECK-NEXT: for (; _t0; _t0--) { +//CHECK-NEXT: i--; //CHECK-NEXT: { +//CHECK-NEXT: r = clad::pop(_t3); //CHECK-NEXT: int _r_d0 = _d_r; //CHECK-NEXT: _d_r += _r_d0; //CHECK-NEXT: _d_sq += _r_d0; @@ -407,9 +422,10 @@ void f_const_grad(const double, const double, clad::array_ref, clad::arr //CHECK-NEXT: { //CHECK-NEXT: double _r0 = _d_sq * clad::pop(_t1); //CHECK-NEXT: * _d_b += _r0; -//CHECK-NEXT: double _r1 = clad::pop(_t2) * _d_sq; +//CHECK-NEXT: double _r1 = b * _d_sq; //CHECK-NEXT: * _d_b += _r1; -// CHECK-NEXT: _d_sq = 0; +//CHECK-NEXT: _d_sq = 0; +//CHECK-NEXT: sq0 = clad::pop(_t2); //CHECK-NEXT: } //CHECK-NEXT: } //CHECK-NEXT: } @@ -432,23 +448,31 @@ double f6 (double i, double j) { // 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: double _d_c = 0; +// CHECK-NEXT: double c = 0; +// CHECK-NEXT: clad::tape _t5 = {}; +// CHECK-NEXT: clad::tape _t6 = {}; // CHECK-NEXT: double a = 0; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: for (int counter = 0; counter < 3; ++counter) { // CHECK-NEXT: _t0++; -// CHECK-NEXT: double b = clad::push(_t2, i) * clad::push(_t1, i); -// CHECK-NEXT: double c = clad::push(_t4, j) * clad::push(_t3, j); +// 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: b += j; +// CHECK-NEXT: clad::push(_t6, a); // CHECK-NEXT: a += b + c + i; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_a += 1; // CHECK-NEXT: for (; _t0; _t0--) { +// CHECK-NEXT: --counter; // CHECK-NEXT: { +// CHECK-NEXT: a = clad::pop(_t6); // CHECK-NEXT: double _r_d1 = _d_a; // CHECK-NEXT: _d_a += _r_d1; // CHECK-NEXT: _d_b += _r_d1; @@ -457,6 +481,7 @@ double f6 (double i, double j) { // CHECK-NEXT: _d_a -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: b = clad::pop(_t5); // CHECK-NEXT: double _r_d0 = _d_b; // CHECK-NEXT: _d_b += _r_d0; // CHECK-NEXT: * _d_j += _r_d0; @@ -465,16 +490,18 @@ double f6 (double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: double _r2 = _d_c * clad::pop(_t3); // CHECK-NEXT: * _d_j += _r2; -// CHECK-NEXT: double _r3 = clad::pop(_t4) * _d_c; +// 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: } // CHECK-NEXT: { // CHECK-NEXT: double _r0 = _d_b * clad::pop(_t1); // CHECK-NEXT: * _d_i += _r0; -// CHECK-NEXT: double _r1 = clad::pop(_t2) * _d_b; +// 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: } // CHECK-NEXT: } // CHECK-NEXT: } @@ -499,7 +526,8 @@ double fn7(double i, double j) { // CHECK-NEXT: while (counter--) // CHECK-NEXT: { // CHECK-NEXT: _t0++; -// CHECK-NEXT: a += clad::push(_t2, i) * clad::push(_t1, i) + j; +// CHECK-NEXT: clad::push(_t1, a); +// CHECK-NEXT: a += i * clad::push(_t2, i) + j; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: @@ -507,11 +535,12 @@ double fn7(double i, double j) { // CHECK-NEXT: while (_t0) // CHECK-NEXT: { // CHECK-NEXT: { +// 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(_t1); +// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t2); // CHECK-NEXT: * _d_i += _r0; -// CHECK-NEXT: double _r1 = clad::pop(_t2) * _r_d0; +// CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: * _d_j += _r_d0; // CHECK-NEXT: _d_a -= _r_d0; @@ -546,7 +575,8 @@ double fn8(double i, double j) { // CHECK-NEXT: clad::push(_t1, 0UL); // CHECK-NEXT: do { // CHECK-NEXT: clad::back(_t1)++; -// CHECK-NEXT: a += clad::push(_t3, i) * clad::push(_t2, i) + j; +// CHECK-NEXT: clad::push(_t2, a); +// CHECK-NEXT: a += i * clad::push(_t3, i) + j; // CHECK-NEXT: } while (--counter); // CHECK-NEXT: } // CHECK-NEXT: goto _label0; @@ -558,11 +588,12 @@ double fn8(double i, double j) { // CHECK-NEXT: do { // CHECK-NEXT: { // CHECK-NEXT: { +// 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(_t2); +// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t3); // CHECK-NEXT: * _d_i += _r0; -// CHECK-NEXT: double _r1 = clad::pop(_t3) * _r_d0; +// CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: * _d_j += _r_d0; // CHECK-NEXT: _d_a -= _r_d0; @@ -591,61 +622,72 @@ double fn9(double i, double j) { // CHECK: void fn9_grad(double i, double j, clad::array_ref _d_i, clad::array_ref _d_j) { // CHECK-NEXT: int _d_counter = 0, _d_counter_again = 0; +// CHECK-NEXT: int _t0; +// CHECK-NEXT: int _t1; // CHECK-NEXT: double _d_a = 0; -// CHECK-NEXT: unsigned long _t0; -// CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: clad::tape _t2 = {}; -// CHECK-NEXT: clad::tape _t3 = {}; +// CHECK-NEXT: unsigned long _t2; +// 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; // CHECK-NEXT: counter = counter_again = 3; // CHECK-NEXT: double a = 0; -// CHECK-NEXT: _t0 = 0; +// CHECK-NEXT: _t2 = 0; // CHECK-NEXT: while (counter--) // CHECK-NEXT: { -// CHECK-NEXT: _t0++; +// CHECK-NEXT: _t2++; +// CHECK-NEXT: clad::push(_t3, counter_again); // CHECK-NEXT: counter_again = 3; -// CHECK-NEXT: clad::push(_t1, 0UL); +// CHECK-NEXT: clad::push(_t4, 0UL); // CHECK-NEXT: while (counter_again--) // CHECK-NEXT: { -// CHECK-NEXT: clad::back(_t1)++; -// CHECK-NEXT: a += clad::push(_t3, i) * clad::push(_t2, i) + j; +// CHECK-NEXT: clad::back(_t4)++; +// CHECK-NEXT: clad::push(_t5, a); +// CHECK-NEXT: a += i * clad::push(_t6, i) + j; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_a += 1; -// CHECK-NEXT: while (_t0) +// CHECK-NEXT: while (_t2) // CHECK-NEXT: { // CHECK-NEXT: { // CHECK-NEXT: { -// CHECK-NEXT: while (clad::back(_t1)) +// CHECK-NEXT: while (clad::back(_t4)) // CHECK-NEXT: { // CHECK-NEXT: { // CHECK-NEXT: { +// 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(_t2); +// CHECK-NEXT: double _r0 = _r_d3 * clad::pop(_t6); // CHECK-NEXT: * _d_i += _r0; -// CHECK-NEXT: double _r1 = clad::pop(_t3) * _r_d3; +// CHECK-NEXT: double _r1 = i * _r_d3; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: * _d_j += _r_d3; // CHECK-NEXT: _d_a -= _r_d3; // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: clad::back(_t1)--; +// CHECK-NEXT: clad::back(_t4)--; // CHECK-NEXT: } -// CHECK-NEXT: clad::pop(_t1); +// CHECK-NEXT: clad::pop(_t4); // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: counter_again = clad::pop(_t3); // CHECK-NEXT: int _r_d2 = _d_counter_again; // CHECK-NEXT: _d_counter_again -= _r_d2; // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: _t0--; +// CHECK-NEXT: _t2--; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: counter = _t0; // CHECK-NEXT: int _r_d0 = _d_counter; // CHECK-NEXT: _d_counter_again += _r_d0; +// CHECK-NEXT: counter_again = _t1; // CHECK-NEXT: int _r_d1 = _d_counter_again; // CHECK-NEXT: _d_counter_again -= _r_d1; // CHECK-NEXT: _d_counter -= _r_d0; @@ -667,17 +709,24 @@ double fn10(double i, double j) { // CHECK-NEXT: double _d_a = 0; // CHECK-NEXT: int _d_counter = 0; // CHECK-NEXT: unsigned long _t0; +// CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: int _d_b = 0; -// CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: clad::tape _t2 = {}; +// 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: double a = 0; // CHECK-NEXT: int counter = 3; // CHECK-NEXT: _t0 = 0; -// CHECK-NEXT: while (int b = counter) +// CHECK-NEXT: while (clad::push(_t1, b) , b = counter) // CHECK-NEXT: { // CHECK-NEXT: _t0++; -// CHECK-NEXT: b += clad::push(_t2, i) * clad::push(_t1, i) + j; +// CHECK-NEXT: clad::push(_t2, b); +// CHECK-NEXT: b += i * clad::push(_t3, i) + j; +// CHECK-NEXT: clad::push(_t4, a); // CHECK-NEXT: a += b; +// CHECK-NEXT: clad::push(_t5, counter); // CHECK-NEXT: counter -= 1; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; @@ -687,22 +736,25 @@ double fn10(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: { // CHECK-NEXT: { +// CHECK-NEXT: counter = clad::pop(_t5); // 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: double _r_d1 = _d_a; // CHECK-NEXT: _d_a += _r_d1; // CHECK-NEXT: _d_b += _r_d1; // CHECK-NEXT: _d_a -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { +// 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(_t1); +// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t3); // CHECK-NEXT: * _d_i += _r0; -// CHECK-NEXT: double _r1 = clad::pop(_t2) * _r_d0; +// CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: * _d_j += _r_d0; // CHECK-NEXT: _d_b -= _r_d0; @@ -711,6 +763,7 @@ double fn10(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: _d_counter += _d_b; // CHECK-NEXT: _d_b = 0; +// CHECK-NEXT: b = clad::pop(_t1); // CHECK-NEXT: } // CHECK-NEXT: _t0--; // CHECK-NEXT: } @@ -731,13 +784,16 @@ double fn11(double i, double j) { // CHECK-NEXT: double _d_a = 0; // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: clad::tape _t2 = {}; +// CHECK-NEXT: tape _t2 = {}; +// CHECK-NEXT: clad::tape _t3 = {}; // CHECK-NEXT: int counter = 3; // CHECK-NEXT: double a = 0; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: do { // CHECK-NEXT: _t0++; -// CHECK-NEXT: a += clad::push(_t2, i) * clad::push(_t1, i) + j; +// CHECK-NEXT: clad::push(_t1, a); +// CHECK-NEXT: a += i * clad::push(_t2, i) + j; +// CHECK-NEXT: clad::push(_t3, counter); // CHECK-NEXT: counter -= 1; // CHECK-NEXT: } while (counter); // CHECK-NEXT: goto _label0; @@ -746,16 +802,18 @@ double fn11(double i, double j) { // CHECK-NEXT: do { // CHECK-NEXT: { // CHECK-NEXT: { +// CHECK-NEXT: counter = clad::pop(_t3); // CHECK-NEXT: int _r_d1 = _d_counter; // CHECK-NEXT: _d_counter += _r_d1; // CHECK-NEXT: _d_counter -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { +// 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(_t1); +// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t2); // CHECK-NEXT: * _d_i += _r0; -// CHECK-NEXT: double _r1 = clad::pop(_t2) * _r_d0; +// CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: * _d_j += _r_d0; // CHECK-NEXT: _d_a -= _r_d0; @@ -786,28 +844,37 @@ double fn12(double i, double j) { // CHECK-NEXT: int _d_counter = 0; // CHECK-NEXT: double _d_a = 0; // CHECK-NEXT: unsigned long _t0; +// CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: int _d_counter_again = 0; -// CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: clad::tape _t2 = {}; +// 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 _t4 = {}; +// CHECK-NEXT: clad::tape _t5 = {}; +// CHECK-NEXT: clad::tape _t6 = {}; +// CHECK-NEXT: clad::tape _t7 = {}; +// CHECK-NEXT: clad::tape _t8 = {}; // CHECK-NEXT: int counter = 3; // CHECK-NEXT: double a = 0; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: do { // CHECK-NEXT: _t0++; -// CHECK-NEXT: int counter_again = 3; -// CHECK-NEXT: clad::push(_t1, 0UL); +// CHECK-NEXT: clad::push(_t1, counter_again) , counter_again = 3; +// CHECK-NEXT: clad::push(_t2, 0UL); // CHECK-NEXT: do { -// CHECK-NEXT: clad::back(_t1)++; -// CHECK-NEXT: a += clad::push(_t3, i) * clad::push(_t2, i) + j; +// 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: counter_again -= 1; -// CHECK-NEXT: clad::push(_t4, 0UL); +// CHECK-NEXT: clad::push(_t6, 0UL); // CHECK-NEXT: do { -// CHECK-NEXT: clad::back(_t4)++; +// CHECK-NEXT: clad::back(_t6)++; +// CHECK-NEXT: clad::push(_t7, a); // CHECK-NEXT: a += j; // CHECK-NEXT: } while (0); // CHECK-NEXT: } while (counter_again); +// CHECK-NEXT: clad::push(_t8, counter); // CHECK-NEXT: counter -= 1; // CHECK-NEXT: } while (counter); // CHECK-NEXT: goto _label0; @@ -816,6 +883,7 @@ double fn12(double i, double j) { // CHECK-NEXT: do { // CHECK-NEXT: { // CHECK-NEXT: { +// CHECK-NEXT: counter = clad::pop(_t8); // CHECK-NEXT: int _r_d3 = _d_counter; // CHECK-NEXT: _d_counter += _r_d3; // CHECK-NEXT: _d_counter -= _r_d3; @@ -826,36 +894,42 @@ double fn12(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: do { // CHECK-NEXT: { +// CHECK-NEXT: a = clad::pop(_t7); // 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(_t4)--; -// CHECK-NEXT: } while (clad::back(_t4)); -// CHECK-NEXT: clad::pop(_t4); +// CHECK-NEXT: clad::back(_t6)--; +// CHECK-NEXT: } while (clad::back(_t6)); +// CHECK-NEXT: clad::pop(_t6); // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: counter_again = clad::pop(_t5); // CHECK-NEXT: int _r_d1 = _d_counter_again; // CHECK-NEXT: _d_counter_again += _r_d1; // CHECK-NEXT: _d_counter_again -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { +// 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(_t2); +// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t4); // CHECK-NEXT: * _d_i += _r0; -// CHECK-NEXT: double _r1 = clad::pop(_t3) * _r_d0; +// CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: * _d_j += _r_d0; // CHECK-NEXT: _d_a -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: clad::back(_t1)--; -// CHECK-NEXT: } while (clad::back(_t1)); -// CHECK-NEXT: clad::pop(_t1); +// CHECK-NEXT: clad::back(_t2)--; +// CHECK-NEXT: } while (clad::back(_t2)); +// CHECK-NEXT: clad::pop(_t2); +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: _d_counter_again = 0; +// CHECK-NEXT: counter_again = clad::pop(_t1); // CHECK-NEXT: } -// CHECK-NEXT: _d_counter_again = 0; // CHECK-NEXT: } // CHECK-NEXT: _t0--; // CHECK-NEXT: } while (_t0); @@ -876,16 +950,25 @@ double fn13(double i, double j) { // CHECK-NEXT: double _d_res = 0; // CHECK-NEXT: int _d_counter = 0; // CHECK-NEXT: unsigned long _t0; +// CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: int _d_k = 0; -// CHECK-NEXT: clad::tape _t1 = {}; +// CHECK-NEXT: int k = 0; +// 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: double res = 0; // CHECK-NEXT: int counter = 3; // CHECK-NEXT: _t0 = 0; -// CHECK-NEXT: for (; k; counter -= 1) { +// CHECK-NEXT: for (; k , clad::push(_t1, k) , k = counter; clad::push(_t2, counter) , (counter -= 1)) { // CHECK-NEXT: _t0++; -// CHECK-NEXT: k += i + 2 * clad::push(_t1, j); -// CHECK-NEXT: double temp = k; +// 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: res += temp; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; @@ -893,12 +976,14 @@ double fn13(double i, double j) { // CHECK-NEXT: _d_res += 1; // CHECK-NEXT: for (; _t0; _t0--) { // CHECK-NEXT: { -// CHECK-NEXT: int _r_d0 = _d_counter; -// CHECK-NEXT: _d_counter += _r_d0; -// CHECK-NEXT: _d_counter -= _r_d0; -// CHECK-NEXT: } -// CHECK-NEXT: { // CHECK-NEXT: { +// CHECK-NEXT: counter = clad::pop(_t2); +// CHECK-NEXT: int _r_d0 = _d_counter; +// CHECK-NEXT: _d_counter += _r_d0; +// CHECK-NEXT: _d_counter -= _r_d0; +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: res = clad::pop(_t6); // CHECK-NEXT: double _r_d2 = _d_res; // CHECK-NEXT: _d_res += _r_d2; // CHECK-NEXT: _d_temp += _r_d2; @@ -907,12 +992,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: } // 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(_t1); +// CHECK-NEXT: double _r0 = _r_d1 * clad::pop(_t4); // CHECK-NEXT: int _r1 = 2 * _r_d1; // CHECK-NEXT: * _d_j += _r1; // CHECK-NEXT: _d_k -= _r_d1; @@ -921,6 +1008,7 @@ double fn13(double i, double j) { // CHECK-NEXT: { // CHECK-NEXT: _d_counter += _d_k; // CHECK-NEXT: _d_k = 0; +// CHECK-NEXT: k = clad::pop(_t1); // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } @@ -951,11 +1039,13 @@ double fn14(double i, double j) { // CHECK-NEXT: double _d_res = 0; // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: clad::tape _t2 = {}; -// CHECK-NEXT: clad::tape _t3 = {}; -// CHECK-NEXT: clad::tape _t5 = {}; -// CHECK-NEXT: clad::tape _t7 = {}; -// CHECK-NEXT: clad::tape _t8 = {}; -// CHECK-NEXT: clad::tape _t9 = {}; +// CHECK-NEXT: clad::tape _t3 = {}; +// CHECK-NEXT: clad::tape _t4 = {}; +// CHECK-NEXT: clad::tape _t6 = {}; +// 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; @@ -965,63 +1055,68 @@ double fn14(double i, double j) { // CHECK-NEXT: bool _t1 = choice > 3; // CHECK-NEXT: { // CHECK-NEXT: if (_t1) { +// CHECK-NEXT: clad::push(_t3, res); // CHECK-NEXT: res += i; // CHECK-NEXT: { -// CHECK-NEXT: clad::push(_t3, 1UL); +// CHECK-NEXT: clad::push(_t4, 1UL); // CHECK-NEXT: continue; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: clad::push(_t2, _t1); // CHECK-NEXT: } -// CHECK-NEXT: bool _t4 = choice > 1; +// CHECK-NEXT: bool _t5 = choice > 1; // CHECK-NEXT: { -// CHECK-NEXT: if (_t4) { +// CHECK-NEXT: if (_t5) { +// CHECK-NEXT: clad::push(_t7, res); // CHECK-NEXT: res += j; // CHECK-NEXT: { -// CHECK-NEXT: clad::push(_t3, 2UL); +// CHECK-NEXT: clad::push(_t4, 2UL); // CHECK-NEXT: continue; // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t5, _t4); +// CHECK-NEXT: clad::push(_t6, _t5); // CHECK-NEXT: } -// CHECK-NEXT: bool _t6 = choice > 0; +// CHECK-NEXT: bool _t8 = choice > 0; // CHECK-NEXT: { -// CHECK-NEXT: if (_t6) { -// CHECK-NEXT: res += clad::push(_t9, i) * clad::push(_t8, j); +// CHECK-NEXT: if (_t8) { +// CHECK-NEXT: clad::push(_t10, res); +// CHECK-NEXT: res += i * clad::push(_t11, j); // CHECK-NEXT: { -// CHECK-NEXT: clad::push(_t3, 3UL); +// CHECK-NEXT: clad::push(_t4, 3UL); // CHECK-NEXT: continue; // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t7, _t6); +// CHECK-NEXT: clad::push(_t9, _t8); // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t3, 4UL); +// CHECK-NEXT: clad::push(_t4, 4UL); // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += 1; // CHECK-NEXT: while (_t0) // CHECK-NEXT: { -// CHECK-NEXT: switch (clad::pop(_t3)) { +// CHECK-NEXT: switch (clad::pop(_t4)) { // CHECK-NEXT: case 4UL: // CHECK-NEXT: ; -// CHECK-NEXT: if (clad::pop(_t7)) { +// CHECK-NEXT: if (clad::pop(_t9)) { // CHECK-NEXT: case 3UL: // CHECK-NEXT: ; // CHECK-NEXT: { +// 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(_t8); +// CHECK-NEXT: double _r0 = _r_d2 * clad::pop(_t11); // CHECK-NEXT: * _d_i += _r0; -// CHECK-NEXT: double _r1 = clad::pop(_t9) * _r_d2; +// CHECK-NEXT: double _r1 = i * _r_d2; // CHECK-NEXT: * _d_j += _r1; // CHECK-NEXT: _d_res -= _r_d2; // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: if (clad::pop(_t5)) { +// CHECK-NEXT: if (clad::pop(_t6)) { // CHECK-NEXT: case 2UL: // CHECK-NEXT: ; // CHECK-NEXT: { +// CHECK-NEXT: res = clad::pop(_t7); // CHECK-NEXT: double _r_d1 = _d_res; // CHECK-NEXT: _d_res += _r_d1; // CHECK-NEXT: * _d_j += _r_d1; @@ -1032,6 +1127,7 @@ double fn14(double i, double j) { // CHECK-NEXT: case 1UL: // CHECK-NEXT: ; // CHECK-NEXT: { +// CHECK-NEXT: res = clad::pop(_t3); // CHECK-NEXT: double _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; // CHECK-NEXT: * _d_i += _r_d0; @@ -1069,11 +1165,15 @@ double fn15(double i, double j) { // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: clad::tape _t2 = {}; // CHECK-NEXT: clad::tape _t3 = {}; +// CHECK-NEXT: clad::tape _t4 = {}; // CHECK-NEXT: int _d_another_choice = 0; -// CHECK-NEXT: clad::tape _t4 = {}; -// CHECK-NEXT: clad::tape _t6 = {}; -// CHECK-NEXT: clad::tape _t7 = {}; -// CHECK-NEXT: clad::tape _t9 = {}; +// CHECK-NEXT: int another_choice = 0; +// CHECK-NEXT: clad::tape _t5 = {}; +// CHECK-NEXT: clad::tape _t7 = {}; +// CHECK-NEXT: clad::tape _t8 = {}; +// CHECK-NEXT: clad::tape _t9 = {}; +// CHECK-NEXT: clad::tape _t11 = {}; +// CHECK-NEXT: clad::tape _t12 = {}; // CHECK-NEXT: int choice = 5; // CHECK-NEXT: double res = 0; // CHECK-NEXT: _t0 = 0; @@ -1088,30 +1188,32 @@ double fn15(double i, double j) { // CHECK-NEXT: } // CHECK-NEXT: clad::push(_t2, _t1); // CHECK-NEXT: } -// CHECK-NEXT: int another_choice = 3; -// CHECK-NEXT: clad::push(_t4, 0UL); +// CHECK-NEXT: clad::push(_t4, another_choice) , another_choice = 3; +// CHECK-NEXT: clad::push(_t5, 0UL); // CHECK-NEXT: while (another_choice--) // CHECK-NEXT: { -// CHECK-NEXT: clad::back(_t4)++; -// CHECK-NEXT: bool _t5 = another_choice > 1; +// CHECK-NEXT: clad::back(_t5)++; +// CHECK-NEXT: bool _t6 = another_choice > 1; // CHECK-NEXT: { -// CHECK-NEXT: if (_t5) { +// CHECK-NEXT: if (_t6) { +// CHECK-NEXT: clad::push(_t8, res); // CHECK-NEXT: res += i; // CHECK-NEXT: { -// CHECK-NEXT: clad::push(_t7, 1UL); +// CHECK-NEXT: clad::push(_t9, 1UL); // CHECK-NEXT: continue; // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t6, _t5); +// CHECK-NEXT: clad::push(_t7, _t6); // CHECK-NEXT: } -// CHECK-NEXT: bool _t8 = another_choice > 0; +// CHECK-NEXT: bool _t10 = another_choice > 0; // CHECK-NEXT: { -// CHECK-NEXT: if (_t8) { +// CHECK-NEXT: if (_t10) { +// CHECK-NEXT: clad::push(_t12, res); // CHECK-NEXT: res += j; // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t9, _t8); +// CHECK-NEXT: clad::push(_t11, _t10); // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t7, 2UL); +// CHECK-NEXT: clad::push(_t9, 2UL); // CHECK-NEXT: } // CHECK-NEXT: clad::push(_t3, 2UL); // CHECK-NEXT: } @@ -1124,23 +1226,25 @@ double fn15(double i, double j) { // CHECK-NEXT: case 2UL: // CHECK-NEXT: ; // CHECK-NEXT: { -// CHECK-NEXT: while (clad::back(_t4)) +// CHECK-NEXT: while (clad::back(_t5)) // CHECK-NEXT: { -// CHECK-NEXT: switch (clad::pop(_t7)) { +// CHECK-NEXT: switch (clad::pop(_t9)) { // CHECK-NEXT: case 2UL: // CHECK-NEXT: ; -// CHECK-NEXT: if (clad::pop(_t9)) { +// CHECK-NEXT: if (clad::pop(_t11)) { // CHECK-NEXT: { +// CHECK-NEXT: res = clad::pop(_t12); // CHECK-NEXT: double _r_d1 = _d_res; // CHECK-NEXT: _d_res += _r_d1; // CHECK-NEXT: * _d_j += _r_d1; // CHECK-NEXT: _d_res -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: if (clad::pop(_t6)) { +// CHECK-NEXT: if (clad::pop(_t7)) { // CHECK-NEXT: case 1UL: // CHECK-NEXT: ; // CHECK-NEXT: { +// CHECK-NEXT: res = clad::pop(_t8); // CHECK-NEXT: double _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; // CHECK-NEXT: * _d_i += _r_d0; @@ -1148,11 +1252,14 @@ double fn15(double i, double j) { // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: clad::back(_t4)--; +// CHECK-NEXT: clad::back(_t5)--; // CHECK-NEXT: } -// CHECK-NEXT: clad::pop(_t4); +// CHECK-NEXT: clad::pop(_t5); +// CHECK-NEXT: } +// CHECK-NEXT: { +// CHECK-NEXT: _d_another_choice = 0; +// CHECK-NEXT: another_choice = clad::pop(_t4); // CHECK-NEXT: } -// CHECK-NEXT: _d_another_choice = 0; // CHECK-NEXT: if (clad::pop(_t2)) // CHECK-NEXT: case 1UL: // CHECK-NEXT: ; @@ -1189,6 +1296,8 @@ double fn16(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: int counter = 5; // CHECK-NEXT: double res = 0; // CHECK-NEXT: _t0 = 0; @@ -1197,7 +1306,8 @@ double fn16(double i, double j) { // CHECK-NEXT: bool _t1 = ii == 4; // CHECK-NEXT: { // CHECK-NEXT: if (_t1) { -// CHECK-NEXT: res += clad::push(_t4, i) * clad::push(_t3, j); +// CHECK-NEXT: clad::push(_t3, res); +// CHECK-NEXT: res += i * clad::push(_t4, j); // CHECK-NEXT: { // CHECK-NEXT: clad::push(_t5, 1UL); // CHECK-NEXT: break; @@ -1208,7 +1318,8 @@ double fn16(double i, double j) { // CHECK-NEXT: bool _t6 = ii > 2; // CHECK-NEXT: { // CHECK-NEXT: if (_t6) { -// CHECK-NEXT: res += 2 * clad::push(_t8, i); +// CHECK-NEXT: clad::push(_t8, res); +// CHECK-NEXT: res += 2 * clad::push(_t9, i); // CHECK-NEXT: { // CHECK-NEXT: clad::push(_t5, 2UL); // CHECK-NEXT: continue; @@ -1216,6 +1327,7 @@ double fn16(double i, double j) { // CHECK-NEXT: } // CHECK-NEXT: clad::push(_t7, _t6); // CHECK-NEXT: } +// CHECK-NEXT: clad::push(_t10, res); // CHECK-NEXT: res += i + j; // CHECK-NEXT: clad::push(_t5, 3UL); // CHECK-NEXT: } @@ -1226,7 +1338,9 @@ double fn16(double i, double j) { // CHECK-NEXT: switch (clad::pop(_t5)) { // CHECK-NEXT: case 3UL: // CHECK-NEXT: ; +// CHECK-NEXT: --ii; // CHECK-NEXT: { +// CHECK-NEXT: res = clad::pop(_t10); // CHECK-NEXT: double _r_d2 = _d_res; // CHECK-NEXT: _d_res += _r_d2; // CHECK-NEXT: * _d_i += _r_d2; @@ -1237,9 +1351,10 @@ double fn16(double i, double j) { // CHECK-NEXT: case 2UL: // CHECK-NEXT: ; // CHECK-NEXT: { +// CHECK-NEXT: res = clad::pop(_t8); // CHECK-NEXT: double _r_d1 = _d_res; // CHECK-NEXT: _d_res += _r_d1; -// CHECK-NEXT: double _r2 = _r_d1 * clad::pop(_t8); +// CHECK-NEXT: double _r2 = _r_d1 * clad::pop(_t9); // CHECK-NEXT: double _r3 = 2 * _r_d1; // CHECK-NEXT: * _d_i += _r3; // CHECK-NEXT: _d_res -= _r_d1; @@ -1249,11 +1364,12 @@ double fn16(double i, double j) { // CHECK-NEXT: case 1UL: // CHECK-NEXT: ; // CHECK-NEXT: { +// 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(_t3); +// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t4); // CHECK-NEXT: * _d_i += _r0; -// CHECK-NEXT: double _r1 = clad::pop(_t4) * _r_d0; +// CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_j += _r1; // CHECK-NEXT: _d_res -= _r_d0; // CHECK-NEXT: } @@ -1286,96 +1402,101 @@ double fn17(double i, double j) { // CHECK-NEXT: double _d_res = 0; // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: int _d_ii = 0; +// CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: int _d_jj = 0; -// CHECK-NEXT: clad::tape _t2 = {}; -// CHECK-NEXT: clad::tape _t3 = {}; +// CHECK-NEXT: int jj = 0; +// CHECK-NEXT: clad::tape _t3 = {}; // CHECK-NEXT: clad::tape _t4 = {}; -// CHECK-NEXT: clad::tape _t6 = {}; -// CHECK-NEXT: clad::tape _t7 = {}; +// 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 _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 _t15 = {}; // CHECK-NEXT: int counter = 5; // CHECK-NEXT: double res = 0; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: for (int ii = 0; ii < counter; ++ii) { // CHECK-NEXT: _t0++; -// CHECK-NEXT: int jj = ii; -// CHECK-NEXT: bool _t1 = ii < 2; +// CHECK-NEXT: clad::push(_t1, jj) , jj = ii; +// CHECK-NEXT: bool _t2 = ii < 2; // CHECK-NEXT: { -// CHECK-NEXT: if (_t1) { -// CHECK-NEXT: clad::push(_t3, 1UL); +// CHECK-NEXT: if (_t2) { +// CHECK-NEXT: clad::push(_t4, 1UL); // CHECK-NEXT: continue; // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t2, _t1); +// CHECK-NEXT: clad::push(_t3, _t2); // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t4, 0UL); +// CHECK-NEXT: clad::push(_t5, 0UL); // CHECK-NEXT: while (jj--) // CHECK-NEXT: { -// CHECK-NEXT: clad::back(_t4)++; -// CHECK-NEXT: bool _t5 = jj < 3; +// CHECK-NEXT: clad::back(_t5)++; +// CHECK-NEXT: bool _t6 = jj < 3; // CHECK-NEXT: { -// CHECK-NEXT: if (_t5) { -// CHECK-NEXT: res += clad::push(_t8, i) * clad::push(_t7, j); +// CHECK-NEXT: if (_t6) { +// CHECK-NEXT: clad::push(_t8, res); +// CHECK-NEXT: res += i * clad::push(_t9, j); // CHECK-NEXT: { -// CHECK-NEXT: clad::push(_t9, 1UL); +// CHECK-NEXT: clad::push(_t10, 1UL); // CHECK-NEXT: break; // CHECK-NEXT: } // CHECK-NEXT: } else { // CHECK-NEXT: { -// CHECK-NEXT: clad::push(_t9, 2UL); +// CHECK-NEXT: clad::push(_t10, 2UL); // CHECK-NEXT: continue; // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t6, _t5); +// CHECK-NEXT: clad::push(_t7, _t6); // CHECK-NEXT: } -// CHECK-NEXT: res += clad::push(_t15, clad::push(_t14, clad::push(_t13, i) * clad::push(_t12, i)) * clad::push(_t11, j)) * clad::push(_t10, j); -// CHECK-NEXT: clad::push(_t9, 3UL); +// 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: } -// CHECK-NEXT: clad::push(_t3, 2UL); +// CHECK-NEXT: clad::push(_t4, 2UL); // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += 1; // CHECK-NEXT: for (; _t0; _t0--) -// CHECK-NEXT: switch (clad::pop(_t3)) { +// CHECK-NEXT: switch (clad::pop(_t4)) { // CHECK-NEXT: case 2UL: // CHECK-NEXT: ; +// CHECK-NEXT: --ii; // CHECK-NEXT: { -// CHECK-NEXT: while (clad::back(_t4)) +// CHECK-NEXT: while (clad::back(_t5)) // CHECK-NEXT: { -// CHECK-NEXT: switch (clad::pop(_t9)) { +// CHECK-NEXT: switch (clad::pop(_t10)) { // CHECK-NEXT: case 3UL: // CHECK-NEXT: ; // CHECK-NEXT: { +// CHECK-NEXT: res = clad::pop(_t11); // CHECK-NEXT: double _r_d1 = _d_res; // CHECK-NEXT: _d_res += _r_d1; -// CHECK-NEXT: double _r2 = _r_d1 * clad::pop(_t10); -// CHECK-NEXT: double _r3 = _r2 * clad::pop(_t11); -// CHECK-NEXT: double _r4 = _r3 * clad::pop(_t12); +// 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: * _d_i += _r4; -// CHECK-NEXT: double _r5 = clad::pop(_t13) * _r3; +// CHECK-NEXT: double _r5 = i * _r3; // CHECK-NEXT: * _d_i += _r5; -// CHECK-NEXT: double _r6 = clad::pop(_t14) * _r2; +// CHECK-NEXT: double _r6 = i * clad::push(_t14, i) * _r2; // CHECK-NEXT: * _d_j += _r6; -// CHECK-NEXT: double _r7 = clad::pop(_t15) * _r_d1; +// CHECK-NEXT: double _r7 = i * clad::push(_t14, i) * clad::push(_t13, j) * _r_d1; // CHECK-NEXT: * _d_j += _r7; // CHECK-NEXT: _d_res -= _r_d1; // CHECK-NEXT: } -// CHECK-NEXT: if (clad::pop(_t6)) { +// CHECK-NEXT: if (clad::pop(_t7)) { // CHECK-NEXT: case 1UL: // CHECK-NEXT: ; // CHECK-NEXT: { +// 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(_t7); +// CHECK-NEXT: double _r0 = _r_d0 * clad::pop(_t9); // CHECK-NEXT: * _d_i += _r0; -// CHECK-NEXT: double _r1 = clad::pop(_t8) * _r_d0; +// CHECK-NEXT: double _r1 = i * _r_d0; // CHECK-NEXT: * _d_j += _r1; // CHECK-NEXT: _d_res -= _r_d0; // CHECK-NEXT: } @@ -1384,16 +1505,17 @@ double fn17(double i, double j) { // CHECK-NEXT: ; // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: clad::back(_t4)--; +// CHECK-NEXT: clad::back(_t5)--; // CHECK-NEXT: } -// CHECK-NEXT: clad::pop(_t4); +// CHECK-NEXT: clad::pop(_t5); // CHECK-NEXT: } -// CHECK-NEXT: if (clad::pop(_t2)) +// CHECK-NEXT: if (clad::pop(_t3)) // CHECK-NEXT: case 1UL: // CHECK-NEXT: ; // CHECK-NEXT: { // CHECK-NEXT: _d_ii += _d_jj; // CHECK-NEXT: _d_jj = 0; +// CHECK-NEXT: jj = clad::pop(_t1); // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } @@ -1419,10 +1541,12 @@ double fn18(double i, double j) { // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: int _d_counter = 0; // CHECK-NEXT: clad::tape _t2 = {}; -// CHECK-NEXT: clad::tape _t4 = {}; -// CHECK-NEXT: clad::tape _t5 = {}; -// CHECK-NEXT: clad::tape _t6 = {}; +// CHECK-NEXT: clad::tape _t3 = {}; +// 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; @@ -1430,54 +1554,59 @@ double fn18(double i, double j) { // CHECK-NEXT: _t0++; // CHECK-NEXT: bool _t1 = counter < 2; // CHECK-NEXT: { -// CHECK-NEXT: if (_t1) +// CHECK-NEXT: if (_t1) { +// CHECK-NEXT: clad::push(_t3, res); // CHECK-NEXT: res += i + j; -// CHECK-NEXT: else { -// CHECK-NEXT: bool _t3 = counter < 4; +// CHECK-NEXT: } else { +// CHECK-NEXT: bool _t4 = counter < 4; // CHECK-NEXT: { -// CHECK-NEXT: if (_t3) { -// CHECK-NEXT: clad::push(_t5, 1UL); +// CHECK-NEXT: if (_t4) { +// CHECK-NEXT: clad::push(_t6, 1UL); // CHECK-NEXT: continue; // CHECK-NEXT: } else { -// CHECK-NEXT: res += 2 * clad::push(_t6, i) + 2 * clad::push(_t7, j); +// CHECK-NEXT: clad::push(_t7, res); +// CHECK-NEXT: res += 2 * clad::push(_t8, i) + 2 * clad::push(_t9, j); // CHECK-NEXT: { -// CHECK-NEXT: clad::push(_t5, 2UL); +// CHECK-NEXT: clad::push(_t6, 2UL); // CHECK-NEXT: break; // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t4, _t3); +// CHECK-NEXT: clad::push(_t5, _t4); // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: clad::push(_t2, _t1); // CHECK-NEXT: } -// CHECK-NEXT: clad::push(_t5, 3UL); +// CHECK-NEXT: clad::push(_t6, 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(_t6)) { // CHECK-NEXT: case 3UL: // CHECK-NEXT: ; +// CHECK-NEXT: --counter; // CHECK-NEXT: if (clad::pop(_t2)) { +// CHECK-NEXT: res = clad::pop(_t3); // CHECK-NEXT: double _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; // CHECK-NEXT: * _d_i += _r_d0; // CHECK-NEXT: * _d_j += _r_d0; // CHECK-NEXT: _d_res -= _r_d0; -// CHECK-NEXT: } else if (clad::pop(_t4)) +// CHECK-NEXT: } else if (clad::pop(_t5)) // CHECK-NEXT: case 1UL: // CHECK-NEXT: ; // CHECK-NEXT: else { // CHECK-NEXT: case 2UL: // CHECK-NEXT: ; // CHECK-NEXT: { +// 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(_t6); +// CHECK-NEXT: double _r0 = _r_d1 * clad::pop(_t8); // CHECK-NEXT: double _r1 = 2 * _r_d1; // CHECK-NEXT: * _d_i += _r1; -// CHECK-NEXT: double _r2 = _r_d1 * clad::pop(_t7); +// CHECK-NEXT: double _r2 = _r_d1 * clad::pop(_t9); // CHECK-NEXT: double _r3 = 2 * _r_d1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: _d_res -= _r_d1; @@ -1500,28 +1629,30 @@ double fn19(double* arr, int n) { // CHECK-NEXT: double _d_res = 0; // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: int _d_i = 0; -// CHECK-NEXT: clad::tape _t1 = {}; -// CHECK-NEXT: clad::tape _t3 = {}; +// CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: double *_d_ref = 0; +// CHECK-NEXT: clad::tape _t3 = {}; // CHECK-NEXT: double res = 0; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: for (int i = 0; i < n; ++i) { // CHECK-NEXT: _t0++; // CHECK-NEXT: _d_ref = &_d_arr[i]; -// CHECK-NEXT: clad::push(_t3, _d_ref); -// CHECK-NEXT: double &ref = arr[clad::push(_t1, i)]; +// CHECK-NEXT: clad::push(_t1, _d_ref); +// CHECK-NEXT: double &ref = arr[i]; +// CHECK-NEXT: clad::push(_t3, res); // CHECK-NEXT: res += ref; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += 1; // CHECK-NEXT: for (; _t0; _t0--) { -// CHECK-NEXT: double *_t4 = clad::pop(_t3); +// CHECK-NEXT: --i; +// CHECK-NEXT: double *_t2 = clad::pop(_t1); // CHECK-NEXT: { -// CHECK-NEXT: int _t2 = clad::pop(_t1); +// CHECK-NEXT: res = clad::pop(_t3); // CHECK-NEXT: double _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; -// CHECK-NEXT: *_t4 += _r_d0; +// CHECK-NEXT: *_t2 += _r_d0; // CHECK-NEXT: _d_res -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: } @@ -1541,48 +1672,47 @@ double f_loop_init_var(double lower, double upper) { // CHECK-NEXT: double _d_sum = 0; // CHECK-NEXT: double _d_num_points = 0; // CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; // CHECK-NEXT: double _d_interval = 0; -// CHECK-NEXT: unsigned long _t2; +// CHECK-NEXT: unsigned long _t1; // 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: clad::tape _t6 = {}; // CHECK-NEXT: double sum = 0; // CHECK-NEXT: double num_points = 10000; -// CHECK-NEXT: _t1 = (upper - lower); // CHECK-NEXT: _t0 = num_points; -// CHECK-NEXT: double interval = _t1 / _t0; -// CHECK-NEXT: _t2 = 0; -// CHECK-NEXT: for (double x = lower; x <= upper; x += interval) { -// CHECK-NEXT: _t2++; -// CHECK-NEXT: sum += clad::push(_t6, clad::push(_t5, x) * clad::push(_t4, x)) * clad::push(_t3, interval); +// CHECK-NEXT: double interval = (upper - lower) / _t0; +// CHECK-NEXT: _t1 = 0; +// 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: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_sum += 1; // CHECK-NEXT: { -// CHECK-NEXT: for (; _t2; _t2--) { +// CHECK-NEXT: for (; _t1; _t1--) { // CHECK-NEXT: { +// CHECK-NEXT: x = clad::pop(_t2); // CHECK-NEXT: double _r_d0 = _d_x; // CHECK-NEXT: _d_x += _r_d0; // CHECK-NEXT: _d_interval += _r_d0; // CHECK-NEXT: _d_x -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: { -// CHECK-NEXT: double _r_d1 = _d_sum; -// CHECK-NEXT: _d_sum += _r_d1; -// CHECK-NEXT: double _r2 = _r_d1 * clad::pop(_t3); -// CHECK-NEXT: double _r3 = _r2 * clad::pop(_t4); -// CHECK-NEXT: _d_x += _r3; -// CHECK-NEXT: double _r4 = clad::pop(_t5) * _r2; -// CHECK-NEXT: _d_x += _r4; -// CHECK-NEXT: double _r5 = clad::pop(_t6) * _r_d1; -// CHECK-NEXT: _d_interval += _r5; -// CHECK-NEXT: _d_sum -= _r_d1; -// CHECK-NEXT: } +// 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: _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: _d_interval += _r5; +// CHECK-NEXT: _d_sum -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: * _d_lower += _d_x; @@ -1591,7 +1721,7 @@ double f_loop_init_var(double lower, double upper) { // CHECK-NEXT: double _r0 = _d_interval / _t0; // CHECK-NEXT: * _d_upper += _r0; // CHECK-NEXT: * _d_lower += -_r0; -// CHECK-NEXT: double _r1 = _d_interval * -_t1 / (_t0 * _t0); +// CHECK-NEXT: double _r1 = _d_interval * -(upper - lower) / (_t0 * _t0); // CHECK-NEXT: _d_num_points += _r1; // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/Gradient/MemberFunctions.C b/test/Gradient/MemberFunctions.C index 950889531..4b78f33ae 100644 --- a/test/Gradient/MemberFunctions.C +++ b/test/Gradient/MemberFunctions.C @@ -1,9 +1,17 @@ // RUN: %cladclang %s -fno-exceptions -I%S/../../include -oMemberFunctions.out 2>&1 | FileCheck %s // RUN: ./MemberFunctions.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -fno-exceptions -I%S/../../include -oMemberFunctions.out +// RUN: ./MemberFunctions.out | FileCheck -check-prefix=CHECK-EXEC %s + // RUN: %cladclang -std=c++14 %s -fno-exceptions -I%S/../../include -oMemberFunctions-cpp14.out 2>&1 | FileCheck %s // RUN: ./MemberFunctions-cpp14.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr -std=c++14 %s -fno-exceptions -I%S/../../include -oMemberFunctions-cpp14.out +// RUN: ./MemberFunctions-cpp14.out | FileCheck -check-prefix=CHECK-EXEC %s + // RUN: %cladclang -std=c++17 %s -fno-exceptions -I%S/../../include -oMemberFunctions-cpp17.out 2>&1 | FileCheck %s // RUN: ./MemberFunctions-cpp17.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr -std=c++17 %s -fno-exceptions -I%S/../../include -oMemberFunctions-cpp17.out +// RUN: ./MemberFunctions-cpp17.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -17,23 +25,19 @@ public: // 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -43,23 +47,19 @@ public: // 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -71,23 +71,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -99,23 +95,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -125,23 +117,19 @@ public: // 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -153,23 +141,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -181,23 +165,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -209,23 +189,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -235,23 +211,19 @@ public: // 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -263,23 +235,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -291,23 +259,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -319,23 +283,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -347,23 +307,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -375,23 +331,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -403,23 +355,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -431,23 +379,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -459,23 +403,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -487,23 +427,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -515,23 +451,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -543,23 +475,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -571,23 +499,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -599,23 +523,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -627,23 +547,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -655,23 +571,19 @@ 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: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -682,23 +594,19 @@ public: // CHECK-NEXT: double _d_j = 0; // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; - // CHECK-NEXT: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -751,11 +659,7 @@ 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: double _t2; -// CHECK-NEXT: double _t3; -// CHECK-NEXT: _t2 = i; // CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t3 = _t2 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: @@ -763,9 +667,9 @@ double fn(double i,double j) { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: double _r1 = _r0 * _t1; // CHECK-NEXT: * _d_i += _r1; -// CHECK-NEXT: double _r2 = _t2 * _r0; +// CHECK-NEXT: double _r2 = i * _r0; // CHECK-NEXT: * _d_i += _r2; -// CHECK-NEXT: double _r3 = _t3 * 1; +// CHECK-NEXT: double _r3 = i * _t1 * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -775,17 +679,23 @@ double fn2(SimpleFunctions& sf, double i) { } // CHECK: void ref_mem_fn_pullback(double i, double _d_y, clad::array_ref _d_this, clad::array_ref _d_i) { +// CHECK-NEXT: double _t0; +// CHECK-NEXT: double _t1; +// CHECK-NEXT: _t0 = this->x; // CHECK-NEXT: this->x = +i; +// CHECK-NEXT: _t1 = this->x; // CHECK-NEXT: this->x = -i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: (* _d_this).x += _d_y; // CHECK-NEXT: { +// CHECK-NEXT: this->x = _t1; // CHECK-NEXT: double _r_d1 = (* _d_this).x; // CHECK-NEXT: * _d_i += -_r_d1; // CHECK-NEXT: (* _d_this).x -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: this->x = _t0; // CHECK-NEXT: double _r_d0 = (* _d_this).x; // CHECK-NEXT: * _d_i += _r_d0; // CHECK-NEXT: (* _d_this).x -= _r_d0; @@ -793,22 +703,24 @@ double fn2(SimpleFunctions& sf, double i) { // CHECK-NEXT: } // CHECK: clad::ValueAndAdjoint ref_mem_fn_forw(double i, clad::array_ref _d_this, clad::array_ref _d_i) { +// CHECK-NEXT: double _t0; +// CHECK-NEXT: double _t1; +// CHECK-NEXT: _t0 = this->x; // CHECK-NEXT: this->x = +i; +// CHECK-NEXT: _t1 = this->x; // CHECK-NEXT: this->x = -i; // CHECK-NEXT: return {this->x, (* _d_this).x}; // CHECK-NEXT: } // CHECK: void fn2_grad(SimpleFunctions &sf, double i, clad::array_ref _d_sf, clad::array_ref _d_i) { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: SimpleFunctions _t1; -// CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t1 = sf; -// CHECK-NEXT: clad::ValueAndAdjoint _t2 = _t1.ref_mem_fn_forw(_t0, &(* _d_sf), nullptr); +// CHECK-NEXT: SimpleFunctions _t0; +// CHECK-NEXT: _t0 = sf; +// CHECK-NEXT: clad::ValueAndAdjoint _t1 = _t0.ref_mem_fn_forw(i, &(* _d_sf), nullptr); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _grad0 = 0.; -// CHECK-NEXT: _t1.ref_mem_fn_pullback(_t0, 1, &(* _d_sf), &_grad0); +// CHECK-NEXT: _t0.ref_mem_fn_pullback(i, 1, &(* _d_sf), &_grad0); // CHECK-NEXT: double _r0 = _grad0; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: } @@ -825,11 +737,14 @@ double fn5(SimpleFunctions& v, double value) { } // CHECK: void operator_plus_equal_pullback(double value, SimpleFunctions _d_y, clad::array_ref _d_this, clad::array_ref _d_value) { +// CHECK-NEXT: double _t0; +// CHECK-NEXT: _t0 = this->x; // CHECK-NEXT: this->x += value; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: ; // CHECK-NEXT: { +// CHECK-NEXT: this->x = _t0; // CHECK-NEXT: double _r_d0 = (* _d_this).x; // CHECK-NEXT: (* _d_this).x += _r_d0; // CHECK-NEXT: * _d_value += _r_d0; @@ -838,22 +753,22 @@ double fn5(SimpleFunctions& v, double value) { // CHECK-NEXT: } // CHECK: clad::ValueAndAdjoint operator_plus_equal_forw(double value, clad::array_ref _d_this, clad::array_ref _d_value) { +// CHECK-NEXT: double _t0; +// CHECK-NEXT: _t0 = this->x; // CHECK-NEXT: this->x += value; // CHECK-NEXT: return {*this, (* _d_this)}; // CHECK-NEXT: } // CHECK: void fn5_grad(SimpleFunctions &v, double value, clad::array_ref _d_v, clad::array_ref _d_value) { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: SimpleFunctions _t1; -// CHECK-NEXT: _t0 = value; -// CHECK-NEXT: _t1 = v; -// CHECK-NEXT: clad::ValueAndAdjoint _t2 = _t1.operator_plus_equal_forw(_t0, &(* _d_v), nullptr); +// CHECK-NEXT: SimpleFunctions _t0; +// CHECK-NEXT: _t0 = v; +// CHECK-NEXT: clad::ValueAndAdjoint _t1 = _t0.operator_plus_equal_forw(value, &(* _d_v), nullptr); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: (* _d_v).x += 1; // CHECK-NEXT: { // CHECK-NEXT: double _grad0 = 0.; -// CHECK-NEXT: _t1.operator_plus_equal_pullback(_t0, {}, &(* _d_v), &_grad0); +// CHECK-NEXT: _t0.operator_plus_equal_pullback(value, {}, &(* _d_v), &_grad0); // CHECK-NEXT: double _r0 = _grad0; // CHECK-NEXT: * _d_value += _r0; // CHECK-NEXT: } @@ -865,11 +780,14 @@ double fn4(SimpleFunctions& v) { } // CHECK: void operator_plus_plus_pullback(SimpleFunctions _d_y, clad::array_ref _d_this) { +// CHECK-NEXT: double _t0; +// CHECK-NEXT: _t0 = this->x; // CHECK-NEXT: this->x += 1.; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: ; // CHECK-NEXT: { +// CHECK-NEXT: this->x = _t0; // CHECK-NEXT: double _r_d0 = (* _d_this).x; // CHECK-NEXT: (* _d_this).x += _r_d0; // CHECK-NEXT: (* _d_this).x -= _r_d0; @@ -877,6 +795,8 @@ double fn4(SimpleFunctions& v) { // CHECK-NEXT: } // CHECK: clad::ValueAndAdjoint operator_plus_plus_forw(clad::array_ref _d_this) { +// CHECK-NEXT: double _t0; +// CHECK-NEXT: _t0 = this->x; // CHECK-NEXT: this->x += 1.; // CHECK-NEXT: return {*this, (* _d_this)}; // CHECK-NEXT: } @@ -946,23 +866,19 @@ int main() { // CHECK-NEXT: double _d_j = 0; // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; - // CHECK-NEXT: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; - // CHECK-NEXT: _label0: + // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: * _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -973,23 +889,19 @@ int main() { // CHECK-NEXT: double _d_i = 0; // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; - // CHECK-NEXT: double _t2; - // CHECK-NEXT: double _t3; - // CHECK-NEXT: _t1 = (this->x + this->y); // CHECK-NEXT: _t0 = i; - // CHECK-NEXT: _t3 = i; - // CHECK-NEXT: _t2 = j; + // CHECK-NEXT: _t1 = j; // CHECK-NEXT: goto _label0; - // CHECK-NEXT: _label0: + // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: (* _d_this).x += _r0; // CHECK-NEXT: (* _d_this).y += _r0; - // CHECK-NEXT: double _r1 = _t1 * 1; + // CHECK-NEXT: double _r1 = (this->x + this->y) * 1; // CHECK-NEXT: _d_i += _r1; - // CHECK-NEXT: double _r2 = 1 * _t2; + // CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: _d_i += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: * _d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -1003,19 +915,15 @@ int main() { // CHECK-NEXT: double _d_x = 0; // CHECK-NEXT: double _d_y = 0; // CHECK-NEXT: SimpleFunctions _d_sf({}); -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: SimpleFunctions _t2; +// CHECK-NEXT: SimpleFunctions _t0; // CHECK-NEXT: SimpleFunctions sf(x, y); -// CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t1 = j; -// CHECK-NEXT: _t2 = sf; +// CHECK-NEXT: _t0 = sf; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _grad0 = 0.; // CHECK-NEXT: double _grad1 = 0.; -// CHECK-NEXT: _t2.mem_fn_pullback(_t0, _t1, 1, &_d_sf, &_grad0, &_grad1); +// CHECK-NEXT: _t0.mem_fn_pullback(i, j, 1, &_d_sf, &_grad0, &_grad1); // CHECK-NEXT: double _r0 = _grad0; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = _grad1; diff --git a/test/Gradient/Pointers.C b/test/Gradient/Pointers.C index 50701f42e..22ec72a94 100644 --- a/test/Gradient/Pointers.C +++ b/test/Gradient/Pointers.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oPointers.out 2>&1 | FileCheck %s // RUN: ./Pointers.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oPointers.out +// RUN: ./Pointers.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -7,18 +9,15 @@ double nonMemFn(double i) { return i*i; } - // CHECK: void nonMemFn_grad(double i, clad::array_ref _d_i) { // CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: _t1 = i; // CHECK-NEXT: _t0 = i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: * _d_i += _r0; -// CHECK-NEXT: double _r1 = _t1 * 1; +// CHECK-NEXT: double _r1 = i * 1; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/Gradient/TemplateFunctors.C b/test/Gradient/TemplateFunctors.C index a7ede0364..f4b511d2e 100644 --- a/test/Gradient/TemplateFunctors.C +++ b/test/Gradient/TemplateFunctors.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oTemplateFunctors.out 2>&1 | FileCheck %s // RUN: ./TemplateFunctors.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oTemplateFunctors.out +// RUN: ./TemplateFunctors.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -16,28 +18,22 @@ template struct Experiment { // 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 = this->x; // CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t3 = _t2 * _t1; // CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t5 = this->y; -// CHECK-NEXT: _t4 = j; +// 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: (* _d_this).x += _r1; -// CHECK-NEXT: double _r2 = _t2 * _r0; +// CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; -// CHECK-NEXT: double _r3 = _t3 * 1; +// CHECK-NEXT: double _r3 = this->x * _t1 * 1; // CHECK-NEXT: * _d_i += _r3; -// CHECK-NEXT: double _r4 = 1 * _t4; +// CHECK-NEXT: double _r4 = 1 * _t2; // CHECK-NEXT: (* _d_this).y += _r4; -// CHECK-NEXT: double _r5 = _t5 * 1; +// CHECK-NEXT: double _r5 = this->y * 1; // CHECK-NEXT: * _d_j += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -58,21 +54,11 @@ template <> struct Experiment { // 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: long double _t9; -// CHECK-NEXT: _t3 = this->x; // CHECK-NEXT: _t2 = i; -// CHECK-NEXT: _t4 = _t3 * _t2; // CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t5 = _t4 * _t1; // CHECK-NEXT: _t0 = j; -// CHECK-NEXT: _t8 = this->y; -// CHECK-NEXT: _t7 = j; -// CHECK-NEXT: _t9 = _t8 * _t7; -// CHECK-NEXT: _t6 = i; +// CHECK-NEXT: _t4 = j; +// CHECK-NEXT: _t3 = i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { @@ -80,18 +66,18 @@ template <> struct Experiment { // CHECK-NEXT: long double _r1 = _r0 * _t1; // CHECK-NEXT: long double _r2 = _r1 * _t2; // CHECK-NEXT: (* _d_this).x += _r2; -// CHECK-NEXT: long double _r3 = _t3 * _r1; +// CHECK-NEXT: long double _r3 = this->x * _r1; // CHECK-NEXT: * _d_i += _r3; -// CHECK-NEXT: long double _r4 = _t4 * _r0; +// CHECK-NEXT: long double _r4 = this->x * _t2 * _r0; // CHECK-NEXT: * _d_i += _r4; -// CHECK-NEXT: long double _r5 = _t5 * 1; +// CHECK-NEXT: long double _r5 = this->x * _t2 * _t1 * 1; // CHECK-NEXT: * _d_j += _r5; -// CHECK-NEXT: long double _r6 = 1 * _t6; -// CHECK-NEXT: long double _r7 = _r6 * _t7; +// CHECK-NEXT: long double _r6 = 1 * _t3; +// CHECK-NEXT: long double _r7 = _r6 * _t4; // CHECK-NEXT: (* _d_this).y += _r7; -// CHECK-NEXT: long double _r8 = _t8 * _r6; +// CHECK-NEXT: long double _r8 = this->y * _r6; // CHECK-NEXT: * _d_j += _r8; -// CHECK-NEXT: long double _r9 = _t9 * 1; +// CHECK-NEXT: long double _r9 = this->y * _t4 * 1; // CHECK-NEXT: * _d_i += _r9; // CHECK-NEXT: } // CHECK-NEXT: } @@ -107,29 +93,23 @@ 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: volatile double _t2; -// CHECK-NEXT: double _t3; -// CHECK-NEXT: double _t4; -// CHECK-NEXT: volatile double _t5; -// CHECK-NEXT: _t2 = this->x; +// CHECK-NEXT: double _t2; // CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t3 = _t2 * _t1; // CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t5 = this->y; -// CHECK-NEXT: _t4 = j; +// 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: (* _d_this).x += _r1; -// CHECK-NEXT: double _r2 = _t2 * _r0; +// CHECK-NEXT: double _r2 = this->x * _r0; // CHECK-NEXT: * _d_i += _r2; -// CHECK-NEXT: double _r3 = _t3 * 1; +// CHECK-NEXT: double _r3 = this->x * _t1 * 1; // CHECK-NEXT: * _d_i += _r3; -// CHECK-NEXT: double _r4 = 1 * _t4; +// CHECK-NEXT: double _r4 = 1 * _t2; // CHECK-NEXT: (* _d_this).y += _r4; -// CHECK-NEXT: double _r5 = _t5 * 1; +// CHECK-NEXT: double _r5 = this->y * 1; // CHECK-NEXT: * _d_j += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -148,23 +128,13 @@ template <> struct ExperimentConstVolatile { // CHECK-NEXT: long double _t0; // CHECK-NEXT: long double _t1; // CHECK-NEXT: long double _t2; -// CHECK-NEXT: volatile long double _t3; +// 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: volatile long double _t8; -// CHECK-NEXT: long double _t9; -// CHECK-NEXT: _t3 = this->x; // CHECK-NEXT: _t2 = i; -// CHECK-NEXT: _t4 = _t3 * _t2; // CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t5 = _t4 * _t1; // CHECK-NEXT: _t0 = j; -// CHECK-NEXT: _t8 = this->y; -// CHECK-NEXT: _t7 = j; -// CHECK-NEXT: _t9 = _t8 * _t7; -// CHECK-NEXT: _t6 = i; +// CHECK-NEXT: _t4 = j; +// CHECK-NEXT: _t3 = i; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { @@ -172,18 +142,18 @@ template <> struct ExperimentConstVolatile { // CHECK-NEXT: long double _r1 = _r0 * _t1; // CHECK-NEXT: long double _r2 = _r1 * _t2; // CHECK-NEXT: (* _d_this).x += _r2; -// CHECK-NEXT: long double _r3 = _t3 * _r1; +// CHECK-NEXT: long double _r3 = this->x * _r1; // CHECK-NEXT: * _d_i += _r3; -// CHECK-NEXT: long double _r4 = _t4 * _r0; +// CHECK-NEXT: long double _r4 = this->x * _t2 * _r0; // CHECK-NEXT: * _d_i += _r4; -// CHECK-NEXT: long double _r5 = _t5 * 1; +// CHECK-NEXT: long double _r5 = this->x * _t2 * _t1 * 1; // CHECK-NEXT: * _d_j += _r5; -// CHECK-NEXT: long double _r6 = 1 * _t6; -// CHECK-NEXT: long double _r7 = _r6 * _t7; +// CHECK-NEXT: long double _r6 = 1 * _t3; +// CHECK-NEXT: long double _r7 = _r6 * _t4; // CHECK-NEXT: (* _d_this).y += _r7; -// CHECK-NEXT: long double _r8 = _t8 * _r6; +// CHECK-NEXT: long double _r8 = this->y * _r6; // CHECK-NEXT: * _d_j += _r8; -// CHECK-NEXT: long double _r9 = _t9 * 1; +// CHECK-NEXT: long double _r9 = this->y * _t4 * 1; // CHECK-NEXT: * _d_i += _r9; // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/Gradient/TestAgainstDiff.C b/test/Gradient/TestAgainstDiff.C index 4c6445725..99fe2234d 100644 --- a/test/Gradient/TestAgainstDiff.C +++ b/test/Gradient/TestAgainstDiff.C @@ -1,6 +1,8 @@ // RUN: %cladclang %s -I%S/../../include -oTestAgainstDiff.out 2>&1 | FileCheck %s // RUN: ./TestAgainstDiff.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oTestAgainstDiff.out +// RUN: ./TestAgainstDiff.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Gradient/TestTypeConversion.C b/test/Gradient/TestTypeConversion.C index d821e2742..d51630880 100644 --- a/test/Gradient/TestTypeConversion.C +++ b/test/Gradient/TestTypeConversion.C @@ -1,5 +1,7 @@ // RUN: %cladnumdiffclang %s -I%S/../../include -oTestTypeConversion.out 2>&1 | FileCheck %s // RUN: ./TestTypeConversion.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladnumdiffclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oTestTypeConversion.out +// RUN: ./TestTypeConversion.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -19,22 +21,25 @@ void fn_type_conversion_grad(float z, int a, clad::array_ref _d_z, clad:: // CHECK: void fn_type_conversion_grad(float z, int a, clad::array_ref _d_z, clad::array_ref _d_a) { // 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: clad::tape _t2 = {}; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: for (int i = 1; i < a; i++) { // CHECK-NEXT: _t0++; -// CHECK-NEXT: z = clad::push(_t2, z) * clad::push(_t1, a); +// CHECK-NEXT: clad::push(_t1, z); +// CHECK-NEXT: z = z * clad::push(_t2, a); // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: * _d_z += 1; // CHECK-NEXT: for (; _t0; _t0--) { +// CHECK-NEXT: i--; // CHECK-NEXT: { +// CHECK-NEXT: z = clad::pop(_t1); // CHECK-NEXT: float _r_d0 = * _d_z; -// CHECK-NEXT: float _r0 = _r_d0 * clad::pop(_t1); +// CHECK-NEXT: float _r0 = _r_d0 * clad::pop(_t2); // CHECK-NEXT: * _d_z += _r0; -// CHECK-NEXT: float _r1 = clad::pop(_t2) * _r_d0; +// CHECK-NEXT: float _r1 = z * _r_d0; // CHECK-NEXT: * _d_a += _r1; // CHECK-NEXT: * _d_z -= _r_d0; // CHECK-NEXT: * _d_z; diff --git a/test/Gradient/UserDefinedTypes.C b/test/Gradient/UserDefinedTypes.C index d10b41857..acfca8ae6 100644 --- a/test/Gradient/UserDefinedTypes.C +++ b/test/Gradient/UserDefinedTypes.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oUserDefinedTypes.out 2>&1 | FileCheck %s // RUN: ./UserDefinedTypes.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oUserDefinedTypes.out +// RUN: ./UserDefinedTypes.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -65,21 +67,23 @@ double sum(Tangent& t) { // CHECK-NEXT: double _d_res = 0; // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: int _d_i = 0; -// CHECK-NEXT: clad::tape _t1 = {}; +// CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: double res = 0; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: for (int i = 0; i < 5; ++i) { // CHECK-NEXT: _t0++; -// CHECK-NEXT: res += t.data[clad::push(_t1, i)]; +// CHECK-NEXT: clad::push(_t1, res); +// CHECK-NEXT: res += t.data[i]; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += _d_y; // CHECK-NEXT: for (; _t0; _t0--) { +// CHECK-NEXT: --i; +// CHECK-NEXT: res = clad::pop(_t1); // CHECK-NEXT: double _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; -// CHECK-NEXT: int _t2 = clad::pop(_t1); -// CHECK-NEXT: (* _d_t).data[_t2] += _r_d0; +// CHECK-NEXT: (* _d_t).data[i] += _r_d0; // CHECK-NEXT: _d_res -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: } @@ -95,21 +99,23 @@ double sum(double *data) { // CHECK-NEXT: double _d_res = 0; // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: int _d_i = 0; -// CHECK-NEXT: clad::tape _t1 = {}; +// CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: double res = 0; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: for (int i = 0; i < 5; ++i) { // CHECK-NEXT: _t0++; -// CHECK-NEXT: res += data[clad::push(_t1, i)]; +// CHECK-NEXT: clad::push(_t1, res); +// CHECK-NEXT: res += data[i]; // CHECK-NEXT: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += _d_y; // CHECK-NEXT: for (; _t0; _t0--) { +// CHECK-NEXT: --i; +// CHECK-NEXT: res = clad::pop(_t1); // CHECK-NEXT: double _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; -// CHECK-NEXT: int _t2 = clad::pop(_t1); -// CHECK-NEXT: _d_data[_t2] += _r_d0; +// CHECK-NEXT: _d_data[i] += _r_d0; // CHECK-NEXT: _d_res -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: } @@ -123,21 +129,22 @@ double fn2(Tangent t, double i) { // CHECK: void fn2_grad(Tangent t, double i, clad::array_ref _d_t, clad::array_ref _d_i) { // CHECK-NEXT: Tangent _t0; // CHECK-NEXT: double _d_res = 0; -// CHECK-NEXT: clad::array _t1(5UL); +// CHECK-NEXT: double _t1; // CHECK-NEXT: double _t3; // CHECK-NEXT: _t0 = t; // CHECK-NEXT: double res = sum(t); -// CHECK-NEXT: _t1 = t.data; +// CHECK-NEXT: _t1 = res; // CHECK-NEXT: _t3 = t.data[0]; // CHECK-NEXT: res += sum(t.data) + i + 2 * _t3; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += 1; // CHECK-NEXT: { +// CHECK-NEXT: res = _t1; // CHECK-NEXT: double _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; // CHECK-NEXT: clad::array_ref _t2 = {(* _d_t).data, 5UL}; -// CHECK-NEXT: sum_pullback(_t1, _r_d0, _t2); +// 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; @@ -146,6 +153,7 @@ double fn2(Tangent t, double i) { // CHECK-NEXT: _d_res -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: t = _t0; // CHECK-NEXT: sum_pullback(_t0, _d_res, &(* _d_t)); // CHECK-NEXT: Tangent _r0 = (* _d_t); // CHECK-NEXT: } @@ -163,33 +171,40 @@ double fn3(double i, double j) { // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; // CHECK-NEXT: double _t2; -// CHECK-NEXT: Tangent _t3; +// CHECK-NEXT: double _t3; +// CHECK-NEXT: double _t4; +// CHECK-NEXT: Tangent _t5; // CHECK-NEXT: Tangent t; -// CHECK-NEXT: _t0 = i; -// CHECK-NEXT: t.data[0] = 2 * _t0; +// CHECK-NEXT: _t0 = t.data[0]; // CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t2 = j; -// CHECK-NEXT: t.data[1] = 5 * _t1 + 3 * _t2; -// CHECK-NEXT: _t3 = t; +// 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: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: sum_pullback(_t3, 1, &_d_t); +// CHECK-NEXT: t = _t5; +// CHECK-NEXT: sum_pullback(_t5, 1, &_d_t); // CHECK-NEXT: Tangent _r6 = _d_t; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: t.data[1] = _t2; // CHECK-NEXT: double _r_d1 = _d_t.data[1]; -// CHECK-NEXT: double _r2 = _r_d1 * _t1; +// CHECK-NEXT: double _r2 = _r_d1 * _t3; // CHECK-NEXT: double _r3 = 5 * _r_d1; // CHECK-NEXT: * _d_i += _r3; -// CHECK-NEXT: double _r4 = _r_d1 * _t2; +// CHECK-NEXT: double _r4 = _r_d1 * _t4; // CHECK-NEXT: double _r5 = 3 * _r_d1; // CHECK-NEXT: * _d_j += _r5; // CHECK-NEXT: _d_t.data[1] -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: { +// CHECK-NEXT: t.data[0] = _t0; // CHECK-NEXT: double _r_d0 = _d_t.data[0]; -// CHECK-NEXT: double _r0 = _r_d0 * _t0; +// CHECK-NEXT: double _r0 = _r_d0 * _t1; // CHECK-NEXT: double _r1 = 2 * _r_d0; // CHECK-NEXT: * _d_i += _r1; // CHECK-NEXT: _d_t.data[0] -= _r_d0; @@ -209,38 +224,30 @@ double fn4(double i, double j) { // 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: pairdd p(1, 3); // CHECK-NEXT: pairdd q({7, 5}); -// CHECK-NEXT: _t1 = p.first; // CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t3 = p.second; -// CHECK-NEXT: _t2 = j; -// CHECK-NEXT: _t5 = q.first; -// CHECK-NEXT: _t4 = i; -// CHECK-NEXT: _t7 = q.second; -// CHECK-NEXT: _t6 = j; +// 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: _d_p.first += _r0; -// CHECK-NEXT: double _r1 = _t1 * 1; +// CHECK-NEXT: double _r1 = p.first * 1; // CHECK-NEXT: * _d_i += _r1; -// CHECK-NEXT: double _r2 = 1 * _t2; +// CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: _d_p.second += _r2; -// CHECK-NEXT: double _r3 = _t3 * 1; +// CHECK-NEXT: double _r3 = p.second * 1; // CHECK-NEXT: * _d_j += _r3; -// CHECK-NEXT: double _r4 = 1 * _t4; +// CHECK-NEXT: double _r4 = 1 * _t2; // CHECK-NEXT: _d_q.first += _r4; -// CHECK-NEXT: double _r5 = _t5 * 1; +// CHECK-NEXT: double _r5 = q.first * 1; // CHECK-NEXT: * _d_i += _r5; -// CHECK-NEXT: double _r6 = 1 * _t6; +// CHECK-NEXT: double _r6 = 1 * _t3; // CHECK-NEXT: _d_q.second += _r6; -// CHECK-NEXT: double _r7 = _t7 * 1; +// CHECK-NEXT: double _r7 = q.second * 1; // CHECK-NEXT: * _d_j += _r7; // CHECK-NEXT: } // CHECK-NEXT: } @@ -250,33 +257,27 @@ double fn4(double i, double j) { // 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: _t1 = this->data[0]; // CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t3 = this->data[1]; -// CHECK-NEXT: _t2 = j; -// CHECK-NEXT: _t4 = this->data[2]; -// CHECK-NEXT: _t6 = this->data[3]; -// CHECK-NEXT: _t5 = this->data[4]; +// 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: (* _d_this).data[0] += _r0; -// CHECK-NEXT: double _r1 = _t1 * 1; +// CHECK-NEXT: double _r1 = this->data[0] * 1; // CHECK-NEXT: * _d_i += _r1; -// CHECK-NEXT: double _r2 = 1 * _t2; +// CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: (* _d_this).data[1] += _r2; -// CHECK-NEXT: double _r3 = _t3 * 1; +// CHECK-NEXT: double _r3 = this->data[1] * 1; // CHECK-NEXT: * _d_j += _r3; -// CHECK-NEXT: double _r4 = 1 * _t4; +// CHECK-NEXT: double _r4 = 1 * _t2; // CHECK-NEXT: double _r5 = 3 * 1; // CHECK-NEXT: (* _d_this).data[2] += _r5; -// CHECK-NEXT: double _r6 = 1 * _t5; +// CHECK-NEXT: double _r6 = 1 * _t3; // CHECK-NEXT: (* _d_this).data[3] += _r6; -// CHECK-NEXT: double _r7 = _t6 * 1; +// CHECK-NEXT: double _r7 = this->data[3] * 1; // CHECK-NEXT: (* _d_this).data[4] += _r7; // CHECK-NEXT: } // CHECK-NEXT: } @@ -289,45 +290,35 @@ double fn5(const Tangent& t, double i) { // 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: _t1 = this->data[0]; // CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t4 = this->data[1]; -// CHECK-NEXT: _t3 = i; -// CHECK-NEXT: _t5 = _t4 * _t3; -// CHECK-NEXT: _t2 = j; +// 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: (* _d_this).data[0] += _r0; -// CHECK-NEXT: double _r1 = _t1 * _d_y; +// CHECK-NEXT: double _r1 = this->data[0] * _d_y; // CHECK-NEXT: * _d_i += _r1; -// CHECK-NEXT: double _r2 = _d_y * _t2; -// CHECK-NEXT: double _r3 = _r2 * _t3; +// CHECK-NEXT: double _r2 = _d_y * _t1; +// CHECK-NEXT: double _r3 = _r2 * _t2; // CHECK-NEXT: (* _d_this).data[1] += _r3; -// CHECK-NEXT: double _r4 = _t4 * _r2; +// CHECK-NEXT: double _r4 = this->data[1] * _r2; // CHECK-NEXT: * _d_i += _r4; -// CHECK-NEXT: double _r5 = _t5 * _d_y; +// CHECK-NEXT: double _r5 = this->data[1] * _t2 * _d_y; // CHECK-NEXT: * _d_j += _r5; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK: void fn5_grad(const Tangent &t, double i, clad::array_ref _d_t, clad::array_ref _d_i) { -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: Tangent _t2; -// CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t2 = t; +// CHECK-NEXT: Tangent _t0; +// CHECK-NEXT: _t0 = t; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _grad0 = 0.; // CHECK-NEXT: double _grad1 = 0.; -// CHECK-NEXT: _t2.someMemFn2_pullback(_t0, _t1, 1, &(* _d_t), &_grad0, &_grad1); +// CHECK-NEXT: _t0.someMemFn2_pullback(i, i, 1, &(* _d_t), &_grad0, &_grad1); // CHECK-NEXT: double _r0 = _grad0; // CHECK-NEXT: * _d_i += _r0; // CHECK-NEXT: double _r1 = _grad1; @@ -344,8 +335,11 @@ double fn6(dcomplex c, double i) { return res; } // CHECK: void real_pullback({{.*}} [[__val:.*]], clad::array_ref > _d_this, clad::array_ref<{{.*}}> [[_d___val:[a-zA-Z_]*]]){{.*}} { +// CHECK-NEXT: double _t0; +// CHECK-NEXT: _t0 ={{(__real)?}} this->[[_M_value:.*]]; // CHECK-NEXT: {{(__real)?}} this->[[_M_value:.*]] = [[__val]]; // CHECK-NEXT: { +// CHECK-NEXT: {{(__real)?}} this->[[_M_value:.*]] = _t0; // CHECK-NEXT: double _r_d0 ={{( __real)?}} (* _d_this).[[_M_value]]; // CHECK-NEXT: * [[_d___val]] += _r_d0; // CHECK-NEXT: {{(__real)?}} (* _d_this).[[_M_value]] -= _r_d0; @@ -366,24 +360,24 @@ double fn6(dcomplex c, double i) { // CHECK: void fn6_grad(dcomplex c, double i, clad::array_ref _d_c, clad::array_ref _d_i) { // CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: dcomplex _t2; -// CHECK-NEXT: dcomplex _t3; -// CHECK-NEXT: double _t4; -// CHECK-NEXT: dcomplex _t5; -// CHECK-NEXT: double _t6; +// CHECK-NEXT: std{{(::__1)?}}::dcomplex _t1; +// CHECK-NEXT: std{{(::__1)?}}::dcomplex _t2; +// CHECK-NEXT: double _t3; +// CHECK-NEXT: std{{(::__1)?}}::dcomplex _t4; +// CHECK-NEXT: double _t5; // CHECK-NEXT: double _d_res = 0; +// CHECK-NEXT: double _t6; // CHECK-NEXT: double _t7; -// CHECK-NEXT: dcomplex _t8; +// CHECK-NEXT: std{{(::__1)?}}::dcomplex _t8; // CHECK-NEXT: _t0 = i; -// CHECK-NEXT: _t1 = 5 * _t0; +// CHECK-NEXT: _t1 = c; +// CHECK-NEXT: c.real(5 * _t0); // CHECK-NEXT: _t2 = c; -// CHECK-NEXT: c.real(_t1); -// CHECK-NEXT: _t3 = c; -// CHECK-NEXT: _t5 = c; -// CHECK-NEXT: _t4 = c.imag(); -// CHECK-NEXT: _t6 = i; -// CHECK-NEXT: double res = c.real() + 3 * _t4 + 6 * _t6; +// 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; @@ -391,6 +385,7 @@ double fn6(dcomplex c, double i) { // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += 1; // CHECK-NEXT: { +// CHECK-NEXT: res = _t6; // CHECK-NEXT: double _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; // CHECK-NEXT: double _r7 = _r_d0 * _t7; @@ -399,17 +394,17 @@ double fn6(dcomplex c, double i) { // CHECK-NEXT: _d_res -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: _t3.real_pullback(_d_res, &(* _d_c)); -// CHECK-NEXT: double _r3 = _d_res * _t4; +// CHECK-NEXT: _t2.real_pullback(_d_res, &(* _d_c)); +// CHECK-NEXT: double _r3 = _d_res * _t3; // CHECK-NEXT: double _r4 = 3 * _d_res; -// CHECK-NEXT: _t5.imag_pullback(_r4, &(* _d_c)); -// CHECK-NEXT: double _r5 = _d_res * _t6; +// CHECK-NEXT: _t4.imag_pullback(_r4, &(* _d_c)); +// CHECK-NEXT: double _r5 = _d_res * _t5; // CHECK-NEXT: double _r6 = 6 * _d_res; // CHECK-NEXT: * _d_i += _r6; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: {{.*}} _grad0 = 0.; -// CHECK-NEXT: _t2.real_pullback(_t1, &(* _d_c), &_grad0); +// CHECK-NEXT: std::complex::value_type _grad0 = 0.; +// CHECK-NEXT: _t1.real_pullback(5 * _t0, &(* _d_c), &_grad0); // CHECK-NEXT: double _r0 = _grad0; // CHECK-NEXT: double _r1 = _r0 * _t0; // CHECK-NEXT: double _r2 = 5 * _r0; @@ -423,34 +418,32 @@ double fn7(dcomplex c1, dcomplex c2) { } // CHECK: void fn7_grad(dcomplex c1, dcomplex c2, clad::array_ref _d_c1, clad::array_ref _d_c2) { -// CHECK-NEXT: dcomplex _t0; +// CHECK-NEXT: std{{(::__1)?}}::dcomplex _t0; // CHECK-NEXT: double _t1; -// CHECK-NEXT: dcomplex _t2; -// CHECK-NEXT: double _t3; -// CHECK-NEXT: dcomplex _t4; -// CHECK-NEXT: dcomplex _t5; -// CHECK-NEXT: double _t6; -// CHECK-NEXT: dcomplex _t7; +// CHECK-NEXT: std{{(::__1)?}}::dcomplex _t2; +// CHECK-NEXT: std{{(::__1)?}}::dcomplex _t3; +// CHECK-NEXT: std{{(::__1)?}}::dcomplex _t4; +// CHECK-NEXT: double _t5; +// CHECK-NEXT: std{{(::__1)?}}::dcomplex _t6; // CHECK-NEXT: _t0 = c2; // CHECK-NEXT: _t2 = c2; // CHECK-NEXT: _t1 = c2.real(); -// CHECK-NEXT: _t3 = c2.imag() + 5 * _t1; +// CHECK-NEXT: _t3 = c1; +// CHECK-NEXT: c1.real(c2.imag() + 5 * _t1); // CHECK-NEXT: _t4 = c1; -// CHECK-NEXT: c1.real(_t3); -// CHECK-NEXT: _t5 = c1; -// CHECK-NEXT: _t7 = c1; -// CHECK-NEXT: _t6 = c1.imag(); +// CHECK-NEXT: _t6 = c1; +// CHECK-NEXT: _t5 = c1.imag(); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: _t5.real_pullback(1, &(* _d_c1)); -// CHECK-NEXT: double _r3 = 1 * _t6; +// CHECK-NEXT: _t4.real_pullback(1, &(* _d_c1)); +// CHECK-NEXT: double _r3 = 1 * _t5; // CHECK-NEXT: double _r4 = 3 * 1; -// CHECK-NEXT: _t7.imag_pullback(_r4, &(* _d_c1)); +// CHECK-NEXT: _t6.imag_pullback(_r4, &(* _d_c1)); // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: {{.*}} _grad0 = 0.; -// CHECK-NEXT: _t4.real_pullback(_t3, &(* _d_c1), &_grad0); +// CHECK-NEXT: _t3.real_pullback(c2.imag() + 5 * _t1, &(* _d_c1), &_grad0); // CHECK-NEXT: double _r0 = _grad0; // CHECK-NEXT: _t0.imag_pullback(_r0, &(* _d_c2)); // CHECK-NEXT: double _r1 = _r0 * _t1; @@ -467,39 +460,40 @@ double fn8(Tangent t, dcomplex c) { // CHECK: void updateTo_pullback(double d, clad::array_ref _d_this, clad::array_ref _d_d) { // CHECK-NEXT: unsigned long _t0; // CHECK-NEXT: int _d_i = 0; -// CHECK-NEXT: clad::tape _t1 = {}; +// CHECK-NEXT: clad::tape _t1 = {}; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: for (int i = 0; i < 5; ++i) { // CHECK-NEXT: _t0++; -// CHECK-NEXT: this->data[clad::push(_t1, i)] = d; +// CHECK-NEXT: clad::push(_t1, this->data[i]); +// CHECK-NEXT: this->data[i] = d; // CHECK-NEXT: } // CHECK-NEXT: for (; _t0; _t0--) { -// CHECK-NEXT: int _t2 = clad::pop(_t1); -// CHECK-NEXT: double _r_d0 = (* _d_this).data[_t2]; +// CHECK-NEXT: --i; +// CHECK-NEXT: this->data[i] = clad::pop(_t1); +// CHECK-NEXT: double _r_d0 = (* _d_this).data[i]; // CHECK-NEXT: * _d_d += _r_d0; -// CHECK-NEXT: (* _d_this).data[_t2] -= _r_d0; +// CHECK-NEXT: (* _d_this).data[i] -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK: void fn8_grad(Tangent t, dcomplex c, clad::array_ref _d_t, clad::array_ref _d_c) { -// CHECK-NEXT: dcomplex _t0; -// CHECK-NEXT: double _t1; +// CHECK-NEXT: std{{(::__1)?}}::dcomplex _t0; +// CHECK-NEXT: Tangent _t1; // CHECK-NEXT: Tangent _t2; -// CHECK-NEXT: Tangent _t3; // CHECK-NEXT: _t0 = c; -// CHECK-NEXT: _t1 = c.real(); +// CHECK-NEXT: _t1 = t; +// CHECK-NEXT: t.updateTo(c.real()); // CHECK-NEXT: _t2 = t; -// CHECK-NEXT: t.updateTo(_t1); -// CHECK-NEXT: _t3 = t; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { -// CHECK-NEXT: sum_pullback(_t3, 1, &(* _d_t)); +// CHECK-NEXT: t = _t2; +// CHECK-NEXT: sum_pullback(_t2, 1, &(* _d_t)); // CHECK-NEXT: Tangent _r1 = (* _d_t); // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: double _grad0 = 0.; -// CHECK-NEXT: _t2.updateTo_pullback(_t1, &(* _d_t), &_grad0); +// CHECK-NEXT: _t1.updateTo_pullback(c.real(), &(* _d_t), &_grad0); // CHECK-NEXT: double _r0 = _grad0; // CHECK-NEXT: _t0.real_pullback(_r0, &(* _d_c)); // CHECK-NEXT: } @@ -518,39 +512,47 @@ double fn9(Tangent t, dcomplex c) { // CHECK-NEXT: double _d_res = 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 _t3 = {}; -// CHECK-NEXT: Tangent _t4; +// CHECK-NEXT: clad::tape _t1 = {}; +// CHECK-NEXT: clad::tape _t2 = {}; +// CHECK-NEXT: clad::tape _t3 = {}; +// CHECK-NEXT: clad::tape _t4 = {}; +// CHECK-NEXT: double _t5; +// CHECK-NEXT: Tangent _t6; // CHECK-NEXT: double res = 0; // CHECK-NEXT: _t0 = 0; // CHECK-NEXT: for (int i = 0; i < 5; ++i) { // CHECK-NEXT: _t0++; -// CHECK-NEXT: clad::push(_t1, c); -// CHECK-NEXT: clad::push(_t3, c); -// CHECK-NEXT: res += c.real() + 2 * clad::push(_t2, c.imag()); +// CHECK-NEXT: clad::push(_t1, res); +// CHECK-NEXT: clad::push(_t2, c); +// CHECK-NEXT: clad::push(_t4, c); +// CHECK-NEXT: res += c.real() + 2 * clad::push(_t3, c.imag()); // CHECK-NEXT: } -// CHECK-NEXT: _t4 = t; +// CHECK-NEXT: _t5 = res; +// CHECK-NEXT: _t6 = t; // CHECK-NEXT: res += sum(t); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d_res += 1; // CHECK-NEXT: { +// CHECK-NEXT: res = _t5; // CHECK-NEXT: double _r_d1 = _d_res; // CHECK-NEXT: _d_res += _r_d1; -// CHECK-NEXT: sum_pullback(_t4, _r_d1, &(* _d_t)); +// CHECK-NEXT: t = _t6; +// CHECK-NEXT: sum_pullback(_t6, _r_d1, &(* _d_t)); // CHECK-NEXT: Tangent _r4 = (* _d_t); // CHECK-NEXT: _d_res -= _r_d1; // CHECK-NEXT: } // CHECK-NEXT: for (; _t0; _t0--) { +// CHECK-NEXT: --i; // CHECK-NEXT: { +// CHECK-NEXT: res = clad::pop(_t1); // CHECK-NEXT: double _r_d0 = _d_res; // CHECK-NEXT: _d_res += _r_d0; -// CHECK-NEXT: std{{(::__1)?}}::complex _r0 = clad::pop(_t1); +// CHECK-NEXT: std{{(::__1)?}}::complex _r0 = clad::pop(_t2); // CHECK-NEXT: _r0.real_pullback(_r_d0, &(* _d_c)); -// CHECK-NEXT: double _r1 = _r_d0 * clad::pop(_t2); +// CHECK-NEXT: double _r1 = _r_d0 * clad::pop(_t3); // CHECK-NEXT: double _r2 = 2 * _r_d0; -// CHECK-NEXT: std{{(::__1)?}}::complex _r3 = clad::pop(_t3); +// CHECK-NEXT: std{{(::__1)?}}::complex _r3 = clad::pop(_t4); // CHECK-NEXT: _r3.imag_pullback(_r2, &(* _d_c)); // CHECK-NEXT: _d_res -= _r_d0; // CHECK-NEXT: } diff --git a/test/Gradient/constexprTest.C b/test/Gradient/constexprTest.C index 72c9a46cb..6ca974e39 100644 --- a/test/Gradient/constexprTest.C +++ b/test/Gradient/constexprTest.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oconstexprTest.out | FileCheck %s // RUN: ./constexprTest.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oconstexprTest.out +// RUN: ./constexprTest.out | FileCheck -check-prefix=CHECK-EXEC %s #include "clad/Differentiator/Differentiator.h" @@ -13,14 +15,10 @@ 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 _t2; -//CHECK-NEXT: double _t3; //CHECK-NEXT: double _d_result = 0; -//CHECK-NEXT: _t2 = a; //CHECK-NEXT: _t1 = b; -//CHECK-NEXT: _t3 = _t2 * _t1; //CHECK-NEXT: _t0 = c; -//CHECK-NEXT: double result = _t3 * _t0; +//CHECK-NEXT: double result = a * _t1 * _t0; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_result += 1; @@ -28,12 +26,12 @@ constexpr double mul (double a, double b, double c) { //CHECK-NEXT: double _r0 = _d_result * _t0; //CHECK-NEXT: double _r1 = _r0 * _t1; //CHECK-NEXT: * _d_a += _r1; -//CHECK-NEXT: double _r2 = _t2 * _r0; +//CHECK-NEXT: double _r2 = a * _r0; //CHECK-NEXT: * _d_b += _r2; -//CHECK-NEXT: double _r3 = _t3 * _d_result; +//CHECK-NEXT: double _r3 = a * _t1 * _d_result; //CHECK-NEXT: * _d_c += _r3; //CHECK-NEXT: } -//CHECK-NEXT:} +//CHECK-NEXT: } constexpr double fn( double a, double b, double c) { double val = 98.00; @@ -47,33 +45,30 @@ constexpr double fn( double a, double b, double c) { //CHECK-NEXT: double _t1; //CHECK-NEXT: double _t2; //CHECK-NEXT: double _t3; -//CHECK-NEXT: double _t4; -//CHECK-NEXT: double _t5; //CHECK-NEXT: double _d_result = 0; //CHECK-NEXT: double val = 98.; -//CHECK-NEXT: _t3 = a; -//CHECK-NEXT: _t2 = b; -//CHECK-NEXT: _t4 = _t3 * _t2; -//CHECK-NEXT: _t1 = c; -//CHECK-NEXT: _t5 = _t4 / _t1; -//CHECK-NEXT: _t0 = (a + b); -//CHECK-NEXT: double result = _t5 * _t0 * 100 + c; +//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: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: _d_result += 1; //CHECK-NEXT: { -//CHECK-NEXT: double _r0 = _d_result * 100; -//CHECK-NEXT: double _r1 = _r0 * _t0; -//CHECK-NEXT: double _r2 = _r1 / _t1; -//CHECK-NEXT: double _r3 = _r2 * _t2; +//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: * _d_a += _r3; -//CHECK-NEXT: double _r4 = _t3 * _r2; +//CHECK-NEXT: double _r4 = a * _r2; //CHECK-NEXT: * _d_b += _r4; -//CHECK-NEXT: double _r5 = _r1 * -_t4 / (_t1 * _t1); +//CHECK-NEXT: double _r5 = _r1 * -a * _t3 / (_t2 * _t2); //CHECK-NEXT: * _d_c += _r5; -//CHECK-NEXT: double _r6 = _t5 * _r0; +//CHECK-NEXT: double _r6 = a * _t3 / _t2 * _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/Arrays.C b/test/Hessian/Arrays.C index 592917daf..36182ce7d 100644 --- a/test/Hessian/Arrays.C +++ b/test/Hessian/Arrays.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oArrays.out 2>&1 | FileCheck %s // RUN: ./Arrays.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oArrays.out +// RUN: ./Arrays.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} diff --git a/test/Hessian/BuiltinDerivatives.C b/test/Hessian/BuiltinDerivatives.C index d6a401e94..352ffaefa 100644 --- a/test/Hessian/BuiltinDerivatives.C +++ b/test/Hessian/BuiltinDerivatives.C @@ -1,5 +1,8 @@ // RUN: %cladclang %s -I%S/../../include -oHessianBuiltinDerivatives.out 2>&1 | FileCheck %s // RUN: ./HessianBuiltinDerivatives.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oHessianBuiltinDerivatives.out +// RUN: ./HessianBuiltinDerivatives.out | FileCheck -check-prefix=CHECK-EXEC %s + //CHECK-NOT: {{.*error|warning|note:.*}} @@ -12,29 +15,23 @@ float f1(float x) { // CHECK: float f1_darg0(float x) { // CHECK-NEXT: float _d_x = 1; -// CHECK-NEXT: ValueAndPushforward _t0 = clad::custom_derivatives{{(::std)?}}::sin_pushforward(x, _d_x); -// CHECK-NEXT: ValueAndPushforward _t1 = clad::custom_derivatives{{(::std)?}}::cos_pushforward(x, _d_x); +// CHECK-NEXT: clad::ValueAndPushforward _t0 = clad::custom_derivatives::sin_pushforward(x, _d_x); +// CHECK-NEXT: clad::ValueAndPushforward _t1 = clad::custom_derivatives::cos_pushforward(x, _d_x); // CHECK-NEXT: return _t0.pushforward + _t1.pushforward; // 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: float _t1; -// CHECK-NEXT: float _t2; -// CHECK-NEXT: float _t3; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t2 = x; -// CHECK-NEXT: _t3 = ::std::cos(_t2); -// CHECK-NEXT: _t1 = d_x; +// 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(_t0, 1.F).pushforward; +// CHECK-NEXT: float _r0 = _d_y.value * clad::custom_derivatives::sin_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r0; -// CHECK-NEXT: float _r1 = _d_y.pushforward * _t1; -// CHECK-NEXT: float _r2 = _r1 * clad::custom_derivatives{{(::std)?}}::cos_pushforward(_t2, 1.F).pushforward; +// CHECK-NEXT: float _r1 = _d_y.pushforward * _t0; +// CHECK-NEXT: float _r2 = _r1 * clad::custom_derivatives::cos_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r2; -// CHECK-NEXT: float _r3 = _t3 * _d_y.pushforward; +// CHECK-NEXT: float _r3 = ::std::cos(x) * _d_y.pushforward; // CHECK-NEXT: * _d_d_x += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -42,44 +39,30 @@ 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: float _t2; -// CHECK-NEXT: float _t3; -// CHECK-NEXT: float _t4; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t3 = x; -// CHECK-NEXT: _t2 = ::std::sin(_t3); -// CHECK-NEXT: _t4 = -1 * _t2; -// CHECK-NEXT: _t1 = d_x; +// CHECK-NEXT: _t1 = ::std::sin(x); +// 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)?}}::cos_pushforward(_t0, 1.F).pushforward; +// CHECK-NEXT: float _r0 = _d_y.value * clad::custom_derivatives::cos_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r0; -// CHECK-NEXT: float _r1 = _d_y.pushforward * _t1; -// CHECK-NEXT: float _r2 = _r1 * _t2; +// CHECK-NEXT: float _r1 = _d_y.pushforward * _t0; +// CHECK-NEXT: float _r2 = _r1 * _t1; // CHECK-NEXT: float _r3 = -1 * _r1; -// CHECK-NEXT: float _r4 = _r3 * clad::custom_derivatives{{(::std)?}}::sin_pushforward(_t3, 1.F).pushforward; +// CHECK-NEXT: float _r4 = _r3 * clad::custom_derivatives::sin_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r4; -// CHECK-NEXT: float _r5 = _t4 * _d_y.pushforward; +// CHECK-NEXT: float _r5 = -1 * _t1 * _d_y.pushforward; // CHECK-NEXT: * _d_d_x += _r5; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK: void f1_darg0_grad(float x, clad::array_ref _d_x) { // CHECK-NEXT: float _d__d_x = 0; -// CHECK-NEXT: float _t0; -// CHECK-NEXT: float _t1; -// CHECK-NEXT: ValueAndPushforward _d__t0 = {}; -// CHECK-NEXT: float _t2; -// CHECK-NEXT: float _t3; -// CHECK-NEXT: ValueAndPushforward _d__t1 = {}; +// CHECK-NEXT: clad::ValueAndPushforward _d__t0 = {}; +// CHECK-NEXT: clad::ValueAndPushforward _d__t1 = {}; // CHECK-NEXT: float _d_x0 = 1; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t1 = _d_x0; -// CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::sin_pushforward(_t0, _t1); -// CHECK-NEXT: _t2 = x; -// CHECK-NEXT: _t3 = _d_x0; -// CHECK-NEXT: ValueAndPushforward _t10 = clad::custom_derivatives{{(::std)?}}::cos_pushforward(_t2, _t3); +// CHECK-NEXT: clad::ValueAndPushforward _t00 = clad::custom_derivatives::sin_pushforward(x, _d_x0); +// CHECK-NEXT: clad::ValueAndPushforward _t10 = clad::custom_derivatives::cos_pushforward(x, _d_x0); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { @@ -89,7 +72,7 @@ float f1(float x) { // CHECK-NEXT: { // CHECK-NEXT: float _grad2 = 0.F; // CHECK-NEXT: float _grad3 = 0.F; -// CHECK-NEXT: cos_pushforward_pullback(_t2, _t3, _d__t1, &_grad2, &_grad3); +// CHECK-NEXT: cos_pushforward_pullback(x, _d_x0, _d__t1, &_grad2, &_grad3); // CHECK-NEXT: float _r2 = _grad2; // CHECK-NEXT: * _d_x += _r2; // CHECK-NEXT: float _r3 = _grad3; @@ -98,7 +81,7 @@ float f1(float x) { // CHECK-NEXT: { // CHECK-NEXT: float _grad0 = 0.F; // CHECK-NEXT: float _grad1 = 0.F; -// CHECK-NEXT: sin_pushforward_pullback(_t0, _t1, _d__t0, &_grad0, &_grad1); +// CHECK-NEXT: sin_pushforward_pullback(x, _d_x0, _d__t0, &_grad0, &_grad1); // CHECK-NEXT: float _r0 = _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: float _r1 = _grad1; @@ -116,48 +99,37 @@ float f2(float x) { // CHECK: float f2_darg0(float x) { // CHECK-NEXT: float _d_x = 1; -// CHECK-NEXT: ValueAndPushforward _t0 = clad::custom_derivatives{{(::std)?}}::exp_pushforward(x, _d_x); +// CHECK-NEXT: clad::ValueAndPushforward _t0 = clad::custom_derivatives::exp_pushforward(x, _d_x); // CHECK-NEXT: return _t0.pushforward; // 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: 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: float _t1; -// CHECK-NEXT: float _t2; -// CHECK-NEXT: float _t3; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t2 = x; -// CHECK-NEXT: _t3 = ::std::exp(_t2); -// CHECK-NEXT: _t1 = d_x; +// 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(_t0, 1.F).pushforward; +// CHECK-NEXT: float _r0 = _d_y.value * clad::custom_derivatives::exp_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r0; -// CHECK-NEXT: float _r1 = _d_y.pushforward * _t1; -// CHECK-NEXT: float _r2 = _r1 * clad::custom_derivatives{{(::std)?}}::exp_pushforward(_t2, 1.F).pushforward; +// CHECK-NEXT: float _r1 = _d_y.pushforward * _t0; +// CHECK-NEXT: float _r2 = _r1 * clad::custom_derivatives::exp_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r2; -// CHECK-NEXT: float _r3 = _t3 * _d_y.pushforward; +// CHECK-NEXT: float _r3 = ::std::exp(x) * _d_y.pushforward; // CHECK-NEXT: * _d_d_x += _r3; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK: void f2_darg0_grad(float x, clad::array_ref _d_x) { // CHECK-NEXT: float _d__d_x = 0; -// CHECK-NEXT: float _t0; -// CHECK-NEXT: float _t1; -// CHECK-NEXT: ValueAndPushforward _d__t0 = {}; +// CHECK-NEXT: clad::ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: float _d_x0 = 1; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t1 = _d_x0; -// CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::exp_pushforward(_t0, _t1); +// CHECK-NEXT: clad::ValueAndPushforward _t00 = clad::custom_derivatives::exp_pushforward(x, _d_x0); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d__t0.pushforward += 1; // CHECK-NEXT: { // CHECK-NEXT: float _grad0 = 0.F; // CHECK-NEXT: float _grad1 = 0.F; -// CHECK-NEXT: exp_pushforward_pullback(_t0, _t1, _d__t0, &_grad0, &_grad1); +// CHECK-NEXT: exp_pushforward_pullback(x, _d_x0, _d__t0, &_grad0, &_grad1); // CHECK-NEXT: float _r0 = _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: float _r1 = _grad1; @@ -176,49 +148,41 @@ float f3(float x) { // CHECK: float f3_darg0(float x) { // CHECK-NEXT: float _d_x = 1; -// CHECK-NEXT: ValueAndPushforward _t0 = clad::custom_derivatives{{(::std)?}}::log_pushforward(x, _d_x); +// CHECK-NEXT: clad::ValueAndPushforward _t0 = clad::custom_derivatives::log_pushforward(x, _d_x); // CHECK-NEXT: return _t0.pushforward; // CHECK-NEXT: } // 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: float _t0; +// CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t2 = x; -// CHECK-NEXT: _t3 = (1. / _t2); -// CHECK-NEXT: _t1 = d_x; +// CHECK-NEXT: _t1 = x; +// 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)?}}::log_pushforward(_t0, 1.F).pushforward; +// CHECK-NEXT: float _r0 = _d_y.value * clad::custom_derivatives::log_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r0; -// CHECK-NEXT: double _r1 = _d_y.pushforward * _t1; -// CHECK-NEXT: double _r2 = _r1 / _t2; -// CHECK-NEXT: double _r3 = _r1 * -1. / (_t2 * _t2); +// CHECK-NEXT: double _r1 = _d_y.pushforward * _t0; +// CHECK-NEXT: double _r2 = _r1 / _t1; +// CHECK-NEXT: double _r3 = _r1 * -1. / (_t1 * _t1); // CHECK-NEXT: * _d_x += _r3; -// CHECK-NEXT: double _r4 = _t3 * _d_y.pushforward; +// CHECK-NEXT: double _r4 = (1. / _t1) * _d_y.pushforward; // CHECK-NEXT: * _d_d_x += _r4; // CHECK-NEXT: } // CHECK-NEXT: } // CHECK: void f3_darg0_grad(float x, clad::array_ref _d_x) { // CHECK-NEXT: float _d__d_x = 0; -// CHECK-NEXT: float _t0; -// CHECK-NEXT: float _t1; -// CHECK-NEXT: ValueAndPushforward _d__t0 = {}; +// CHECK-NEXT: clad::ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: float _d_x0 = 1; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t1 = _d_x0; -// CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::log_pushforward(_t0, _t1); +// CHECK-NEXT: clad::ValueAndPushforward _t00 = clad::custom_derivatives::log_pushforward(x, _d_x0); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d__t0.pushforward += 1; // CHECK-NEXT: { // CHECK-NEXT: float _grad0 = 0.F; // CHECK-NEXT: float _grad1 = 0.F; -// CHECK-NEXT: log_pushforward_pullback(_t0, _t1, _d__t0, &_grad0, &_grad1); +// CHECK-NEXT: log_pushforward_pullback(x, _d_x0, _d__t0, &_grad0, &_grad1); // CHECK-NEXT: float _r0 = _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: float _r1 = _grad1; @@ -237,49 +201,29 @@ float f4(float x) { // CHECK: float f4_darg0(float x) { // CHECK-NEXT: float _d_x = 1; -// CHECK-NEXT: ValueAndPushforward _t0 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(x, 4.F, _d_x, 0.F); +// CHECK-NEXT: clad::ValueAndPushforward _t0 = clad::custom_derivatives::pow_pushforward(x, 4.F, _d_x, 0.F); // CHECK-NEXT: return _t0.pushforward; // CHECK-NEXT: } // 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_val = 0; +// CHECK-NEXT: float _d_derivative = 0; +// CHECK-NEXT: float _cond0; // CHECK-NEXT: float _t2; // CHECK-NEXT: float _t3; // CHECK-NEXT: float _t4; -// CHECK-NEXT: float _t5; -// CHECK-NEXT: float _t6; -// CHECK-NEXT: float _t7; -// CHECK-NEXT: float _d_derivative = 0; -// CHECK-NEXT: float _cond0; -// CHECK-NEXT: float _t8; -// CHECK-NEXT: float _t9; -// CHECK-NEXT: float _t10; -// CHECK-NEXT: float _t11; -// CHECK-NEXT: float _t12; -// CHECK-NEXT: float _t13; -// CHECK-NEXT: float _t14; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t1 = exponent; -// CHECK-NEXT: float val = ::std::pow(_t0, _t1); -// CHECK-NEXT: _t4 = exponent; -// CHECK-NEXT: _t5 = x; -// CHECK-NEXT: _t6 = exponent - 1; -// CHECK-NEXT: _t3 = ::std::pow(_t5, _t6); -// CHECK-NEXT: _t7 = (_t4 * _t3); -// CHECK-NEXT: _t2 = d_x; -// CHECK-NEXT: float derivative = _t7 * _t2; +// 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: _cond0 = d_exponent; // CHECK-NEXT: if (_cond0) { -// CHECK-NEXT: _t10 = x; -// CHECK-NEXT: _t11 = exponent; -// CHECK-NEXT: _t12 = ::std::pow(_t10, _t11); -// CHECK-NEXT: _t13 = x; -// CHECK-NEXT: _t9 = ::std::log(_t13); -// CHECK-NEXT: _t14 = (_t12 * _t9); -// CHECK-NEXT: _t8 = d_exponent; -// CHECK-NEXT: derivative += _t14 * _t8; +// 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: } // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: @@ -288,43 +232,44 @@ float f4(float x) { // CHECK-NEXT: _d_derivative += _d_y.pushforward; // CHECK-NEXT: } // CHECK-NEXT: if (_cond0) { +// CHECK-NEXT: derivative = _t2; // CHECK-NEXT: float _r_d0 = _d_derivative; // CHECK-NEXT: _d_derivative += _r_d0; -// CHECK-NEXT: float _r8 = _r_d0 * _t8; -// CHECK-NEXT: float _r9 = _r8 * _t9; +// CHECK-NEXT: float _r8 = _r_d0 * _t3; +// CHECK-NEXT: float _r9 = _r8 * _t4; // CHECK-NEXT: float _grad4 = 0.F; // CHECK-NEXT: float _grad5 = 0.F; -// CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(_t10, _t11, _r9, &_grad4, &_grad5); +// CHECK-NEXT: clad::custom_derivatives::pow_pullback(x, exponent, _r9, &_grad4, &_grad5); // CHECK-NEXT: float _r10 = _grad4; // CHECK-NEXT: * _d_x += _r10; // CHECK-NEXT: float _r11 = _grad5; // CHECK-NEXT: * _d_exponent += _r11; -// CHECK-NEXT: float _r12 = _t12 * _r8; -// CHECK-NEXT: float _r13 = _r12 * clad::custom_derivatives{{(::std)?}}::log_pushforward(_t13, 1.F).pushforward; +// CHECK-NEXT: float _r12 = ::std::pow(x, exponent) * _r8; +// CHECK-NEXT: float _r13 = _r12 * clad::custom_derivatives::log_pushforward(x, 1.F).pushforward; // CHECK-NEXT: * _d_x += _r13; -// CHECK-NEXT: float _r14 = _t14 * _r_d0; +// CHECK-NEXT: float _r14 = (::std::pow(x, exponent) * _t4) * _r_d0; // CHECK-NEXT: * _d_d_exponent += _r14; // CHECK-NEXT: _d_derivative -= _r_d0; // CHECK-NEXT: } // CHECK-NEXT: { -// CHECK-NEXT: float _r2 = _d_derivative * _t2; -// CHECK-NEXT: float _r3 = _r2 * _t3; +// CHECK-NEXT: float _r2 = _d_derivative * _t0; +// CHECK-NEXT: float _r3 = _r2 * _t1; // CHECK-NEXT: * _d_exponent += _r3; -// CHECK-NEXT: float _r4 = _t4 * _r2; +// CHECK-NEXT: float _r4 = exponent * _r2; // CHECK-NEXT: float _grad2 = 0.F; // CHECK-NEXT: float _grad3 = 0.F; -// CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(_t5, _t6, _r4, &_grad2, &_grad3); +// CHECK-NEXT: clad::custom_derivatives::pow_pullback(x, exponent - 1, _r4, &_grad2, &_grad3); // CHECK-NEXT: float _r5 = _grad2; // CHECK-NEXT: * _d_x += _r5; // CHECK-NEXT: float _r6 = _grad3; // CHECK-NEXT: * _d_exponent += _r6; -// CHECK-NEXT: float _r7 = _t7 * _d_derivative; +// CHECK-NEXT: float _r7 = (exponent * _t1) * _d_derivative; // CHECK-NEXT: * _d_d_x += _r7; // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: float _grad0 = 0.F; // CHECK-NEXT: float _grad1 = 0.F; -// CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(_t0, _t1, _d_val, &_grad0, &_grad1); +// CHECK-NEXT: clad::custom_derivatives::pow_pullback(x, exponent, _d_val, &_grad0, &_grad1); // CHECK-NEXT: float _r0 = _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: float _r1 = _grad1; @@ -334,13 +279,9 @@ float f4(float x) { // CHECK: void f4_darg0_grad(float x, clad::array_ref _d_x) { // CHECK-NEXT: float _d__d_x = 0; -// CHECK-NEXT: float _t0; -// CHECK-NEXT: float _t1; -// CHECK-NEXT: ValueAndPushforward _d__t0 = {}; +// CHECK-NEXT: clad::ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: float _d_x0 = 1; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t1 = _d_x0; -// CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(_t0, 4.F, _t1, 0.F); +// CHECK-NEXT: clad::ValueAndPushforward _t00 = clad::custom_derivatives::pow_pushforward(x, 4.F, _d_x0, 0.F); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d__t0.pushforward += 1; @@ -349,7 +290,7 @@ float f4(float x) { // CHECK-NEXT: float _grad1 = 0.F; // CHECK-NEXT: float _grad2 = 0.F; // CHECK-NEXT: float _grad3 = 0.F; -// CHECK-NEXT: pow_pushforward_pullback(_t0, 4.F, _t1, 0.F, _d__t0, &_grad0, &_grad1, &_grad2, &_grad3); +// CHECK-NEXT: pow_pushforward_pullback(x, 4.F, _d_x0, 0.F, _d__t0, &_grad0, &_grad1, &_grad2, &_grad3); // CHECK-NEXT: float _r0 = _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: float _r1 = _grad1; @@ -370,19 +311,15 @@ float f5(float x) { // CHECK: float f5_darg0(float x) { // CHECK-NEXT: float _d_x = 1; -// CHECK-NEXT: ValueAndPushforward _t0 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(2.F, x, 0.F, _d_x); +// CHECK-NEXT: clad::ValueAndPushforward _t0 = clad::custom_derivatives::pow_pushforward(2.F, x, 0.F, _d_x); // CHECK-NEXT: return _t0.pushforward; // CHECK-NEXT: } // CHECK: void f5_darg0_grad(float x, clad::array_ref _d_x) { // CHECK-NEXT: float _d__d_x = 0; -// CHECK-NEXT: float _t0; -// CHECK-NEXT: float _t1; -// CHECK-NEXT: ValueAndPushforward _d__t0 = {}; +// CHECK-NEXT: clad::ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: float _d_x0 = 1; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t1 = _d_x0; -// CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(2.F, _t0, 0.F, _t1); +// CHECK-NEXT: clad::ValueAndPushforward _t00 = clad::custom_derivatives::pow_pushforward(2.F, x, 0.F, _d_x0); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d__t0.pushforward += 1; @@ -391,7 +328,7 @@ float f5(float x) { // CHECK-NEXT: float _grad1 = 0.F; // CHECK-NEXT: float _grad2 = 0.F; // CHECK-NEXT: float _grad3 = 0.F; -// CHECK-NEXT: pow_pushforward_pullback(2.F, _t0, 0.F, _t1, _d__t0, &_grad0, &_grad1, &_grad2, &_grad3); +// CHECK-NEXT: pow_pushforward_pullback(2.F, x, 0.F, _d_x0, _d__t0, &_grad0, &_grad1, &_grad2, &_grad3); // CHECK-NEXT: float _r0 = _grad0; // CHECK-NEXT: float _r1 = _grad1; // CHECK-NEXT: * _d_x += _r1; @@ -413,25 +350,17 @@ float f6(float x, float y) { // CHECK: float f6_darg0(float x, float y) { // CHECK-NEXT: float _d_x = 1; // CHECK-NEXT: float _d_y = 0; -// CHECK-NEXT: ValueAndPushforward _t0 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(x, y, _d_x, _d_y); +// CHECK-NEXT: clad::ValueAndPushforward _t0 = clad::custom_derivatives::pow_pushforward(x, y, _d_x, _d_y); // CHECK-NEXT: return _t0.pushforward; // CHECK-NEXT: } // CHECK: void f6_darg0_grad(float x, float y, clad::array_ref _d_x, clad::array_ref _d_y) { // CHECK-NEXT: float _d__d_x = 0; // CHECK-NEXT: float _d__d_y = 0; -// CHECK-NEXT: float _t0; -// CHECK-NEXT: float _t1; -// CHECK-NEXT: float _t2; -// CHECK-NEXT: float _t3; -// CHECK-NEXT: ValueAndPushforward _d__t0 = {}; +// CHECK-NEXT: clad::ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: float _d_x0 = 1; // CHECK-NEXT: float _d_y0 = 0; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t1 = y; -// CHECK-NEXT: _t2 = _d_x0; -// CHECK-NEXT: _t3 = _d_y0; -// CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(_t0, _t1, _t2, _t3); +// CHECK-NEXT: clad::ValueAndPushforward _t00 = clad::custom_derivatives::pow_pushforward(x, y, _d_x0, _d_y0); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d__t0.pushforward += 1; @@ -440,7 +369,7 @@ float f6(float x, float y) { // CHECK-NEXT: float _grad1 = 0.F; // CHECK-NEXT: float _grad2 = 0.F; // CHECK-NEXT: float _grad3 = 0.F; -// CHECK-NEXT: pow_pushforward_pullback(_t0, _t1, _t2, _t3, _d__t0, &_grad0, &_grad1, &_grad2, &_grad3); +// CHECK-NEXT: pow_pushforward_pullback(x, y, _d_x0, _d_y0, _d__t0, &_grad0, &_grad1, &_grad2, &_grad3); // CHECK-NEXT: float _r0 = _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: float _r1 = _grad1; @@ -455,25 +384,17 @@ float f6(float x, float y) { // CHECK: float f6_darg1(float x, float y) { // CHECK-NEXT: float _d_x = 0; // CHECK-NEXT: float _d_y = 1; -// CHECK-NEXT: ValueAndPushforward _t0 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(x, y, _d_x, _d_y); +// CHECK-NEXT: clad::ValueAndPushforward _t0 = clad::custom_derivatives::pow_pushforward(x, y, _d_x, _d_y); // CHECK-NEXT: return _t0.pushforward; // CHECK-NEXT: } // CHECK: void f6_darg1_grad(float x, float y, clad::array_ref _d_x, clad::array_ref _d_y) { // CHECK-NEXT: float _d__d_x = 0; // CHECK-NEXT: float _d__d_y = 0; -// CHECK-NEXT: float _t0; -// CHECK-NEXT: float _t1; -// CHECK-NEXT: float _t2; -// CHECK-NEXT: float _t3; -// CHECK-NEXT: ValueAndPushforward _d__t0 = {}; +// CHECK-NEXT: clad::ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: float _d_x0 = 0; // CHECK-NEXT: float _d_y0 = 1; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t1 = y; -// CHECK-NEXT: _t2 = _d_x0; -// CHECK-NEXT: _t3 = _d_y0; -// CHECK-NEXT: ValueAndPushforward _t00 = clad::custom_derivatives{{(::std)?}}::pow_pushforward(_t0, _t1, _t2, _t3); +// CHECK-NEXT: clad::ValueAndPushforward _t00 = clad::custom_derivatives::pow_pushforward(x, y, _d_x0, _d_y0); // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: _d__t0.pushforward += 1; @@ -482,7 +403,7 @@ float f6(float x, float y) { // CHECK-NEXT: float _grad1 = 0.F; // CHECK-NEXT: float _grad2 = 0.F; // CHECK-NEXT: float _grad3 = 0.F; -// CHECK-NEXT: pow_pushforward_pullback(_t0, _t1, _t2, _t3, _d__t0, &_grad0, &_grad1, &_grad2, &_grad3); +// CHECK-NEXT: pow_pushforward_pullback(x, y, _d_x0, _d_y0, _d__t0, &_grad0, &_grad1, &_grad2, &_grad3); // CHECK-NEXT: float _r0 = _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: float _r1 = _grad1; diff --git a/test/Hessian/Functors.C b/test/Hessian/Functors.C index eb1fbe054..c5e3a71a7 100644 --- a/test/Hessian/Functors.C +++ b/test/Hessian/Functors.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oFunctors.out 2>&1 | FileCheck %s // RUN: ./Functors.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oFunctors.out +// RUN: ./Functors.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Hessian/Hessians.C b/test/Hessian/Hessians.C index f7249a867..672de6474 100644 --- a/test/Hessian/Hessians.C +++ b/test/Hessian/Hessians.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oHessians.out 2>&1 | FileCheck %s // RUN: ./Hessians.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oHessians.out +// RUN: ./Hessians.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -14,95 +16,75 @@ void f_cubed_add1_darg0_grad(double a, double b, clad::array_ref _d_a, c //CHECK-NEXT: double _d__d_a = 0; //CHECK-NEXT: double _d__d_b = 0; //CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; //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 _d__t1 = 0; //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 _t11; -//CHECK-NEXT: double _t12; -//CHECK-NEXT: double _t13; -//CHECK-NEXT: double _t14; -//CHECK-NEXT: double _t15; -//CHECK-NEXT: double _t16; -//CHECK-NEXT: double _t17; -//CHECK-NEXT: double _t18; -//CHECK-NEXT: double _t19; -//CHECK-NEXT: double _t20; //CHECK-NEXT: double _d_a0 = 1; //CHECK-NEXT: double _d_b0 = 0; -//CHECK-NEXT: _t1 = a; //CHECK-NEXT: _t0 = a; -//CHECK-NEXT: double _t00 = _t1 * _t0; -//CHECK-NEXT: _t3 = b; -//CHECK-NEXT: _t2 = b; -//CHECK-NEXT: double _t10 = _t3 * _t2; -//CHECK-NEXT: _t6 = _d_a0; -//CHECK-NEXT: _t5 = a; -//CHECK-NEXT: _t8 = a; -//CHECK-NEXT: _t7 = _d_a0; -//CHECK-NEXT: _t9 = (_t6 * _t5 + _t8 * _t7); -//CHECK-NEXT: _t4 = a; -//CHECK-NEXT: _t12 = _t00; -//CHECK-NEXT: _t11 = _d_a0; -//CHECK-NEXT: _t15 = _d_b0; -//CHECK-NEXT: _t14 = b; -//CHECK-NEXT: _t17 = b; -//CHECK-NEXT: _t16 = _d_b0; -//CHECK-NEXT: _t18 = (_t15 * _t14 + _t17 * _t16); -//CHECK-NEXT: _t13 = b; -//CHECK-NEXT: _t20 = _t10; -//CHECK-NEXT: _t19 = _d_b0; +//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: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t4; -//CHECK-NEXT: double _r5 = _r4 * _t5; +//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r5 = _r4 * _t3; //CHECK-NEXT: _d__d_a += _r5; -//CHECK-NEXT: double _r6 = _t6 * _r4; +//CHECK-NEXT: double _r6 = _d_a0 * _r4; //CHECK-NEXT: * _d_a += _r6; -//CHECK-NEXT: double _r7 = _r4 * _t7; +//CHECK-NEXT: double _r7 = _r4 * _t4; //CHECK-NEXT: * _d_a += _r7; -//CHECK-NEXT: double _r8 = _t8 * _r4; +//CHECK-NEXT: double _r8 = a * _r4; //CHECK-NEXT: _d__d_a += _r8; -//CHECK-NEXT: double _r9 = _t9 * 1; +//CHECK-NEXT: double _r9 = (_d_a0 * _t3 + a * _t4) * 1; //CHECK-NEXT: * _d_a += _r9; -//CHECK-NEXT: double _r10 = 1 * _t11; +//CHECK-NEXT: double _r10 = 1 * _t5; //CHECK-NEXT: _d__t0 += _r10; -//CHECK-NEXT: double _r11 = _t12 * 1; +//CHECK-NEXT: double _r11 = _t00 * 1; //CHECK-NEXT: _d__d_a += _r11; -//CHECK-NEXT: double _r12 = 1 * _t13; -//CHECK-NEXT: double _r13 = _r12 * _t14; +//CHECK-NEXT: double _r12 = 1 * _t6; +//CHECK-NEXT: double _r13 = _r12 * _t7; //CHECK-NEXT: _d__d_b += _r13; -//CHECK-NEXT: double _r14 = _t15 * _r12; +//CHECK-NEXT: double _r14 = _d_b0 * _r12; //CHECK-NEXT: * _d_b += _r14; -//CHECK-NEXT: double _r15 = _r12 * _t16; +//CHECK-NEXT: double _r15 = _r12 * _t8; //CHECK-NEXT: * _d_b += _r15; -//CHECK-NEXT: double _r16 = _t17 * _r12; +//CHECK-NEXT: double _r16 = b * _r12; //CHECK-NEXT: _d__d_b += _r16; -//CHECK-NEXT: double _r17 = _t18 * 1; +//CHECK-NEXT: double _r17 = (_d_b0 * _t7 + b * _t8) * 1; //CHECK-NEXT: * _d_b += _r17; -//CHECK-NEXT: double _r18 = 1 * _t19; +//CHECK-NEXT: double _r18 = 1 * _t9; //CHECK-NEXT: _d__t1 += _r18; -//CHECK-NEXT: double _r19 = _t20 * 1; +//CHECK-NEXT: double _r19 = _t10 * 1; //CHECK-NEXT: _d__d_b += _r19; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r2 = _d__t1 * _t2; +//CHECK-NEXT: double _r2 = _d__t1 * _t1; //CHECK-NEXT: * _d_b += _r2; -//CHECK-NEXT: double _r3 = _t3 * _d__t1; +//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: * _d_a += _r0; -//CHECK-NEXT: double _r1 = _t1 * _d__t0; +//CHECK-NEXT: double _r1 = a * _d__t0; //CHECK-NEXT: * _d_a += _r1; //CHECK-NEXT: } //CHECK-NEXT:} @@ -112,95 +94,75 @@ void f_cubed_add1_darg1_grad(double a, double b, clad::array_ref _d_a, c //CHECK-NEXT: double _d__d_a = 0; //CHECK-NEXT: double _d__d_b = 0; //CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; //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 _d__t1 = 0; //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 _t11; -//CHECK-NEXT: double _t12; -//CHECK-NEXT: double _t13; -//CHECK-NEXT: double _t14; -//CHECK-NEXT: double _t15; -//CHECK-NEXT: double _t16; -//CHECK-NEXT: double _t17; -//CHECK-NEXT: double _t18; -//CHECK-NEXT: double _t19; -//CHECK-NEXT: double _t20; //CHECK-NEXT: double _d_a0 = 0; //CHECK-NEXT: double _d_b0 = 1; -//CHECK-NEXT: _t1 = a; //CHECK-NEXT: _t0 = a; -//CHECK-NEXT: double _t00 = _t1 * _t0; -//CHECK-NEXT: _t3 = b; -//CHECK-NEXT: _t2 = b; -//CHECK-NEXT: double _t10 = _t3 * _t2; -//CHECK-NEXT: _t6 = _d_a0; -//CHECK-NEXT: _t5 = a; -//CHECK-NEXT: _t8 = a; -//CHECK-NEXT: _t7 = _d_a0; -//CHECK-NEXT: _t9 = (_t6 * _t5 + _t8 * _t7); -//CHECK-NEXT: _t4 = a; -//CHECK-NEXT: _t12 = _t00; -//CHECK-NEXT: _t11 = _d_a0; -//CHECK-NEXT: _t15 = _d_b0; -//CHECK-NEXT: _t14 = b; -//CHECK-NEXT: _t17 = b; -//CHECK-NEXT: _t16 = _d_b0; -//CHECK-NEXT: _t18 = (_t15 * _t14 + _t17 * _t16); -//CHECK-NEXT: _t13 = b; -//CHECK-NEXT: _t20 = _t10; -//CHECK-NEXT: _t19 = _d_b0; +//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: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t4; -//CHECK-NEXT: double _r5 = _r4 * _t5; +//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r5 = _r4 * _t3; //CHECK-NEXT: _d__d_a += _r5; -//CHECK-NEXT: double _r6 = _t6 * _r4; +//CHECK-NEXT: double _r6 = _d_a0 * _r4; //CHECK-NEXT: * _d_a += _r6; -//CHECK-NEXT: double _r7 = _r4 * _t7; +//CHECK-NEXT: double _r7 = _r4 * _t4; //CHECK-NEXT: * _d_a += _r7; -//CHECK-NEXT: double _r8 = _t8 * _r4; +//CHECK-NEXT: double _r8 = a * _r4; //CHECK-NEXT: _d__d_a += _r8; -//CHECK-NEXT: double _r9 = _t9 * 1; +//CHECK-NEXT: double _r9 = (_d_a0 * _t3 + a * _t4) * 1; //CHECK-NEXT: * _d_a += _r9; -//CHECK-NEXT: double _r10 = 1 * _t11; +//CHECK-NEXT: double _r10 = 1 * _t5; //CHECK-NEXT: _d__t0 += _r10; -//CHECK-NEXT: double _r11 = _t12 * 1; +//CHECK-NEXT: double _r11 = _t00 * 1; //CHECK-NEXT: _d__d_a += _r11; -//CHECK-NEXT: double _r12 = 1 * _t13; -//CHECK-NEXT: double _r13 = _r12 * _t14; +//CHECK-NEXT: double _r12 = 1 * _t6; +//CHECK-NEXT: double _r13 = _r12 * _t7; //CHECK-NEXT: _d__d_b += _r13; -//CHECK-NEXT: double _r14 = _t15 * _r12; +//CHECK-NEXT: double _r14 = _d_b0 * _r12; //CHECK-NEXT: * _d_b += _r14; -//CHECK-NEXT: double _r15 = _r12 * _t16; +//CHECK-NEXT: double _r15 = _r12 * _t8; //CHECK-NEXT: * _d_b += _r15; -//CHECK-NEXT: double _r16 = _t17 * _r12; +//CHECK-NEXT: double _r16 = b * _r12; //CHECK-NEXT: _d__d_b += _r16; -//CHECK-NEXT: double _r17 = _t18 * 1; +//CHECK-NEXT: double _r17 = (_d_b0 * _t7 + b * _t8) * 1; //CHECK-NEXT: * _d_b += _r17; -//CHECK-NEXT: double _r18 = 1 * _t19; +//CHECK-NEXT: double _r18 = 1 * _t9; //CHECK-NEXT: _d__t1 += _r18; -//CHECK-NEXT: double _r19 = _t20 * 1; +//CHECK-NEXT: double _r19 = _t10 * 1; //CHECK-NEXT: _d__d_b += _r19; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r2 = _d__t1 * _t2; +//CHECK-NEXT: double _r2 = _d__t1 * _t1; //CHECK-NEXT: * _d_b += _r2; -//CHECK-NEXT: double _r3 = _t3 * _d__t1; +//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: * _d_a += _r0; -//CHECK-NEXT: double _r1 = _t1 * _d__t0; +//CHECK-NEXT: double _r1 = a * _d__t0; //CHECK-NEXT: * _d_a += _r1; //CHECK-NEXT: } //CHECK-NEXT:} diff --git a/test/Hessian/NestedFunctionCalls.C b/test/Hessian/NestedFunctionCalls.C index 7518c0aa1..d848ff1c7 100644 --- a/test/Hessian/NestedFunctionCalls.C +++ b/test/Hessian/NestedFunctionCalls.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oNestedFunctionCalls.out 2>&1 | FileCheck %s // RUN: ./NestedFunctionCalls.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oNestedFunctionCalls.out +// RUN: ./NestedFunctionCalls.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} @@ -35,50 +37,38 @@ double f2(double x, double y){ // 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 _t10; -// CHECK-NEXT: double _t11; -// CHECK-NEXT: _t1 = x; // CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t3 = y; -// CHECK-NEXT: _t2 = y; -// CHECK-NEXT: _t5 = _d_x; -// CHECK-NEXT: _t4 = x; -// CHECK-NEXT: _t7 = x; -// CHECK-NEXT: _t6 = _d_x; -// CHECK-NEXT: _t9 = _d_y; -// CHECK-NEXT: _t8 = y; -// CHECK-NEXT: _t11 = y; -// CHECK-NEXT: _t10 = _d_y; +// 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: * _d_x += _r0; -// CHECK-NEXT: double _r1 = _t1 * _d_y0.value; +// CHECK-NEXT: double _r1 = x * _d_y0.value; // CHECK-NEXT: * _d_x += _r1; -// CHECK-NEXT: double _r2 = _d_y0.value * _t2; +// CHECK-NEXT: double _r2 = _d_y0.value * _t1; // CHECK-NEXT: * _d_y += _r2; -// CHECK-NEXT: double _r3 = _t3 * _d_y0.value; +// CHECK-NEXT: double _r3 = y * _d_y0.value; // CHECK-NEXT: * _d_y += _r3; -// CHECK-NEXT: double _r4 = _d_y0.pushforward * _t4; +// CHECK-NEXT: double _r4 = _d_y0.pushforward * _t2; // CHECK-NEXT: * _d__d_x += _r4; -// CHECK-NEXT: double _r5 = _t5 * _d_y0.pushforward; +// CHECK-NEXT: double _r5 = _d_x * _d_y0.pushforward; // CHECK-NEXT: * _d_x += _r5; -// CHECK-NEXT: double _r6 = _d_y0.pushforward * _t6; +// CHECK-NEXT: double _r6 = _d_y0.pushforward * _t3; // CHECK-NEXT: * _d_x += _r6; -// CHECK-NEXT: double _r7 = _t7 * _d_y0.pushforward; +// CHECK-NEXT: double _r7 = x * _d_y0.pushforward; // CHECK-NEXT: * _d__d_x += _r7; -// CHECK-NEXT: double _r8 = _d_y0.pushforward * _t8; +// CHECK-NEXT: double _r8 = _d_y0.pushforward * _t4; // CHECK-NEXT: * _d__d_y += _r8; -// CHECK-NEXT: double _r9 = _t9 * _d_y0.pushforward; +// CHECK-NEXT: double _r9 = _d_y * _d_y0.pushforward; // CHECK-NEXT: * _d_y += _r9; -// CHECK-NEXT: double _r10 = _d_y0.pushforward * _t10; +// CHECK-NEXT: double _r10 = _d_y0.pushforward * _t5; // CHECK-NEXT: * _d_y += _r10; -// CHECK-NEXT: double _r11 = _t11 * _d_y0.pushforward; +// CHECK-NEXT: double _r11 = y * _d_y0.pushforward; // CHECK-NEXT: * _d__d_y += _r11; // CHECK-NEXT: } // CHECK-NEXT: } @@ -86,20 +76,12 @@ double f2(double x, double y){ // CHECK: void f2_darg0_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { // CHECK-NEXT: double _d__d_x = 0; // CHECK-NEXT: double _d__d_y = 0; -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; // CHECK-NEXT: clad::ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: double _d__d_ans = 0; // CHECK-NEXT: double _d_ans0 = 0; // CHECK-NEXT: double _d_x0 = 1; // CHECK-NEXT: double _d_y0 = 0; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t1 = y; -// CHECK-NEXT: _t2 = _d_x0; -// CHECK-NEXT: _t3 = _d_y0; -// CHECK-NEXT: clad::ValueAndPushforward _t00 = f_pushforward(_t0, _t1, _t2, _t3); +// CHECK-NEXT: clad::ValueAndPushforward _t00 = f_pushforward(x, y, _d_x0, _d_y0); // CHECK-NEXT: double _d_ans = _t00.pushforward; // CHECK-NEXT: double ans = _t00.value; // CHECK-NEXT: goto _label0; @@ -112,7 +94,7 @@ double f2(double x, double y){ // CHECK-NEXT: double _grad1 = 0.; // CHECK-NEXT: double _grad2 = 0.; // CHECK-NEXT: double _grad3 = 0.; -// CHECK-NEXT: f_pushforward_pullback(_t0, _t1, _t2, _t3, _d__t0, &_grad0, &_grad1, &_grad2, &_grad3); +// CHECK-NEXT: f_pushforward_pullback(x, y, _d_x0, _d_y0, _d__t0, &_grad0, &_grad1, &_grad2, &_grad3); // CHECK-NEXT: double _r0 = _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: double _r1 = _grad1; @@ -136,20 +118,12 @@ double f2(double x, double y){ // CHECK: void f2_darg1_grad(double x, double y, clad::array_ref _d_x, clad::array_ref _d_y) { // CHECK-NEXT: double _d__d_x = 0; // CHECK-NEXT: double _d__d_y = 0; -// CHECK-NEXT: double _t0; -// CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; // CHECK-NEXT: clad::ValueAndPushforward _d__t0 = {}; // CHECK-NEXT: double _d__d_ans = 0; // CHECK-NEXT: double _d_ans0 = 0; // CHECK-NEXT: double _d_x0 = 0; // CHECK-NEXT: double _d_y0 = 1; -// CHECK-NEXT: _t0 = x; -// CHECK-NEXT: _t1 = y; -// CHECK-NEXT: _t2 = _d_x0; -// CHECK-NEXT: _t3 = _d_y0; -// CHECK-NEXT: clad::ValueAndPushforward _t00 = f_pushforward(_t0, _t1, _t2, _t3); +// CHECK-NEXT: clad::ValueAndPushforward _t00 = f_pushforward(x, y, _d_x0, _d_y0); // CHECK-NEXT: double _d_ans = _t00.pushforward; // CHECK-NEXT: double ans = _t00.value; // CHECK-NEXT: goto _label0; @@ -162,7 +136,7 @@ double f2(double x, double y){ // CHECK-NEXT: double _grad1 = 0.; // CHECK-NEXT: double _grad2 = 0.; // CHECK-NEXT: double _grad3 = 0.; -// CHECK-NEXT: f_pushforward_pullback(_t0, _t1, _t2, _t3, _d__t0, &_grad0, &_grad1, &_grad2, &_grad3); +// CHECK-NEXT: f_pushforward_pullback(x, y, _d_x0, _d_y0, _d__t0, &_grad0, &_grad1, &_grad2, &_grad3); // CHECK-NEXT: double _r0 = _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: double _r1 = _grad1; diff --git a/test/Hessian/Pointers.C b/test/Hessian/Pointers.C index 89fd3dcbf..cf5f4883e 100644 --- a/test/Hessian/Pointers.C +++ b/test/Hessian/Pointers.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oPointers.out 2>&1 | FileCheck %s // RUN: ./Pointers.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oPointers.out +// RUN: ./Pointers.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -19,24 +21,20 @@ double nonMemFn(double i, double j) { // CHECK-NEXT: double _d__d_j = 0; // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; // CHECK-NEXT: double _d_i0 = 1; // CHECK-NEXT: double _d_j0 = 0; -// CHECK-NEXT: _t1 = _d_i0; // CHECK-NEXT: _t0 = j; -// CHECK-NEXT: _t3 = i; -// CHECK-NEXT: _t2 = _d_j0; +// CHECK-NEXT: _t1 = _d_j0; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: _d__d_i += _r0; -// CHECK-NEXT: double _r1 = _t1 * 1; +// CHECK-NEXT: double _r1 = _d_i0 * 1; // CHECK-NEXT: * _d_j += _r1; -// CHECK-NEXT: double _r2 = 1 * _t2; +// CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; -// CHECK-NEXT: double _r3 = _t3 * 1; +// CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: _d__d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -52,24 +50,20 @@ double nonMemFn(double i, double j) { // CHECK-NEXT: double _d__d_j = 0; // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; -// CHECK-NEXT: double _t2; -// CHECK-NEXT: double _t3; // CHECK-NEXT: double _d_i0 = 0; // CHECK-NEXT: double _d_j0 = 1; -// CHECK-NEXT: _t1 = _d_i0; // CHECK-NEXT: _t0 = j; -// CHECK-NEXT: _t3 = i; -// CHECK-NEXT: _t2 = _d_j0; +// CHECK-NEXT: _t1 = _d_j0; // CHECK-NEXT: goto _label0; // CHECK-NEXT: _label0: // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: _d__d_i += _r0; -// CHECK-NEXT: double _r1 = _t1 * 1; +// CHECK-NEXT: double _r1 = _d_i0 * 1; // CHECK-NEXT: * _d_j += _r1; -// CHECK-NEXT: double _r2 = 1 * _t2; +// CHECK-NEXT: double _r2 = 1 * _t1; // CHECK-NEXT: * _d_i += _r2; -// CHECK-NEXT: double _r3 = _t3 * 1; +// CHECK-NEXT: double _r3 = i * 1; // CHECK-NEXT: _d__d_j += _r3; // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/Hessian/TemplateFunctors.C b/test/Hessian/TemplateFunctors.C index e37732ba8..e5c7e5bc6 100644 --- a/test/Hessian/TemplateFunctors.C +++ b/test/Hessian/TemplateFunctors.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oTemplateFunctors.out 2>&1 | FileCheck %s // RUN: ./TemplateFunctors.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oTemplateFunctors.out +// RUN: ./TemplateFunctors.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Hessian/constexprTest.C b/test/Hessian/constexprTest.C index 6f9b01451..9430068da 100644 --- a/test/Hessian/constexprTest.C +++ b/test/Hessian/constexprTest.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -std=c++14 -oconstexprTest.out 2>&1 | FileCheck %s // RUN: ./constexprTest.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -std=c++14 -oconstexprTest.out +// RUN: ./constexprTest.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Hessian/testhessUtility.C b/test/Hessian/testhessUtility.C index 369ae8dc0..f927f7fee 100644 --- a/test/Hessian/testhessUtility.C +++ b/test/Hessian/testhessUtility.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -otesthessUtility.out 2>&1 | FileCheck %s // RUN: ./testhessUtility.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -otesthessUtility.out +// RUN: ./testhessUtility.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Jacobian/FunctionCalls.C b/test/Jacobian/FunctionCalls.C index 4e6a216e5..b0b6b8eca 100644 --- a/test/Jacobian/FunctionCalls.C +++ b/test/Jacobian/FunctionCalls.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oFunctionCalls.out 2>&1 | FileCheck %s // RUN: ./FunctionCalls.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oFunctionCalls.out +// RUN: ./FunctionCalls.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -14,20 +16,12 @@ void fn1(double i, double j, double* output) { } // CHECK: void fn1_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: _t0 = i; -// CHECK-NEXT: _t1 = j; // CHECK-NEXT: output[0] = std::pow(i, j); -// CHECK-NEXT: _t2 = j; -// CHECK-NEXT: _t3 = i; // CHECK-NEXT: output[1] = std::pow(j, i); // CHECK-NEXT: { // CHECK-NEXT: double _jac2 = 0.; // CHECK-NEXT: double _jac3 = 0.; -// CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(_t2, _t3, 1, &_jac2, &_jac3); +// CHECK-NEXT: clad::custom_derivatives::pow_pullback(j, i, 1, &_jac2, &_jac3); // CHECK-NEXT: double _r2 = _jac2; // CHECK-NEXT: jacobianMatrix[3UL] += _r2; // CHECK-NEXT: double _r3 = _jac3; @@ -36,7 +30,7 @@ void fn1(double i, double j, double* output) { // CHECK-NEXT: { // CHECK-NEXT: double _jac0 = 0.; // CHECK-NEXT: double _jac1 = 0.; -// CHECK-NEXT: clad::custom_derivatives{{(::std)?}}::pow_pullback(_t0, _t1, 1, &_jac0, &_jac1); +// CHECK-NEXT: clad::custom_derivatives::pow_pullback(i, j, 1, &_jac0, &_jac1); // CHECK-NEXT: double _r0 = _jac0; // CHECK-NEXT: jacobianMatrix[0UL] += _r0; // CHECK-NEXT: double _r1 = _jac1; diff --git a/test/Jacobian/Functors.C b/test/Jacobian/Functors.C index da7b664c4..c4db0d705 100644 --- a/test/Jacobian/Functors.C +++ b/test/Jacobian/Functors.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oFunctors.out 2>&1 | FileCheck %s // RUN: ./Functors.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oFunctors.out +// RUN: ./Functors.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -22,46 +24,34 @@ struct Experiment { // 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 _t10; - // CHECK-NEXT: double _t11; - // CHECK-NEXT: _t3 = this->x; // CHECK-NEXT: _t2 = i; - // CHECK-NEXT: _t4 = _t3 * _t2; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t5 = _t4 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * i * i * j; - // CHECK-NEXT: _t9 = this->y; - // CHECK-NEXT: _t8 = i; - // CHECK-NEXT: _t10 = _t9 * _t8; - // CHECK-NEXT: _t7 = j; - // CHECK-NEXT: _t11 = _t10 * _t7; - // CHECK-NEXT: _t6 = 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 * _t6; - // CHECK-NEXT: double _r7 = _r6 * _t7; - // CHECK-NEXT: double _r8 = _r7 * _t8; - // CHECK-NEXT: double _r9 = _t9 * _r7; + // CHECK-NEXT: double _r6 = 1 * _t3; + // CHECK-NEXT: double _r7 = _r6 * _t4; + // CHECK-NEXT: double _r8 = _r7 * _t5; + // CHECK-NEXT: double _r9 = this->y * _r7; // CHECK-NEXT: jacobianMatrix[2UL] += _r9; - // CHECK-NEXT: double _r10 = _t10 * _r6; + // CHECK-NEXT: double _r10 = this->y * _t5 * _r6; // CHECK-NEXT: jacobianMatrix[3UL] += _r10; - // CHECK-NEXT: double _r11 = _t11 * 1; + // CHECK-NEXT: double _r11 = this->y * _t5 * _t4 * 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 _r3 = _t3 * _r1; + // CHECK-NEXT: double _r3 = this->x * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; - // CHECK-NEXT: double _r4 = _t4 * _r0; + // CHECK-NEXT: double _r4 = this->x * _t2 * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; - // CHECK-NEXT: double _r5 = _t5 * 1; + // CHECK-NEXT: double _r5 = this->x * _t2 * _t1 * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -85,46 +75,34 @@ struct ExperimentConst { // 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 _t10; - // CHECK-NEXT: double _t11; - // CHECK-NEXT: _t3 = this->x; // CHECK-NEXT: _t2 = i; - // CHECK-NEXT: _t4 = _t3 * _t2; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t5 = _t4 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * i * i * j; - // CHECK-NEXT: _t9 = this->y; - // CHECK-NEXT: _t8 = i; - // CHECK-NEXT: _t10 = _t9 * _t8; - // CHECK-NEXT: _t7 = j; - // CHECK-NEXT: _t11 = _t10 * _t7; - // CHECK-NEXT: _t6 = 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 * _t6; - // CHECK-NEXT: double _r7 = _r6 * _t7; - // CHECK-NEXT: double _r8 = _r7 * _t8; - // CHECK-NEXT: double _r9 = _t9 * _r7; + // CHECK-NEXT: double _r6 = 1 * _t3; + // CHECK-NEXT: double _r7 = _r6 * _t4; + // CHECK-NEXT: double _r8 = _r7 * _t5; + // CHECK-NEXT: double _r9 = this->y * _r7; // CHECK-NEXT: jacobianMatrix[2UL] += _r9; - // CHECK-NEXT: double _r10 = _t10 * _r6; + // CHECK-NEXT: double _r10 = this->y * _t5 * _r6; // CHECK-NEXT: jacobianMatrix[3UL] += _r10; - // CHECK-NEXT: double _r11 = _t11 * 1; + // CHECK-NEXT: double _r11 = this->y * _t5 * _t4 * 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 _r3 = _t3 * _r1; + // CHECK-NEXT: double _r3 = this->x * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; - // CHECK-NEXT: double _r4 = _t4 * _r0; + // CHECK-NEXT: double _r4 = this->x * _t2 * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; - // CHECK-NEXT: double _r5 = _t5 * 1; + // CHECK-NEXT: double _r5 = this->x * _t2 * _t1 * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -145,49 +123,37 @@ struct ExperimentVolatile { // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; // CHECK-NEXT: double _t2; - // CHECK-NEXT: volatile double _t3; + // 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: volatile double _t9; - // CHECK-NEXT: double _t10; - // CHECK-NEXT: double _t11; - // CHECK-NEXT: _t3 = this->x; // CHECK-NEXT: _t2 = i; - // CHECK-NEXT: _t4 = _t3 * _t2; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t5 = _t4 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * i * i * j; - // CHECK-NEXT: _t9 = this->y; - // CHECK-NEXT: _t8 = i; - // CHECK-NEXT: _t10 = _t9 * _t8; - // CHECK-NEXT: _t7 = j; - // CHECK-NEXT: _t11 = _t10 * _t7; - // CHECK-NEXT: _t6 = 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 * _t6; - // CHECK-NEXT: double _r7 = _r6 * _t7; - // CHECK-NEXT: double _r8 = _r7 * _t8; - // CHECK-NEXT: double _r9 = _t9 * _r7; + // CHECK-NEXT: double _r6 = 1 * _t3; + // CHECK-NEXT: double _r7 = _r6 * _t4; + // CHECK-NEXT: double _r8 = _r7 * _t5; + // CHECK-NEXT: double _r9 = this->y * _r7; // CHECK-NEXT: jacobianMatrix[2UL] += _r9; - // CHECK-NEXT: double _r10 = _t10 * _r6; + // CHECK-NEXT: double _r10 = this->y * _t5 * _r6; // CHECK-NEXT: jacobianMatrix[3UL] += _r10; - // CHECK-NEXT: double _r11 = _t11 * 1; + // CHECK-NEXT: double _r11 = this->y * _t5 * _t4 * 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 _r3 = _t3 * _r1; + // CHECK-NEXT: double _r3 = this->x * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; - // CHECK-NEXT: double _r4 = _t4 * _r0; + // CHECK-NEXT: double _r4 = this->x * _t2 * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; - // CHECK-NEXT: double _r5 = _t5 * 1; + // CHECK-NEXT: double _r5 = this->x * _t2 * _t1 * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -208,49 +174,37 @@ struct ExperimentConstVolatile { // CHECK-NEXT: double _t0; // CHECK-NEXT: double _t1; // CHECK-NEXT: double _t2; - // CHECK-NEXT: volatile double _t3; + // 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: volatile double _t9; - // CHECK-NEXT: double _t10; - // CHECK-NEXT: double _t11; - // CHECK-NEXT: _t3 = this->x; // CHECK-NEXT: _t2 = i; - // CHECK-NEXT: _t4 = _t3 * _t2; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t5 = _t4 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * i * i * j; - // CHECK-NEXT: _t9 = this->y; - // CHECK-NEXT: _t8 = i; - // CHECK-NEXT: _t10 = _t9 * _t8; - // CHECK-NEXT: _t7 = j; - // CHECK-NEXT: _t11 = _t10 * _t7; - // CHECK-NEXT: _t6 = 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 * _t6; - // CHECK-NEXT: double _r7 = _r6 * _t7; - // CHECK-NEXT: double _r8 = _r7 * _t8; - // CHECK-NEXT: double _r9 = _t9 * _r7; + // CHECK-NEXT: double _r6 = 1 * _t3; + // CHECK-NEXT: double _r7 = _r6 * _t4; + // CHECK-NEXT: double _r8 = _r7 * _t5; + // CHECK-NEXT: double _r9 = this->y * _r7; // CHECK-NEXT: jacobianMatrix[2UL] += _r9; - // CHECK-NEXT: double _r10 = _t10 * _r6; + // CHECK-NEXT: double _r10 = this->y * _t5 * _r6; // CHECK-NEXT: jacobianMatrix[3UL] += _r10; - // CHECK-NEXT: double _r11 = _t11 * 1; + // CHECK-NEXT: double _r11 = this->y * _t5 * _t4 * 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 _r3 = _t3 * _r1; + // CHECK-NEXT: double _r3 = this->x * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; - // CHECK-NEXT: double _r4 = _t4 * _r0; + // CHECK-NEXT: double _r4 = this->x * _t2 * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; - // CHECK-NEXT: double _r5 = _t5 * 1; + // CHECK-NEXT: double _r5 = this->x * _t2 * _t1 * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -276,46 +230,34 @@ namespace outer { // 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 _t10; - // CHECK-NEXT: double _t11; - // CHECK-NEXT: _t3 = this->x; // CHECK-NEXT: _t2 = i; - // CHECK-NEXT: _t4 = _t3 * _t2; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t5 = _t4 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * i * i * j; - // CHECK-NEXT: _t9 = this->y; - // CHECK-NEXT: _t8 = i; - // CHECK-NEXT: _t10 = _t9 * _t8; - // CHECK-NEXT: _t7 = j; - // CHECK-NEXT: _t11 = _t10 * _t7; - // CHECK-NEXT: _t6 = 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 * _t6; - // CHECK-NEXT: double _r7 = _r6 * _t7; - // CHECK-NEXT: double _r8 = _r7 * _t8; - // CHECK-NEXT: double _r9 = _t9 * _r7; + // CHECK-NEXT: double _r6 = 1 * _t3; + // CHECK-NEXT: double _r7 = _r6 * _t4; + // CHECK-NEXT: double _r8 = _r7 * _t5; + // CHECK-NEXT: double _r9 = this->y * _r7; // CHECK-NEXT: jacobianMatrix[2UL] += _r9; - // CHECK-NEXT: double _r10 = _t10 * _r6; + // CHECK-NEXT: double _r10 = this->y * _t5 * _r6; // CHECK-NEXT: jacobianMatrix[3UL] += _r10; - // CHECK-NEXT: double _r11 = _t11 * 1; + // CHECK-NEXT: double _r11 = this->y * _t5 * _t4 * 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 _r3 = _t3 * _r1; + // CHECK-NEXT: double _r3 = this->x * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; - // CHECK-NEXT: double _r4 = _t4 * _r0; + // CHECK-NEXT: double _r4 = this->x * _t2 * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; - // CHECK-NEXT: double _r5 = _t5 * 1; + // CHECK-NEXT: double _r5 = this->x * _t2 * _t1 * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -331,36 +273,28 @@ namespace outer { // 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: _t2 = i; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t3 = _t2 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = i * i * j; - // CHECK-NEXT: _t6 = i; - // CHECK-NEXT: _t5 = j; - // CHECK-NEXT: _t7 = _t6 * _t5; - // CHECK-NEXT: _t4 = j; + // CHECK-NEXT: _t3 = j; + // CHECK-NEXT: _t2 = j; // CHECK-NEXT: output[1] = i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: double _r4 = 1 * _t4; - // CHECK-NEXT: double _r5 = _r4 * _t5; + // CHECK-NEXT: double _r4 = 1 * _t2; + // CHECK-NEXT: double _r5 = _r4 * _t3; // CHECK-NEXT: jacobianMatrix[2UL] += _r5; - // CHECK-NEXT: double _r6 = _t6 * _r4; + // CHECK-NEXT: double _r6 = i * _r4; // CHECK-NEXT: jacobianMatrix[3UL] += _r6; - // CHECK-NEXT: double _r7 = _t7 * 1; + // CHECK-NEXT: double _r7 = i * _t3 * 1; // CHECK-NEXT: jacobianMatrix[3UL] += _r7; // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: double _r1 = _r0 * _t1; // CHECK-NEXT: jacobianMatrix[0UL] += _r1; - // CHECK-NEXT: double _r2 = _t2 * _r0; + // CHECK-NEXT: double _r2 = i * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * _t1 * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -404,36 +338,28 @@ int main() { // 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: _t2 = i; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t3 = _t2 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = i * i * j; - // CHECK-NEXT: _t6 = i; - // CHECK-NEXT: _t5 = j; - // CHECK-NEXT: _t7 = _t6 * _t5; - // CHECK-NEXT: _t4 = j; + // CHECK-NEXT: _t3 = j; + // CHECK-NEXT: _t2 = j; // CHECK-NEXT: output[1] = i * j * j; // CHECK-NEXT: { - // CHECK-NEXT: double _r4 = 1 * _t4; - // CHECK-NEXT: double _r5 = _r4 * _t5; + // CHECK-NEXT: double _r4 = 1 * _t2; + // CHECK-NEXT: double _r5 = _r4 * _t3; // CHECK-NEXT: jacobianMatrix[2UL] += _r5; - // CHECK-NEXT: double _r6 = _t6 * _r4; + // CHECK-NEXT: double _r6 = i * _r4; // CHECK-NEXT: jacobianMatrix[3UL] += _r6; - // CHECK-NEXT: double _r7 = _t7 * 1; + // CHECK-NEXT: double _r7 = i * _t3 * 1; // CHECK-NEXT: jacobianMatrix[3UL] += _r7; // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: double _r1 = _r0 * _t1; // CHECK-NEXT: jacobianMatrix[0UL] += _r1; - // CHECK-NEXT: double _r2 = _t2 * _r0; + // CHECK-NEXT: double _r2 = i * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r2; - // CHECK-NEXT: double _r3 = _t3 * 1; + // CHECK-NEXT: double _r3 = i * _t1 * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r3; // CHECK-NEXT: } // CHECK-NEXT: } @@ -450,46 +376,34 @@ int main() { // 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 _t10; - // CHECK-NEXT: double _t11; - // CHECK-NEXT: _t3 = x; // CHECK-NEXT: _t2 = i; - // CHECK-NEXT: _t4 = _t3 * _t2; // CHECK-NEXT: _t1 = i; - // CHECK-NEXT: _t5 = _t4 * _t1; // CHECK-NEXT: _t0 = jj; // CHECK-NEXT: output[0] = x * i * i * jj; - // CHECK-NEXT: _t9 = y; - // CHECK-NEXT: _t8 = i; - // CHECK-NEXT: _t10 = _t9 * _t8; - // CHECK-NEXT: _t7 = jj; - // CHECK-NEXT: _t11 = _t10 * _t7; - // CHECK-NEXT: _t6 = 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 * _t6; - // CHECK-NEXT: double _r7 = _r6 * _t7; - // CHECK-NEXT: double _r8 = _r7 * _t8; - // CHECK-NEXT: double _r9 = _t9 * _r7; + // CHECK-NEXT: double _r6 = 1 * _t3; + // CHECK-NEXT: double _r7 = _r6 * _t4; + // CHECK-NEXT: double _r8 = _r7 * _t5; + // CHECK-NEXT: double _r9 = y * _r7; // CHECK-NEXT: jacobianMatrix[2UL] += _r9; - // CHECK-NEXT: double _r10 = _t10 * _r6; + // CHECK-NEXT: double _r10 = y * _t5 * _r6; // CHECK-NEXT: jacobianMatrix[3UL] += _r10; - // CHECK-NEXT: double _r11 = _t11 * 1; + // CHECK-NEXT: double _r11 = y * _t5 * _t4 * 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 _r3 = _t3 * _r1; + // CHECK-NEXT: double _r3 = x * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; - // CHECK-NEXT: double _r4 = _t4 * _r0; + // CHECK-NEXT: double _r4 = x * _t2 * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; - // CHECK-NEXT: double _r5 = _t5 * 1; + // CHECK-NEXT: double _r5 = x * _t2 * _t1 * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/Jacobian/Jacobian.C b/test/Jacobian/Jacobian.C index 0af0ada5a..d8b52062b 100644 --- a/test/Jacobian/Jacobian.C +++ b/test/Jacobian/Jacobian.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oJacobian.out 2>&1 | FileCheck %s // RUN: ./Jacobian.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oJacobian.out +// RUN: ./Jacobian.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -13,7 +15,7 @@ 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: f_1_jac(double a, double b, double c, double output[], double *jacobianMatrix) { +//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; @@ -23,66 +25,53 @@ void f_1_jac(double a, double b, double c, double output[], double *_result); //CHECK-NEXT: double _t6; //CHECK-NEXT: double _t7; //CHECK-NEXT: double _t8; -//CHECK-NEXT: double _t9; -//CHECK-NEXT: double _t10; -//CHECK-NEXT: double _t11; -//CHECK-NEXT: double _t12; -//CHECK-NEXT: double _t13; -//CHECK-NEXT: double _t14; -//CHECK-NEXT: double _t15; -//CHECK-NEXT: _t2 = a; //CHECK-NEXT: _t1 = a; -//CHECK-NEXT: _t3 = _t2 * _t1; //CHECK-NEXT: _t0 = a; //CHECK-NEXT: output[0] = a * a * a; -//CHECK-NEXT: _t6 = a; -//CHECK-NEXT: _t5 = a; -//CHECK-NEXT: _t7 = _t6 * _t5; -//CHECK-NEXT: _t4 = a; -//CHECK-NEXT: _t10 = b; -//CHECK-NEXT: _t9 = b; -//CHECK-NEXT: _t11 = _t10 * _t9; -//CHECK-NEXT: _t8 = b; +//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: _t13 = c; -//CHECK-NEXT: _t12 = c; -//CHECK-NEXT: _t15 = a; -//CHECK-NEXT: _t14 = a; +//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 * 10; -//CHECK-NEXT: double _r13 = _r12 * _t12; +//CHECK-NEXT: double _r12 = 1 * _t6; +//CHECK-NEXT: double _r13 = _r12 * _t7; //CHECK-NEXT: jacobianMatrix[8UL] += _r13; -//CHECK-NEXT: double _r14 = _t13 * _r12; +//CHECK-NEXT: double _r14 = c * _r12; //CHECK-NEXT: jacobianMatrix[8UL] += _r14; -//CHECK-NEXT: double _r15 = -1 * _t14; -//CHECK-NEXT: jacobianMatrix[6UL] += _r15; -//CHECK-NEXT: double _r16 = _t15 * -1; +//CHECK-NEXT: double _r15 = c * _t7 * 1; +//CHECK-NEXT: double _r16 = -1 * _t8; //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 * _t4; -//CHECK-NEXT: double _r5 = _r4 * _t5; +//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r5 = _r4 * _t3; //CHECK-NEXT: jacobianMatrix[3UL] += _r5; -//CHECK-NEXT: double _r6 = _t6 * _r4; +//CHECK-NEXT: double _r6 = a * _r4; //CHECK-NEXT: jacobianMatrix[3UL] += _r6; -//CHECK-NEXT: double _r7 = _t7 * 1; +//CHECK-NEXT: double _r7 = a * _t3 * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r7; -//CHECK-NEXT: double _r8 = 1 * _t8; -//CHECK-NEXT: double _r9 = _r8 * _t9; +//CHECK-NEXT: double _r8 = 1 * _t4; +//CHECK-NEXT: double _r9 = _r8 * _t5; //CHECK-NEXT: jacobianMatrix[4UL] += _r9; -//CHECK-NEXT: double _r10 = _t10 * _r8; +//CHECK-NEXT: double _r10 = b * _r8; //CHECK-NEXT: jacobianMatrix[4UL] += _r10; -//CHECK-NEXT: double _r11 = _t11 * 1; +//CHECK-NEXT: double _r11 = b * _t5 * 1; //CHECK-NEXT: jacobianMatrix[4UL] += _r11; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 * _t0; //CHECK-NEXT: double _r1 = _r0 * _t1; //CHECK-NEXT: jacobianMatrix[0UL] += _r1; -//CHECK-NEXT: double _r2 = _t2 * _r0; +//CHECK-NEXT: double _r2 = a * _r0; //CHECK-NEXT: jacobianMatrix[0UL] += _r2; -//CHECK-NEXT: double _r3 = _t3 * 1; +//CHECK-NEXT: double _r3 = a * _t1 * 1; //CHECK-NEXT: jacobianMatrix[0UL] += _r3; //CHECK-NEXT: } //CHECK-NEXT:} @@ -102,57 +91,43 @@ void f_3_jac(double x, double y, double z, double *_result, double *jacobianMatr //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: double constant = 42; -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t2 = sin(_t1); //CHECK-NEXT: _t0 = constant; //CHECK-NEXT: _result[0] = sin(x) * constant; -//CHECK-NEXT: _t4 = y; -//CHECK-NEXT: _t5 = sin(_t4); -//CHECK-NEXT: _t3 = constant; +//CHECK-NEXT: _t1 = constant; //CHECK-NEXT: _result[1] = sin(y) * constant; -//CHECK-NEXT: _t7 = z; -//CHECK-NEXT: _t8 = sin(_t7); -//CHECK-NEXT: _t6 = constant; +//CHECK-NEXT: _t2 = constant; //CHECK-NEXT: _result[2] = sin(z) * constant; //CHECK-NEXT: { -//CHECK-NEXT: double _r6 = 1 * _t6; -// CHECK-NEXT: double _r7 = _r6 * clad::custom_derivatives{{(::std)?}}::sin_pushforward(_t7, 1.).pushforward; +//CHECK-NEXT: double _r6 = 1 * _t2; +//CHECK-NEXT: double _r7 = _r6 * clad::custom_derivatives::sin_pushforward(z, 1.).pushforward; //CHECK-NEXT: jacobianMatrix[8UL] += _r7; -//CHECK-NEXT: double _r8 = _t8 * 1; +//CHECK-NEXT: double _r8 = sin(z) * 1; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r3 = 1 * _t3; -// CHECK-NEXT: double _r4 = _r3 * clad::custom_derivatives{{(::std)?}}::sin_pushforward(_t4, 1.).pushforward; +//CHECK-NEXT: double _r3 = 1 * _t1; +//CHECK-NEXT: double _r4 = _r3 * clad::custom_derivatives::sin_pushforward(y, 1.).pushforward; //CHECK-NEXT: jacobianMatrix[4UL] += _r4; -//CHECK-NEXT: double _r5 = _t5 * 1; +//CHECK-NEXT: double _r5 = sin(y) * 1; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 * _t0; -// CHECK-NEXT: double _r1 = _r0 * clad::custom_derivatives{{(::std)?}}::sin_pushforward(_t1, 1.).pushforward; +//CHECK-NEXT: double _r1 = _r0 * clad::custom_derivatives::sin_pushforward(x, 1.).pushforward; //CHECK-NEXT: jacobianMatrix[0UL] += _r1; -//CHECK-NEXT: double _r2 = _t2 * 1; +//CHECK-NEXT: double _r2 = sin(x) * 1; //CHECK-NEXT: } //CHECK-NEXT:} 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: double _t1; -//CHECK-NEXT: _t1 = x; //CHECK-NEXT: _t0 = y; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r0 = _d_y0 * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * _d_y0; +//CHECK-NEXT: double _r1 = x * _d_y0; //CHECK-NEXT: * _d_y += _r1; //CHECK-NEXT: } //CHECK-NEXT:} @@ -171,63 +146,45 @@ void f_4_jac(double x, double y, double z, double *_result, double *jacobianMatr //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: double _t9; -//CHECK-NEXT: double _t10; -//CHECK-NEXT: double _t11; //CHECK-NEXT: double constant = 42; -//CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t2 = y; -//CHECK-NEXT: _t3 = multiply(_t1, _t2); //CHECK-NEXT: _t0 = constant; //CHECK-NEXT: _result[0] = multiply(x, y) * constant; -//CHECK-NEXT: _t5 = y; -//CHECK-NEXT: _t6 = z; -//CHECK-NEXT: _t7 = multiply(_t5, _t6); -//CHECK-NEXT: _t4 = constant; +//CHECK-NEXT: _t1 = constant; //CHECK-NEXT: _result[1] = multiply(y, z) * constant; -//CHECK-NEXT: _t9 = z; -//CHECK-NEXT: _t10 = x; -//CHECK-NEXT: _t11 = multiply(_t9, _t10); -//CHECK-NEXT: _t8 = constant; +//CHECK-NEXT: _t2 = constant; //CHECK-NEXT: _result[2] = multiply(z, x) * constant; //CHECK-NEXT: { -//CHECK-NEXT: double _r8 = 1 * _t8; +//CHECK-NEXT: double _r8 = 1 * _t2; //CHECK-NEXT: double _jac4 = 0.; //CHECK-NEXT: double _jac5 = 0.; -//CHECK-NEXT: multiply_pullback(_t9, _t10, _r8, &_jac4, &_jac5); +//CHECK-NEXT: multiply_pullback(z, x, _r8, &_jac4, &_jac5); //CHECK-NEXT: double _r9 = _jac4; //CHECK-NEXT: jacobianMatrix[8UL] += _r9; //CHECK-NEXT: double _r10 = _jac5; //CHECK-NEXT: jacobianMatrix[6UL] += _r10; -//CHECK-NEXT: double _r11 = _t11 * 1; +//CHECK-NEXT: double _r11 = multiply(z, x) * 1; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t4; +//CHECK-NEXT: double _r4 = 1 * _t1; //CHECK-NEXT: double _jac2 = 0.; //CHECK-NEXT: double _jac3 = 0.; -//CHECK-NEXT: multiply_pullback(_t5, _t6, _r4, &_jac2, &_jac3); +//CHECK-NEXT: multiply_pullback(y, z, _r4, &_jac2, &_jac3); //CHECK-NEXT: double _r5 = _jac2; //CHECK-NEXT: jacobianMatrix[4UL] += _r5; //CHECK-NEXT: double _r6 = _jac3; //CHECK-NEXT: jacobianMatrix[5UL] += _r6; -//CHECK-NEXT: double _r7 = _t7 * 1; +//CHECK-NEXT: double _r7 = multiply(y, z) * 1; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 * _t0; //CHECK-NEXT: double _jac0 = 0.; //CHECK-NEXT: double _jac1 = 0.; -//CHECK-NEXT: multiply_pullback(_t1, _t2, _r0, &_jac0, &_jac1); +//CHECK-NEXT: multiply_pullback(x, y, _r0, &_jac0, &_jac1); //CHECK-NEXT: double _r1 = _jac0; //CHECK-NEXT: jacobianMatrix[0UL] += _r1; //CHECK-NEXT: double _r2 = _jac1; //CHECK-NEXT: jacobianMatrix[1UL] += _r2; -//CHECK-NEXT: double _r3 = _t3 * 1; +//CHECK-NEXT: double _r3 = multiply(x, y) * 1; //CHECK-NEXT: } //CHECK-NEXT:} @@ -244,61 +201,48 @@ void f_1_jac_0(double a, double b, double c, double output[], double *jacobianMa // CHECK-NEXT: double _t6; // CHECK-NEXT: double _t7; // CHECK-NEXT: double _t8; -// CHECK-NEXT: double _t9; -// CHECK-NEXT: double _t10; -// CHECK-NEXT: double _t11; -// CHECK-NEXT: double _t12; -// CHECK-NEXT: double _t13; -// CHECK-NEXT: double _t14; -// CHECK-NEXT: double _t15; -// CHECK-NEXT: _t2 = a; // CHECK-NEXT: _t1 = a; -// CHECK-NEXT: _t3 = _t2 * _t1; // CHECK-NEXT: _t0 = a; // CHECK-NEXT: output[0] = a * a * a; -// CHECK-NEXT: _t6 = a; -// CHECK-NEXT: _t5 = a; -// CHECK-NEXT: _t7 = _t6 * _t5; -// CHECK-NEXT: _t4 = a; -// CHECK-NEXT: _t10 = b; -// CHECK-NEXT: _t9 = b; -// CHECK-NEXT: _t11 = _t10 * _t9; -// CHECK-NEXT: _t8 = b; +// 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: _t13 = c; -// CHECK-NEXT: _t12 = c; -// CHECK-NEXT: _t15 = a; -// CHECK-NEXT: _t14 = a; +// 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 * 10; -// CHECK-NEXT: double _r13 = _r12 * _t12; -// CHECK-NEXT: double _r14 = _t13 * _r12; -// CHECK-NEXT: double _r15 = -1 * _t14; -// CHECK-NEXT: jacobianMatrix[2UL] += _r15; -// CHECK-NEXT: double _r16 = _t15 * -1; +// CHECK-NEXT: double _r12 = 1 * _t6; +// CHECK-NEXT: double _r13 = _r12 * _t7; +// CHECK-NEXT: double _r14 = c * _r12; +// CHECK-NEXT: double _r15 = c * _t7 * 1; +// CHECK-NEXT: double _r16 = -1 * _t8; // 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 * _t4; -// CHECK-NEXT: double _r5 = _r4 * _t5; +// CHECK-NEXT: double _r4 = 1 * _t2; +// CHECK-NEXT: double _r5 = _r4 * _t3; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; -// CHECK-NEXT: double _r6 = _t6 * _r4; +// CHECK-NEXT: double _r6 = a * _r4; // CHECK-NEXT: jacobianMatrix[1UL] += _r6; -// CHECK-NEXT: double _r7 = _t7 * 1; +// CHECK-NEXT: double _r7 = a * _t3 * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r7; -// CHECK-NEXT: double _r8 = 1 * _t8; -// CHECK-NEXT: double _r9 = _r8 * _t9; -// CHECK-NEXT: double _r10 = _t10 * _r8; -// CHECK-NEXT: double _r11 = _t11 * 1; +// CHECK-NEXT: double _r8 = 1 * _t4; +// CHECK-NEXT: double _r9 = _r8 * _t5; +// CHECK-NEXT: double _r10 = b * _r8; +// CHECK-NEXT: double _r11 = b * _t5 * 1; // CHECK-NEXT: } // CHECK-NEXT: { // CHECK-NEXT: double _r0 = 1 * _t0; // CHECK-NEXT: double _r1 = _r0 * _t1; // CHECK-NEXT: jacobianMatrix[0UL] += _r1; -// CHECK-NEXT: double _r2 = _t2 * _r0; +// CHECK-NEXT: double _r2 = a * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r2; -// CHECK-NEXT: double _r3 = _t3 * 1; +// CHECK-NEXT: double _r3 = a * _t1 * 1; // CHECK-NEXT: jacobianMatrix[0UL] += _r3; // CHECK-NEXT: } // CHECK-NEXT:} diff --git a/test/Jacobian/Pointers.C b/test/Jacobian/Pointers.C index 9629d7975..3245aaed8 100644 --- a/test/Jacobian/Pointers.C +++ b/test/Jacobian/Pointers.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oPointers.out 2>&1 | FileCheck %s // RUN: ./Pointers.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oPointers.out +// RUN: ./Pointers.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" diff --git a/test/Jacobian/TemplateFunctors.C b/test/Jacobian/TemplateFunctors.C index 2c206bc34..3486b9280 100644 --- a/test/Jacobian/TemplateFunctors.C +++ b/test/Jacobian/TemplateFunctors.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oTemplateFunctors.out 2>&1 | FileCheck %s // RUN: ./TemplateFunctors.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oTemplateFunctors.out +// RUN: ./TemplateFunctors.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -22,47 +24,35 @@ template struct Experiment { // 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 _t10; -// CHECK-NEXT: double _t11; -// CHECK-NEXT: double _t12; -// CHECK-NEXT: _t3 = this->x; // CHECK-NEXT: _t2 = this->y; -// CHECK-NEXT: _t4 = _t3 * _t2; // CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t5 = _t4 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * this->y * i * j; -// CHECK-NEXT: _t9 = this->x; -// CHECK-NEXT: _t10 = 2 * _t9; -// CHECK-NEXT: _t8 = this->y; -// CHECK-NEXT: _t11 = _t10 * _t8; -// CHECK-NEXT: _t7 = i; -// CHECK-NEXT: _t12 = _t11 * _t7; -// CHECK-NEXT: _t6 = 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 * _t6; -// CHECK-NEXT: double _r7 = _r6 * _t7; -// CHECK-NEXT: double _r8 = _r7 * _t8; -// CHECK-NEXT: double _r9 = _r8 * _t9; +// 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 _r10 = 2 * _r8; -// CHECK-NEXT: double _r11 = _t10 * _r7; -// CHECK-NEXT: double _r12 = _t11 * _r6; +// CHECK-NEXT: double _r11 = 2 * _t6 * _r7; +// CHECK-NEXT: double _r12 = 2 * _t6 * _t5 * _r6; // CHECK-NEXT: jacobianMatrix[2UL] += _r12; -// CHECK-NEXT: double _r13 = _t12 * 1; +// CHECK-NEXT: double _r13 = 2 * _t6 * _t5 * _t4 * 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 _r3 = _t3 * _r1; -// CHECK-NEXT: double _r4 = _t4 * _r0; +// CHECK-NEXT: double _r3 = this->x * _r1; +// CHECK-NEXT: double _r4 = this->x * _t2 * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r4; -// CHECK-NEXT: double _r5 = _t5 * 1; +// CHECK-NEXT: double _r5 = this->x * _t2 * _t1 * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r5; // CHECK-NEXT: } // CHECK-NEXT: } @@ -87,46 +77,30 @@ template <> struct Experiment { // CHECK-NEXT: long double _t6; // CHECK-NEXT: long double _t7; // CHECK-NEXT: long double _t8; -// CHECK-NEXT: long double _t9; -// CHECK-NEXT: long double _t10; -// CHECK-NEXT: long double _t11; -// CHECK-NEXT: long double _t12; -// CHECK-NEXT: long double _t13; -// CHECK-NEXT: long double _t14; -// CHECK-NEXT: long double _t15; -// CHECK-NEXT: long double _t16; -// CHECK-NEXT: _t4 = this->x; // CHECK-NEXT: _t3 = this->y; -// CHECK-NEXT: _t5 = _t4 * _t3; // CHECK-NEXT: _t2 = i; -// CHECK-NEXT: _t6 = _t5 * _t2; // CHECK-NEXT: _t1 = i; -// CHECK-NEXT: _t7 = _t6 * _t1; // CHECK-NEXT: _t0 = j; // CHECK-NEXT: output[0] = this->x * this->y * i * i * j; -// CHECK-NEXT: _t12 = this->x; -// CHECK-NEXT: _t13 = 2 * _t12; -// CHECK-NEXT: _t11 = this->y; -// CHECK-NEXT: _t14 = _t13 * _t11; -// CHECK-NEXT: _t10 = i; -// CHECK-NEXT: _t15 = _t14 * _t10; -// CHECK-NEXT: _t9 = i; -// CHECK-NEXT: _t16 = _t15 * _t9; -// CHECK-NEXT: _t8 = 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 * _t8; -// CHECK-NEXT: long double _r9 = _r8 * _t9; -// CHECK-NEXT: long double _r10 = _r9 * _t10; -// CHECK-NEXT: long double _r11 = _r10 * _t11; -// CHECK-NEXT: long double _r12 = _r11 * _t12; +// 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 _r13 = 2 * _r11; -// CHECK-NEXT: long double _r14 = _t13 * _r10; -// CHECK-NEXT: long double _r15 = _t14 * _r9; +// CHECK-NEXT: long double _r14 = 2 * _t8 * _r10; +// CHECK-NEXT: long double _r15 = 2 * _t8 * _t7 * _r9; // CHECK-NEXT: jacobianMatrix[2UL] += _r15; -// CHECK-NEXT: long double _r16 = _t15 * _r8; +// CHECK-NEXT: long double _r16 = 2 * _t8 * _t7 * _t6 * _r8; // CHECK-NEXT: jacobianMatrix[2UL] += _r16; -// CHECK-NEXT: long double _r17 = _t16 * 1; +// CHECK-NEXT: long double _r17 = 2 * _t8 * _t7 * _t6 * _t5 * 1; // CHECK-NEXT: jacobianMatrix[3UL] += _r17; // CHECK-NEXT: } // CHECK-NEXT: { @@ -134,12 +108,12 @@ template <> struct Experiment { // 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 _r4 = _t4 * _r2; -// CHECK-NEXT: long double _r5 = _t5 * _r1; +// CHECK-NEXT: long double _r4 = this->x * _r2; +// CHECK-NEXT: long double _r5 = this->x * _t3 * _r1; // CHECK-NEXT: jacobianMatrix[0UL] += _r5; -// CHECK-NEXT: long double _r6 = _t6 * _r0; +// CHECK-NEXT: long double _r6 = this->x * _t3 * _t2 * _r0; // CHECK-NEXT: jacobianMatrix[0UL] += _r6; -// CHECK-NEXT: long double _r7 = _t7 * 1; +// CHECK-NEXT: long double _r7 = this->x * _t3 * _t2 * _t1 * 1; // CHECK-NEXT: jacobianMatrix[1UL] += _r7; // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/Jacobian/constexprTest.C b/test/Jacobian/constexprTest.C index 8fa166511..68f9579f6 100644 --- a/test/Jacobian/constexprTest.C +++ b/test/Jacobian/constexprTest.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -std=c++14 -oconstexprTest.out 2>&1 | FileCheck %s // RUN: ./constexprTest.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -std=c++14 -oconstexprTest.out +// RUN: ./constexprTest.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -21,34 +23,28 @@ constexpr void fn_mul(double i, double j, double *res) { //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: _t1 = i; //CHECK-NEXT: _t0 = i; //CHECK-NEXT: res[0] = i * i; -//CHECK-NEXT: _t3 = j; -//CHECK-NEXT: _t2 = j; +//CHECK-NEXT: _t1 = j; //CHECK-NEXT: res[1] = j * j; -//CHECK-NEXT: _t5 = i; -//CHECK-NEXT: _t4 = j; +//CHECK-NEXT: _t2 = j; //CHECK-NEXT: res[2] = i * j; //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t4; +//CHECK-NEXT: double _r4 = 1 * _t2; //CHECK-NEXT: jacobianMatrix[4UL] += _r4; -//CHECK-NEXT: double _r5 = _t5 * 1; +//CHECK-NEXT: double _r5 = i * 1; //CHECK-NEXT: jacobianMatrix[5UL] += _r5; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r2 = 1 * _t2; +//CHECK-NEXT: double _r2 = 1 * _t1; //CHECK-NEXT: jacobianMatrix[3UL] += _r2; -//CHECK-NEXT: double _r3 = _t3 * 1; +//CHECK-NEXT: double _r3 = j * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r3; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 * _t0; //CHECK-NEXT: jacobianMatrix[0UL] += _r0; -//CHECK-NEXT: double _r1 = _t1 * 1; +//CHECK-NEXT: double _r1 = i * 1; //CHECK-NEXT: jacobianMatrix[0UL] += _r1; //CHECK-NEXT: } //CHECK-NEXT:} @@ -69,66 +65,53 @@ constexpr void f_1(double x, double y, double z, double output[]) { //CHECK-NEXT: double _t6; //CHECK-NEXT: double _t7; //CHECK-NEXT: double _t8; -//CHECK-NEXT: double _t9; -//CHECK-NEXT: double _t10; -//CHECK-NEXT: double _t11; -//CHECK-NEXT: double _t12; -//CHECK-NEXT: double _t13; -//CHECK-NEXT: double _t14; -//CHECK-NEXT: double _t15; -//CHECK-NEXT: _t2 = x; //CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t3 = _t2 * _t1; //CHECK-NEXT: _t0 = x; //CHECK-NEXT: output[0] = x * x * x; -//CHECK-NEXT: _t6 = x; -//CHECK-NEXT: _t5 = y; -//CHECK-NEXT: _t7 = _t6 * _t5; +//CHECK-NEXT: _t3 = y; +//CHECK-NEXT: _t2 = x; +//CHECK-NEXT: _t5 = x; //CHECK-NEXT: _t4 = x; -//CHECK-NEXT: _t10 = y; -//CHECK-NEXT: _t9 = x; -//CHECK-NEXT: _t11 = _t10 * _t9; -//CHECK-NEXT: _t8 = x; //CHECK-NEXT: output[1] = x * y * x + y * x * x; -//CHECK-NEXT: _t13 = z; -//CHECK-NEXT: _t12 = x; -//CHECK-NEXT: _t15 = y; -//CHECK-NEXT: _t14 = z; +//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 * 10; -//CHECK-NEXT: double _r13 = _r12 * _t12; +//CHECK-NEXT: double _r12 = 1 * _t6; +//CHECK-NEXT: double _r13 = _r12 * _t7; //CHECK-NEXT: jacobianMatrix[8UL] += _r13; -//CHECK-NEXT: double _r14 = _t13 * _r12; +//CHECK-NEXT: double _r14 = z * _r12; //CHECK-NEXT: jacobianMatrix[6UL] += _r14; -//CHECK-NEXT: double _r15 = -1 * _t14; -//CHECK-NEXT: jacobianMatrix[7UL] += _r15; -//CHECK-NEXT: double _r16 = _t15 * -1; -//CHECK-NEXT: jacobianMatrix[8UL] += _r16; +//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: } //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t4; -//CHECK-NEXT: double _r5 = _r4 * _t5; +//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r5 = _r4 * _t3; //CHECK-NEXT: jacobianMatrix[3UL] += _r5; -//CHECK-NEXT: double _r6 = _t6 * _r4; +//CHECK-NEXT: double _r6 = x * _r4; //CHECK-NEXT: jacobianMatrix[4UL] += _r6; -//CHECK-NEXT: double _r7 = _t7 * 1; +//CHECK-NEXT: double _r7 = x * _t3 * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r7; -//CHECK-NEXT: double _r8 = 1 * _t8; -//CHECK-NEXT: double _r9 = _r8 * _t9; +//CHECK-NEXT: double _r8 = 1 * _t4; +//CHECK-NEXT: double _r9 = _r8 * _t5; //CHECK-NEXT: jacobianMatrix[4UL] += _r9; -//CHECK-NEXT: double _r10 = _t10 * _r8; +//CHECK-NEXT: double _r10 = y * _r8; //CHECK-NEXT: jacobianMatrix[3UL] += _r10; -//CHECK-NEXT: double _r11 = _t11 * 1; +//CHECK-NEXT: double _r11 = y * _t5 * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r11; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 * _t0; //CHECK-NEXT: double _r1 = _r0 * _t1; //CHECK-NEXT: jacobianMatrix[0UL] += _r1; -//CHECK-NEXT: double _r2 = _t2 * _r0; +//CHECK-NEXT: double _r2 = x * _r0; //CHECK-NEXT: jacobianMatrix[0UL] += _r2; -//CHECK-NEXT: double _r3 = _t3 * 1; +//CHECK-NEXT: double _r3 = x * _t1 * 1; //CHECK-NEXT: jacobianMatrix[0UL] += _r3; //CHECK-NEXT: } //CHECK-NEXT:} diff --git a/test/Jacobian/testUtility.C b/test/Jacobian/testUtility.C index 9919e7095..a3e404d6b 100644 --- a/test/Jacobian/testUtility.C +++ b/test/Jacobian/testUtility.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -otestUtility.out 2>&1 | FileCheck %s // RUN: ./testUtility.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -otestUtility.out +// RUN: ./testUtility.out | FileCheck -check-prefix=CHECK-EXEC %s // CHECK-NOT: {{.*error|warning|note:.*}} #include "clad/Differentiator/Differentiator.h" @@ -21,34 +23,28 @@ void fn_mul(double i, double j, double *res) { //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: _t1 = i; //CHECK-NEXT: _t0 = i; //CHECK-NEXT: res[0] = i * i; -//CHECK-NEXT: _t3 = j; -//CHECK-NEXT: _t2 = j; +//CHECK-NEXT: _t1 = j; //CHECK-NEXT: res[1] = j * j; -//CHECK-NEXT: _t5 = i; -//CHECK-NEXT: _t4 = j; +//CHECK-NEXT: _t2 = j; //CHECK-NEXT: res[2] = i * j; //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t4; +//CHECK-NEXT: double _r4 = 1 * _t2; //CHECK-NEXT: jacobianMatrix[4UL] += _r4; -//CHECK-NEXT: double _r5 = _t5 * 1; +//CHECK-NEXT: double _r5 = i * 1; //CHECK-NEXT: jacobianMatrix[5UL] += _r5; //CHECK-NEXT: } //CHECK-NEXT: { -//CHECK-NEXT: double _r2 = 1 * _t2; +//CHECK-NEXT: double _r2 = 1 * _t1; //CHECK-NEXT: jacobianMatrix[3UL] += _r2; -//CHECK-NEXT: double _r3 = _t3 * 1; +//CHECK-NEXT: double _r3 = j * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r3; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 * _t0; //CHECK-NEXT: jacobianMatrix[0UL] += _r0; -//CHECK-NEXT: double _r1 = _t1 * 1; +//CHECK-NEXT: double _r1 = i * 1; //CHECK-NEXT: jacobianMatrix[0UL] += _r1; //CHECK-NEXT: } //CHECK-NEXT:} @@ -70,66 +66,53 @@ void f_1(double x, double y, double z, double output[]) { //CHECK-NEXT: double _t6; //CHECK-NEXT: double _t7; //CHECK-NEXT: double _t8; -//CHECK-NEXT: double _t9; -//CHECK-NEXT: double _t10; -//CHECK-NEXT: double _t11; -//CHECK-NEXT: double _t12; -//CHECK-NEXT: double _t13; -//CHECK-NEXT: double _t14; -//CHECK-NEXT: double _t15; -//CHECK-NEXT: _t2 = x; //CHECK-NEXT: _t1 = x; -//CHECK-NEXT: _t3 = _t2 * _t1; //CHECK-NEXT: _t0 = x; //CHECK-NEXT: output[0] = x * x * x; -//CHECK-NEXT: _t6 = x; -//CHECK-NEXT: _t5 = y; -//CHECK-NEXT: _t7 = _t6 * _t5; +//CHECK-NEXT: _t3 = y; +//CHECK-NEXT: _t2 = x; +//CHECK-NEXT: _t5 = x; //CHECK-NEXT: _t4 = x; -//CHECK-NEXT: _t10 = y; -//CHECK-NEXT: _t9 = x; -//CHECK-NEXT: _t11 = _t10 * _t9; -//CHECK-NEXT: _t8 = x; //CHECK-NEXT: output[1] = x * y * x + y * x * x; -//CHECK-NEXT: _t13 = z; -//CHECK-NEXT: _t12 = x; -//CHECK-NEXT: _t15 = y; -//CHECK-NEXT: _t14 = z; +//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 * 10; -//CHECK-NEXT: double _r13 = _r12 * _t12; +//CHECK-NEXT: double _r12 = 1 * _t6; +//CHECK-NEXT: double _r13 = _r12 * _t7; //CHECK-NEXT: jacobianMatrix[8UL] += _r13; -//CHECK-NEXT: double _r14 = _t13 * _r12; +//CHECK-NEXT: double _r14 = z * _r12; //CHECK-NEXT: jacobianMatrix[6UL] += _r14; -//CHECK-NEXT: double _r15 = -1 * _t14; -//CHECK-NEXT: jacobianMatrix[7UL] += _r15; -//CHECK-NEXT: double _r16 = _t15 * -1; -//CHECK-NEXT: jacobianMatrix[8UL] += _r16; +//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: } //CHECK-NEXT: { -//CHECK-NEXT: double _r4 = 1 * _t4; -//CHECK-NEXT: double _r5 = _r4 * _t5; +//CHECK-NEXT: double _r4 = 1 * _t2; +//CHECK-NEXT: double _r5 = _r4 * _t3; //CHECK-NEXT: jacobianMatrix[3UL] += _r5; -//CHECK-NEXT: double _r6 = _t6 * _r4; +//CHECK-NEXT: double _r6 = x * _r4; //CHECK-NEXT: jacobianMatrix[4UL] += _r6; -//CHECK-NEXT: double _r7 = _t7 * 1; +//CHECK-NEXT: double _r7 = x * _t3 * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r7; -//CHECK-NEXT: double _r8 = 1 * _t8; -//CHECK-NEXT: double _r9 = _r8 * _t9; +//CHECK-NEXT: double _r8 = 1 * _t4; +//CHECK-NEXT: double _r9 = _r8 * _t5; //CHECK-NEXT: jacobianMatrix[4UL] += _r9; -//CHECK-NEXT: double _r10 = _t10 * _r8; +//CHECK-NEXT: double _r10 = y * _r8; //CHECK-NEXT: jacobianMatrix[3UL] += _r10; -//CHECK-NEXT: double _r11 = _t11 * 1; +//CHECK-NEXT: double _r11 = y * _t5 * 1; //CHECK-NEXT: jacobianMatrix[3UL] += _r11; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: double _r0 = 1 * _t0; //CHECK-NEXT: double _r1 = _r0 * _t1; //CHECK-NEXT: jacobianMatrix[0UL] += _r1; -//CHECK-NEXT: double _r2 = _t2 * _r0; +//CHECK-NEXT: double _r2 = x * _r0; //CHECK-NEXT: jacobianMatrix[0UL] += _r2; -//CHECK-NEXT: double _r3 = _t3 * 1; +//CHECK-NEXT: double _r3 = x * _t1 * 1; //CHECK-NEXT: jacobianMatrix[0UL] += _r3; //CHECK-NEXT: } //CHECK-NEXT:} diff --git a/test/Misc/RunDemos.C b/test/Misc/RunDemos.C index 04adfaef8..9cd585f92 100644 --- a/test/Misc/RunDemos.C +++ b/test/Misc/RunDemos.C @@ -111,12 +111,14 @@ //CHECK_FLOAT_SUM: float _EERepl_sum0; //CHECK_FLOAT_SUM: unsigned long _t0; //CHECK_FLOAT_SUM: unsigned int _d_i = 0; +//CHECK_FLOAT_SUM: clad::tape _t1 = {}; //CHECK_FLOAT_SUM: clad::tape _EERepl_sum1 = {}; //CHECK_FLOAT_SUM: float sum = 0.; //CHECK_FLOAT_SUM: _EERepl_sum0 = sum; //CHECK_FLOAT_SUM: _t0 = 0; //CHECK_FLOAT_SUM: for (unsigned int i = 0; i < n; i++) { //CHECK_FLOAT_SUM: _t0++; +//CHECK_FLOAT_SUM: clad::push(_t1, sum); //CHECK_FLOAT_SUM: sum = sum + x; //CHECK_FLOAT_SUM: clad::push(_EERepl_sum1, sum); //CHECK_FLOAT_SUM: } @@ -124,19 +126,21 @@ //CHECK_FLOAT_SUM: _label0: //CHECK_FLOAT_SUM: _d_sum += 1; //CHECK_FLOAT_SUM: for (; _t0; _t0--) { +//CHECK_FLOAT_SUM: i--; //CHECK_FLOAT_SUM: { +//CHECK_FLOAT_SUM: sum = clad::pop(_t1); //CHECK_FLOAT_SUM: float _r_d0 = _d_sum; //CHECK_FLOAT_SUM: _d_sum += _r_d0; //CHECK_FLOAT_SUM: * _d_x += _r_d0; //CHECK_FLOAT_SUM: float _r0 = clad::pop(_EERepl_sum1); -//CHECK_FLOAT_SUM: _delta_sum += std::abs(_r_d0 * _r0 * {{.+}}); +//CHECK_FLOAT_SUM: _delta_sum += std::abs(_r_d0 * _r0 * 1.1920928955078125E-7); //CHECK_FLOAT_SUM: _d_sum -= _r_d0; //CHECK_FLOAT_SUM: } //CHECK_FLOAT_SUM: } -//CHECK_FLOAT_SUM: _delta_sum += std::abs(_d_sum * _EERepl_sum0 * {{.+}}); +//CHECK_FLOAT_SUM: _delta_sum += std::abs(_d_sum * _EERepl_sum0 * 1.1920928955078125E-7); //CHECK_FLOAT_SUM: double _delta_x = 0; -//CHECK_FLOAT_SUM: _delta_x += std::abs(* _d_x * x * {{.+}}); -//CHECK_FLOAT_SUM: _final_error += _delta_{{x|sum}} + _delta_{{x|sum}}; +//CHECK_FLOAT_SUM: _delta_x += std::abs(* _d_x * x * 1.1920928955078125E-7); +//CHECK_FLOAT_SUM: _final_error += _delta_x + _delta_sum; //CHECK_FLOAT_SUM: } //-----------------------------------------------------------------------------/ @@ -156,15 +160,18 @@ // CHECK_CUSTOM_MODEL_EXEC-NEXT: float _d_z = 0; // CHECK_CUSTOM_MODEL_EXEC-NEXT: double _delta_z = 0; // CHECK_CUSTOM_MODEL_EXEC-NEXT: float _EERepl_z0; +// CHECK_CUSTOM_MODEL_EXEC-NEXT: float _t0; // CHECK_CUSTOM_MODEL_EXEC-NEXT: float _EERepl_z1; // CHECK_CUSTOM_MODEL_EXEC-NEXT: float z; // CHECK_CUSTOM_MODEL_EXEC-NEXT: _EERepl_z0 = z; +// CHECK_CUSTOM_MODEL_EXEC-NEXT: _t0 = z; // CHECK_CUSTOM_MODEL_EXEC-NEXT: z = x + y; // CHECK_CUSTOM_MODEL_EXEC-NEXT: _EERepl_z1 = z; // CHECK_CUSTOM_MODEL_EXEC-NEXT: goto _label0; // CHECK_CUSTOM_MODEL_EXEC-NEXT: _label0: // CHECK_CUSTOM_MODEL_EXEC-NEXT: _d_z += 1; // CHECK_CUSTOM_MODEL_EXEC-NEXT: { +// CHECK_CUSTOM_MODEL_EXEC-NEXT: z = _t0; // CHECK_CUSTOM_MODEL_EXEC-NEXT: float _r_d0 = _d_z; // CHECK_CUSTOM_MODEL_EXEC-NEXT: * _d_x += _r_d0; // CHECK_CUSTOM_MODEL_EXEC-NEXT: * _d_y += _r_d0; @@ -227,8 +234,6 @@ //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: double _t1; -//CHECK_GRADIENT_DESCENT-NEXT: _t1 = theta_1; //CHECK_GRADIENT_DESCENT-NEXT: _t0 = x; //CHECK_GRADIENT_DESCENT-NEXT: goto _label0; //CHECK_GRADIENT_DESCENT-NEXT: _label0: @@ -236,31 +241,23 @@ //CHECK_GRADIENT_DESCENT-NEXT: * _d_theta_0 += _d_y; //CHECK_GRADIENT_DESCENT-NEXT: double _r0 = _d_y * _t0; //CHECK_GRADIENT_DESCENT-NEXT: * _d_theta_1 += _r0; -//CHECK_GRADIENT_DESCENT-NEXT: double _r1 = _t1 * _d_y; +//CHECK_GRADIENT_DESCENT-NEXT: double _r1 = theta_1 * _d_y; //CHECK_GRADIENT_DESCENT-NEXT: * _d_x += _r1; //CHECK_GRADIENT_DESCENT-NEXT: } //CHECK_GRADIENT_DESCENT-NEXT: } //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 _t0; -//CHECK_GRADIENT_DESCENT-NEXT: double _t1; -//CHECK_GRADIENT_DESCENT-NEXT: double _t2; //CHECK_GRADIENT_DESCENT-NEXT: double _d_f_x = 0; -//CHECK_GRADIENT_DESCENT-NEXT: double _t3; -//CHECK_GRADIENT_DESCENT-NEXT: double _t4; -//CHECK_GRADIENT_DESCENT-NEXT: _t0 = theta_0; -//CHECK_GRADIENT_DESCENT-NEXT: _t1 = theta_1; -//CHECK_GRADIENT_DESCENT-NEXT: _t2 = x; -//CHECK_GRADIENT_DESCENT-NEXT: double f_x = f(_t0, _t1, _t2); -//CHECK_GRADIENT_DESCENT-NEXT: _t4 = (f_x - y); -//CHECK_GRADIENT_DESCENT-NEXT: _t3 = (f_x - y); +//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 * _t3; +//CHECK_GRADIENT_DESCENT-NEXT: double _r3 = 1 * _t0; //CHECK_GRADIENT_DESCENT-NEXT: _d_f_x += _r3; //CHECK_GRADIENT_DESCENT-NEXT: * _d_y += -_r3; -//CHECK_GRADIENT_DESCENT-NEXT: double _r4 = _t4 * 1; +//CHECK_GRADIENT_DESCENT-NEXT: double _r4 = (f_x - y) * 1; //CHECK_GRADIENT_DESCENT-NEXT: _d_f_x += _r4; //CHECK_GRADIENT_DESCENT-NEXT: * _d_y += -_r4; //CHECK_GRADIENT_DESCENT-NEXT: } @@ -268,7 +265,7 @@ //CHECK_GRADIENT_DESCENT-NEXT: double _grad0 = 0.; //CHECK_GRADIENT_DESCENT-NEXT: double _grad1 = 0.; //CHECK_GRADIENT_DESCENT-NEXT: double _grad2 = 0.; -//CHECK_GRADIENT_DESCENT-NEXT: f_pullback(_t0, _t1, _t2, _d_f_x, &_grad0, &_grad1, &_grad2); +//CHECK_GRADIENT_DESCENT-NEXT: f_pullback(theta_0, theta_1, x, _d_f_x, &_grad0, &_grad1, &_grad2); //CHECK_GRADIENT_DESCENT-NEXT: double _r0 = _grad0; //CHECK_GRADIENT_DESCENT-NEXT: * _d_theta_0 += _r0; //CHECK_GRADIENT_DESCENT-NEXT: double _r1 = _grad1; diff --git a/test/NestedCalls/NestedCalls.C b/test/NestedCalls/NestedCalls.C index bf2725a2d..91d82811e 100644 --- a/test/NestedCalls/NestedCalls.C +++ b/test/NestedCalls/NestedCalls.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oNestedCalls.out 2>&1 | FileCheck %s // RUN: ./NestedCalls.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oNestedCalls.out +// RUN: ./NestedCalls.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -39,64 +41,50 @@ double f(double x, double y) { //CHECK: void sq_pullback(double x, double _d_y, clad::array_ref _d_x) { //CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: _t1 = x; //CHECK-NEXT: _t0 = x; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _r0 = _d_y * _t0; //CHECK-NEXT: * _d_x += _r0; -//CHECK-NEXT: double _r1 = _t1 * _d_y; +//CHECK-NEXT: double _r1 = x * _d_y; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: } //CHECK-NEXT: } //CHECK: void one_pullback(double x, double _d_y, clad::array_ref _d_x) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: double _t3; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: _t1 = std::sin(_t0); -//CHECK-NEXT: _t2 = x; -//CHECK-NEXT: _t3 = std::cos(_t2); //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: double _grad0 = 0.; -//CHECK-NEXT: sq_pullback(_t1, _d_y, &_grad0); +//CHECK-NEXT: sq_pullback(std::sin(x), _d_y, &_grad0); //CHECK-NEXT: double _r0 = _grad0; -//CHECK-NEXT: double _r1 = _r0 * clad::custom_derivatives::sin_pushforward(_t0, 1.).pushforward; +//CHECK-NEXT: double _r1 = _r0 * clad::custom_derivatives::sin_pushforward(x, 1.).pushforward; //CHECK-NEXT: * _d_x += _r1; //CHECK-NEXT: double _grad1 = 0.; -//CHECK-NEXT: sq_pullback(_t3, _d_y, &_grad1); +//CHECK-NEXT: sq_pullback(std::cos(x), _d_y, &_grad1); //CHECK-NEXT: double _r2 = _grad1; -//CHECK-NEXT: double _r3 = _r2 * clad::custom_derivatives::cos_pushforward(_t2, 1.).pushforward; +//CHECK-NEXT: double _r3 = _r2 * clad::custom_derivatives::cos_pushforward(x, 1.).pushforward; //CHECK-NEXT: * _d_x += _r3; //CHECK-NEXT: } //CHECK-NEXT: } //CHECK: void f_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: double _t1; -//CHECK-NEXT: double _t2; -//CHECK-NEXT: _t0 = x; -//CHECK-NEXT: double t = one(_t0); -//CHECK-NEXT: _t2 = t; -//CHECK-NEXT: _t1 = y; +//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 * _t1; +//CHECK-NEXT: double _r1 = 1 * _t0; //CHECK-NEXT: _d_t += _r1; -//CHECK-NEXT: double _r2 = _t2 * 1; +//CHECK-NEXT: double _r2 = t * 1; //CHECK-NEXT: * _d_y += _r2; //CHECK-NEXT: } //CHECK-NEXT: { //CHECK-NEXT: double _grad0 = 0.; -//CHECK-NEXT: one_pullback(_t0, _d_t, &_grad0); +//CHECK-NEXT: one_pullback(x, _d_t, &_grad0); //CHECK-NEXT: double _r0 = _grad0; //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: } diff --git a/test/NumericalDiff/GradientMultiArg.C b/test/NumericalDiff/GradientMultiArg.C index 3a3b19c78..5270965d0 100644 --- a/test/NumericalDiff/GradientMultiArg.C +++ b/test/NumericalDiff/GradientMultiArg.C @@ -1,5 +1,7 @@ // RUN: %cladnumdiffclang %s -I%S/../../include -oGradientMultiArg.out 2>&1 | FileCheck -check-prefix=CHECK %s // RUN: ./GradientMultiArg.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladnumdiffclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oGradientMultiArg.out +// RUN: ./GradientMultiArg.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -13,19 +15,15 @@ double test_1(double x, double y){ } // CHECK: warning: Falling back to numerical differentiation for 'hypot' since no suitable overload was found and clad could not derive it. To disable this feature, compile your programs with -DCLAD_NO_NUM_DIFF. // CHECK: void test_1_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 _grad0 = 0.; // CHECK-NEXT: double _grad1 = 0.; -// CHECK-NEXT: clad::tape > _t2 = {}; -// CHECK-NEXT: clad::push(_t2, &_grad0); -// CHECK-NEXT: clad::push(_t2, &_grad1); -// CHECK-NEXT: numerical_diff::central_difference(std::hypot, _t2, 0, _t0, _t1); +// CHECK-NEXT: clad::tape > _t0 = {}; +// CHECK-NEXT: clad::push(_t0, &_grad0); +// CHECK-NEXT: clad::push(_t0, &_grad1); +// CHECK-NEXT: numerical_diff::central_difference(std::hypot, _t0, 0, x, y); // CHECK-NEXT: double _r0 = 1 * _grad0; // CHECK-NEXT: * _d_x += _r0; // CHECK-NEXT: double _r1 = 1 * _grad1; diff --git a/test/NumericalDiff/NoNumDiff.C b/test/NumericalDiff/NoNumDiff.C index b7a8dc091..76749de86 100644 --- a/test/NumericalDiff/NoNumDiff.C +++ b/test/NumericalDiff/NoNumDiff.C @@ -16,8 +16,6 @@ double func(double x) { return std::tanh(x); } //CHECK-NEXT: } //CHECK: void func_grad(double x, clad::array_ref _d_x) { -//CHECK-NEXT: double _t0; -//CHECK-NEXT: _t0 = x; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { diff --git a/test/NumericalDiff/NumDiff.C b/test/NumericalDiff/NumDiff.C index d05a05080..e4d46f263 100644 --- a/test/NumericalDiff/NumDiff.C +++ b/test/NumericalDiff/NumDiff.C @@ -11,12 +11,10 @@ double test_1(double x){ //CHECK: warning: Falling back to numerical differentiation for 'log10' since no suitable overload was found and clad could not derive it. To disable this feature, compile your programs with -DCLAD_NO_NUM_DIFF. //CHECK: void test_1_grad(double x, 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 = 1 * numerical_diff::forward_central_difference(tanh, _t0, 0, 0, _t0); +//CHECK-NEXT: double _r0 = 1 * numerical_diff::forward_central_difference(tanh, x, 0, 0, x); //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: } //CHECK-NEXT: } diff --git a/test/NumericalDiff/PrintErrorNumDiff.C b/test/NumericalDiff/PrintErrorNumDiff.C index a1f93531f..4d1cf069e 100644 --- a/test/NumericalDiff/PrintErrorNumDiff.C +++ b/test/NumericalDiff/PrintErrorNumDiff.C @@ -1,5 +1,7 @@ // RUN: %cladnumdiffclang -Xclang -plugin-arg-clad -Xclang -fprint-num-diff-errors %s -I%S/../../include -oPrintErrorNumDiff.out 2>&1 | FileCheck -check-prefix=CHECK %s -// -Xclang -verify 2>&1 RUN: ./PrintErrorNumDiff.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: ./PrintErrorNumDiff.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladnumdiffclang -Xclang -plugin-arg-clad -Xclang -fprint-num-diff-errors -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oPrintErrorNumDiff.out +// RUN: ./PrintErrorNumDiff.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -15,12 +17,10 @@ double test_1(double x){ //CHECK: warning: Falling back to numerical differentiation for 'tanh' since no suitable overload was found and clad could not derive it. To disable this feature, compile your programs with -DCLAD_NO_NUM_DIFF. //CHECK: void test_1_grad(double x, 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 = 1 * numerical_diff::forward_central_difference(tanh, _t0, 0, 1, _t0); +//CHECK-NEXT: double _r0 = 1 * numerical_diff::forward_central_difference(tanh, x, 0, 1, x); //CHECK-NEXT: * _d_x += _r0; //CHECK-NEXT: } //CHECK-NEXT: } diff --git a/test/ROOT/Hessian.C b/test/ROOT/Hessian.C index c7ca79325..9fc21d0a0 100644 --- a/test/ROOT/Hessian.C +++ b/test/ROOT/Hessian.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oHessian.out 2>&1 | FileCheck %s // RUN: ./Hessian.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oHessian.out +// RUN: ./Hessian.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} diff --git a/test/ROOT/Interface.C b/test/ROOT/Interface.C index 31261c07c..53da1e5eb 100644 --- a/test/ROOT/Interface.C +++ b/test/ROOT/Interface.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oInterface.out 2>&1 | FileCheck %s // RUN: ./Interface.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oInterface.out +// RUN: ./Interface.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -22,15 +24,13 @@ 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: Double_t _t1; -// CHECK-NEXT: _t1 = x[0]; // 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}} _r1 = _t1 * 1; +// CHECK-NEXT: {{double|Double_t}} _r1 = x[0] * 1; // CHECK-NEXT: _d_p[1] += _r1; // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/test/ROOT/TFormula.C b/test/ROOT/TFormula.C index ba53c4d3d..cd443ef41 100644 --- a/test/ROOT/TFormula.C +++ b/test/ROOT/TFormula.C @@ -1,5 +1,7 @@ // RUN: %cladclang %s -I%S/../../include -oTFormula.out 2>&1 | FileCheck %s // RUN: ./TFormula.out | FileCheck -check-prefix=CHECK-EXEC %s +// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oTFormula.out +// RUN: ./TFormula.out | FileCheck -check-prefix=CHECK-EXEC %s //CHECK-NOT: {{.*error|warning|note:.*}} @@ -40,24 +42,18 @@ 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: Double_t _t1; -//CHECK-NEXT: Double_t _t2; -//CHECK-NEXT: Double_t _t3; -//CHECK-NEXT: _t1 = x[0]; //CHECK-NEXT: _t0 = (p[0] + p[1] + p[2]); -//CHECK-NEXT: _t2 = -p[0]; -//CHECK-NEXT: _t3 = p[1]; //CHECK-NEXT: goto _label0; //CHECK-NEXT: _label0: //CHECK-NEXT: { //CHECK-NEXT: {{double|Double_t}} _r0 = 1 * _t0; -//CHECK-NEXT: {{double|Double_t}} _r1 = _t1 * 1; +//CHECK-NEXT: {{double|Double_t}} _r1 = x[0] * 1; //CHECK-NEXT: _d_p[0] += _r1; //CHECK-NEXT: _d_p[1] += _r1; //CHECK-NEXT: _d_p[2] += _r1; -//CHECK-NEXT: Double_t _r2 = 1 * clad::custom_derivatives{{(::std)?}}::TMath::Exp_pushforward(_t2, 1.).pushforward; +//CHECK-NEXT: Double_t _r2 = 1 * clad::custom_derivatives{{(::std)?}}::TMath::Exp_pushforward(-p[0], 1.).pushforward; //CHECK-NEXT: _d_p[0] += -_r2; -//CHECK-NEXT: Double_t _r3 = 1 * clad::custom_derivatives{{(::std)?}}::TMath::Abs_pushforward(_t3, 1.).pushforward; +//CHECK-NEXT: Double_t _r3 = 1 * clad::custom_derivatives{{(::std)?}}::TMath::Abs_pushforward(p[1], 1.).pushforward; //CHECK-NEXT: _d_p[1] += _r3; //CHECK-NEXT: } //CHECK-NEXT: }