From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58799 invoked by alias); 21 Nov 2017 13:58:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 58789 invoked by uid 89); 21 Nov 2017 13:58:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_1,KAM_NUMSUBJECT,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=HTo:D*be, Hx-languages-length:1687 X-HELO: mail-wm0-f41.google.com Received: from mail-wm0-f41.google.com (HELO mail-wm0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Nov 2017 13:58:40 +0000 Received: by mail-wm0-f41.google.com with SMTP id 9so3589068wme.4 for ; Tue, 21 Nov 2017 05:58:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0jn2cYCT/OPwxKrHe5z8x0Y5c+Oq6eNtloezK25psIs=; b=kfjOQtnnmyBa66r5N+F9iSD5vEhFHExTdfAdZOIRtkJpZxnpchXAt9wI3R/rKtlewX ZkeUpduKhr3anROFSJx9zK/tBbpsEkZrM0HV655hcse95it094tCQbHBkKcndkaSgB1K JGT7X0e0tWFh5a0Y9V0vrQiUb6NWCPWgV3PNPU2BIzKmzlZPOIdE1ivuWS3y2AJv40y+ cofiQ/LaK7Jgdx6hFAp63x8562ZcwPe0PYX+CoET5blea1YY3PzIyu+DobBRvE1ZIYbw 3YtzORETEAPvJ4Yz+WTR0Ak16/AsmxR+pV8yGXqGoMHMX/GgV0Zhfc9NDHO2pQSQJ2Wz XKhg== X-Gm-Message-State: AJaThX5eMUYHQMxcL9dqf0W+0kbA5Yc1QfmNgWqo/wbmlnQc0nheImVg 6iNqzdJea9LjHzwYDzYREy1CVTPpWo8eD8x/Eqo= X-Google-Smtp-Source: AGs4zMZ+Jcr3Lbl8RNNIuLXxNLlzL74wQGp5MQTkt1BuEBg6wtsyY1xJNOysOQYZrq3cRFh0FAdFIIARs8Tjb7mUg5I= X-Received: by 10.80.137.106 with SMTP id f39mr25591951edf.148.1511272718256; Tue, 21 Nov 2017 05:58:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.143.34 with HTTP; Tue, 21 Nov 2017 05:58:37 -0800 (PST) In-Reply-To: <87d14brhj6.fsf@uclouvain.be> References: <87d14brhj6.fsf@uclouvain.be> From: Richard Biener Date: Tue, 21 Nov 2017 14:06:00 -0000 Message-ID: Subject: Re: [PATCH] Fix result for conditional reductions matching at index 0 To: Kilian Verhetsel , alan.hayward@arm.com Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-11/txt/msg01894.txt.bz2 On Tue, Nov 21, 2017 at 12:35 PM, Kilian Verhetsel wrote: > > Hi, > > When translating conditional reductions based on integer induction, the > compiler uses the value zero to indicate the absence of any matches: if > the index of the last match is still zero at the end of the loop, the > default value is returned. The problem with this approach is that this > default value is returned not only when there were no matches at all, > but also when the last match occurred at index 0. This causes the test > gcc.dg/vect/pr65947-14.c to fail. > > This patch corrects this by reusing the vector of indices used for > COND_REDUCTION, which starts at 1. If the 1-based index of the last > match is non-zero, 1 is subtracted from it, otherwise the initial value > is returned. > > I tested this patch on x86_64-pc-linux-gnu (both with SSE and AVX2, > causing both paths through the reduc_code != ERROR_MARK branch being > taken). This is PR81179 I think, please mention that in the changelog. This unconditionally pessimizes code even if there is no valid index zero, right? The issue with the COND_REDUCITION index vector is overflow IIRC. Alan, can you please comment on the patch? Thanks, Richard. > 2017-11-21 Kilian Verhetsel > > * tree-vect-loop.c > (vect_create_epilog_for_reduction): Fix the returned value for > INTEGER_INDUC_COND_REDUCTION whose last match occurred at > index 0. > (vectorizable_reduction): For INTEGER_INDUC_COND_REDUCTION, > pass the PHI statement that sets the induction variable to the > code generating the epilogue. >