From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id 695343858D35 for ; Thu, 9 Dec 2021 00:11:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 695343858D35 Received: by mail-pg1-x534.google.com with SMTP id f125so3561110pgc.0 for ; Wed, 08 Dec 2021 16:11:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=8ffOeFLTkjwzyXUNGNVTuxX9P0Li/wXO5EthdSBDOFk=; b=tTB+srS8us55cMTEqCo2o754U2j+FI75aY2uMO+Izk+3sCEFoM4Vdx8u8fowqWK+5C OUfEVH76oYgXHmO/FF5ltTZU1cE3uTAIi4cB/Xa7D58vRqUHnGwH3MZTaZ9NOima4aPl AoKIq0PrkdXksMqDEwDlOfdWVCA6k6OVG8orUYjvrWAWzZwTDEwOMASPQBJcLwD4kMbd jZ586LYU3fUsrcOb9wYILB6eTqW/m1p7oVmDf5Psyj57abwY+Dq8MgYLGsI56jsA0WjX 19dgDC6aUbq/AAp8UyEQ1uXWaLc0SdUIj1cBduBw2rlj7pnjBLOMRXbj4MnbAcymq9+R /KDw== X-Gm-Message-State: AOAM533mVYne5I4qeyjjOZoHxEnI9mXXZcP9SJsM1WpynFORO2kcMrsa wpnBOk6C9dYnDKZuqGmSz6g= X-Google-Smtp-Source: ABdhPJw5RN/P/N+yrLCHsPrHuZB4oRruAlU1j7t/0ABCgJCRwKYBFtAVlKTBgylRZjAKOvbzVQbIAw== X-Received: by 2002:a63:1950:: with SMTP id 16mr32789818pgz.422.1639008701443; Wed, 08 Dec 2021 16:11:41 -0800 (PST) Received: from [192.168.1.15] (65-130-80-28.slkc.qwest.net. [65.130.80.28]) by smtp.gmail.com with ESMTPSA id s15sm4060047pjs.51.2021.12.08.16.11.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Dec 2021 16:11:41 -0800 (PST) Message-ID: Date: Wed, 8 Dec 2021 17:11:40 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH v3 4/7] ifcvt/optabs: Allow using a CC comparison for emit_conditional_move. Content-Language: en-US To: Robin Dapp , gcc-patches@gcc.gnu.org, richard.sandiford@arm.com References: <20211206184352.42264-1-rdapp@linux.ibm.com> <20211206184352.42264-5-rdapp@linux.ibm.com> From: Jeff Law In-Reply-To: <20211206184352.42264-5-rdapp@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Thu, 09 Dec 2021 00:11:44 -0000 On 12/6/2021 11:43 AM, Robin Dapp via Gcc-patches wrote: > Currently we only ever call emit_conditional_move with the comparison > (as well as its comparands) we got from the jump. Thus, backends are > going to emit a CC comparison for every conditional move that is being > generated instead of re-using the existing CC. > This, combined with emitting temporaries for each conditional move, > causes sky-high costs for conditional moves. > > This patch allows to re-use a CC so the costing situation is improved a > bit. > --- > gcc/expmed.c | 8 +-- > gcc/expr.c | 10 ++-- > gcc/ifcvt.c | 45 ++++++++++------- > gcc/optabs.c | 135 ++++++++++++++++++++++++++++++++++++++------------- > gcc/optabs.h | 4 +- > gcc/rtl.h | 11 ++++- > 6 files changed, 150 insertions(+), 63 deletions(-) > > > @@ -4948,17 +4947,85 @@ emit_conditional_move (rtx target, enum rtx_code code, rtx op0, rtx op1, > > +/* Helper for emitting a conditional move. */ > + > +static rtx > +emit_conditional_move_1 (rtx target, rtx comparison, > + rtx op2, rtx op3, machine_mode mode) > +{ > + enum insn_code icode; > + > + if (comparison == NULL_RTX || !COMPARISON_P (comparison)) > + return NULL_RTX; > + > + /* If the two source operands are identical, that's just a move. */ > + if (rtx_equal_p (op2, op3)) > + { > + if (!target) > + target = gen_reg_rtx (mode); > + > + emit_move_insn (target, op3); > + return target; > + } What if the condition has a side effect?  Doesn't this drop the side effect by converting the conditional move into a simple move? That's my only technical concern.  Obviously the patch needs a ChangeLog. Jeff