i965/fs: If we see a RCP of a constant, try to constant fold it.
authorEric Anholt <eric@anholt.net>
Fri, 22 Jul 2011 23:18:39 +0000 (16:18 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 29 Jul 2011 19:17:03 +0000 (12:17 -0700)
src/mesa/drivers/dri/i965/brw_fs.cpp

index 9c3180fbc1c10743cc7d039d7366799e625870c9..351d1dd283e6a7384df5cfc1e8119eeb43ca9e6a 100644 (file)
@@ -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;
            }
         }