diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-07-08 23:59:51 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-07-28 09:07:11 +0200 |
| commit | dd7cfd8c2817da86acc42b8c285055f79ccdedc2 (patch) | |
| tree | 7c7962afe406c2d96d21a78b9e4dc6ddf93b6d48 /simplify.c | |
| parent | bc0f5843abbc4579a277392af8db70f7835f4b97 (diff) | |
| download | sparse-dev-dd7cfd8c2817da86acc42b8c285055f79ccdedc2.tar.gz | |
simplify SET{EQ,NE}(SEXT(x, N),{0,1})
A sign-extension has no effect on the result of a comparison
with 0 or with 1 when the original size is bigger than 1.
Optimize away the extension.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'simplify.c')
| -rw-r--r-- | simplify.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -607,9 +607,13 @@ static int simplify_seteq_setne(struct instruction *insn, long long value) remove_usage(old, &insn->src1); return REPEAT_CSE; + case OP_SEXT: + if (value && (def->orig_type->bit_size == 1)) + break; + /* Fall through */ case OP_ZEXT: // Convert: - // zext.m %s <- (1) %a + // *ext.m %s <- (1) %a // setne.1 %r <- %s, $0 // into: // setne.1 %s <- %a, $0 |
