From patchwork Wed Oct 11 13:20:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 824411 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-463939-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="f418SWUe"; dkim-atps=neutral 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 3yBvk3700jz9rxj for ; Thu, 12 Oct 2017 00:20:42 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=psPjphDXGgytl6ikUsvcP7xsiAcRMMTA3f95iSAVzvUJ9crSThe5w mAHi7kf2sMIsaPvjBGbyfHaKDhW/U95uR5i1oNx+gwZ3ipH3f4FoaJs0oJ83XjzO i9m4M49EYwyHdxHqpIY9p/IqqhSHHkucdHRllCo+silBcNp5MFKZkQ= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=ala7uEIkSAY6J38szlMLVQWzyVI=; b=f418SWUeQTkjLXxZFo/k 1yd9wx4nQim+RGkRDmtip3SSqpCavT4oqer7gRjC6gVQeoFTJyZhEgC9cufdqcUI Mk6SoJLedOtgut2uzReiZDJEyxdjouSiH8WpBjGSsPWQw84ib2eMuaOQ6GB+C7gL bjGnAztVj0Up0MqMRXuFVlY= Received: (qmail 41651 invoked by alias); 11 Oct 2017 13:20:35 -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 41635 invoked by uid 89); 11 Oct 2017 13:20:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1030 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Oct 2017 13:20:32 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4F7F8ABCA for ; Wed, 11 Oct 2017 13:20:30 +0000 (UTC) Date: Wed, 11 Oct 2017 15:20:30 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix infer_loop_bounds_from_pointer_arith Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following fixes a common mistake in calling analyze_scalar_evolution -- it's supposed to be called with the loop the use is directly in. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2017-10-11 Richard Biener * tree-ssa-loop-niter.c (infer_loop_bounds_from_pointer_arith): Properly call analyze_scalar_evolution with the loop of the stmt. Index: gcc/tree-ssa-loop-niter.c =================================================================== --- gcc/tree-ssa-loop-niter.c (revision 253642) +++ gcc/tree-ssa-loop-niter.c (working copy) @@ -3444,7 +3444,8 @@ infer_loop_bounds_from_pointer_arith (st if (TYPE_PRECISION (type) != TYPE_PRECISION (TREE_TYPE (var))) return; - scev = instantiate_parameters (loop, analyze_scalar_evolution (loop, def)); + struct loop *uloop = loop_containing_stmt (stmt); + scev = instantiate_parameters (loop, analyze_scalar_evolution (uloop, def)); if (chrec_contains_undetermined (scev)) return;