Patchwork Fix PR tree-optimization/46167

login
register
mail settings
Submitter Ira Rosen
Date Oct. 26, 2010, 3:53 p.m.
Message ID <OF4B318A2E.A2837690-ONC22577C8.0054DD52-C22577C8.005755BA@il.ibm.com>
Download mbox | patch
Permalink /patch/69261/
State New
Headers show

Comments

Ira Rosen - Oct. 26, 2010, 3:53 p.m.
Hi,

This patch adds a check that a basic block exists before calling
flow_bb_inside_loop_p.

Bootstrapped and tested on x86_64-suse-linux.
Committed to trunk.

Now testing the patch for 4.5 on x86_64-suse-linux. OK for 4.5 once the
testing completes?

Thanks,
Ira

ChangeLog:

	PR tree-optimization/46167
	* tree-vect-patterns.c (vect_recog_dot_prod_pattern): Check that
there
	is basic block for the statement.

testsuite/ChangeLog:

	PR tree-optimization/46167
	* gcc.dg/vect/O-pr46167.c: New.
	* gcc.dg/vect/vect.exp: Run tests with -O.


4.6 patch:


   /* FORNOW.  Can continue analyzing the def-use chain when this stmt in a
phi
Richard Guenther - Oct. 26, 2010, 7:12 p.m.
On Tue, Oct 26, 2010 at 11:53 AM, Ira Rosen <IRAR@il.ibm.com> wrote:
>
> Hi,
>
> This patch adds a check that a basic block exists before calling
> flow_bb_inside_loop_p.
>
> Bootstrapped and tested on x86_64-suse-linux.
> Committed to trunk.
>
> Now testing the patch for 4.5 on x86_64-suse-linux. OK for 4.5 once the
> testing completes?

Why is the stmt not in any BB?

Richard.

> Thanks,
> Ira
>
> ChangeLog:
>
>        PR tree-optimization/46167
>        * tree-vect-patterns.c (vect_recog_dot_prod_pattern): Check that
> there
>        is basic block for the statement.
>
> testsuite/ChangeLog:
>
>        PR tree-optimization/46167
>        * gcc.dg/vect/O-pr46167.c: New.
>        * gcc.dg/vect/vect.exp: Run tests with -O.
>
>
> 4.6 patch:
>
> Index: testsuite/gcc.dg/vect/O-pr46167.c
> ===================================================================
> --- testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
> +++ testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
> @@ -0,0 +1,11 @@
> +/* { dg-do compile } */
> +
> +int foo (char c, int i)
> +{
> +  int s = 0;
> +  while (i--)
> +    s += c;
> +  return s;
> +}
> +
> +/* { dg-final { cleanup-tree-dump "vect" } } */
> Index: testsuite/gcc.dg/vect/vect.exp
> ===================================================================
> --- testsuite/gcc.dg/vect/vect.exp      (revision 165969)
> +++ testsuite/gcc.dg/vect/vect.exp      (working copy)
> @@ -126,6 +126,11 @@ set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
>  lappend O1_VECTCFLAGS "-O1"
>  lappend O1_VECTCFLAGS "-fdump-tree-vect-details"
>
> +global O_VECTCFLAGS
> +set O_VECTCFLAGS $DEFAULT_VECTCFLAGS
> +lappend O_VECTCFLAGS "-O"
> +lappend O_VECTCFLAGS "-fdump-tree-vect-details"
> +
>  lappend DEFAULT_VECTCFLAGS "-O2"
>
>  # Tests that should be run without generating dump info
> @@ -287,6 +292,10 @@ dg-runtest [lsort [glob -nocomplain $src
>  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]]  \
>         "" $O1_VECTCFLAGS
>
> +# With -O
> +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]]  \
> +        "" $O_VECTCFLAGS
> +
>  # -fno-tree-reassoc
>  set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
>  lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
> Index: tree-vect-patterns.c
> ===================================================================
> --- tree-vect-patterns.c        (revision 165969)
> +++ tree-vect-patterns.c        (working copy)
> @@ -257,7 +257,7 @@ vect_recog_dot_prod_pattern (gimple last
>   stmt = SSA_NAME_DEF_STMT (oprnd0);
>
>   /* It could not be the dot_prod pattern if the stmt is outside the loop.
> */
> -  if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
> +  if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb
> (stmt)))
>     return NULL;
>
>   /* FORNOW.  Can continue analyzing the def-use chain when this stmt in a
> phi
>
>
> 4.5 patch:
>
> Index: testsuite/gcc.dg/vect/O-pr46167.c
> ===================================================================
> --- testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
> +++ testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
> @@ -0,0 +1,11 @@
> +/* { dg-do compile } */
> +
> +int foo (char c, int i)
> +{
> +  int s = 0;
> +  while (i--)
> +    s += c;
> +  return s;
> +}
> +
> +/* { dg-final { cleanup-tree-dump "vect" } } */
> Index: testsuite/gcc.dg/vect/vect.exp
> ===================================================================
> --- testsuite/gcc.dg/vect/vect.exp      (revision 165269)
> +++ testsuite/gcc.dg/vect/vect.exp      (working copy)
> @@ -122,6 +122,11 @@ set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
>  lappend O1_VECTCFLAGS "-O1"
>  lappend O1_VECTCFLAGS "-fdump-tree-vect-details"
>
> +global O_VECTCFLAGS
> +set O_VECTCFLAGS $DEFAULT_VECTCFLAGS
> +lappend O_VECTCFLAGS "-O"
> +lappend O_VECTCFLAGS "-fdump-tree-vect-details"
> +
>  lappend DEFAULT_VECTCFLAGS "-O2"
>
>  # Tests that should be run without generating dump info
> @@ -283,6 +288,10 @@ dg-runtest [lsort [glob -nocomplain $src
>  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]]  \
>         "" $O1_VECTCFLAGS
>
> +# With -O
> +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]]  \
> +        "" $O_VECTCFLAGS
> +
>  # -fno-tree-reassoc
>  set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
>  lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
> Index: tree-vect-patterns.c
> ===================================================================
> --- tree-vect-patterns.c        (revision 165269)
> +++ tree-vect-patterns.c        (working copy)
> @@ -256,7 +256,7 @@ vect_recog_dot_prod_pattern (gimple last
>   stmt = SSA_NAME_DEF_STMT (oprnd0);
>
>   /* It could not be the dot_prod pattern if the stmt is outside the loop.
> */
> -  if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
> +  if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb
> (stmt)))
>     return NULL;
>
>   /* FORNOW.  Can continue analyzing the def-use chain when this stmt in a
> phi
>
>
Ira Rosen - Oct. 26, 2010, 7:34 p.m.
Richard Guenther <richard.guenther@gmail.com> wrote on 26/10/2010 09:12:50
PM:

> On Tue, Oct 26, 2010 at 11:53 AM, Ira Rosen <IRAR@il.ibm.com> wrote:
> >
> > Hi,
> >
> > This patch adds a check that a basic block exists before calling
> > flow_bb_inside_loop_p.
> >
> > Bootstrapped and tested on x86_64-suse-linux.
> > Committed to trunk.
> >
> > Now testing the patch for 4.5 on x86_64-suse-linux. OK for 4.5 once the
> > testing completes?
>
> Why is the stmt not in any BB?

It's a function argument.

Ira

>
> Richard.
>
> > Thanks,
> > Ira
> >
> > ChangeLog:
> >
> >        PR tree-optimization/46167
> >        * tree-vect-patterns.c (vect_recog_dot_prod_pattern): Check that
> > there
> >        is basic block for the statement.
> >
> > testsuite/ChangeLog:
> >
> >        PR tree-optimization/46167
> >        * gcc.dg/vect/O-pr46167.c: New.
> >        * gcc.dg/vect/vect.exp: Run tests with -O.
> >
> >
> > 4.6 patch:
> >
> > Index: testsuite/gcc.dg/vect/O-pr46167.c
> > ===================================================================
> > --- testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
> > +++ testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
> > @@ -0,0 +1,11 @@
> > +/* { dg-do compile } */
> > +
> > +int foo (char c, int i)
> > +{
> > +  int s = 0;
> > +  while (i--)
> > +    s += c;
> > +  return s;
> > +}
> > +
> > +/* { dg-final { cleanup-tree-dump "vect" } } */
> > Index: testsuite/gcc.dg/vect/vect.exp
> > ===================================================================
> > --- testsuite/gcc.dg/vect/vect.exp      (revision 165969)
> > +++ testsuite/gcc.dg/vect/vect.exp      (working copy)
> > @@ -126,6 +126,11 @@ set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
> >  lappend O1_VECTCFLAGS "-O1"
> >  lappend O1_VECTCFLAGS "-fdump-tree-vect-details"
> >
> > +global O_VECTCFLAGS
> > +set O_VECTCFLAGS $DEFAULT_VECTCFLAGS
> > +lappend O_VECTCFLAGS "-O"
> > +lappend O_VECTCFLAGS "-fdump-tree-vect-details"
> > +
> >  lappend DEFAULT_VECTCFLAGS "-O2"
> >
> >  # Tests that should be run without generating dump info
> > @@ -287,6 +292,10 @@ dg-runtest [lsort [glob -nocomplain $src
> >  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]]  \
> >         "" $O1_VECTCFLAGS
> >
> > +# With -O
> > +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]]  \
> > +        "" $O_VECTCFLAGS
> > +
> >  # -fno-tree-reassoc
> >  set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
> >  lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
> > Index: tree-vect-patterns.c
> > ===================================================================
> > --- tree-vect-patterns.c        (revision 165969)
> > +++ tree-vect-patterns.c        (working copy)
> > @@ -257,7 +257,7 @@ vect_recog_dot_prod_pattern (gimple last
> >   stmt = SSA_NAME_DEF_STMT (oprnd0);
> >
> >   /* It could not be the dot_prod pattern if the stmt is outside the
loop.
> > */
> > -  if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
> > +  if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb
> > (stmt)))
> >     return NULL;
> >
> >   /* FORNOW.  Can continue analyzing the def-use chain when this stmt
in a
> > phi
> >
> >
> > 4.5 patch:
> >
> > Index: testsuite/gcc.dg/vect/O-pr46167.c
> > ===================================================================
> > --- testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
> > +++ testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
> > @@ -0,0 +1,11 @@
> > +/* { dg-do compile } */
> > +
> > +int foo (char c, int i)
> > +{
> > +  int s = 0;
> > +  while (i--)
> > +    s += c;
> > +  return s;
> > +}
> > +
> > +/* { dg-final { cleanup-tree-dump "vect" } } */
> > Index: testsuite/gcc.dg/vect/vect.exp
> > ===================================================================
> > --- testsuite/gcc.dg/vect/vect.exp      (revision 165269)
> > +++ testsuite/gcc.dg/vect/vect.exp      (working copy)
> > @@ -122,6 +122,11 @@ set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
> >  lappend O1_VECTCFLAGS "-O1"
> >  lappend O1_VECTCFLAGS "-fdump-tree-vect-details"
> >
> > +global O_VECTCFLAGS
> > +set O_VECTCFLAGS $DEFAULT_VECTCFLAGS
> > +lappend O_VECTCFLAGS "-O"
> > +lappend O_VECTCFLAGS "-fdump-tree-vect-details"
> > +
> >  lappend DEFAULT_VECTCFLAGS "-O2"
> >
> >  # Tests that should be run without generating dump info
> > @@ -283,6 +288,10 @@ dg-runtest [lsort [glob -nocomplain $src
> >  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]]  \
> >         "" $O1_VECTCFLAGS
> >
> > +# With -O
> > +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]]  \
> > +        "" $O_VECTCFLAGS
> > +
> >  # -fno-tree-reassoc
> >  set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
> >  lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
> > Index: tree-vect-patterns.c
> > ===================================================================
> > --- tree-vect-patterns.c        (revision 165269)
> > +++ tree-vect-patterns.c        (working copy)
> > @@ -256,7 +256,7 @@ vect_recog_dot_prod_pattern (gimple last
> >   stmt = SSA_NAME_DEF_STMT (oprnd0);
> >
> >   /* It could not be the dot_prod pattern if the stmt is outside the
loop.
> > */
> > -  if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
> > +  if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb
> > (stmt)))
> >     return NULL;
> >
> >   /* FORNOW.  Can continue analyzing the def-use chain when this stmt
in a
> > phi
> >
> >
Richard Guenther - Oct. 26, 2010, 7:35 p.m.
On Tue, Oct 26, 2010 at 3:34 PM, Ira Rosen <IRAR@il.ibm.com> wrote:
>
>
> Richard Guenther <richard.guenther@gmail.com> wrote on 26/10/2010 09:12:50
> PM:
>
>> On Tue, Oct 26, 2010 at 11:53 AM, Ira Rosen <IRAR@il.ibm.com> wrote:
>> >
>> > Hi,
>> >
>> > This patch adds a check that a basic block exists before calling
>> > flow_bb_inside_loop_p.
>> >
>> > Bootstrapped and tested on x86_64-suse-linux.
>> > Committed to trunk.
>> >
>> > Now testing the patch for 4.5 on x86_64-suse-linux. OK for 4.5 once the
>> > testing completes?
>>
>> Why is the stmt not in any BB?
>
> It's a function argument.

You mean it's the defining statement for a parameter SSA name?  In that
case, yes, the patch is ok for backporting

Thanks,
Richard.

> Ira
>
>>
>> Richard.
>>
>> > Thanks,
>> > Ira
>> >
>> > ChangeLog:
>> >
>> >        PR tree-optimization/46167
>> >        * tree-vect-patterns.c (vect_recog_dot_prod_pattern): Check that
>> > there
>> >        is basic block for the statement.
>> >
>> > testsuite/ChangeLog:
>> >
>> >        PR tree-optimization/46167
>> >        * gcc.dg/vect/O-pr46167.c: New.
>> >        * gcc.dg/vect/vect.exp: Run tests with -O.
>> >
>> >
>> > 4.6 patch:
>> >
>> > Index: testsuite/gcc.dg/vect/O-pr46167.c
>> > ===================================================================
>> > --- testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
>> > +++ testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
>> > @@ -0,0 +1,11 @@
>> > +/* { dg-do compile } */
>> > +
>> > +int foo (char c, int i)
>> > +{
>> > +  int s = 0;
>> > +  while (i--)
>> > +    s += c;
>> > +  return s;
>> > +}
>> > +
>> > +/* { dg-final { cleanup-tree-dump "vect" } } */
>> > Index: testsuite/gcc.dg/vect/vect.exp
>> > ===================================================================
>> > --- testsuite/gcc.dg/vect/vect.exp      (revision 165969)
>> > +++ testsuite/gcc.dg/vect/vect.exp      (working copy)
>> > @@ -126,6 +126,11 @@ set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
>> >  lappend O1_VECTCFLAGS "-O1"
>> >  lappend O1_VECTCFLAGS "-fdump-tree-vect-details"
>> >
>> > +global O_VECTCFLAGS
>> > +set O_VECTCFLAGS $DEFAULT_VECTCFLAGS
>> > +lappend O_VECTCFLAGS "-O"
>> > +lappend O_VECTCFLAGS "-fdump-tree-vect-details"
>> > +
>> >  lappend DEFAULT_VECTCFLAGS "-O2"
>> >
>> >  # Tests that should be run without generating dump info
>> > @@ -287,6 +292,10 @@ dg-runtest [lsort [glob -nocomplain $src
>> >  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]]  \
>> >         "" $O1_VECTCFLAGS
>> >
>> > +# With -O
>> > +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]]  \
>> > +        "" $O_VECTCFLAGS
>> > +
>> >  # -fno-tree-reassoc
>> >  set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
>> >  lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
>> > Index: tree-vect-patterns.c
>> > ===================================================================
>> > --- tree-vect-patterns.c        (revision 165969)
>> > +++ tree-vect-patterns.c        (working copy)
>> > @@ -257,7 +257,7 @@ vect_recog_dot_prod_pattern (gimple last
>> >   stmt = SSA_NAME_DEF_STMT (oprnd0);
>> >
>> >   /* It could not be the dot_prod pattern if the stmt is outside the
> loop.
>> > */
>> > -  if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
>> > +  if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb
>> > (stmt)))
>> >     return NULL;
>> >
>> >   /* FORNOW.  Can continue analyzing the def-use chain when this stmt
> in a
>> > phi
>> >
>> >
>> > 4.5 patch:
>> >
>> > Index: testsuite/gcc.dg/vect/O-pr46167.c
>> > ===================================================================
>> > --- testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
>> > +++ testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
>> > @@ -0,0 +1,11 @@
>> > +/* { dg-do compile } */
>> > +
>> > +int foo (char c, int i)
>> > +{
>> > +  int s = 0;
>> > +  while (i--)
>> > +    s += c;
>> > +  return s;
>> > +}
>> > +
>> > +/* { dg-final { cleanup-tree-dump "vect" } } */
>> > Index: testsuite/gcc.dg/vect/vect.exp
>> > ===================================================================
>> > --- testsuite/gcc.dg/vect/vect.exp      (revision 165269)
>> > +++ testsuite/gcc.dg/vect/vect.exp      (working copy)
>> > @@ -122,6 +122,11 @@ set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
>> >  lappend O1_VECTCFLAGS "-O1"
>> >  lappend O1_VECTCFLAGS "-fdump-tree-vect-details"
>> >
>> > +global O_VECTCFLAGS
>> > +set O_VECTCFLAGS $DEFAULT_VECTCFLAGS
>> > +lappend O_VECTCFLAGS "-O"
>> > +lappend O_VECTCFLAGS "-fdump-tree-vect-details"
>> > +
>> >  lappend DEFAULT_VECTCFLAGS "-O2"
>> >
>> >  # Tests that should be run without generating dump info
>> > @@ -283,6 +288,10 @@ dg-runtest [lsort [glob -nocomplain $src
>> >  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]]  \
>> >         "" $O1_VECTCFLAGS
>> >
>> > +# With -O
>> > +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]]  \
>> > +        "" $O_VECTCFLAGS
>> > +
>> >  # -fno-tree-reassoc
>> >  set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
>> >  lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
>> > Index: tree-vect-patterns.c
>> > ===================================================================
>> > --- tree-vect-patterns.c        (revision 165269)
>> > +++ tree-vect-patterns.c        (working copy)
>> > @@ -256,7 +256,7 @@ vect_recog_dot_prod_pattern (gimple last
>> >   stmt = SSA_NAME_DEF_STMT (oprnd0);
>> >
>> >   /* It could not be the dot_prod pattern if the stmt is outside the
> loop.
>> > */
>> > -  if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
>> > +  if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb
>> > (stmt)))
>> >     return NULL;
>> >
>> >   /* FORNOW.  Can continue analyzing the def-use chain when this stmt
> in a
>> > phi
>> >
>> >
>
>
Changpeng Fang - Oct. 26, 2010, 8:13 p.m.
Thanks.

This fix should also be back-ported to 4.5 branch.

Changpeng



On Tue, Oct 26, 2010 at 12:35 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Tue, Oct 26, 2010 at 3:34 PM, Ira Rosen <IRAR@il.ibm.com> wrote:
>>
>>
>> Richard Guenther <richard.guenther@gmail.com> wrote on 26/10/2010 09:12:50
>> PM:
>>
>>> On Tue, Oct 26, 2010 at 11:53 AM, Ira Rosen <IRAR@il.ibm.com> wrote:
>>> >
>>> > Hi,
>>> >
>>> > This patch adds a check that a basic block exists before calling
>>> > flow_bb_inside_loop_p.
>>> >
>>> > Bootstrapped and tested on x86_64-suse-linux.
>>> > Committed to trunk.
>>> >
>>> > Now testing the patch for 4.5 on x86_64-suse-linux. OK for 4.5 once the
>>> > testing completes?
>>>
>>> Why is the stmt not in any BB?
>>
>> It's a function argument.
>
> You mean it's the defining statement for a parameter SSA name?  In that
> case, yes, the patch is ok for backporting
>
> Thanks,
> Richard.
>
>> Ira
>>
>>>
>>> Richard.
>>>
>>> > Thanks,
>>> > Ira
>>> >
>>> > ChangeLog:
>>> >
>>> >        PR tree-optimization/46167
>>> >        * tree-vect-patterns.c (vect_recog_dot_prod_pattern): Check that
>>> > there
>>> >        is basic block for the statement.
>>> >
>>> > testsuite/ChangeLog:
>>> >
>>> >        PR tree-optimization/46167
>>> >        * gcc.dg/vect/O-pr46167.c: New.
>>> >        * gcc.dg/vect/vect.exp: Run tests with -O.
>>> >
>>> >
>>> > 4.6 patch:
>>> >
>>> > Index: testsuite/gcc.dg/vect/O-pr46167.c
>>> > ===================================================================
>>> > --- testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
>>> > +++ testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
>>> > @@ -0,0 +1,11 @@
>>> > +/* { dg-do compile } */
>>> > +
>>> > +int foo (char c, int i)
>>> > +{
>>> > +  int s = 0;
>>> > +  while (i--)
>>> > +    s += c;
>>> > +  return s;
>>> > +}
>>> > +
>>> > +/* { dg-final { cleanup-tree-dump "vect" } } */
>>> > Index: testsuite/gcc.dg/vect/vect.exp
>>> > ===================================================================
>>> > --- testsuite/gcc.dg/vect/vect.exp      (revision 165969)
>>> > +++ testsuite/gcc.dg/vect/vect.exp      (working copy)
>>> > @@ -126,6 +126,11 @@ set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
>>> >  lappend O1_VECTCFLAGS "-O1"
>>> >  lappend O1_VECTCFLAGS "-fdump-tree-vect-details"
>>> >
>>> > +global O_VECTCFLAGS
>>> > +set O_VECTCFLAGS $DEFAULT_VECTCFLAGS
>>> > +lappend O_VECTCFLAGS "-O"
>>> > +lappend O_VECTCFLAGS "-fdump-tree-vect-details"
>>> > +
>>> >  lappend DEFAULT_VECTCFLAGS "-O2"
>>> >
>>> >  # Tests that should be run without generating dump info
>>> > @@ -287,6 +292,10 @@ dg-runtest [lsort [glob -nocomplain $src
>>> >  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]]  \
>>> >         "" $O1_VECTCFLAGS
>>> >
>>> > +# With -O
>>> > +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]]  \
>>> > +        "" $O_VECTCFLAGS
>>> > +
>>> >  # -fno-tree-reassoc
>>> >  set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
>>> >  lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
>>> > Index: tree-vect-patterns.c
>>> > ===================================================================
>>> > --- tree-vect-patterns.c        (revision 165969)
>>> > +++ tree-vect-patterns.c        (working copy)
>>> > @@ -257,7 +257,7 @@ vect_recog_dot_prod_pattern (gimple last
>>> >   stmt = SSA_NAME_DEF_STMT (oprnd0);
>>> >
>>> >   /* It could not be the dot_prod pattern if the stmt is outside the
>> loop.
>>> > */
>>> > -  if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
>>> > +  if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb
>>> > (stmt)))
>>> >     return NULL;
>>> >
>>> >   /* FORNOW.  Can continue analyzing the def-use chain when this stmt
>> in a
>>> > phi
>>> >
>>> >
>>> > 4.5 patch:
>>> >
>>> > Index: testsuite/gcc.dg/vect/O-pr46167.c
>>> > ===================================================================
>>> > --- testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
>>> > +++ testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
>>> > @@ -0,0 +1,11 @@
>>> > +/* { dg-do compile } */
>>> > +
>>> > +int foo (char c, int i)
>>> > +{
>>> > +  int s = 0;
>>> > +  while (i--)
>>> > +    s += c;
>>> > +  return s;
>>> > +}
>>> > +
>>> > +/* { dg-final { cleanup-tree-dump "vect" } } */
>>> > Index: testsuite/gcc.dg/vect/vect.exp
>>> > ===================================================================
>>> > --- testsuite/gcc.dg/vect/vect.exp      (revision 165269)
>>> > +++ testsuite/gcc.dg/vect/vect.exp      (working copy)
>>> > @@ -122,6 +122,11 @@ set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
>>> >  lappend O1_VECTCFLAGS "-O1"
>>> >  lappend O1_VECTCFLAGS "-fdump-tree-vect-details"
>>> >
>>> > +global O_VECTCFLAGS
>>> > +set O_VECTCFLAGS $DEFAULT_VECTCFLAGS
>>> > +lappend O_VECTCFLAGS "-O"
>>> > +lappend O_VECTCFLAGS "-fdump-tree-vect-details"
>>> > +
>>> >  lappend DEFAULT_VECTCFLAGS "-O2"
>>> >
>>> >  # Tests that should be run without generating dump info
>>> > @@ -283,6 +288,10 @@ dg-runtest [lsort [glob -nocomplain $src
>>> >  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]]  \
>>> >         "" $O1_VECTCFLAGS
>>> >
>>> > +# With -O
>>> > +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]]  \
>>> > +        "" $O_VECTCFLAGS
>>> > +
>>> >  # -fno-tree-reassoc
>>> >  set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
>>> >  lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
>>> > Index: tree-vect-patterns.c
>>> > ===================================================================
>>> > --- tree-vect-patterns.c        (revision 165269)
>>> > +++ tree-vect-patterns.c        (working copy)
>>> > @@ -256,7 +256,7 @@ vect_recog_dot_prod_pattern (gimple last
>>> >   stmt = SSA_NAME_DEF_STMT (oprnd0);
>>> >
>>> >   /* It could not be the dot_prod pattern if the stmt is outside the
>> loop.
>>> > */
>>> > -  if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
>>> > +  if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb
>>> > (stmt)))
>>> >     return NULL;
>>> >
>>> >   /* FORNOW.  Can continue analyzing the def-use chain when this stmt
>> in a
>>> > phi
>>> >
>>> >
>>
>>
>
Ira Rosen - Oct. 26, 2010, 8:18 p.m.
Richard Guenther <richard.guenther@gmail.com> wrote on 26/10/2010 09:35:47
PM:

>
> On Tue, Oct 26, 2010 at 3:34 PM, Ira Rosen <IRAR@il.ibm.com> wrote:
> >
> >
> > Richard Guenther <richard.guenther@gmail.com> wrote on 26/10/2010
09:12:50
> > PM:
> >
> >> On Tue, Oct 26, 2010 at 11:53 AM, Ira Rosen <IRAR@il.ibm.com> wrote:
> >> >
> >> > Hi,
> >> >
> >> > This patch adds a check that a basic block exists before calling
> >> > flow_bb_inside_loop_p.
> >> >
> >> > Bootstrapped and tested on x86_64-suse-linux.
> >> > Committed to trunk.
> >> >
> >> > Now testing the patch for 4.5 on x86_64-suse-linux. OK for 4.5 once
the
> >> > testing completes?
> >>
> >> Why is the stmt not in any BB?
> >
> > It's a function argument.
>
> You mean it's the defining statement for a parameter SSA name?

Yes.

> In that
> case, yes, the patch is ok for backporting

Committed.

Thanks,
Ira

>
> Thanks,
> Richard.
>
> > Ira
> >
> >>
> >> Richard.
> >>
> >> > Thanks,
> >> > Ira
> >> >
> >> > ChangeLog:
> >> >
> >> >        PR tree-optimization/46167
> >> >        * tree-vect-patterns.c (vect_recog_dot_prod_pattern): Check
that
> >> > there
> >> >        is basic block for the statement.
> >> >
> >> > testsuite/ChangeLog:
> >> >
> >> >        PR tree-optimization/46167
> >> >        * gcc.dg/vect/O-pr46167.c: New.
> >> >        * gcc.dg/vect/vect.exp: Run tests with -O.
> >> >
> >> >
> >> > 4.6 patch:
> >> >
> >> > Index: testsuite/gcc.dg/vect/O-pr46167.c
> >> > ===================================================================
> >> > --- testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
> >> > +++ testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
> >> > @@ -0,0 +1,11 @@
> >> > +/* { dg-do compile } */
> >> > +
> >> > +int foo (char c, int i)
> >> > +{
> >> > +  int s = 0;
> >> > +  while (i--)
> >> > +    s += c;
> >> > +  return s;
> >> > +}
> >> > +
> >> > +/* { dg-final { cleanup-tree-dump "vect" } } */
> >> > Index: testsuite/gcc.dg/vect/vect.exp
> >> > ===================================================================
> >> > --- testsuite/gcc.dg/vect/vect.exp      (revision 165969)
> >> > +++ testsuite/gcc.dg/vect/vect.exp      (working copy)
> >> > @@ -126,6 +126,11 @@ set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
> >> >  lappend O1_VECTCFLAGS "-O1"
> >> >  lappend O1_VECTCFLAGS "-fdump-tree-vect-details"
> >> >
> >> > +global O_VECTCFLAGS
> >> > +set O_VECTCFLAGS $DEFAULT_VECTCFLAGS
> >> > +lappend O_VECTCFLAGS "-O"
> >> > +lappend O_VECTCFLAGS "-fdump-tree-vect-details"
> >> > +
> >> >  lappend DEFAULT_VECTCFLAGS "-O2"
> >> >
> >> >  # Tests that should be run without generating dump info
> >> > @@ -287,6 +292,10 @@ dg-runtest [lsort [glob -nocomplain $src
> >> >  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]]
\
> >> >         "" $O1_VECTCFLAGS
> >> >
> >> > +# With -O
> >> > +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]]  \
> >> > +        "" $O_VECTCFLAGS
> >> > +
> >> >  # -fno-tree-reassoc
> >> >  set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
> >> >  lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
> >> > Index: tree-vect-patterns.c
> >> > ===================================================================
> >> > --- tree-vect-patterns.c        (revision 165969)
> >> > +++ tree-vect-patterns.c        (working copy)
> >> > @@ -257,7 +257,7 @@ vect_recog_dot_prod_pattern (gimple last
> >> >   stmt = SSA_NAME_DEF_STMT (oprnd0);
> >> >
> >> >   /* It could not be the dot_prod pattern if the stmt is outside the
> > loop.
> >> > */
> >> > -  if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
> >> > +  if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb
> >> > (stmt)))
> >> >     return NULL;
> >> >
> >> >   /* FORNOW.  Can continue analyzing the def-use chain when this
stmt
> > in a
> >> > phi
> >> >
> >> >
> >> > 4.5 patch:
> >> >
> >> > Index: testsuite/gcc.dg/vect/O-pr46167.c
> >> > ===================================================================
> >> > --- testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
> >> > +++ testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
> >> > @@ -0,0 +1,11 @@
> >> > +/* { dg-do compile } */
> >> > +
> >> > +int foo (char c, int i)
> >> > +{
> >> > +  int s = 0;
> >> > +  while (i--)
> >> > +    s += c;
> >> > +  return s;
> >> > +}
> >> > +
> >> > +/* { dg-final { cleanup-tree-dump "vect" } } */
> >> > Index: testsuite/gcc.dg/vect/vect.exp
> >> > ===================================================================
> >> > --- testsuite/gcc.dg/vect/vect.exp      (revision 165269)
> >> > +++ testsuite/gcc.dg/vect/vect.exp      (working copy)
> >> > @@ -122,6 +122,11 @@ set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
> >> >  lappend O1_VECTCFLAGS "-O1"
> >> >  lappend O1_VECTCFLAGS "-fdump-tree-vect-details"
> >> >
> >> > +global O_VECTCFLAGS
> >> > +set O_VECTCFLAGS $DEFAULT_VECTCFLAGS
> >> > +lappend O_VECTCFLAGS "-O"
> >> > +lappend O_VECTCFLAGS "-fdump-tree-vect-details"
> >> > +
> >> >  lappend DEFAULT_VECTCFLAGS "-O2"
> >> >
> >> >  # Tests that should be run without generating dump info
> >> > @@ -283,6 +288,10 @@ dg-runtest [lsort [glob -nocomplain $src
> >> >  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]]
\
> >> >         "" $O1_VECTCFLAGS
> >> >
> >> > +# With -O
> >> > +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]]  \
> >> > +        "" $O_VECTCFLAGS
> >> > +
> >> >  # -fno-tree-reassoc
> >> >  set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
> >> >  lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
> >> > Index: tree-vect-patterns.c
> >> > ===================================================================
> >> > --- tree-vect-patterns.c        (revision 165269)
> >> > +++ tree-vect-patterns.c        (working copy)
> >> > @@ -256,7 +256,7 @@ vect_recog_dot_prod_pattern (gimple last
> >> >   stmt = SSA_NAME_DEF_STMT (oprnd0);
> >> >
> >> >   /* It could not be the dot_prod pattern if the stmt is outside the
> > loop.
> >> > */
> >> > -  if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
> >> > +  if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb
> >> > (stmt)))
> >> >     return NULL;
> >> >
> >> >   /* FORNOW.  Can continue analyzing the def-use chain when this
stmt
> > in a
> >> > phi
> >> >
> >> >
> >
> >

Patch

Index: testsuite/gcc.dg/vect/O-pr46167.c
===================================================================
--- testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
+++ testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
@@ -0,0 +1,11 @@ 
+/* { dg-do compile } */
+
+int foo (char c, int i)
+{
+  int s = 0;
+  while (i--)
+    s += c;
+  return s;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect.exp
===================================================================
--- testsuite/gcc.dg/vect/vect.exp      (revision 165969)
+++ testsuite/gcc.dg/vect/vect.exp      (working copy)
@@ -126,6 +126,11 @@  set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
 lappend O1_VECTCFLAGS "-O1"
 lappend O1_VECTCFLAGS "-fdump-tree-vect-details"

+global O_VECTCFLAGS
+set O_VECTCFLAGS $DEFAULT_VECTCFLAGS
+lappend O_VECTCFLAGS "-O"
+lappend O_VECTCFLAGS "-fdump-tree-vect-details"
+
 lappend DEFAULT_VECTCFLAGS "-O2"

 # Tests that should be run without generating dump info
@@ -287,6 +292,10 @@  dg-runtest [lsort [glob -nocomplain $src
 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]]  \
         "" $O1_VECTCFLAGS

+# With -O
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]]  \
+        "" $O_VECTCFLAGS
+
 # -fno-tree-reassoc
 set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
 lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
