diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-01-03 23:40:45 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-03-10 22:42:42 +0100 |
commit | e5ac481d66869dae85367311056a613ed0fcdb00 (patch) | |
tree | e1c8f6a85b9f21f5117ab62c1d4a07983f81a6ca | |
parent | 3289d1c73b10b46bab66ac02096e911c3b5168d7 (diff) | |
download | sparse-e5ac481d66869dae85367311056a613ed0fcdb00.tar.gz |
simplify (x & M) cmps 0
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | simplify.c | 4 | ||||
-rw-r--r-- | validation/optim/cmps0-and0.c | 1 |
2 files changed, 4 insertions, 1 deletions
@@ -1271,6 +1271,8 @@ static int simplify_compare_constant(struct instruction *insn, long long value) return replace_with_value(insn, 0); if (value >= (long long)bits) return replace_with_value(insn, 1); + if (value == 0) + return replace_opcode(insn, OP_SET_EQ); break; case OP_SET_GT: value = sign_extend(value, def->size); @@ -1280,6 +1282,8 @@ static int simplify_compare_constant(struct instruction *insn, long long value) return replace_with_value(insn, 1); if (value >= (long long)bits) return replace_with_value(insn, 0); + if (value == 0) + return replace_opcode(insn, OP_SET_NE); break; case OP_SET_B: if (value > bits) diff --git a/validation/optim/cmps0-and0.c b/validation/optim/cmps0-and0.c index 819a1dc2..8316916a 100644 --- a/validation/optim/cmps0-and0.c +++ b/validation/optim/cmps0-and0.c @@ -6,7 +6,6 @@ int cmps_and_sgt0(int a) { return ((a & M) > 0) == ((a & M) != 0); } /* * check-name: cmps0-and * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-returns: 1 |