Unsigned <= or > against SMAX are equivalent to testing if the value is positive or not (when interpreted as a signed number). Canonicalize to this positive/negative test since it only needs the constant 0 which make it easier to handle at later steps. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 4 ++++ validation/optim/set-uimm3.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 7921300f7280..2176f90dc133 100644 --- a/simplify.c +++ b/simplify.c @@ -1112,6 +1112,8 @@ static int simplify_compare_constant(struct instruction *insn, long long value) return replace_with_pseudo(insn, value_pseudo(1)); if (value == (bits - 1)) // (x <= ~1) --> (x != ~0) return replace_binop_value(insn, OP_SET_NE, bits); + if (value == (bits >> 1)) // (x u<= SMAX) --> (x s>= 0) + changed |= replace_binop_value(insn, OP_SET_GE, 0); break; case OP_SET_A: if (!value) // (x > 0) --> (x != 0) @@ -1120,6 +1122,8 @@ static int simplify_compare_constant(struct instruction *insn, long long value) return replace_with_pseudo(insn, value_pseudo(0)); if (value == (bits - 1)) // (x > ~1) --> (x == ~0) return replace_binop_value(insn, OP_SET_EQ, bits); + if (value == (bits >> 1)) // (x u> SMAX) --> (x s< 0) + changed |= replace_binop_value(insn, OP_SET_LT, 0); break; } return changed; diff --git a/validation/optim/set-uimm3.c b/validation/optim/set-uimm3.c index b72ef8d6e819..5160f741d85b 100644 --- a/validation/optim/set-uimm3.c +++ b/validation/optim/set-uimm3.c @@ -4,7 +4,6 @@ int gt(int x) { return (x > 0x7fffffffU) == (x < 0); } /* * check-name: set-uimm3 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-returns: 1 -- 2.29.2