diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-06-02 19:13:16 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-07-23 01:40:31 +0200 |
| commit | 9fb59b83b936e16ec1fd600e68cd3cf9f1048fbe (patch) | |
| tree | d0745ca38636a929b75197fb0905e40caf3e5309 | |
| parent | 9ac79ec0a88f4f39c90ecab252773b261c9e9721 (diff) | |
| download | sparse-dev-9fb59b83b936e16ec1fd600e68cd3cf9f1048fbe.tar.gz | |
big-shift: simplify over-sized OP_SHLs
In the mathematical sense, the result of a left-shift by an
amount bigger than the operand size equals zero.
Do the corresponding simplification.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | simplify.c | 2 | ||||
| -rw-r--r-- | validation/optim/shift-big.c | 7 |
2 files changed, 9 insertions, 0 deletions
@@ -557,6 +557,8 @@ static int simplify_shift(struct instruction *insn, pseudo_t pseudo, long long v break; case OP_LSR: size = operand_size(insn, pseudo); + /* fall through */ + case OP_SHL: if (value >= size) return replace_with_pseudo(insn, value_pseudo(0)); } diff --git a/validation/optim/shift-big.c b/validation/optim/shift-big.c index 3249854e..da65c5cd 100644 --- a/validation/optim/shift-big.c +++ b/validation/optim/shift-big.c @@ -3,6 +3,7 @@ typedef int s32; static u32 lsr32(u32 a) { return a >> 32; } static s32 asr32(s32 a) { return a >> 32; } +static u32 shl32(u32 a) { return a << 32; } /* * check-name: optim/shift-big.c @@ -23,5 +24,11 @@ asr32: ret.32 %r5 +shl32: +.L4: + <entry-point> + ret.32 $0 + + * check-output-end */ |
