[PATCH] Use ceqw/l for logical not (!) operator instead of jnz+phi
Export this patch
This leads to neater code - single instruction, no more
blocks, and facilitates further QBE optimisations.
Yep I wanted to do that but did not. I'll merge that in
my patch and re-send it.
---
qbe.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/qbe.c b/qbe.c
index 0d1a499..1791511 100644
--- a/qbe.c
+++ b/qbe.c
@@ -702,12 +702,6 @@ funcbranch(struct func *f, struct expr *e, struct block *bt, struct block *bf)
/* Maybe we we could do something for EXPRCOND as well. */
switch (e->kind) {
- case EXPRUNARY:
- if (e->op == TLNOT) {
- funcbranch(f, e->base, bf, bt);
- return;
- }
- break;
case EXPRBINARY:
if (e->op == TLOR || e->op == TLAND) {
if (e->op == TLOR) {
@@ -833,7 +827,9 @@ funcexpr(struct func *f, struct expr *e)
case EXPRUNARY:
switch (e->op) {
case TLNOT:
- return funclogical(f, e);
+ r = funcexpr(f, e->base);
+ return funcinst(f, (qbetype(e->type).base == 'w' ? ICEQW : ICEQL),
+ 'w', r, mkintconst(0));
case TBAND:
lval = funclval(f, e->base);
return lval.addr;
--
2.34.1