This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: MIPS patch for nmadd/nmsub w/wo fast-math


On Sat, 2004-08-14 at 00:23, Richard Sandiford wrote:
> Indeed.  Patch looks OK to me, except for the very minor nit below.
> Please do add a scan-assembler testcase to dejagnu though.  Preferrably
> one for -ffast-math and one for -fno-fast-math.

Here is that patch I checked in.  A made the mips.md changes you asked
for, and I added two testcases one with -ffast-math and one with
-fno-fast-math.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

gcc/ChangeLog
2004-08-17  James E Wilson  <wilson@specifixinc.com>

	* config/mips/mips.md: Add canonical nmadd and nmsub patterns for both
	normal and -ffast-math code.

gcc/testsuite/ChangeLog
2004-08-17  James E Wilson  <wilson@specifixinc.com>

	* gcc.dg/mips-nmadd-1.c: New test.
	* gcc.dg/mips-nmadd-2.c: New test.

Index: mips.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.md,v
retrieving revision 1.266
diff -p -r1.266 mips.md
*** mips.md	14 Aug 2004 20:55:56 -0000	1.266
--- mips.md	17 Aug 2004 21:38:49 -0000
***************
*** 1904,1910 ****
  	(neg:DF (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
  				  (match_operand:DF 2 "register_operand" "f"))
  			 (match_operand:DF 3 "register_operand" "f"))))]
!   "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
    "nmadd.d\t%0,%3,%1,%2"
    [(set_attr "type"	"fmadd")
     (set_attr "mode"	"DF")])
--- 1904,1922 ----
  	(neg:DF (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
  				  (match_operand:DF 2 "register_operand" "f"))
  			 (match_operand:DF 3 "register_operand" "f"))))]
!   "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT
!    && TARGET_FUSED_MADD && HONOR_SIGNED_ZEROS (DFmode)"
!   "nmadd.d\t%0,%3,%1,%2"
!   [(set_attr "type"	"fmadd")
!    (set_attr "mode"	"DF")])
! 
! (define_insn ""
!   [(set (match_operand:DF 0 "register_operand" "=f")
! 	(minus:DF (mult:DF (neg:DF (match_operand:DF 1 "register_operand" "f"))
! 				   (match_operand:DF 2 "register_operand" "f"))
! 		  (match_operand:DF 3 "register_operand" "f")))]
!   "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT
!    && TARGET_FUSED_MADD && !HONOR_SIGNED_ZEROS (DFmode)"
    "nmadd.d\t%0,%3,%1,%2"
    [(set_attr "type"	"fmadd")
     (set_attr "mode"	"DF")])
***************
*** 1914,1940 ****
  	(neg:SF (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
  				  (match_operand:SF 2 "register_operand" "f"))
  			 (match_operand:SF 3 "register_operand" "f"))))]
!   "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
    "nmadd.s\t%0,%3,%1,%2"
    [(set_attr "type"	"fmadd")
     (set_attr "mode"	"SF")])
  
  (define_insn ""
    [(set (match_operand:DF 0 "register_operand" "=f")
  	(minus:DF (match_operand:DF 1 "register_operand" "f")
  		  (mult:DF (match_operand:DF 2 "register_operand" "f")
  			   (match_operand:DF 3 "register_operand" "f"))))]
!   "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
    "nmsub.d\t%0,%1,%2,%3"
    [(set_attr "type"	"fmadd")
     (set_attr "mode"	"DF")])
  
  (define_insn ""
    [(set (match_operand:SF 0 "register_operand" "=f")
  	(minus:SF (match_operand:SF 1 "register_operand" "f")
  		  (mult:SF (match_operand:SF 2 "register_operand" "f")
  			   (match_operand:SF 3 "register_operand" "f"))))]
!   "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
    "nmsub.s\t%0,%1,%2,%3"
    [(set_attr "type"	"fmadd")
     (set_attr "mode"	"SF")])
--- 1926,1988 ----
  	(neg:SF (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
  				  (match_operand:SF 2 "register_operand" "f"))
  			 (match_operand:SF 3 "register_operand" "f"))))]
