aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/arc
diff options
context:
space:
mode:
authorJoern Rennecke <joern.rennecke@embecosm.com>2013-11-07 17:37:11 +0000
committerJoern Rennecke <amylaar@gcc.gnu.org>2013-11-07 17:37:11 +0000
commit9bf218f918e35d875270fcda4be593a500388d97 (patch)
tree847488a56221715a9d1d914ec11c1194e3872936 /gcc/config/arc
parent89d3d605c34442ebf2717b8c100619bae7401ef9 (diff)
downloadgcc-9bf218f918e35d875270fcda4be593a500388d97.zip
gcc-9bf218f918e35d875270fcda4be593a500388d97.tar.gz
gcc-9bf218f918e35d875270fcda4be593a500388d97.tar.bz2
arc.c (arc_ifcvt): Use commutativity, e.g.: reg_a := reg_b + reg_a ==> reg_a := reg_a + reg_b
* config/arc/arc.c (arc_ifcvt): Use commutativity, e.g.: reg_a := reg_b + reg_a ==> reg_a := reg_a + reg_b From-SVN: r204534
Diffstat (limited to 'gcc/config/arc')
-rw-r--r--gcc/config/arc/arc.c24
1 files changed, 24 insertions, 0 deletions
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))