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]

the simple fix for the ia32 stack adjusts problem


Rather than dink with fragile code in combine and flow, this patch
just cleans up the mess with a peephole optimizer.  The advantage of
doing it that way is you combine all adjacent stack adjusts, including
the ones in prolog and epilog that combine never sees, and you only
combine adjacent stack adjusts so there can't be a problem with the
stack pointer being above live data.  The disadvantage is of course
that it doesn't help anyone else.

As a rough
indicator of the improvement you get in code size:

$ size cc1.old cc1
   text    data     bss     dec     hex filename
2101418   16152   96036 2213606  21c6e6 cc1.old
2091962   16152   96036 2204150  21a1f6 cc1

No measurable performance delta for the compiler - I'd be interested
to know how much it helps a smaller, less memory bound example.

Bootstraps successfully on i686-pc-linux-gnu, no regressions.

zw

	* config/i386/i386.md: Add peephole to merge successive stack
	adjusts.

===================================================================
Index: config/i386/i386.md
--- config/i386/i386.md	2000/01/11 18:01:35	1.128
+++ config/i386/i386.md	2000/01/15 02:36:22
@@ -8947,6 +8947,25 @@
   [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))
 	      (clobber (reg:CC 17))])]
   "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));")
+
+;; Merge two successive stack adjusts.  The combiner doesn't know how
+;; to do this, and doesn't see all of them.
+;; (reg:SI 7) is %esp.
+(define_peephole2
+  [(parallel[
+    (set (reg:SI 7)
+	 (plus:SI (reg:SI 7) (match_operand:SI 0 "const_int_operand" "")))
+    (clobber (reg:CC 17))])
+   (parallel[
+    (set (reg:SI 7)
+	 (plus:SI (reg:SI 7) (match_operand:SI 1 "const_int_operand" "")))
+    (clobber (reg:CC 17))])]
+  ""
+  [(parallel[
+    (set (reg:SI 7)
+	 (plus:SI (reg:SI 7) (match_dup 2)))
+    (clobber (reg:CC 17))])]
+  "operands[2] = GEN_INT (INTVAL (operands[0]) + INTVAL (operands[1]));")
 
 ;; Call-value patterns last so that the wildcard operand does not
 ;; disrupt insn-recog's switch tables.

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