From patchwork Mon Feb 3 05:41:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 24022 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 37DE820341 for ; Mon, 3 Feb 2014 05:42:16 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id x10sf16599082pdj.0 for ; Sun, 02 Feb 2014 21:42:16 -0800 (PST) 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:message-id:date:from:user-agent:mime-version:to :subject:x-original-sender:x-original-authentication-results :content-type; bh=8I+O0hBkfLxZ9thVlIcD4cHQm1qxEHW8VrSLE967Fck=; b=BUtMNFLh0SehK2Jt3OCjujPKgf+CC1RpVb7xnDb7Dh17Dy+DuihnelVc42auixG8j2 b2v95jtXf5y1OUjOSMDKmSqSngXHIM2ela4iMu1PsWhbOXlRSXn1gAP0+Gkx3ihezMCH j2O1T0rntZEyge0xaA21NV4Bf2ZvzYBXVjfg8hAWUWIr4mUc0IOkYyCjf6Dx79acx+IF HbQrd7LrDZNxnc+rte98O7K8fbopEwA+FS9stmx8zeJ7quCOAiWNe8PfrfufuC9llTii jkUUgSV/2ZHmVYOQszymAQxMqJoWw5lwD/k3ym2bPsz1zKkCWPLOsX9p2y68RBhiGJAs a77Q== X-Gm-Message-State: ALoCoQmV2GTLHkj86cCN9NiR2/PEy2DOXf6kB/YCV735JcnsHOOfJlCzNQ57W6jdO7uNAdGmp2hs X-Received: by 10.67.4.202 with SMTP id cg10mr1455818pad.42.1391406135969; Sun, 02 Feb 2014 21:42:15 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.101.134 with SMTP id u6ls1771313qge.79.gmail; Sun, 02 Feb 2014 21:42:15 -0800 (PST) X-Received: by 10.58.4.138 with SMTP id k10mr27335984vek.8.1391406135830; Sun, 02 Feb 2014 21:42:15 -0800 (PST) Received: from mail-vb0-x22e.google.com (mail-vb0-x22e.google.com [2607:f8b0:400c:c02::22e]) by mx.google.com with ESMTPS id tj7si6521462vdc.7.2014.02.02.21.42.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Feb 2014 21:42:15 -0800 (PST) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::22e; Received: by mail-vb0-f46.google.com with SMTP id o19so4287477vbm.5 for ; Sun, 02 Feb 2014 21:42:15 -0800 (PST) X-Received: by 10.220.99.7 with SMTP id s7mr4054018vcn.19.1391406135648; Sun, 02 Feb 2014 21:42:15 -0800 (PST) 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.220.174.196 with SMTP id u4csp133168vcz; Sun, 2 Feb 2014 21:42:14 -0800 (PST) X-Received: by 10.67.5.7 with SMTP id ci7mr34926246pad.99.1391406134261; Sun, 02 Feb 2014 21:42:14 -0800 (PST) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l8si19153227pao.210.2014.02.02.21.42.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Feb 2014 21:42:14 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-360919-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 13649 invoked by alias); 3 Feb 2014 05:42:00 -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 13638 invoked by uid 89); 3 Feb 2014 05:41:59 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pb0-f44.google.com Received: from mail-pb0-f44.google.com (HELO mail-pb0-f44.google.com) (209.85.160.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 03 Feb 2014 05:41:58 +0000 Received: by mail-pb0-f44.google.com with SMTP id rq2so6637696pbb.17 for ; Sun, 02 Feb 2014 21:41:56 -0800 (PST) X-Received: by 10.68.135.137 with SMTP id ps9mr1058107pbb.160.1391406115995; Sun, 02 Feb 2014 21:41:55 -0800 (PST) Received: from [192.168.0.100] ([120.159.71.8]) by mx.google.com with ESMTPSA id eo11sm135659350pac.0.2014.02.02.21.41.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Feb 2014 21:41:54 -0800 (PST) Message-ID: <52EF2C1D.7050207@linaro.org> Date: Mon, 03 Feb 2014 16:41:49 +1100 From: Kugan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" , Ramana Radhakrishnan , "gcc-patches@gcc.gnu.org" , Richard Earnshaw Subject: [ARM][PATCH] Vectorizer generates unaligned access when -mno-unaligned-access is enabled X-IsSubscribed: yes X-Original-Sender: kugan.vivekanandarajah@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 With the 2013-09-21 version of trunk, attached test case results in bus error when simultaneously enabling both -mno-unaligned-access and -ftree-vectorize. The error is caused by unaligned vector load via two vldr instructions: vldr d16, [r3, #-16] vldr d17, [r3, #-8] Cause for this error is, even when -mno-unaligned-access is enabled, backend will inform vectorizer that it supports misaligned accesses via TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT. Attached patch fixes this. Is this OK for trunk? Thanks, Kugan +2014-02-03 Yury Gribov + Kugan Vivekanandarajah + + * config/arm/arm.c (arm_vector_alignment_reachable): Check + unaligned_access. + * config/arm/arm.c (arm_builtin_support_vector_misalignment): Likewise. + +2014-02-03 Yury Gribov + Kugan Vivekanandarajah + + * gcc.target/arm/vect-noalign.c: New file. + diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 39d23cc..d7e74de 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -29521,7 +29521,7 @@ arm_vector_alignment_reachable (const_tree type, bool is_packed) { /* Vectors which aren't in packed structures will not be less aligned than the natural alignment of their element type, so this is safe. */ - if (TARGET_NEON && !BYTES_BIG_ENDIAN) + if (TARGET_NEON && !BYTES_BIG_ENDIAN && unaligned_access) return !is_packed; return default_builtin_vector_alignment_reachable (type, is_packed); @@ -29532,7 +29532,7 @@ arm_builtin_support_vector_misalignment (enum machine_mode mode, const_tree type, int misalignment, bool is_packed) { - if (TARGET_NEON && !BYTES_BIG_ENDIAN) + if (TARGET_NEON && !BYTES_BIG_ENDIAN && unaligned_access) { HOST_WIDE_INT align = TYPE_ALIGN_UNIT (type); diff --git a/gcc/testsuite/gcc.target/arm/vect-noalign.c b/gcc/testsuite/gcc.target/arm/vect-noalign.c index e69de29..a934233 100644 --- a/gcc/testsuite/gcc.target/arm/vect-noalign.c +++ b/gcc/testsuite/gcc.target/arm/vect-noalign.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-require-effective-target arm_neon_hw } */ +/* { dg-options "-mfpu=neon -ffast-math -ftree-vectorize -fno-common -O2 -mno-unaligned-access" } */ + + +/* Test for-mno-unaligned-access and -ftree-vectorize and results bus error. */ +#define N 128 + +char ia[N]; +char ib[N+1]; + +int main() { + int i; + for(i = 0; i < N; ++i) { + ia[i] = ib[i + 1]; + } + + return 0; +} +