From patchwork Mon Jan 23 12:04:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 137350 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 64E51B6FA7 for ; Mon, 23 Jan 2012 23:05:04 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1327925105; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=5MvucASvvH7plrIeGXBj 9pmTqAc=; b=d77QGAq7tOX3p+Sf0r6JPJsQe1GBn+UbJNpthaI94TFzQyC1wq64 OcPaBNfJmoJ6Min5WoclkunWr02W8bWSK0WqdD8d654JTZm4SXpx8mBtW5tyKAHC UGuKkWEI3ghRQw9NAMEhYqUbbIqvrb/6sRLGr5o3XISmUPDH2bnsyOo= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Xig1UuXfsE4G+FPybhKXm3+afW6q6sbqviX0cvhgrWOQpTt12fdAl/IOhvcyGW oGGwAF0F4pw1ZRdeFBus5HKsqXci4lbcXjwjSgJZYPNrWzVv7S8eBdN4hSTMFluI CAJ/B/tt44746BkOeyANHbCh74mlbII5nD3FUezyiEBX4=; Received: (qmail 27453 invoked by alias); 23 Jan 2012 12:04:59 -0000 Received: (qmail 27440 invoked by uid 22791); 23 Jan 2012 12:04:57 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jan 2012 12:04:39 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 307F28FC92 for ; Mon, 23 Jan 2012 13:04:38 +0100 (CET) Date: Mon, 23 Jan 2012 13:04:38 +0100 (CET) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH][1/n] Fix PR50444, handle unaligned VIEW_CONVERT_EXPRs during expansion Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 VIEW_CONVERT_EXPR expansion path fails to handle the case where we promote alignment for !STRICT_ALIGNMENT targets but for modes that are supposed to be handled by movmisalign. This is exposed in gcc.dg/torture/pr45678-2.c on i?86 when you apply the candidate patch for PR50444 in comment #15. I'm now bootstrapping and regtesting this as a prerequesite. Richard. 2012-01-23 Richard Guenther PR tree-optimization/50444 * expr.c (expand_expr_real_1): Properly expand VIEW_CONVERT_EXPR to an aligned mode from unaligned memory using movmisalign. Index: gcc/expr.c =================================================================== --- gcc/expr.c (revision 183423) +++ gcc/expr.c (working copy) @@ -10044,10 +10044,24 @@ expand_expr_real_1 (tree exp, rtx target results. */ if (MEM_P (op0)) { + enum insn_code icode; + op0 = copy_rtx (op0); if (TYPE_ALIGN_OK (type)) set_mem_align (op0, MAX (MEM_ALIGN (op0), TYPE_ALIGN (type))); + else if (mode != BLKmode + && MEM_ALIGN (op0) < GET_MODE_ALIGNMENT (mode) + && ((icode = optab_handler (movmisalign_optab, mode)) + != CODE_FOR_nothing)) + { + struct expand_operand ops[2]; + PUT_MODE (op0, mode); + create_output_operand (&ops[0], NULL_RTX, mode); + create_fixed_operand (&ops[1], op0); + expand_insn (icode, 2, ops); + return ops[0].value; + } else if (STRICT_ALIGNMENT && mode != BLKmode && MEM_ALIGN (op0) < GET_MODE_ALIGNMENT (mode))