diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-16 01:16:32 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-20 22:35:08 +0200 |
commit | 249f95bcf50595c97c126cb46d7db02d48249fe6 (patch) | |
tree | a0fbdc0a54e59579da11fdc674f0fa3b32637d68 | |
parent | e51008eb29ccb75e2e58f5d9c545f944185c9765 (diff) | |
download | sparse-249f95bcf50595c97c126cb46d7db02d48249fe6.tar.gz |
constants must be truncated to the operation's size
At expansion phase, when simplified, all constants are truncated
to the size of the operations that generate them.
This should be done during simplification too because:
*) if some constants are sometimes truncated and sometimes
sign-extended, CSE will miss some opportunities.
*) it's not possible to sign-extend them because it's not
always known if the constant is used in a signed context or not.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | simplify.c | 2 | ||||
-rw-r--r-- | validation/optim/canonical-sub-cte.c | 1 |
2 files changed, 1 insertions, 2 deletions
@@ -1118,7 +1118,7 @@ static int simplify_constant_rightside(struct instruction *insn) case OP_SUB: if (value) { insn->opcode = OP_ADD; - insn->src2 = value_pseudo(-value); + insn->src2 = eval_unop(OP_NEG, insn->size, insn->src2); return REPEAT_CSE; } /* Fall through */ diff --git a/validation/optim/canonical-sub-cte.c b/validation/optim/canonical-sub-cte.c index 223be96f..c0072884 100644 --- a/validation/optim/canonical-sub-cte.c +++ b/validation/optim/canonical-sub-cte.c @@ -3,7 +3,6 @@ int sub_cte(int x) { return (x - 1) != (x + -1); } /* * check-name: canonical-sub-cte * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-contains: ret\\..*\\$0 |