@@ -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;
@@ -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\\.
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@gmail.com> --- simplify.c | 10 ++++++++++ validation/optim/ext-trunc-same.c | 1 - 2 files changed, 10 insertions(+), 1 deletion(-)