]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Use pc_or_label_operand to collapse a couple more patterns in preparation for the...
authorJeff Law <law@torsion.usersys.redhat.com>
Sun, 17 May 2020 17:20:39 +0000 (13:20 -0400)
committerJeff Law <law@torsion.usersys.redhat.com>
Sun, 17 May 2020 17:22:38 +0000 (13:22 -0400)
* config/h8300/predicates.md (pc_or_label_operand): New predicate.
* config/h8300/jumpcall.md (branch_true, branch_false): Consolidate
into a single pattern using pc_or_label_operand.
* config/h8300/combiner.md (bit branch patterns): Likewise.
* config/h8300/peepholes.md (HImode and SImode branches): Likewise.

gcc/ChangeLog
gcc/config/h8300/combiner.md
gcc/config/h8300/jumpcall.md
gcc/config/h8300/peepholes.md
gcc/config/h8300/predicates.md

index f03b996ab9e4e8eedcfe784998f17d128cbf713c..3a090452a969d5bbb249a6546bdc4837f0120792 100644 (file)
@@ -1,3 +1,11 @@
+2020-05-17 Jeff Law  <law@redhat.com>
+
+       * config/h8300/predicates.md (pc_or_label_operand): New predicate.
+       * config/h8300/jumpcall.md (branch_true, branch_false): Consolidate
+       into a single pattern using pc_or_label_operand.
+       * config/h8300/combiner.md (bit branch patterns): Likewise.
+       * config/h8300/peepholes.md (HImode and SImode branches): Likewise.
+
 2020-05-17  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/95021
index f59ff5f15bdc637090933b5d32cfb7234a6f4ac2..4f49c7fba3498d91cf73b1d9e27b5f884a71e93b 100644 (file)
                                           (const_int 1)
                                           (const_int 7))
                          (const_int 0))
-                     (label_ref (match_operand 1 "" ""))
-                     (pc)))]
-  ""
+                     (match_operand 1 "pc_or_label_operand" "")
+                     (match_operand 2 "pc_or_label_operand" "")))]
+  "operands[1] == pc_rtx || operands[2] == pc_rtx"
   "#"
   ""
   [(set (cc0) (compare (match_dup 0)
    (set (pc)
        (if_then_else (ge (cc0)
                          (const_int 0))
-                     (label_ref (match_dup 1))
-                     (pc)))]
-  "")
+                     (match_dup 1)
+                     (match_dup 2)))])
 
 (define_insn_and_split ""
   [(set (pc)
                                           (const_int 1)
                                           (const_int 7))
                          (const_int 0))
-                     (label_ref (match_operand 1 "" ""))
-                     (pc)))]
-  ""
+                     (match_operand 1 "pc_or_label_operand" "")
+                     (match_operand 2 "pc_or_label_operand" "")))]
+  "operands[1] == pc_rtx || operands[2] == pc_rtx"
   "#"
   ""
   [(set (cc0) (compare (match_dup 0)
    (set (pc)
        (if_then_else (lt (cc0)
                          (const_int 0))
-                     (label_ref (match_dup 1))
-                     (pc)))]
-  "")
+                     (match_dup 1)
+                     (match_dup 2)))])
index 4c0a5ccf8af4d66088001a1978b44964fdfe99d1..7208fb6d86b550a39efd16ca1da795177162b1ba 100644 (file)
     DONE;
   })
 
