]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/29953 ([SH-4] Perfomance regression in loops. cmp/eq used instead of dt)
authorChristian Bruel <christian.bruel@st.com>
Fri, 8 Jun 2007 07:58:41 +0000 (09:58 +0200)
committerChristian Bruel <chrbr@gcc.gnu.org>
Fri, 8 Jun 2007 07:58:41 +0000 (09:58 +0200)
PR target/29953
* config/sh/sh.md (doloop_end): New pattern and splitter.
* loop-iv.c (simple_rhs_p): Check for hardware registers.

From-SVN: r125564

gcc/ChangeLog
gcc/config/sh/sh.md
gcc/loop-iv.c

index 14ac46ac54aef454f54f87553c1e27c97391cd43..583ba38eff8f6369df8f57ccc2441e9544397a68 100644 (file)
@@ -1,3 +1,9 @@
+2007-06-08  Christian Bruel  <christian.bruel@st.com>
+
+       PR target/29953
+       * config/sh/sh.md (doloop_end): New pattern and splitter.
+       * loop-iv.c (simple_rhs_p): Check for hardware registers.
+       
 2007-06-08  Zdenek Dvorak  <dvorakz@suse.cz>
 
        PR middle-end/32209
index c4f6257500eebea7bb922e5e050fa6d06aed5fcd..20653b13105c560d74c85459756a420631566626 100644 (file)
@@ -7323,6 +7323,52 @@ label:
                 ? gen_rtx_GE (VOIDmode, operands[4], const0_rtx)
                 : gen_rtx_GT (VOIDmode, const0_rtx, operands[4]));
 }")
+
+; operand 0 is the loop count pseudo register
+; operand 1 is the number of loop iterations or 0 if it is unknown
+; operand 2 is the maximum number of loop iterations
+; operand 3 is the number of levels of enclosed loops
+; operand 4 is the label to jump to at the top of the loop
+
+(define_expand "doloop_end"
+  [(parallel [(set (pc) (if_then_else
+                         (ne:SI (match_operand:SI 0 "" "")
+                             (const_int 1))
+                         (label_ref (match_operand 4 "" ""))
+                         (pc)))
+             (set (match_dup 0)
+                  (plus:SI (match_dup 0) (const_int -1)))
+             (clobber (reg:SI T_REG))])]
+  "TARGET_SH2"
+  "
+{
+  if (GET_MODE (operands[0]) != SImode)
+    FAIL;
+}
+")
+
+(define_insn_and_split "doloop_end_split"
+  [(set (pc)
+       (if_then_else (ne:SI (match_operand:SI 0 "arith_reg_dest" "+r")
+                         (const_int 1))
+                     (label_ref (match_operand 1 "" ""))
+                     (pc)))
+   (set (match_dup 0)
+       (plus (match_dup 0) (const_int -1)))
+   (clobber (reg:SI T_REG))]
+  "TARGET_SH2"
+  "#"
+  ""
+  [(parallel [(set (reg:SI T_REG)
+                  (eq:SI (match_operand:SI 0 "arith_reg_dest" "+r")
+                         (const_int 1)))
+             (set (match_dup 0) (plus:SI (match_dup 0) (const_int -1)))])
+   (set (pc) (if_then_else (eq (reg:SI T_REG) (const_int 0))
+                          (label_ref (match_operand 1 "" ""))
+                          (pc)))]
+""
+   [(set_attr "type" "cbranch")])
+
 \f
 ;; ------------------------------------------------------------------------
 ;; Jump and linkage insns
index bdf1508d9ef951a609cd4af6a89032c09249336c..0b6d46db04a33963c1ca24672fd55df95feb2396 100644 (file)
@@ -1293,7 +1293,7 @@ simple_rhs_p (rtx rhs)
   rtx op0, op1;
 
   if (CONSTANT_P (rhs)
-      || REG_P (rhs))
+      || (REG_P (rhs) && !HARD_REGISTER_P (rhs)))
     return true;
 
   switch (GET_CODE (rhs))
@@ -1303,9 +1303,9 @@ simple_rhs_p (rtx rhs)
       op0 = XEXP (rhs, 0);
       op1 = XEXP (rhs, 1);
       /* Allow reg + const sets only.  */
-      if (REG_P (op0) && CONSTANT_P (op1))
+      if (REG_P (op0) && !HARD_REGISTER_P (op0) && CONSTANT_P (op1))
        return true;
-      if (REG_P (op1) && CONSTANT_P (op0))
+      if (REG_P (op1) && !HARD_REGISTER_P (op1) && CONSTANT_P (op0))
        return true;
 
       return false;