This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR rtl-optimization/71634


On 06/23/2016 12:56 PM, Martin Liška wrote:
Following patch changes minimum of ira-max-loops-num to 1.
Having the minimum equal to zero does not make much sense.

Ready after it finishes reg&bootstrap on x86_64-linux?

Hmm, why wouldn't a number of zero make sense if you want try to have all loops removed?

The problem seems to be here:

  for (i = 0; n - i + 1 > IRA_MAX_LOOPS_NUM; i++)
    {
      sorted_loops[i]->to_remove_p = true;

and this looks like an off-by-one error. n is the number of elements in the array, so if IRA_MAX_LOOPS_NUM is 1, it'll iterate i from 0 up to n-1, where
  n - i + 1 == 2 > 1
So it'll clear everything, where it seems like it should leave one loop around.

So maybe write this with a standard form of for loop so it's actually comprehensible:

  int maxidx = MIN (IRA_MAX_LOOPS_NUM, n);
  for (i = 0; i < maxidx; i++)
    {
       ....


Bernd


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]