From patchwork Thu Sep 22 22:24:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 673739 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 3sg9zD3fnPz9t1C for ; Fri, 23 Sep 2016 08:24:48 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=lbhY+3UT; 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:cc:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=HLX506vwVhajm5MMVbOL6tW04GbrmsASDs1P0m7nXfLgtNIEmq 4R2zlNpoFt3wxXtClZCQU5rQrpwe4TBjw4O9e2Si4po5ZoWOycML0gVli2y6PDFB t/cqDhDpP/81zsCe/IWV91U8Dv+Dz2eheh4ykVLgUUMCX3bJsGGp3Wg+s= 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:message-id:date:mime-version:content-type; s= default; bh=36AnjQaKSny4ejokbQ1LQ9EFTgo=; b=lbhY+3UTJqE6nc51R0GY /gvvf71jrzfwqnzN4hYq48bCYCTePDDMi/I4kNstnnf7dug287tHrifG2axxFxk9 f+Ya+Tuqqnmf4/PSt0bTZrU3npvE/YwLPZMOSfaFXFc9zQckAdPd8w/wJGVZGhIE P4VFOyeKHB0kHvJuwUG8D18= Received: (qmail 38188 invoked by alias); 22 Sep 2016 22:24:41 -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 38177 invoked by uid 89); 22 Sep 2016 22:24:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=20160923, 2016-09-23, HX-Received:10.98.159.194 X-HELO: mail-pf0-f181.google.com Received: from mail-pf0-f181.google.com (HELO mail-pf0-f181.google.com) (209.85.192.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Sep 2016 22:24:30 +0000 Received: by mail-pf0-f181.google.com with SMTP id s13so461291pfd.2 for ; Thu, 22 Sep 2016 15:24:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:message-id:date:user-agent :mime-version; bh=fJpmaFzxENMjSzz+S11B5+3SsMFPX2yxHgWCM6cTWKM=; b=ZH0bFFMA1L25wJWo/SSasuB0Qi9p4NBcoKE3bcB+Ojuf26vfqRGVVgfil+khbx13jS 322DA94hBGgCJ1WhEqb8CFzhU7wPjRGUnUWbzGOqmzXdKoPf2qR4bZeSp0EEe3rDz72C yZ6Kj/bTt1GmtCUCZb9Km+5gNet5SvejpmgkKeLUrFjXxIiOCM6EUQo+iByfWCbjf+tg rZ+ORdoLwtxw0tCltQpj1lL7BYxiOLsaAkEAfoHFxqRusyFVdyNe+/KwXs/NtD6qjuqQ KzJMBAL2IZEGlRLm0hZH4ZJfdlKsQI0zAhSOWBLDtbpiEaxgZ129bN6GyXvy6eZAFvl4 pLjA== X-Gm-Message-State: AE9vXwOQGF0QM0iQEzmGHbrreAuBupM6y1W2VeD4/jXuhXEOFo93blm0180iMxAvsORSXA9k X-Received: by 10.98.159.194 with SMTP id v63mr7080068pfk.91.1474583068930; Thu, 22 Sep 2016 15:24:28 -0700 (PDT) Received: from [10.1.1.7] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.gmail.com with ESMTPSA id e21sm6250027pfb.96.2016.09.22.15.24.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Sep 2016 15:24:27 -0700 (PDT) From: kugan To: "gcc-patches@gcc.gnu.org" Cc: Richard Biener , Martin Jambor , Jan Hubicka Subject: ICE at -O1 and above in both 32-bit and 64-bit modes on x86_64-linux-gnu Message-ID: Date: Fri, 23 Sep 2016 08:24:23 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, As Richard pointed out in PR77677, TREE_OVERFLOW is not cleared in IPA-VRP. There are three places in which we set value_range: 1. When value ranges are obtained from SSA_NAME with get_range_info with wide_int_to_tree. In this case we will not have TREE_OVERFLOW set. 2. When we vrp_meet/vrp_intersect_ranges two ranges. It does int_const_binop but AFAIK this does not set TREE_OVERFLOW. 3. When we create range from constant. This is the problem bit and we need to clear TREE_OVERFLOW here. Attached patch clears the TREE_OVERFLOW in 3rd case. Bootstrap and regression testing are ongoing. Is this OK if there is no regression. Thanks, Kugan gcc/ChangeLog: 2016-09-23 Kugan Vivekanandarajah PR ipa/77677 * ipa-cp.c (propagate_vr_accross_jump_function):Drop TREE_OVERFLOW from constant while creating value range. gcc/testsuite/ChangeLog: 2016-09-23 Kugan Vivekanandarajah PR ipa/77677 * gcc.dg/torture/pr77677.c: New test. diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index cb60f1e..f735ef7 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -2065,6 +2065,8 @@ propagate_vr_accross_jump_function (cgraph_edge *cs, tree val = ipa_get_jf_constant (jfunc); if (TREE_CODE (val) == INTEGER_CST) { + if (TREE_OVERFLOW_P (val)) + val = drop_tree_overflow (val); jfunc->vr_known = true; jfunc->m_vr.type = VR_RANGE; jfunc->m_vr.min = val; diff --git a/gcc/testsuite/gcc.dg/torture/pr77677.c b/gcc/testsuite/gcc.dg/torture/pr77677.c index e69de29..af3f0b0 100644 --- a/gcc/testsuite/gcc.dg/torture/pr77677.c +++ b/gcc/testsuite/gcc.dg/torture/pr77677.c @@ -0,0 +1,18 @@ +/* PR ipa/77677 */ +/* { dg-do compile } */ + +int a, b; + +static void fn1 (short p1) +{ + a = -p1; + if (a || b) + __builtin_printf ("%d\n", b); +} + +int main () +{ + int c[] = { 40000 }; + fn1 (c[0]); + return 0; +}