diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2028-09-29 00:53:53 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-20 22:35:41 +0200 |
commit | f8434575357435242114a6f9912c13eb0588149f (patch) | |
tree | 74fbcb241fbfa27e601ae424c65672ffcf340310 | |
parent | 249f95bcf50595c97c126cb46d7db02d48249fe6 (diff) | |
download | sparse-f8434575357435242114a6f9912c13eb0588149f.tar.gz |
reassoc: simplify (x # C) # K --> x # eval(C # K)
Do this simplification once for all associative binops.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | simplify.c | 5 | ||||
-rw-r--r-- | validation/optim/reassoc-op-op1.c | 1 |
2 files changed, 5 insertions, 1 deletions
@@ -1295,6 +1295,11 @@ static int simplify_associative_binop(struct instruction *insn) return 0; if (!simple_pseudo(def->src2)) return 0; + if (constant(def->src2) && constant(insn->src2)) { + // (x # C) # K --> x # eval(C # K) + insn->src2 = eval_op(insn->opcode, insn->size, insn->src2, def->src2); + return replace_pseudo(insn, &insn->src1, def->src1); + } if (multi_users(def->target)) return 0; switch_pseudo(def, &def->src1, insn, &insn->src2); diff --git a/validation/optim/reassoc-op-op1.c b/validation/optim/reassoc-op-op1.c index aa7092ff..3d050c14 100644 --- a/validation/optim/reassoc-op-op1.c +++ b/validation/optim/reassoc-op-op1.c @@ -8,7 +8,6 @@ int foo(int x, int *ptr) /* * check-name: reassoc-op-op1 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-pattern(1): add\\. |