summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <tstellar@gmail.com>2010-09-09 19:13:57 -0700
committerTom Stellard <tstellar@gmail.com>2010-09-09 19:13:57 -0700
commitae77f68041cd0aa49887cf87c95b2a40d59d2061 (patch)
tree2eddedddb6145c39d5394cc238a4c3c662b2ca3b
parent865f1917adec327af5a9740d33144bc26602748c (diff)
r300/compiler: Reorganize presub_helper()presub-rebase-v2
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_optimize.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
index 9416400c8d4..5e3b21e577d 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
@@ -533,51 +533,45 @@ static int presub_helper(
for(inst = s->Inst->Next; inst != &c->Program.Instructions;
inst = inst->Next) {
unsigned int i;
+ unsigned char can_use_presub = 1;
const struct rc_opcode_info * info =
rc_get_opcode_info(inst->U.I.Opcode);
+ /* XXX: There are some situations where instructions
+ * with more than 2 src registers can use the
+ * presubtract select, but to keep things simple we
+ * will disable presubtract on these instructions for
+ * now. */
+ if (info->NumSrcRegs > 2 || info->HasTexture) {
+ can_use_presub = 0;
+ }
+
+ /* We can't use more than one presubtract value in an
+ * instruction, unless the two prsubtract operations
+ * are the same and read from the same registers. */
+ if (inst->U.I.PreSub.Opcode != RC_PRESUB_NONE) {
+ if (inst->U.I.PreSub.Opcode != presub_opcode
+ || inst->U.I.PreSub.SrcReg[0].File !=
+ s->Inst->U.I.SrcReg[1].File
+ || inst->U.I.PreSub.SrcReg[0].Index !=
+ s->Inst->U.I.SrcReg[1].Index) {
+ can_use_presub = 0;
+ }
+ }
+ /* Even if the instruction can't use a presubtract operation
+ * we still need to check if the instruction reads from
+ * s->Inst->U.I.DstReg, because if it does we must not
+ * remove s->Inst. */
for(i = 0; i < info->NumSrcRegs; i++) {
if(s->Inst->U.I.DstReg.WriteMask !=
src_reads_dst_mask(inst->U.I.SrcReg[i],
s->Inst->U.I.DstReg)) {
continue;
}
- if (cant_sub) {
- can_remove = 0;
- break;
- }
- /* XXX: There are some situations where instructions
- * with more than 2 src registers can use the
- * presubtract select, but to keep things simple we
- * will disable presubtract on these instructions for
- * now. Note: This if statement should not be pulled
- * outside of the loop, because it only applies to
- * instructions that could potentially use the
- * presubtract source. */
- if (info->NumSrcRegs > 2) {
+ if (cant_sub || !can_use_presub) {
can_remove = 0;
break;
}
-
- if (info->HasTexture) {
- can_remove = 0;
- break;
- }
-
- /* We can't use more than one presubtract value in an
- * instruction, unless the two prsubtract operations
- * are the same and read from the same registers. */
- if (inst->U.I.PreSub.Opcode != RC_PRESUB_NONE) {
- if (inst->U.I.PreSub.Opcode != presub_opcode
- || inst->U.I.PreSub.SrcReg[0].File !=
- s->Inst->U.I.SrcReg[1].File
- || inst->U.I.PreSub.SrcReg[0].Index !=
- s->Inst->U.I.SrcReg[1].Index) {
-
- can_remove = 0;
- break;
- }
- }
presub_replace(s, inst, i);
can_remove = 1;
}