https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92649
Bug ID: 92649 Summary: dead store elimination Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jiangning.liu at amperecomputing dot com Target Milestone: --- For this small case, int f(void) { int i, a[1024]; for (i=0; i<1024; i++) a[i] = 5; return a[0]; } "gcc -O3" can't figure out the memory stores from a[1] to a[1023] all can be eliminated. The assembly code for aarch64 is as below. movi v0.4s, 0x5 sub sp, sp, #4096 mov x0, sp add x1, sp, 4096 .L2: str q0, [x0], 16 cmp x0, x1 bne .L2 ldr w0, [sp] add sp, sp, 4096 ret