@@ -625,6 +625,13 @@ static int simplify_seteq_setne(struct instruction *insn, long long value)
break;
default:
+ if (def->size == 1 && !inverse)
+ // Replace:
+ // setne.1 %r <- %s, $0
+ // or:
+ // seteq.1 %r <- %s, $1
+ // by %s
+ return replace_with_pseudo(insn, old);
break;
}
return 0;
@@ -54,8 +54,7 @@ bfior:
fcmpune.1 %r20 <- %arg1, %r19
fcmpune.1 %r23 <- %arg2, %r19
or-bool.1 %r24 <- %r20, %r23
- setne.1 %r26 <- %r24, $0
- ret.1 %r26
+ ret.1 %r24
ifior:
@@ -76,8 +75,7 @@ bfand:
fcmpune.1 %r39 <- %arg1, %r38
fcmpune.1 %r42 <- %arg2, %r38
and-bool.1 %r43 <- %r39, %r42
- setne.1 %r45 <- %r43, $0
- ret.1 %r45
+ ret.1 %r43
ifand:
@@ -7,7 +7,7 @@ static int foo(int a, int b, int c)
* check-name: bool-simplify2
* check-command: test-linearize $file
*
- * check-output-pattern(4): setne\\.
+ * check-output-pattern(3): setne\\.
* check-output-pattern(1): zext\\.
*
* check-output-start
@@ -17,9 +17,8 @@ foo:
setne.1 %r2 <- %arg1, $0
setne.1 %r4 <- %arg2, $0
or-bool.1 %r5 <- %r2, %r4
- setne.1 %r7 <- %r5, $0
setne.1 %r9 <- %arg3, $0
- or-bool.1 %r10 <- %r7, %r9
+ or-bool.1 %r10 <- %r5, %r9
zext.32 %r11 <- (1) %r10
ret.32 %r11
These two comparisons are no-ops when the operand is a bool. Simplify away these comparisons. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- simplify.c | 7 +++++++ validation/optim/bool-context-fp.c | 6 ++---- validation/optim/bool-simplify2.c | 5 ++--- 3 files changed, 11 insertions(+), 7 deletions(-)