Instructions removed during CSE had their ->bb simply set to NULL and the usage of their operand was not adjusted. Fix that by calling kill_instruction(). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- cse.c | 7 +------ validation/kill-cse.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 validation/kill-cse.c diff --git a/cse.c b/cse.c index 165b862af..048a3eb79 100644 --- a/cse.c +++ b/cse.c @@ -251,12 +251,7 @@ static struct instruction * cse_one_instruction(struct instruction *insn, struct { convert_instruction_target(insn, def->target); - if (insn->opcode == OP_PHI) { - kill_instruction(insn); - } - - insn->opcode = OP_NOP; - insn->bb = NULL; + kill_instruction(insn); repeat_phase |= REPEAT_CSE; return def; } diff --git a/validation/kill-cse.c b/validation/kill-cse.c new file mode 100644 index 000000000..2e2b10246 --- /dev/null +++ b/validation/kill-cse.c @@ -0,0 +1,21 @@ +int foo(int a) +{ + return ((a == 0) + 1) != ((a == 0) + 1); +} + +/* + * check-name: kill-cse + * check-description: + * Verify that instructions removed at CSE are + * properly adjust the usage of their operands. + * check-command: test-linearize -Wno-decl $file + * + * check-output-start +foo: +.L0: + <entry-point> + ret.32 $0 + + + * check-output-end + */ -- 2.11.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