diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-08-07 11:14:37 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-08-17 08:51:05 +0200 |
| commit | 3a729e93ba9f435855f0ca0cccafaa0c1648fb84 (patch) | |
| tree | 107bdb3d45f57efdcc2cacfff9095bd936b53247 | |
| parent | 1d5acb58b0a45183b80fc45423a93bd38d448d0d (diff) | |
| download | sparse-dev-3a729e93ba9f435855f0ca0cccafaa0c1648fb84.tar.gz | |
simplify ((x >> S) << S)
The simplification of ((x << S) >> S) was already added
but its dual was forgotten.
Add it now.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | simplify.c | 7 | ||||
| -rw-r--r-- | validation/optim/shl-lsr0.c | 1 |
2 files changed, 7 insertions, 1 deletions
@@ -683,6 +683,13 @@ static int simplify_shift(struct instruction *insn, pseudo_t pseudo, long long v if (value >= size) goto zero; switch(DEF_OPCODE(def, pseudo)) { + case OP_LSR: + // replace ((x >> S) << S) + // by (x & (-1 << S)) + if (def->src2 != insn->src2) + break; + mask = bits_mask(insn->size - value) << value; + goto replace_mask; case OP_SHL: case_shift_shift: // also for LSR - LSR if (def == insn) // cyclic DAG! diff --git a/validation/optim/shl-lsr0.c b/validation/optim/shl-lsr0.c index 851f6284..fc2561bd 100644 --- a/validation/optim/shl-lsr0.c +++ b/validation/optim/shl-lsr0.c @@ -6,7 +6,6 @@ unsigned mask(unsigned x) /* * check-name: shl-lsr0 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-contains: and\\..*0xffff8000 |
