diff mbox

[7/N,xtensa] convert to fma

Message ID 20101112021746.GA13310@twiddle.net
State New
Headers show

Commit Message

Richard Henderson Nov. 12, 2010, 2:17 a.m. UTC
Straight-forward conversion here.  Untested except for cross-compile.

Ok?


r~
diff mbox

Patch

diff --git a/gcc/config.gcc b/gcc/config.gcc
index f92483d..c6a2d4c 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -393,12 +393,16 @@  spu*-*-*)
 s390*-*-*)
 	cpu_type=s390
 	need_64bit_hwint=yes
+	extra_options="${extra_options} fused-madd.opt"
 	;;
 # Note the 'l'; we need to be able to match e.g. "shle" or "shl".
 sh[123456789lbe]*-*-* | sh-*-*)
 	cpu_type=sh
 	need_64bit_hwint=yes
 	;;
+xtensa*-*-*)
+	extra_options="${extra_options} fused-madd.opt"
+	;;
 esac
 
 tm_file=${cpu_type}/${cpu_type}.h
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index a01fb0b..033779c 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -193,7 +193,7 @@  static const struct default_options xtensa_option_optimization_table[] =
 #define TARGET_ASM_SELECT_RTX_SECTION  xtensa_select_rtx_section
 
 #undef TARGET_DEFAULT_TARGET_FLAGS
-#define TARGET_DEFAULT_TARGET_FLAGS (TARGET_DEFAULT | MASK_FUSED_MADD)
+#define TARGET_DEFAULT_TARGET_FLAGS (TARGET_DEFAULT)
 
 #undef TARGET_LEGITIMIZE_ADDRESS
 #define TARGET_LEGITIMIZE_ADDRESS xtensa_legitimize_address
diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
index 13883f1..9d9bf9c 100644
--- a/gcc/config/xtensa/xtensa.md
+++ b/gcc/config/xtensa/xtensa.md
@@ -315,24 +315,25 @@ 
    (set_attr "mode"	"SF")
    (set_attr "length"	"3")])
 
-(define_insn "muladdsf3"
+(define_insn "fmasf4"
   [(set (match_operand:SF 0 "register_operand" "=f")
-	(plus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f")
-			  (match_operand:SF 2 "register_operand" "f"))
-		 (match_operand:SF 3 "register_operand" "0")))]
-  "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
+	(fma:SF (match_operand:SF 1 "register_operand" "f")
+		(match_operand:SF 2 "register_operand" "f")
+		(match_operand:SF 3 "register_operand" "0")))]
+  "TARGET_HARD_FLOAT"
   "madd.s\t%0, %1, %2"
   [(set_attr "type"	"fmadd")
    (set_attr "mode"	"SF")
    (set_attr "length"	"3")])
 
-(define_insn "mulsubsf3"
+;; Note that (C - A*B) = (-A*B + C)
+(define_insn "fnmasf4"
   [(set (match_operand:SF 0 "register_operand" "=f")
-	(minus:SF (match_operand:SF 1 "register_operand" "0")
-		  (mult:SF (match_operand:SF 2 "register_operand" "%f")
-			   (match_operand:SF 3 "register_operand" "f"))))]
-  "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
-  "msub.s\t%0, %2, %3"
+	(fma:SF (neg:SF (match_operand:SF 1 "register_operand" "f"))
+		(match_operand:SF 2 "register_operand" "f")
+		(match_operand:SF 3 "register_operand" "0")))]
+  "TARGET_HARD_FLOAT"
+  "msub.s\t%0, %1, %2"
   [(set_attr "type"	"fmadd")
    (set_attr "mode"	"SF")
    (set_attr "length"	"3")])
diff --git a/gcc/config/xtensa/xtensa.opt b/gcc/config/xtensa/xtensa.opt
index 18f8bf3..9ae8b39 100644
--- a/gcc/config/xtensa/xtensa.opt
+++ b/gcc/config/xtensa/xtensa.opt
@@ -22,10 +22,6 @@  mconst16
 Target Report Mask(CONST16)
 Use CONST16 instruction to load constants
 
-mfused-madd
-Target Report Mask(FUSED_MADD)
-Enable fused multiply/add and multiply/subtract FP instructions
-
 mforce-no-pic
 Target Report Mask(FORCE_NO_PIC)
 Disable position-independent code (PIC) for use in OS kernel code