i386-protos.h (emit_i387_cw_initialization): Declare.
authorJan Hubicka <jh@suse.cz>
Sat, 23 Jun 2001 17:41:33 +0000 (19:41 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sat, 23 Jun 2001 17:41:33 +0000 (17:41 +0000)
* i386-protos.h (emit_i387_cw_initialization): Declare.
* i386.md (movsi_insv_1): Remove '*'.
(fix_trunc?f?i2): Revamp to use control word parameters.
(fix_trunc?i_1): Likewise; update splitters.
(fix splitter): Remove.
* i386.c (MAX_386_STACK_LOCALS): set to 3.
(emit_i387_cw_initialization): New function.
(output_fix_trunc): Do not initialize control word;
kill dead code; simplify.

From-SVN: r43530

gcc/ChangeLog
gcc/config/i386/i386-protos.h
gcc/config/i386/i386.c
gcc/config/i386/i386.md

index 442c35d..eaadef0 100644 (file)
@@ -1,3 +1,15 @@
+Sat Jun 23 19:40:05 CEST 2001  Jan Hubicka  <jh@suse.cz>
+
+       * i386-protos.h (emit_i387_cw_initialization): Declare.
+       * i386.md (movsi_insv_1): Remove '*'.
+       (fix_trunc?f?i2): Revamp to use control word parameters.
+       (fix_trunc?i_1): Likewise; update splitters.
+       (fix splitter): Remove.
+       * i386.c (MAX_386_STACK_LOCALS): set to 3.
+       (emit_i387_cw_initialization): New function.
+       (output_fix_trunc): Do not initialize control word;
+       kill dead code; simplify.
+
 2001-06-23  Neil Booth  <neil@cat.daikokuya.demon.co.uk>
 
        * cppmacro.c (make_string_token): Avoid warning.
index f5e9371..58d2313 100644 (file)
@@ -154,6 +154,7 @@ extern enum reg_class ix86_preferred_reload_class PARAMS ((rtx,
 extern int ix86_memory_move_cost PARAMS ((enum machine_mode, enum reg_class,
                                          int));
 extern void ix86_set_move_mem_attrs PARAMS ((rtx, rtx, rtx, rtx, rtx));
+extern void emit_i387_cw_initialization PARAMS ((rtx, rtx));
 
 
 #ifdef TREE_CODE
index fb57394..42cc2f7 100644 (file)
@@ -445,7 +445,7 @@ int const svr4_dbx_register_map[FIRST_PSEUDO_REGISTER] =
 struct rtx_def *ix86_compare_op0 = NULL_RTX;
 struct rtx_def *ix86_compare_op1 = NULL_RTX;
 
-#define MAX_386_STACK_LOCALS 2
+#define MAX_386_STACK_LOCALS 3
 /* Size of the register save area.  */
 #define X86_64_VARARGS_SIZE (REGPARM_MAX * UNITS_PER_WORD + SSE_REGPARM_MAX * 16)
 
@@ -4639,6 +4639,25 @@ output_387_binary_op (insn, operands)
   return buf;
 }
 
+/* Output code to initialize control word copies used by 
+   trunc?f?i patterns.  NORMAL is set to current control word, while ROUND_DOWN
+   is set to control word rounding downwards.  */
+void
+emit_i387_cw_initialization (normal, round_down)
+     rtx normal, round_down;
+{
+  rtx reg = gen_reg_rtx (HImode);
+
+  emit_insn (gen_x86_fnstcw_1 (normal));
+  emit_move_insn (reg, normal);
+  if (!TARGET_PARTIAL_REG_STALL && !optimize_size
+      && !TARGET_64BIT)
+    emit_insn (gen_movsi_insv_1 (reg, GEN_INT (0xc)));
+  else
+    emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0xc00)));
+  emit_move_insn (round_down, reg);
+}
+
 /* Output code for INSN to convert a float to a signed int.  OPERANDS
    are the insn operands.  The output may be [HSD]Imode and the input
    operand may be [SDX]Fmode.  */
@@ -4658,45 +4677,19 @@ output_fix_trunc (insn, operands)
   if (dimode_p && !stack_top_dies)
     output_asm_insn ("fld\t%y1", operands);
 
-  if (! STACK_TOP_P (operands[1]))
+  if (!STACK_TOP_P (operands[1]))
     abort ();
 
-  xops[0] = GEN_INT (12);
-  xops[1] = adj_offsettable_operand (operands[2], 1);
-  xops[1] = change_address (xops[1], QImode, NULL_RTX);
-
-  xops[2] = operands[0];
   if (GET_CODE (operands[0]) != MEM)
