From d04fb4943f642bea677ca38df5f906bde41a199a Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Tue, 30 Jun 2020 16:35:55 -0400 Subject: [PATCH] add patch fixing broken m68k sqrt gcc pr 95921. the m68k sqrt rtl handles excess precision wrong. I couldn't figure out how to make gcc generate the insn only for long double, but since long double usage is rare anyway, just remove it. this can be replaced with a proper fix later if there's ever one upstream. --- patches/gcc-5.3.0/0019-m68k-sqrt.diff | 38 +++++++++++++++++++++++++++ patches/gcc-6.5.0/0024-m68k-sqrt.diff | 38 +++++++++++++++++++++++++++ patches/gcc-7.3.0/0021-m68k-sqrt.diff | 38 +++++++++++++++++++++++++++ patches/gcc-8.3.0/0018-m68k-sqrt.diff | 38 +++++++++++++++++++++++++++ patches/gcc-9.2.0/0018-m68k-sqrt.diff | 38 +++++++++++++++++++++++++++ 5 files changed, 190 insertions(+) create mode 100644 patches/gcc-5.3.0/0019-m68k-sqrt.diff create mode 100644 patches/gcc-6.5.0/0024-m68k-sqrt.diff create mode 100644 patches/gcc-7.3.0/0021-m68k-sqrt.diff create mode 100644 patches/gcc-8.3.0/0018-m68k-sqrt.diff create mode 100644 patches/gcc-9.2.0/0018-m68k-sqrt.diff diff --git a/patches/gcc-5.3.0/0019-m68k-sqrt.diff b/patches/gcc-5.3.0/0019-m68k-sqrt.diff new file mode 100644 index 0000000..3315939 --- /dev/null +++ b/patches/gcc-5.3.0/0019-m68k-sqrt.diff @@ -0,0 +1,38 @@ +--- gcc-9.2.0.orig/gcc/config/m68k/m68k.md 2019-01-01 07:31:55.000000000 -0500 ++++ gcc-9.2.0/gcc/config/m68k/m68k.md 2020-06-30 15:56:20.061868526 -0400 +@@ -4121,35 +4121,6 @@ + return "fneg%. %1,%0"; + }) + +-;; Sqrt instruction for the 68881 +- +-(define_expand "sqrt2" +- [(set (match_operand:FP 0 "nonimmediate_operand" "") +- (sqrt:FP (match_operand:FP 1 "general_operand" "")))] +- "TARGET_HARD_FLOAT" +- "") +- +-(define_insn "sqrt2_68881" +- [(set (match_operand:FP 0 "nonimmediate_operand" "=f") +- (sqrt:FP (match_operand:FP 1 "general_operand" "fm")))] +- "TARGET_68881" +-{ +- if (FP_REG_P (operands[1])) +- return "fsqrt%.x %1,%0"; +- return "fsqrt%. %1,%0"; +-} +- [(set_attr "type" "fsqrt")]) +- +-(define_insn "sqrt2_cf" +- [(set (match_operand:FP 0 "nonimmediate_operand" "=f") +- (sqrt:FP (match_operand:FP 1 "general_operand" "fU")))] +- "TARGET_COLDFIRE_FPU" +-{ +- if (FP_REG_P (operands[1])) +- return "fsqrt%.d %1,%0"; +- return "fsqrt%. %1,%0"; +-} +- [(set_attr "type" "fsqrt")]) + ;; Absolute value instructions + ;; If using software floating point, just zero the sign bit. + diff --git a/patches/gcc-6.5.0/0024-m68k-sqrt.diff b/patches/gcc-6.5.0/0024-m68k-sqrt.diff new file mode 100644 index 0000000..3315939 --- /dev/null +++ b/patches/gcc-6.5.0/0024-m68k-sqrt.diff @@ -0,0 +1,38 @@ +--- gcc-9.2.0.orig/gcc/config/m68k/m68k.md 2019-01-01 07:31:55.000000000 -0500 ++++ gcc-9.2.0/gcc/config/m68k/m68k.md 2020-06-30 15:56:20.061868526 -0400 +@@ -4121,35 +4121,6 @@ + return "fneg%. %1,%0"; + }) + +-;; Sqrt instruction for the 68881 +- +-(define_expand "sqrt2" +- [(set (match_operand:FP 0 "nonimmediate_operand" "") +- (sqrt:FP (match_operand:FP 1 "general_operand" "")))] +- "TARGET_HARD_FLOAT" +- "") +- +-(define_insn "sqrt2_68881" +- [(set (match_operand:FP 0 "nonimmediate_operand" "=f") +- (sqrt:FP (match_operand:FP 1 "general_operand" "fm")))] +- "TARGET_68881" +-{ +- if (FP_REG_P (operands[1])) +- return "fsqrt%.x %1,%0"; +- return "fsqrt%. %1,%0"; +-} +- [(set_attr "type" "fsqrt")]) +- +-(define_insn "sqrt2_cf" +- [(set (match_operand:FP 0 "nonimmediate_operand" "=f") +- (sqrt:FP (match_operand:FP 1 "general_operand" "fU")))] +- "TARGET_COLDFIRE_FPU" +-{ +- if (FP_REG_P (operands[1])) +- return "fsqrt%.d %1,%0"; +- return "fsqrt%. %1,%0"; +-} +- [(set_attr "type" "fsqrt")]) + ;; Absolute value instructions + ;; If using software floating point, just zero the sign bit. + diff --git a/patches/gcc-7.3.0/0021-m68k-sqrt.diff b/patches/gcc-7.3.0/0021-m68k-sqrt.diff new file mode 100644 index 0000000..3315939 --- /dev/null +++ b/patches/gcc-7.3.0/0021-m68k-sqrt.diff @@ -0,0 +1,38 @@ +--- gcc-9.2.0.orig/gcc/config/m68k/m68k.md 2019-01-01 07:31:55.000000000 -0500 ++++ gcc-9.2.0/gcc/config/m68k/m68k.md 2020-06-30 15:56:20.061868526 -0400 +@@ -4121,35 +4121,6 @@ + return "fneg%. %1,%0"; + }) + +-;; Sqrt instruction for the 68881 +- +-(define_expand "sqrt2" +- [(set (match_operand:FP 0 "nonimmediate_operand" "") +- (sqrt:FP (match_operand:FP 1 "general_operand" "")))] +- "TARGET_HARD_FLOAT" +- "") +- +-(define_insn "sqrt2_68881" +- [(set (match_operand:FP 0 "nonimmediate_operand" "=f") +- (sqrt:FP (match_operand:FP 1 "general_operand" "fm")))] +- "TARGET_68881" +-{ +- if (FP_REG_P (operands[1])) +- return "fsqrt%.x %1,%0"; +- return "fsqrt%. %1,%0"; +-} +- [(set_attr "type" "fsqrt")]) +- +-(define_insn "sqrt2_cf" +- [(set (match_operand:FP 0 "nonimmediate_operand" "=f") +- (sqrt:FP (match_operand:FP 1 "general_operand" "fU")))] +- "TARGET_COLDFIRE_FPU" +-{ +- if (FP_REG_P (operands[1])) +- return "fsqrt%.d %1,%0"; +- return "fsqrt%. %1,%0"; +-} +- [(set_attr "type" "fsqrt")]) + ;; Absolute value instructions + ;; If using software floating point, just zero the sign bit. + diff --git a/patches/gcc-8.3.0/0018-m68k-sqrt.diff b/patches/gcc-8.3.0/0018-m68k-sqrt.diff new file mode 100644 index 0000000..3315939 --- /dev/null +++ b/patches/gcc-8.3.0/0018-m68k-sqrt.diff @@ -0,0 +1,38 @@ +--- gcc-9.2.0.orig/gcc/config/m68k/m68k.md 2019-01-01 07:31:55.000000000 -0500 ++++ gcc-9.2.0/gcc/config/m68k/m68k.md 2020-06-30 15:56:20.061868526 -0400 +@@ -4121,35 +4121,6 @@ + return "fneg%. %1,%0"; + }) + +-;; Sqrt instruction for the 68881 +- +-(define_expand "sqrt2" +- [(set (match_operand:FP 0 "nonimmediate_operand" "") +- (sqrt:FP (match_operand:FP 1 "general_operand" "")))] +- "TARGET_HARD_FLOAT" +- "") +- +-(define_insn "sqrt2_68881" +- [(set (match_operand:FP 0 "nonimmediate_operand" "=f") +- (sqrt:FP (match_operand:FP 1 "general_operand" "fm")))] +- "TARGET_68881" +-{ +- if (FP_REG_P (operands[1])) +- return "fsqrt%.x %1,%0"; +- return "fsqrt%. %1,%0"; +-} +- [(set_attr "type" "fsqrt")]) +- +-(define_insn "sqrt2_cf" +- [(set (match_operand:FP 0 "nonimmediate_operand" "=f") +- (sqrt:FP (match_operand:FP 1 "general_operand" "fU")))] +- "TARGET_COLDFIRE_FPU" +-{ +- if (FP_REG_P (operands[1])) +- return "fsqrt%.d %1,%0"; +- return "fsqrt%. %1,%0"; +-} +- [(set_attr "type" "fsqrt")]) + ;; Absolute value instructions + ;; If using software floating point, just zero the sign bit. + diff --git a/patches/gcc-9.2.0/0018-m68k-sqrt.diff b/patches/gcc-9.2.0/0018-m68k-sqrt.diff new file mode 100644 index 0000000..3315939 --- /dev/null +++ b/patches/gcc-9.2.0/0018-m68k-sqrt.diff @@ -0,0 +1,38 @@ +--- gcc-9.2.0.orig/gcc/config/m68k/m68k.md 2019-01-01 07:31:55.000000000 -0500 ++++ gcc-9.2.0/gcc/config/m68k/m68k.md 2020-06-30 15:56:20.061868526 -0400 +@@ -4121,35 +4121,6 @@ + return "fneg%. %1,%0"; + }) + +-;; Sqrt instruction for the 68881 +- +-(define_expand "sqrt2" +- [(set (match_operand:FP 0 "nonimmediate_operand" "") +- (sqrt:FP (match_operand:FP 1 "general_operand" "")))] +- "TARGET_HARD_FLOAT" +- "") +- +-(define_insn "sqrt2_68881" +- [(set (match_operand:FP 0 "nonimmediate_operand" "=f") +- (sqrt:FP (match_operand:FP 1 "general_operand" "fm")))] +- "TARGET_68881" +-{ +- if (FP_REG_P (operands[1])) +- return "fsqrt%.x %1,%0"; +- return "fsqrt%. %1,%0"; +-} +- [(set_attr "type" "fsqrt")]) +- +-(define_insn "sqrt2_cf" +- [(set (match_operand:FP 0 "nonimmediate_operand" "=f") +- (sqrt:FP (match_operand:FP 1 "general_operand" "fU")))] +- "TARGET_COLDFIRE_FPU" +-{ +- if (FP_REG_P (operands[1])) +- return "fsqrt%.d %1,%0"; +- return "fsqrt%. %1,%0"; +-} +- [(set_attr "type" "fsqrt")]) + ;; Absolute value instructions + ;; If using software floating point, just zero the sign bit. +