@@ -1239,13 +1239,13 @@ static int simplify_compare_constant(struct instruction *insn, long long value)
}
break;
case OP_SET_LT: case OP_SET_LE:
- if (value >= sign_bit(osize))
+ if (value < sign_bit(size))
return replace_with_value(insn, 1);
else
return replace_with_value(insn, 0);
break;
case OP_SET_GE: case OP_SET_GT:
- if (value >= sign_bit(osize))
+ if (value < sign_bit(size))
return replace_with_value(insn, 0);
else
return replace_with_value(insn, 1);
@@ -4,21 +4,45 @@
static int lt_ge0(int x) { return (sext(x) < (POS + 0)) == 1; }
static int lt_ge1(int x) { return (sext(x) < (POS + 1)) == 1; }
+static int lt_ge2(int x) { return (sext(x) < (POS + 2)) == 1; }
+static int lt_gex(int x) { return (sext(x) < (POS<< 1)) == 1; }
+static int lt_gey(int x) { return (sext(x) < (POS<< 3)) == 1; }
static int le_ge0(int x) { return (sext(x) <= (POS + 0)) == 1; }
static int le_ge1(int x) { return (sext(x) <= (POS + 1)) == 1; }
-static int lt_lt0(int x) { return (sext(x) < (NEG - 0)) == 1; }
-static int lt_lt1(int x) { return (sext(x) < (NEG - 1)) == 1; }
-static int le_lt0(int x) { return (sext(x) <= (NEG - 0)) == 1; }
-static int le_lt1(int x) { return (sext(x) <= (NEG - 1)) == 1; }
-
-static int gt_ge0(int x) { return (sext(x) > (POS + 0)) == 0; }
-static int gt_ge1(int x) { return (sext(x) > (POS + 1)) == 0; }
+static int le_ge2(int x) { return (sext(x) <= (POS + 2)) == 1; }
+static int le_gex(int x) { return (sext(x) <= (POS<< 1)) == 1; }
+static int le_gey(int x) { return (sext(x) <= (POS<< 3)) == 1; }
static int ge_ge0(int x) { return (sext(x) >= (POS + 0)) == 0; }
static int ge_ge1(int x) { return (sext(x) >= (POS + 1)) == 0; }
-static int gt_lt0(int x) { return (sext(x) > (NEG - 0)) == 0; }
-static int gt_lt1(int x) { return (sext(x) > (NEG - 1)) == 0; }
-static int ge_lt0(int x) { return (sext(x) >= (NEG - 0)) == 0; }
-static int ge_lt1(int x) { return (sext(x) >= (NEG - 1)) == 0; }
+static int ge_ge2(int x) { return (sext(x) >= (POS + 2)) == 0; }
+static int ge_gex(int x) { return (sext(x) >= (POS<< 1)) == 0; }
+static int ge_gey(int x) { return (sext(x) >= (POS<< 3)) == 0; }
+static int gt_ge0(int x) { return (sext(x) > (POS + 0)) == 0; }
+static int gt_ge1(int x) { return (sext(x) > (POS + 1)) == 0; }
+static int gt_ge2(int x) { return (sext(x) > (POS + 2)) == 0; }
+static int gt_gex(int x) { return (sext(x) > (POS<< 1)) == 0; }
+static int gt_gey(int x) { return (sext(x) > (POS<< 3)) == 0; }
+
+static int lt_lt0(int x) { return (sext(x) < (NEG - 0)) == 0; }
+static int lt_lt1(int x) { return (sext(x) < (NEG - 1)) == 0; }
+static int lt_lt2(int x) { return (sext(x) < (NEG - 2)) == 0; }
+static int lt_ltx(int x) { return (sext(x) < (NEG<< 1)) == 0; }
+static int lt_lty(int x) { return (sext(x) < (NEG<< 3)) == 0; }
+static int le_lt0(int x) { return (sext(x) <= (NEG - 0)) == 0; }
+static int le_lt1(int x) { return (sext(x) <= (NEG - 1)) == 0; }
+static int le_lt2(int x) { return (sext(x) <= (NEG - 2)) == 0; }
+static int le_ltx(int x) { return (sext(x) <= (NEG<< 1)) == 0; }
+static int le_lty(int x) { return (sext(x) <= (NEG<< 3)) == 0; }
+static int ge_lt0(int x) { return (sext(x) >= (NEG - 0)) == 1; }
+static int ge_lt1(int x) { return (sext(x) >= (NEG - 1)) == 1; }
+static int ge_lt2(int x) { return (sext(x) >= (NEG - 2)) == 1; }
+static int ge_ltx(int x) { return (sext(x) >= (NEG<< 1)) == 1; }
+static int ge_lty(int x) { return (sext(x) >= (NEG<< 3)) == 1; }
+static int gt_lt0(int x) { return (sext(x) > (NEG - 0)) == 1; }
+static int gt_lt1(int x) { return (sext(x) > (NEG - 1)) == 1; }
+static int gt_lt2(int x) { return (sext(x) > (NEG - 2)) == 1; }
+static int gt_ltx(int x) { return (sext(x) > (NEG<< 1)) == 1; }
+static int gt_lty(int x) { return (sext(x) > (NEG<< 3)) == 1; }
/*
* check-name: cmp-sext-simm
Commit a1c1b9236d5d ("cmp: simplify sext(x) cmps {SMAX,SMIN}") had a double error (wrong size and wrong compare direction) which was hidden because of too narrow testcases. So, fix the simplification and extend the testcases. Fixes: a1c1b9236d5d4af1681a45ced26f8350bd7721c2 Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- simplify.c | 4 +-- validation/optim/cmp-sext-simm.c | 46 ++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 13 deletions(-)