From 9d88dc64ceefc36c23ce89917a8d2f72d2419b3c Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Thu, 16 Feb 2017 05:57:07 +0100 Subject: [PATCH] use kill_instruction() when killing any instructions during CSE 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 Signed-off-by: Christopher Li --- 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 165b862a..048a3eb7 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 00000000..2e2b1024 --- /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: + + ret.32 $0 + + + * check-output-end + */ -- 2.11.4.GIT