diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-11-07 20:23:54 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-11-08 02:29:17 +0100 |
commit | 29c405153720add05185351a13dcc68a5f39d3ff (patch) | |
tree | bd0f0a340bde51cfd9375a45619aa51062672bab | |
parent | 467fce3048571227e49beee068f783fb1c76a1e7 (diff) | |
download | sparse-29c405153720add05185351a13dcc68a5f39d3ff.tar.gz |
select: simplify handling of select(x, 0, x) --> 0
This simplification is already handled but explicitly kills it's 2
operands while this is done automatically when killing the instruction.
Also, it uses replace_with_value(0) which needs to recreate the
pseudo for 0 while it's already available via its operands.
So, changes to use replace_with_pseudo() and without the unneeded kills.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | simplify.c | 7 | ||||
-rw-r--r-- | validation/optim/select-self-zero.c | 9 |
2 files changed, 11 insertions, 5 deletions
@@ -1776,11 +1776,8 @@ static int simplify_select(struct instruction *insn) return REPEAT_CSE; } } - if (cond == src2 && is_zero(src1)) { - kill_use(&insn->src1); - kill_use(&insn->src3); - return replace_with_value(insn, 0); - } + if (cond == src2 && is_zero(src1)) // SEL(x, 0, x) --> 0 + return replace_with_pseudo(insn, src1); switch (DEF_OPCODE(def, cond)) { case OP_SET_EQ: diff --git a/validation/optim/select-self-zero.c b/validation/optim/select-self-zero.c new file mode 100644 index 00000000..ea309894 --- /dev/null +++ b/validation/optim/select-self-zero.c @@ -0,0 +1,9 @@ +int sel_self0x(int x) { return (x ? 0 : x) == 0; } + +/* + * check-name: select-self-zero + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-returns: 1 + */ |