From 67595cbb21ce2cd419dcc390e811e4cdb2ef25af Mon Sep 17 00:00:00 2001 From: Roman Zippel Date: Mon, 24 Sep 2007 21:00:22 +0000 Subject: [PATCH] m68k.c (notice_update_cc): Recognize fp compare (moved from fp compare patterns). * config/m68k/m68k.c (notice_update_cc): Recognize fp compare (moved from fp compare patterns). * config/m68k/m68k.md (cmp, cmp_68881, cmp_cf): Cleanup predicates to relieve reload. (conditional_trap): Reject conditional trap with fp condition. * gcc/config/m68k/predicates.md (fp_src_operand): New, reject certain constants early. From-SVN: r128727 --- gcc/ChangeLog | 10 +++++ gcc/config/m68k/m68k.c | 7 ++++ gcc/config/m68k/m68k.md | 77 +++++++++++++++++------------------ gcc/config/m68k/predicates.md | 13 ++++++ 4 files changed, 67 insertions(+), 40 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 72834124268..c092fec34fe 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2007-09-24 Roman Zippel + + * config/m68k/m68k.c (notice_update_cc): Recognize fp compare + (moved from fp compare patterns). + * config/m68k/m68k.md (cmp, cmp_68881, cmp_cf): + Cleanup predicates to relieve reload. + (conditional_trap): Reject conditional trap with fp condition. + * gcc/config/m68k/predicates.md (fp_src_operand): New, reject + certain constants early. + 2007-09-24 Roman Zippel * gcc/final.c (final_scan_insn): Remove accidentally duplicated code. diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c index c8e5a6f4a05..1f6b4f9fde7 100644 --- a/gcc/config/m68k/m68k.c +++ b/gcc/config/m68k/m68k.c @@ -3513,6 +3513,13 @@ notice_update_cc (rtx exp, rtx insn) if (((cc_status.value1 && FP_REG_P (cc_status.value1)) || (cc_status.value2 && FP_REG_P (cc_status.value2)))) cc_status.flags = CC_IN_68881; + if (cc_status.value2 && GET_CODE (cc_status.value2) == COMPARE + && GET_MODE_CLASS (GET_MODE (XEXP (cc_status.value2, 0))) == MODE_FLOAT) + { + cc_status.flags = CC_IN_68881; + if (!FP_REG_P (XEXP (cc_status.value2, 0))) + cc_status.flags |= CC_REVERSED; + } } const char * diff --git a/gcc/config/m68k/m68k.md b/gcc/config/m68k/m68k.md index b3f12d8b616..b6ce6a8df0e 100644 --- a/gcc/config/m68k/m68k.md +++ b/gcc/config/m68k/m68k.md @@ -632,51 +632,35 @@ (define_expand "cmp" [(set (cc0) - (compare (match_operand:FP 0 "general_operand" "") - (match_operand:FP 1 "general_operand" "")))] + (compare (match_operand:FP 0 "register_operand" "") + (match_operand:FP 1 "fp_src_operand" "")))] "TARGET_HARD_FLOAT" -{ - m68k_last_compare_had_fp_operands = 1; - if (TARGET_COLDFIRE && !reload_completed) - operands[1] = force_reg (mode, operands[1]); -}) + "m68k_last_compare_had_fp_operands = 1;") -(define_insn "cmp_68881" +(define_insn "*cmp_68881" [(set (cc0) - (compare (match_operand:FP 0 "general_operand" "f,m") - (match_operand:FP 1 "general_operand" "fm,f")))] - "TARGET_68881" -{ - cc_status.flags = CC_IN_68881; - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "fcmp%.x %1,%0"; - else - return "fcmp%. %f1,%0"; - } - cc_status.flags |= CC_REVERSED; /*|*/ - return "fcmp%. %f0,%1"; -} + (compare (match_operand:FP 0 "fp_src_operand" "f,f,mF") + (match_operand:FP 1 "fp_src_operand" "f,mF,f")))] + "TARGET_68881 + && (register_operand (operands[0], mode) + || register_operand (operands[1], mode))" + "@ + fcmp%.x %1,%0 + fcmp%. %f1,%0 + fcmp%. %0,%f1" [(set_attr "type" "fcmp")]) -(define_insn "cmp_cf" +(define_insn "*cmp_cf" [(set (cc0) - (compare (match_operand:FP 0 "general_operand" "f,U") - (match_operand:FP 1 "general_operand" "fU,f")))] - "TARGET_COLDFIRE_FPU" -{ - cc_status.flags = CC_IN_68881; - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "fcmp%.d %1,%0"; - else - return "fcmp%. %f1,%0"; - } - cc_status.flags |= CC_REVERSED; /*|*/ - return "fcmp%. %f0,%1"; -} + (compare (match_operand:FP 0 "fp_src_operand" "f,f,U") + (match_operand:FP 1 "fp_src_operand" "f,U,f")))] + "TARGET_COLDFIRE_FPU + && (register_operand (operands[0], mode) + || register_operand (operands[1], mode))" + "@ + fcmp%.d %1,%0 + fcmp%. %f1,%0 + fcmp%. %0,%f1" [(set_attr "type" "fcmp")]) ;; Recognizers for btst instructions. @@ -7683,7 +7667,20 @@ "trap #7" [(set_attr "type" "trap")]) -(define_insn "conditional_trap" +(define_expand "conditional_trap" + [(trap_if (match_operator 0 "valid_dbcc_comparison_p" + [(cc0) (const_int 0)]) + (match_operand:SI 1 "const_int_operand" "I"))] + "TARGET_68020" +{ + if (m68k_last_compare_had_fp_operands) + { + m68k_last_compare_had_fp_operands = 0; + FAIL; + } +}) + +(define_insn "*conditional_trap" [(trap_if (match_operator 0 "valid_dbcc_comparison_p" [(cc0) (const_int 0)]) (match_operand:SI 1 "const_int_operand" "I"))] diff --git a/gcc/config/m68k/predicates.md b/gcc/config/m68k/predicates.md index bf968635c25..b43e55b8972 100644 --- a/gcc/config/m68k/predicates.md +++ b/gcc/config/m68k/predicates.md @@ -206,3 +206,16 @@ (ior (and (match_code "const_int") (match_test "!symbolic_operand (op, mode)")) (match_test "!symbolic_operand (op,mode)")))) + +;; Special case of general_src_operand, which rejects a few fp +;; constants (which we prefer in registers) before reload. + +(define_predicate "fp_src_operand" + (match_operand 0 "general_src_operand") +{ + return !CONSTANT_P (op) + || (TARGET_68881 + && (!standard_68881_constant_p (op) + || reload_in_progress + || reload_completed)); +}) -- 2.30.2