https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62147
Kewen Lin <linkw at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED --- Comment #4 from Kewen Lin <linkw at gcc dot gnu.org> --- 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. <bb 3> [local count: 955630224]: # ivtmp.8_3 = PHI <ivtmp.8_10(5), ivtmp.8_2(6)> ivtmp.8_2 = ivtmp.8_3 + 4; _15 = (void *) ivtmp.8_2; MEM[base: _15, offset: 0B] = 0; if (ivtmp.8_2 != _22) goto <bb 6>; [89.00%] else goto <bb 8>; [11.00%] instead of <bb 3> [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 <bb 6>; [89.00%] else goto <bb 8>; [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.