Mesa (master): r300/compiler: remove an unused-but-set variable and simplify the code

Marek Olšák mareko at kemper.freedesktop.org
Fri Jul 15 12:48:47 PDT 2011


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

Author: Marek Olšák <maraeo at gmail.com>
Date:   Fri Jul 15 20:52:16 2011 +0200

r300/compiler: remove an unused-but-set variable and simplify the code

---

 .../drivers/dri/r300/compiler/radeon_optimize.c    |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
index ac73608..b242742 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
@@ -560,7 +560,7 @@ static int peephole_add_presub_add(
 	struct radeon_compiler * c,
 	struct rc_instruction * inst_add)
 {
-	struct rc_src_register * src0 = NULL;
+	unsigned dstmask = inst_add->U.I.DstReg.WriteMask;
 	struct rc_src_register * src1 = NULL;
 	unsigned int i;
 
@@ -570,18 +570,15 @@ static int peephole_add_presub_add(
 	if (inst_add->U.I.SrcReg[0].Swizzle != inst_add->U.I.SrcReg[1].Swizzle)
 		return 0;
 
-	/* src0 and src1 can't have absolute values only one can be negative and they must be all negative or all positive. */
+	/* XXX This isn't fully implemented, is it? */
+	/*   src0 and src1 can't have absolute values only one can be negative and they must be all negative or all positive. */
 	for (i = 0; i < 2; i++) {
 		if (inst_add->U.I.SrcReg[i].Abs)
 			return 0;
-		if ((inst_add->U.I.SrcReg[i].Negate
-					& inst_add->U.I.DstReg.WriteMask) ==
-						inst_add->U.I.DstReg.WriteMask) {
-			src0 = &inst_add->U.I.SrcReg[i];
-		} else if (!src1) {
+
+		/* XXX This looks weird, but it's basically what was here before this commit (see git blame): */
+		if ((inst_add->U.I.SrcReg[i].Negate & dstmask) != dstmask && !src1) {
 			src1 = &inst_add->U.I.SrcReg[i];
-		} else {
-			src0 = &inst_add->U.I.SrcReg[i];
 		}
 	}
 



More information about the mesa-commit mailing list