Mesa (master): i965/fs: If we see a RCP of a constant, try to constant fold it.

Eric Anholt anholt at kemper.freedesktop.org
Fri Jul 29 19:37:59 UTC 2011


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

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Jul 22 16:18:39 2011 -0700

i965/fs: If we see a RCP of a constant, try to constant fold it.

---

 src/mesa/drivers/dri/i965/brw_fs.cpp |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 9c3180f..351d1dd 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1056,6 +1056,20 @@ fs_visitor::propagate_constants()
 		  progress = true;
 	       }
 	       break;
+
+	    case FS_OPCODE_RCP:
+	       /* The hardware doesn't do math on immediate values
+		* (because why are you doing that, seriously?), but
+		* the correct answer is to just constant fold it
+		* anyway.
+		*/
+	       assert(i == 0);
+	       if (inst->src[0].imm.f != 0.0f) {
+		  scan_inst->opcode = BRW_OPCODE_MOV;
+		  scan_inst->src[0] = inst->src[0];
+		  progress = true;
+	       }
+	       break;
 	    }
 	 }
 




More information about the mesa-commit mailing list