https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129029
Bug ID: 129029
Summary: [rs6000-future] Wrong code for DMF builtin when the
input dense-math register is reused (-mcpu=future)
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: kishan at gcc dot gnu.org
CC: jskumari at gcc dot gnu.org, meissner at gcc dot gnu.org
Target Milestone: ---
Target: power*-linux-gnu
Testcase below,
typedef unsigned char vec_t __attribute__ ((vector_size (16)));
void
foo (__dmr1024 *dst, __vector_pair *vp, vec_t *v)
{
__dmr1024 z, d0, d1;
__builtin_dmsetdmrz (&z);
d0 = z;
d1 = z;
__builtin_mma_dmxvbf16gerx2pp (&d0, vp[0], v[0]);
__builtin_mma_dmxvbf16gerx2pp (&d1, vp[1], v[1]);
dst[0] = d0;
dst[1] = d1;
}
Generates below asm,
foo:
lxvp %vs10,0(%r4)
lxv %vs9,0(%r5)
dmsetdmrz %dm1
lxvp %vs0,32(%r4)
lxv %vs12,16(%r5)
dmxvbf16gerx2pp %dm1,%vs10,%vs9
dmxxextfdmr512 %vs4,%vs6,%dm1,0
dmxxextfdmr512 %vs8,%vs10,%dm1,1
stxvp %vs6,64(%r3)
dmxvbf16gerx2pp %dm1,%vs0,%vs12
stxvp %vs4,96(%r3)
dmxxextfdmr512 %vs0,%vs2,%dm1,0
dmxxextfdmr512 %vs4,%vs6,%dm1,1
stxvp %vs10,0(%r3)
stxvp %vs8,32(%r3)
stxvp %vs6,128(%r3)
stxvp %vs4,160(%r3)
stxvp %vs2,192(%r3)
stxvp %vs0,224(%r3)
blr
Expectation is to each
dmxvbf16gerx2pp must start from a zeroed DMR (a dmsetdmrz, or a dmmr
copy of the zero).
No dmmr or second dmsetdmrz is emitted between the two accumulations.
dmxvbf16gerx2pp reads the old DMR contents
But Power10 Emits correct code,
#include <altivec.h>
typedef vector unsigned char vec_t;
void
foo (__vector_quad *dst, vec_t *a, vec_t *b)
{
__vector_quad z, d0, d1;
__builtin_mma_xxsetaccz (&z);
d0 = z;
d1 = z;
__builtin_mma_xvbf16ger2pp (&d0, a[0], b[0]);
__builtin_mma_xvbf16ger2pp (&d1, a[1], b[1]);
dst[0] = d0;
dst[1] = d1;
}
foo:
xxsetaccz 0
xxmfacc 0
lxv %vs45,0(%r4)
lxv %vs44,0(%r5)
lxv %vs32,16(%r4)
lxv %vs33,16(%r5)
xxlor %vs11,%vs3,%vs3
xxlor %vs10,%vs2,%vs2
xxlor %vs9,%vs1,%vs1
xxlor %vs8,%vs0,%vs0
xvbf16ger2pp 0,%vs32,%vs33
xxmtacc 2
xxmfacc 0
xvbf16ger2pp 2,%vs45,%vs44
xxmfacc 2
stxvp %vs2,64(%r3)
stxvp %vs0,96(%r3)
stxvp %vs10,0(%r3)
stxvp %vs8,32(%r3)
blr