nv50: check for immediates when turning MUL ADD into MAD
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Sun, 12 Sep 2010 17:43:22 +0000 (19:43 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Mon, 13 Sep 2010 15:26:41 +0000 (17:26 +0200)
src/gallium/drivers/nv50/nv50_pc_optimize.c

index ea1da62..fba6098 100644 (file)
@@ -562,6 +562,11 @@ constant_expression(struct nv_pc *pc, struct nv_instruction *nvi,
       nvi->src[0] = nvi->src[2];
       nvi->src[2] = NULL;
       nvi->opcode = NV_OP_ADD;
+
+      if (val->reg.imm.u32 == 0) {
+         nvi->src[1] = NULL;
+         nvi->opcode = NV_OP_MOV;
+      }
    }
 }
 
@@ -703,6 +708,10 @@ nv_pass_lower_arith(struct nv_pass *ctx, struct nv_basic_block *b)
       else
          continue;
 
+      /* could have an immediate from above constant_*  */
+      if (src0->reg.file != NV_FILE_GPR || src1->reg.file != NV_FILE_GPR)
+         continue;
+
       nvi->opcode = NV_OP_MAD;
       mod = nvi->src[(src == src0) ? 0 : 1]->mod;
       nv_reference(ctx->pc, &nvi->src[(src == src0) ? 0 : 1], NULL);