* [PATCH][combine][obvious] Use std::swap instead of manually swapping
@ 2015-04-27 9:55 Kyrill Tkachov
2015-04-27 14:38 ` Segher Boessenkool
0 siblings, 1 reply; 4+ messages in thread
From: Kyrill Tkachov @ 2015-04-27 9:55 UTC (permalink / raw)
To: GCC Patches; +Cc: Segher Boessenkool
[-- Attachment #1: Type: text/plain, Size: 516 bytes --]
Hi all,
This is another one of those std::swap patches, this time I was in the combine neighbourhood
Bootstrapped on x86_64 and tested on aarch64.
Precedents suggest these changes are considered obvious.
So I'll commit this in a couple of days unless someone objects.
Thanks,
Kyrill
2015-04-27 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* combine.c (simplify_if_then_else): Use std::swap instead
of manually swapping.
(known_cond): Likewise.
(simplify_comparison): Likewise.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: combine-swap.patch --]
[-- Type: text/x-patch; name=combine-swap.patch, Size: 2232 bytes --]
commit e8aa8f2ec22cf548bc05f0f8e56a13a2bdd1c228
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date: Fri Apr 24 17:47:14 2015 +0100
[combine][obvious] Use std::swap instead of manually swapping
diff --git a/gcc/combine.c b/gcc/combine.c
index 9f840cb..5f7cbc0 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -6185,7 +6185,7 @@ simplify_if_then_else (rtx x)
if (false_code == EQ)
{
swapped = 1, true_code = EQ, false_code = NE;
- temp = true_rtx, true_rtx = false_rtx, false_rtx = temp;
+ std::swap (true_rtx, false_rtx);
}
/* If we are comparing against zero and the expression being tested has
@@ -6250,7 +6250,7 @@ simplify_if_then_else (rtx x)
SUBST (XEXP (x, 1), false_rtx);
SUBST (XEXP (x, 2), true_rtx);
- temp = true_rtx, true_rtx = false_rtx, false_rtx = temp;
+ std::swap (true_rtx, false_rtx);
cond = XEXP (x, 0);
/* It is possible that the conditional has been simplified out. */
@@ -9022,7 +9022,6 @@ static rtx
known_cond (rtx x, enum rtx_code cond, rtx reg, rtx val)
{
enum rtx_code code = GET_CODE (x);
- rtx temp;
const char *fmt;
int i, j;
@@ -9062,7 +9061,7 @@ known_cond (rtx x, enum rtx_code cond, rtx reg, rtx val)
else if (COMPARISON_P (x) || COMMUTATIVE_ARITH_P (x))
{
if (rtx_equal_p (XEXP (x, 0), val))
- cond = swap_condition (cond), temp = val, val = reg, reg = temp;
+ cond = swap_condition (cond), std::swap (val, reg);
if (rtx_equal_p (XEXP (x, 0), reg) && rtx_equal_p (XEXP (x, 1), val))
{
@@ -11454,7 +11453,7 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx *pop1)
is already a constant integer. */
if (swap_commutative_operands_p (op0, op1))
{
- tem = op0, op0 = op1, op1 = tem;
+ std::swap (op0, op1);
code = swap_condition (code);
}
@@ -12341,7 +12340,7 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx *pop1)
/* We may have changed the comparison operands. Re-canonicalize. */
if (swap_commutative_operands_p (op0, op1))
{
- tem = op0, op0 = op1, op1 = tem;
+ std::swap (op0, op1);
code = swap_condition (code);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][combine][obvious] Use std::swap instead of manually swapping
2015-04-27 9:55 [PATCH][combine][obvious] Use std::swap instead of manually swapping Kyrill Tkachov
@ 2015-04-27 14:38 ` Segher Boessenkool
2015-04-27 14:58 ` Kyrill Tkachov
2015-04-27 16:07 ` Jeff Law
0 siblings, 2 replies; 4+ messages in thread
From: Segher Boessenkool @ 2015-04-27 14:38 UTC (permalink / raw)
To: Kyrill Tkachov; +Cc: GCC Patches
On Mon, Apr 27, 2015 at 10:55:17AM +0100, Kyrill Tkachov wrote:
> Precedents suggest these changes are considered obvious.
> So I'll commit this in a couple of days unless someone objects.
Yes it's obvious. One tiny thing...
> @@ -9062,7 +9061,7 @@ known_cond (rtx x, enum rtx_code cond, rtx reg, rtx val)
> else if (COMPARISON_P (x) || COMMUTATIVE_ARITH_P (x))
> {
> if (rtx_equal_p (XEXP (x, 0), val))
> - cond = swap_condition (cond), temp = val, val = reg, reg = temp;
> + cond = swap_condition (cond), std::swap (val, reg);
>
> if (rtx_equal_p (XEXP (x, 0), reg) && rtx_equal_p (XEXP (x, 1), val))
> {
Might as well write this as two statements, like everywhere else, e.g.
> @@ -11454,7 +11453,7 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx *pop1)
> is already a constant integer. */
> if (swap_commutative_operands_p (op0, op1))
> {
> - tem = op0, op0 = op1, op1 = tem;
> + std::swap (op0, op1);
> code = swap_condition (code);
> }
Thanks,
Segher
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH][combine][obvious] Use std::swap instead of manually swapping
2015-04-27 14:38 ` Segher Boessenkool
@ 2015-04-27 14:58 ` Kyrill Tkachov
2015-04-27 16:07 ` Jeff Law
1 sibling, 0 replies; 4+ messages in thread
From: Kyrill Tkachov @ 2015-04-27 14:58 UTC (permalink / raw)
To: 'Segher Boessenkool'; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 1221 bytes --]
On 27/04/15 15:37, Segher Boessenkool wrote:
> On Mon, Apr 27, 2015 at 10:55:17AM +0100, Kyrill Tkachov wrote:
>> Precedents suggest these changes are considered obvious.
>> So I'll commit this in a couple of days unless someone objects.
>
> Yes it's obvious. One tiny thing...
>
>> @@ -9062,7 +9061,7 @@ known_cond (rtx x, enum rtx_code cond, rtx reg, rtx
val)
>> else if (COMPARISON_P (x) || COMMUTATIVE_ARITH_P (x))
>> {
>> if (rtx_equal_p (XEXP (x, 0), val))
>> - cond = swap_condition (cond), temp = val, val = reg, reg = temp;
>> + cond = swap_condition (cond), std::swap (val, reg);
>>
>> if (rtx_equal_p (XEXP (x, 0), reg) && rtx_equal_p (XEXP (x, 1),
val))
>> {
>
> Might as well write this as two statements, like everywhere else, e.g.
>
>> @@ -11454,7 +11453,7 @@ simplify_comparison (enum rtx_code code, rtx
*pop0, rtx *pop1)
>> is already a constant integer. */
>> if (swap_commutative_operands_p (op0, op1))
>> {
>> - tem = op0, op0 = op1, op1 = tem;
>> + std::swap (op0, op1);
>> code = swap_condition (code);
>> }
>
> Thanks,
Thanks, here's what I committed with r222468.
Kyrill
>
>
>
> Segher
>
[-- Attachment #2: combine-swap.patch --]
[-- Type: application/octet-stream, Size: 2198 bytes --]
commit 0f453edfd3d2aaa9414fa89eb3fea18adac1f319
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date: Fri Apr 24 17:47:14 2015 +0100
[combine][obvious] Use std::swap instead of manually swapping
diff --git a/gcc/combine.c b/gcc/combine.c
index 9f840cb..000188b 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -6185,7 +6185,7 @@ simplify_if_then_else (rtx x)
if (false_code == EQ)
{
swapped = 1, true_code = EQ, false_code = NE;
- temp = true_rtx, true_rtx = false_rtx, false_rtx = temp;
+ std::swap (true_rtx, false_rtx);
}
/* If we are comparing against zero and the expression being tested has
@@ -6250,7 +6250,7 @@ simplify_if_then_else (rtx x)
SUBST (XEXP (x, 1), false_rtx);
SUBST (XEXP (x, 2), true_rtx);
- temp = true_rtx, true_rtx = false_rtx, false_rtx = temp;
+ std::swap (true_rtx, false_rtx);
cond = XEXP (x, 0);
/* It is possible that the conditional has been simplified out. */
@@ -9022,7 +9022,6 @@ static rtx
known_cond (rtx x, enum rtx_code cond, rtx reg, rtx val)
{
enum rtx_code code = GET_CODE (x);
- rtx temp;
const char *fmt;
int i, j;
@@ -9062,7 +9061,10 @@ known_cond (rtx x, enum rtx_code cond, rtx reg, rtx val)
else if (COMPARISON_P (x) || COMMUTATIVE_ARITH_P (x))
{
if (rtx_equal_p (XEXP (x, 0), val))
- cond = swap_condition (cond), temp = val, val = reg, reg = temp;
+ {
+ std::swap (val, reg);
+ cond = swap_condition (cond);
+ }
if (rtx_equal_p (XEXP (x, 0), reg) && rtx_equal_p (XEXP (x, 1), val))
{
@@ -11454,7 +11456,7 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx *pop1)
is already a constant integer. */
if (swap_commutative_operands_p (op0, op1))
{
- tem = op0, op0 = op1, op1 = tem;
+ std::swap (op0, op1);
code = swap_condition (code);
}
@@ -12341,7 +12343,7 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx *pop1)
/* We may have changed the comparison operands. Re-canonicalize. */
if (swap_commutative_operands_p (op0, op1))
{
- tem = op0, op0 = op1, op1 = tem;
+ std::swap (op0, op1);
code = swap_condition (code);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][combine][obvious] Use std::swap instead of manually swapping
2015-04-27 14:38 ` Segher Boessenkool
2015-04-27 14:58 ` Kyrill Tkachov
@ 2015-04-27 16:07 ` Jeff Law
1 sibling, 0 replies; 4+ messages in thread
From: Jeff Law @ 2015-04-27 16:07 UTC (permalink / raw)
To: Segher Boessenkool, Kyrill Tkachov; +Cc: GCC Patches
On 04/27/2015 08:37 AM, Segher Boessenkool wrote:
> On Mon, Apr 27, 2015 at 10:55:17AM +0100, Kyrill Tkachov wrote:
>> Precedents suggest these changes are considered obvious.
>> So I'll commit this in a couple of days unless someone objects.
>
> Yes it's obvious. One tiny thing...
>
>> @@ -9062,7 +9061,7 @@ known_cond (rtx x, enum rtx_code cond, rtx reg, rtx val)
>> else if (COMPARISON_P (x) || COMMUTATIVE_ARITH_P (x))
>> {
>> if (rtx_equal_p (XEXP (x, 0), val))
>> - cond = swap_condition (cond), temp = val, val = reg, reg = temp;
>> + cond = swap_condition (cond), std::swap (val, reg);
>>
>> if (rtx_equal_p (XEXP (x, 0), reg) && rtx_equal_p (XEXP (x, 1), val))
>> {
>
> Might as well write this as two statements, like everywhere else, e.g.
Agreed. I really dislike using ',' like is shown above from a
readability standpoint.
jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-27 16:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-27 9:55 [PATCH][combine][obvious] Use std::swap instead of manually swapping Kyrill Tkachov
2015-04-27 14:38 ` Segher Boessenkool
2015-04-27 14:58 ` Kyrill Tkachov
2015-04-27 16:07 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).