[Mesa-dev] [PATCH 4/9] draw, gallivm, llvmpipe: Avoid implicit casts of 32-bit shifts to 64-bits.

jfonseca at vmware.com jfonseca at vmware.com
Wed Nov 26 10:47:26 PST 2014


From: José Fonseca <jfonseca at vmware.com>

Addresses MSVC warnings "result of 32-bit shift implicitly converted to
64 bits (was 64-bit shift intended?)", which can often be symptom of
bugs, but in these cases were all benign.
---
 src/gallium/auxiliary/draw/draw_llvm.c        | 4 ++--
 src/gallium/auxiliary/gallivm/lp_bld_arit.c   | 2 +-
 src/gallium/auxiliary/gallivm/lp_bld_sample.c | 2 +-
 src/gallium/drivers/llvmpipe/lp_setup_tri.c   | 4 ++--
 src/gallium/drivers/llvmpipe/lp_state_fs.c    | 8 ++++----
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index a2e6112..dbaece3 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1269,7 +1269,7 @@ generate_clipmask(struct draw_llvm *llvm,
             test = lp_build_compare(gallivm, f32_type, PIPE_FUNC_GREATER, zero, clipdist);
             is_nan_or_inf = lp_build_is_inf_or_nan(gallivm, vs_type, clipdist);
             test = LLVMBuildOr(builder, test, is_nan_or_inf, "");
-            temp = lp_build_const_int_vec(gallivm, i32_type, 1 << plane_idx);
+            temp = lp_build_const_int_vec(gallivm, i32_type, 1LL << plane_idx);
             test = LLVMBuildAnd(builder, test, temp, "");
             mask = LLVMBuildOr(builder, mask, test, "");
          } else {
@@ -1305,7 +1305,7 @@ generate_clipmask(struct draw_llvm *llvm,
             sum = LLVMBuildFAdd(builder, sum, test, "");
 
             test = lp_build_compare(gallivm, f32_type, PIPE_FUNC_GREATER, zero, sum);
-            temp = lp_build_const_int_vec(gallivm, i32_type, 1 << plane_idx);
+            temp = lp_build_const_int_vec(gallivm, i32_type, 1LL << plane_idx);
             test = LLVMBuildAnd(builder, test, temp, "");
             mask = LLVMBuildOr(builder, mask, test, "");
          }
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index 87da355..cd05f11 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -932,7 +932,7 @@ lp_build_mul_norm(struct gallivm_state *gallivm,
     * half = sgn(ab) * 0.5 * (2 ** n) = sgn(ab) * (1 << (n - 1))
     */
 
-   half = lp_build_const_int_vec(gallivm, wide_type, 1 << (n - 1));
+   half = lp_build_const_int_vec(gallivm, wide_type, 1LL << (n - 1));
    if (wide_type.sign) {
       LLVMValueRef minus_half = LLVMBuildNeg(builder, half, "");
       LLVMValueRef sign = lp_build_shr_imm(&bld, ab, wide_type.width - 1);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
index 85c0d4e..8cee994 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
@@ -1641,7 +1641,7 @@ lp_build_cube_lookup(struct lp_build_sample_context *bld,
    LLVMValueRef ma, mai, signma, signmabit, imahalfpos;
    LLVMValueRef posHalf = lp_build_const_vec(gallivm, coord_bld->type, 0.5);
    LLVMValueRef signmask = lp_build_const_int_vec(gallivm, intctype,
-                                                  1 << (intctype.width - 1));
+                                                  1LL << (intctype.width - 1));
    LLVMValueRef signshift = lp_build_const_int_vec(gallivm, intctype,
                                                    intctype.width -1);
    LLVMValueRef facex = lp_build_const_int_vec(gallivm, intctype, PIPE_TEX_FACE_POS_X);
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index 900df71..a2f55ed 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -760,8 +760,8 @@ lp_setup_bin_triangle( struct lp_setup_context *setup,
             for (i = 0; i < nr_planes; i++) {
                int64_t planeout = cx[i] + eo[i];
                int64_t planepartial = cx[i] + ei[i] - 1;
-               out |= (planeout >> 63);
-               partial |= (planepartial >> 63) & (1<<i);
+               out |= (int) (planeout >> 63);
+               partial |= ((int) (planepartial >> 63)) & (1<<i);
             }
 
             if (out) {
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 0fc3686..a68b274 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -174,10 +174,10 @@ generate_quad_mask(struct gallivm_state *gallivm,
 
    for (i = 0; i < fs_type.length / 4; i++) {
       unsigned j = 2 * (i % 2) + (i / 2) * 8;
-      bits[4*i + 0] = LLVMConstInt(i32t, 1 << (j + 0), 0);
-      bits[4*i + 1] = LLVMConstInt(i32t, 1 << (j + 1), 0);
-      bits[4*i + 2] = LLVMConstInt(i32t, 1 << (j + 4), 0);
-      bits[4*i + 3] = LLVMConstInt(i32t, 1 << (j + 5), 0);
+      bits[4*i + 0] = LLVMConstInt(i32t, 1ULL << (j + 0), 0);
+      bits[4*i + 1] = LLVMConstInt(i32t, 1ULL << (j + 1), 0);
+      bits[4*i + 2] = LLVMConstInt(i32t, 1ULL << (j + 4), 0);
+      bits[4*i + 3] = LLVMConstInt(i32t, 1ULL << (j + 5), 0);
    }
    mask = LLVMBuildAnd(builder, mask, LLVMConstVector(bits, fs_type.length), "");
 
-- 
1.9.1



More information about the mesa-dev mailing list