Index: tree-vect-patterns.c
===================================================================
--- tree-vect-patterns.c        (revision 165969)
+++ tree-vect-patterns.c        (working copy)
@@ -257,7 +257,7 @@  vect_recog_dot_prod_pattern (gimple last
   stmt = SSA_NAME_DEF_STMT (oprnd0);

   /* It could not be the dot_prod pattern if the stmt is outside the loop.
*/
-  if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
+  if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb
(stmt)))
     return NULL;

   /* FORNOW.  Can continue analyzing the def-use chain when this stmt in a
phi


4.5 patch:

Index: testsuite/gcc.dg/vect/O-pr46167.c
===================================================================
--- testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
+++ testsuite/gcc.dg/vect/O-pr46167.c   (revision 0)
@@ -0,0 +1,11 @@ 
+/* { dg-do compile } */
+
+int foo (char c, int i)
+{
+  int s = 0;
+  while (i--)
+    s += c;
+  return s;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect.exp
===================================================================
--- testsuite/gcc.dg/vect/vect.exp      (revision 165269)
+++ testsuite/gcc.dg/vect/vect.exp      (working copy)
@@ -122,6 +122,11 @@  set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS
 lappend O1_VECTCFLAGS "-O1"
 lappend O1_VECTCFLAGS "-fdump-tree-vect-details"

+global O_VECTCFLAGS
+set O_VECTCFLAGS $DEFAULT_VECTCFLAGS
+lappend O_VECTCFLAGS "-O"
+lappend O_VECTCFLAGS "-fdump-tree-vect-details"
+
 lappend DEFAULT_VECTCFLAGS "-O2"

 # Tests that should be run without generating dump info
@@ -283,6 +288,10 @@  dg-runtest [lsort [glob -nocomplain $src
 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]]  \
         "" $O1_VECTCFLAGS

+# With -O
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]]  \
+        "" $O_VECTCFLAGS
+
 # -fno-tree-reassoc
 set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS
 lappend VECT_SLP_CFLAGS "-fno-tree-reassoc"
Index: tree-vect-patterns.c
===================================================================
--- tree-vect-patterns.c        (revision 165269)
+++ tree-vect-patterns.c        (working copy)
@@ -256,7 +256,7 @@  vect_recog_dot_prod_pattern (gimple last
   stmt = SSA_NAME_DEF_STMT (oprnd0);

   /* It could not be the dot_prod pattern if the stmt is outside the loop.
*/
-  if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
+  if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb
(stmt)))
     return NULL;