aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <[email protected]>2024-06-18 16:59:42 +0200
committerQuentin Carbonneaux <[email protected]>2024-06-18 16:59:42 +0200
commit96f18be71d34b63ceca3e4fa5480eb9ca9afcf4e (patch)
tree1c50b7b72bc7634011c3bd92cde85f7e574c9017
parent0631bc4fecf9a9f96c8a520ac56371a0a86318b9 (diff)
simplify 8*x as well as x*8
-rw-r--r--simpl.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/simpl.c b/simpl.c
index 7186d2f..8588d6c 100644
--- a/simpl.c
+++ b/simpl.c
@@ -65,7 +65,7 @@ ins(Ins **pi, int *new, Blk *b, Fn *fn)
i = *pi;
/* simplify more instructions here;
- * copy 0 into xor bit rotations,
+ * copy 0 into xor, bit rotations,
* etc. */
switch (i->op) {
case Oblit1:
@@ -80,8 +80,14 @@ ins(Ins **pi, int *new, Blk *b, Fn *fn)
}
blit((i-1)->arg, rsval(i->arg[0]), fn);
*pi = i-1;
- break;
+ return;
case Omul:
+ if (rtype(i->arg[0]) == RCon) {
+ r = i->arg[0];
+ i->arg[0] = i->arg[1];
+ i->arg[1] = r;
+ }
+ /* fall through */
case Oudiv:
case Ourem:
r = i->arg[1];
@@ -103,12 +109,10 @@ ins(Ins **pi, int *new, Blk *b, Fn *fn)
}
}
}
- /* fall through */
- default:
- if (*new)
- emiti(*i);
break;
}
+ if (*new)
+ emiti(*i);
}
void