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: 54671 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id C31E322FF8 for ; Thu, 8 Oct 2015 14:11:19 +0000 (UTC) Received: by wicgi15 with SMTP id gi15sf4665039wic.2 for ; Thu, 08 Oct 2015 07:11:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:date:from:to:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent:x-original-sender:x-original-authentication-results; bh=f9dgaOqpxkjwy45/p8vg9UBV+OmcYYXTE3rDFQjv3Pc=; b=jGO68eCXy8n197tLGOXBkzTc9C48rXAL7nbRZVeyxhxhbeMCeDYAgYeOZZ1qWvJUlu fgHyHsc5FnaYwBKot+uvIr00C6CiapgmpNg3pB1PaZkKrDrZnW5Koj6YQClmDCUUVxSp VxKqhspr+e3iPpKzLKp3cp2IMeSqRkKWVKxaPXyzGZ2GNR5GXi0vnESVXthk67B0kulF a5riyr4rJFxvcBYX42qcEEbkzS4Tz2BnkQBaO9vdtFYaeMMLIN7XK5r/QxRLWLCJ2uoO RWcYSrPzYxI0Y1jWxUKk4LKAw329/UZtCnDZoEVSSviexQt/fn3X9jv+nDj3uKkVkCUM 1vXg== X-Gm-Message-State: ALoCoQlqybM4SK7uDcoQkzg5w5WeihA/rWOhQWVfum0DGXbDSqh9DoDHl7LecdIsUg0s7sxyrfs5 X-Received: by 10.195.18.100 with SMTP id gl4mr1476874wjd.4.1444313479131; Thu, 08 Oct 2015 07:11:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.159.212 with SMTP id i203ls197147lfe.61.gmail; Thu, 08 Oct 2015 07:11:18 -0700 (PDT) X-Received: by 10.25.170.206 with SMTP id t197mr2449794lfe.64.1444313478840; Thu, 08 Oct 2015 07:11:18 -0700 (PDT) Received: from mail-lb0-x232.google.com (mail-lb0-x232.google.com. [2a00:1450:4010:c04::232]) by mx.google.com with ESMTPS id um2si5619832lbb.58.2015.10.08.07.11.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Oct 2015 07:11:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::232 as permitted sender) client-ip=2a00:1450:4010:c04::232; Received: by lbos8 with SMTP id s8so47975805lbo.0 for ; Thu, 08 Oct 2015 07:11:18 -0700 (PDT) X-Received: by 10.25.86.213 with SMTP id k204mr2476878lfb.36.1444313478470; Thu, 08 Oct 2015 07:11:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp610222lbq; Thu, 8 Oct 2015 07:11:17 -0700 (PDT) X-Received: by 10.60.23.1 with SMTP id i1mr4454051oef.57.1444313476033; Thu, 08 Oct 2015 07:11:16 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id f19si22320960oib.41.2015.10.08.07.11.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Oct 2015 07:11:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-409622-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 5866 invoked by alias); 8 Oct 2015 14:11:02 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 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) X-Original-Sender: ramana.radhakrishnan@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::232 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 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;