[Bug target/62147] missed loop counter based optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62147 Kewen Lin changed: What|Removed |Added CC||meissner at gcc dot gnu.org --- Comment #9 from Kewen Lin --- *** Bug 84042 has been marked as a duplicate of this bug. ***
[Bug target/62147] missed loop counter based optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62147 Kewen Lin changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #8 from Kewen Lin --- The fix has been checked in, please verify it.
[Bug target/62147] missed loop counter based optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62147 --- Comment #7 from Kewen Lin --- Author: linkw Date: Thu Jun 27 05:33:15 2019 New Revision: 272732 URL: https://gcc.gnu.org/viewcvs?rev=272732&root=gcc&view=rev Log: One line change onto r272731 PR target/62147 * gcc/loop-iv.c (find_simple_exit) - if (single_exit (loop) && finite_loop_p (loop)) + if (desc->infinite && single_exit (loop) && finite_loop_p (loop)) Modified: trunk/gcc/loop-iv.c
[Bug target/62147] missed loop counter based optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62147 --- Comment #6 from Kewen Lin --- Author: linkw Date: Thu Jun 27 05:24:00 2019 New Revision: 272731 URL: https://gcc.gnu.org/viewcvs?rev=272731&root=gcc&view=rev Log: Call finite_loop_p in RTL to get better finiteness information. gcc/ChangeLog 2019-06-27 Kewen Lin PR target/62147 * gcc/loop-iv.c (find_simple_exit): Call finite_loop_p to update finiteness. gcc/testsuite/ChangeLog 2019-06-27 Kewen Lin PR target/62147 * gcc.target/powerpc/pr62147.c: New test. Added: trunk/gcc/testsuite/gcc.target/powerpc/pr62147.c Modified: trunk/gcc/ChangeLog trunk/gcc/loop-iv.c trunk/gcc/testsuite/ChangeLog
[Bug target/62147] missed loop counter based optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62147 --- Comment #5 from Kewen Lin --- Created attachment 46478 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46478&action=edit one simple patch It can generate expected codes with the patch draft: >---subf 9,10,9 >---addi 9,9,-4 >---srdi 9,9,2 >---addi 9,9,1 >---mtctr 9 .L3: >---stwu 8,4(10) >---bdnz .L3 >---blr
[Bug target/62147] missed loop counter based optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62147 Kewen Lin changed: What|Removed |Added Status|NEW |ASSIGNED --- Comment #4 from Kewen Lin --- It's reproducible on LE too. With the latest trunk, we should add option -fno-tree-loop-distribute-patterns to disable the memset transformation. IVOPTs performs well to use memory based IV to replace the BIV. [local count: 955630224]: # ivtmp.8_3 = PHI ivtmp.8_2 = ivtmp.8_3 + 4; _15 = (void *) ivtmp.8_2; MEM[base: _15, offset: 0B] = 0; if (ivtmp.8_2 != _22) goto ; [89.00%] else goto ; [11.00%] instead of [local count: 955630224]: # i_11 = PHI <0(5), i_8(6)> s_5(D)->b[i_11] = 0; i_8 = i_11 + 1; if (_1 >= i_11) goto ; [89.00%] else goto ; [11.00%] Later the doloop optimization fails to know this loop is finite. Because the loop body has two BBs, BB 4 (address update, store, comp) and BB 6 (latch). The iteration description is calculated from comp (condition), one of the operand is invariant and calculated from BB 3, but we don't have any UD information to back substitute it and determine it's finite then. One idea is to pass down the finiteness information to RTL phase when we perform some eliminated IV transformation, later RTL phase can leverage this information for accurate finiteness.
[Bug target/62147] missed loop counter based optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62147 --- Comment #3 from Segher Boessenkool --- Still happens.
[Bug target/62147] missed loop counter based optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62147 Segher Boessenkool changed: What|Removed |Added Target|powerpc64le |powerpc64*-* Status|UNCONFIRMED |NEW Last reconfirmed||2014-08-16 CC||segher at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Segher Boessenkool --- Confirmed, on powerpc64 with default tuning. -m32 generates bdnz just fine. Using a different limit (as in your code comment) doesn't help. Using long int instead of int does work. The ivopts pass thinks using the pointer as loop counter is cheapest.
[Bug target/62147] missed loop counter based optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62147 --- Comment #1 from Andrew Pinski --- This is related to bug 37451.