public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jeff Law <law@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Simplify EQ vs NE selection in `riscv_expand_conditional_move'
Date: Wed, 22 Nov 2023 05:09:33 +0000 (GMT)	[thread overview]
Message-ID: <20231122050933.138953858C30@sourceware.org> (raw)

https://gcc.gnu.org/g:b903e827990807ab691c033c72a3aebd60fe075f

commit b903e827990807ab691c033c72a3aebd60fe075f
Author: Maciej W. Rozycki <macro@embecosm.com>
Date:   Wed Nov 22 01:18:24 2023 +0000

    RISC-V: Simplify EQ vs NE selection in `riscv_expand_conditional_move'
    
    Just choose between EQ and NE at `gen_rtx_fmt_ee' invocation, removing
    an extraneous variable only referred once and improving code clarity.
    
            gcc/
            * config/riscv/riscv.cc (riscv_expand_conditional_move): Remove
            extraneous variable for EQ vs NE operation selection.
    
    (cherry picked from commit 35bea66d367520e6f62fc723bca6bf9cb291e581)

Diff:
---
 gcc/config/riscv/riscv.cc | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 7450989f35e..6a7ecdb627f 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -4052,10 +4052,12 @@ riscv_expand_conditional_move (rtx dest, rtx op, rtx cons, rtx alt)
 	 we can then use an equality comparison against zero.  */
       if (!equality_operator (op, VOIDmode) || op1 != CONST0_RTX (mode))
 	{
-	  enum rtx_code new_code = NE;
 	  bool *invert_ptr = nullptr;
 	  bool invert = false;
 
+	  /* If riscv_expand_int_scc inverts the condition, then it will
+	     flip the value of INVERT.  We need to know where so that
+	     we can adjust it for our needs.  */
 	  if (code == LE || code == GE)
 	    invert_ptr = &invert;
 
@@ -4072,13 +4074,7 @@ riscv_expand_conditional_move (rtx dest, rtx op, rtx cons, rtx alt)
 	  else
 	    return false;
 
-	  /* If riscv_expand_int_scc inverts the condition, then it will
-	     flip the value of INVERT.  We need to know where so that
-	     we can adjust it for our needs.  */
-	  if (invert)
-	    new_code = EQ;
-
-	  op = gen_rtx_fmt_ee (new_code, mode, tmp, const0_rtx);
+	  op = gen_rtx_fmt_ee (invert ? EQ : NE, mode, tmp, const0_rtx);
 
 	  /* We've generated a new comparison.  Update the local variables.  */
 	  code = GET_CODE (op);

                 reply	other threads:[~2023-11-22  5:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231122050933.138953858C30@sourceware.org \
    --to=law@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).