scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit c56363ebc297fa01ebe8ee7b5ebb0626bc629676
parent 9653030c822fa1a34b30b1e29fd1c7f4a545b7fc
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 27 Jan 2016 16:25:41 +0100

[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.

Diffstat:
Mcc1/stmt.c | 2+-
Mcc1/tests/test010.c | 3++-
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/cc1/stmt.c b/cc1/stmt.c @@ -110,7 +110,7 @@ For(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) 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); diff --git a/cc1/tests/test010.c b/cc1/tests/test010.c @@ -42,7 +42,8 @@ L14 j L11 L13 - y L11 + j L11 + b L12 e