[v2,2/3] xtensa: Make use of std::swap where appropriate

Message ID 02092015-c705-434f-9ebf-e2008b4e5afc@yahoo.co.jp
State New
Headers
Series [v2,1/3] xtensa: Resurrect LEAF_REGISTERS and LEAF_REG_REMAP |

Commit Message

Takayuki 'January June' Suwa July 14, 2024, 11:03 a.m. UTC
  No functional changes.

gcc/ChangeLog:

	* config/xtensa/xtensa.cc
	(gen_int_relational, gen_float_relational): Replace tempvar-based
	value-swapping codes with std::swap.
	* config/xtensa/xtensa.md (movdi_internal, movdf_internal):
	Ditto.
---
  gcc/config/xtensa/xtensa.cc | 12 ++----------
  gcc/config/xtensa/xtensa.md | 10 ++++------
  2 files changed, 6 insertions(+), 16 deletions(-)
  

Comments

Max Filippov July 30, 2024, 12:09 a.m. UTC | #1
On Sun, Jul 14, 2024 at 4:05 AM Takayuki 'January June' Suwa
<jjsuwa_sys3175@yahoo.co.jp> wrote:
>
> No functional changes.
>
> gcc/ChangeLog:
>
>         * config/xtensa/xtensa.cc
>         (gen_int_relational, gen_float_relational): Replace tempvar-based
>         value-swapping codes with std::swap.
>         * config/xtensa/xtensa.md (movdi_internal, movdf_internal):
>         Ditto.
> ---
>   gcc/config/xtensa/xtensa.cc | 12 ++----------
>   gcc/config/xtensa/xtensa.md | 10 ++++------
>   2 files changed, 6 insertions(+), 16 deletions(-)

Regtested for target=xtensa-linux-uclibc, no new regressions.
Committed to master
  

Patch

diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc
index 099213f0994..f0a91763feb 100644
--- a/gcc/config/xtensa/xtensa.cc
+++ b/gcc/config/xtensa/xtensa.cc
@@ -801,11 +801,7 @@  gen_int_relational (enum rtx_code test_code, /* relational test (EQ, etc) */
  
      }
    else if (p_info->reverse_regs)
-    {
-      rtx temp = cmp0;
-      cmp0 = cmp1;
-      cmp1 = temp;
-    }
+    std::swap (cmp0, cmp1);
  
    return gen_rtx_fmt_ee (invert ? reverse_condition (p_info->test_code)
  				: p_info->test_code,
@@ -849,11 +845,7 @@  gen_float_relational (enum rtx_code test_code, /* relational test (EQ, etc) */
      }
  
    if (reverse_regs)
-    {
-      rtx temp = cmp0;
-      cmp0 = cmp1;
-      cmp1 = temp;
-    }
+    std::swap (cmp0, cmp1);
  
    brtmp = gen_rtx_REG (CCmode, FPCC_REGNUM);
    emit_insn (gen_fn (brtmp, cmp0, cmp1));
diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
index 8709ef6d7a7..0fcbb0b7bc3 100644
--- a/gcc/config/xtensa/xtensa.md
+++ b/gcc/config/xtensa/xtensa.md
@@ -1215,9 +1215,8 @@ 
    xtensa_split_operand_pair (operands, SImode);
    if (reg_overlap_mentioned_p (operands[0], operands[3]))
      {
-      rtx tmp;
-      tmp = operands[0], operands[0] = operands[1], operands[1] = tmp;
-      tmp = operands[2], operands[2] = operands[3], operands[3] = tmp;
+      std::swap (operands[0], operands[1]);
+      std::swap (operands[2], operands[3]);
      }
  })
  
@@ -1562,9 +1561,8 @@ 
    xtensa_split_operand_pair (operands, SFmode);
    if (reg_overlap_mentioned_p (operands[0], operands[3]))
      {
-      rtx tmp;
-      tmp = operands[0], operands[0] = operands[1], operands[1] = tmp;
-      tmp = operands[2], operands[2] = operands[3], operands[3] = tmp;
+      std::swap (operands[0], operands[1]);
+      std::swap (operands[2], operands[3]);
      }
  })