From patchwork Sun Jul 24 15:04:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 146 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp1225926pxt; Sun, 24 Jul 2022 08:06:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1veV1LCylX/HtCEWeptkxydAU1gbhxzBTkOPoEGJkdsbQ5gKpFa60IboevFlTDvVfQEsIxr X-Received: by 2002:a17:907:7d8e:b0:72b:9d09:5c48 with SMTP id oz14-20020a1709077d8e00b0072b9d095c48mr6950602ejc.38.1658675166782; Sun, 24 Jul 2022 08:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658675166; cv=none; d=google.com; s=arc-20160816; b=RxCc54iwEmxYJyCjgFW/GYYGfT4Xj+DuPDnmAz2me0L2fVmUU/thmPyFHGpVC0H5P7 dmwO+15ZxK2DiH/n5IAvV9+MXvr4vOKN1vD0d8fMvFaKje/HQa/sP+SRZvd+8jbL75nH G0xP3iOdpnCYHDMZalJgqPubV67PyY9ajurZEzW75UnPbeFYyw27k/RT28m6gfySIIVW jx0v1YYvHYHHB6JTnA/of4soK6J0kHkuQdtTr4+08/2WxlnZzNeCT5BxFHuAsyoDEhJ+ oLDQTS8nyATisa8Pxo2zLIYivWaziFcETgDgxnWTqj3HM7dUoKTxs1dqaG/G/Ag6kVBW ZFSA== 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:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=3PF6XRaKESQsz5z3iaYuNvKmL8NU25YFJ/XLN4CwUPE=; b=Sgrsn1FuEenXU07nNHuzJIxMAvkm19vj40+RhCB5lqEqzhbHiPJJE1nVIgC4P89p+A AwKWBTbiHKiPIWIxfVCGtgfTTRCa4eEltK5IE90Z9LyUUCKUD7TTlHVI+6k3Iwru7/Sr 9gCCZR1h3UExgIonb+b15V8NMiMGxQn/a2Lpw9cT2srAznjerfdEDqH6OcMf0U8Lx66s JY2IHuBuCmB4MFvTdHZRXefKhl4cbYn+G5xKbwBTXrZ+om/0JSkRM2b++XqX7sjbvEAf A6ojhqEL1QjvkCTVnPj4W3WgK+BIBqktQX+DOYOlG1hCZ1JPpIuzbjKJCkwBtF0PQluZ swgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yRpRlJIX; 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 er20-20020a056402449400b0043be6504388si2115887edb.623.2022.07.24.08.06.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jul 2022 08:06:06 -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=yRpRlJIX; 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 2E693385742D for ; Sun, 24 Jul 2022 15:05:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E693385742D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658675126; bh=3PF6XRaKESQsz5z3iaYuNvKmL8NU25YFJ/XLN4CwUPE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yRpRlJIXJU61rFYlD5wSa0zcNVpoK8LTvXV8uU/4fDkHHXDArT6oRYuVsCGutt/a0 u+26b5ZZFQb8pDutylJ7f9Tu5DQxE/PG7MEX4Bh1o73oCqSBQS3g1bSblhecEbbKoH 8btMHG5UKekRhwxrGPcWkJgAd6wd16tA9dxPtipw= 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 62BD83857C76 for ; Sun, 24 Jul 2022 15:04:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 62BD83857C76 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-524-UAcWQN9aMTC8n4Xgho2rtQ-1; Sun, 24 Jul 2022 11:04:39 -0400 X-MC-Unique: UAcWQN9aMTC8n4Xgho2rtQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 87E092803024 for ; Sun, 24 Jul 2022 15:04:39 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.85]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 290672026985; Sun, 24 Jul 2022 15:04:39 +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 26OF4bsD2010513 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 24 Jul 2022 17:04:37 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 26OF4btO2010512; Sun, 24 Jul 2022 17:04:37 +0200 To: GCC patches Subject: [COMMITTED] Minor fixes to vr_values to not die on non integral types. Date: Sun, 24 Jul 2022 17:04:31 +0200 Message-Id: <20220724150431.2010479-4-aldyh@redhat.com> In-Reply-To: <20220724150431.2010479-1-aldyh@redhat.com> References: <20220724150431.2010479-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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_NONE, SPF_HELO_NONE, SPF_NONE, TXREP 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: "Li, Pan2 via Gcc-patches" 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?1739246971796696115?= X-GMAIL-MSGID: =?utf-8?q?1739246971796696115?= The legacy code in vr_values mostly works on integral types (with few exceptions such as some conversions from float). This patch makes vr_values::range_of_expr not die when asked for a range of an unsupported type. It also keeps the min/max simplification code from being called on non integrals, similarly to what many of the other assignment code is doing. This is all a nop on the current code, but will keep us from misbehaving when VRP starts working on non-integrals. Tested on x86-64 Linux. gcc/ChangeLog: * value-query.cc (range_query::get_value_range): Add assert. * vr-values.cc (vr_values::range_of_expr): Make sure we don't ICE on unsupported types in vr_values. (simplify_using_ranges::simplify): Same. --- gcc/value-query.cc | 1 + gcc/vr-values.cc | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/value-query.cc b/gcc/value-query.cc index 3560d19f1ae..decf5aae1fe 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -167,6 +167,7 @@ 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); diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc index 6b9c630fed3..626a9189472 100644 --- a/gcc/vr-values.cc +++ b/gcc/vr-values.cc @@ -188,6 +188,17 @@ vr_values::range_of_expr (vrange &r, tree expr, gimple *stmt) r = *vr; else { + if (!vr->supports_type_p (TREE_TYPE (expr))) + { + // vr_values::extract_range_basic() use of ranger's + // fold_range() can create a situation where we are + // asked for the range of an unsupported legacy type. + // Since get_value_range() above will return varying for + // such types, avoid copying incompatible range types. + gcc_checking_assert (vr->varying_p ()); + r.set_varying (TREE_TYPE (expr)); + return true; + } value_range tmp = *vr; tmp.normalize_symbolics (); r = tmp; @@ -4375,7 +4386,9 @@ simplify_using_ranges::simplify (gimple_stmt_iterator *gsi) case MIN_EXPR: case MAX_EXPR: - return simplify_min_or_max_using_ranges (gsi, stmt); + if (INTEGRAL_TYPE_P (TREE_TYPE (rhs1))) + return simplify_min_or_max_using_ranges (gsi, stmt); + break; case RSHIFT_EXPR: {