Re: [PATCH][combine][obvious] Use std::swap instead of manually swapping

2015-04-27 Thread Segher Boessenkool
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


RE: [PATCH][combine][obvious] Use std::swap instead of manually swapping

2015-04-27 Thread Kyrill Tkachov
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



combine-swap.patch
Description: Binary data


Re: [PATCH][combine][obvious] Use std::swap instead of manually swapping

2015-04-27 Thread Jeff Law

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