@@ -2301,6 +2301,13 @@ static int simplify_select(struct instruction *insn)
if (src2 == def->src1 && src1 == def->src2)
return replace_with_pseudo(insn, src1); // SEL(y!=x,x,y) --> x
break;
+ case OP_SET_LE: case OP_SET_LT:
+ case OP_SET_BE: case OP_SET_B:
+ if (!one_use(cond))
+ break;
+ // SEL(x {<,<=} y, a, b) --> SEL(x {>=,>} y, b, a)
+ def->opcode = opcode_negate(def->opcode);
+ return switch_pseudo(insn, &insn->src2, insn, &insn->src3);
case OP_SEL:
if (constant(def->src2) && constant(def->src3)) {
// Is the def of the conditional another select?
@@ -19,7 +19,6 @@ _Bool sel_leu(unsigned int a, unsigned int b, int x, int y)
/*
* check-name: canonical-cmps-sel
* check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
*
* check-output-ignore
* check-output-returns: 1
Both compares and OP_SELECT are anti-symmetrical: swapping the arguments is equivalent to inversing the condition. As consequence, when combined, they're symmetrical: swapping the arguments of the compare (or equivalently reversing the direction of the compare) and swapping the operand of the OP_SELECT is a no-op, both forms are equivalent. So, canonicalize these to always use OP_GT or OP_GE. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- simplify.c | 7 +++++++ validation/optim/canonical-cmps-sel.c | 1 - 2 files changed, 7 insertions(+), 1 deletion(-)