From patchwork Tue Sep 21 09:42:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 65288 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 DAD90B70A5 for ; Tue, 21 Sep 2010 19:42:51 +1000 (EST) Received: (qmail 15285 invoked by alias); 21 Sep 2010 09:42:49 -0000 Received: (qmail 15273 invoked by uid 22791); 21 Sep 2010 09:42:49 -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, TW_CP X-Spam-Check-By: sourceware.org Received: from mail-iw0-f175.google.com (HELO mail-iw0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 21 Sep 2010 09:42:44 +0000 Received: by iwn2 with SMTP id 2so5442518iwn.20 for ; Tue, 21 Sep 2010 02:42:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.58.201 with SMTP id i9mr11548230ibh.98.1285062162656; Tue, 21 Sep 2010 02:42:42 -0700 (PDT) Received: by 10.231.17.130 with HTTP; Tue, 21 Sep 2010 02:42:42 -0700 (PDT) In-Reply-To: References: Date: Tue, 21 Sep 2010 11:42:42 +0200 Message-ID: Subject: Re: 4.4/4.5 PATCH: PR middle-end/45678: [4.4/4.5/4.6 Regression] crash on vector code with -m32 -msse From: Richard Guenther To: "H.J. Lu" Cc: Richard Henderson , 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 On Tue, Sep 21, 2010 at 1:45 AM, H.J. Lu wrote: > 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? No, checking alignment that way doesn't make sense. You're likely just papering over the problem. The alignment check is bogus anyway as get_pointer_alignment will at least return TYPE_ALIGN ({dest,src}type). There's a lot of latent issues with memcpy folding for strict-alignment targets on the branch (and that includes SSE modes which make x86 strict-alignment as well). I'm not sure it's worth fixing there. You could try to do The problem is that src_align and dest_align are completely bogus estimates. Richard. > Thanks. > > > -- > H.J. > -- > gcc/ > > 2010-09-20  H.J. Lu   > >        PR middle-end/45678 >        * builtins.c (fold_builtin_memory_op): Return NULL_TREE if >        dest alignment > src alignment. > >        Backport from mainline >        2010-09-20  Jakub Jelinek   > >        PR middle-end/45678 >        * cfgexpand.c (expand_one_stack_var_at): Limit alignment to >        crtl->max_used_stack_slot_alignment. > > gcc/testsuite/ > > 2010-09-20  H.J. Lu   > >        Backport from mainline >        2010-09-17  Richard Guenther   >                    H.J. Lu   > >        PR middle-end/45678 >        * gcc.dg/torture/pr45678-1.c: New. >        * gcc.dg/torture/pr45678-2.c: Likewise. > Index: builtins.c =================================================================== --- builtins.c (revision 164429) +++ builtins.c (working copy) @@ -8373,7 +8373,8 @@ fold_builtin_memory_op (location_t loc, return NULL_TREE; srctype = build_qualified_type (desttype, 0); - if (src_align < (int) TYPE_ALIGN (srctype)) + if (src_align < (int) TYPE_ALIGN (srctype) + || GET_MODE_BITSIZE (TYPE_MODE (srctype)) > BITS_PER_WORD) { if (AGGREGATE_TYPE_P (srctype) || SLOW_UNALIGNED_ACCESS (TYPE_MODE (srctype), src_align)) @@ -8395,7 +8396,8 @@ fold_builtin_memory_op (location_t loc, return NULL_TREE; desttype = build_qualified_type (srctype, 0); - if (dest_align < (int) TYPE_ALIGN (desttype)) + if (dest_align < (int) TYPE_ALIGN (desttype) + || GET_MODE_BITSIZE (TYPE_MODE (desttype)) > BITS_PER_WORD) { if (AGGREGATE_TYPE_P (desttype) || SLOW_UNALIGNED_ACCESS (TYPE_MODE (desttype), dest_align))