This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][obvious] Use std::swap instead of manually swapping in a few more places


Hi all,

This patch uses std::swap in a few places in the midend, replacing the manual approach, and removing
a few, now unused, local variables in the process.

Bootstrapped on x86_64.
Committed as obvious with  r226179.

Thanks,
Kyrill

2015-07-24  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

    * alias.c (nonoverlapping_memrefs_p): Use std::swap instead of
    manually swapping values.
    * cse.c (fold_rtx): Likewise.
    * lra-eliminations.c (form_sum): Likewise.
commit 8ab508f57d6f10ac6ec97f61f80689807821772f
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date:   Fri Jul 24 16:16:35 2015 +0100

    [obvious] Use std::swap instead of manually swapping in a few more places

diff --git a/gcc/alias.c b/gcc/alias.c
index 3203722..fa7d5d8 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -2466,7 +2466,7 @@ nonoverlapping_memrefs_p (const_rtx x, const_rtx y, bool loop_invariant)
   rtx basex, basey;
   bool moffsetx_known_p, moffsety_known_p;
   HOST_WIDE_INT moffsetx = 0, moffsety = 0;
-  HOST_WIDE_INT offsetx = 0, offsety = 0, sizex, sizey, tem;
+  HOST_WIDE_INT offsetx = 0, offsety = 0, sizex, sizey;
 
   /* Unless both have exprs, we can't tell anything.  */
   if (exprx == 0 || expry == 0)
@@ -2583,8 +2583,8 @@ nonoverlapping_memrefs_p (const_rtx x, const_rtx y, bool loop_invariant)
   /* Put the values of the memref with the lower offset in X's values.  */
   if (offsetx > offsety)
     {
-      tem = offsetx, offsetx = offsety, offsety = tem;
-      tem = sizex, sizex = sizey, sizey = tem;
+      std::swap (offsetx, offsety);
+      std::swap (sizex, sizey);
     }
 
   /* If we don't know the size of the lower-offset value, we can't tell
diff --git a/gcc/cse.c b/gcc/cse.c
index 1c14d83..112cac5 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -3297,9 +3297,8 @@ fold_rtx (rtx x, rtx_insn *insn)
 	 consistent with the order in X.  */
       if (canonicalize_change_group (insn, x))
 	{
-	  rtx tem;
-	  tem = const_arg0, const_arg0 = const_arg1, const_arg1 = tem;
-	  tem = folded_arg0, folded_arg0 = folded_arg1, folded_arg1 = tem;
+	  std::swap (const_arg0, const_arg1);
+	  std::swap (folded_arg0, folded_arg1);
 	}
 
       apply_change_group ();
diff --git a/gcc/lra-eliminations.c b/gcc/lra-eliminations.c
index c8da0c2..fdf4179 100644
--- a/gcc/lra-eliminations.c
+++ b/gcc/lra-eliminations.c
@@ -215,7 +215,6 @@ setup_elimination_map (void)
 static rtx
 form_sum (rtx x, rtx y)
 {
-  rtx tem;
   machine_mode mode = GET_MODE (x);
 
   if (mode == VOIDmode)
@@ -229,7 +228,7 @@ form_sum (rtx x, rtx y)
   else if (CONST_INT_P (y))
     return plus_constant (mode, x, INTVAL (y));
   else if (CONSTANT_P (x))
-    tem = x, x = y, y = tem;
+    std::swap (x, y);
 
   if (GET_CODE (x) == PLUS && CONSTANT_P (XEXP (x, 1)))
     return form_sum (XEXP (x, 0), form_sum (XEXP (x, 1), y));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]