From 2e9471d51289b7b67090ee06c475fe7d2b8e6ede Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Thu, 16 Feb 2017 05:57:04 +0100 Subject: [PATCH] add killing of stores OP_STOREs were ignored by kill_instruction() but if it is force-killed because the basic block it belong became unreachable then we need to adjust the usage of its operands. Signed-off-by: Luc Van Oostenryck Signed-off-by: Christopher Li --- simplify.c | 7 +++++++ validation/kill-store.c | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 validation/kill-store.c diff --git a/simplify.c b/simplify.c index a27f6a33..804467f0 100644 --- a/simplify.c +++ b/simplify.c @@ -255,6 +255,13 @@ void kill_insn(struct instruction *insn, int force) kill_use(&insn->src); break; + case OP_STORE: + if (!force) + return; + kill_use(&insn->src); + kill_use(&insn->target); + break; + case OP_ENTRY: /* ignore */ return; diff --git a/validation/kill-store.c b/validation/kill-store.c new file mode 100644 index 00000000..8f725322 --- /dev/null +++ b/validation/kill-store.c @@ -0,0 +1,16 @@ +void keep(int *p) { *p = 0; } +void kill(int *p, int i) { if (i && 0) *p = 0; } +void dead(int *p, int i) { int v = i++; if (i && 0) p[v] = 0; } + + +/* + * check-name: kill-store + * check-command: test-linearize -Wno-decl $file + * check-description: + * Check that stores are optimized away but only + * when needed: + * - bb unreachable. + * + * check-output-ignore + * check-output-pattern-1-times: store\\. + */ -- 2.11.4.GIT