From patchwork Thu Sep 22 19:10:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 57938 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 1BCF23858017 for ; Thu, 22 Sep 2022 19:10:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BCF23858017 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663873843; bh=JFqxHQw7h4km9I2ttqhkzVVM3DFXEWW7ofuRIUa6Izg=; 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=wvtTxqb56+5KIAtxcoc64Au0EdaZisJGwH+yP9sFpqM2a9zsaZ51YGGkwADrpMG0z djWsmagjVMDzKhmS3sNMgL5O2ud20hLxrvkPBuF0r2prmZYSUEQPj2F6kVnq7lMPZD IgO8ifpnvwMtkDGi8HSzELW9x77kVigwVuNO/SOY= 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 B7AD23858D38 for ; Thu, 22 Sep 2022 19:10:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B7AD23858D38 Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-562-655F-dfBNgCmDiIrtGrz_A-1; Thu, 22 Sep 2022 15:10:11 -0400 X-MC-Unique: 655F-dfBNgCmDiIrtGrz_A-1 Received: by mail-io1-f69.google.com with SMTP id i14-20020a5d934e000000b006892db5bcd4so5343147ioo.22 for ; Thu, 22 Sep 2022 12:10:11 -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=28MRBqqCpjYtuKrtA4Z6pf0IFJz+KXKxvHAIIBRyS5I=; b=6KRq0N1tH521kfOvSC3uB7OFrAO9fgt+7cMUZh/zo1GYKZHQaLSfH6dDuShIoQgEzn F8E8o98vLDOWlXzt9tpVlkEEhLfT94WBE50w84YbbLYsgHo7s51oBM++saGFyBhawS3E jpUZREaZgOfx+AR3SqhUI5U4REqkH3Xyix0K6brmz+RC6FW2HPRj72gZo8jMLrP2GUct tU9DN9Sd1qTvJ26FQtO3XDdT7vIH8Vp0f+AcDlomYUqIaz6V8xsn6V6op+j5ycIF0lCJ 569Hl+XdYGMH84J3yrRYiiAZXhN6FeVSjBKJQ0a0Quo1lv5K5Gl2kJqIA0kfy2u+AoUr 8z3g== X-Gm-Message-State: ACrzQf3ndLtwwRSLRJqxCZnF8HlGxjIOzqEXiFbQ+F950/p2bJfWtLsa vLdIM5a/lNwfat+esAQfOqGjonYUuB8DWQ7rwbwn5swGonoIJH0XTY1xol0aK9PkNodfGHbd0qy g27C0UYz0oGShKCrmlUXh+WhWgKJn4xFmHUpCmM9+Q8I8nG0SO1+8nusNfQ4zxTXJdMJx1g== X-Received: by 2002:a05:6638:13cb:b0:33f:336c:34ae with SMTP id i11-20020a05663813cb00b0033f336c34aemr2719666jaj.317.1663873810093; Thu, 22 Sep 2022 12:10:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WgIgCNKFwjw/GJhGXMDIVGL1MaVrV6X3zXNu9ojTzs/5cn1FKM0sOeco78eQx07ywvG0Y7g== X-Received: by 2002:a05:6638:13cb:b0:33f:336c:34ae with SMTP id i11-20020a05663813cb00b0033f336c34aemr2719648jaj.317.1663873809795; Thu, 22 Sep 2022 12:10:09 -0700 (PDT) Received: from ?IPV6:2607:fea8:a263:f600::3dbe? ([2607:fea8:a263:f600::3dbe]) by smtp.gmail.com with ESMTPSA id f24-20020a5d8798000000b0068a82e9b780sm2595818ion.28.2022.09.22.12.10.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Sep 2022 12:10:08 -0700 (PDT) Message-ID: Date: Thu, 22 Sep 2022 15:10:07 -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 16/17] Convert CFN_BUILT_IN_GOACC_DIM_* 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" Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From e7f035f66aa25e0537a0e3a76d43c71fe9531724 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 20 Sep 2022 19:19:30 -0400 Subject: [PATCH 16/17] Convert CFN_BUILT_IN_GOACC_DIM_* to range-ops. * gimple-range-fold.cc (range_of_builtin_int_call): Remove case for CFN_GOACC_DIM_*. * gimple-range-op.cc (class cfn_goacc_dim): New. (gimple_range_op_handler::maybe_builtin_call): Set arguments. --- gcc/gimple-range-fold.cc | 19 ---------------- gcc/gimple-range-op.cc | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index d22fb0e9352..5e8a13e7337 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -889,25 +889,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_GOACC_DIM_SIZE: - case CFN_GOACC_DIM_POS: - // Optimizing these two internal functions helps the loop - // optimizer eliminate outer comparisons. Size is [1,N] - // and pos is [0,N-1]. - { - bool is_pos = func == CFN_GOACC_DIM_POS; - int axis = oacc_get_ifn_dim_arg (call); - int size = oacc_get_fn_dim_size (current_function_decl, axis); - if (!size) - // If it's dynamic, the backend might know a hardware limitation. - size = targetm.goacc.dim_limit (axis); - - r.set (build_int_cst (type, is_pos ? 0 : 1), - size - ? build_int_cst (type, size - is_pos) : vrp_val_max (type)); - return true; - } - default: break; } diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index f9161b5820f..76295466e65 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -635,6 +635,34 @@ public: } } op_cfn_strlen; + +// Implement range operator for CFN_BUILT_IN_GOACC_DIM +class cfn_goacc_dim : public range_operator +{ +public: + cfn_goacc_dim (bool is_pos) { m_is_pos = is_pos; } + using range_operator::fold_range; + virtual bool fold_range (irange &r, tree type, const irange &lh, + const irange &, relation_kind) const + { + tree axis_tree; + if (!lh.singleton_p (&axis_tree)) + return false; + HOST_WIDE_INT axis = TREE_INT_CST_LOW (axis_tree); + int size = oacc_get_fn_dim_size (current_function_decl, axis); + if (!size) + // If it's dynamic, the backend might know a hardware limitation. + size = targetm.goacc.dim_limit (axis); + + r.set (build_int_cst (type, m_is_pos ? 0 : 1), + size + ? build_int_cst (type, size - m_is_pos) : vrp_val_max (type)); + return true; + } +private: + bool m_is_pos; +} op_cfn_goacc_dim_size (false), op_cfn_goacc_dim_pos (true); + // Set up a gimple_range_op_handler for any built in function which can be // supported via range-ops. @@ -748,6 +776,25 @@ gimple_range_op_handler::maybe_builtin_call () break; } + // Optimizing these two internal functions helps the loop + // optimizer eliminate outer comparisons. Size is [1,N] + // and pos is [0,N-1]. + case CFN_GOACC_DIM_SIZE: + // This call will ensure all the asserts are triggered. + oacc_get_ifn_dim_arg (call); + m_op1 = gimple_call_arg (call, 0); + m_valid = true; + m_int = &op_cfn_goacc_dim_size; + break; + + case CFN_GOACC_DIM_POS: + // This call will ensure all the asserts are triggered. + oacc_get_ifn_dim_arg (call); + m_op1 = gimple_call_arg (call, 0); + m_valid = true; + m_int = &op_cfn_goacc_dim_pos; + break; + default: break; } -- 2.37.3