shithub: scc

Download patch

ref: c56363ebc297fa01ebe8ee7b5ebb0626bc629676
parent: 9653030c822fa1a34b30b1e29fd1c7f4a545b7fc
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Jan 27 11:25:41 EST 2016

[cc1] Select branch or jump in For()

For can have a sustain condition or not,
and if it has not a condition then we have
to emit a jump, and otherwise a branch.

--- a/cc1/stmt.c
+++ b/cc1/stmt.c
@@ -110,7 +110,7 @@
 	stmt(end, begin, lswitch);
 	emit(OEXPR, einc);
 	emit(OLABEL, cond);
-	emit(OBRANCH, begin);
+	emit((econd) ? OBRANCH : OJUMP, begin);
 	emit(OEXPR, econd);
 	emit(OELOOP, NULL);
 	emit(OLABEL, end);
--- a/cc1/tests/test010.c
+++ b/cc1/tests/test010.c
@@ -42,7 +42,8 @@
 	j	L11
 
 L13
-	y	L11
+	j	L11
+
 	b
 L12
 	e