Mesa (nv50-compiler): nv50: load address register before using it, not after

Christoph Bumiller chrisbmr at kemper.freedesktop.org
Fri Sep 3 12:27:16 UTC 2010


Module: Mesa
Branch: nv50-compiler
Commit: 9e4901402cf50405be28ce6311f10e22196fbc35
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9e4901402cf50405be28ce6311f10e22196fbc35

Author: Christoph Bumiller <e0425955 at student.tuwien.ac.at>
Date:   Fri Sep  3 14:26:47 2010 +0200

nv50: load address register before using it, not after

---

 src/gallium/drivers/nv50/nv50_tgsi_to_nc.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
index e1c6ed8..386dbda 100644
--- a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
+++ b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
@@ -1000,6 +1000,7 @@ emit_fetch(struct bld_context *bld, const struct tgsi_full_instruction *insn,
 {
    const struct tgsi_full_src_register *src = &insn->Src[s];
    struct nv_value *res;
+   struct nv_value *ptr = NULL;
    unsigned idx, swz, dim_idx, ind_idx, ind_swz;
    ubyte type = infer_src_type(insn->Instruction.Opcode);
 
@@ -1012,7 +1013,11 @@ emit_fetch(struct bld_context *bld, const struct tgsi_full_instruction *insn,
    if (src->Register.Indirect) {
       ind_idx = src->Indirect.Index;
       ind_swz = tgsi_util_get_src_register_swizzle(&src->Indirect, 0);
+
+      ptr = FETCH_ADDR(ind_idx, ind_swz);
    }
+   if (idx >= (128 / 4) && src->Register.File == TGSI_FILE_CONSTANT)
+      ptr = bld_get_address(bld, (idx * 16) & ~0x1ff, ptr);
 
    switch (src->Register.File) {
    case TGSI_FILE_CONSTANT:
@@ -1025,11 +1030,8 @@ emit_fetch(struct bld_context *bld, const struct tgsi_full_instruction *insn,
       res->reg.id = (idx * 4 + swz) & 127;
       res = bld_insn_1(bld, NV_OP_LDA, res);
 
-      if (src->Register.Indirect)
-         res->insn->src[4] = new_ref(bld->pc, FETCH_ADDR(ind_idx, ind_swz));
-      if (idx >= (128 / 4))
-         res->insn->src[4] =
-            new_ref(bld->pc, bld_get_address(bld, (idx * 16) & ~0x1ff, NULL));
+      if (ptr)
+         res->insn->src[4] = new_ref(bld->pc, ptr);
       break;
    case TGSI_FILE_IMMEDIATE:
       assert(idx < bld->ti->immd32_nr);




More information about the mesa-commit mailing list