arc.c (arc_ifcvt): Use commutativity, e.g.: reg_a := reg_b + reg_a ==> reg_a := reg_a...
authorJoern Rennecke <joern.rennecke@embecosm.com>
Thu, 7 Nov 2013 17:37:11 +0000 (17:37 +0000)
committerJoern Rennecke <amylaar@gcc.gnu.org>
Thu, 7 Nov 2013 17:37:11 +0000 (17:37 +0000)
        * 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

gcc/ChangeLog
gcc/config/arc/arc.c

index 43ae4ea..57e276a 100644 (file)
@@ -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.
index 6ddd486..1e0c25e 100644 (file)
@@ -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))