diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-20 15:11:58 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-11-16 20:37:00 +0100 |
| commit | 4750ad6f4d4cb6c44aa86aacfc3a44a7429605fc (patch) | |
| tree | 672d4f452955b8b1aaec0fd1eda88e8820532cb8 | |
| parent | bf9785053a6e8b0f66bdee7531db76b05a779bf0 (diff) | |
| download | sparse-dev-4750ad6f4d4cb6c44aa86aacfc3a44a7429605fc.tar.gz | |
canonicalize binops before simplification
Currently, canonicalization of binops (more specifically
insuring that the operands of binops are in canonical order)
is only done after simplify_binop(). But the goal of
canonicalization is to limit the number of cases/patterns
we need to check/handle during ... simplification.
So canonicalization need to be done before simplification.
Fix this by moving (this part of) canonicalization before
doing simplification.
Note 1: the motivation of this patch is to prepare code for
the canonicalization of compare instructions
Note 2: this patch allow now some simplification of ...
the simplification code (simplify_binop()), this
will be done in a later serie.
Note 3: this patch changes slightly the cost of the CSE/
simplification, positively or negatively, depending
on the ration of simplification/canonicalization
that can be done.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | simplify.c | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -741,13 +741,13 @@ static int canonical_order(pseudo_t p1, pseudo_t p2) return 1; } -static int simplify_commutative_binop(struct instruction *insn) +static int canonicalize_commutative(struct instruction *insn) { - if (!canonical_order(insn->src1, insn->src2)) { - switch_pseudo(insn, &insn->src1, insn, &insn->src2); - return REPEAT_CSE; - } - return 0; + if (canonical_order(insn->src1, insn->src2)) + return 0; + + switch_pseudo(insn, &insn->src1, insn, &insn->src2); + return repeat_phase |= REPEAT_CSE; } static inline int simple_pseudo(pseudo_t pseudo) @@ -1148,17 +1148,15 @@ int simplify_instruction(struct instruction *insn) case OP_ADD: case OP_MULS: case OP_AND: case OP_OR: case OP_XOR: case OP_AND_BOOL: case OP_OR_BOOL: + canonicalize_commutative(insn); if (simplify_binop(insn)) return REPEAT_CSE; - if (simplify_commutative_binop(insn)) - return REPEAT_CSE; return simplify_associative_binop(insn); case OP_MULU: case OP_SET_EQ: case OP_SET_NE: - if (simplify_binop(insn)) - return REPEAT_CSE; - return simplify_commutative_binop(insn); + canonicalize_commutative(insn); + return simplify_binop(insn); case OP_SUB: case OP_DIVU: case OP_DIVS: |
