Message ID | 20170129104808.2500-7-luc.vanoostenryck@gmail.com (mailing list archive) |
---|---|
State | Mainlined, archived |
Headers | show |
diff --git a/simplify.c b/simplify.c index 1e4aa63b4..690fdc4e8 100644 --- a/simplify.c +++ b/simplify.c @@ -225,6 +225,7 @@ void kill_instruction(struct instruction *insn) kill_use(&insn->src3); return; case OP_BR: + case OP_COMPUTEDGOTO: insn->bb = NULL; repeat_phase |= REPEAT_CSE; if (insn->bb_true && insn->bb_false) diff --git a/validation/kill-computedgoto.c b/validation/kill-computedgoto.c new file mode 100644 index 000000000..3b3ed8ff2 --- /dev/null +++ b/validation/kill-computedgoto.c @@ -0,0 +1,17 @@ +void foo(int a); +void foo(int a) +{ + void *l = &&end + 3; + +end: + if (a * 0) + goto *l; +} + +/* + * check-name: kill-computedgoto + * check-command: test-linearize $file + * + * check-output-ignore + * check-output-excludes: add\\. + */
Currently kill_instruction() doesn't do anything with the operands of computed gotos (OP_COMPUTEDGOTO). But when these instructions are removed we must also remove the operands 'usage'. Without this some instructions, which provides the select's operands, are not optimized away as expected. The fix consists by killing it's operand much like what is done for conditional branches. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- simplify.c | 1 + validation/kill-computedgoto.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 validation/kill-computedgoto.c