From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109825 invoked by alias); 1 Oct 2015 15:47:53 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 109815 invoked by uid 89); 1 Oct 2015 15:47:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 01 Oct 2015 15:47:52 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id D3BFEC0B64C7; Thu, 1 Oct 2015 15:47:50 +0000 (UTC) Received: from localhost.localdomain (ovpn-113-105.phx2.redhat.com [10.3.113.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t91FloFh016126; Thu, 1 Oct 2015 11:47:50 -0400 Subject: Re: [PATCH] Fix warnings building pdp11 port To: Richard Biener References: <560AC292.3010608@redhat.com> <560C114C.8070007@redhat.com> Cc: "gcc-patches@gcc.gnu.org >> gcc-patches" From: Jeff Law Message-ID: <560D55A6.7030308@redhat.com> Date: Thu, 01 Oct 2015 15:47:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg00089.txt.bz2 On 10/01/2015 03:49 AM, Richard Biener wrote: > On Wed, Sep 30, 2015 at 6:43 PM, Jeff Law wrote: >> On 09/30/2015 01:48 AM, Richard Biener wrote: >>> >>> On Tue, Sep 29, 2015 at 6:55 PM, Jeff Law wrote: >>>> >>>> The pdp11 port fails to build with the trunk because of a warning. >>>> Essentially VRP determines that the result of using BRANCH_COST is a >>>> constant with the range [0..1]. That's always less than 4, 3 and the >>>> various other magic constants used with BRANCH_COST and VRP issues a >>>> warning >>>> about that comparison. >>> >>> >>> It does? Huh. Is it about undefined overflow which is the only thing >>> VRP should end up >>> warning about? If so I wonder how that happens, at least I can't >>> reproduce it for >>> --target=pdp11 --enable-werror build of cc1. >> >> You have to use a trunk compiler to build the pdp11 cross. You'll bump into >> this repeatedly: >> >> if (warn_type_limits >> && ret && only_ranges >> && TREE_CODE_CLASS (code) == tcc_comparison >> && TREE_CODE (op0) == SSA_NAME) >> { >> /* If the comparison is being folded and the operand on the LHS >> is being compared against a constant value that is outside of >> the natural range of OP0's type, then the predicate will >> always fold regardless of the value of OP0. If -Wtype-limits >> was specified, emit a warning. */ >> tree type = TREE_TYPE (op0); >> value_range_t *vr0 = get_value_range (op0); >> >> if (vr0->type == VR_RANGE >> && INTEGRAL_TYPE_P (type) >> && vrp_val_is_min (vr0->min) >> && vrp_val_is_max (vr0->max) >> && is_gimple_min_invariant (op1)) >> { >> location_t location; >> >> if (!gimple_has_location (stmt)) >> location = input_location; >> else >> location = gimple_location (stmt); >> >> warning_at (location, OPT_Wtype_limits, >> integer_zerop (ret) >> ? G_("comparison always false " >> "due to limited range of data type") >> : G_("comparison always true " >> "due to limited range of data type")); >> } >> } > > Oh, I didn't remember we have this kind of warning in VRP ... it's > bound to trigger > for example after jump-threading. So I'm not sure it's useful. It caught me by surprise as well. It's a poor man's attempt at unreachable code warnings. Strangely, it's been around since 2009, but is only just now causing problems. I'd certainly question it's utility as well. That may be a symptom of something else not optimizing the condition earlier or we've made some changes that expose the collapsed range to VRP. Jef