From e5ac481d66869dae85367311056a613ed0fcdb00 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Sun, 3 Jan 2021 23:40:45 +0100 Subject: simplify (x & M) cmps 0 Signed-off-by: Luc Van Oostenryck --- simplify.c | 4 ++++ validation/optim/cmps0-and0.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index ee29c961..6c11018e 100644 --- a/simplify.c +++ b/simplify.c @@ -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 -- cgit 1.2.3-korg