]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Reinstate branch-on-bit insns for H8
authorJeff Law <jeffreyalaw@gmail.com>
Thu, 29 Jul 2021 18:32:59 +0000 (14:32 -0400)
committerJeff Law <jeffreyalaw@gmail.com>
Thu, 29 Jul 2021 18:57:53 +0000 (14:57 -0400)
gcc/
* config/h8300/h8300-modes.def: Add CCZ, CCV and CCC, drop CCZNV.
* config/h8300/h8300.md (H8cc mode iterator): Add CCZ.
(cc mode_attr): Similarly.
(ccz subst_attr): Similarly.
* config/h8300/jumpcall.md: Add new patterns for branch-on-bit.
* config/h8300/testcompare.md: Remove various cc0 based patterns
that had been commented out.  Add pattern to set CCZ from a bit
test.

gcc/config/h8300/h8300-modes.def
gcc/config/h8300/h8300.md
gcc/config/h8300/jumpcall.md
gcc/config/h8300/testcompare.md

index 23b777b296651a04d38191bed0f1a91aa68f921c..6ab52606a9a301c552d357e891e9f0d72b985827 100644 (file)
@@ -18,4 +18,6 @@
    <http://www.gnu.org/licenses/>.  */
 
 CC_MODE (CCZN);
-CC_MODE (CCZNV);
+CC_MODE (CCZ);
+CC_MODE (CCV);
+CC_MODE (CCC);
index e596987a6a613a03d10a2feea1f25706d99cb9fd..7f49e4284f26cc6aa8bf88b8a5a8b189fd260d7b 100644 (file)
 
 ;; The modes we're supporting.  This is used when we want to generate
 ;; multiple patterns where only the mode differs from a single template
-(define_mode_iterator H8cc [CC CCZN])
+(define_mode_iterator H8cc [CC CCZN CCZ])
 
 ;; This is used to generate multiple define_substs from a single
 ;; template for the different variants we might have.
-(define_mode_attr cc [(CC "cc") (CCZN "cczn")])
+(define_mode_attr cc [(CC "cc") (CCZN "cczn") (CCZ "ccz")])
 
 ;; The primary substitution pattern.  <cc> is used to create multiple
 ;; substitutions based on the CC bits that are set.
 ;; apply the subst_cczn or subset_cc define_subst to generate a
 ;; new pattern that compare-elim can use
 (define_subst_attr "cczn" "subst_cczn" "" "_cczn")
+(define_subst_attr "ccz" "subst_ccz" "" "_ccz")
 (define_subst_attr "cc" "subst_cc" "" "_cc")
 
 ;; Type of delay slot.  NONE means the instruction has no delay slot.
index e1f04183564b74d3e0b664882c12b255bbabb4e1..3e59fee58bdfb0c50297808f1e3ee338ee348070 100644 (file)
   [(set_attr "type" "bitbranch")
    (set_attr "length_table" "bitbranch")])
 
+(define_insn_and_split ""
+  [(set (pc)
+       (if_then_else (match_operator 3 "eqne_operator"
+                       [(zero_extract:QHSI (match_operand:QHSI 1 "register_operand" "r")
+                                           (const_int 1)
+                                           (match_operand 2 "const_int_operand" "n"))
+                        (const_int 0)])
+                     (label_ref (match_operand 0 "" ""))
+                     (pc)))]
+  "INTVAL (operands[2]) < 16"
+  "#"
+  "&& reload_completed"
+  [(set (reg:CCZ CC_REG)
+       (eq (zero_extract:QHSI (match_dup 1) (const_int 1) (match_dup 2))
+           (const_int 0)))
+   (set (pc)
+       (if_then_else (match_op_dup 3 [(reg:CCZ CC_REG) (const_int 0)])
+                     (label_ref (match_dup 0))
+                     (pc)))])
+
+(define_insn_and_split ""
+  [(set (pc)
+       (if_then_else (match_operator 3 "eqne_operator"
+                       [(zero_extract:SI (match_operand:SI 1 "register_operand" "r")
+                                         (const_int 1)
+                                         (match_operand 2 "const_int_operand" "n"))
+                        (const_int 0)])
+                     (label_ref (match_operand 0 "" ""))
+                     (pc)))
+   (clobber (match_scratch:SI 4 "=&r"))]
+  "INTVAL (operands[2]) >= 16"
+  "#"
+  "&& reload_completed"
+  [(parallel [(set (match_dup 4)
+                  (ior:SI (and:SI (match_dup 4) (const_int -65536))
+                          (lshiftrt:SI (match_dup 1) (const_int 16))))
+             (clobber (reg:CC CC_REG))])
+   (set (reg:CCZ CC_REG)
+       (eq (zero_extract:SI (match_dup 4) (const_int 1) (match_dup 2))
+           (const_int 0)))
+   (set (pc)
+       (if_then_else (match_op_dup 3 [(reg:CCZ CC_REG) (const_int 0)])
+                     (label_ref (match_dup 0))
+                     (pc)))]
+  "operands[2] = GEN_INT (INTVAL (operands[2]) - 16);")
+
 ;; Unconditional and other jump instructions.
 
 (define_insn "jump"
index e9f6ddcf075f32e8e0106b23a509084a047388e5..29190532e493fbb4092b7ff402a3a67801a2cbbe 100644 (file)
 ;;  ""
 ;;  [(set_attr "length" "2,8,10")])
 ;;
