From patchwork Thu Sep 22 19:06:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 57936 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 9E3243857BBD for ; Thu, 22 Sep 2022 19:08:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E3243857BBD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663873688; bh=VMTc7lQLk7xF5zB5DU5WjEp1qtZEj7fQTQ6NNQEGQKc=; 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=Ng0CiwOcyvtlqQ+bDj90yQPS9x6tYXdtgxPV7Ir6z1EOLtUgGitYgHEpTAbesRTqT P6QeoWNrpbYJLgP9k4N2G67dZgU+lHkI/RUeoLJfo651MpNMhL+wuI4rnvvQd1RuNd 7YFUHTyEtLKf8dyFgb/1A4Ue5wQvidPBIouZBMKE= 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 9CBA53857C42 for ; Thu, 22 Sep 2022 19:06:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9CBA53857C42 Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-344-ZhhT2VU1PPmUc1Et3Tv72w-1; Thu, 22 Sep 2022 15:06:17 -0400 X-MC-Unique: ZhhT2VU1PPmUc1Et3Tv72w-1 Received: by mail-il1-f198.google.com with SMTP id a8-20020a92c548000000b002f6440ff96bso5547417ilj.22 for ; Thu, 22 Sep 2022 12:06:17 -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=BnQ647yjmuLZ7hXXb41zEPTxXUGhlC5HfcbpZoBMuHs=; b=iblcgbbxIxlb6a8a+5bSZITU7Ij+GAN6WPuzShDPaykzemMiBe79JcoqZKeTe3t/fL mZ3w5+dq0eW/lcuHjajzzAjjCapOBY6u3t7BW3xzo4C1ik0Qjg1lSqrAhcdyhfn2FFfH nxoKdGmZ4NmIAPFabiE5+9pNjtMxckzpyk5qU/9KeLhYDz1/tQkGYTnYUJQI7u6xaGlL DXUx4FmhE/7A2W8jMU+OMycVN2PRPhKuZEuyEOCD/6/wZwmasrw/mWRxzbHwlDBZTONE P4FG0lFdrloEB1P++d4mTNiOKvOttYn+Z8y9cKKVvWSX7oJ4vs3yV1QEkP2xKObAgLeU 3ePw== X-Gm-Message-State: ACrzQf3V3fOgTtLMv9Czy6nyoTvcZNj8AgZaodR516j6yDwjxD3lAZtQ jUWntXUUQL0eKi30mxYVNJRIVNS15yTJPWKy7UNkurfe8fNjxughHCrC2ZWH3dTtWyhKZ3UfvMO WaTlnPVgizGw+sj56BXAC1UjjgWrlzoBF1+AhquJMQ3v2wwMZ0/RQB6jzQ1ABm5jXqGgNyA== X-Received: by 2002:a05:6e02:1d02:b0:2f1:6fb4:26b6 with SMTP id i2-20020a056e021d0200b002f16fb426b6mr2413530ila.49.1663873576874; Thu, 22 Sep 2022 12:06:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ezBmx5U2+p1hyMjf7yMmbxU6ksegG9Tp5jaAwXFkisZO67vkf9ofAQkrBbjXLnf8odknWgw== X-Received: by 2002:a05:6e02:1d02:b0:2f1:6fb4:26b6 with SMTP id i2-20020a056e021d0200b002f16fb426b6mr2413519ila.49.1663873576645; Thu, 22 Sep 2022 12:06:16 -0700 (PDT) Received: from ?IPV6:2607:fea8:a263:f600::3dbe? ([2607:fea8:a263:f600::3dbe]) by smtp.gmail.com with ESMTPSA id x3-20020a056602160300b006a19872663bsm2571766iow.53.2022.09.22.12.06.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Sep 2022 12:06:15 -0700 (PDT) Message-ID: Date: Thu, 22 Sep 2022 15:06:14 -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 13/17] Convert CFN_BUILT_IN_CLRSB 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.7 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" Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From f7e62b09300b6935bceaffb4c42f6edab80f52dc Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 20 Sep 2022 18:21:04 -0400 Subject: [PATCH 13/17] Convert CFN_BUILT_IN_CLRSB to range-ops. * gimple-range-fold.cc (range_of_builtin_int_call): Remove case for CFN_BUILT_IN_CLRSB. * gimple-range-op.cc (class cfn_clrsb): New. (gimple_range_op_handler::maybe_builtin_call): Set arguments. --- gcc/gimple-range-fold.cc | 7 ------- gcc/gimple-range-op.cc | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 96a138a7a02..1d7d1da7bbe 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -916,8 +916,6 @@ fold_using_range::range_of_builtin_int_call (irange &r, gcall *call, return false; tree type = gimple_range_type (call); - tree arg; - int prec; scalar_int_mode mode; switch (func) @@ -926,11 +924,6 @@ fold_using_range::range_of_builtin_int_call (irange &r, gcall *call, r.set (build_zero_cst (type), build_one_cst (type)); return true; - CASE_CFN_CLRSB: - arg = gimple_call_arg (call, 0); - prec = TYPE_PRECISION (TREE_TYPE (arg)); - r.set (build_int_cst (type, 0), build_int_cst (type, prec - 1)); - return true; case CFN_UBSAN_CHECK_ADD: range_of_builtin_ubsan_call (r, call, PLUS_EXPR, src); return true; diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index 801c2bb235e..bee225431e8 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -559,6 +559,23 @@ cfn_ctz::fold_range (irange &r, tree type, const irange &lh, return true; } + +// Implement range operator for CFN_BUILT_IN_ +class cfn_clrsb : public range_operator +{ +public: + using range_operator::fold_range; + virtual bool fold_range (irange &r, tree type, const irange &lh, + const irange &, relation_kind) const + { + if (lh.undefined_p ()) + return false; + int prec = TYPE_PRECISION (lh.type ()); + r.set (build_int_cst (type, 0), build_int_cst (type, prec - 1)); + return true; + } +} op_cfn_clrsb; + // Set up a gimple_range_op_handler for any built in function which can be // supported via range-ops. @@ -632,6 +649,12 @@ gimple_range_op_handler::maybe_builtin_call () m_int = &op_cfn_ctz; break; + CASE_CFN_CLRSB: + m_op1 = gimple_call_arg (call, 0); + m_valid = true; + m_int = &op_cfn_clrsb; + break; + default: break; } -- 2.37.3