systems-nuts / unifico

Compiler and build harness for heterogeneous-ISA binaries with the same stack layout.
3 stars 1 forks source link

Different constant hoisting due to different legal addresses #311

Closed blackgeorge-boom closed 9 months ago

blackgeorge-boom commented 9 months ago
int main(int argc, char *argv[])
{
    int i, j, it;

    double rnorm;
    double norm_temp2;

    lastrow  = NA-1;
    lastcol  = NA-1;

    naa = NA;
    nzz = NZ;

    makea(naa, nzz, a, colidx, rowstr,
          firstrow, lastrow, firstcol, lastcol,
          arow,
          (int (*)[NONZER+1])(void*)acol,
          (double (*)[NONZER+1])(void*)aelt,
          iv);

    for (i = 0; i < NA+1; i++) {
        x[i] = 1.0;
    }

    for (it = 1; it <= 1; it++) {
        conj_grad(colidx, rowstr, x, z, a, p, q, r, &rnorm);

        norm_temp2 = 1.0 / norm_temp2;

        for (j = 0; j < lastcol - firstcol + 1; j++) {
            x[j] = norm_temp2 * z[j];
        }
    }

    return 0;
}

AArch64 after hoisting:

  %const5 = bitcast i64 75000 to i64
  %const = bitcast i32 74999 to i32

X86:

  %const = bitcast i32 74999 to i32
blackgeorge-boom commented 9 months ago

Again the issue is similar to https://github.com/systems-nuts/unifico/issues/309, regarding legal addressing.