-    xops[2] = operands[3];
-
-  output_asm_insn ("fnstcw\t%2", operands);
-  output_asm_insn ("mov{l}\t{%2, %4|%4, %2}", operands);
-  output_asm_insn ("mov{b}\t{%0, %1|%1, %0}", xops);
-  output_asm_insn ("fldcw\t%2", operands);
-  output_asm_insn ("mov{l}\t{%4, %2|%2, %4}", operands);
+    abort ();
 
+  output_asm_insn ("fldcw\t%3", operands);
   if (stack_top_dies || dimode_p)
-    output_asm_insn ("fistp%z2\t%2", xops);
+    output_asm_insn ("fistp%z0\t%0", operands);
   else
-    output_asm_insn ("fist%z2\t%2", xops);
-
+    output_asm_insn ("fist%z0\t%0", operands);
   output_asm_insn ("fldcw\t%2", operands);
 
-  if (GET_CODE (operands[0]) != MEM)
-    {
-      if (dimode_p)
-       {
-         split_di (operands+0, 1, xops+0, xops+1);
-         split_di (operands+3, 1, xops+2, xops+3);
-         output_asm_insn ("mov{l}\t{%2, %0|%0, %2}", xops);
-         output_asm_insn ("mov{l}\t{%3, %1|%1, %3}", xops);
-       }
-      else if (GET_MODE (operands[0]) == SImode)
-       output_asm_insn ("mov{l}\t{%3, %0|%0, %3}", operands);
-      else
-       output_asm_insn ("mov{w}\t{%3, %0|%0, %3}", operands);
-    }
-
   return "";
 }
 
index c141902..fe341a3 100644 (file)
        (const_string "SI")
        (const_string "QI")))])
 
-(define_insn "*movsi_insv_1"
+(define_insn "movsi_insv_1"
   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
                         (const_int 8)
                         (const_int 8))
 (define_expand "fix_truncxfdi2"
   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
                   (fix:DI (match_operand:XF 1 "register_operand" "")))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
-             (clobber (match_scratch:SI 4 ""))
+             (use (match_dup 2))
+             (use (match_dup 3))
+             (clobber (match_dup 4))
              (clobber (match_scratch:XF 5 ""))])]
   "TARGET_80387 && !TARGET_64BIT"
-  "operands[2] = assign_386_stack_local (SImode, 0);
-   operands[3] = assign_386_stack_local (DImode, 1);")
+  "operands[2] = assign_386_stack_local (HImode, 1);
+   operands[3] = assign_386_stack_local (HImode, 2);
+   emit_i387_cw_initialization (operands[2], operands[3]);
+   operands[4] = assign_386_stack_local (DImode, 0);")
 
 (define_expand "fix_trunctfdi2"
   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
                   (fix:DI (match_operand:TF 1 "register_operand" "")))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
-             (clobber (match_scratch:SI 4 ""))
-             (clobber (match_scratch:TF 5 ""))])]
+             (use (match_dup 2))
+             (use (match_dup 3))
+             (clobber (match_dup 4))
+             (clobber (match_scratch:XF 5 ""))])]
   "TARGET_80387"
-  "operands[2] = assign_386_stack_local (SImode, 0);
-   operands[3] = assign_386_stack_local (DImode, 1);")
+  "operands[2] = assign_386_stack_local (HImode, 1);
+   operands[3] = assign_386_stack_local (HImode, 2);
+   emit_i387_cw_initialization (operands[2], operands[3]);
+   operands[4] = assign_386_stack_local (DImode, 0);")
 
 (define_expand "fix_truncdfdi2"
   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
                   (fix:DI (match_operand:DF 1 "register_operand" "")))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
-             (clobber (match_scratch:SI 4 ""))
-             (clobber (match_scratch:DF 5 ""))])]
+             (use (match_dup 2))
+             (use (match_dup 3))
+             (clobber (match_dup 4))
+             (clobber (match_scratch:XF 5 ""))])]
   "TARGET_80387 || (TARGET_SSE2 && TARGET_64BIT)"
   "
 {
    }
   else
    {
-     operands[2] = assign_386_stack_local (SImode, 0);
-     operands[3] = assign_386_stack_local (DImode, 1);
+     operands[2] = assign_386_stack_local (HImode, 1);
+     operands[3] = assign_386_stack_local (HImode, 2);
+     emit_i387_cw_initialization (operands[2], operands[3]);
+     operands[4] = assign_386_stack_local (DImode, 0);
    }
 }")
 
 (define_expand "fix_truncsfdi2"
   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
                   (fix:DI (match_operand:SF 1 "register_operand" "")))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
