From patchwork Sun Apr 28 19:05:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1928693 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ghe4gFMp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VSGHs1ZPDz23hv for ; Mon, 29 Apr 2024 05:10:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A3F43857C4F for ; Sun, 28 Apr 2024 19:10:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [205.139.111.44]) by sourceware.org (Postfix) with ESMTPS id 167F43858C42 for ; Sun, 28 Apr 2024 19:06:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 167F43858C42 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=localhost.redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 167F43858C42 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.139.111.44 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714331167; cv=none; b=BycutWUHdBcqIeRcyRb4oykHFwkKILCpDPT1JpovANrCMHDD/WX2ascwgMN5zpgwnd0dXxSfFEA/QjbG/NacznQnFwlK6Q0XT0ZH+1q22HiyOw3UoRpyvhHX6/txE1RzkTvRFSHPUc5L0YbDm+jV14VlvjBd/LPSjazMMM9r/7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714331167; c=relaxed/simple; bh=nN5vqDOJr4njBmRjY3iO6lfwiLyVYaEg9qEBcsRYjPw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pqoTpgIh2suy/VnycTY7MqFzJQwXhQ38wKR+TmSK3/OTa5vm5JNtodyr5b1xGH4ecoG2r8f81ZzTtkpfQHJkD9/tjMNl5pTFG5s8PoTjGpUU4Dd7EdK5viyiNeYLc8P+xEGDIaW9IS2Q4fsr8gzGrfxNXMddbgfxS00Z/WLtsBQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714331164; 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: in-reply-to:in-reply-to:references:references; bh=uzMJ5+jOb8yIdp1QAhDt3nG/I76wTVj2xqQQxVDKkYE=; b=Ghe4gFMpSD0aiHAYU6kRQiHYIdWkiq+h1OFqu1QeK4i79ORw8HMd2ZQEJ1A1YmtRz2ZkUL 5OsYgah1zAfqYSdRSfL7cdmrg2f64685qW/9oUk/xRfz2JeNJvl8sxZxOOf/4sCPCB8RNh QaAxYT/4X6C5UVFIXfrfjsT5p7RUlaA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-500-KBL65Wg4N-WvI-lbm5FdYA-1; Sun, 28 Apr 2024 15:06:03 -0400 X-MC-Unique: KBL65Wg4N-WvI-lbm5FdYA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E72C380B3DD for ; Sun, 28 Apr 2024 19:06:02 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.56]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A4CEDEC683; Sun, 28 Apr 2024 19:06:02 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.2/8.17.1) with ESMTPS id 43SJ61Mu1209684 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 28 Apr 2024 21:06:01 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.2/8.17.2/Submit) id 43SJ61Mv1209683; Sun, 28 Apr 2024 21:06:01 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED 12/16] Make some integer specific ranges generic Value_Range's. Date: Sun, 28 Apr 2024 21:05:50 +0200 Message-ID: <20240428190557.1209586-13-aldyh@redhat.com> In-Reply-To: <20240428190557.1209586-1-aldyh@redhat.com> References: <20240428190557.1209586-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org There are some irange uses that should be Value_Range, because they can be either integers or pointers. This will become a problem when prange comes live. gcc/ChangeLog: * tree-ssa-loop-split.cc (split_at_bb_p): Make int_range a Value_Range. * tree-ssa-strlen.cc (get_range): Same. * value-query.cc (range_query::get_tree_range): Handle both integers and pointers. * vr-values.cc (simplify_using_ranges::fold_cond_with_ops): Make r0 and r1 Value_Range's. --- gcc/tree-ssa-loop-split.cc | 6 +++--- gcc/tree-ssa-strlen.cc | 2 +- gcc/value-query.cc | 4 +--- gcc/vr-values.cc | 3 ++- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/gcc/tree-ssa-loop-split.cc b/gcc/tree-ssa-loop-split.cc index a770ea371a2..a6be0cef7b0 100644 --- a/gcc/tree-ssa-loop-split.cc +++ b/gcc/tree-ssa-loop-split.cc @@ -144,18 +144,18 @@ split_at_bb_p (class loop *loop, basic_block bb, tree *border, affine_iv *iv, value range. */ else { - int_range<2> r; + Value_Range r (TREE_TYPE (op0)); get_global_range_query ()->range_of_expr (r, op0, stmt); if (!r.varying_p () && !r.undefined_p () && TREE_CODE (op1) == INTEGER_CST) { wide_int val = wi::to_wide (op1); - if (known_eq (val, r.lower_bound ())) + if (known_eq (val, wi::to_wide (r.lbound ()))) { code = (code == EQ_EXPR) ? LE_EXPR : GT_EXPR; break; } - else if (known_eq (val, r.upper_bound ())) + else if (known_eq (val, wi::to_wide (r.ubound ()))) { code = (code == EQ_EXPR) ? GE_EXPR : LT_EXPR; break; diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc index e09c9cc081f..61c3da22322 100644 --- a/gcc/tree-ssa-strlen.cc +++ b/gcc/tree-ssa-strlen.cc @@ -215,7 +215,7 @@ get_range (tree val, gimple *stmt, wide_int minmax[2], rvals = get_range_query (cfun); } - value_range vr; + Value_Range vr (TREE_TYPE (val)); if (!rvals->range_of_expr (vr, val, stmt)) return NULL_TREE; diff --git a/gcc/value-query.cc b/gcc/value-query.cc index eda71dc89d3..052b7511565 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -156,11 +156,9 @@ range_query::get_tree_range (vrange &r, tree expr, gimple *stmt) { case INTEGER_CST: { - irange &i = as_a (r); if (TREE_OVERFLOW_P (expr)) expr = drop_tree_overflow (expr); - wide_int w = wi::to_wide (expr); - i.set (TREE_TYPE (expr), w, w); + r.set (expr, expr); return true; } diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc index ff68d40c355..0572bf6c8c7 100644 --- a/gcc/vr-values.cc +++ b/gcc/vr-values.cc @@ -310,7 +310,8 @@ tree simplify_using_ranges::fold_cond_with_ops (enum tree_code code, tree op0, tree op1, gimple *s) { - int_range_max r0, r1; + Value_Range r0 (TREE_TYPE (op0)); + Value_Range r1 (TREE_TYPE (op1)); if (!query->range_of_expr (r0, op0, s) || !query->range_of_expr (r1, op1, s)) return NULL_TREE;