-(define_insn "branch_true"
+(define_insn "branch"
   [(set (pc)
-       (if_then_else (match_operator 1 "comparison_operator"
+       (if_then_else (match_operator 2 "comparison_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 0 "" ""))
-                     (pc)))]
-  ""
+                     (match_operand 0 "pc_or_label_operand" "")
+                     (match_operand 1 "pc_or_label_operand" "")))]
+  "operands[0] == pc_rtx || operands[1] == pc_rtx"
 {
   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
-      && (GET_CODE (operands[1]) == GT
-         || GET_CODE (operands[1]) == GE
-         || GET_CODE (operands[1]) == LE
-         || GET_CODE (operands[1]) == LT))
+      && (GET_CODE (operands[2]) == GT
+         || GET_CODE (operands[2]) == GE
+         || GET_CODE (operands[2]) == LE
+         || GET_CODE (operands[2]) == LT))
     {
       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
       return 0;
     }
 
-  if (get_attr_length (insn) == 2)
-    return "b%j1       %l0";
-  else if (get_attr_length (insn) == 4)
-    return "b%j1       %l0:16";
-  else
-    return "b%k1       .Lh8BR%=\;jmp   @%l0\\n.Lh8BR%=:";
-}
- [(set_attr "type" "branch")
-   (set_attr "cc" "none")])
-
-(define_insn "branch_false"
-  [(set (pc)
-       (if_then_else (match_operator 1 "comparison_operator"
-                      [(cc0) (const_int 0)])
-                     (pc)
-                     (label_ref (match_operand 0 "" ""))))]
-  ""
-{
-  if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
-      && (GET_CODE (operands[1]) == GT
-         || GET_CODE (operands[1]) == GE
-         || GET_CODE (operands[1]) == LE
-         || GET_CODE (operands[1]) == LT))
+  if (operands[0] != pc_rtx)
     {
-      cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
-      return 0;
+      if (get_attr_length (insn) == 2)
+       return "b%j2    %l0";
+      else if (get_attr_length (insn) == 4)
+       return "b%j2    %l0:16";
+      else
+       return "b%k2    .Lh8BR%=\;jmp   @%l0\\n.Lh8BR%=:";
     }
-
-  if (get_attr_length (insn) == 2)
-    return "b%k1       %l0";
-  else if (get_attr_length (insn) == 4)
-    return "b%k1       %l0:16";
   else
-    return "b%j1       .Lh8BR%=\;jmp   @%l0\\n.Lh8BR%=:";
+    {
+      if (get_attr_length (insn) == 2)
+       return "b%k2    %l1";
+      else if (get_attr_length (insn) == 4)
+       return "b%k2    %l1:16";
+      else
+       return "b%j2    .Lh8BR%=\;jmp   @%l1\\n.Lh8BR%=:";
+    }
 }
 [(set_attr "type" "branch")
+ [(set_attr "type" "branch")
    (set_attr "cc" "none")])
 
 (define_insn "*brabc"
index a0f5af28a53f640ff5037d10ecec1d61cb7ea05f..8442cd80a5e8be92b1e1418f5af9b04bf405df5f 100644 (file)
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_operator 3 "eqne_operator"
+       (if_then_else (match_operator 4 "eqne_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   ""
   [(set (match_operand:HI 0 "register_operand" "")
        (unspec:HI [(match_dup 0)
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
-                     (label_ref (match_dup 2))
-                     (pc)))]
-  "")
+       (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
+                     (match_dup 2)
+                     (match_dup 3)))])
 
 ;; The SImode version of the previous pattern.
 
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_operator 3 "eqne_operator"
+       (if_then_else (match_operator 4 "eqne_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   ""
   [(set (match_operand:SI 0 "register_operand" "")
        (unspec:SI [(match_dup 0)
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
-                     (label_ref (match_dup 2))
-                     (pc)))]
-  "")
+       (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
+                     (match_dup 2)
+                     (match_dup 3)))])
 
 (define_peephole2
   [(parallel [(set (cc0)
                            (const_int 0)))
              (clobber (scratch:QI))])
    (set (pc)
-       (if_then_else (match_operator 1 "eqne_operator"
+       (if_then_else (match_operator 4 "eqne_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   ""
   [(set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
-                     (label_ref (match_dup 2))
-                     (pc)))]
+       (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[3] = ((GET_CODE (operands[1]) == EQ)
+    operands[4] = ((GET_CODE (operands[4]) == EQ)
                   ? gen_rtx_GE (VOIDmode, cc0_rtx, const0_rtx)
                   : gen_rtx_LT (VOIDmode, cc0_rtx, const0_rtx));
   })
        (compare (match_operand:HI 0 "register_operand" "")
                 (match_operand:HI 1 "incdec_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 3 "eqne_operator"
+       (if_then_else (match_operator 4 "eqne_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "INTVAL (operands[1]) != 0 && peep2_reg_dead_p (1, operands[0])"
   [(set (match_dup 0)
        (unspec:HI [(match_dup 0)
-                   (match_dup 4)]
+                   (match_dup 5)]
                   UNSPEC_INCDEC))
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
-                     (label_ref (match_dup 2))
-                     (pc)))]
+       (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[4] = GEN_INT (- INTVAL (operands[1]));
+    operands[5] = GEN_INT (- INTVAL (operands[1]));
   })
 
 ;; Transform
        (compare (match_operand:HI 0 "register_operand" "")
                 (match_operand:HI 1 "const_int_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 2 "gtle_operator"
+       (if_then_else (match_operator 4 "gtle_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 3 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "peep2_reg_dead_p (1, operands[0])
    && (INTVAL (operands[1]) == 1
        || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
   [(parallel [(set (match_dup 0)
                   (ashiftrt:HI (match_dup 0)
-                               (match_dup 4)))
+                               (match_dup 5)))
              (clobber (scratch:QI))])
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_dup 2)
-                     (label_ref (match_dup 3))
-                     (pc)))]
+       (if_then_else (match_dup 4)
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
+    operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
   })
 
 ;; Transform
        (compare (match_operand:HI 0 "register_operand" "")
                 (match_operand:HI 1 "const_int_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 2 "gtuleu_operator"
+       (if_then_else (match_operator 4 "gtuleu_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 3 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "peep2_reg_dead_p (1, operands[0])
    && (INTVAL (operands[1]) == 1
        || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
   [(parallel [(set (match_dup 0)
                   (ashiftrt:HI (match_dup 0)
-                               (match_dup 4)))
+                               (match_dup 5)))
              (clobber (scratch:QI))])
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_dup 5)
-                     (label_ref (match_dup 3))
-                     (pc)))]
+       (if_then_else (match_dup 6)
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
-    operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
+    operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
+    operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[4]) == GTU ? NE : EQ,
                                  VOIDmode, cc0_rtx, const0_rtx);
   })
 
    (set (pc)
        (if_then_else (match_operator 1 "gtle_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   ""
   [(set (cc0) (compare (and:HI (match_dup 0)
                               (const_int -256))
                       (const_int 0)))
    (set (pc)
        (if_then_else (match_dup 1)
-                     (label_ref (match_dup 2))
-                     (pc)))]
-  "")
+                     (match_dup 2)
+                     (match_dup 3)))])
 
 ;; Transform
 ;;
    (set (pc)
        (if_then_else (match_operator 1 "gtuleu_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   ""
   [(set (cc0) (compare (and:HI (match_dup 0)
                               (const_int -256))
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_dup 3)
-                     (label_ref (match_dup 2))
-                     (pc)))]
+       (if_then_else (match_dup 4)
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
+    operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
                                  VOIDmode, cc0_rtx, const0_rtx);
   })
 
        (compare (match_operand:SI 0 "register_operand" "")
                 (match_operand:SI 1 "incdec_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 3 "eqne_operator"
+       (if_then_else (match_operator 4 "eqne_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "INTVAL (operands[1]) != 0 && peep2_reg_dead_p (1, operands[0])"
   [(set (match_dup 0)
        (unspec:SI [(match_dup 0)
-                   (match_dup 4)]
+                   (match_dup 5)]
                   UNSPEC_INCDEC))
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
-                     (label_ref (match_dup 2))
-                     (pc)))]
+       (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[4] = GEN_INT (- INTVAL (operands[1]));
+    operands[5] = GEN_INT (- INTVAL (operands[1]));
   })
 
 ;; Transform
        (compare (match_operand:SI 0 "register_operand" "")
                 (match_operand:SI 1 "const_int_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 3 "eqne_operator"
+       (if_then_else (match_operator 4 "eqne_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "peep2_reg_dead_p (1, operands[0])
    && (INTVAL (operands[1]) == -131072
        || INTVAL (operands[1]) == -65536
        || INTVAL (operands[1]) == 131072)"
   [(set (match_dup 0)
        (plus:SI (match_dup 0)
-                (match_dup 4)))
+                (match_dup 5)))
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
-                     (label_ref (match_dup 2))
-                     (pc)))]
+       (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[4] = GEN_INT (- INTVAL (operands[1]));
+    operands[5] = GEN_INT (- INTVAL (operands[1]));
   })
 
 ;; Transform
        (compare (match_operand:SI 0 "register_operand" "")
                 (match_operand:SI 1 "const_int_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 3 "eqne_operator"
+       (if_then_else (match_operator 4 "eqne_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "peep2_reg_dead_p (1, operands[0])
    && ((INTVAL (operands[1]) & 0x00ff) == INTVAL (operands[1])
        || (INTVAL (operands[1]) & 0xff00) == INTVAL (operands[1])
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
-                     (label_ref (match_dup 2))
-                     (pc)))]
-  "")
+       (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
+                     (match_dup 2)
+                     (match_dup 3)))])
 
 ;; Transform
 ;;
        (compare (match_operand:SI 0 "register_operand" "")
                 (match_operand:SI 1 "const_int_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 3 "eqne_operator"
+       (if_then_else (match_operator 4 "eqne_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "peep2_reg_dead_p (1, operands[0])
    && ((INTVAL (operands[1]) | 0x00ff) == -1
        || (INTVAL (operands[1]) | 0xff00) == -1)
    && INTVAL (operands[1]) != -2"
   [(set (match_dup 0)
        (xor:SI (match_dup 0)
-               (match_dup 4)))
+               (match_dup 5)))
    (set (match_dup 0)
        (not:SI (match_dup 0)))
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
-                     (label_ref (match_dup 2))
-                     (pc)))]
+       (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[4] = GEN_INT (INTVAL (operands[1]) ^ -1);
+    operands[5] = GEN_INT (INTVAL (operands[1]) ^ -1);
   })
 
 ;; Transform
        (compare (match_operand:SI 0 "register_operand" "")
                 (match_operand:SI 1 "const_int_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 3 "eqne_operator"
+       (if_then_else (match_operator 4 "eqne_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "peep2_reg_dead_p (1, operands[0])
    && (INTVAL (operands[1]) == -2147483647 - 1
        || (TARGET_H8300S && INTVAL (operands[1]) == 1073741824))"
   [(set (match_dup 0)
        (rotate:SI (match_dup 0)
-                  (match_dup 4)))
+                  (match_dup 5)))
    (set (match_dup 0)
        (unspec:SI [(match_dup 0)
                    (const_int -1)]
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
-                     (label_ref (match_dup 2))
-                     (pc)))]
+       (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[4] = GEN_INT (INTVAL (operands[1]) == -2147483647 - 1 ? 1 : 2);
+    operands[5] = GEN_INT (INTVAL (operands[1]) == -2147483647 - 1 ? 1 : 2);
   })
 
 ;; Transform
 ;; same compare insn immediately before this one.
 
 (define_peephole2
-  [(match_scratch:SI 4 "r")
+  [(match_scratch:SI 5 "r")
    (set (cc0)
        (compare (match_operand:SI 0 "register_operand" "")
                 (match_operand:SI 1 "const_int_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 2 "gtle_operator"
+       (if_then_else (match_operator 4 "gtle_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 3 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "!peep2_reg_dead_p (1, operands[0])
    && (INTVAL (operands[1]) == 1
        || (TARGET_H8300S && INTVAL (operands[1]) == 3))
    && !same_cmp_preceding_p (insn)"
-  [(set (match_dup 4)
+  [(set (match_dup 5)
        (match_dup 0))
-   (parallel [(set (match_dup 4)
-                  (ashiftrt:SI (match_dup 4)
-                               (match_dup 5)))
+   (parallel [(set (match_dup 5)
+                  (ashiftrt:SI (match_dup 5)
+                               (match_dup 6)))
              (clobber (scratch:QI))])
-   (set (cc0) (compare (match_dup 4)
+   (set (cc0) (compare (match_dup 5)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_dup 2)
-                     (label_ref (match_dup 3))
-                     (pc)))]
+       (if_then_else (match_dup 4)
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
+    operands[6] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
   })
 
 ;; Transform
 ;; same compare insn immediately before this one.
 
 (define_peephole2
-  [(match_scratch:SI 4 "r")
+  [(match_scratch:SI 5 "r")
    (set (cc0)
        (compare (match_operand:SI 0 "register_operand" "")
                 (match_operand:SI 1 "const_int_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 2 "gtuleu_operator"
+       (if_then_else (match_operator 4 "gtuleu_operator"
                         [(cc0) (const_int 0)])
-                     (label_ref (match_operand 3 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "!peep2_reg_dead_p (1, operands[0])
    && (INTVAL (operands[1]) == 1
        || (TARGET_H8300S && INTVAL (operands[1]) == 3))
    && !same_cmp_preceding_p (insn)"
-  [(set (match_dup 4)
+  [(set (match_dup 5)
        (match_dup 0))
-   (parallel [(set (match_dup 4)
-                  (ashiftrt:SI (match_dup 4)
-                               (match_dup 5)))
+   (parallel [(set (match_dup 5)
+                  (ashiftrt:SI (match_dup 5)
+                               (match_dup 6)))
              (clobber (scratch:QI))])
-   (set (cc0) (compare (match_dup 4)
+   (set (cc0) (compare (match_dup 5)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_dup 6)
-                     (label_ref (match_dup 3))
-                     (pc)))]
+       (if_then_else (match_dup 7)
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
-    operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
+    operands[6] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
+    operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[4]) == GTU ? NE : EQ,
                                  VOIDmode, cc0_rtx, const0_rtx);
   })
 
        (compare (match_operand:SI 0 "register_operand" "")
                 (match_operand:SI 1 "const_int_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 2 "gtle_operator"
+       (if_then_else (match_operator 4 "gtle_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 3 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "peep2_reg_dead_p (1, operands[0])
    && (INTVAL (operands[1]) == 1
        || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
   [(parallel [(set (match_dup 0)
                   (ashiftrt:SI (match_dup 0)
-                               (match_dup 4)))
+                               (match_dup 5)))
              (clobber (scratch:QI))])
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_dup 2)
-                     (label_ref (match_dup 3))
-                     (pc)))]
+       (if_then_else (match_dup 4)
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
+    operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
   })
 
 ;; Transform
        (compare (match_operand:SI 0 "register_operand" "")
                 (match_operand:SI 1 "const_int_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 2 "gtuleu_operator"
+       (if_then_else (match_operator 4 "gtuleu_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 3 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "peep2_reg_dead_p (1, operands[0])
    && (INTVAL (operands[1]) == 1
        || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
   [(parallel [(set (match_dup 0)
                   (ashiftrt:SI (match_dup 0)
-                               (match_dup 4)))
+                               (match_dup 5)))
              (clobber (scratch:QI))])
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_dup 5)
-                     (label_ref (match_dup 3))
-                     (pc)))]
+       (if_then_else (match_dup 6)
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
-    operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
+    operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
+    operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[4]) == GTU ? NE : EQ,
                                  VOIDmode, cc0_rtx, const0_rtx);
   })
 
        (compare (match_operand:SI 0 "register_operand" "")
                 (match_operand:SI 1 "const_int_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 2 "gtle_operator"
+       (if_then_else (match_operator 4 "gtle_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 3 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "peep2_reg_dead_p (1, operands[0])
    && (INTVAL (operands[1]) == 3
        || INTVAL (operands[1]) == 7
        || INTVAL (operands[1]) == 255)"
   [(set (match_dup 0)
        (and:SI (match_dup 0)
-               (match_dup 4)))
+               (match_dup 5)))
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_dup 2)
-                     (label_ref (match_dup 3))
-                     (pc)))]
+       (if_then_else (match_dup 4)
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[4] = GEN_INT (~INTVAL (operands[1]));
+    operands[5] = GEN_INT (~INTVAL (operands[1]));
   })
 
 ;; Transform
        (compare (match_operand:SI 0 "register_operand" "")
                 (match_operand:SI 1 "const_int_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 2 "gtuleu_operator"
+       (if_then_else (match_operator 4 "gtuleu_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 3 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "peep2_reg_dead_p (1, operands[0])
    && ((TARGET_H8300H && INTVAL (operands[1]) == 3)
        || INTVAL (operands[1]) == 7
        || INTVAL (operands[1]) == 255)"
   [(set (match_dup 0)
        (and:SI (match_dup 0)
-               (match_dup 4)))
+               (match_dup 5)))
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_dup 5)
-                     (label_ref (match_dup 3))
-                     (pc)))]
+       (if_then_else (match_dup 6)
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[4] = GEN_INT (~INTVAL (operands[1]));
-    operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
+    operands[5] = GEN_INT (~INTVAL (operands[1]));
+    operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[4]) == GTU ? NE : EQ,
                                  VOIDmode, cc0_rtx, const0_rtx);
   })
 
    (set (pc)
        (if_then_else (match_operator 1 "gtle_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   ""
   [(set (cc0) (compare (and:SI (match_dup 0)
                               (const_int -65536))
                       (const_int 0)))
    (set (pc)
        (if_then_else (match_dup 1)
-                     (label_ref (match_dup 2))
-                     (pc)))]
-  "")
+                     (match_dup 2)
+                     (match_dup 3)))])
 
 ;; Transform
 ;;
    (set (pc)
        (if_then_else (match_operator 1 "gtuleu_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   ""
   [(set (cc0) (compare (and:SI (match_dup 0)
                               (const_int -65536))
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_dup 3)
-                     (label_ref (match_dup 2))
-                     (pc)))]
+       (if_then_else (match_dup 4)
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
+    operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
                                  VOIDmode, cc0_rtx, const0_rtx);
   })
 
 ;; same compare insn.
 
 (define_peephole2
-  [(match_scratch:SI 4 "r")
+  [(match_scratch:SI 5 "r")
    (set (cc0)
        (compare (match_operand:SI 0 "register_operand" "")
                 (match_operand:SI 1 "incdec_operand" "")))
    (set (pc)
-       (if_then_else (match_operator 3 "eqne_operator"
+       (if_then_else (match_operator 4 "eqne_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "INTVAL (operands[1]) != 0
    && !peep2_reg_dead_p (1, operands[0])
    && !same_cmp_following_p (insn)"
-  [(set (match_dup 4)
+  [(set (match_dup 5)
        (match_dup 0))
-   (set (match_dup 4)
-       (unspec:SI [(match_dup 4)
-                   (match_dup 5)]
+   (set (match_dup 5)
+       (unspec:SI [(match_dup 5)
+                   (match_dup 6)]
                   UNSPEC_INCDEC))
-   (set (cc0) (compare (match_dup 4)
+   (set (cc0) (compare (match_dup 5)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
-                     (label_ref (match_dup 2))
-                     (pc)))]
+       (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
-    operands[5] = GEN_INT (- INTVAL (operands[1]));
+    operands[6] = GEN_INT (- INTVAL (operands[1]));
   })
 
 ;; Narrow the mode of testing if possible.
    (set (cc0) (compare (match_dup 0)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_operator 3 "eqne_operator"
+       (if_then_else (match_operator 4 "eqne_operator"
                       [(cc0) (const_int 0)])
-                     (label_ref (match_operand 2 "" ""))
-                     (pc)))]
+                     (match_operand 2 "pc_or_label_operand" "")
+                     (match_operand 3 "pc_or_label_operand" "")))]
   "((const_int_qi_operand (operands[1], QImode)
      || (GET_MODE (operands[0]) == SImode
         && const_int_hi_operand (operands[1], HImode)))
     && peep2_reg_dead_p (2, operands[0]))"
-  [(set (match_dup 4) (match_dup 6))
-   (set (cc0) (compare (match_dup 4)
+  [(set (match_dup 5) (match_dup 7))
+   (set (cc0) (compare (match_dup 5)
                       (const_int 0)))
    (set (pc)
-       (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
-                     (label_ref (match_dup 2))
-                     (pc)))]
+       (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
+                     (match_dup 2)
+                     (match_dup 3)))]
   {
     enum machine_mode mode;
 
     mode = const_int_qi_operand (operands[1], QImode) ? QImode : HImode;
-    operands[4] = gen_rtx_REG (mode, REGNO (operands[0]));
-    operands[5] = gen_int_mode (INTVAL (operands[1]), mode);
-    operands[6] = gen_rtx_AND (mode, operands[4], operands[5]);
+    operands[5] = gen_rtx_REG (mode, REGNO (operands[0]));
+    operands[6] = gen_int_mode (INTVAL (operands[1]), mode);
+    operands[7] = gen_rtx_AND (mode, operands[5], operands[6]);
   })
 
 ;; These triggers right at the end of allocation of locals in the
index 6496992dbe8bd190587bd9da54cce7765a9b7725..b530c2cb23ebc297bb64ed3314b15ed1d38a39dc 100644 (file)
 
   return (code == IOR || code == XOR);
 })
+
+;; Used to detect valid targets for conditional branches
+;; Used to detect (pc) or (label_ref) in some jumping patterns
+(define_predicate "pc_or_label_operand"
+  (match_code "pc,label_ref"))
+