From patchwork Fri Sep 17 16:58:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 65094 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 1E2B4B70A6 for ; Sat, 18 Sep 2010 02:58:42 +1000 (EST) Received: (qmail 1588 invoked by alias); 17 Sep 2010 16:58:40 -0000 Received: (qmail 1578 invoked by uid 22791); 17 Sep 2010 16:58:40 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL, BAYES_00, NO_DNS_FOR_FROM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga03.intel.com (HELO mga03.intel.com) (143.182.124.21) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 17 Sep 2010 16:58:35 +0000 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 17 Sep 2010 09:58:33 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by azsmga001.ch.intel.com with ESMTP; 17 Sep 2010 09:58:33 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 6544A207F1; Fri, 17 Sep 2010 09:58:33 -0700 (PDT) Date: Fri, 17 Sep 2010 09:58:33 -0700 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Subject: PATCH: PR middle-end/45678: [4.4/4.5/4.6 Regression] crash on vector code with -m32 -msse Message-ID: <20100917165833.GA17163@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) 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 We failed to update stack alignment when we increase alignment of local variable. This patch fixes it. OK for trunk/4.5/4.4? Thanks. H.J. --- gcc/ 2010-09-17 H.J. Lu PR middle-end/45678 * cfgexpand.c (update_stack_alignment): New. (get_decl_align_unit): Use it. (expand_one_stack_var_at): Call update_stack_alignment. gcc/testsuite/ 2010-09-17 H.J. Lu PR middle-end/45678 * gcc.dg/torture/pr45678-2.c: New. diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 4237276..1e67e77 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -205,19 +205,11 @@ static bool has_protected_decls; smaller than our cutoff threshold. Used for -Wstack-protector. */ static bool has_short_buffer; -/* Discover the byte alignment to use for DECL. Ignore alignment - we can't do with expected alignment of the stack boundary. */ +/* Update stack alignment requirement. */ -static unsigned int -get_decl_align_unit (tree decl) +static void +update_stack_alignment (unsigned int align) { - unsigned int align; - - align = LOCAL_DECL_ALIGNMENT (decl); - - if (align > MAX_SUPPORTED_STACK_ALIGNMENT) - align = MAX_SUPPORTED_STACK_ALIGNMENT; - if (SUPPORTS_STACK_ALIGNMENT) { if (crtl->stack_alignment_estimated < align) @@ -233,6 +225,22 @@ get_decl_align_unit (tree decl) crtl->stack_alignment_needed = align; if (crtl->max_used_stack_slot_alignment < align) crtl->max_used_stack_slot_alignment = align; +} + +/* Discover the byte alignment to use for DECL. Ignore alignment + we can't do with expected alignment of the stack boundary. */ + +static unsigned int +get_decl_align_unit (tree decl) +{ + unsigned int align; + + align = LOCAL_DECL_ALIGNMENT (decl); + + if (align > MAX_SUPPORTED_STACK_ALIGNMENT) + align = MAX_SUPPORTED_STACK_ALIGNMENT; + + update_stack_alignment (align); return align / BITS_PER_UNIT; } @@ -735,6 +743,7 @@ expand_one_stack_var_at (tree decl, HOST_WIDE_INT offset) if (align == 0 || align > max_align) align = max_align; + update_stack_alignment (align); DECL_ALIGN (decl) = align; DECL_USER_ALIGN (decl) = 0; } --- /dev/null 2010-09-09 09:16:30.485584932 -0700 +++ gcc/gcc/testsuite/gcc.dg/torture/pr45678-2.c 2010-09-17 09:53:20.510888017 -0700 @@ -0,0 +1,16 @@ +/* { dg-do run } */ + +typedef float V __attribute__ ((vector_size (16))); +V g; + +int +main () +{ + float d[4] = { 4, 3, 2, 1 }; + V e; + __builtin_memcpy (&e, &d, sizeof (d)); + V f = { 5, 15, 25, 35 }; + e = e * f; + g = e; + return 0; +}