diff options
| author | WormHeamer | 2025-08-10 23:36:58 -0400 |
|---|---|---|
| committer | WormHeamer | 2025-08-10 23:36:58 -0400 |
| commit | 13c139cc56029ac7108c46fda843950ed1a36f29 (patch) | |
| tree | 47b29db45758480f5ed1ed2188f256bceac2831d | |
| parent | 27418008d4b492aff432c44fc92cd8485bcd5cf7 (diff) | |
it's commutative, not communative
| -rw-r--r-- | peephole.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -7,7 +7,7 @@ extern int no_opt; -#define NM_COMMUNATIVE (NM_OP_ADD | NM_OP_MUL | NM_OP_AND | NM_OP_XOR | NM_OP_OR | NM_CMP_EQL | NM_CMP_NEQ) +#define NM_COMMUTATIVE (NM_OP_ADD | NM_OP_MUL | NM_OP_AND | NM_OP_XOR | NM_OP_OR | NM_CMP_EQL | NM_CMP_NEQ) #define NM_ASSOCIATIVE (NM_OP_ADD | NM_OP_MUL | NM_OP_AND | NM_OP_XOR | NM_OP_OR) #define NM_COMPARISON (NM_CMP_EQL | NM_CMP_NEQ | NM_CMP_LES | NM_CMP_GTR | NM_CMP_LTE | NM_CMP_GTE) #define NM_IDEMPOTENT (NM_OP_AND | NM_OP_OR) @@ -225,7 +225,7 @@ static int node_equiv_input(Node *a, Node *b) { //if (CTRL(a) != CTRL(b)) return 0; /* note that this means the order of inputs isn't guaranteed, so be * careful what you use this procedure for */ - if (((NMASK(a->op) | NMASK(b->op)) & NM_COMMUNATIVE) + if (((NMASK(a->op) | NMASK(b->op)) & NM_COMMUTATIVE) && ((node_equiv(CDR(a), CAR(b)) && node_equiv(CAR(a), CDR(b))) || (node_equiv(CAR(a), CDR(b)) && node_equiv(CDR(a), CAR(b))))) { /* assuming input count is 2 */ @@ -312,7 +312,7 @@ Node *node_idealize(Node *n, Proc *p, Lexer *l) { /* transformations to help encourage constant folding */ /* the overall trend is to move them rightwards */ - if (NMASK(n->op) & NM_COMMUNATIVE) { + if (NMASK(n->op) & NM_COMMUTATIVE) { /* op(lit, X) -> op(X, lit) */ if (T(CAR(n), N_LIT) && !T(CDR(n), N_LIT)) return OP(CDR(n), CAR(n)); |
