diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-02-17 00:12:29 +0100 |
|---|---|---|
| committer | Christopher Li <sparse@chrisli.org> | 2017-02-23 08:04:19 +0800 |
| commit | 5265109dabc72cf7694b3ca9da456c832076aa00 (patch) | |
| tree | 4b40519707e0d62bf1c1ceb5f0db597461979528 /validation/optim | |
| parent | 60ba2df1de54fa7da812aecf282ca14d39916bae (diff) | |
| download | sparse-dev-5265109dabc72cf7694b3ca9da456c832076aa00.tar.gz | |
CSE: use commutativity to identify equivalent instructions
By definition a commutative operation give the same result if its
operands are exchanged.
CSE can use this property when comparing instructions to find
more equivalent instructions and thus eliminate more of them..
Implement this by special-casing commutative ops in insn_compare().
Note: this come for free when all instructions are properly
canonicalized, which is not yet the case.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'validation/optim')
| -rw-r--r-- | validation/optim/cse-commutativity.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/validation/optim/cse-commutativity.c b/validation/optim/cse-commutativity.c new file mode 100644 index 00000000..82603478 --- /dev/null +++ b/validation/optim/cse-commutativity.c @@ -0,0 +1,22 @@ +static int add(int a, int b) { return (a + b) == (b + a); } +static int mul(int a, int b) { return (a * b) == (b * a); } +static int and(int a, int b) { return (a & b) == (b & a); } +static int ior(int a, int b) { return (a | b) == (b | a); } +static int xor(int a, int b) { return (a ^ b) == (b ^ a); } +static int eq(int a, int b) { return (a == b) == (b == a); } +static int ne(int a, int b) { return (a != b) == (b != a); } + + +/* + * check-name: cse-commutativity + * check-command: test-linearize $file + * check-output-ignore + * + * check-output-excludes: add\\. + * check-output-excludes: muls\\. + * check-output-excludes: and\\. + * check-output-excludes: or\\. + * check-output-excludes: xor\\. + * check-output-excludes: seteq\\. + * check-output-excludes: setne\\. + */ |
