diff options
Diffstat (limited to 'validation/optim')
| -rw-r--r-- | validation/optim/bool-eq0.c | 12 | ||||
| -rw-r--r-- | validation/optim/bool-ne0.c | 12 | ||||
| -rw-r--r-- | validation/optim/bool-neq0.c | 12 | ||||
| -rw-r--r-- | validation/optim/canonical-add.c | 55 | ||||
| -rw-r--r-- | validation/optim/canonical-mul.c | 24 | ||||
| -rw-r--r-- | validation/optim/volatile-store00.c | 27 |
6 files changed, 142 insertions, 0 deletions
diff --git a/validation/optim/bool-eq0.c b/validation/optim/bool-eq0.c new file mode 100644 index 00000000..dbc93d95 --- /dev/null +++ b/validation/optim/bool-eq0.c @@ -0,0 +1,12 @@ +int beq0(int a) { return a == 0; } +int bnotne0(int a) { return !(a != 0); } +int bnot(int a) { return !a; } + +/* + * check-name: bool-eq0 + * check-command: test-linearize -Wno-decl $file + * check-output-ignore + * + * check-output-excludes: setne\\. + * check-output-contains: seteq\\. + */ diff --git a/validation/optim/bool-ne0.c b/validation/optim/bool-ne0.c new file mode 100644 index 00000000..b8206f6c --- /dev/null +++ b/validation/optim/bool-ne0.c @@ -0,0 +1,12 @@ +int bne0(int a) { return a != 0; } +int bnoteq0(int a) { return !(a == 0); } +int bnotnot(int a) { return !(!a); } + +/* + * check-name: bool-ne0 + * check-command: test-linearize -Wno-decl $file + * check-output-ignore + * + * check-output-excludes: seteq\\. + * check-output-contains: setne\\. + */ diff --git a/validation/optim/bool-neq0.c b/validation/optim/bool-neq0.c new file mode 100644 index 00000000..d6ad7aec --- /dev/null +++ b/validation/optim/bool-neq0.c @@ -0,0 +1,12 @@ +int bneq0(int a) { return a != 0; } +int bnoteq0(int a) { return !(a == 0); } +int bnotnot(int a) { return !(!a); } + +/* + * check-name: bool-neq0 + * check-command: test-linearize -Wno-decl $file + * check-output-ignore + * + * check-output-excludes: seteq\\. + * check-output-contains: setne\\. + */ diff --git a/validation/optim/canonical-add.c b/validation/optim/canonical-add.c new file mode 100644 index 00000000..b7035e4c --- /dev/null +++ b/validation/optim/canonical-add.c @@ -0,0 +1,55 @@ +int xpc_add_ypc(int x, int y) +{ + return (x + 1) + (y + 1); +} + +int xmc_add_ypc(int x, int y) +{ + return (x - 1) + (y + 1); +} + +int xpc_add_ymc(int x, int y) +{ + return (x + 1) + (y - 1); +} + +int xmc_add_ymc(int x, int y) +{ + return (x - 1) + (y - 1); +} + +int xpc_sub_ypc(int x, int y) +{ + return (x + 1) - (y + 1); +} + +int xmc_sub_ypc(int x, int y) +{ + return (x - 1) - (y + 1); +} + +int xpc_sub_ymc(int x, int y) +{ + return (x + 1) - (y - 1); +} + +int xmc_sub_ymc(int x, int y) +{ + return (x - 1) - (y - 1); +} + +/* + * check-name: canonical-add + * check-description: + * 1) verify that constants in add/sub chains are + * pushed at the right of the whole chain. + * For example '(a + 1) + b' must be canonicalized into '(a + b) + 1' + * This is needed for '(a + 1) + b - 1' to be simplified into '(a + b)' + * + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * check-output-ignore + + * check-output-excludes: \$1 + * check-output-excludes: \$-1 + */ diff --git a/validation/optim/canonical-mul.c b/validation/optim/canonical-mul.c new file mode 100644 index 00000000..90d59f2e --- /dev/null +++ b/validation/optim/canonical-mul.c @@ -0,0 +1,24 @@ +#define uint unsigned int + +uint xtc_umul_ytc(uint x, uint y) { return (x * 3) * (y * 2); } + +/* + * check-name: canonical-muldiv + * check-description: + * 1) verify that constants in mul chains are + * pushed at the right of the whole chain. + * For example '(a * 3) * b' must be canonicalized into '(a * b) * 1' + * This is needed in general for constant simplification; + * for example, for: + * '(a * 3) * (b * 2)' + * to be simplified into: + * '(a * b) * 6' + * + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * check-output-ignore + * + * check-output-excludes: \$3 + * check-output-excludes: \$2 + * check-output-contains: \$6 + */ diff --git a/validation/optim/volatile-store00.c b/validation/optim/volatile-store00.c new file mode 100644 index 00000000..451eefa1 --- /dev/null +++ b/validation/optim/volatile-store00.c @@ -0,0 +1,27 @@ +void foo(volatile int *p) +{ + *p = 0; + *p = 0; +} + +void bar(void) +{ + extern volatile int i; + i = 0; + i = 0; +} + + +void baz(void) +{ + volatile int i; + i = 0; + i = 0; +} + +/* + * check-name: keep volatile stores + * check-command: test-linearize -Wno-decl -fdump-ir=final $file + * check-output-ignore + * check-output-pattern(6): store\\. + */ |
