https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110748

--- Comment #11 from Vineet Gupta <vineetg at gcc dot gnu.org> ---
There's a variation which can be optimized as well and seems non trivial to
implement

Now it is the negative constant -0.0 to be stored to mem. In bit notation this
has a single sign bit set thus can be optimized using a bseti if rv64gc_zbs.

void znd(double *d) { *d = -0.0; }
void znf(float *f)  { *f = -0.0; }

llvm optim these to

znd(double*):
        bseti   a1, zero, 63
        sd      a1, 0(a0)
        ret

znf(float*):
        lui     a1, 0x80000
        sw      a1, 0(a0)
        ret

While gcc resorts to constant pool for both

        lui     a5,%hi(.LANCHOR0)
        fld     fa5,%lo(.LANCHOR0)(a5)
        fsd     fa5,0(a0)
        ret
        .set    .LANCHOR0,. + 0
.LC0:
        .word   0
        .word   -2147483648

Reply via email to