aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/arc/arc.c24
2 files changed, 29 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 43ae4ea..57e276a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-07 Joern Rennecke <joern.rennecke@embecosm.com>
+
+ * config/arc/arc.c (arc_ifcvt): Use commutativity, e.g.:
+ reg_a := reg_b + reg_a ==> reg_a := reg_a + reg_b
+
2013-11-07 Jeff Law <law@redhat.com>
* doc/invoke.texi (-fisolate-erroneous-paths): Document.
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 6ddd486..1e0c25e 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -8203,6 +8203,30 @@ arc_ifcvt (void)
{
/* ??? don't conditionalize if all side effects are dead
in the not-execute case. */
+
+ /* For commutative operators, we generally prefer to have
+ the first source match the destination. */
+ if (GET_CODE (pat) == SET)
+ {
+ rtx src = SET_SRC (pat);
+
+ if (COMMUTATIVE_P (src))
+ {
+ rtx src0 = XEXP (src, 0);
+ rtx src1 = XEXP (src, 1);
+ rtx dst = SET_DEST (pat);
+
+ if (rtx_equal_p (src1, dst) && !rtx_equal_p (src0, dst)
+ /* Leave add_n alone - the canonical form is to
+ have the complex summand first. */
+ && REG_P (src0))
+ pat = gen_rtx_SET (VOIDmode, dst,
+ gen_rtx_fmt_ee (GET_CODE (src),
+ GET_MODE (src),
+ src1, src0));
+ }
+ }
+
/* dwarf2out.c:dwarf2out_frame_debug_expr doesn't know
what to do with COND_EXEC. */
if (RTX_FRAME_RELATED_P (insn))