-             (clobber (match_scratch:SI 4 ""))
-             (clobber (match_scratch:SF 5 ""))])]
+             (use (match_dup 2))
+             (use (match_dup 3))
+             (clobber (match_dup 4))
+             (clobber (match_scratch:XF 5 ""))])]
   "TARGET_80387 || (TARGET_SSE && TARGET_64BIT)"
   "
 {
    }
   else
    {
-     operands[2] = assign_386_stack_local (SImode, 0);
-     operands[3] = assign_386_stack_local (DImode, 1);
+     operands[2] = assign_386_stack_local (HImode, 1);
+     operands[3] = assign_386_stack_local (HImode, 2);
+     emit_i387_cw_initialization (operands[2], operands[3]);
+     operands[4] = assign_386_stack_local (DImode, 0);
    }
 }")
 
 (define_insn "*fix_truncdi_1"
   [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r")
        (fix:DI (match_operand 1 "register_operand" "f,f")))
-   (clobber (match_operand:SI 2 "memory_operand" "=o,o"))
-   (clobber (match_operand:DI 3 "memory_operand" "=m,m"))
-   (clobber (match_scratch:SI 4 "=&r,&r"))
-   (clobber (match_scratch 5 "=&f,&f"))]
+   (use (match_operand:HI 2 "memory_operand" "m,m"))
+   (use (match_operand:HI 3 "memory_operand" "m,m"))
+   (clobber (match_operand:DI 4 "memory_operand" "=m,m"))
+   (clobber (match_scratch 5 "=&1f,&1f"))]
   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
    && (!TARGET_SSE2 || !TARGET_64BIT
        || !SSE_FLOAT_MODE_P (GET_MODE (operands[1])))"
 (define_split 
   [(set (match_operand:DI 0 "register_operand" "")
        (fix:DI (match_operand 1 "register_operand" "")))
-   (clobber (match_operand:SI 2 "memory_operand" ""))
-   (clobber (match_operand:DI 3 "memory_operand" ""))
-   (clobber (match_scratch:SI 4 ""))
+   (use (match_operand:HI 2 "memory_operand" ""))
+   (use (match_operand:HI 3 "memory_operand" ""))
+   (clobber (match_operand:DI 4 "memory_operand" ""))
    (clobber (match_scratch 5 ""))]
-  "reload_completed && !reg_overlap_mentioned_p (operands[4], operands[3])"
-  [(parallel [(set (match_dup 3) (fix:DI (match_dup 1)))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
+  "reload_completed"
+  [(parallel [(set (match_dup 4) (fix:DI (match_dup 1)))
+             (use (match_dup 2))
+             (use (match_dup 3))
              (clobber (match_dup 4))
              (clobber (match_dup 5))])
-   (set (match_dup 0) (match_dup 3))]
+   (set (match_dup 0) (match_dup 4))]
   "")
 
 ;; When SSE available, it is always faster to use it!
 (define_expand "fix_truncxfsi2"
   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
                   (fix:SI (match_operand:XF 1 "register_operand" "")))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
-             (clobber (match_scratch:SI 4 ""))])]
+             (use (match_dup 2))
+             (use (match_dup 3))
+             (clobber (match_dup 4))])]
   "TARGET_80387 && !TARGET_64BIT"
-  "operands[2] = assign_386_stack_local (SImode, 0);
-   operands[3] = assign_386_stack_local (SImode, 1);")
+  "operands[2] = assign_386_stack_local (HImode, 1);
+   operands[3] = assign_386_stack_local (HImode, 2);
+   emit_i387_cw_initialization (operands[2], operands[3]);
+   operands[4] = assign_386_stack_local (SImode, 0);")
 
 (define_expand "fix_trunctfsi2"
   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
                   (fix:SI (match_operand:TF 1 "register_operand" "")))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
-             (clobber (match_scratch:SI 4 ""))])]
+             (use (match_dup 2))
+             (use (match_dup 3))
+             (clobber (match_dup 4))])]
   "TARGET_80387"
-  "operands[2] = assign_386_stack_local (SImode, 0);
-   operands[3] = assign_386_stack_local (SImode, 1);")
+  "operands[2] = assign_386_stack_local (HImode, 1);
+   operands[3] = assign_386_stack_local (HImode, 2);
+   emit_i387_cw_initialization (operands[2], operands[3]);
+   operands[4] = assign_386_stack_local (SImode, 0);")
 
 (define_expand "fix_truncdfsi2"
   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
                   (fix:SI (match_operand:DF 1 "register_operand" "")))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
