From 13c139cc56029ac7108c46fda843950ed1a36f29 Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Sun, 10 Aug 2025 23:36:58 -0400 Subject: it's commutative, not communative --- peephole.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'peephole.c') diff --git a/peephole.c b/peephole.c index 4b39cf8..d8846f5 100644 --- a/peephole.c +++ b/peephole.c @@ -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)); -- cgit v1.2.3