[PATCH] Fix PR46190

Richard Guenther rguenther@suse.de
Wed Nov 3 13:34:00 GMT 2010


This fixes an ICE introduced by the recent fixes for negative step
vectorization.  The issue is that while for positive steps it doesn't
matter whether we compute peel iterations with the vectorization
factor it does so for negative steps (or rather the way we compute
npeel here).

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2010-11-03  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/46190
	* tree-vect-data-refs.c (vect_enhance_data_refs_alignment):
	Properly compute peel iterations.

	* gfortran.dg/pr46190.f90: New testcase.

Index: gcc/tree-vect-data-refs.c
===================================================================
*** gcc/tree-vect-data-refs.c	(revision 166238)
--- gcc/tree-vect-data-refs.c	(working copy)
*************** vect_enhance_data_refs_alignment (loop_v
*** 1518,1524 ****
                mis = DR_MISALIGNMENT (dr) / GET_MODE_SIZE (TYPE_MODE (
                                                  TREE_TYPE (DR_REF (dr))));
                npeel_tmp = (negative
! 			   ? (mis - nelements) : (nelements - mis)) & (vf - 1);
  
                /* For multiple types, it is possible that the bigger type access
                   will have more than one peeling option.  E.g., a loop with two
--- 1518,1525 ----
                mis = DR_MISALIGNMENT (dr) / GET_MODE_SIZE (TYPE_MODE (
                                                  TREE_TYPE (DR_REF (dr))));
                npeel_tmp = (negative
! 			   ? (mis - nelements) : (nelements - mis))
! 		  & (nelements - 1);
  
                /* For multiple types, it is possible that the bigger type access
                   will have more than one peeling option.  E.g., a loop with two
*************** vect_enhance_data_refs_alignment (loop_v
*** 1722,1728 ****
                   count.  */
                mis = DR_MISALIGNMENT (dr0);
                mis /= GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (DR_REF (dr0))));
!               npeel = (negative ? mis - nelements : nelements - mis) & (vf - 1);
              }
  
  	  /* For interleaved data access every iteration accesses all the
--- 1723,1730 ----
                   count.  */
                mis = DR_MISALIGNMENT (dr0);
                mis /= GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (DR_REF (dr0))));
!               npeel = ((negative ? mis - nelements : nelements - mis)
! 		       & (nelements - 1));
              }
  
  	  /* For interleaved data access every iteration accesses all the
Index: gcc/testsuite/gfortran.dg/pr46190.f90
===================================================================
*** gcc/testsuite/gfortran.dg/pr46190.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/pr46190.f90	(revision 0)
***************
*** 0 ****
--- 1,64 ----
+ ! { dg-do compile }
+ ! { dg-options "-O2 -ftree-vectorize" }
+ 
+       TYPE :: spot_weld_type                                            
+         CHARACTER(8)     PLACE      ! Keyword "NODE" or "POSITION"         
+       END TYPE                                                          
+       TYPE (spot_weld_type),  DIMENSION(:), ALLOCATABLE :: SPOT_WELD    
+       INTEGER, PARAMETER :: LSRT = 12 ! Length of sorted-element-distance array
+       INTEGER                    &
+      &          IETYP(LSRT)        ! -/- Sort array for closest el's, 0/1=tri/qu
+       REAL(KIND(0D0))                                                          &
+      &          DSQRD(LSRT)        ! -/- Sort array for closest el's, d**2
+       LOGICAL                                                                  &
+      &          COINCIDENT,                                                    &
+      &          INSIDE_ELEMENT
+       IF (SPOT_WELD(NSW)%PLACE .EQ. 'POSITION') THEN
+         DO n = 1,LSRT
+         ENDDO
+         DO i = 1,NUMP3
+           DO WHILE (Distance_Squared .GT. DSQRD(n) .AND. n .LE. LSRT)
+           ENDDO
+           IF (n .LT. LSRT) THEN
+             DO k = LSRT-1,n,-1
+               DSQRD(k+1) = DSQRD(k)
+               IETYP(k+1) = IETYP(k)
+             ENDDO
+           ENDIF
+           DO n = 1,LSRT
+             IF (IETYP(n) .EQ. 0) THEN
+               INSIDE_ELEMENT =                                                 &
+      &          Xi1EL(n) .GE. 0.0 .AND. Xi2EL(n) .GE. 0.0
+               IF (DSQRD(n) .LT. Dmin) THEN
+               ENDIF
+             ENDIF
+           ENDDO
+         ENDDO
+         IF (Icount .GT. 0) THEN
+           DO i = 1,Icount
+             CALL USER_MESSAGE                                                  &
+      &          (                                                              &
+      &          )
+           ENDDO
+           CALL USER_MESSAGE                                                    &
+      &          (                                                              &
+      &          )
+         ENDIF
+         IF                                                                     &
+      &          (                                                              &
+      &          .NOT.COINCIDENT                                                &
+      &          )                                                              &
+      &    THEN
+           IF (NP1 .GT. 0) THEN
+             IF (NP1 .GT. 0) THEN
+             ENDIF
+           ENDIF
+         ENDIF
+         IF (.NOT.COINCIDENT) THEN
+           DO i = 1,3
+             IF (NP(i) .GT. 0) THEN
+             ENDIF
+           ENDDO
+         ENDIF
+       ENDIF
+       END



More information about the Gcc-patches mailing list