[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#401585: [m68k] ICE: in reload, at reload1.c:1079



Hi,

On Sat, 9 Dec 2006, Matthias Klose wrote:

> Roman, do you intend to provide a fix for gcc-4.1?

Attached, it's an update to the m68k-fpcompare patch.
For the log: Allow any fp constant as any immediate operand during and 
after reload, even for special constants in case reload can't find a free 
register.

bye, Roman
#! /bin/sh -e

# All lines beginning with `# DPATCH:' are a description of the patch.
# DP: bring fp compare early to its desired form to relieve reload,
# DP: allow any fp constant during and after reload (even special constants)
# DP: in case reload can't find a free register for them.

dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
    pdir="-d $3"
    dir="$3/"
elif [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch)
        patch $pdir -f --no-backup-if-mismatch -p1 < $0
        #cd ${dir}gcc && autoconf
        ;;
    -unpatch)
        patch $pdir -f --no-backup-if-mismatch -R -p1 < $0
        #rm ${dir}gcc/configure
        ;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1
esac
exit 0

---

 gcc/config/m68k/m68k.c        |    3 +
 gcc/config/m68k/m68k.md       |   86 ++++++------------------------------------
 gcc/config/m68k/predicates.md |    7 +++
 3 files changed, 24 insertions(+), 72 deletions(-)

Index: gcc-4.1/gcc/config/m68k/m68k.c
===================================================================
--- gcc-4.1.orig/gcc/config/m68k/m68k.c
+++ gcc-4.1/gcc/config/m68k/m68k.c
@@ -2467,6 +2467,9 @@ 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;
 }
 
 const char *
Index: gcc-4.1/gcc/config/m68k/m68k.md
===================================================================
--- gcc-4.1.orig/gcc/config/m68k/m68k.md
+++ gcc-4.1/gcc/config/m68k/m68k.md
@@ -408,59 +408,26 @@
   return "cmp%.b %d1,%d0";
 })
 
-(define_expand "cmpdf"
-  [(set (cc0)
-	(compare (match_operand:DF 0 "general_operand" "")
-		 (match_operand:DF 1 "general_operand" "")))]
-  "TARGET_68881"
-{
-  m68k_last_compare_had_fp_operands = 1;
-})
+(define_mode_macro F [XF DF SF])
+(define_mode_attr F_fmt [(XF "%.x") (DF "%.d") (SF "%.s")])
+(define_mode_attr F_c [(XF "mF") (DF "mF") (SF "mdF")])
 
-(define_insn ""
+(define_expand "cmp<mode>"
   [(set (cc0)
-	(compare (match_operand:DF 0 "general_operand" "f,mG")
-		 (match_operand:DF 1 "general_operand" "fmG,f")))]
+	(compare (match_operand:F 0 "register_operand" "")
+		 (match_operand:F 1 "fp_src_operand" "")))]
   "TARGET_68881"
-{
-  cc_status.flags = CC_IN_68881;
-  if (REG_P (operands[0]))
-    {
-      if (REG_P (operands[1]))
-	return "fcmp%.x %1,%0";
-      else
-        return "fcmp%.d %f1,%0";
-    }
-  cc_status.flags |= CC_REVERSED;
-  return "fcmp%.d %f0,%1";
-})
-
-(define_expand "cmpsf"
- [(set (cc0)
-       (compare (match_operand:SF 0 "general_operand" "")
-		(match_operand:SF 1 "general_operand" "")))]
- "TARGET_68881"
-{
-  m68k_last_compare_had_fp_operands = 1;
-})
+  "m68k_last_compare_had_fp_operands = 1;")
 
-(define_insn ""
+(define_insn "*cmp<mode>"
   [(set (cc0)
-	(compare (match_operand:SF 0 "general_operand" "f,mdG")
-		 (match_operand:SF 1 "general_operand" "fmdG,f")))]
+	(compare (match_operand:F 0 "register_operand" "f,f")
+		 (match_operand:F 1 "fp_src_operand" "f,<F_c>")))]
   "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%.s %f1,%0";
-    }
-  cc_status.flags |= CC_REVERSED;
-  return "fcmp%.s %f0,%1";
-})
+  "@
+   fcmp%.x %1,%0
+   fcmp<F_fmt> %f1,%0")
+
 
 ;; Recognizers for btst instructions.
 
@@ -6819,31 +6786,6 @@
   return "ftst%.x %0";
 })
 
-(define_expand "cmpxf"
-  [(set (cc0)
-	(compare (match_operand:XF 0 "nonimmediate_operand" "")
-		 (match_operand:XF 1 "nonimmediate_operand" "")))]
-  "TARGET_68881"
-  "m68k_last_compare_had_fp_operands = 1;")
-
-(define_insn ""
-  [(set (cc0)
-	(compare (match_operand:XF 0 "nonimmediate_operand" "f,m")
-		 (match_operand:XF 1 "nonimmediate_operand" "fm,f")))]
-  "TARGET_68881"
-{
-  cc_status.flags = CC_IN_68881;
-  if (REG_P (operands[0]))
-    {
-      if (REG_P (operands[1]))
-	return "fcmp%.x %1,%0";
-      else
-        return "fcmp%.x %f1,%0";
-    }
-  cc_status.flags |= CC_REVERSED;
-  return "fcmp%.x %f0,%1";
-})
-
 (define_insn "extendsfxf2"
   [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
 	(float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
Index: gcc-4.1/gcc/config/m68k/predicates.md
===================================================================
--- gcc-4.1.orig/gcc/config/m68k/predicates.md
+++ gcc-4.1/gcc/config/m68k/predicates.md
@@ -194,3 +194,10 @@
 {
   return MEM_P (op) && GET_CODE (XEXP (op, 0)) == PRE_DEC;
 })
+
+(define_predicate "fp_src_operand"
+  (match_operand 0 "general_src_operand")
+{
+  return !CONSTANT_P (op) || !standard_68881_constant_p (op)
+	 || reload_completed || reload_in_progress;
+})

Reply to: