scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 04bf83528662711fca73d47d49ef64fd39cf431c
parent 310831073070f33d03d475cab91fdba47d179272
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 26 Dec 2024 09:59:02 +0100

cc1: Avoid goto in for without conditions

The initial jump is emitted to reuse the condition for the
first iteration, but when we don't have condition it does
not make sense to emit that jump and make easier the life
of the backend.

Diffstat:
Msrc/cmd/scc-cc/cc1/stmt.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/cmd/scc-cc/cc1/stmt.c b/src/cmd/scc-cc/cc1/stmt.c @@ -139,7 +139,8 @@ For(Symbol *lbreak, Symbol *lcont, Switch *lswitch) einc = (yytoken != ')') ? simplify(expr()) : NULL; expect(')'); - emit(OJUMP, cond); + if (econd) + emit(OJUMP, cond); emit(OBLOOP, NULL); emit(OLABEL, begin);