vc4: Add algebraic opt for rcp(1.0).
authorEric Anholt <eric@anholt.net>
Wed, 19 Aug 2015 05:19:12 +0000 (22:19 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 21 Aug 2015 06:43:04 +0000 (23:43 -0700)
We're generating rcps as part of backend lowering of the packed coordinate
in the CS, and we don't want to lower them in NIR because of the extra
newton-raphson steps in the common case.  However, GLB2.7 is moving a
vertex attribute with a 1.0 W component to the position, and that makes us
produce some silly RCPs.

total instructions in shared programs: 97590 -> 97580 (-0.01%)
instructions in affected programs:     74 -> 64 (-13.51%)

src/gallium/drivers/vc4/vc4_opt_algebraic.c

index 77028bc026f666444d6a672367e429814ff6d157..5b435832b92fa6f78d0a1e501096146bd8fd7b49 100644 (file)
@@ -275,6 +275,14 @@ qir_opt_algebraic(struct vc4_compile *c)
                         }
                         break;
 
+                case QOP_RCP:
+                        if (is_1f(c, inst->src[0])) {
+                                replace_with_mov(c, inst, inst->src[0]);
+                                progress = true;
+                                break;
+                        }
+                        break;
+
                 default:
                         break;
                 }