[Mono-bugs] [Bug 40225][Wis] New - A wish for the JIT: Encode x * -1 with NEG EAX on x86

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Mon, 24 Mar 2003 18:22:47 -0500 (EST)


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 mathias.hasselmann@gmx.de.

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

--- shadow/40225	Mon Mar 24 18:22:47 2003
+++ shadow/40225.tmp.11592	Mon Mar 24 18:22:47 2003
@@ -0,0 +1,37 @@
+Bug#: 40225
+Product: Mono/Runtime
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: mathias.hasselmann@gmx.de               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: A wish for the JIT: Encode x * -1 with NEG EAX on x86
+
+Just was writing some weird code and realized that the JIT would rock, if
+it could optimize multiplication with plus and minus one. Haven't measured
+yet, if using x86 instruction "NEG EAX" is faster than "IMUL EAX, -1", but
+if it is, this optimization could be worth the effort.
+
+Consider this code for instance:
+
+int direction = (foo ? +1 : -1);
+int end = (bar ? posA : posB);
+
+for (int offset = 42; direction * offset < direction * offset; )
+{
+     offset = computed();
+}
+
+This style of code just saved me lot of code duplication and it saved me
+alot of complex boolean evaluations. So my concrete code looks good
+already. Nevertheless my code would rock much more, if I knew Mono
+processes it efficently. ;o)