On 2021-07-13 23:51, Segher Boessenkool wrote:
On Tue, Jul 13, 2021 at 10:09:25AM +0800, guojiufu wrote:
>For loop looks like:
>  do ;
>  while (n-- > 0); /* while  (n-- > low); */

(This whole loop as written will be optimised away, but :-) )
At -O2, the loop is optimized away.
At -O1, the loop is there.
        .cfi_startproc
        addi %r3,%r3,1
.L2:
        addi %r9,%r3,-1
        mr %r3,%r9
        andi. %r9,%r9,0xff
        bne %cr0,.L2
The patch v2 (https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574596.html)
could help it to be:
        .cfi_startproc
        addi %r3,%r3,1
        mtctr %r3
.L2:
        addi %r3,%r3,-1
        bdnz .L2


There is a patch that could mitigate "-1 +1 pair" in rtl part.
https://gcc.gnu.org/g:8a15faa730f99100f6f3ed12663563356ec5a2c0

Does that solve PR67288 (and its many duplicates)?
Had a test, yes, the "-1 +1" issue in PR67288 was fixed by that patch.

BR,
Jiufu.


Segher

Reply via email to