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]

[PATCH, i386]: x87 fops can handle HImodes, too.


Hello!

x87 integer fops (fiadd, fisub, fidiv, fimul) can handle SImode *and HImode* inputs. Attached patch adds missing modes. Bootstrapped i686-pc-linux-gnu, c and c++, regtest in progress. OK for mainline if it passes?

2004-09-13 Uros Bizjak <uros@kss-loka.si>

   * config/i386/i386.md (*fop_sf_2, *fop_sf_3, *fop_df_2, *fop_xf_2,
   *fop_xf_3): Also handle HImode.


The testcases: double test1 (double a, short b) { return sin (a) + b; } double test2 (double a, short b) { return sin (a) - b; } double test3 (double a, short b) { return sin (a) * b; } double test4 (double a, short b) { return sin (a) / b; }

now return (gcc -O2 -ffast-math -S -march=pentium4 -fomit-frame-pointer)
test1:
       fldl    4(%esp)
       fsin
       fiadds  12(%esp)
       ret
       .size   test1, .-test1
.globl test2
       .type   test2, @function
test2:
       fldl    4(%esp)
       fsin
       fisubs  12(%esp)
       ret
       .size   test2, .-test2
.globl test3
       .type   test3, @function
test3:
       fldl    4(%esp)
       fsin
       fimuls  12(%esp)
       ret
       .size   test3, .-test3
.globl test4
       .type   test4, @function
test4:
       fldl    4(%esp)
       fsin
       fld1
       fidivs  12(%esp)
       fmulp   %st, %st(1)
       ret
       .size   test4, .-test4
       .ident  "GCC: (GNU) 4.0.0 20040913 (experimental)"
       .section        .note.GNU-stack,"",@progbits

The test4 still divides as (1.0)/b * sin(a), which is BUG 14851 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14851), but this is an unrelated problem to this patch. Patch respects x86_use_fiop condition, so code for i686 & co. still uses 'fild?' insn.

Uros.
Index: i386.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.md,v
retrieving revision 1.560
diff -u -p -r1.560 i386.md
--- i386.md	12 Sep 2004 18:00:46 -0000	1.560
+++ i386.md	13 Sep 2004 13:26:44 -0000
@@ -14539,9 +14539,10 @@
 (define_insn "*fop_sf_2"
   [(set (match_operand:SF 0 "register_operand" "=f,f")
 	(match_operator:SF 3 "binary_fp_operator"
-	  [(float:SF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
+	  [(float:SF (match_operand 1 "nonimmediate_operand" "m,?r"))
 	   (match_operand:SF 2 "register_operand" "0,0")]))]
-  "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH"
+  "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH
+   && (GET_MODE (operands[1]) == SImode || GET_MODE (operands[1]) == HImode)"
   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
   [(set (attr "type") 
         (cond [(match_operand:SF 3 "mult_operator" "") 
@@ -14557,8 +14558,9 @@
   [(set (match_operand:SF 0 "register_operand" "=f,f")
 	(match_operator:SF 3 "binary_fp_operator"
 	  [(match_operand:SF 1 "register_operand" "0,0")
-	   (float:SF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
-  "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH"
+	   (float:SF (match_operand 2 "nonimmediate_operand" "m,?r"))]))]
+  "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH
+   && (GET_MODE (operands[2]) == SImode || GET_MODE (operands[2]) == HImode)"
   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
   [(set (attr "type") 
         (cond [(match_operand:SF 3 "mult_operator" "") 
@@ -14636,9 +14638,10 @@
 (define_insn "*fop_df_2"
   [(set (match_operand:DF 0 "register_operand" "=f,f")
 	(match_operator:DF 3 "binary_fp_operator"
-	   [(float:DF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
+	   [(float:DF (match_operand 1 "nonimmediate_operand" "m,?r"))
 	    (match_operand:DF 2 "register_operand" "0,0")]))]
-  "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)"
+  "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)
+   && (GET_MODE (operands[1]) == SImode || GET_MODE (operands[1]) == HImode)"
   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
   [(set (attr "type") 
         (cond [(match_operand:DF 3 "mult_operator" "") 
@@ -14654,8 +14657,9 @@
   [(set (match_operand:DF 0 "register_operand" "=f,f")
 	(match_operator:DF 3 "binary_fp_operator"
 	   [(match_operand:DF 1 "register_operand" "0,0")
-	    (float:DF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
-  "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)"
+	    (float:DF (match_operand 2 "nonimmediate_operand" "m,?r"))]))]
+  "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)
+   && (GET_MODE (operands[2]) == SImode || GET_MODE (operands[2]) == HImode)"
   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
   [(set (attr "type") 
         (cond [(match_operand:DF 3 "mult_operator" "") 
@@ -14739,9 +14743,10 @@
 (define_insn "*fop_xf_2"
   [(set (match_operand:XF 0 "register_operand" "=f,f")
 	(match_operator:XF 3 "binary_fp_operator"
-	   [(float:XF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
+	   [(float:XF (match_operand 1 "nonimmediate_operand" "m,?r"))
 	    (match_operand:XF 2 "register_operand" "0,0")]))]
-  "TARGET_80387 && TARGET_USE_FIOP"
+  "TARGET_80387 && TARGET_USE_FIOP
+   && (GET_MODE (operands[1]) == SImode || GET_MODE (operands[1]) == HImode)"
   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
   [(set (attr "type") 
         (cond [(match_operand:XF 3 "mult_operator" "") 
@@ -14757,8 +14762,9 @@
   [(set (match_operand:XF 0 "register_operand" "=f,f")
 	(match_operator:XF 3 "binary_fp_operator"
 	  [(match_operand:XF 1 "register_operand" "0,0")
-	   (float:XF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
-  "TARGET_80387 && TARGET_USE_FIOP"
+	   (float:XF (match_operand 2 "nonimmediate_operand" "m,?r"))]))]
+  "TARGET_80387 && TARGET_USE_FIOP
+   && (GET_MODE (operands[2]) == SImode || GET_MODE (operands[2]) == HImode)"
   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
   [(set (attr "type") 
         (cond [(match_operand:XF 3 "mult_operator" "") 

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