https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120675
Bug ID: 120675 Summary: Missed loop invariant code elimination from loop Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vekumar at gcc dot gnu.org Target Milestone: --- For the below case GCC does not remove store of 3 from the loop. void test_licm(int * restrict a, int * restrict b, int n) { for (int i=0;i<n;i++) { b[0] = 3; a[i] = a[i] + b[i]; } } -O3 Assembly --Snip-- .L3: movl $3, (%rsi) movl (%rsi,%rax), %ecx addl %ecx, (%rdi,%rax) addq $4, %rax cmpq %rax, %rdx jne .L3 --Snip-- ref: https://godbolt.org/z/rbhz9z6r1