glsl: Resolve GCC sign-compare warning.
authorRhys Kidd <rhyskidd@gmail.com>
Tue, 8 Sep 2015 15:52:48 +0000 (23:52 +0800)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 10 Sep 2015 13:56:41 +0000 (14:56 +0100)
mesa/src/glsl/nir/nir_lower_tex_projector.c: In function 'nir_lower_tex_projector_block':
mesa/src/glsl/nir/nir_lower_tex_projector.c:63:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for (int i = 0; i < tex->num_srcs; i++) {
                         ^
mesa/src/glsl/nir/nir_lower_tex_projector.c: In function 'nir_lower_tex_projector_block':
mesa/src/glsl/nir/nir_lower_tex_projector.c:114:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for (int i = proj_index + 1; i < tex->num_srcs; i++) {
                                      ^
mesa/src/glsl/nir/nir_lower_tex_projector.c: In function 'nir_lower_tex_projector_block':
mesa/src/glsl/nir/nir_lower_tex_projector.c:53:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for (proj_index = 0; proj_index < tex->num_srcs; proj_index++) {
                                       ^
mesa/src/glsl/nir/nir_lower_tex_projector.c:57:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if (proj_index == tex->num_srcs)
                      ^
mesa/src/glsl/nir/nir_search.c: In function 'match_value':
mesa/src/glsl/nir/nir_search.c:84:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int i = 0; i < num_components; ++i)
                      ^
mesa/src/glsl/nir/nir_search.c: In function 'match_value':
mesa/src/glsl/nir/nir_search.c:110:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
          for (int i = 0; i < num_components; ++i) {
                            ^
mesa/src/glsl/nir/nir_search.c: In function 'match_value':
mesa/src/glsl/nir/nir_search.c:139:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (i < num_components)
                   ^
mesa/src/glsl/nir/nir_opt_peephole_ffma.c: In function 'get_mul_for_src':
mesa/src/glsl/nir/nir_opt_peephole_ffma.c:130:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (unsigned i = 0; i < num_components; i++)
                           ^

Signed-off-by: Rhys Kidd <rhyskidd@gmail.com>
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
src/glsl/nir/nir_lower_tex_projector.c
src/glsl/nir/nir_opt_peephole_ffma.c
src/glsl/nir/nir_search.c

index 8a482b182a9b927e7a741c846e6047c320eda49f..6530021c8b75a0a1182687edd0b8e57c6c157d6a 100644 (file)
@@ -49,7 +49,7 @@ nir_lower_tex_projector_block(nir_block *block, void *void_state)
       b->cursor = nir_before_instr(&tex->instr);
 
       /* Find the projector in the srcs list, if present. */
-      int proj_index;
+      unsigned proj_index;
       for (proj_index = 0; proj_index < tex->num_srcs; proj_index++) {
          if (tex->src[proj_index].src_type == nir_tex_src_projector)
             break;
@@ -60,7 +60,7 @@ nir_lower_tex_projector_block(nir_block *block, void *void_state)
          nir_frcp(b, nir_ssa_for_src(b, tex->src[proj_index].src, 1));
 
       /* Walk through the sources projecting the arguments. */
-      for (int i = 0; i < tex->num_srcs; i++) {
+      for (unsigned i = 0; i < tex->num_srcs; i++) {
          switch (tex->src[i].src_type) {
          case nir_tex_src_coord:
          case nir_tex_src_comparitor:
@@ -111,7 +111,7 @@ nir_lower_tex_projector_block(nir_block *block, void *void_state)
        */
       nir_instr_rewrite_src(&tex->instr, &tex->src[proj_index].src,
                             NIR_SRC_INIT);
-      for (int i = proj_index + 1; i < tex->num_srcs; i++) {
+      for (unsigned i = proj_index + 1; i < tex->num_srcs; i++) {
          tex->src[i-1].src_type = tex->src[i].src_type;
          nir_instr_move_src(&tex->instr, &tex->src[i-1].src, &tex->src[i].src);
       }
index a823adbb4651e7680167b0b958b9ce0f62228ec0..97538e5e64a449989b3c624afff467687bfe1406 100644 (file)
@@ -127,7 +127,7 @@ get_mul_for_src(nir_alu_src *src, int num_components,
     *   If we reuse swizzle in the loop, then output swizzle would be zyzz.
     */
    memcpy(swizzle_tmp, swizzle, 4*sizeof(uint8_t));
-   for (unsigned i = 0; i < num_components; i++)
+   for (int i = 0; i < num_components; i++)
       swizzle[i] = swizzle_tmp[src->swizzle[i]];
 
    return alu;
index c33d6c3eb840abe4fde9ca4bf3688f0662060f92..51e69b06d8c3f9ab27e44169864f0fbe7286a2a5 100644 (file)
@@ -81,7 +81,7 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
       swizzle = identity_swizzle;
    }
 
-   for (int i = 0; i < num_components; ++i)
+   for (unsigned i = 0; i < num_components; ++i)
       new_swizzle[i] = instr->src[src].swizzle[swizzle[i]];
 
    switch (value->type) {
@@ -107,7 +107,7 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
 
          assert(!instr->src[src].abs && !instr->src[src].negate);
 
-         for (int i = 0; i < num_components; ++i) {
+         for (unsigned i = 0; i < num_components; ++i) {
             if (state->variables[var->variable].swizzle[i] != new_swizzle[i])
                return false;
          }
@@ -135,7 +135,7 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
          state->variables[var->variable].abs = false;
          state->variables[var->variable].negate = false;
 
-         for (int i = 0; i < 4; ++i) {
+         for (unsigned i = 0; i < 4; ++i) {
             if (i < num_components)
                state->variables[var->variable].swizzle[i] = new_swizzle[i];
             else