From patchwork Fri Jan 3 15:42:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bingfeng Mei X-Patchwork-Id: 306606 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 7B0AA2C0040 for ; Sat, 4 Jan 2014 02:43:11 +1100 (EST) 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:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=aoT Lhiq7wK3giFpR6CsPQ+wLK0+e8TizhW43Ny/PuA7Bk0ElXIGNJeefA1pLefyk98I 1phQhXGQ80dF+U8IDuFv8mHXeaQMBz75w5V81mo95l/EWBtS4N6hr0uS+r9x/coJ OvZqgtr3HsQo8z3rQU8Bfq9PwKO6WgPvk+LggSqI= 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:content-type :content-transfer-encoding:mime-version; s=default; bh=SpVO7sQpv mPGFYfFrizRTdImLpg=; b=Dg5oGLu5MuOAo+vgBrBxa3T/N0LZ5L8X0YqFCOr4w GsTjmJtBi/ufb3JTHVDnsV4RQQrSe9f6QNi/QEwkCu+w09YAg5vuUpD6uEUnUP9b R08MEIZYAvAdLFvK420gZG7ZY8kwj2O2HkGCfN8q+BCAdhvhhCgHyM+KBSHvJurV t8= Received: (qmail 15276 invoked by alias); 3 Jan 2014 15:43:04 -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 15264 invoked by uid 89); 3 Jan 2014 15:43:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-gw1-out.broadcom.com Received: from mail-gw1-out.broadcom.com (HELO mail-gw1-out.broadcom.com) (216.31.210.62) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 Jan 2014 15:43:03 +0000 Received: from irvexchcas06.broadcom.com (HELO IRVEXCHCAS06.corp.ad.broadcom.com) ([10.9.208.53]) by mail-gw1-out.broadcom.com with ESMTP; 03 Jan 2014 07:51:48 -0800 Received: from SJEXCHCAS03.corp.ad.broadcom.com (10.16.203.8) by IRVEXCHCAS06.corp.ad.broadcom.com (10.9.208.53) with Microsoft SMTP Server (TLS) id 14.1.438.0; Fri, 3 Jan 2014 07:42:44 -0800 Received: from SJEXCHMB13.corp.ad.broadcom.com ([fe80::9d40:1e86:a7dc:c46a]) by SJEXCHCAS03.corp.ad.broadcom.com ([::1]) with mapi id 14.01.0438.000; Fri, 3 Jan 2014 07:42:43 -0800 From: Bingfeng Mei To: Jakub Jelinek CC: "gcc-patches@gcc.gnu.org" , "tbelagod@arm.com" Subject: [COMMITTED] [PATCH] fixed pr59651 & new test case Date: Fri, 3 Jan 2014 15:42:43 +0000 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Jakub, thanks. Committed with suggested changes. Bingfeng -----Original Message----- From: Jakub Jelinek [mailto:jakub@redhat.com] Sent: 03 January 2014 14:26 To: Bingfeng Mei Cc: gcc-patches@gcc.gnu.org; tbelagod@arm.com Subject: Re: [PING] [PATCH] fixed pr59651 & new test case On Fri, Jan 03, 2014 at 02:07:03PM +0000, Bingfeng Mei wrote: > This patch fixes pr59651. The original regression for pr52943 only > appears on AArch64 target. I constructed a similar test that also exposes > bug on x86-64. The problem is that calculation of address range in alias > versioning for loops with negative step is wrong during vectorization. > For example, for a loop that access int a[3] -> a[1], the old calculated > address range is [a, a+12). It should be [a+4, a+16) instead. +extern void abort (void); +int a[] = { 0, 0, 0, 0, 0, 0, 0, 6 }; + +int b; +int +main () +{ + for (;;) + { + b = 7; + for (; b; b -= 1) Sounds like C-reduce weirdness, just write for (b = 7; b; --b) + a[b] = a[7] > 1; + break; + } + if (a[1] != 0) + abort (); + return 0; +} Ok with those changes. Jakub --- tree-vect-loop-manip.c (revision 206279) +++ tree-vect-loop-manip.c (working copy) @@ -2241,12 +2241,26 @@ vect_create_cond_for_alias_checks (loop_ tree seg_a_min = addr_base_a; tree seg_a_max = fold_build_pointer_plus (addr_base_a, segment_length_a); if (tree_int_cst_compare (DR_STEP (dr_a.dr), size_zero_node) < 0) - seg_a_min = seg_a_max, seg_a_max = addr_base_a; + { + seg_a_min = + fold_build_pointer_plus (seg_a_max, + TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr_a.dr)))); + seg_a_max = + fold_build_pointer_plus (addr_base_a, + TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr_a.dr)))); + } Too long lines, can you create a temporary tree var for TYPE_SIZE_UNIT (...); value? Can you add a comment why you do this? --- testsuite/gcc.dg/torture/pr59651.c (revision 0) +++ testsuite/gcc.dg/torture/pr59651.c (revision 0) Perhaps better would be to put this test into gcc.dg/vect/pr59651.c (with the required /* { dg-final { cleanup-tree-dump "vect" } } */ ), so that it is also tested say on i686-linux with -msse2 etc. Or duplicate between those two places (the body of the test can be included in one of those two from the other place using relative path). @@ -0,0 +1,20 @@ +/* { dg-do run } */ +