vc4: Optimize SF(ITOF(x)) -> SF(x).
authorEric Anholt <eric@anholt.net>
Thu, 9 Oct 2014 07:36:03 +0000 (09:36 +0200)
committerEric Anholt <eric@anholt.net>
Thu, 9 Oct 2014 09:01:18 +0000 (11:01 +0200)
This is a common production of st_glsl_to_tgsi, because CMP takes a float
argument.

src/gallium/drivers/vc4/vc4_opt_algebraic.c

index 4155e72fd21676fa9328a56784dd56db114acb71..e247f302ee9000b4738fbc8441c5e0895207593f 100644 (file)
@@ -91,6 +91,22 @@ qir_opt_algebraic(struct vc4_compile *c)
                         defs[inst->dst.index] = inst;
 
                 switch (inst->op) {
+                case QOP_SF:
+                        /* SF just looks at the sign bit, or whether all the
+                         * bits are 0.  This is preserved across an itof
+                         * transformation.
+                         */
+                        if (inst->src[0].file == QFILE_TEMP &&
+                            defs[inst->src[0].index]->op == QOP_ITOF) {
+                                dump_from(c, inst);
+                                inst->src[0] =
+                                        defs[inst->src[0].index]->src[0];
+                                progress =  true;
+                                dump_to(c, inst);
+                                break;
+                        }
+                        break;
+
                 case QOP_SEL_X_Y_ZS:
                 case QOP_SEL_X_Y_ZC:
                 case QOP_SEL_X_Y_NS: