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

Jordan Justen jljusten at gmail.com
Sat Sep 27 08:09:46 PDT 2014


On Fri, Sep 26, 2014 at 6:09 PM, Matt Turner <mattst88 at gmail.com> wrote:
> ... 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.

No cliff notes version? :)

Is it something that you could give a few lines of code that reproduce it?

Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

>  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
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list