summaryrefslogtreecommitdiff
path: root/peephole.c
diff options
context:
space:
mode:
authorWormHeamer2025-08-10 04:46:09 -0400
committerWormHeamer2025-08-10 04:46:09 -0400
commitc9980711ce42de9cf58db35f41ce1ac42bfea0c7 (patch)
treecaa99c741b012f5fc683f131c6c2281fec4e2f61 /peephole.c
parentd4c768a481b923d407201c25d3d750040b6ccd44 (diff)
fix peephole bug (communative(phi(a,b), phi(a,b)) =/= communative(a,b))
Diffstat (limited to 'peephole.c')
-rw-r--r--peephole.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/peephole.c b/peephole.c
index b8118db..76d1fbd 100644
--- a/peephole.c
+++ b/peephole.c
@@ -251,6 +251,22 @@ static inline int is_zero(Node *n) {
/* needs lexer for error reporting */
Node *node_idealize(Node *n, Proc *p, Lexer *l) {
type_check(n, l);
+
+ /* stuff that needs to happen even if optimizations are disabled */
+
+ /*switch (n->op) {
+ case N_PHI:
+ for (int i = 0; i < n->in.len; i++) {
+ if (IN(n,i) && IN(n,i)->op == N_UNINIT) {
+ Node *r = node_new(p, N_UNINIT, p->start);
+ r->type = n->type;
+ return r;
+ }
+ }
+ default:
+ break;
+ }*/
+
if (no_opt) return NULL;
/* try to compute a literal value */
@@ -302,9 +318,8 @@ Node *node_idealize(Node *n, Proc *p, Lexer *l) {
}
if (T(CAR(n), N_PHI) && T(CDR(n), N_PHI) && CTRL(CAR(n)) == CTRL(CDR(n))
- && ((node_equiv(CAAR(n), CDAR(n)) && node_equiv(CADR(n), CDDR(n)))
- || (node_equiv(CADR(n), CDAR(n)) && node_equiv(CAAR(n), CDDR(n))))) {
- return OP(CAAR(n), CDAR(n));
+ && (node_equiv(CADR(n), CDAR(n)) && node_equiv(CAAR(n), CDDR(n)))) {
+ return OP(CAAR(n), CADR(n));
}
}