]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Guard 2 peephole optimizations which should only work on the currently-last instructi...
authorWolfgang Bumiller <blub@speed.at>
Sun, 6 Jan 2013 23:22:54 +0000 (00:22 +0100)
committerWolfgang Bumiller <blub@speed.at>
Sun, 6 Jan 2013 23:22:54 +0000 (00:22 +0100)
Makefile
ir.c

index c5297d6bca36a06bbe53489bece99cc8428cbecd..532300385e8cf9bf520bec357bc77a7a6646a5ff 100644 (file)
--- 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 afe4a40d1d5258988dac2e665f43c75a37faca21..6ac74e868c5a8f0610a08d310d05499a87d4495d 100644 (file)
--- 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++;