From patchwork Tue Nov 15 12:44:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 695018 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 3tJ6Yw6tsrz9t1T for ; Tue, 15 Nov 2016 23:45:40 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="SD5kTtVq"; 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:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=wStv1kNnAs/iQeI0dar2qz9PK7xsQLan9X0eQzarmSZ7mK4uRylaD LrdSzrZUQgc77GnFSKolRWQwkpBooRTR2jtAKuR3I9xGHseq+XjkPVR879p8KiZL B7eflmQLwUD8b7+iR8ehb474lILc0onfK2i/pv8Ok9Mi4Vd76rR/Dg= 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:subject:date:message-id:mime-version:content-type; s= default; bh=KqqdVKCKXf61EP4q38faHuRj22c=; b=SD5kTtVqf28Qka+JctEM jkMtJpJNrpnqIB/ieLpbtahSDtRX87ZBjS+tHww1xXB2zNxnndOrUQba562BiBut jmCGgR30YBSLefzXspUNtPJBMiDXgfAO1uLAq+YHEpRSEf+SK/G1F1egay8S7iDK ZyAoCASPflR4XnRdp3HtJZI= Received: (qmail 33109 invoked by alias); 15 Nov 2016 12:45:26 -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 32961 invoked by uid 89); 15 Nov 2016 12:45:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=fold_build2 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; Tue, 15 Nov 2016 12:45:02 +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 0FA41AD7; Tue, 15 Nov 2016 04:45:01 -0800 (PST) Received: from localhost (e105548-lin.manchester.arm.com [10.45.32.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AF5EB3F218 for ; Tue, 15 Nov 2016 04:45:00 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Fix nb_iterations calculation in tree-vect-loop-manip.c Date: Tue, 15 Nov 2016 12:44:59 +0000 Message-ID: <8737is52us.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 We previously stored the number of loop iterations rather than the number of latch iterations. Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Thanks, Richard [ This patch is part of the SVE series posted here: https://gcc.gnu.org/ml/gcc/2016-11/msg00030.html ] gcc/ 2016-11-15 Richard Sandiford Alan Hayward David Sherwood * tree-vect-loop-manip.c (slpeel_make_loop_iterate_ntimes): Set nb_iterations to the number of latch iterations rather than the number of loop iterations. diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c index 6bfd332..4c6b8c7 100644 --- a/gcc/tree-vect-loop-manip.c +++ b/gcc/tree-vect-loop-manip.c @@ -285,7 +285,10 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop, tree niters) LOCATION_LINE (loop_loc)); dump_gimple_stmt (MSG_NOTE, TDF_SLIM, cond_stmt, 0); } - loop->nb_iterations = niters; + + /* Record the number of latch iterations. */ + loop->nb_iterations = fold_build2 (MINUS_EXPR, TREE_TYPE (niters), niters, + build_int_cst (TREE_TYPE (niters), 1)); } /* Helper routine of slpeel_tree_duplicate_loop_to_edge_cfg.