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 | |
| 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>
| -rw-r--r-- | simplify.c | 6 | ||||
| -rw-r--r-- | validation/optim/bool-sext-test.c | 1 |
2 files changed, 5 insertions, 2 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 diff --git a/validation/optim/bool-sext-test.c b/validation/optim/bool-sext-test.c index 0ca3dea9..bd85e06e 100644 --- a/validation/optim/bool-sext-test.c +++ b/validation/optim/bool-sext-test.c @@ -6,7 +6,6 @@ _Bool nes1( signed char a) { return a != 1; } /* * check-name: bool-sext-test * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-excludes: sext\\. |
