[Mono-bugs] [Bug 61641][Wis] New - Bad register allocation with `if' statements
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Thu, 15 Jul 2004 16:52:55 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by bmaurer@users.sf.net.
http://bugzilla.ximian.com/show_bug.cgi?id=61641
--- shadow/61641 2004-07-15 16:52:55.000000000 -0400
+++ shadow/61641.tmp.18647 2004-07-15 16:52:55.000000000 -0400
@@ -0,0 +1,110 @@
+Bug#: 61641
+Product: Mono: Runtime
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: bmaurer@users.sf.net
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Bad register allocation with `if' statements
+
+Consider this program:
+
+class T {
+ static void Main () {
+ T t = new T ();
+ t.X ();
+ }
+
+ void X ()
+ {
+ for (int i = 0; i < 10000; i ++) {
+ {
+ int x;
+ if (i == 1) x = 1;
+ else x = 2;
+
+ for (; x < 10000; x ++);
+ }
+ {
+ int x;
+ if (i == 1) x = 1;
+ else x = 2;
+
+ for (; x < 10000; x ++);
+ }
+ {
+ int x;
+ if (i == 1) x = 1;
+ else x = 2;
+
+ for (; x < 10000; x ++);
+ }
+ {
+ int x;
+ if (i == 1) x = 1;
+ else x = 2;
+
+ for (; x < 10000; x ++);
+ }
+ {
+ int x;
+ if (i == 1) x = 1;
+ else x = 2;
+
+ for (; x < 10000; x ++);
+ }
+ {
+ int x;
+ if (i == 1) x = 1;
+ else x = 2;
+
+ for (; x < 10000; x ++);
+ }
+ {
+ int x;
+ if (i == 1) x = 1;
+ else x = 2;
+
+ for (; x < 10000; x ++);
+ }
+ {
+ int x;
+ if (i == 1) x = 1;
+ else x = 2;
+
+ for (; x < 10000; x ++);
+ }
+ }
+ }
+}
+
+In this test case, most of the `x' variables are sored in the stack rather
+than in registers. (NB: you have to run -O=deadce to give it a fair chance
+-- 0 initting would cause all the live ranges to overlap)
+
+What is happening is that the variables have overlapping live ranges:
+
+If you enable the debugging flags in linear-scan.c, you get:
+
+ start end
+ dfn inst dfn inst
+VAR 1 00010009 0033ffff C69
+VAR 2 00040000 0033ffff C43
+VAR 3 00090000 0032ffff C43
+VAR 4 000e0000 0031ffff C43
+VAR 5 00130000 0030ffff C43
+VAR 6 00180000 002fffff C43
+VAR 7 001d0000 002effff C43
+VAR 8 00220000 002dffff C43
+VAR 9 00270000 002cffff C43
+
+As you can see, the `x' variables all have overlapping live ranges.