* [PATCH, sh]: Use std::swap
@ 2014-11-16 13:02 Uros Bizjak
2014-11-16 13:19 ` Oleg Endo
0 siblings, 1 reply; 2+ messages in thread
From: Uros Bizjak @ 2014-11-16 13:02 UTC (permalink / raw)
To: gcc-patches; +Cc: Kaz Kojima, Oleg Endo
[-- Attachment #1: Type: text/plain, Size: 442 bytes --]
Hello!
2014-11-16 Uros Bizjak <ubizjak@gmail.com>
* config/sh/sh.c: Do not include algorithm.
(sh_emit_scc_to_t): Replace open-coded swap with std::swap
to swap values.
(sh_emit_compare_and_branch): Ditto.
(sh_emit_compare_and_set): Ditto.
* config/sh/sh.md (replacement peephole2): Ditto.
(cstore4_media): Ditto.
(*fmasf4): Ditto.
Tested by building a crosscompiler to sh-elf, otherwise untested.
Uros.
[-- Attachment #2: s.diff.txt --]
[-- Type: text/plain, Size: 3039 bytes --]
Index: sh.c
===================================================================
--- sh.c (revision 217624)
+++ sh.c (working copy)
@@ -21,7 +21,6 @@ along with GCC; see the file COPYING3. If not see
#include <sstream>
#include <vector>
-#include <algorithm>
#include "config.h"
#include "system.h"
@@ -2351,11 +2350,7 @@ sh_emit_scc_to_t (enum rtx_code code, rtx op0, rtx
break;
}
if (code != oldcode)
- {
- rtx tmp = op0;
- op0 = op1;
- op1 = tmp;
- }
+ std::swap (op0, op1);
mode = GET_MODE (op0);
if (mode == VOIDmode)
@@ -2436,7 +2431,7 @@ sh_emit_compare_and_branch (rtx *operands, machine
enum rtx_code branch_code;
rtx op0 = operands[1];
rtx op1 = operands[2];
- rtx insn, tem;
+ rtx insn;
bool need_ccmpeq = false;
if (TARGET_SH2E && GET_MODE_CLASS (mode) == MODE_FLOAT)
@@ -2461,7 +2456,7 @@ sh_emit_compare_and_branch (rtx *operands, machine
|| (code == LE && TARGET_IEEE && TARGET_SH2E)
|| (code == GE && !(TARGET_IEEE && TARGET_SH2E)))
{
- tem = op0, op0 = op1, op1 = tem;
+ std::swap (op0, op1);
code = swap_condition (code);
}
@@ -2520,7 +2515,6 @@ sh_emit_compare_and_set (rtx *operands, machine_mo
rtx op1 = operands[3];
rtx_code_label *lab = NULL;
bool invert = false;
- rtx tem;
op0 = force_reg (mode, op0);
if ((code != EQ && code != NE
@@ -2534,8 +2528,8 @@ sh_emit_compare_and_set (rtx *operands, machine_mo
{
if (code == LT || code == LE)
{
+ std::swap (op0, op1);
code = swap_condition (code);
- tem = op0, op0 = op1, op1 = tem;
}
if (code == GE)
{
Index: sh.md
===================================================================
--- sh.md (revision 217624)
+++ sh.md (working copy)
@@ -1618,14 +1618,9 @@
extract_insn (insn2);
if (! constrain_operands (1, get_preferred_alternatives (insn2, bb)))
{
- rtx tmp;
failure:
- tmp = replacements[0];
- replacements[0] = replacements[1];
- replacements[1] = tmp;
- tmp = replacements[2];
- replacements[2] = replacements[3];
- replacements[3] = tmp;
+ std::swap (replacements[0], replacements[1]);
+ std::swap (replacements[2], replacements[3]);
replace_n_hard_rtx (SET_DEST (set1), replacements, 2, 1);
replace_n_hard_rtx (SET_DEST (set2), replacements, 2, 1);
replace_n_hard_rtx (SET_SRC (set2), replacements, 2, 1);
@@ -11348,9 +11343,7 @@ label:
if (swap)
{
- rtx tem = operands[2];
- operands[2] = operands[3];
- operands[3] = tem;
+ std::swap (operands[2], operands[3]);
code = swap_condition (code);
}
@@ -12538,11 +12531,7 @@ label:
/* Change 'b * a + a' into 'a * b + a'.
This is better for register allocation. */
if (REGNO (operands[2]) == REGNO (operands[3]))
- {
- rtx tmp = operands[1];
- operands[1] = operands[2];
- operands[2] = tmp;
- }
+ std::swap (operands[1], operands[2]);
}
[(set_attr "type" "fp")
(set_attr "fp_mode" "single")])
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH, sh]: Use std::swap
2014-11-16 13:02 [PATCH, sh]: Use std::swap Uros Bizjak
@ 2014-11-16 13:19 ` Oleg Endo
0 siblings, 0 replies; 2+ messages in thread
From: Oleg Endo @ 2014-11-16 13:19 UTC (permalink / raw)
To: Uros Bizjak; +Cc: gcc-patches, Kaz Kojima
On Nov 16, 2014, at 6:36 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> Hello!
>
> 2014-11-16 Uros Bizjak <ubizjak@gmail.com>
>
> * config/sh/sh.c: Do not include algorithm.
> (sh_emit_scc_to_t): Replace open-coded swap with std::swap
> to swap values.
> (sh_emit_compare_and_branch): Ditto.
> (sh_emit_compare_and_set): Ditto.
> * config/sh/sh.md (replacement peephole2): Ditto.
> (cstore4_media): Ditto.
> (*fmasf4): Ditto.
>
> Tested by building a crosscompiler to sh-elf, otherwise untested.
OK for trunk. Thanks for taking care of this.
Cheers,
Oleg
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-16 10:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-16 13:02 [PATCH, sh]: Use std::swap Uros Bizjak
2014-11-16 13:19 ` Oleg Endo
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).