From patchwork Wed Sep 14 12:49:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1206 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp2799416wrt; Wed, 14 Sep 2022 05:50:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR6r03ctMfiB0z2QbilMfWta49HnxX0wP5W0gDy0ub0ICvQ2dtgvaXM0uoiYzCUYIyXwMnFF X-Received: by 2002:a05:6402:240d:b0:442:b0c4:9e02 with SMTP id t13-20020a056402240d00b00442b0c49e02mr30594898eda.210.1663159832379; Wed, 14 Sep 2022 05:50:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663159832; cv=none; d=google.com; s=arc-20160816; b=oAPMGW5jk4lOSU04ygIOKUgRTFE9zGhCCFEmN6IQCKgCzINaWTQVvo0gWFbM/5Aoji 1G9kNtXUP3rYs+2wUAccm6x7dmg8nUUb9Ac/YrphxNmHU7y90Uv2zoAj9Arrfo4RC0rd IipIDHdkFqM9eKkvjO2/eV2qYKZgqKNdMw98X0tBoU2wPMKG7gtfvGOgitBXyMKrD6XQ 2OZmJkmdPJA4zFCFTaJ0QK199kcuVoY8q8MTSpZCBK2KwTLNan0f96c9+Hz5eX+bXMIu T3SUVnObiTc5WILUl3Rw0Y+lYTAh5/MJWAQc51ttLa9FZOhCk9LykJEZG/x+gKOv8FFR g87A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=l/+vjx72SxDGku+M9jzOR5BV+mMGirUwX8AOS6fSrTQ=; b=UuGzg1dai6YJx8RooJ7dTlOQN/ufeT4kLFXF3wdplcvXpNun7BCEiJ02hhDedrQ/So UDjmzNpArqPZ033W7TrQ5fJ3NgoEnRZ2wIk+IwROtm18INRDRUcp50uv86FZVjCyEj4P qzwBenqVgt7QnzlqG5HeoPJhbNkGbpQP+fO3UgofKwf9ZcmiOoY0pZ+bIv85unCJwcbk JEP9JxasyY47y+R3dhQ9HiiiCE9wacjBmG125ahioqYidffoKmYuzwATbf/hC8SzTrND iKPd42R44nCT+gJ+0uRLzNw43Ba6MkZ29GP/q3SiMpUYSN9GGdwdKoPBnQ7uVNu++DhZ P2nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WBghh54d; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r15-20020aa7c14f000000b0045177ee32a2si7852390edp.376.2022.09.14.05.50.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 05:50:32 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WBghh54d; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CC3703857B9E for ; Wed, 14 Sep 2022 12:50:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC3703857B9E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663159825; bh=l/+vjx72SxDGku+M9jzOR5BV+mMGirUwX8AOS6fSrTQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=WBghh54dfPxwsajHoNVVC8w77LrGW+XdlnZuIJfE0F2IV/YF9FkuIstUgdLg+D9ua R07iUntYwNTytfNyH/s270SfxWupJW6/Ozqjd/MsJe692UHRPrxbvyJ283poS4hCvJ Cb0tjqRZEGDXM/8yDzyqp/ZBH/yG2GuJOoCX7AjQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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 To: GCC patches 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743949484343417320?= X-GMAIL-MSGID: =?utf-8?q?1743949484343417320?= 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);