From patchwork Mon Nov 1 18:58:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 69826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 2B03AB70D4 for ; Tue, 2 Nov 2010 05:58:50 +1100 (EST) Received: (qmail 18974 invoked by alias); 1 Nov 2010 18:58:48 -0000 Received: (qmail 18962 invoked by uid 22791); 1 Nov 2010 18:58:47 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 01 Nov 2010 18:58:41 +0000 Received: (qmail 22537 invoked from network); 1 Nov 2010 18:58:39 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 1 Nov 2010 18:58:39 -0000 Date: Mon, 1 Nov 2010 14:58:37 -0400 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Subject: [PATCH,obv] fix PR 46259, crash while vectorizing Fortran code Message-ID: <20101101185836.GR6758@nightcrawler> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 PR tree-optimization/46259 Revert: 2010-10-30 Nathan Froyd * tree-vect-stmts.c (vect_get_vec_def_for_operand): Use build_vector_from_val. gcc/testsuite/ 2010-11-01 H.J. Lu Nathan Froyd PR tree-optimization/46259 * gfortran.dg/pr46259.f: New testcase. 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); }