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] 4.1 ivopts bug


On Friday 31 March 2006 14:25, Richard Guenther wrote:
> On 3/31/06, Paul Brook <paul@codesourcery.com> wrote:
> > On Friday 31 March 2006 04:35, Paul Brook wrote:
> > > The attached patch backports a couple of ivopts changes from mainline
> > > to 4.1. While they were nominally to fix missed optimization
> > > opportunities, it appears they also fix a a wrong-code bug.
> > >
> > > When compiling the code below with -O1 the .t75.ivcanon dump contains:
> > > (set_nb_iterations_in_loop = 357913943B)
> > > And the resulting code is incorrect.
> >
> > In case it wasn't clear, this is a regression.
>
> Is there a PR for the 4.1 regression?  Is the testcase you quoted in
> the body taken from the mainline testsuite?  If not, the testcase should be 
added there,
> too.

There is not a PR. Apparently the testcase comes from 126.gcc in spec95
I've attached a testcase that I'll add to both 4.1 and mainline once the patch 
is approved.

Paul
/* Test for a bug in 4.1 ivcanon code.  The loop ends up with two IV, bot with
   a base of &num[1]. In the provess of converting the < condition to =
   we calculate (base1 - 1) - base0, which overflows and gives 0xffffffffu
   leading to a bogus loop iteration count.  */
#include <stdlib.h>

struct f
{
    int initial_offset;
    int can_eliminate;
    int can_eliminate_prev;
};


struct f num[2] = {{1, 3, 5}, {30, 50, 70}}};
int x = 0;

int main()
{
    struct f *p;
    for (p = num; p < &num[1]; p++)
        {
            x += p->can_eliminate;
        }
    if (x != 3)
      abort();
    exit (0);
}

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