From: Wolfgang Bumiller Date: Sun, 6 Jan 2013 23:22:54 +0000 (+0100) Subject: Guard 2 peephole optimizations which should only work on the currently-last instructi... X-Git-Tag: before-library~353^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=99249c8fa346d05e3d37d4c8ba532b86e54e2439;p=xonotic%2Fgmqcc.git Guard 2 peephole optimizations which should only work on the currently-last instruction by a check if it's actually really at the end... --- diff --git a/Makefile b/Makefile index c5297d6..5323003 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ CYGWIN = $(findstring CYGWIN, $(UNAME)) MINGW = $(findstring MINGW32, $(UNAME)) CC ?= clang -CFLAGS += -Wall -Wextra -I. -fno-strict-aliasing -fsigned-char -O2 +CFLAGS += -Wall -Wextra -I. -fno-strict-aliasing -fsigned-char CFLAGS += -DGMQCC_GITINFO="`git describe`" #turn on tons of warnings if clang is present # but also turn off the STUPID ONES diff --git a/ir.c b/ir.c index afe4a40..6ac74e8 100644 --- a/ir.c +++ b/ir.c @@ -2884,7 +2884,7 @@ tailcall: if (onfalse->generated) { /* fixup the jump address */ code_statements[stidx].o2.s1 = (onfalse->code_start) - (stidx); - if (code_statements[stidx].o2.s1 == 1) { + if (stidx+2 == vec_size(code_statements) && code_statements[stidx].o2.s1 == 1) { code_statements[stidx] = code_statements[stidx+1]; if (code_statements[stidx].o1.s1 < 0) code_statements[stidx].o1.s1++; @@ -2909,7 +2909,7 @@ tailcall: code_push_statement(&stmt, instr->context.line); return true; } - else if (code_statements[stidx].o2.s1 == 1) { + else if (stidx+2 == vec_size(code_statements) && code_statements[stidx].o2.s1 == 1) { code_statements[stidx] = code_statements[stidx+1]; if (code_statements[stidx].o1.s1 < 0) code_statements[stidx].o1.s1++;