[Mono-bugs] [Bug 23797] New - Conditional branch optimizations

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
23 Apr 2002 21:12:05 -0000


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 dihlewis@yahoo.co.uk.

http://bugzilla.ximian.com/show_bug.cgi?id=23797

--- shadow/23797	Tue Apr 23 17:12:05 2002
+++ shadow/23797.tmp.20322	Tue Apr 23 17:12:05 2002
@@ -0,0 +1,52 @@
+Bug#: 23797
+Product: Mono/MCS
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: dihlewis@yahoo.co.uk               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Conditional branch optimizations
+
+1.  if (a == b) { }
+
+Under mcs, this statement is compiled as:
+
+    IL_0004:  ldloc.0
+    IL_0005:  ldloc.1
+    IL_0006:  ceq
+    IL_0008:  brfalse    IL_0012
+
+But csc reduces [ceq, brfalse] to bne:
+
+    IL_0004:  ldloc.0
+    IL_0005:  ldloc.1
+    IL_0006:  bne.un.s   IL_000d
+
+2   if (a != b)
+
+Under mcs:
+
+    IL_0004:  ldloc.0
+    IL_0005:  ldloc.1
+    IL_0006:  ceq
+    IL_0008:  ldc.i4.0
+    IL_0009:  ceq
+    IL_000b:  brfalse    IL_0015
+
+Now csc collapses the last four instructions to a beq:
+
+    IL_0004:  ldloc.0
+    IL_0005:  ldloc.1
+    IL_0006:  beq.s      IL_000d
+
+These are very common operations, so it would probably be worth the 
+optimization effort.