public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/18400] New: wrong unrolling after vectorization due to invalid loop->nb_iterations
@ 2004-11-09 14:50 dorit at il dot ibm dot com
  2004-11-09 14:54 ` [Bug tree-optimization/18400] " dorit at il dot ibm dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dorit at il dot ibm dot com @ 2004-11-09 14:50 UTC (permalink / raw)
  To: gcc-bugs

When a loop like the following:

=============================
#define N 8
int main ()
{
  int b[N] = {0,3,6,9,12,15,18,21};
  int a[N];
  int i;
  for (i = 0; i < N; i++){
      a[i] = b[i];
  }
  /* check results:  */
  for (i = 0; i < N; i++){
      if (a[i] != b[i])
        abort ();
  }
  return 0;
}
=============================

is compiled with:
-O2 -ftree-vectorize -maltivec -funroll-loops 

it gets vectorized and then completely unrolled. The complete unroller looks at 
loop->nb_iterations to get the number of iterations; the problem is that loop-
>nb_iterations is not always updated after vectorization, so the loop ends up 
being unrolled by 8 instead of by 2, and we get an execution failure.

The following patch will fix the problem:

Index: tree-vectorizer.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-vectorizer.c,v
retrieving revision 2.25
diff -c -3 -p -r2.25 tree-vectorizer.c
*** tree-vectorizer.c   8 Nov 2004 13:54:41 -0000       2.25
--- tree-vectorizer.c   9 Nov 2004 13:16:54 -0000
*************** make_loop_iterate_ntimes (struct loop *l
*** 635,640 ****
--- 635,642 ----

    if (vect_debug_stats (loop) || vect_debug_details (loop))
      print_generic_expr (dump_file, cond_stmt, TDF_SLIM);
+   
+   loop->nb_iterations = niters;
  }

  
*************** vect_transform_loop_bound (loop_vec_info
*** 2881,2886 ****
--- 2883,2890 ----

    if (vect_debug_details (NULL))
      print_generic_expr (dump_file, cond_stmt, TDF_SLIM);
+   
+   loop->nb_iterations = new_loop_bound;
  }

-- 
           Summary: wrong unrolling after vectorization due to invalid loop-
                    >nb_iterations
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: dorit at il dot ibm dot com
        ReportedBy: dorit at il dot ibm dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-apple-darwin7.0.0
  GCC host triplet: powerpc-apple-darwin7.0.0
GCC target triplet: powerpc-apple-darwin7.0.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18400


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/18400] wrong unrolling after vectorization due to invalid loop->nb_iterations
  2004-11-09 14:50 [Bug tree-optimization/18400] New: wrong unrolling after vectorization due to invalid loop->nb_iterations dorit at il dot ibm dot com
@ 2004-11-09 14:54 ` dorit at il dot ibm dot com
  2004-11-09 14:56 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dorit at il dot ibm dot com @ 2004-11-09 14:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dorit at il dot ibm dot com  2004-11-09 14:54 -------
Created an attachment (id=7502)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7502&action=view)
testcase


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18400


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/18400] wrong unrolling after vectorization due to invalid loop->nb_iterations
  2004-11-09 14:50 [Bug tree-optimization/18400] New: wrong unrolling after vectorization due to invalid loop->nb_iterations dorit at il dot ibm dot com
  2004-11-09 14:54 ` [Bug tree-optimization/18400] " dorit at il dot ibm dot com
@ 2004-11-09 14:56 ` pinskia at gcc dot gnu dot org
  2004-11-14 18:30 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-09 14:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-09 14:56 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|                            |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-11-09 14:56:05
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18400


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/18400] wrong unrolling after vectorization due to invalid loop->nb_iterations
  2004-11-09 14:50 [Bug tree-optimization/18400] New: wrong unrolling after vectorization due to invalid loop->nb_iterations dorit at il dot ibm dot com
  2004-11-09 14:54 ` [Bug tree-optimization/18400] " dorit at il dot ibm dot com
  2004-11-09 14:56 ` pinskia at gcc dot gnu dot org
@ 2004-11-14 18:30 ` cvs-commit at gcc dot gnu dot org
  2004-11-14 18:33 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-11-14 18:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-11-14 18:30 -------
Subject: Bug 18400

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dorit@gcc.gnu.org	2004-11-14 18:30:36

Modified files:
	gcc            : ChangeLog tree-vectorizer.c 

Log message:
	PR tree-opt/18400
	* tree-vectorizer.c (make_loop_iterate_ntimes): Set loop->nb_iterations.
	(vect_transform_loop_bound): Set loop->nb_iterations.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6334&r2=2.6335
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-vectorizer.c.diff?cvsroot=gcc&r1=2.29&r2=2.30



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18400


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/18400] wrong unrolling after vectorization due to invalid loop->nb_iterations
  2004-11-09 14:50 [Bug tree-optimization/18400] New: wrong unrolling after vectorization due to invalid loop->nb_iterations dorit at il dot ibm dot com
                   ` (2 preceding siblings ...)
  2004-11-14 18:30 ` cvs-commit at gcc dot gnu dot org
@ 2004-11-14 18:33 ` pinskia at gcc dot gnu dot org
  2004-11-14 20:45 ` cvs-commit at gcc dot gnu dot org
  2004-11-15  4:14 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-14 18:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-14 18:33 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18400


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/18400] wrong unrolling after vectorization due to invalid loop->nb_iterations
  2004-11-09 14:50 [Bug tree-optimization/18400] New: wrong unrolling after vectorization due to invalid loop->nb_iterations dorit at il dot ibm dot com
                   ` (3 preceding siblings ...)
  2004-11-14 18:33 ` pinskia at gcc dot gnu dot org
@ 2004-11-14 20:45 ` cvs-commit at gcc dot gnu dot org
  2004-11-15  4:14 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-11-14 20:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-11-14 20:45 -------
Subject: Bug 18400

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dorit@gcc.gnu.org	2004-11-14 20:44:52

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/vect: pr18400.c pr18425.c 

Log message:
	2004-11-14  Dorit Naishlos  <dorit@il.ibm.com>
	
	PR tree-opt/18400
	* gcc.dg/vect/pr18400.c: New test.
	
	2004-11-14  Dorit Naishlos  <dorit@il.ibm.com>
	Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR tree-opt/18425
	* gcc.dg/vect/pr18425.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4599&r2=1.4600
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/vect/pr18400.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/vect/pr18425.c.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18400


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/18400] wrong unrolling after vectorization due to invalid loop->nb_iterations
  2004-11-09 14:50 [Bug tree-optimization/18400] New: wrong unrolling after vectorization due to invalid loop->nb_iterations dorit at il dot ibm dot com
                   ` (4 preceding siblings ...)
  2004-11-14 20:45 ` cvs-commit at gcc dot gnu dot org
@ 2004-11-15  4:14 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-15  4:14 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18400


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-11-15  4:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-09 14:50 [Bug tree-optimization/18400] New: wrong unrolling after vectorization due to invalid loop->nb_iterations dorit at il dot ibm dot com
2004-11-09 14:54 ` [Bug tree-optimization/18400] " dorit at il dot ibm dot com
2004-11-09 14:56 ` pinskia at gcc dot gnu dot org
2004-11-14 18:30 ` cvs-commit at gcc dot gnu dot org
2004-11-14 18:33 ` pinskia at gcc dot gnu dot org
2004-11-14 20:45 ` cvs-commit at gcc dot gnu dot org
2004-11-15  4:14 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).