diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-08-18 19:12:08 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-08-22 09:26:18 +0200 |
| commit | e65784bc11f85d5e14693e3686b3e76cd1327103 (patch) | |
| tree | e96d4f215eec529087e76bc82984a8e7442c6ac1 /validation/optim | |
| parent | c05b1caa7c81b945526b77e84b888f48cfa91780 (diff) | |
| download | sparse-dev-e65784bc11f85d5e14693e3686b3e76cd1327103.tar.gz | |
add testcases for {LSR,SHL}(AND(x, M), S) with shared AND(x, M)
The pattern LSR(AND(x, M), S) is already generically simplified into
((x >> S) & (M >> S)) but only if the sub-expression AND(x, M) is not
shared with some other expressions because the simplification modify it.
But for some special cases the expression can be simplified even if
the sub-expression is shared because the simplification doesn't need
to modify this AND(x, M) part.
Add the testcases for LSR and the incoming SHL.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/optim')
| -rw-r--r-- | validation/optim/lsr-and0.c | 14 | ||||
| -rw-r--r-- | validation/optim/lsr-and1.c | 19 | ||||
| -rw-r--r-- | validation/optim/shl-and0.c | 14 | ||||
| -rw-r--r-- | validation/optim/shl-and1.c | 19 |
4 files changed, 66 insertions, 0 deletions
diff --git a/validation/optim/lsr-and0.c b/validation/optim/lsr-and0.c new file mode 100644 index 00000000..292c0332 --- /dev/null +++ b/validation/optim/lsr-and0.c @@ -0,0 +1,14 @@ +unsigned lsr_and0(unsigned x) +{ + unsigned t = (x & 0x00000fff); + return (t >> 12) & t; +} + +/* + * check-name: lsr-and0 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: ret\\..*\\$0$ + */ diff --git a/validation/optim/lsr-and1.c b/validation/optim/lsr-and1.c new file mode 100644 index 00000000..e2eb5059 --- /dev/null +++ b/validation/optim/lsr-and1.c @@ -0,0 +1,19 @@ +// If (t >> S) is simplified into (x >> S) +// then the whole expression will be 0. +// The test is only interesting if the sub-expression +// (x & M) is referenced more than once +// (because otherwise other simplifications apply). +unsigned lsr_and1(unsigned x) +{ + unsigned t = (x & 0xfffff000); + return ((t >> 12) ^ (x >> 12)) & t; +} + +/* + * check-name: lsr-and1 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: ret\\..*\\$0$ + */ diff --git a/validation/optim/shl-and0.c b/validation/optim/shl-and0.c new file mode 100644 index 00000000..289859ae --- /dev/null +++ b/validation/optim/shl-and0.c @@ -0,0 +1,14 @@ +unsigned shl_and0(unsigned x) +{ + unsigned t = (x & 0xfff00000); + return (t << 12) & t; +} + +/* + * check-name: shl-and0 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: ret\\..*\\$0$ + */ diff --git a/validation/optim/shl-and1.c b/validation/optim/shl-and1.c new file mode 100644 index 00000000..5f4fdcb1 --- /dev/null +++ b/validation/optim/shl-and1.c @@ -0,0 +1,19 @@ +// If (t << S) is simplified into (x << S) +// then the whole expression will be 0. +// The test is only interesting if the sub-expression +// (x & M) is referenced more than once +// (because otherwise other simplifications apply). +unsigned shl_and1(unsigned x) +{ + unsigned t = (x & 0x000fffff); + return ((t << 12) ^ (x << 12)) & t; +} + +/* + * check-name: shl-and1 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: ret\\..*\\$0$ + */ |
