These two comparisons are no-ops when the operand is a bool. Simplify away these comparisons. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 7 +++++++ validation/optim/bool-context-fp.c | 6 ++---- validation/optim/bool-simplify2.c | 5 ++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/simplify.c b/simplify.c index 9f0d13b55..89532646a 100644 --- a/simplify.c +++ b/simplify.c @@ -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; diff --git a/validation/optim/bool-context-fp.c b/validation/optim/bool-context-fp.c index c3c2e546c..6c80eeb17 100644 --- a/validation/optim/bool-context-fp.c +++ b/validation/optim/bool-context-fp.c @@ -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: diff --git a/validation/optim/bool-simplify2.c b/validation/optim/bool-simplify2.c index 72fc2f2ea..e015fe8ec 100644 --- a/validation/optim/bool-simplify2.c +++ b/validation/optim/bool-simplify2.c @@ -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 -- 2.18.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html