[08/44] RISC-V: Simplify EQ vs NE selection in `riscv_expand_conditional_move'
Checks
Context |
Check |
Description |
rivoscibot/toolchain-ci-rivos-apply-patch |
success
|
Patch applied
|
rivoscibot/toolchain-ci-rivos-lint |
success
|
Lint passed
|
rivoscibot/toolchain-ci-rivos-build--newlib-rv64gc-lp64d-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-build--linux-rv32gc_zba_zbb_zbc_zbs-ilp32d-non-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-build--linux-rv64gc_zba_zbb_zbc_zbs-lp64d-non-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-build--linux-rv64gcv-lp64d-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-build--newlib-rv64gcv-lp64d-multilib |
success
|
Build passed
|
Commit Message
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.
---
FWIW I have no idea what "We need to know where so that we can adjust it
for our needs." refers to, but that would have to be for another change.
---
gcc/config/riscv/riscv.cc | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
gcc-riscv-expand-conditional-move-new-code.diff
Comments
LGTM
On Sun, Nov 19, 2023 at 1:37 PM Maciej W. Rozycki <macro@embecosm.com> wrote:
>
> 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.
> ---
> FWIW I have no idea what "We need to know where so that we can adjust it
> for our needs." refers to, but that would have to be for another change.
> ---
> gcc/config/riscv/riscv.cc | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> gcc-riscv-expand-conditional-move-new-code.diff
> Index: gcc/gcc/config/riscv/riscv.cc
> ===================================================================
> --- gcc.orig/gcc/config/riscv/riscv.cc
> +++ gcc/gcc/config/riscv/riscv.cc
> @@ -4023,10 +4023,12 @@ riscv_expand_conditional_move (rtx dest,
> 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;
>
> @@ -4043,13 +4045,7 @@ riscv_expand_conditional_move (rtx dest,
> 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);
===================================================================
@@ -4023,10 +4023,12 @@ riscv_expand_conditional_move (rtx dest,
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;
@@ -4043,13 +4045,7 @@ riscv_expand_conditional_move (rtx dest,
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);