shithub: riscv

Download patch

ref: ce62bbb8539eaa56c6646da3d445d968dabec99f
parent: b325475fc8da20bf15e95ab3e45cc9533061bec1
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;
--