The remaining compares with SMIN or SMAX are equivalent to an equality testing. For example, (x < SMAX) is the same as (x != SMAX). Canonicalize these to the equality testing since these are usually simpler to handle. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 8 ++++++++ validation/optim/canonical-cmps-minmax.c | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 096742d51a16..f7c6c68d4ce9 100644 --- a/simplify.c +++ b/simplify.c @@ -1173,18 +1173,26 @@ static int simplify_compare_constant(struct instruction *insn, long long value) case OP_SET_LT: if (value == sign_bit(size)) // (x < SMIN) --> 0 return replace_with_pseudo(insn, value_pseudo(0)); + if (value == sign_mask(size)) // (x < SMAX) --> (x != SMAX) + return replace_opcode(insn, OP_SET_NE); break; case OP_SET_LE: if (value == sign_mask(size)) // (x <= SMAX) --> 1 return replace_with_pseudo(insn, value_pseudo(1)); + if (value == sign_bit(size)) // (x <= SMIN) --> (x == SMIN) + return replace_opcode(insn, OP_SET_EQ); break; case OP_SET_GE: if (value == sign_bit(size)) // (x >= SMIN) --> 1 return replace_with_pseudo(insn, value_pseudo(1)); + if (value == sign_mask(size)) // (x >= SMAX) --> (x == SMAX) + return replace_opcode(insn, OP_SET_EQ); break; case OP_SET_GT: if (value == sign_mask(size)) // (x > SMAX) --> 0 return replace_with_pseudo(insn, value_pseudo(0)); + if (value == sign_bit(size)) // (x > SMIN) --> (x != SMIN) + return replace_opcode(insn, OP_SET_NE); break; case OP_SET_B: diff --git a/validation/optim/canonical-cmps-minmax.c b/validation/optim/canonical-cmps-minmax.c index bab09282d241..48927f49db6e 100644 --- a/validation/optim/canonical-cmps-minmax.c +++ b/validation/optim/canonical-cmps-minmax.c @@ -10,7 +10,6 @@ int gt_smin(int a) { return (a > SMIN) == (a != SMIN); } /* * check-name: canonical-cmps-minmax * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-returns: 1 -- 2.30.0