From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 3ABC3385828A for ; Wed, 14 Sep 2022 12:49:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3ABC3385828A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663159782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=l/+vjx72SxDGku+M9jzOR5BV+mMGirUwX8AOS6fSrTQ=; b=KCNLUW1IK53vRLgRLXWxjMBSt8g+Wzkws1iwJupmUvppej4tFlCpRZDTgUZATNJqZ31YXN HYU+sX9s7SiVPxyQeAoKXiaJ8oaY3jCQHWqtyvWF0Hh/A8EIBk62xv5yuKFNu+S5u89GxO 3A02em3Wpi6AZXNQYrFY3/sPi2m90q0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-52-N8KgO3lTPS6TvpfPdFX50Q-1; Wed, 14 Sep 2022 08:49:41 -0400 X-MC-Unique: N8KgO3lTPS6TvpfPdFX50Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A2AC11C0514C for ; Wed, 14 Sep 2022 12:49:41 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.40.195.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3BBB7C15BA4; Wed, 14 Sep 2022 12:49:41 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 28ECncP71221685 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 14 Sep 2022 14:49:38 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 28ECncK61221684; Wed, 14 Sep 2022 14:49:38 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] [PR106936] Remove assert from get_value_range. Date: Wed, 14 Sep 2022 14:49:35 +0200 Message-Id: <20220914124935.1221658-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This assert was put here to make sure that the legacy get_value_range() wasn't being called on stuff that legacy couldn't handle (floats, etc), because the result would ultimately be copied into a value_range_equiv. In this case, simplify_casted_cond() is calling it on an offset_type which is neither an integer nor a pointer. However, range_of_expr happily punted on it, and then the fallthru code set the range to VARYING. As value_range_equiv can store VARYING types of anything (including types it can't handle), this is fine. The easiest thing to do is remove the assert. If someone from the non legacy world tries to get a non integer/pointer range here, it's going to blow up anyhow because the temporary in get_value_range is int_range_max. PR tree-optimization/106936 gcc/ChangeLog: * value-query.cc (range_query::get_value_range): Remove assert. gcc/testsuite/ChangeLog: * g++.dg/tree-ssa/pr106936.C: New test. --- gcc/testsuite/g++.dg/tree-ssa/pr106936.C | 14 ++++++++++++++ gcc/value-query.cc | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr106936.C diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr106936.C b/gcc/testsuite/g++.dg/tree-ssa/pr106936.C new file mode 100644 index 00000000000..c3096e0dd20 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr106936.C @@ -0,0 +1,14 @@ +// { dg-do compile } */ +// { dg-options "-O2 -fno-tree-ccp -fno-tree-forwprop -fno-tree-fre" } + +namespace testPointerToMemberMiscCasts2 { +struct B { + int f; +}; +struct L : public B { }; +struct R : public B { }; +struct D : public L, R { }; + int B::* pb = &B::f; + int R::* pr = pb; + int D::* pdr = pr; +} diff --git a/gcc/value-query.cc b/gcc/value-query.cc index 201f679a36e..ad80db780c2 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -167,7 +167,6 @@ range_query::free_value_range_equiv (value_range_equiv *v) const class value_range_equiv * range_query::get_value_range (const_tree expr, gimple *stmt) { - gcc_checking_assert (value_range_equiv::supports_p (TREE_TYPE (expr))); int_range_max r; if (range_of_expr (r, const_cast (expr), stmt)) return new (equiv_alloc->allocate ()) value_range_equiv (r); -- 2.37.1