From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2119) id 138953858C30; Wed, 22 Nov 2023 05:09:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 138953858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700629773; bh=xzZUkDClaMcddgdsyrrvpPO9EuwP4DGCG4m9c2gmzVs=; h=From:To:Subject:Date:From; b=JdeJ9QxCybVtUs0WN3xtvFZD+YAEcceWG57v/HdlTy5z6dXvK2DoHGGs0Jd8T2ZzP 0I7RfxfI5YwaErjrQT6df/c3fqqmHj0gpFSo58uu8ubdA6J2VSwdQOMb5tEbLLiWPU 4zJwwSkqYjcDGS6to/w1sNqzHptDCFMNDqFuFTQk= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jeff Law 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' X-Act-Checkin: gcc X-Git-Author: Maciej W. Rozycki X-Git-Refname: refs/vendors/riscv/heads/gcc-13-with-riscv-opts X-Git-Oldrev: 792801f53d0f729ca52e0720800a9433204da564 X-Git-Newrev: b903e827990807ab691c033c72a3aebd60fe075f Message-Id: <20231122050933.138953858C30@sourceware.org> Date: Wed, 22 Nov 2023 05:09:33 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b903e827990807ab691c033c72a3aebd60fe075f commit b903e827990807ab691c033c72a3aebd60fe075f Author: Maciej W. Rozycki 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);