https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122139
Bug ID: 122139
Summary: bpf: wromg code for __builtin_memset
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: kristerw at gcc dot gnu.org
Target Milestone: ---
Target: bpf-unknown-none
The following function is miscompiled at all optimization levels:
struct A { int i, j; char pad[512]; } a;
int __attribute__((noinline))
foo (void)
{
__builtin_memset (&a, 38, sizeof a);
return a.i;
}
The generated code performs word-sized stores as:
foo:
lddw %r0,a
stw [%r0+0],38
stw [%r0+4],38
stw [%r0+8],38
....
instead of the expected:
foo:
lddw %r0,a
stw [%r0+0],640034342
stw [%r0+4],640034342
stw [%r0+8],640034342
....
where the constant is updated to replicate the value across all bytes.