This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, i386]: Use std::swap
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 10 Nov 2014 22:27:30 +0100
- Subject: Re: [PATCH, i386]: Use std::swap
- Authentication-results: sourceware.org; auth=none
- References: <CAFULd4Z1gspEpeVbAsbR6K1NaR+Bg9VfLpAA8png+=xyLoCOqw at mail dot gmail dot com> <4E8B61D5-FBFE-4BC8-A252-9B1580E1E8DE at gmail dot com>
On Mon, Nov 10, 2014 at 10:13 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On November 10, 2014 9:13:29 PM CET, Uros Bizjak <ubizjak@gmail.com> wrote:
>>Hello!
>>
>>std::swap was recently mentioned in gcc-patches@ mailing list, so I
>>gave it a try. As can be seen below, a lot of code in config/i386
>>benefits from this conversion.
>>
>>Surprisingly, I didn't have to include any header on F20 linux build.
>>So, is this patch OK as far as c++ is concerned?
>>
>>2014-11-10 Uros Bizjak <ubizjak@gmail.com>
>>
>> * config/i386/i386.c (ix86_decompose_address): Replace open-coded
>
> No extra includes required? Then certainly OK. Otherwise the required includes have to go to system.h in which case please drop the custom swap template from tree-vect-data-refs.c
Interesting, tree-vect-data-refs.c survives bootstrap with:
--cut here--
Index: tree-vect-data-refs.c
===================================================================
--- tree-vect-data-refs.c (revision 217303)
+++ tree-vect-data-refs.c (working copy)
@@ -2718,14 +2718,6 @@ comp_dr_with_seg_len_pair (const void *p1_, const
return 0;
}
-template <class T> static void
-swap (T& a, T& b)
-{
- T c (a);
- a = b;
- b = c;
-}
-
/* Function vect_vfa_segment_size.
Create an expression that computes the size of segment
@@ -2858,7 +2850,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info
dr_with_seg_len (dr_b, segment_length_b));
if (compare_tree (DR_BASE_ADDRESS (dr_a), DR_BASE_ADDRESS (dr_b)) > 0)
- swap (dr_with_seg_len_pair.first, dr_with_seg_len_pair.second);
+ std::swap (dr_with_seg_len_pair.first, dr_with_seg_len_pair.second);
comp_alias_ddrs.safe_push (dr_with_seg_len_pair);
}
@@ -2908,8 +2900,8 @@ vect_prune_runtime_alias_test_list (loop_vec_info
and DR_A1 and DR_A2 are two consecutive memrefs. */
if (*dr_a1 == *dr_a2)
{
- swap (dr_a1, dr_b1);
- swap (dr_a2, dr_b2);
+ std::swap (dr_a1, dr_b1);
+ std::swap (dr_a2, dr_b2);
}
if (!operand_equal_p (DR_BASE_ADDRESS (dr_a1->dr),
--cut here--
Uros.