[Mesa-dev] [PATCH] i965/compaction: Avoid (unexpected) unsigned division.

Matt Turner mattst88 at gmail.com
Fri Sep 26 18:09:50 PDT 2014


... which leads to incorrect results on 32-bit x86.

Reported-by: Mark Janes <mark.a.janes at intel.com>
---
I tried writing up a nice commit message that explained what was going
on and why this worked on 64-bit, but then I realized that it was taking
orders of magnitude longer than the fix itself and probably no one would
care anyway.

 src/mesa/drivers/dri/i965/brw_eu_compact.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu_compact.c b/src/mesa/drivers/dri/i965/brw_eu_compact.c
index 114d18f..3f655ac 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_compact.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_compact.c
@@ -1445,8 +1445,8 @@ brw_compact_instructions(struct brw_compile *p, int start_offset,
             assert(brw_inst_src1_reg_file(brw, insn) == BRW_IMMEDIATE_VALUE);
 
             int jump = brw_inst_imm_d(brw, insn);
-            int jump_compacted = jump / sizeof(brw_compact_inst);
-            int jump_uncompacted = jump / sizeof(brw_inst);
+            int jump_compacted = jump / (int)sizeof(brw_compact_inst);
+            int jump_uncompacted = jump / (int)sizeof(brw_inst);
 
             target_old_ip = this_old_ip + jump_uncompacted;
             target_compacted_count = compacted_counts[target_old_ip];
-- 
1.8.5.5



More information about the mesa-dev mailing list