Patch to resurrect the x86 HImode integer -> FP patterns

John Wehle john@feith.com
Thu Apr 6 21:58:00 GMT 2000


This patch resurrects the HImode integer -> FP conversion patterns
which are present in GCC 2.95.2 and were loss in the switch to the
new x86 backend.  It passes make bootstrap and make check on
FreeBSD-3.4 x86.

Notes:

  1)  The HImode split doesn't use pop to update the stack pointer
      in order to avoid a potential partial register stall.

ChangeLog:

Thu Apr  6 00:21:27 EDT 2000  John Wehle  (john@feith.com)

	* i386.md (floathisf2, floathidf2, floathixf2): New patterns.
	* i386.c (print_operand): Use the proper suffix for a 387 HImode
	operand.  Abort if a 387 operand has an unsupported size.

Enjoy!

-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/config/i386/i386.md.ORIGINAL	Thu Apr  6 00:32:33 2000
--- gcc/config/i386/i386.md	Thu Apr  6 00:32:44 2000
***************
*** 3135,3140 ****
--- 3135,3150 ----
  ;; Even though we only accept memory inputs, the backend _really_
  ;; wants to be able to do this between registers.
  
+ (define_insn "floathisf2"
+   [(set (match_operand:SF 0 "register_operand" "=f,f")
+ 	(float:SF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
+   "TARGET_80387"
+   "@
+    fild%z1\\t%1
+    #"
+   [(set_attr "type" "fmov,multi")
+    (set_attr "fp_int_src" "true")])
+ 
  (define_insn "floatsisf2"
    [(set (match_operand:SF 0 "register_operand" "=f,f")
  	(float:SF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
***************
*** 3155,3160 ****
--- 3165,3180 ----
    [(set_attr "type" "fmov,multi")
     (set_attr "fp_int_src" "true")])
  
+ (define_insn "floathidf2"
+   [(set (match_operand:DF 0 "register_operand" "=f,f")
+ 	(float:DF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
+   "TARGET_80387"
+   "@
+    fild%z1\\t%1
+    #"
+   [(set_attr "type" "fmov,multi")
+    (set_attr "fp_int_src" "true")])
+ 
  (define_insn "floatsidf2"
    [(set (match_operand:DF 0 "register_operand" "=f,f")
  	(float:DF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
***************
*** 3175,3180 ****
--- 3195,3210 ----
    [(set_attr "type" "fmov,multi")
     (set_attr "fp_int_src" "true")])
  
+ (define_insn "floathixf2"
+   [(set (match_operand:XF 0 "register_operand" "=f,f")
+ 	(float:XF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
+   "TARGET_80387"
+   "@
+    fild%z1\\t%1
+    #"
+   [(set_attr "type" "fmov,multi")
+    (set_attr "fp_int_src" "true")])
+ 
  (define_insn "floatsixf2"
    [(set (match_operand:XF 0 "register_operand" "=f,f")
  	(float:XF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
***************
*** 3196,3201 ****
--- 3226,3241 ----
     (set_attr "fp_int_src" "true")])
  
  ;; %%% Kill these when reload knows how to do it.
+ (define_split
+   [(set (match_operand 0 "register_operand" "")
+ 	(float (match_operand:HI 1 "register_operand" "")))]
+   "reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
+   [(set (mem:HI (pre_dec:SI (reg:SI 7))) (match_dup 1))
+    (set (match_dup 0) (match_dup 2))
+    (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 2)))]
+   "operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]),
+ 			       	gen_rtx_MEM (HImode, stack_pointer_rtx));")
+ 
  (define_split
    [(set (match_operand 0 "register_operand" "")
  	(float (match_operand:SI 1 "register_operand" "")))]
*** gcc/config/i386/i386.c.ORIGINAL	Sat Apr  1 18:26:46 2000
--- gcc/config/i386/i386.c	Thu Apr  6 00:32:44 2000
*************** print_operand (file, x, code)
*** 3107,3122 ****
  	    return;
  
  	  /* this is the size of op from size of operand */
  	  switch (GET_MODE_SIZE (GET_MODE (x)))
  	    {
- 	    case 1:
- 	      putc ('b', file);
- 	      return;
- 
  	    case 2:
! 	      putc ('w', file);
  	      return;
  
  	    case 4:
  	      if (GET_MODE (x) == SFmode)
  		{
--- 3107,3120 ----
  	    return;
  
  	  /* this is the size of op from size of operand */
  	  switch (GET_MODE_SIZE (GET_MODE (x)))
  	    {
  	    case 2:
! #ifdef HAVE_GAS_FILDS_FISTS
! 	      putc ('s', file);
! #endif
  	      return;
  
  	    case 4:
  	      if (GET_MODE (x) == SFmode)
  		{
*************** print_operand (file, x, code)
*** 3142,3151 ****
--- 3140,3152 ----
  #endif
  		}
  	      else
  	        putc ('l', file);
  	      return;
+ 
+ 	    default:
+ 	      abort ();
  	    }
  
  	case 'b':
  	case 'w':
  	case 'k':
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------



More information about the Gcc-patches mailing list