!   "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_FUSED_MADD
!    && HONOR_SIGNED_ZEROS (SFmode)"
!   "nmadd.s\t%0,%3,%1,%2"
!   [(set_attr "type"	"fmadd")
!    (set_attr "mode"	"SF")])
! 
! (define_insn ""
!   [(set (match_operand:SF 0 "register_operand" "=f")
! 	(minus:SF (mult:SF (neg:SF (match_operand:SF 1 "register_operand" "f"))
! 			   (match_operand:SF 2 "register_operand" "f"))
! 		  (match_operand:SF 3 "register_operand" "f")))]
!   "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_FUSED_MADD
!    && !HONOR_SIGNED_ZEROS (SFmode)"
    "nmadd.s\t%0,%3,%1,%2"
    [(set_attr "type"	"fmadd")
     (set_attr "mode"	"SF")])
  
  (define_insn ""
    [(set (match_operand:DF 0 "register_operand" "=f")
+ 	(neg:DF (minus:DF (mult:DF (match_operand:DF 2 "register_operand" "f")
+ 				   (match_operand:DF 3 "register_operand" "f"))
+ 			  (match_operand:DF 1 "register_operand" "f"))))]
+   "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT
+    && TARGET_FUSED_MADD && HONOR_SIGNED_ZEROS (DFmode)"
+   "nmsub.d\t%0,%1,%2,%3"
+   [(set_attr "type"	"fmadd")
+    (set_attr "mode"	"DF")])
+ 
+ (define_insn ""
+   [(set (match_operand:DF 0 "register_operand" "=f")
  	(minus:DF (match_operand:DF 1 "register_operand" "f")
  		  (mult:DF (match_operand:DF 2 "register_operand" "f")
  			   (match_operand:DF 3 "register_operand" "f"))))]
!   "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT
!    && TARGET_FUSED_MADD && !HONOR_SIGNED_ZEROS (DFmode)"
    "nmsub.d\t%0,%1,%2,%3"
    [(set_attr "type"	"fmadd")
     (set_attr "mode"	"DF")])
  
  (define_insn ""
    [(set (match_operand:SF 0 "register_operand" "=f")
+ 	(neg:SF (minus:SF (mult:SF (match_operand:SF 2 "register_operand" "f")
+ 				   (match_operand:SF 3 "register_operand" "f"))
+ 			  (match_operand:SF 1 "register_operand" "f"))))]
+   "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_FUSED_MADD
+    && HONOR_SIGNED_ZEROS (SFmode)"
+   "nmsub.s\t%0,%1,%2,%3"
+   [(set_attr "type"	"fmadd")
+    (set_attr "mode"	"SF")])
+ 
+ (define_insn ""
+   [(set (match_operand:SF 0 "register_operand" "=f")
  	(minus:SF (match_operand:SF 1 "register_operand" "f")
  		  (mult:SF (match_operand:SF 2 "register_operand" "f")
  			   (match_operand:SF 3 "register_operand" "f"))))]
!   "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_FUSED_MADD
!    && !HONOR_SIGNED_ZEROS (SFmode)"
    "nmsub.s\t%0,%1,%2,%3"
    [(set_attr "type"	"fmadd")
     (set_attr "mode"	"SF")])


Index: gcc.dg/mips-nmadd-1.c
===================================================================
RCS file: gcc.dg/mips-nmadd-1.c
diff -N gcc.dg/mips-nmadd-1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/mips-nmadd-1.c	17 Aug 2004 21:40:18 -0000
***************
*** 0 ****
--- 1,30 ----
+ /* { dg-do compile { target "mips*-*-*" } } */
+ /* { dg-options "-O2 -ffast-math -mips4" } */
+ /* { dg-final { scan-assembler "nmadd.s" } } */
+ /* { dg-final { scan-assembler "nmadd.d" } } */
+ /* { dg-final { scan-assembler "nmsub.s" } } */
+ /* { dg-final { scan-assembler "nmsub.d" } } */
+ 
+ float
+ sub1 (float f, float g, float h)
+ {
+   return -((f * g) + h);
+ }
+ 
+ double
+ sub2 (double f, double g, double h)
+ {
+   return -((f * g) + h);
+ }
+ 
+ float
+ sub3 (float f, float g, float h)
+ {
+   return -((f * g) - h);
+ }
+ 
+ double
+ sub4 (double f, double g, double h)
+ {
+   return -((f * g) - h);
+ }
Index: gcc.dg/mips-nmadd-2.c
===================================================================
RCS file: gcc.dg/mips-nmadd-2.c
diff -N gcc.dg/mips-nmadd-2.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc.dg/mips-nmadd-2.c	17 Aug 2004 21:40:18 -0000
***************
*** 0 ****
--- 1,30 ----
+ /* { dg-do compile { target "mips*-*-*" } } */
+ /* { dg-options "-O2 -fno-fast-math -mips4" } */
+ /* { dg-final { scan-assembler "nmadd.s" } } */
+ /* { dg-final { scan-assembler "nmadd.d" } } */
+ /* { dg-final { scan-assembler "nmsub.s" } } */
+ /* { dg-final { scan-assembler "nmsub.d" } } */
+ 
+ float
+ sub1 (float f, float g, float h)
+ {
+   return -((f * g) + h);
+ }
+ 
+ double
+ sub2 (double f, double g, double h)
+ {
+   return -((f * g) + h);
+ }
+ 
+ float
+ sub3 (float f, float g, float h)
+ {
+   return -((f * g) - h);
+ }
+ 
+ double
+ sub4 (double f, double g, double h)
+ {
+   return -((f * g) - h);
+ }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]