From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id A27223858D37 for ; Fri, 28 Apr 2023 23:33:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A27223858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5286344e1d4so362972a12.3 for ; Fri, 28 Apr 2023 16:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682724802; x=1685316802; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=IPE3XqIWP3mT3dK3Ej4f487kGQ8V7kAZHF2wT8beUx4=; b=Oqi9OpI6dZ4L+OJ8DU4eX7OgOwV0uYf3QvNdHNAjbLXeJtfBFHWKSkfCT0t5Fcs84A T4GPfU2OP/7H9+9etg0a5kA4TNWrgH8UiHjSuPtvYWlm96oy4EftzuFgA5t/0qEHcNQm rz/1S5ScOqT7MAIDY8u050kgeEb0f6WOnf72Hb5fJ19aJKiRkjJFbfGkvpa3hcq2oUR4 XHAeTqF3yUZUANxr1NSqx1fMpmX43AFFRkWbclYp4QbZpcekZl0G6Cw0di4iNegMOT2o aCuldoeEbAmi9KZdqCCn1SuwIXAHNg22BxbxZ0puWZxV+Tfle9worIvdW3ihYANBOzjJ UfVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682724802; x=1685316802; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IPE3XqIWP3mT3dK3Ej4f487kGQ8V7kAZHF2wT8beUx4=; b=fsDHUpIV8Hkwlki4mDaqJpmJeGEBDWuVeJhOJ2tpGu/Xh3P4fTKScvrss9KPl+7odr RxASA7zWXhKt5PZ0WgTc7uY49dnzyknQWKy9RLsmh+XfsrNadLMxu59UGclcP667C+hJ r5Vi8pJn3Txne1PBbeut7CBHE7QP6THSdLsbKEgap9pYbbelNZ4KdxemsiHhyhKAmLRP 9c6DX79zBbv4Y24riWi4dNJBF79UH/W0ZXP21mOQViH1800Za1TFfO6BzD41pkyIKvUb LPBXx4cWULZqSJKx6kpB50Vd76DP2anxn/UA4YCJhKMk4xeF/JYMWLY/MvMzCFnxHTBx 8nmA== X-Gm-Message-State: AC+VfDyYFJoTkGex+DtPRQbpkxuK/tstswWgYf8k+ei3797GgbApThHc l/841Ce34nsKMKHDceX7u44= X-Google-Smtp-Source: ACHHUZ6SRFPC9FyEN84yvsg51WjmxEMxgjS5cV1QCYxBqtmuDi/0xt5HiMNmhHf08X+fVRdNnkkOyA== X-Received: by 2002:a05:6a20:144d:b0:f6:2287:e05d with SMTP id a13-20020a056a20144d00b000f62287e05dmr8994864pzi.10.1682724802303; Fri, 28 Apr 2023 16:33:22 -0700 (PDT) Received: from ?IPV6:2601:681:8600:13d0::99f? ([2601:681:8600:13d0::99f]) by smtp.gmail.com with ESMTPSA id s8-20020a656908000000b0051b7e3546acsm13660953pgq.22.2023.04.28.16.33.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Apr 2023 16:33:21 -0700 (PDT) Message-ID: <77213cc0-f666-8233-5af7-0aa199455b54@gmail.com> Date: Fri, 28 Apr 2023 17:33:20 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH v4 4/4] ree: Improve ree pass for rs6000 target using defined ABI interfaces. Content-Language: en-US To: Hans-Peter Nilsson , Ajit Agarwal Cc: gcc-patches , Segher Boessenkool , Peter Bergner , Richard Biener References: <8b50f07a-994e-1637-ae4d-2be8dbb25807@linux.ibm.com> From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: On 4/28/23 16:42, Hans-Peter Nilsson wrote: > On Sat, 22 Apr 2023, Ajit Agarwal via Gcc-patches wrote: > >> Hello All: >> >> This new version of patch 4 use improve ree pass for rs6000 target using defined ABI interfaces. >> Bootstrapped and regtested on power64-linux-gnu. >> >> Thanks & Regards >> Ajit >> >> >> ree: Improve ree pass for rs6000 target using defined abi interfaces >> >> For rs6000 target we see redundant zero and sign >> extension and done to improve ree pass to eliminate >> such redundant zero and sign extension using defines >> ABI interfaces. >> >> 2023-04-22 Ajit Kumar Agarwal >> >> gcc/ChangeLog: >> >> * ree.cc (combline_reaching_defs): Add zero_extend >> using defined abi interfaces. >> (add_removable_extension): use of defined abi interfaces >> for no reaching defs. >> (abi_extension_candidate_return_reg_p): New defined ABI function. >> (abi_extension_candidate_p): New defined ABI function. >> (abi_extension_candidate_argno_p): New defined ABI function. >> (abi_handle_regs_without_defs_p): New defined ABI function. >> >> gcc/testsuite/ChangeLog: >> >> * g++.target/powerpc/zext-elim-3.C >> --- >> gcc/ree.cc | 176 +++++++++++++++--- >> .../g++.target/powerpc/zext-elim-3.C | 16 ++ >> 2 files changed, 162 insertions(+), 30 deletions(-) >> create mode 100644 gcc/testsuite/g++.target/powerpc/zext-elim-3.C >> >> diff --git a/gcc/ree.cc b/gcc/ree.cc >> index 413aec7c8eb..0de96b1ece1 100644 >> --- a/gcc/ree.cc >> +++ b/gcc/ree.cc >> @@ -473,7 +473,8 @@ get_defs (rtx_insn *insn, rtx reg, vec *dest) >> break; >> } >> >> - gcc_assert (use != NULL); >> + if (use == NULL) >> + return NULL; >> >> ref_chain = DF_REF_CHAIN (use); >> >> @@ -514,7 +515,8 @@ get_uses (rtx_insn *insn, rtx reg) >> if (REGNO (DF_REF_REG (def)) == REGNO (reg)) >> break; >> >> - gcc_assert (def != NULL); >> + if (def == NULL) >> + return NULL; >> >> ref_chain = DF_REF_CHAIN (def); >> >> @@ -750,6 +752,103 @@ get_extended_src_reg (rtx src) >> return src; >> } >> >> +/* Return TRUE if the candidate insn is zero extend and regno is >> + an return registers. */ >> + >> +static bool >> +abi_extension_candidate_return_reg_p (rtx_insn *insn, int regno) >> +{ >> + rtx set = single_set (insn); >> + >> + if (GET_CODE (SET_SRC (set)) != ZERO_EXTEND) >> + return false; >> + >> + if (FUNCTION_VALUE_REGNO_P (regno)) >> + return true; >> + >> + return false; >> +} >> + >> +/* Return TRUE if reg source operand of zero_extend is argument registers >> + and not return registers and source and destination operand are same >> + and mode of source and destination operand are not same. */ >> + >> +static bool >> +abi_extension_candidate_p (rtx_insn *insn) >> +{ >> + rtx set = single_set (insn); >> + >> + if (GET_CODE (SET_SRC (set)) != ZERO_EXTEND) >> + return false; >> + >> + machine_mode ext_dst_mode = GET_MODE (SET_DEST (set)); >> + rtx orig_src = XEXP (SET_SRC (set),0); >> + >> + bool copy_needed >> + = (REGNO (SET_DEST (set)) != REGNO (XEXP (SET_SRC (set), 0))); >> + >> + if (!copy_needed && ext_dst_mode != GET_MODE (orig_src) >> + && FUNCTION_ARG_REGNO_P (REGNO (orig_src)) >> + && !abi_extension_candidate_return_reg_p (insn, REGNO (orig_src))) >> + return true; >> + >> + return false; >> +} >> + >> +/* Return TRUE if the candidate insn is zero extend and regno is >> + an argument registers. */ >> + >> +static bool >> +abi_extension_candidate_argno_p (rtx_code code, int regno) >> +{ >> + if (code != ZERO_EXTEND) >> + return false; >> + >> + if (FUNCTION_ARG_REGNO_P (regno)) >> + return true; >> + >> + return false; >> +} > > I don't see anything in those functions that checks if > ZERO_EXTEND is actually a feature of the ABI, e.g. as opposed to > no extension or SIGN_EXTEND. Do I miss something? I don't think you missed anything. That was one of the points I was making last week. Somewhere, somehow we need to describe what the ABI mandates and guarantees. So while what Ajit has done is a step forward, at some point the actual details of the ABI need to be described in a way that can be checked and consumed by REE. Jeff