EtchedPixels / Fuzix-Compiler-Kit

Fuzix C Compiler Project
Other
49 stars 14 forks source link

be-code-6800.c load_r_with(), load_x_with(): unnecessary invalidate_x() is used after make_local_ptr() #134

Closed zu2 closed 4 weeks ago

zu2 commented 1 month ago

Because an unnecessary invalidate_x() is used after make_local_ptr(), the value of X is not used effectively and TSX is emitted excessively.

--- ../Fuzix-Compiler-Kit/be-code-6800.c    2024-10-27 08:05:59
+++ be-code-6800.c  2024-10-27 09:51:53
@@ -934,7 +934,8 @@
    case T_LREF:
        off = make_local_ptr(v + off, 252);
        printf("\tld%c %u,x\n", reg, off);
-       invalidate_x();
+       if(reg == 'x')
+           invalidate_x();
        break;
    case T_CONSTANT:
    case T_LBREF:
@@ -942,6 +943,8 @@
    case T_NREF:
    case T_NAME:
        printf("\tld%c %s\n", reg, addr_form(r, off, 2));
+       if(reg == 'x')
+           invalidate_x();
        break;
    default:
        error("lxw");
@@ -952,7 +955,6 @@
 unsigned load_x_with(struct node *r, unsigned off)
 {
    unsigned rv = load_r_with('x', r, off);
-   invalidate_x();
    return rv;
 }
EtchedPixels commented 4 weeks ago

Thanks