From patchwork Thu Sep 22 19:10:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 57939 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6C3723857BB7 for ; Thu, 22 Sep 2022 19:12:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C3723857BB7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663873926; bh=zw/WHEHESSwBeKyMIvQHe/nsjVMk/TGPlX842/cXWtI=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=PgvMy39UenwpPbOHHI09To0Z84icCqE03H/ODSwuLk9I0eAGGEqZnNwhiebVPGGRa x3IHMZbCYWc7eD528PVxozjETP/coE1/bW/OCdMwofMUK8Lf9OYLTBkFUYS5a/Oi9v t5dCXr9XyJ+MiPMZdG1em43q53bcAbDnrMUj5Nl4= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 1E2E538582B5 for ; Thu, 22 Sep 2022 19:10:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1E2E538582B5 Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-631-zy807MKLNX6tHDRsnU3cnQ-1; Thu, 22 Sep 2022 15:10:49 -0400 X-MC-Unique: zy807MKLNX6tHDRsnU3cnQ-1 Received: by mail-io1-f72.google.com with SMTP id y1-20020a056602200100b006893cd97da9so5270218iod.1 for ; Thu, 22 Sep 2022 12:10:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:references:cc:to:from:content-language:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date; bh=PWeT8UYyVU/ZgmDlFAMFXDIRY134GwWBIlz90JNqg1I=; b=3grLIb0Gw+wB4Nrjzh1GSqGMK3vOcoFj6SwzCwM+bPSfWhIWX3QTwhIBAwJg9sW3Jw IYQUQvBX6KTcauxNJQ3ICdFfUHF1pqfGDrFI9xKrZDzfzf+Ji/hhHtnDunAB8E98intc b+6Ov0L1VxSGdCxpRXmR9P2KMui6QSoTlgkA2xtSincRmIs5FUXv1J7irRjHei0MKJLK ep/xETO/qrPwAte1Uv84/qUP50P//syfEZIlSqNCruDAfqj/f0f7J46JeZRtgDKp4VVd /0QC/g0d/tmlAdNNVrSp/G+UvIVtxknnxjMoq5H19tOynT2LN9Oa31We/eXdlFph61Sr h/ag== X-Gm-Message-State: ACrzQf1VUnuBnj+1mgEcW1onU6s+x65CEUtHJ5YvpNnq382oGLpLC18i J2ZgjjvH5fngYKbT7YmwF2M5MYfX5B1qP4mrDLzJz2RAdV4CFScJMY11XAKc7055PM8KMJtl/IK tX9BfIuKgSlfE555PGKroc1p+XeLtLF1KZZztwWpJW4DKbRa8swdaUndvV12k/WuYg6c4ZA== X-Received: by 2002:a05:6e02:168f:b0:2f2:467:5f39 with SMTP id f15-20020a056e02168f00b002f204675f39mr2600987ila.174.1663873848041; Thu, 22 Sep 2022 12:10:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Eh6jjJOWuYTDPXxPI5Brz+EC+LLCSb1Ijuy6/c0Ub2A5pEW3vU3jk6hKnrri7fqX9CZwxeQ== X-Received: by 2002:a05:6e02:168f:b0:2f2:467:5f39 with SMTP id f15-20020a056e02168f00b002f204675f39mr2600980ila.174.1663873847717; Thu, 22 Sep 2022 12:10:47 -0700 (PDT) Received: from ?IPV6:2607:fea8:a263:f600::3dbe? ([2607:fea8:a263:f600::3dbe]) by smtp.gmail.com with ESMTPSA id p23-20020a02b017000000b0034e75d95c13sm2469510jah.151.2022.09.22.12.10.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Sep 2022 12:10:47 -0700 (PDT) Message-ID: Date: Thu, 22 Sep 2022 15:10:45 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: [PATCH 17/17] Convert CFN_BUILT_IN_PARITY to range-ops. To: gcc-patches References: <571782f9-72e6-5c30-da55-b8d62d3a153e@redhat.com> In-Reply-To: <571782f9-72e6-5c30-da55-b8d62d3a153e@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.8 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 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Also, as the last builtin remaining, also remove the builtin infrastructure routines from fold_using_range. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 5608e410914ebb7c8cc9fa50afc8ada3b22cbf2c Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 20 Sep 2022 19:30:46 -0400 Subject: [PATCH 17/17] Convert CFN_BUILT_IN_PARITY to range-ops. Also, as the last builtin remaining, also remove the builtin infrastrucure routines from fold_using_range. * gimple-range-fold.cc (range_of_range_op): Handle no operands. (range_of_call): Do not check for builtins. (fold_using_range::range_of_builtin_call): Delete. (fold_using_range::range_of_builtin_int_call): Delete. * gimple-range-fold.h: Adjust prototypes. * gimple-range-op.cc (class cfn_parity): New. (gimple_range_op_handler::maybe_builtin_call): Set arguments. --- gcc/gimple-range-fold.cc | 60 ++++++++-------------------------------- gcc/gimple-range-fold.h | 4 --- gcc/gimple-range-op.cc | 19 +++++++++++++ 3 files changed, 31 insertions(+), 52 deletions(-) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 5e8a13e7337..c381ef94087 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -534,6 +534,16 @@ fold_using_range::range_of_range_op (vrange &r, tree lhs = handler.lhs (); tree op1 = handler.operand1 (); tree op2 = handler.operand2 (); + + // Certain types of builtin functions may have no arguments. + if (!op1) + { + Value_Range r1 (type); + if (!handler.fold_range (r, type, r1, r1)) + r.set_varying (type); + return true; + } + Value_Range range1 (TREE_TYPE (op1)); Value_Range range2 (op2 ? TREE_TYPE (op2) : TREE_TYPE (op1)); @@ -823,7 +833,7 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src) // If a range cannot be calculated, return false. bool -fold_using_range::range_of_call (vrange &r, gcall *call, fur_source &src) +fold_using_range::range_of_call (vrange &r, gcall *call, fur_source &) { tree type = gimple_range_type (call); if (!type) @@ -832,9 +842,7 @@ fold_using_range::range_of_call (vrange &r, gcall *call, fur_source &src) tree lhs = gimple_call_lhs (call); bool strict_overflow_p; - if (range_of_builtin_call (r, call, src)) - ; - else if (gimple_stmt_nonnegative_warnv_p (call, &strict_overflow_p)) + if (gimple_stmt_nonnegative_warnv_p (call, &strict_overflow_p)) r.set_nonnegative (type); else if (gimple_call_nonnull_result_p (call) || gimple_call_nonnull_arg (call)) @@ -852,50 +860,6 @@ fold_using_range::range_of_call (vrange &r, gcall *call, fur_source &src) return true; } -// For a builtin in CALL, return a range in R if known and return -// TRUE. Otherwise return FALSE. - -bool -fold_using_range::range_of_builtin_call (vrange &r, gcall *call, - fur_source &src) -{ - combined_fn func = gimple_call_combined_fn (call); - if (func == CFN_LAST) - return false; - - tree type = gimple_range_type (call); - gcc_checking_assert (type); - - if (irange::supports_p (type)) - return range_of_builtin_int_call (as_a (r), call, src); - - return false; -} - -bool -fold_using_range::range_of_builtin_int_call (irange &r, gcall *call, - fur_source &) -{ - combined_fn func = gimple_call_combined_fn (call); - if (func == CFN_LAST) - return false; - - tree type = gimple_range_type (call); - scalar_int_mode mode; - - switch (func) - { - CASE_CFN_PARITY: - r.set (build_zero_cst (type), build_one_cst (type)); - return true; - - default: - break; - } - return false; -} - - // Calculate a range for COND_EXPR statement S and return it in R. // If a range cannot be calculated, return false. diff --git a/gcc/gimple-range-fold.h b/gcc/gimple-range-fold.h index ce18c66b8e7..d1ed2bca80f 100644 --- a/gcc/gimple-range-fold.h +++ b/gcc/gimple-range-fold.h @@ -165,10 +165,6 @@ protected: bool range_of_call (vrange &r, gcall *call, fur_source &src); bool range_of_cond_expr (vrange &r, gassign* cond, fur_source &src); bool range_of_address (irange &r, gimple *s, fur_source &src); - bool range_of_builtin_call (vrange &r, gcall *call, fur_source &src); - bool range_of_builtin_int_call (irange &r, gcall *call, fur_source &src); - void range_of_builtin_ubsan_call (irange &r, gcall *call, tree_code code, - fur_source &src); bool range_of_phi (vrange &r, gphi *phi, fur_source &src); void range_of_ssa_name_with_loop_info (vrange &, tree, class loop *, gphi *, fur_source &src); diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index 76295466e65..d7c6dfa933d 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -663,6 +663,20 @@ private: bool m_is_pos; } op_cfn_goacc_dim_size (false), op_cfn_goacc_dim_pos (true); + +// Implement range operator for CFN_BUILT_IN_ +class cfn_parity : public range_operator +{ +public: + using range_operator::fold_range; + virtual bool fold_range (irange &r, tree type, const irange &, + const irange &, relation_kind) const + { + r.set (build_zero_cst (type), build_one_cst (type)); + return true; + } +} op_cfn_parity; + // Set up a gimple_range_op_handler for any built in function which can be // supported via range-ops. @@ -795,6 +809,11 @@ gimple_range_op_handler::maybe_builtin_call () m_int = &op_cfn_goacc_dim_pos; break; + CASE_CFN_PARITY: + m_valid = true; + m_int = &op_cfn_parity; + break; + default: break; } -- 2.37.3