https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123103
--- Comment #2 from Yi <652023330028 at smail dot nju.edu.cn> ---
(In reply to Andrew Pinski from comment #1)
> I am 99% sure that is not valid if ecx points to read only locations.
Thank you very much for your reply. The "simpler sequence" presented jwas just
meant to illustrate some instructions that appear redundant: regardless of the
value of t2 ( in movl t2(%rip), %eax), .L10 will be executed next.
The intended optimization might look like this:
g:
movslq t3(%rip), %rax
testq %rdi, %rdi
je .L7
movq (%rdi,%rax,8), %rax
jmp .L11
.L8:
movl $1, (%rax)
.L11:
movslq t1(%rip), %rdx
movl 4(%rax,%rdx,4), %edx
testl %edx, %edx
je .L8
.L9:
jmp .L9
.L7:
jmp .L7
Would you kindly clarify if you mean that such an optimization might be unsafe?
I would appreciate it very much.