git: 9front

Download patch

ref: f6bff3c0830c1fe63dc45cd84d0a0a3a67b0cdf0
parent: 0d88e7d3d41b99d31f1fd0d61b1e4ad439415e1a
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Mon Apr 29 16:15:40 EDT 2013

5c: dont emit conditional integer division instructions

the integer division instructions are emulated with _div()
function patched in by 5l which does not handle conditional
execution. so do not optimize away the branch in that case.

--- a/sys/src/cmd/5c/peep.c
+++ b/sys/src/cmd/5c/peep.c
@@ -1354,6 +1354,15 @@
 			j->end = r->s2;
 			return Branch;
 		}
+		switch(r->prog->as){
+		case ADIV:
+		case ADIVU:
+		case AMOD:
+		case AMODU:
+			/* emulated by 5l, doesnt handle conditionals */
+			j->end = r->s1;
+			return Toolong;
+		}
 		if (modifiescpsr(r->prog)) {
 			j->end = r->s1;
 			return Setcond;
--