A sign-extension has no effect on the result of a comparison with 0 or with 1 when the original size is bigger than 1. Optimize away the extension. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 4 ++++ validation/optim/bool-sext-test.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index fb4bb3429..db2fba7ff 100644 --- a/simplify.c +++ b/simplify.c @@ -607,6 +607,10 @@ static int simplify_seteq_setne(struct instruction *insn, long long value) remove_usage(old, &insn->src1); return REPEAT_CSE; + case OP_SEXT: + if (value && (def->orig_type->bit_size == 1)) + break; + /* Fall through */ case OP_ZEXT: // Convert: // *ext.m %s <- (1) %a diff --git a/validation/optim/bool-sext-test.c b/validation/optim/bool-sext-test.c index 0ca3dea9a..bd85e06ee 100644 --- a/validation/optim/bool-sext-test.c +++ b/validation/optim/bool-sext-test.c @@ -6,7 +6,6 @@ _Bool nes1( signed char a) { return a != 1; } /* * check-name: bool-sext-test * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-excludes: sext\\. -- 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