This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Blackfin patch: Tighter predicates
- From: Bernd Schmidt <bernds_cb1 at t-online dot de>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 11 Jul 2005 18:16:19 +0200
- Subject: Blackfin patch: Tighter predicates
This disallows non-CONST_INT constants (i.e. SYMBOL_REFs) in
comparisons. Slightly improves code on one testcase I looked at.
Bernd
* config/bfin/bfin.md (cmpsi, compare_eq, compare_ne, compare_lt,
compare_le, compare_leu, compare_ltu): Use reg_or_const_int_operand
for second comparison operand.
* config/bfin/predicates.md (reg_or_const_int_operand): New.
Index: config/bfin/bfin.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/bfin/bfin.md,v
retrieving revision 1.9
diff -c -p -r1.9 bfin.md
*** config/bfin/bfin.md 11 Jul 2005 16:11:28 -0000 1.9
--- config/bfin/bfin.md 11 Jul 2005 16:14:00 -0000
***************
*** 1451,1457 ****
(define_expand "cmpsi"
[(set (cc0) (compare (match_operand:SI 0 "register_operand" "")
! (match_operand:SI 1 "nonmemory_operand" "")))]
""
{
bfin_compare_op0 = operands[0];
--- 1451,1457 ----
(define_expand "cmpsi"
[(set (cc0) (compare (match_operand:SI 0 "register_operand" "")
! (match_operand:SI 1 "reg_or_const_int_operand" "")))]
""
{
bfin_compare_op0 = operands[0];
***************
*** 1462,1468 ****
(define_insn "compare_eq"
[(set (match_operand:BI 0 "cc_operand" "=C,C")
(eq:BI (match_operand:SI 1 "register_operand" "d,a")
! (match_operand:SI 2 "nonmemory_operand" "dKs3,aKs3")))]
""
"cc =%1==%2;"
[(set_attr "type" "compare")])
--- 1462,1468 ----
(define_insn "compare_eq"
[(set (match_operand:BI 0 "cc_operand" "=C,C")
(eq:BI (match_operand:SI 1 "register_operand" "d,a")
! (match_operand:SI 2 "reg_or_const_int_operand" "dKs3,aKs3")))]
""
"cc =%1==%2;"
[(set_attr "type" "compare")])
***************
*** 1470,1476 ****
(define_insn "compare_ne"
[(set (match_operand:BI 0 "cc_operand" "=C,C")
(ne:BI (match_operand:SI 1 "register_operand" "d,a")
! (match_operand:SI 2 "nonmemory_operand" "dKs3,aKs3")))]
"0"
"cc =%1!=%2;"
[(set_attr "type" "compare")])
--- 1470,1476 ----
(define_insn "compare_ne"
[(set (match_operand:BI 0 "cc_operand" "=C,C")
(ne:BI (match_operand:SI 1 "register_operand" "d,a")
! (match_operand:SI 2 "reg_or_const_int_operand" "dKs3,aKs3")))]
"0"
"cc =%1!=%2;"
[(set_attr "type" "compare")])
***************
*** 1478,1484 ****
(define_insn "compare_lt"
[(set (match_operand:BI 0 "cc_operand" "=C,C")
(lt:BI (match_operand:SI 1 "register_operand" "d,a")
! (match_operand:SI 2 "nonmemory_operand" "dKs3,aKs3")))]
""
"cc =%1<%2;"
[(set_attr "type" "compare")])
--- 1478,1484 ----
(define_insn "compare_lt"
[(set (match_operand:BI 0 "cc_operand" "=C,C")
(lt:BI (match_operand:SI 1 "register_operand" "d,a")
! (match_operand:SI 2 "reg_or_const_int_operand" "dKs3,aKs3")))]
""
"cc =%1<%2;"
[(set_attr "type" "compare")])
***************
*** 1486,1492 ****
(define_insn "compare_le"
[(set (match_operand:BI 0 "cc_operand" "=C,C")
(le:BI (match_operand:SI 1 "register_operand" "d,a")
! (match_operand:SI 2 "nonmemory_operand" "dKs3,aKs3")))]
""
"cc =%1<=%2;"
[(set_attr "type" "compare")])
--- 1486,1492 ----
(define_insn "compare_le"
[(set (match_operand:BI 0 "cc_operand" "=C,C")
(le:BI (match_operand:SI 1 "register_operand" "d,a")
! (match_operand:SI 2 "reg_or_const_int_operand" "dKs3,aKs3")))]
""
"cc =%1<=%2;"
[(set_attr "type" "compare")])
***************
*** 1494,1500 ****
(define_insn "compare_leu"
[(set (match_operand:BI 0 "cc_operand" "=C,C")
(leu:BI (match_operand:SI 1 "register_operand" "d,a")
! (match_operand:SI 2 "nonmemory_operand" "dKu3,aKu3")))]
""
"cc =%1<=%2 (iu);"
[(set_attr "type" "compare")])
--- 1494,1500 ----
(define_insn "compare_leu"
[(set (match_operand:BI 0 "cc_operand" "=C,C")
(leu:BI (match_operand:SI 1 "register_operand" "d,a")
! (match_operand:SI 2 "reg_or_const_int_operand" "dKu3,aKu3")))]
""
"cc =%1<=%2 (iu);"
[(set_attr "type" "compare")])
***************
*** 1502,1508 ****
(define_insn "compare_ltu"
[(set (match_operand:BI 0 "cc_operand" "=C,C")
(ltu:BI (match_operand:SI 1 "register_operand" "d,a")
! (match_operand:SI 2 "nonmemory_operand" "dKu3,aKu3")))]
""
"cc =%1<%2 (iu);"
[(set_attr "type" "compare")])
--- 1502,1508 ----
(define_insn "compare_ltu"
[(set (match_operand:BI 0 "cc_operand" "=C,C")
(ltu:BI (match_operand:SI 1 "register_operand" "d,a")
! (match_operand:SI 2 "reg_or_const_int_operand" "dKu3,aKu3")))]
""
"cc =%1<%2 (iu);"
[(set_attr "type" "compare")])
Index: config/bfin/predicates.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/bfin/predicates.md,v
retrieving revision 1.3
diff -c -p -r1.3 predicates.md
*** config/bfin/predicates.md 25 Jun 2005 01:20:59 -0000 1.3
--- config/bfin/predicates.md 11 Jul 2005 16:14:00 -0000
***************
*** 49,54 ****
--- 49,59 ----
(and (match_code "const_int")
(match_test "log2constp (INTVAL (op))"))))
+ ;; Return nonzero if OP is a register or an integer constant.
+ (define_predicate "reg_or_const_int_operand"
+ (ior (match_operand 0 "register_operand")
+ (match_code "const_int")))
+
;; Like register_operand, but make sure that hard regs have a valid mode.
(define_predicate "valid_reg_operand"
(match_operand 0 "register_operand")