Merge branch 'cleanup' of git://github.com/graphitemaster/gmqcc into cleanup
authorWolfgang Bumiller <wry.git@bumiller.com>
Sun, 1 Feb 2015 11:13:59 +0000 (12:13 +0100)
committerWolfgang Bumiller <wry.git@bumiller.com>
Sun, 1 Feb 2015 11:13:59 +0000 (12:13 +0100)
fold.cpp
ir.cpp

index 658ec382e342d10ce2ed91e2be611d0acd82eed6..f5a1b310ee304ecf0a4b6a4861e52df13bef6498 100644 (file)
--- a/fold.cpp
+++ b/fold.cpp
@@ -1338,11 +1338,15 @@ ast_expression *fold::op_cmp(ast_value *a, ast_value *b, bool ne) {
             float la = immvalue_float(a);
             float lb = immvalue_float(b);
             check_inexact_float(a, b);
-            return (ast_expression*)m_imm_float[!(ne ? la == lb : la != lb)];
-        } if (isvector(a) && isvector(b)) {
+            return (ast_expression*)m_imm_float[ne ? la != lb : la == lb];
+        } else if (isvector(a) && isvector(b)) {
             vec3_t la = immvalue_vector(a);
             vec3_t lb = immvalue_vector(b);
-            return (ast_expression*)m_imm_float[!(ne ? vec3_cmp(la, lb) : !vec3_cmp(la, lb))];
+            bool compare = vec3_cmp(la, lb);
+            return (ast_expression*)m_imm_float[ne ? !compare : compare];
+        } else if (isstring(a) && isstring(b)) {
+            bool compare = !strcmp(immvalue_string(a), immvalue_string(b));
+            return (ast_expression*)m_imm_float[ne ? !compare : compare];
         }
     }
     return nullptr;
diff --git a/ir.cpp b/ir.cpp
index 044b834bf0e8a0d1a9c745f016015d16e65e0f96..d11bbb795e0335e491ad4b2279abdffd21484a9a 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -3436,6 +3436,8 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc
     {
         ir_value_code_setaddr(global, self->m_code->globals.size());
         if (global->m_hasvalue) {
+            if (global->m_cvq == CV_CONST && global->m_reads.empty())
+                return true;
             iptr = (int32_t*)&global->m_constval.ivec[0];
             self->m_code->globals.push_back(*iptr);
         } else {
@@ -3451,6 +3453,8 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc
     {
         ir_value_code_setaddr(global, self->m_code->globals.size());
         if (global->m_hasvalue) {
+            if (global->m_cvq == CV_CONST && global->m_reads.empty())
+                return true;
             uint32_t load = code_genstring(self->m_code.get(), global->m_constval.vstring);
             self->m_code->globals.push_back(load);
         } else {