X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fdri%2Fi965%2Fbrw_fs_combine_constants.cpp;h=5bd5343b8b4436adf8a20569d92c0466387c4d4b;hb=55364ab5b7136e09a61d858f1167dee81e17bd9f;hp=c3ad7ad4771acc466a00b637a9c3c605eb3d05d3;hpb=179fc4aae8f782453f0488e8dd508f9a01117376;p=mesa.git diff --git a/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp b/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp index c3ad7ad4771..5bd5343b8b4 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp @@ -35,11 +35,12 @@ */ #include "brw_fs.h" -#include "brw_fs_live_variables.h" #include "brw_cfg.h" using namespace brw; +static const bool debug = false; + /* Returns whether an instruction could co-issue if its immediate source were * replaced with a GRF source. */ @@ -146,8 +147,6 @@ struct table { static struct imm * find_imm(struct table *table, float val) { - assert(signbit(val) == 0); - for (int i = 0; i < table->len; i++) { if (table->imm[i].val == val) { return &table->imm[i]; @@ -219,7 +218,8 @@ fs_visitor::opt_combine_constants() inst->src[i].type != BRW_REGISTER_TYPE_F) continue; - float val = fabsf(inst->src[i].f); + float val = !inst->can_do_source_mods(devinfo) ? inst->src[i].f : + fabs(inst->src[i].f); struct imm *imm = find_imm(&table, val); if (imm) { @@ -266,9 +266,8 @@ fs_visitor::opt_combine_constants() if (cfg->num_blocks != 1) qsort(table.imm, table.len, sizeof(struct imm), compare); - /* Insert MOVs to load the constant values into GRFs. */ - fs_reg reg(VGRF, alloc.allocate(dispatch_width / 8)); + fs_reg reg(VGRF, alloc.allocate(1)); reg.stride = 0; for (int i = 0; i < table.len; i++) { struct imm *imm = &table.imm[i]; @@ -284,8 +283,8 @@ fs_visitor::opt_combine_constants() imm->subreg_offset = reg.subreg_offset; reg.subreg_offset += sizeof(float); - if ((unsigned)reg.subreg_offset == dispatch_width * sizeof(float)) { - reg.nr = alloc.allocate(dispatch_width / 8); + if ((unsigned)reg.subreg_offset == 8 * sizeof(float)) { + reg.nr = alloc.allocate(1); reg.subreg_offset = 0; } } @@ -300,7 +299,26 @@ fs_visitor::opt_combine_constants() reg->subreg_offset = table.imm[i].subreg_offset; reg->stride = 0; reg->negate = signbit(reg->f) != signbit(table.imm[i].val); - assert(fabsf(reg->f) == table.imm[i].val); + assert((isnan(reg->f) && isnan(table.imm[i].val)) || + fabsf(reg->f) == fabs(table.imm[i].val)); + } + } + + if (debug) { + for (int i = 0; i < table.len; i++) { + struct imm *imm = &table.imm[i]; + + printf("%.3fF - block %3d, reg %3d sub %2d, Uses: (%2d, %2d), " + "IP: %4d to %4d, length %4d\n", + imm->val, + imm->block->num, + imm->nr, + imm->subreg_offset, + imm->must_promote, + imm->uses_by_coissue, + imm->first_use_ip, + imm->last_use_ip, + imm->last_use_ip - imm->first_use_ip); } }