i386.md (ashlsi3): Turn into a define_expand an anonymous pattern.
authorJeffrey A Law <law@cygnus.com>
Tue, 2 Feb 1999 19:06:58 +0000 (19:06 +0000)
committerJeff Law <law@gcc.gnu.org>
Tue, 2 Feb 1999 19:06:58 +0000 (12:06 -0700)
        * i386.md (ashlsi3): Turn into a define_expand an anonymous pattern.
        Make the anonymous pattern match when ! optimize_size.
        (ashlsi3 size optimizer): New pattern.

From-SVN: r24980

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

index 5837037eb8f1b40b8cfb846a914f1c7675b4ef7b..4382b7cde96100df958692bfd7a9ffd41854ee0a 100644 (file)
@@ -6,6 +6,10 @@ Tue Feb  2 20:29:34 1999  Catherine Moore  <clm@cygnus.com>
  
 Tue Feb  2 19:43:59 1999  Jeffrey A Law  (law@cygnus.com)
 
+       * i386.md (ashlsi3): Turn into a define_expand an anonymous pattern.
+       Make the anonymous pattern match when ! optimize_size.
+       (ashlsi3 size optimizer): New pattern.
+
        * intl/Makefile.in (uninstall): Add missing "; \".
 
 Tue Feb  2 18:21:23 1999  Stan Cox  <scox@cygnus.com>
index 9781d7aeb024f1f577294c2b8239e16ee6deee6f..48833170834c9dbd6c33587f08851217b7993874 100644 (file)
@@ -4713,11 +4713,46 @@ byte_xor_operation:
 ;; On i486, movl/sall appears slightly faster than leal, but the leal
 ;; is smaller - use leal for now unless the shift count is 1.
 
-(define_insn "ashlsi3"
+(define_expand "ashlsi3"
+  [(set (match_operand:SI 0 "nonimmediate_operand" "")
+       (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "")
+                  (match_operand:SI 2 "nonmemory_operand" "")))]
+  ""
+  "")
+
+;; For regsiter destinations:
+;;   add == 2 bytes, move == 2 bytes, shift == 3 bytes, lea == 7 bytes
+;;
+;;   lea loses when optimizing for size
+;;
+;; Do the math.  If the count is 1, using add, else using sal will
+;; produce the smallest possible code, even when the source and
+;; dest do not match.  For a memory destination, sal is the only
+;; choice.
+;;
+;; Do not try to handle case where src and dest do not match.  Let regmove
+;; and reload handle them.  A mov followed by this insn will generate the
+;; desired size optimized results.
+(define_insn ""
+  [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
+       (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0")
+                  (match_operand:SI 2 "nonmemory_operand" "cI")))]
+  "optimize_size"
+  "*
+{
+  if (REG_P (operands[0]) && operands[2] == const1_rtx)
+    return AS2 (add%L0,%0,%0);
+
+  if (REG_P (operands[2]))
+    return AS2 (sal%L0,%b2,%0);
+  return AS2 (sal%L0,%2,%0);
+}")
+
+(define_insn ""
   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
        (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "r,0")
                   (match_operand:SI 2 "nonmemory_operand" "M,cI")))]
-  ""
+  "! optimize_size"
   "*
 {
   if (REG_P (operands[0]) && REGNO (operands[0]) != REGNO (operands[1]))