An OP_ZEXT/OP_SEXT following by a OP_TRUNC to the original size is a NOP. Simplify away such OP_TRUNC. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 10 ++++++++++ validation/optim/ext-trunc-same.c | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 1ac000e52..2549860e3 100644 --- a/simplify.c +++ b/simplify.c @@ -1008,6 +1008,16 @@ static int simplify_cast(struct instruction *insn) return replace_pseudo(insn, &insn->src1, def->src); } break; + case OP_ZEXT: + case OP_SEXT: + switch (insn->opcode) { + case OP_TRUNC: + osize = def->orig_type->bit_size; + if (size == osize) + return replace_with_pseudo(insn, def->src); + break; + } + break; } return 0; diff --git a/validation/optim/ext-trunc-same.c b/validation/optim/ext-trunc-same.c index 634fdb87a..2bfcf0304 100644 --- a/validation/optim/ext-trunc-same.c +++ b/validation/optim/ext-trunc-same.c @@ -11,7 +11,6 @@ short ueq(unsigned short x) /* * check-name: ext-trunc-same * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-excludes: trunc\\. -- 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