diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-07-30 23:51:22 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-08-06 08:51:36 +0200 |
| commit | 8457b3c20a2f3e3f1ad1201af217faf4e89e0940 (patch) | |
| tree | 5f1fb6616eb2adf70d0a93b684bbfaaaf519b77b | |
| parent | 34c4c964d0969a5c594b6bedaa3d749cf1ba6e24 (diff) | |
| download | sparse-dev-8457b3c20a2f3e3f1ad1201af217faf4e89e0940.tar.gz | |
simplify SETNE(TRUNC(x,N),{0,1})
Convert the OP_TRUNC into an OP_AND with the appropriate mask.
This a greater chance to simplify with previous instructions
and to correspond to a register-size operand.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | simplify.c | 17 | ||||
| -rw-r--r-- | validation/optim/trunc-setne0.c | 1 |
2 files changed, 17 insertions, 1 deletions
@@ -690,6 +690,7 @@ static int simplify_seteq_setne(struct instruction *insn, long long value) { pseudo_t old = insn->src1; struct instruction *def; + unsigned osize; int inverse; int opcode; @@ -749,6 +750,22 @@ static int simplify_seteq_setne(struct instruction *insn, long long value) // setne.1 %s <- %a, $0 // and same for setne/eq ... 0/1 return replace_pseudo(insn, &insn->src1, def->src); + case OP_TRUNC: + if (nbr_users(old) > 1) + break; + // convert + // trunc.n %s <- (o) %a + // setne.m %r <- %s, $0 + // into: + // and.o %s <- %a, $((1 << o) - 1) + // setne.m %r <- %s, $0 + // and same for setne/eq ... 0/1 + osize = def->size; + def->opcode = OP_AND; + def->type = def->orig_type; + def->size = def->type->bit_size; + def->src2 = value_pseudo(bits_mask(osize)); + return REPEAT_CSE; } return 0; } diff --git a/validation/optim/trunc-setne0.c b/validation/optim/trunc-setne0.c index 16f99a88..878c05fa 100644 --- a/validation/optim/trunc-setne0.c +++ b/validation/optim/trunc-setne0.c @@ -13,7 +13,6 @@ unsigned int foo(struct s x) /* * check-name: trunc-setne0 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-contains: and\\. |
