From patchwork Fri Dec 9 04:25:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 87379 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp120182qgi; Thu, 8 Dec 2016 20:25:31 -0800 (PST) X-Received: by 10.99.181.17 with SMTP id y17mr136400287pge.97.1481257531833; Thu, 08 Dec 2016 20:25:31 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e9si31836569pfk.129.2016.12.08.20.25.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Dec 2016 20:25:31 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-443853-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-443853-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-443853-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=NVnUOryPhynHmL3IniSKnBVxB1H6ozEnCMn3RYfgDMLPa7wzw+ H+CrDJHjLtKTw2dgZdKi35G3jhA0v8+yQKnF8WS3LLnEyxMdyMpKsjcMhXwueTTq 6tg86R2UTHVRjydoYyU85QGCZlj3ckuZj02v9oiaGcOu8aopOfEajBaWY= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=PTkud+WvQ1PxDvhsMCPBe3GUSUk=; b=OJ40K9tA3WAsNITalclG PAE2tdA4PNi5d9COK8XP2RgvRl7Sl1lerjYZO5MFwJ+ymjCPm5sNEKb0fQJ+MDYn VMV4Uq2cPR7rQYtuoc+IzLeihh9Dogai466t6EqicUVsYVlc7pH6LACQY6NwYsCh GDklQr8hniJnMlQciTVGsXM= Received: (qmail 123835 invoked by alias); 9 Dec 2016 04:25:18 -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 123818 invoked by uid 89); 9 Dec 2016 04:25:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Received:10.98.78.88, 2016-12-09, 20161209 X-HELO: mail-pf0-f170.google.com Received: from mail-pf0-f170.google.com (HELO mail-pf0-f170.google.com) (209.85.192.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Dec 2016 04:25:07 +0000 Received: by mail-pf0-f170.google.com with SMTP id d2so1613456pfd.0 for ; Thu, 08 Dec 2016 20:25:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version; bh=dul8tURCYYZ4Ik9lReyj1jZaamqk2vqaFja3GTWrk+M=; b=NFeuqGP1HiL0jOQ99Xpl2uGzo1FzR8fdRaWXtDpNfk7KwceVs/l+xLXm4/X11cs/DF 63AMi1oGD0zSjeZNcx5ITyvHCerDKlTYvApnjEBm0IpW7slp1cyTLMnh6Dlh/ZPnKghl Ho7KJyT2xEDEgWSBBKOXcs2wnM/tixOC7A/Te9f3iKO+DHMSgiJBC9wtH0cp8ew1H6PE z1OVdhRF09AnjiExnvq/KqDi+VFVgD7B5HKK5URUnGG7GNQE442shjaj1ZKmiptk7bK8 3xyTmTcj51VG/HsbmnstM9zokTEkzEF759uoZxSxTL022ZboqYkb0FF0YUrXxW1TzeKD /MUQ== X-Gm-Message-State: AKaTC01WYdT0v2LaAbwVllnYtDOwZRlkNSNcdAvINSSUT4E54yIm+4WazZ1qL/PdAeCnTDh0 X-Received: by 10.98.78.88 with SMTP id c85mr79423049pfb.138.1481257505668; Thu, 08 Dec 2016 20:25:05 -0800 (PST) Received: from [10.1.1.4] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.gmail.com with ESMTPSA id l3sm53587695pgc.41.2016.12.08.20.25.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Dec 2016 20:25:05 -0800 (PST) To: "gcc-patches@gcc.gnu.org" , Martin Jambor , Jan Hubicka From: kugan Subject: [PATCH] Fix PR78721 Message-ID: Date: Fri, 9 Dec 2016 15:25:01 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, in propagate_vr_accross_jump_function, drop_tree_overflow should be after fold_convert. Attached patch changes this. Bootstrapped and regression tested on x86_64-linux-gnu with no new regressions. Is this OK for trunk? Thanks, Kugan gcc/testsuite/ChangeLog: 2016-12-09 Kugan Vivekanandarajah PR ipa/78721 * gcc.dg/pr78721.c: New test. gcc/ChangeLog: 2016-12-09 Kugan Vivekanandarajah PR ipa/78721 * ipa-cp.c (propagate_vr_accross_jump_function): drop_tree_overflow after fold_convert. diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 2ec671f..4ec7cc5 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -1895,9 +1895,9 @@ propagate_vr_accross_jump_function (cgraph_edge *cs, tree val = ipa_get_jf_constant (jfunc); if (TREE_CODE (val) == INTEGER_CST) { + val = fold_convert (param_type, val); if (TREE_OVERFLOW_P (val)) val = drop_tree_overflow (val); - val = fold_convert (param_type, val); jfunc->vr_known = true; jfunc->m_vr.type = VR_RANGE; jfunc->m_vr.min = val; diff --git a/gcc/testsuite/gcc.dg/pr78721.c b/gcc/testsuite/gcc.dg/pr78721.c index e69de29..fb2ffc3 100644 --- a/gcc/testsuite/gcc.dg/pr78721.c +++ b/gcc/testsuite/gcc.dg/pr78721.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int a, b, c; + +int fn1 (char e, char f) +{ + return !f || (e && f == 1); +} + +void fn2 (char e) +{ + while (b) + e = 0; + a = 128; + c = fn1 (e, a == e); +} + +int main () +{ + fn2 (0); + return 0; +}