On Mon, Aug 31, 2015 at 6:51 AM, shmeel gutl <shmeelg...@shmuelhome.mine.nu> wrote: > When dealing with an array with known values, pre will evaluate the first > iteration of a loop over the elements. The code generator with then jump > into the loop. This is at best increasing the size of the code. It also > creates inferior code when the hardware supports zero overhead loops. The > attached code demonstrates the difference between an unknown array and a > known array. The loop size has been picked large enough for cunrolli to not > fully unroll the loop. The problem did not exist in gcc 4.8.
I think you were just lucky with GCC 4.8 - the issue is present since forever. Basically it's because we treat a constant as available. So PRE might end up rotating the loop, inserting the 2nd iteration on the latch edge. Unfortunately this transform sometimes improves code-gen, it would be quite simple to disallow this kind of transform generally though. Richard. > >