From patchwork Thu Jan 11 08:16:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 858892 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-470780-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="Oj9uhM3n"; 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 3zHJf32Ckvz9t3F for ; Thu, 11 Jan 2018 19:17:44 +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=RKZNrbGHv2rClqcVnMSxfQRbsUbQEet8KOoy2jaRRrXge80hzyL8W 3Bo4RlH+4RC/3uD1Vo7nHQgqhKYgiwLpC23Sro/oaTwra6IDW1Xgd4I9wRUt2R2Y /7/GGAMaZY/tYgAk8unmkq3U9aOwInzFbUWYHV58BcvaybIAjteglM= 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=/iNHdOK8wxHq5FvFs/kRU7G0W1A=; b=Oj9uhM3ncT3h2Rd+rbfm xc9rdL2W5tIiyLT0i4ScFRDONzZEIBH7DfAsC5SlNlipYYQxelF3bp/KdFjDKDHW Gz+GkIP2bVjxtz4HM+wmiba8Wg+3yYuR/8ctWW+rhpynIsXK28hS6eSu0IoXuB74 75wt5wofIO7xVo1vNc0/sYY= Received: (qmail 107652 invoked by alias); 11 Jan 2018 08:16:50 -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 107275 invoked by uid 89); 11 Jan 2018 08:16:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=n3 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Jan 2018 08:16:46 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id DA983547355; Thu, 11 Jan 2018 09:16:43 +0100 (CET) Date: Thu, 11 Jan 2018 09:16:43 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix predictive commoning profile update ICE Message-ID: <20180111081643.GA54969@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Hi, in this testcase predictive commoning decides to duplicate loop with profile count of entry being 0. This leads to division by zero. This patch fixes the profile ICE, but I will look into why such update happens at first place. Bootstrapped/regtested x86_64-linux, comitted. Honza PR middle-end/83189 * gfortran.fortran-torture/compile/pr83189.f90: New testcase. * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Handle zero profile. Index: testsuite/gfortran.fortran-torture/compile/pr83189.f90 =================================================================== --- testsuite/gfortran.fortran-torture/compile/pr83189.f90 (revision 256478) +++ testsuite/gfortran.fortran-torture/compile/pr83189.f90 (working copy) @@ -1,30 +0,0 @@ +Module radin_mod + INTEGER, PARAMETER :: DP = selected_real_kind(14,200) +Contains + Subroutine SPLIFT (X,Y,YP,YPP,N,IERR,ISX,A1,B1,AN,BN) + Integer, Intent(in) :: N,ISX + Real(dp), Intent(in) :: X(N),Y(N),A1,B1,AN,BN + Real(dp), Intent(out) :: YP(N),YPP(N) + Real(dp), Allocatable, Dimension(:,:) :: W + NM1 = N-1 + NM2 = N-2 + If (ISX.Gt.0) GO TO 40 + Do I=2,N + If (X(I)-X(I-1) .Le. 0) Then + IERR = 3 + Return + Endif + End Do + Allocate(W(N,3)) +40 YPP(1) = 4*B1 + DOLD = (Y(2)-Y(1))/W(2,2) + Do I=2,NM2 + DNEW = (Y(I+1) - Y(I))/W(I+1,2) + YPP(I) = 6*(DNEW - DOLD) + YP(I) = DOLD + DOLD = DNEW + End Do + Return + End Subroutine SPLIFT +End Module radin_mod + Index: tree-ssa-loop-manip.c =================================================================== --- tree-ssa-loop-manip.c (revision 256441) +++ tree-ssa-loop-manip.c (working copy) @@ -1378,7 +1378,8 @@ tree_transform_and_unroll_loop (struct l { /* Avoid dropping loop body profile counter to 0 because of zero count in loop's preheader. */ - freq_e = freq_e.force_nonzero (); + if (freq_h.nonzero_p () && !(freq_e == profile_count::zero ())) + freq_e = freq_e.force_nonzero (); scale_loop_frequencies (loop, freq_e.probability_in (freq_h)); }