From patchwork Mon Sep 20 23:45:07 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: 65269 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 00035B70B8 for ; Tue, 21 Sep 2010 09:45:18 +1000 (EST) Received: (qmail 9197 invoked by alias); 20 Sep 2010 23:45:15 -0000 Received: (qmail 9189 invoked by uid 22791); 20 Sep 2010 23:45:15 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-vw0-f47.google.com (HELO mail-vw0-f47.google.com) (209.85.212.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Sep 2010 23:45:09 +0000 Received: by vws9 with SMTP id 9so4020180vws.20 for ; Mon, 20 Sep 2010 16:45:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.63.5 with SMTP id z5mr758557vch.245.1285026307284; Mon, 20 Sep 2010 16:45:07 -0700 (PDT) Received: by 10.220.202.9 with HTTP; Mon, 20 Sep 2010 16:45:07 -0700 (PDT) Date: Mon, 20 Sep 2010 16:45:07 -0700 Message-ID: Subject: 4.4/4.5 PATCH: PR middle-end/45678: [4.4/4.5/4.6 Regression] crash on vector code with -m32 -msse From: "H.J. Lu" To: Richard Henderson , Richard Guenther Cc: Jakub Jelinek , gcc-patches@gcc.gnu.org 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 Here is the patch for 4.4/4.5. fold_builtin_memory_op is very different in 4.4/4.5. Simple backport doesn't work. Does this patch make any senses? Thanks. diff --git a/gcc/builtins.c b/gcc/builtins.c index 08a5578..fb777d5 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -8327,6 +8327,7 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src, src_align = get_pointer_alignment (src, BIGGEST_ALIGNMENT); dest_align = get_pointer_alignment (dest, BIGGEST_ALIGNMENT); if (dest_align < (int) TYPE_ALIGN (desttype) + || src_align < (int) TYPE_ALIGN (desttype) || src_align < (int) TYPE_ALIGN (srctype)) return NULL_TREE; diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 4e44cdb..69c3f5f 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -705,7 +705,7 @@ static void expand_one_stack_var_at (tree decl, HOST_WIDE_INT offset) { /* Alignment is unsigned. */ - unsigned HOST_WIDE_INT align; + unsigned HOST_WIDE_INT align, max_align; rtx x; /* If this fails, we've overflowed the stack frame. Error nicely? */ @@ -722,10 +722,9 @@ expand_one_stack_var_at (tree decl, HOST_WIDE_INT offset) offset -= frame_phase; align = offset & -offset; align *= BITS_PER_UNIT; - if (align == 0) - align = STACK_BOUNDARY; - else if (align > MAX_SUPPORTED_STACK_ALIGNMENT) - align = MAX_SUPPORTED_STACK_ALIGNMENT; + max_align = crtl->max_used_stack_slot_alignment; + if (align == 0 || align > max_align) + align = max_align; DECL_ALIGN (decl) = align; DECL_USER_ALIGN (decl) = 0; --- /dev/null 2010-09-09 09:16:30.485584932 -0700 +++ gcc-release/gcc/testsuite/gcc.dg/torture/pr45678-1.c 2010-09-20 09:11:36.000000000 -0700 @@ -0,0 +1,16 @@ +/* { dg-do run } */ + +typedef float V __attribute__ ((vector_size (16))); +V g; +float d[4] = { 4, 3, 2, 1 }; + +int +main () +{ + V e; + __builtin_memcpy (&e, &d, sizeof (d)); + V f = { 5, 15, 25, 35 }; + e = e * f; + g = e; + return 0; +} --- /dev/null 2010-09-09 09:16:30.485584932 -0700 +++ gcc-release/gcc/testsuite/gcc.dg/torture/pr45678-2.c 2010-09-20 09:11:36.000000000 -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; +}