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

Author: Christoph Bumiller <e0425...@student.tuwien.ac.at>
Date:   Sat Jan  7 18:42:13 2012 +0100

nv50/ir/opt: optimize u32 MOD by power of 2 into AND

---

 .../drivers/nv50/codegen/nv50_ir_peephole.cpp      |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp 
b/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp
index 2a7a981..fc025d8 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp
@@ -698,6 +698,14 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue *src, 
int s)
       }
       break;
 
+   case OP_MOD:
+      if (i->sType == TYPE_U32 && imm.isPow2()) {
+         bld.setPosition(i, false);
+         i->op = OP_AND;
+         i->setSrc(1, bld.loadImm(NULL, imm.reg.data.u32 - 1));
+      }
+      break;
+
    case OP_SET: // TODO: SET_AND,OR,XOR
    {
       CmpInstruction *si = findOriginForTestWithZero(i->getSrc(t));

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to