gallium/freedreno: move cast to avoid integer overflow
authorEric Engestrom <eric@engestrom.ch>
Sat, 30 Jul 2016 00:33:56 +0000 (01:33 +0100)
committerRob Clark <robdclark@gmail.com>
Sat, 30 Jul 2016 13:23:42 +0000 (09:23 -0400)
Previously, the bitshift would be performed on a simple int (32 bits on
most systems), overflow, and then be cast to 64 bits.

CovID: 1362461
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/a2xx/fd2_compiler.c

index 6829544d354a624ca77cbfc8c43ba5824809b702..39418fca41f4985a00ce05d89a47fe0ad167337b 100644 (file)
@@ -402,10 +402,10 @@ add_src_reg(struct fd2_compile_context *ctx, struct ir2_instruction *alu,
        swiz[3] = swiz_vals[src->SwizzleW];
        swiz[4] = '\0';
 
-       if ((ctx->need_sync & (uint64_t)(1 << num)) &&
+       if ((ctx->need_sync & ((uint64_t)1 << num)) &&
                        !(flags & IR2_REG_CONST)) {
                alu->sync = true;
-               ctx->need_sync &= ~(uint64_t)(1 << num);
+               ctx->need_sync &= ~((uint64_t)1 << num);
        }
 
        return ir2_reg_create(alu, num, swiz, flags);