-;;(define_insn ""
-;;  [(set (cc0)
-;;     (compare (zero_extract:HSI (match_operand:HSI 0 "register_operand" "r")
-;;                                (const_int 1)
-;;                                (match_operand 1 "const_int_operand" "n"))
-;;              (const_int 0)))]
-;;  "INTVAL (operands[1]) <= 15"
-;;  "btst      %Z1,%Y0"
-;;  [(set_attr "length" "2")])
-;;
-;;(define_insn_and_split "*tstsi_upper_bit"
-;;  [(set (cc0)
-;;     (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
-;;                               (const_int 1)
-;;                               (match_operand 1 "const_int_operand" "n"))
-;;              (const_int 0)))
-;;   (clobber (match_scratch:SI 2 "=&r"))]
-;;  "INTVAL (operands[1]) >= 16"
-;;  "#"
-;;  "&& reload_completed"
-;;  [(set (match_dup 2)
-;;     (ior:SI (and:SI (match_dup 2)
-;;                     (const_int -65536))
-;;             (lshiftrt:SI (match_dup 0)
-;;                          (const_int 16))))
-;;   (set (cc0)
-;;     (compare (zero_extract:SI (match_dup 2)
-;;                               (const_int 1)
-;;                               (match_dup 3))
-;;              (const_int 0)))]
-;;  {
-;;    operands[3] = GEN_INT (INTVAL (operands[1]) - 16);
-;;  })
-;;
-;;(define_insn "*tstsi_variable_bit"
-;;  [(set (cc0)
-;;     (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
-;;                               (const_int 1)
-;;                               (and:SI (match_operand:SI 1 "register_operand" "r")
-;;                                       (const_int 7)))
-;;              (const_int 0)))]
-;;  ""
-;;  "btst      %w1,%w0"
-;;  [(set_attr "length" "2")])
-;;
-;;(define_insn_and_split "*tstsi_variable_bit_qi"
-;;  [(set (cc0)
-;;     (compare (zero_extract:SI (zero_extend:SI (match_operand:QI 0 "general_operand_src" "r,U,mn>"))
-;;                               (const_int 1)
-;;                               (and:SI (match_operand:SI 1 "register_operand" "r,r,r")
-;;                                       (const_int 7)))
-;;              (const_int 0)))
-;;   (clobber (match_scratch:QI 2 "=X,X,&r"))]
-;;  "!CONSTANT_P (operands[0])"
-;;  "@
-;;   btst\\t%w1,%X0
-;;   btst\\t%w1,%X0
-;;   #"
-;;  "&& reload_completed
-;;   && !satisfies_constraint_U (operands[0])"
-;;  [(set (match_dup 2)
-;;     (match_dup 0))
-;;   (parallel [(set (cc0)
-;;                (compare (zero_extract:SI (zero_extend:SI (match_dup 2))
-;;                                          (const_int 1)
-;;                                          (and:SI (match_dup 1)
-;;                                                  (const_int 7)))
-;;                         (const_int 0)))
-;;           (clobber (scratch:QI))])]
-;;  ""
-;;  [(set_attr "length" "2,8,10")])
+(define_insn ""
+  [(set (reg:CCZ CC_REG)
+       (eq (zero_extract:HSI (match_operand:HSI 0 "register_operand" "r")
+                             (const_int 1)
+                             (match_operand 1 "const_int_operand" "n"))
+           (const_int 0)))]
+  "INTVAL (operands[1]) < 16"
+  "btst        %Z1,%Y0"
+  [(set_attr "length" "2")])
 
 (define_insn "*tst<mode>"
   [(set (reg:CCZN CC_REG)