-             (clobber (match_scratch:SI 4 ""))])]
+             (use (match_dup 2))
+             (use (match_dup 3))
+             (clobber (match_dup 4))])]
   "TARGET_80387 || TARGET_SSE2"
   "
 {
    }
   else
    {
-     operands[2] = assign_386_stack_local (SImode, 0);
-     operands[3] = assign_386_stack_local (SImode, 1);
+     operands[2] = assign_386_stack_local (HImode, 1);
+     operands[3] = assign_386_stack_local (HImode, 2);
+     emit_i387_cw_initialization (operands[2], operands[3]);
+     operands[4] = assign_386_stack_local (SImode, 0);
    }
 }")
 
 (define_expand "fix_truncsfsi2"
   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
                   (fix:SI (match_operand:SF 1 "register_operand" "")))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
-             (clobber (match_scratch:SI 4 ""))])]
+             (use (match_dup 2))
+             (use (match_dup 3))
+             (clobber (match_dup 4))])]
   "TARGET_80387 || TARGET_SSE"
   "
 {
    }
   else
    {
-     operands[2] = assign_386_stack_local (SImode, 0);
-     operands[3] = assign_386_stack_local (SImode, 1);
+     operands[2] = assign_386_stack_local (HImode, 1);
+     operands[3] = assign_386_stack_local (HImode, 2);
+     emit_i387_cw_initialization (operands[2], operands[3]);
+     operands[4] = assign_386_stack_local (SImode, 0);
    }
 }")
 
 (define_insn "*fix_truncsi_1"
   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r")
        (fix:SI (match_operand 1 "register_operand" "f,f")))
-   (clobber (match_operand:SI 2 "memory_operand" "=o,o"))
-   (clobber (match_operand:SI 3 "memory_operand" "=m,m"))
-   (clobber (match_scratch:SI 4 "=&r,r"))]
+   (use (match_operand:HI 2 "memory_operand" "m,m"))
+   (use (match_operand:HI 3 "memory_operand" "m,m"))
+   (clobber (match_operand:SI 4 "memory_operand" "=m,m"))]
   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
    && (!TARGET_SSE2 || !SSE_FLOAT_MODE_P (GET_MODE (operands[1])))"
   "* return output_fix_trunc (insn, operands);"
 (define_split 
   [(set (match_operand:SI 0 "register_operand" "")
        (fix:SI (match_operand 1 "register_operand" "")))
-   (clobber (match_operand:SI 2 "memory_operand" ""))
-   (clobber (match_operand:SI 3 "memory_operand" ""))
-   (clobber (match_scratch:SI 4 ""))]
+   (use (match_operand:HI 2 "memory_operand" ""))
+   (use (match_operand:HI 3 "memory_operand" ""))
+   (clobber (match_operand:SI 4 "memory_operand" ""))]
   "reload_completed"
-  [(parallel [(set (match_dup 3) (fix:SI (match_dup 1)))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
+  [(parallel [(set (match_dup 4) (fix:SI (match_dup 1)))
+             (use (match_dup 2))
+             (use (match_dup 3))
              (clobber (match_dup 4))])
-   (set (match_dup 0) (match_dup 3))]
+   (set (match_dup 0) (match_dup 4))]
   "")
 
 ;; Signed conversion to HImode.
 (define_expand "fix_truncxfhi2"
   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
                   (fix:HI (match_operand:XF 1 "register_operand" "")))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
-             (clobber (match_scratch:SI 4 ""))])]
+             (use (match_dup 2))
+             (use (match_dup 3))
+             (clobber (match_dup 4))])]
   "TARGET_80387 && !TARGET_64BIT"
-  "operands[2] = assign_386_stack_local (SImode, 0);
-   operands[3] = assign_386_stack_local (HImode, 1);")
+  "operands[2] = assign_386_stack_local (HImode, 1);
+   operands[3] = assign_386_stack_local (HImode, 2);
+   emit_i387_cw_initialization (operands[2], operands[3]);
+   operands[4] = assign_386_stack_local (HImode, 0);")
 
 (define_expand "fix_trunctfhi2"
   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
                   (fix:HI (match_operand:TF 1 "register_operand" "")))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
-             (clobber (match_scratch:SI 4 ""))])]
+             (use (match_dup 2))
+             (use (match_dup 3))
+             (clobber (match_dup 4))])]
   "TARGET_80387"
