From patchwork Sat Sep 24 03:36:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 674278 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 3sgxRz16Fkz9sD6 for ; Sat, 24 Sep 2016 14:03:49 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=MgNQyB7d; 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=qspWYn4GHZJXX+ZcV AqKf3curRSgnJr6ao5XkY9FEnRXL7a5fknVUWjNZewyIyGxtCOIsC4KVSusnztYF SHpkHwq1jxjLp1MQ42CccINSkoqNUxTZPajm4eoMqdjuv4U+U9plmvOT+u4hscnq Bls86g6VJ33No8LcqENg6Lwqno= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=h70GM+30ZHjzuCkswNN7W8r 3hYo=; b=MgNQyB7drr9G5LbJf8CAeA4/4Gr4gck3LcCTirjuujYV96o/5ClV/1G ZJsT02bvQTPBrMxf6o1uNJ4DsKlEKNivQf1ITL3U5QvWqF3J6TiTsH+eTYU0zfCX 4MJD6vkY1oHl/aAKTW6LngvPAV0p829fJwja9G0QeQSISvOkpnXI= Received: (qmail 127254 invoked by alias); 24 Sep 2016 03:37:01 -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 127199 invoked by uid 89); 24 Sep 2016 03:36:55 -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=2016-09-24, vr0, 20160924 X-HELO: mail-pf0-f178.google.com Received: from mail-pf0-f178.google.com (HELO mail-pf0-f178.google.com) (209.85.192.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 24 Sep 2016 03:36:45 +0000 Received: by mail-pf0-f178.google.com with SMTP id q2so47641501pfj.3 for ; Fri, 23 Sep 2016 20:36:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=g91V8Eoug+AiuuKt3ZZBgd+Wqb/oYphYxyGGL+lQzvM=; b=OlrSWbaHTc3XmZmTh0of7D5uAR8x3B6x2MIvpnIWLwuht6gweIvkPYvfm2CwwrKc6i HwnAJzEcYhwK+sMxDNnOclTuShpsHRzjNhlIAuIrbkl4tx1rTq7zoLc9tqg2j1tpxf5l Uvr/NXN1juiGJQ7phoOentnAqd7U8+2gddp77lXyvJN6D+J4A0fM3D0VZnrbPJOIsf0Y ju9yTdxOywEWIlyPO6YUgAJyR1JLAzsRuJ0/aFIKnls3WJOttyfbhrttJ1a4qKWnBjOZ CcX6yCud+Hi6hBr7H2lm8sbyZMhEhz6khwcFgmigI0x0ObQDBqQ3QIqRnwGO7CYKLOVX aO/g== X-Gm-Message-State: AE9vXwNFQE+O0VwTyfbh1YoJXPQgqkNK1/kngthDFU82ZRCgBcHrs60OOj6RDQbwenYUA0/3 X-Received: by 10.98.21.85 with SMTP id 82mr18288493pfv.81.1474688203812; Fri, 23 Sep 2016 20:36:43 -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 o123sm14435074pfg.78.2016.09.23.20.36.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Sep 2016 20:36:43 -0700 (PDT) Subject: Re: ICE at -O1 and above in both 32-bit and 64-bit modes on x86_64-linux-gnu To: Richard Biener References: Cc: "gcc-patches@gcc.gnu.org" , Martin Jambor , Jan Hubicka From: kugan Message-ID: Date: Sat, 24 Sep 2016 13:36:39 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes Hi Richard, There is also one more issue as reported by Pat Haugen. That is, in converting value_range of ssa (which we get from get_range_info) to argument type, my implementation is too simplistic and wrong at times. I can check TYPE_UNSIGNED here but that would be pessimistic. tree-vrp already has logic to handle this so the attached patch exports this and uses it. This also would be useful when we pass an argument of the function to anther function call with unary operation. I will send a separate patch for that later if this is OK. Bootstrapped and regression tested on x86_64-linux-gnu with no new regressions. Is this OK for trunk? Thanks, Kugan gcc/ChangeLog: 2016-09-24 Kugan Vivekanandarajah PR ipa/77677 * ipa-prop.c (ipa_compute_jump_functions_for_edge): Use extract_range_from_unary_expr to convert value_range. * tree-vrp.c (extract_range_from_unary_expr_1): Rename to. (extract_range_from_unary_expr): This. * tree-vrp.h (extract_range_from_unary_expr): Declare. gcc/testsuite/ChangeLog: 2016-09-24 Kugan Vivekanandarajah PR ipa/77677 * gcc.dg/torture/pr77677-2.c: New test. diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index feecd23..f1f641b 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -1703,13 +1703,22 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, if (TREE_CODE (arg) == SSA_NAME && param_type && (type = get_range_info (arg, &min, &max)) - && (type == VR_RANGE || type == VR_ANTI_RANGE) - && (min.get_precision () <= TYPE_PRECISION (param_type))) + && (type == VR_RANGE || type == VR_ANTI_RANGE)) { - jfunc->vr_known = true; - jfunc->m_vr.type = type; - jfunc->m_vr.min = wide_int_to_tree (param_type, min); - jfunc->m_vr.max = wide_int_to_tree (param_type, max); + value_range vr; + + vr.type = type; + vr.min = wide_int_to_tree (TREE_TYPE (arg), min); + vr.max = wide_int_to_tree (TREE_TYPE (arg), max); + vr.equiv = NULL; + extract_range_from_unary_expr_range (&jfunc->m_vr, + NOP_EXPR, + param_type, + &vr, TREE_TYPE (arg)); + if (jfunc->m_vr.type == VR_RANGE || jfunc->m_vr.type == VR_ANTI_RANGE) + jfunc->vr_known = true; + else + jfunc->vr_known = false; } else gcc_assert (!jfunc->vr_known); diff --git a/gcc/testsuite/gcc.dg/torture/pr77677-2.c b/gcc/testsuite/gcc.dg/torture/pr77677-2.c index e69de29..661e6a3 100644 --- a/gcc/testsuite/gcc.dg/torture/pr77677-2.c +++ b/gcc/testsuite/gcc.dg/torture/pr77677-2.c @@ -0,0 +1,16 @@ +/* PR ipa/77677 */ +/* { dg-do compile } */ + +enum machine_mode { MAX_MACHINE_MODE }; + +struct { + int mode : 8; +} a; +int b; + +static int fn1(); + +void fn2() { fn1(a, a.mode); } + +int fn1(a, mode) enum machine_mode mode; +{ int c = b = c; } diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 3c75a0d..39a33ae 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -3281,10 +3281,10 @@ extract_range_from_binary_expr (value_range *vr, the range of its operand *VR0 with type OP0_TYPE with resulting type TYPE. The resulting range is stored in *VR. */ -static void -extract_range_from_unary_expr_1 (value_range *vr, - enum tree_code code, tree type, - value_range *vr0_, tree op0_type) +void +extract_range_from_unary_expr_range (value_range *vr, + enum tree_code code, tree type, + value_range *vr0_, tree op0_type) { value_range vr0 = *vr0_, vrtem0 = VR_INITIALIZER, vrtem1 = VR_INITIALIZER; @@ -3337,12 +3337,12 @@ extract_range_from_unary_expr_1 (value_range *vr, if (vr0.type == VR_ANTI_RANGE && ranges_from_anti_range (&vr0, &vrtem0, &vrtem1)) { - extract_range_from_unary_expr_1 (vr, code, type, &vrtem0, op0_type); + extract_range_from_unary_expr_range (vr, code, type, &vrtem0, op0_type); if (vrtem1.type != VR_UNDEFINED) { value_range vrres = VR_INITIALIZER; - extract_range_from_unary_expr_1 (&vrres, code, type, - &vrtem1, op0_type); + extract_range_from_unary_expr_range (&vrres, code, type, + &vrtem1, op0_type); vrp_meet (vr, &vrres); } return; @@ -3597,7 +3597,7 @@ extract_range_from_unary_expr (value_range *vr, enum tree_code code, else set_value_range_to_varying (&vr0); - extract_range_from_unary_expr_1 (vr, code, type, &vr0, TREE_TYPE (op0)); + extract_range_from_unary_expr_range (vr, code, type, &vr0, TREE_TYPE (op0)); } diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h index 7ffb7e7..ee92b58 100644 --- a/gcc/tree-vrp.h +++ b/gcc/tree-vrp.h @@ -51,4 +51,9 @@ struct GTY(()) value_range extern void vrp_intersect_ranges (value_range *vr0, value_range *vr1); extern void vrp_meet (value_range *vr0, const value_range *vr1); extern void dump_value_range (FILE *, const value_range *); +extern void extract_range_from_unary_expr_range (value_range *vr, + enum tree_code code, + tree type, + value_range *vr0_, + tree op0_type);