diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-01 00:52:36 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-20 22:35:43 +0200 |
| commit | 4afcbe027c4f0571568ac00c7a7e086589001c9d (patch) | |
| tree | 5c2807730b38c703e452887b0831640f33ce9d9c | |
| parent | 3d82d5de0425045a745ab6e8b8a7d0e7f804008d (diff) | |
| download | sparse-dev-4afcbe027c4f0571568ac00c7a7e086589001c9d.tar.gz | |
sub: canonicalize (0 - x) into -x
Not really a simplification in itself but it make some other
simplification a little easier (already because there is one
argument less to be matched).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | simplify.c | 4 | ||||
| -rw-r--r-- | validation/optim/simplify-zero-sub.c | 1 |
2 files changed, 4 insertions, 1 deletions
@@ -1174,6 +1174,10 @@ static int simplify_constant_leftside(struct instruction *insn) if (!value) return replace_with_pseudo(insn, insn->src1); return 0; + case OP_SUB: + if (!value) // (0 - x) --> -x + return replace_with_unop(insn, OP_NEG, insn->src2); + break; } return 0; } diff --git a/validation/optim/simplify-zero-sub.c b/validation/optim/simplify-zero-sub.c index cc8fe7a3..70ce7c90 100644 --- a/validation/optim/simplify-zero-sub.c +++ b/validation/optim/simplify-zero-sub.c @@ -3,7 +3,6 @@ int zero_sub(int x) { return 0 - x; } /* * check-name: simplify-zero-sub * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-contains: neg\\..* %arg1 |
