From patchwork Mon Jun 12 15:32:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793971 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=QL7VTEBi; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QfwhW1Fybz20QH for ; Tue, 13 Jun 2023 01:34:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09A7538323D2 for ; Mon, 12 Jun 2023 15:34:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09A7538323D2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584041; bh=efQ7i0+XsYgSXa9VnMx07t3rMo9zrsUI5oKOVbWu+fc=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=QL7VTEBi6eEYqEmaFI22oOUIforLQ/nTj3F5YLTah+ho4KqFDyu0t7BUF7wFSytBS s3iahJr7xZyjOy/eY7TqVRqGB7Jskq1GbVtc+X0tZsRLiu/8vtFset6ozwC9kBv5mc ImhnKRIZuOIIGowOi+UrzUEMR+XCkbO+UqoGdziA= 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 0ADE13857735 for ; Mon, 12 Jun 2023 15:33:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0ADE13857735 Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-346-eZAiYGk7N3yKl0A8WrrTQQ-1; Mon, 12 Jun 2023 11:33:01 -0400 X-MC-Unique: eZAiYGk7N3yKl0A8WrrTQQ-1 Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-6b29f1f2febso2066218a34.3 for ; Mon, 12 Jun 2023 08:33:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583980; x=1689175980; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VdTri3ihE1BCtTCFtwiyfIfUJCYl0Enu1w/2iGZctsE=; b=lK0biYlJVsvcDallBEosvfjsGEuRTOFPPpXHDZRypRST0Tz4ESJprpRPtt9iSnPM3S 0FzmhHIi373JbpPHPAJZY0wFkmwtMst/Y0MAc9A8axDQQnJEdBBuD4BTzmvUJcBC7UkP slPSBSoYgyT4f4PLQZuS/CvGyVFoQdOFboZu7GPDhhFwiaG9aXEpnVrE7bU0w2X+N2L+ lH3cx/QLMqSXOXjTqOLQCiTgTDC+roxqFUnjsxTPf7pxV1QWDFLNSsxPl/LSb1L5Q//i rUhfTfpasJoOddvFp/3LWPR5fglhUxmb3QdKGd8bmnGYZ0d6IaTYDkswQgTnwthl224h SsdA== X-Gm-Message-State: AC+VfDyaPl7Cik0A87yz4OKVJePyVLTS40jPBIhqqqhosfIG3q0ai24o hltmFr/HUBE6v+FjB5cA4s5rP4jcnDKCRwNsk070diWAy/RKa3Tm62PgF9lq96Qbnl0nL/SLPO+ 7mHjfAyXpEILy7T64tOMF1HEqmAFqknItz0V6OnptUNAzlLAhM+wwuit8B7A3rNn++iIC9VSql7 u3RQ== X-Received: by 2002:a9d:7842:0:b0:6b0:c963:6cba with SMTP id c2-20020a9d7842000000b006b0c9636cbamr7477087otm.13.1686583979819; Mon, 12 Jun 2023 08:32:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4cz91dZSgz8VLi5oDa5ano50tOx0CfpEjIWdaEAbJLs4+vGHVzWN5iQMjYFeSwAlDUoSicxg== X-Received: by 2002:a9d:7842:0:b0:6b0:c963:6cba with SMTP id c2-20020a9d7842000000b006b0c9636cbamr7477067otm.13.1686583979525; Mon, 12 Jun 2023 08:32:59 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id fx6-20020a05622a4ac600b003f9efa2ddb4sm1264269qtb.66.2023.06.12.08.32.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:32:59 -0700 (PDT) Message-ID: Date: Mon, 12 Jun 2023 11:32:58 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches Cc: "hernandez, aldy" Subject: [COMMITTED 11/17] - Add a hybrid MIN_EXPR operator for integer and pointer. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US 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, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, 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: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Add a hybrid operator to choose between integer and pointer versions at runtime. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 08f2e419b1e29f114857b3d817904abf3b4891be Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:34:26 -0400 Subject: [PATCH 11/17] Add a hybrid MIN_EXPR operator for integer and pointer. This adds an operator to the unified table for MIN_EXPR which will select either the pointer or integer version based on the type passed to the method. This is for use until we have a seperate PRANGE class. * range-op-mixed.h (operator_min): Remove final. * range-op-ptr.cc (pointer_table::pointer_table): Remove MIN_EXPR. (class hybrid_min_operator): New. (range_op_table::initialize_pointer_ops): Add hybrid_min_operator. * range-op.cc (unified_table::unified_table): Comment out MIN_EXPR. --- gcc/range-op-mixed.h | 6 +++--- gcc/range-op-ptr.cc | 28 +++++++++++++++++++++++++++- gcc/range-op.cc | 2 +- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index e4852e974c4..a65935435c2 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -625,11 +625,11 @@ class operator_min : public range_operator { public: void update_bitmask (irange &r, const irange &lh, - const irange &rh) const final override; -private: + const irange &rh) const override; +protected: void wi_fold (irange &r, tree type, const wide_int &lh_lb, const wide_int &lh_ub, const wide_int &rh_lb, - const wide_int &rh_ub) const final override; + const wide_int &rh_ub) const override; }; class operator_max : public range_operator diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index 7b22d0bf05b..483e43ca994 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -270,7 +270,6 @@ operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type, pointer_table::pointer_table () { - set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); } @@ -380,6 +379,32 @@ public: } } op_hybrid_or; +// Temporary class which dispatches routines to either the INT version or +// the pointer version depending on the type. Once PRANGE is a range +// class, we can remove the hybrid. + +class hybrid_min_operator : public operator_min +{ +public: + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override + { + if (!r.undefined_p () && INTEGRAL_TYPE_P (r.type ())) + operator_min::update_bitmask (r, lh, rh); + } + + void wi_fold (irange &r, tree type, const wide_int &lh_lb, + const wide_int &lh_ub, const wide_int &rh_lb, + const wide_int &rh_ub) const final override + { + if (INTEGRAL_TYPE_P (type)) + return operator_min::wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub); + else + return op_ptr_min_max.wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub); + } +} op_hybrid_min; + + // Initialize any pointer operators to the primary table @@ -391,4 +416,5 @@ range_op_table::initialize_pointer_ops () set (POINTER_DIFF_EXPR, op_pointer_diff); set (BIT_AND_EXPR, op_hybrid_and); set (BIT_IOR_EXPR, op_hybrid_or); + set (MIN_EXPR, op_hybrid_min); } diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 0a9a3297de7..481f3b1324d 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -123,7 +123,7 @@ unified_table::unified_table () // set (BIT_AND_EXPR, op_bitwise_and); // set (BIT_IOR_EXPR, op_bitwise_or); - set (MIN_EXPR, op_min); + // set (MIN_EXPR, op_min); set (MAX_EXPR, op_max); } -- 2.40.1