From patchwork Thu Oct 8 14:10:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramana Radhakrishnan X-Patchwork-Id: 527717 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 508DF140D95 for ; Fri, 9 Oct 2015 01:11:10 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ylsZCFgW; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=Ldfmv3Ph4EPRIjFVRb+CVd6a3rl9on aE7c02F5ygeDEBv6koPxOkXgOh/PmKdEsqfBB2abQzUs8Bpsgggl+9tBrw0Wgnn4 wILqmhTzBnC3esjDS3QOP8T2cP8W5Qub/v5BAd6OMGqW3SlYBaZlICho8MrvV4bx xkF6m21MIK32w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=oY6FwtVoX4xLS5Iu6fN6/YW+SXo=; b=ylsZ CFgWNmS/oLWtmjUyO3Maj7tGfX1++KTbvWMJ5NFn8jYDt6IJ5CexgMyvVcR4f1SX 8D5gPaw2lC9sIJyOIAcA7UwgyBGiEk4eSsCw4dmE6SfiPJbx8nzpXmQquYEPGPNk LpB4ZYJ4NjVCdCOznJzsKhkXdphWBikIeczFK6c= Received: (qmail 5866 invoked by alias); 8 Oct 2015 14:11:02 -0000 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 Received: (qmail 5853 invoked by uid 89); 8 Oct 2015 14:11:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 Oct 2015 14:10:58 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1F6D6399 for ; Thu, 8 Oct 2015 07:10:56 -0700 (PDT) Received: from e105545-lin (e105545-lin.cambridge.arm.com [10.2.206.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 40B3C3F236 for ; Thu, 8 Oct 2015 07:10:56 -0700 (PDT) Date: Thu, 8 Oct 2015 15:10:50 +0100 From: Ramana Radhakrishnan To: gcc-patches@gcc.gnu.org Subject: [Patch PR target/67366 2/2] [gimple-fold.c] Support movmisalign optabs in gimple-fold.c Message-ID: <2ab528a7fba51e409cb1018fdb64bd6d3fc07af2.1444312704.git.ramana.radhakrishnan@arm.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) This patch by Richard allows for movmisalign optabs to be supported in gimple-fold.c. This caused a bit of pain in the testsuite with strlenopt-8.c in conjunction with the ARM support for movmisalign_optabs as the test was coded up to do different things depending on whether the target supported misaligned access or not. However now with unaligned access being allowed for different levels of the architecture in the arm backend, the concept of the helper function non_strict_align mapping identically to the definition of STRICT_ALIGNMENT disappears. Adjusted thusly for ARM. The testsuite/lib changes were tested with an arm-none-eabi multilib that included architecture variants that did not support unaligned access and architecture variants that did. The testing matrix for this patch was: 1. x86_64 bootstrap and regression test - no regressions. 2. armhf bootstrap and regression test - no regressions. 3. arm-none-eabi cross build and regression test for {-marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp} {-mthumb/-march=armv8-a/-mfpu=crypto-neon-fp-armv8/-mfloat-abi=hard} {-marm/-mcpu=arm7tdmi/-mfloat-abi=soft} {-mthumb/-mcpu=arm7tdmi/-mfloat-abi=soft} with no regressions. Ok to apply ? Ramana 2015-10-08 Richard Biener * gimple-fold.c (optabs-query.h): Include (gimple_fold_builtin_memory_op): Allow unaligned stores when movmisalign_optabs are available. 2015-10-08 Ramana Radhakrishnan PR target/67366 * lib/target-supports.exp (check_effective_target_non_strict_align): Adjust for arm*-*-*. * gcc.target/arm/pr67366.c: New test. --- gcc/gimple-fold.c | 11 +++++++++-- gcc/testsuite/gcc.target/arm/pr67366.c | 14 ++++++++++++++ gcc/testsuite/lib/target-supports.exp | 9 +++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/arm/pr67366.c diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index a6caaa4..59d496b 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -63,6 +63,8 @@ along with GCC; see the file COPYING3. If not see #include "tree-eh.h" #include "gimple-match.h" #include "gomp-constants.h" +#include "optabs-query.h" + /* Return true when DECL can be referenced from current unit. FROM_DECL (if non-null) specify constructor of variable DECL was taken from. @@ -709,7 +711,9 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi, /* If the destination pointer is not aligned we must be able to emit an unaligned store. */ && (dest_align >= GET_MODE_ALIGNMENT (TYPE_MODE (type)) - || !SLOW_UNALIGNED_ACCESS (TYPE_MODE (type), dest_align))) + || !SLOW_UNALIGNED_ACCESS (TYPE_MODE (type), dest_align) + || (optab_handler (movmisalign_optab, TYPE_MODE (type)) + != CODE_FOR_nothing))) { tree srctype = type; tree desttype = type; @@ -721,7 +725,10 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi, srcmem = tem; else if (src_align < GET_MODE_ALIGNMENT (TYPE_MODE (type)) && SLOW_UNALIGNED_ACCESS (TYPE_MODE (type), - src_align)) + src_align) + && (optab_handler (movmisalign_optab, + TYPE_MODE (type)) + == CODE_FOR_nothing)) srcmem = NULL_TREE; if (srcmem) { diff --git a/gcc/testsuite/gcc.target/arm/pr67366.c b/gcc/testsuite/gcc.target/arm/pr67366.c new file mode 100644 index 0000000..1e8b672 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr67366.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_unaligned } */ +/* { dg-options "-O2" } */ + +typedef unsigned int u32; +u32 +read32 (const void* ptr) +{ + u32 v; + __builtin_memcpy (&v, ptr, sizeof(v)); + return v; +} + +/* { dg-final { scan-assembler "@ unaligned" } } */ diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 9057a27..4d5b0a3d 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -6262,6 +6262,15 @@ proc check_vect_support_and_set_flags { } { # Return 1 if the target does *not* require strict alignment. proc check_effective_target_non_strict_align {} { + + # On ARM, the default is to use STRICT_ALIGNMENT, but there + # are interfaces defined for misaligned access and thus + # depending on the architecture levels unaligned access is + # available. + if [istarget "arm*-*-*"] { + return [check_effective_target_arm_unaligned] + } + return [check_no_compiler_messages non_strict_align assembly { char *y; typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;