From patchwork Fri Oct 23 15:15:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Lawrence X-Patchwork-Id: 535038 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 21859141312 for ; Sat, 24 Oct 2015 02:15:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=t9s/osn6; 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:from :to:cc:subject:date:message-id:in-reply-to:references :content-type:content-transfer-encoding; q=dns; s=default; b=a0+ 1xov2pb23IAzMQVwI9L8l9ix/AKSOcJ0tL96gXlgEDGxCPpxFJTvGkVx9uZm6+WI YQ7UdUsmFiXacj/UWn9Uhfs4DBS8srQNrK6d0g+whiqM3R62ge0TT2yAyPbtcQku bJZeuCA5TOxHPfVwgwnbgonEtZRRcL3Ur4JFOLW4= 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:from :to:cc:subject:date:message-id:in-reply-to:references :content-type:content-transfer-encoding; s=default; bh=oeecJsua/ 46btezr+7kVPa+UUU8=; b=t9s/osn6zR87iI8eIKIS8SDUHjZnVDqdf8TnjNpT5 GsprJXHZLAfz//JVl0pN1LaWxTKogGZHAguaVjzvQQmBGGLITx8WjXJ+J0xFOmsc dmUPGZVtrN8X6Ruagtb9cIIstlwsu0A01JWWGuOEVAiFC8jlrslQdWT3TnFNQuoS gk= Received: (qmail 61250 invoked by alias); 23 Oct 2015 15:15:38 -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 61239 invoked by uid 89); 23 Oct 2015 15:15:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Oct 2015 15:15:37 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-6-1CQW8eHdSLuR4GJymPBbcg-1; Fri, 23 Oct 2015 16:15:29 +0100 Received: from arm.com ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 23 Oct 2015 16:15:29 +0100 From: Alan Lawrence To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com Subject: Re: [PATCH] tree-scalar-evolution.c: Handle LSHIFT by constant Date: Fri, 23 Oct 2015 16:15:21 +0100 Message-Id: <1445613321-12202-1-git-send-email-alan.lawrence@arm.com> In-Reply-To: References: X-MC-Unique: 1CQW8eHdSLuR4GJymPBbcg-1 X-IsSubscribed: yes On 19/10/15 12:49, Richard Biener wrote: > Err, you should always do the shift in the type of rhs1. You should also > avoid the chrec_convert of rhs2 above for shifts. Err, yes, indeed. Needed to keep the chrec_convert before the chrec_fold_multiply, and the rest followed. How's this? Bootstrapped+check-gcc,g++ on x86, ARM, AArch64. gcc/ChangeLog (as before): PR tree-optimization/65963 * tree-scalar-evolution.c (interpret_rhs_expr): Handle some LSHIFT_EXPRs as equivalent MULT_EXPRs. gcc/testsuite/ChangeLog: * gcc.dg/vect/vect-strided-shift-1.c: New. --- gcc/testsuite/gcc.dg/vect/vect-strided-shift-1.c | 33 ++++++++++++++++++++++++ gcc/tree-scalar-evolution.c | 15 +++++++++++ 2 files changed, 48 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/vect/vect-strided-shift-1.c diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-shift-1.c b/gcc/testsuite/gcc.dg/vect/vect-strided-shift-1.c new file mode 100644 index 0000000..b1ce2ec --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-shift-1.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/65963. */ +#include "tree-vect.h" + +#define N 512 + +int in[2*N], out[N]; + +__attribute__ ((noinline)) void +loop (void) +{ + for (int i = 0; i < N; i++) + out[i] = in[i << 1] + 7; +} + +int +main (int argc, char **argv) +{ + check_vect (); + for (int i = 0; i < 2*N; i++) + { + in[i] = i; + __asm__ volatile ("" : : : "memory"); + } + loop (); + __asm__ volatile ("" : : : "memory"); + for (int i = 0; i < N; i++) + { + if (out[i] != i*2 + 7) + abort (); + } + return 0; +} +/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 1 "vect" { target { vect_strided2 } } } } */ diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 0753bf3..129682f 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -1840,6 +1840,21 @@ interpret_rhs_expr (struct loop *loop, gimple *at_stmt, res = chrec_fold_multiply (type, chrec1, chrec2); break; + case LSHIFT_EXPR: + /* Handle A<