Mesa (master): r600g: optimize away CF ALU instructions even if type doesn' t match

Christian König deathsimple at kemper.freedesktop.org
Thu Jan 13 18:41:20 UTC 2011


Module: Mesa
Branch: master
Commit: 236e99fe05a8d301f81ca4330bf4ded80cf501a2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=236e99fe05a8d301f81ca4330bf4ded80cf501a2

Author: Christian König <deathsimple at vodafone.de>
Date:   Sat Dec 18 00:45:59 2010 +0100

r600g: optimize away CF ALU instructions even if type doesn't match

---

 src/gallium/drivers/r600/r600_asm.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_asm.c b/src/gallium/drivers/r600/r600_asm.c
index 57acb87..53122e5 100644
--- a/src/gallium/drivers/r600/r600_asm.c
+++ b/src/gallium/drivers/r600/r600_asm.c
@@ -539,16 +539,29 @@ int r600_bc_add_alu_type(struct r600_bc *bc, const struct r600_bc_alu *alu, int
 	memcpy(nalu, alu, sizeof(struct r600_bc_alu));
 	nalu->nliteral = 0;
 
+	if (bc->cf_last != NULL && bc->cf_last->inst != (type << 3)) {
+		/* check if we could add it anyway */
+		if (bc->cf_last->inst == (V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU << 3) &&
+			type == V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE) {
+			LIST_FOR_EACH_ENTRY(lalu, &bc->cf_last->alu, list) {
+				if (lalu->predicate) {
+					bc->force_add_cf = 1;
+					break;
+				}
+			}
+		} else
+			bc->force_add_cf = 1;
+	}
+
 	/* cf can contains only alu or only vtx or only tex */
-	if (bc->cf_last == NULL || bc->cf_last->inst != (type << 3) ||
-		bc->force_add_cf) {
+	if (bc->cf_last == NULL || bc->force_add_cf) {
 		r = r600_bc_add_cf(bc);
 		if (r) {
 			free(nalu);
 			return r;
 		}
-		bc->cf_last->inst = (type << 3);
 	}
+	bc->cf_last->inst = (type << 3);
 
 	/* Setup the kcache for this ALU instruction. This will start a new
 	 * ALU clause if needed. */




More information about the mesa-commit mailing list