-  "operands[2] = assign_386_stack_local (SImode, 0);
-   operands[3] = assign_386_stack_local (HImode, 1);")
+  "operands[2] = assign_386_stack_local (HImode, 1);
+   operands[3] = assign_386_stack_local (HImode, 2);
+   emit_i387_cw_initialization (operands[2], operands[3]);
+   operands[4] = assign_386_stack_local (HImode, 0);")
 
 (define_expand "fix_truncdfhi2"
   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
                   (fix:HI (match_operand:DF 1 "register_operand" "")))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
-             (clobber (match_scratch:SI 4 ""))])]
+             (use (match_dup 2))
+             (use (match_dup 3))
+             (clobber (match_dup 4))])]
   "TARGET_80387 && !TARGET_SSE2"
-  "operands[2] = assign_386_stack_local (SImode, 0);
-   operands[3] = assign_386_stack_local (HImode, 1);")
+  "operands[2] = assign_386_stack_local (HImode, 1);
+   operands[3] = assign_386_stack_local (HImode, 2);
+   emit_i387_cw_initialization (operands[2], operands[3]);
+   operands[4] = assign_386_stack_local (HImode, 0);")
 
 (define_expand "fix_truncsfhi2"
   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
                   (fix:HI (match_operand:SF 1 "register_operand" "")))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
-             (clobber (match_scratch:SI 4 ""))])]
+             (use (match_dup 2))
+             (use (match_dup 3))
+             (clobber (match_dup 4))])]
   "TARGET_80387 && !TARGET_SSE"
-  "operands[2] = assign_386_stack_local (SImode, 0);
-   operands[3] = assign_386_stack_local (HImode, 1);")
+  "operands[2] = assign_386_stack_local (HImode, 1);
+   operands[3] = assign_386_stack_local (HImode, 2);
+   emit_i387_cw_initialization (operands[2], operands[3]);
+   operands[4] = assign_386_stack_local (HImode, 0);")
 
 (define_insn "*fix_trunchi_1"
   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r")
        (fix:HI (match_operand 1 "register_operand" "f,f")))
-   (clobber (match_operand:SI 2 "memory_operand" "=o,o"))
-   (clobber (match_operand:HI 3 "memory_operand" "=m,m"))
-   (clobber (match_scratch:SI 4 "=&r,r"))]
+   (use (match_operand:HI 2 "memory_operand" "m,m"))
+   (use (match_operand:HI 3 "memory_operand" "m,m"))
+   (clobber (match_operand:HI 4 "memory_operand" "=m,m"))]
   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
    && (TARGET_SSE2 || !SSE_FLOAT_MODE_P (GET_MODE (operands[1])))"
   "* return output_fix_trunc (insn, operands);"
 (define_split 
   [(set (match_operand:HI 0 "register_operand" "")
        (fix:HI (match_operand 1 "register_operand" "")))
-   (clobber (match_operand:SI 2 "memory_operand" ""))
-   (clobber (match_operand:HI 3 "memory_operand" ""))
-   (clobber (match_scratch:SI 4 ""))]
+   (use (match_operand:HI 2 "memory_operand" ""))
+   (use (match_operand:HI 3 "memory_operand" ""))
+   (clobber (match_operand:HI 4 "memory_operand" ""))]
   "reload_completed"
-  [(parallel [(set (match_dup 3) (fix:HI (match_dup 1)))
-             (clobber (match_dup 2))
-             (clobber (match_dup 3))
+  [(parallel [(set (match_dup 4) (fix:HI (match_dup 1)))
+             (use (match_dup 2))
+             (use (match_dup 3))
              (clobber (match_dup 4))])
-   (set (match_dup 0) (match_dup 3))]
+   (set (match_dup 0) (match_dup 4))]
   "")
 
-;; %%% Kill these when reload knows how to do it.
-(define_split
-  [(set (match_operand 0 "register_operand" "")
-       (fix (match_operand 1 "register_operand" "")))]
-  "reload_completed && FLOAT_MODE_P (GET_MODE (operands[1]))
-   && FP_REG_P (operands[1])"
-  [(const_int 0)]
-  "
-{
-  operands[2] = ix86_force_to_memory (GET_MODE (operands[0]), operands[0]);
-  operands[2] = gen_rtx_FIX (GET_MODE (operands[2]), operands[1]);
-  emit_insn (gen_rtx_SET (VOIDmode, operands[2], operands[1]));
-  emit_move_insn (operands[0], operands[2]);
-  ix86_free_from_memory (GET_MODE (operands[0]));
-  DONE;
-}")
-
 ;; %% Not used yet.
 (define_insn "x86_fnstcw_1"
   [(set (match_operand:HI 0 "memory_operand" "=m")