i965/fs: Avoid register coalescing away gen6 MATH workarounds.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 19 Feb 2011 09:05:11 +0000 (01:05 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 22 Feb 2011 18:52:44 +0000 (10:52 -0800)
The code that generates MATH instructions attempts to work around
the hardware ignoring source modifiers (abs and negate) by emitting
moves into temporaries.  Unfortunately, this pass coalesced those
registers, restoring the original problem.  Avoid doing that.

Fixes several OpenGL ES2 conformance failures on Sandybridge.

NOTE: This is a candidate for the 7.10 branch.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_fs.cpp

index 66bbdbe80e673da3fd3311d47498a153e19acb6a..ed973f428f748b15470b5a3baa9c1d9cfcfa51f7 100644 (file)
@@ -3059,6 +3059,8 @@ fs_visitor::register_coalesce()
          inst->dst.type != inst->src[0].type)
         continue;
 
+      bool has_source_modifiers = inst->src[0].abs || inst->src[0].negate;
+
       /* Found a move of a GRF to a GRF.  Let's see if we can coalesce
        * them: check for no writes to either one until the exit of the
        * program.
@@ -3083,6 +3085,14 @@ fs_visitor::register_coalesce()
               break;
            }
         }
+
+        /* The gen6 MATH instruction can't handle source modifiers, so avoid
+         * coalescing those for now.  We should do something more specific.
+         */
+        if (intel->gen == 6 && scan_inst->is_math() && has_source_modifiers) {
+           interfered = true;
+           break;
+        }
       }
       if (interfered) {
         continue;