i386.md (divmodsi4): Rewrite to expander.
authorJan Hubicka <hubicka@freesoft.cz>
Wed, 17 Nov 1999 17:39:18 +0000 (18:39 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 17 Nov 1999 17:39:18 +0000 (17:39 +0000)
Mon Nov 15 22:45:39 CET 1999  Jan Hubicka  <hubicka@freesoft.cz>
* i386.md (divmodsi4): Rewrite to expander.
(*divmodsi4_nocltd): New.
(*divmodsi4_cltd): New.
(divmodsi4 splitter): Handle the case when input comes in edx.
(udivmodhi4): Do not use constraints in exander.
(ashrsi3_31): Conditionize by TARGET_USE_CLTD.

From-SVN: r30555

gcc/ChangeLog
gcc/config/i386/i386.md

index f6f11ed22911e5891d6fb94539bda9bb0fc4dcf1..58c33f12680c704f29c416081bd1b4137fd46e01 100644 (file)
@@ -1,3 +1,11 @@
+Mon Nov 15 22:45:39 CET 1999  Jan Hubicka  <hubicka@freesoft.cz>
+       * i386.md (divmodsi4): Rewrite to expander.
+       (*divmodsi4_nocltd): New.
+       (*divmodsi4_cltd): New.
+       (divmodsi4 splitter): Handle the case when input comes in edx.
+       (udivmodhi4): Do not use constraints in exander.
+       (ashrsi3_31): Conditionize by TARGET_USE_CLTD.
+
 1999-11-17  Jason Merrill  <jason@yorick.cygnus.com>
 
        * dwarf2out.c (push_decl_scope): Still use decl_scope_depth - 1
index e89965ecf862d6366433a24822ccb89c4464cecd..82553cf043d4e85c316a5747e45519a79037d117 100644 (file)
   "")
 \f
 ;; Remainder instructions.
+(define_expand "divmodsi4"
+  [(parallel [(set (match_operand:SI 0 "register_operand" "")
+                  (div:SI (match_operand:SI 1 "register_operand" "")
+                          (match_operand:SI 2 "nonimmediate_operand" "")))
+             (set (match_operand:SI 3 "register_operand" "")
+                  (mod:SI (match_dup 1) (match_dup 2)))
+             (clobber (reg:CC 17))])]
+  ""
+  "")
+
+;; Allow to come the parameter in eax or edx to avoid extra moves.
+;; Penalize eax case sligthly because it results in worse scheduling
+;; of code.
+(define_insn "*divmodsi4_nocltd"
+  [(set (match_operand:SI 0 "register_operand" "=&a,?a")
+       (div:SI (match_operand:SI 2 "register_operand" "1,0")
+               (match_operand:SI 3 "nonimmediate_operand" "rm,rm")))
+   (set (match_operand:SI 1 "register_operand" "=&d,&d")
+       (mod:SI (match_dup 2) (match_dup 3)))
+   (clobber (reg:CC 17))]
+  "!optimize_size && !TARGET_USE_CLTD"
+  "#"
+  [(set_attr "type" "multi")])
 
-(define_insn "divmodsi4"
+(define_insn "*divmodsi4_cltd"
   [(set (match_operand:SI 0 "register_operand" "=a")
-       (div:SI (match_operand:SI 1 "register_operand" "A")
-               (match_operand:SI 2 "nonimmediate_operand" "rm")))
-   (set (match_operand:SI 3 "register_operand" "=&d")
-       (mod:SI (match_dup 1) (match_dup 2)))
+       (div:SI (match_operand:SI 2 "register_operand" "a")
+               (match_operand:SI 3 "nonimmediate_operand" "rm")))
+   (set (match_operand:SI 1 "register_operand" "=&d")
+       (mod:SI (match_dup 2) (match_dup 3)))
    (clobber (reg:CC 17))]
-  ""
-  "{cltd|cdq}\;idiv{l}\\t%2"
+  "optimize_size || TARGET_USE_CLTD"
+  "#"
   [(set_attr "type" "multi")])
 
 (define_insn "*divmodsi_noext"
   [(set (match_operand:SI 0 "register_operand" "=a")
-       (div:SI (match_operand:SI 1 "register_operand" "A")
+       (div:SI (match_operand:SI 1 "register_operand" "0")
                (match_operand:SI 2 "nonimmediate_operand" "rm")))
    (set (match_operand:SI 3 "register_operand" "=d")
        (mod:SI (match_dup 1) (match_dup 2)))
-   (use (match_dup 3))
+   (use (match_operand:SI 4 "register_operand" "3"))
    (clobber (reg:CC 17))]
   ""
   "idiv{l}\\t%2"
                   (ashiftrt:SI (match_dup 4) (const_int 31)))
              (clobber (reg:CC 17))])
    (parallel [(set (match_dup 0)
-                  (div:SI (match_dup 1) (match_dup 2)))
+                  (div:SI (reg:SI 0) (match_dup 2)))
              (set (match_dup 3)
-                  (mod:SI (match_dup 1) (match_dup 2)))
+                  (mod:SI (reg:SI 0) (match_dup 2)))
              (use (match_dup 3))
              (clobber (reg:CC 17))])]
   "
 {
   /* Avoid use of cltd in favour of a mov+shift.  */
-  if (TARGET_PENTIUM && !optimize_size)
+  if (!TARGET_USE_CLTD && !optimize_size)
     {
-      emit_move_insn (operands[3], operands[1]);
+      if (true_regnum (operands[1]))
+        emit_move_insn (operands[0], operands[1]);
+      else
+       emit_move_insn (operands[3], operands[1]);
       operands[4] = operands[3];
     }
   else
-    operands[4] = operands[1];
+    {
+      if (true_regnum (operands[1]))
+       abort();
+      operands[4] = operands[1];
+    }
 }")
-
 ;; %%% Split me.
 (define_insn "divmodhi4"
   [(set (match_operand:HI 0 "register_operand" "=a")
 (define_expand "udivmodhi4"
   [(parallel [(set (match_dup 4) (const_int 0))
              (clobber (reg:CC 17))])
-   (parallel [(set (match_operand:HI 0 "register_operand" "=a")
-                  (udiv:HI (match_operand:HI 1 "register_operand" "0")
-                           (match_operand:HI 2 "nonimmediate_operand" "rm")))
-             (set (match_operand:HI 3 "register_operand" "=&d")
+   (parallel [(set (match_operand:HI 0 "register_operand" "")
+                  (udiv:HI (match_operand:HI 1 "register_operand" "")
+                           (match_operand:HI 2 "nonimmediate_operand" "")))
+             (set (match_operand:HI 3 "register_operand" "")
                   (umod:HI (match_dup 1) (match_dup 2)))
              (use (match_dup 4))
              (clobber (reg:CC 17))])]
        (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "*a,0")
                     (match_operand:SI 2 "const_int_operand" "i,i")))
    (clobber (reg:CC 17))]
-  "INTVAL (operands[2]) == 31"
+  "INTVAL (operands[2]) == 31 && TARGET_USE_CLTD"
   "@
    {cltd|cdq}
    sar{l}\\t{%2, %0|%0, %2}"