diff mbox

[obv] fix PR 46259, crash while vectorizing Fortran code

Message ID 20101101185836.GR6758@nightcrawler
State New
Headers show

Commit Message

Nathan Froyd Nov. 1, 2010, 6:58 p.m. UTC
The patch below fixes PR 46259 by reverting a hunk of my previous
patch.  Thanks to H.J. for providing the testcase and testing my
theories on what was wrong with the patch.

Tested on x86_64-unknown-linux-gnu.  Committed as obvious.

-Nathan

gcc/
2010-11-01  Nathan Froyd  <froydnj@codesourcery.com>

	PR tree-optimization/46259

	Revert:

	2010-10-30  Nathan Froyd  <froydnj@codesourcery.com>

	* tree-vect-stmts.c (vect_get_vec_def_for_operand): Use
	build_vector_from_val.

gcc/testsuite/
2010-11-01  H.J. Lu  <hongjiu.lu@intel.com>
	    Nathan Froyd  <froydnj@codesourcery.com>

	PR tree-optimization/46259
	* gfortran.dg/pr46259.f: New testcase.
diff mbox

Patch

Index: testsuite/ChangeLog
===================================================================
Index: testsuite/gfortran.dg/pr46259.f
===================================================================
--- testsuite/gfortran.dg/pr46259.f	(revision 0)
+++ testsuite/gfortran.dg/pr46259.f	(revision 0)
@@ -0,0 +1,19 @@ 
+! PR tree-optimization/46259
+! { dg-do compile }
+! { dg-options "-O3" }
+      SUBROUTINE RDSTFR(FRGMNT,IFRAG,PROVEC,FOCKMA,
+     *                  MXBF,MXMO,MXMO2,NTMOF)
+      PARAMETER (MXPT=100, MXFRG=50, MXFGPT=MXPT*MXFRG)
+      CHARACTER*8 WORD,MNAME,PNAME,RNAME
+      COMMON /FRGSTD/ CORD(3,MXPT),PCORD(3,MXPT),POLT(9,MXPT),
+     *                INLPR(4*MXPT),IKFR(MXPT),IKLR(MXPT),
+     *                MNAME(MXPT),PNAME(MXPT),RNAME(MXPT)
+      DO 10 I=1,MXPT
+         INLPR(4*(I-1)+1)=0
+         INLPR(4*(I-1)+2)=0
+         INLPR(4*(I-1)+3)=0
+         INLPR(4*(I-1)+4)=0
+         IKLR(I)=0
+         RNAME(I)='        '
+   10 CONTINUE
+      END
Index: tree-vect-stmts.c
===================================================================
--- tree-vect-stmts.c	(revision 166138)
+++ tree-vect-stmts.c	(working copy)
@@ -987,7 +987,9 @@  vect_get_vec_def_for_operand (tree op, g
   loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo);
   tree vec_inv;
   tree vec_cst;
+  tree t = NULL_TREE;
   tree def;
+  int i;
   enum vect_def_type dt;
   bool is_simple_use;
   tree vector_type;
@@ -1049,7 +1051,13 @@  vect_get_vec_def_for_operand (tree op, g
         if (vect_print_dump_info (REPORT_DETAILS))
           fprintf (vect_dump, "Create vector_inv.");
 
-        vec_inv = build_vector_from_val (vector_type, def);
+        for (i = nunits - 1; i >= 0; --i)
+          {
+            t = tree_cons (NULL_TREE, def, t);
+          }
+
+	/* FIXME: use build_constructor directly.  */
+        vec_inv = build_constructor_from_list (vector_type, t);
         return vect_init_vector (stmt, vec_inv, vector_type, NULL);
       }