Skip to content

Commit

Permalink
Fix Gradient/Switch test on i586
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailMihov committed Mar 19, 2024
1 parent a94f791 commit a072044
Showing 1 changed file with 41 additions and 42 deletions.
83 changes: 41 additions & 42 deletions test/Gradient/Switch.C
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// RUN: %cladclang %s -I%S/../../include -oSwitch.out 2>&1 -lstdc++ -lm | FileCheck %s
// RUN: ./Switch.out | FileCheck -check-prefix=CHECK-EXEC %s
//CHECK-NOT: {{.*error|warning|note:.*}}
// XFAIL: target={{i586.*}}

#include "clad/Differentiator/Differentiator.h"
#include "../TestUtils.h"
Expand All @@ -24,7 +23,7 @@ double fn1(double i, double j) {
// CHECK-NEXT: int _d_count = 0;
// CHECK-NEXT: int _cond0;
// CHECK-NEXT: double _t0;
// CHECK-NEXT: clad::tape<unsigned long> _t1 = {};
// CHECK-NEXT: clad::tape<unsigned {{int|long}}> _t1 = {};
// CHECK-NEXT: double _t2;
// CHECK-NEXT: double _t3;
// CHECK-NEXT: double _t4;
Expand All @@ -39,7 +38,7 @@ double fn1(double i, double j) {
// CHECK-NEXT: _t0 = res;
// CHECK-NEXT: }
// CHECK-NEXT: {
// CHECK-NEXT: clad::push(_t1, 1UL);
// CHECK-NEXT: clad::push(_t1, {{1U|1UL}});
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: {
Expand All @@ -59,15 +58,15 @@ double fn1(double i, double j) {
// CHECK-NEXT: res += i * i * j * j;
// CHECK-NEXT: _t4 = res;
// CHECK-NEXT: }
// CHECK-NEXT: clad::push(_t1, 2UL);
// CHECK-NEXT: clad::push(_t1, {{2U|2UL}});
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: _d_res += 1;
// CHECK-NEXT: {
// CHECK-NEXT: switch (clad::pop(_t1)) {
// CHECK-NEXT: case 2UL:
// CHECK-NEXT: case {{2U|2UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: {
// CHECK-NEXT: {
Expand Down Expand Up @@ -103,7 +102,7 @@ double fn1(double i, double j) {
// CHECK-NEXT: if (1 == _cond0)
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: case 1UL:
// CHECK-NEXT: case {{1U|1UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: {
// CHECK-NEXT: {
Expand Down Expand Up @@ -140,7 +139,7 @@ double fn2(double i, double j) {
// CHECK-NEXT: double _t0;
// CHECK-NEXT: double _t1;
// CHECK-NEXT: double _t2;
// CHECK-NEXT: clad::tape<unsigned long> _t3 = {};
// CHECK-NEXT: clad::tape<unsigned {{int|long}}> _t3 = {};
// CHECK-NEXT: double _t4;
// CHECK-NEXT: double _t5;
// CHECK-NEXT: double _t6;
Expand All @@ -159,7 +158,7 @@ double fn2(double i, double j) {
// CHECK-NEXT: _t2 = res;
// CHECK-NEXT: }
// CHECK-NEXT: {
// CHECK-NEXT: clad::push(_t3, 1UL);
// CHECK-NEXT: clad::push(_t3, {{1U|1UL}});
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: {
Expand All @@ -173,23 +172,23 @@ double fn2(double i, double j) {
// CHECK-NEXT: _t5 = res;
// CHECK-NEXT: }
// CHECK-NEXT: {
// CHECK-NEXT: clad::push(_t3, 2UL);
// CHECK-NEXT: clad::push(_t3, {{2U|2UL}});
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: {
// CHECK-NEXT: default:
// CHECK-NEXT: res += i + j;
// CHECK-NEXT: _t6 = res;
// CHECK-NEXT: }
// CHECK-NEXT: clad::push(_t3, 3UL);
// CHECK-NEXT: clad::push(_t3, {{3U|3UL}});
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: _d_res += 1;
// CHECK-NEXT: {
// CHECK-NEXT: switch (clad::pop(_t3)) {
// CHECK-NEXT: case 3UL:
// CHECK-NEXT: case {{3U|3UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: {
// CHECK-NEXT: {
Expand All @@ -201,7 +200,7 @@ double fn2(double i, double j) {
// CHECK-NEXT: if (_cond0 != 0 && _cond0 != 1 && _cond0 != 2)
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: case 2UL:
// CHECK-NEXT: case {{2U|2UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: {
// CHECK-NEXT: {
Expand All @@ -222,7 +221,7 @@ double fn2(double i, double j) {
// CHECK-NEXT: if (1 == _cond0)
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: case 1UL:
// CHECK-NEXT: case {{1U|1UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: {
// CHECK-NEXT: {
Expand Down Expand Up @@ -269,11 +268,11 @@ double fn3(double i, double j) {
// CHECK: void fn3_grad(double i, double j, clad::array_ref<double> _d_i, clad::array_ref<double> _d_j) {
// CHECK-NEXT: double _d_res = 0;
// CHECK-NEXT: int _d_counter = 0;
// CHECK-NEXT: unsigned long _t0;
// CHECK-NEXT: unsigned {{int|long}} _t0;
// CHECK-NEXT: clad::tape<int> _cond0 = {};
// CHECK-NEXT: clad::tape<double> _t1 = {};
// CHECK-NEXT: clad::tape<double> _t2 = {};
// CHECK-NEXT: clad::tape<unsigned long> _t3 = {};
// CHECK-NEXT: clad::tape<unsigned {{int|long}}> _t3 = {};
// CHECK-NEXT: clad::tape<double> _t4 = {};
// CHECK-NEXT: clad::tape<double> _t5 = {};
// CHECK-NEXT: double res = 0;
Expand All @@ -297,7 +296,7 @@ double fn3(double i, double j) {
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: {
// CHECK-NEXT: clad::push(_t3, 1UL);
// CHECK-NEXT: clad::push(_t3, {{1U|1UL}});
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: {
Expand All @@ -310,7 +309,7 @@ double fn3(double i, double j) {
// CHECK-NEXT: res += i + j;
// CHECK-NEXT: clad::push(_t5, res);
// CHECK-NEXT: }
// CHECK-NEXT: clad::push(_t3, 2UL);
// CHECK-NEXT: clad::push(_t3, {{2U|2UL}});
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
Expand All @@ -322,7 +321,7 @@ double fn3(double i, double j) {
// CHECK-NEXT: {
// CHECK-NEXT: {
// CHECK-NEXT: switch (clad::pop(_t3)) {
// CHECK-NEXT: case 2UL:
// CHECK-NEXT: case {{2U|2UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: {
// CHECK-NEXT: {
Expand All @@ -344,7 +343,7 @@ double fn3(double i, double j) {
// CHECK-NEXT: if (2 == clad::back(_cond0))
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: case 1UL:
// CHECK-NEXT: case {{1U|1UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: {
// CHECK-NEXT: {
Expand Down Expand Up @@ -395,10 +394,10 @@ double fn4(double i, double j) {
// CHECK: void fn4_grad(double i, double j, clad::array_ref<double> _d_i, clad::array_ref<double> _d_j) {
// CHECK-NEXT: double _d_res = 0;
// CHECK-NEXT: double _t0;
// CHECK-NEXT: clad::tape<unsigned long> _t1 = {};
// CHECK-NEXT: clad::tape<unsigned {{int|long}}> _t1 = {};
// CHECK-NEXT: int _d_counter = 0;
// CHECK-NEXT: int counter = 0;
// CHECK-NEXT: unsigned long _t2;
// CHECK-NEXT: unsigned {{int|long}} _t2;
// CHECK-NEXT: clad::tape<double> _t3 = {};
// CHECK-NEXT: double res = 0;
// CHECK-NEXT: {
Expand All @@ -409,7 +408,7 @@ double fn4(double i, double j) {
// CHECK-NEXT: _t0 = res;
// CHECK-NEXT: }
// CHECK-NEXT: {
// CHECK-NEXT: clad::push(_t1, 1UL);
// CHECK-NEXT: clad::push(_t1, {{1U|1UL}});
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: {
Expand All @@ -424,20 +423,20 @@ double fn4(double i, double j) {
// CHECK-NEXT: res += i * j;
// CHECK-NEXT: }
// CHECK-NEXT: {
// CHECK-NEXT: clad::push(_t1, 2UL);
// CHECK-NEXT: clad::push(_t1, {{2U|2UL}});
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: clad::push(_t1, 3UL);
// CHECK-NEXT: clad::push(_t1, {{3U|3UL}});
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: _d_res += 1;
// CHECK-NEXT: {
// CHECK-NEXT: switch (clad::pop(_t1)) {
// CHECK-NEXT: case 3UL:
// CHECK-NEXT: case {{3U|3UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: case 2UL:
// CHECK-NEXT: case {{2U|2UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: while (_t2)
// CHECK-NEXT: {
Expand All @@ -455,7 +454,7 @@ double fn4(double i, double j) {
// CHECK-NEXT: if (1 == 1)
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: case 1UL:
// CHECK-NEXT: case {{1U|1UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: {
// CHECK-NEXT: {
Expand Down Expand Up @@ -487,7 +486,7 @@ double fn5(double i, double j) {
// CHECK-NEXT: int count = 0;
// CHECK-NEXT: int _cond0;
// CHECK-NEXT: double _t0;
// CHECK-NEXT: clad::tape<unsigned long> _t1 = {};
// CHECK-NEXT: clad::tape<unsigned {{int|long}}> _t1 = {};
// CHECK-NEXT: double res = 0;
// CHECK-NEXT: {
// CHECK-NEXT: count = 1;
Expand All @@ -496,15 +495,15 @@ double fn5(double i, double j) {
// CHECK-NEXT: case 1:
// CHECK-NEXT: res += i * j;
// CHECK-NEXT: _t0 = res;
// CHECK-NEXT: clad::push(_t1, 1UL);
// CHECK-NEXT: clad::push(_t1, {{1U|1UL}});
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: _d_res += 1;
// CHECK-NEXT: {
// CHECK-NEXT: switch (clad::pop(_t1)) {
// CHECK-NEXT: case 1UL:
// CHECK-NEXT: case {{1U|1UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: {
// CHECK-NEXT: res = _t0;
Expand Down Expand Up @@ -534,7 +533,7 @@ double fn6(double u, double v) {
// CHECK-NEXT: int _t0;
// CHECK-NEXT: int _cond0;
// CHECK-NEXT: double _t1;
// CHECK-NEXT: clad::tape<unsigned long> _t2 = {};
// CHECK-NEXT: clad::tape<unsigned {{int|long}}> _t2 = {};
// CHECK-NEXT: int res = 0;
// CHECK-NEXT: double temp = 0;
// CHECK-NEXT: {
Expand All @@ -547,15 +546,15 @@ double fn6(double u, double v) {
// CHECK-NEXT: temp = 1;
// CHECK-NEXT: _t1 = temp;
// CHECK-NEXT: }
// CHECK-NEXT: clad::push(_t2, 1UL);
// CHECK-NEXT: clad::push(_t2, {{1U|1UL}});
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: goto _label0;
// CHECK-NEXT: _label0:
// CHECK-NEXT: _d_res += 1;
// CHECK-NEXT: {
// CHECK-NEXT: switch (clad::pop(_t2)) {
// CHECK-NEXT: case 1UL:
// CHECK-NEXT: case {{1U|1UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: {
// CHECK-NEXT: {
Expand Down Expand Up @@ -597,12 +596,12 @@ double fn7(double u, double v) {

// CHECK: void fn7_grad(double u, double v, clad::array_ref<double> _d_u, clad::array_ref<double> _d_v) {
// CHECK-NEXT: double _d_res = 0;
// CHECK-NEXT: unsigned long _t0;
// CHECK-NEXT: unsigned {{int|long}} _t0;
// CHECK-NEXT: int _d_i = 0;
// CHECK-NEXT: int i = 0;
// CHECK-NEXT: clad::tape<int> _cond0 = {};
// CHECK-NEXT: clad::tape<double> _t1 = {};
// CHECK-NEXT: clad::tape<unsigned long> _t2 = {};
// CHECK-NEXT: clad::tape<unsigned {{int|long}}> _t2 = {};
// CHECK-NEXT: clad::tape<double> _t3 = {};
// CHECK-NEXT: double res = 0;
// CHECK-NEXT: _t0 = 0;
Expand All @@ -622,7 +621,7 @@ double fn7(double u, double v) {
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: {
// CHECK-NEXT: clad::push(_t2, 1UL);
// CHECK-NEXT: clad::push(_t2, {{1U|1UL}});
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: {
Expand All @@ -634,10 +633,10 @@ double fn7(double u, double v) {
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: {
// CHECK-NEXT: clad::push(_t2, 2UL);
// CHECK-NEXT: clad::push(_t2, {{2U|2UL}});
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: clad::push(_t2, 3UL);
// CHECK-NEXT: clad::push(_t2, {{3U|3UL}});
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
Expand All @@ -648,9 +647,9 @@ double fn7(double u, double v) {
// CHECK-NEXT: --i;
// CHECK-NEXT: {
// CHECK-NEXT: switch (clad::pop(_t2)) {
// CHECK-NEXT: case 3UL:
// CHECK-NEXT: case {{3U|3UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: case 2UL:
// CHECK-NEXT: case {{2U|2UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: {
// CHECK-NEXT: {
Expand All @@ -665,7 +664,7 @@ double fn7(double u, double v) {
// CHECK-NEXT: if (3 == clad::back(_cond0))
// CHECK-NEXT: break;
// CHECK-NEXT: }
// CHECK-NEXT: case 1UL:
// CHECK-NEXT: case {{1U|1UL}}:
// CHECK-NEXT: ;
// CHECK-NEXT: {
// CHECK-NEXT: {
Expand Down Expand Up @@ -714,4 +713,4 @@ int main() {

TEST_GRADIENT(fn6, 2, 3, 5, &result[0], &result[1]); // CHECK-EXEC: {5.00, 3.00}
TEST_GRADIENT(fn7, 2, 3, 5, &result[0], &result[1]); // CHECK-EXEC: {3.00, 2.00}
}
}

0 comments on commit a072044

Please sign in to comment.