i965: Fix brw_swap_cmod() for LE/GE comparisons.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 16 Jun 2012 09:08:13 +0000 (02:08 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 18 Jun 2012 22:25:31 +0000 (15:25 -0700)
The idea here is to rewrite comparisons like 2 >= x with x <= 2; we want
to simply exchange arguments, not negate the condition.  If equality was
part of the original comparison, it should remain part of the swapped
version.

This is the true cause of bug #50298.  It didn't manifest itself on
Sandybridge because we embed the conditional modifier in the IF
instruction rather than emitting a CMP.  All other platforms use CMP.

It also didn't manifest itself on the master branch because commit
be5f27a84d ("glsl: Refine the loop instruction counting.") papered over
the problem.

NOTE: This is a candidate for stable release branches.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=50298
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_eu.c

index 00b9671d828658fae330c2d5b805b03601d02e7d..2c432a92303c387a836c805dcb87e45bb40b2032 100644 (file)
@@ -47,13 +47,13 @@ brw_swap_cmod(uint32_t cmod)
    case BRW_CONDITIONAL_NZ:
       return cmod;
    case BRW_CONDITIONAL_G:
-      return BRW_CONDITIONAL_LE;
-   case BRW_CONDITIONAL_GE:
       return BRW_CONDITIONAL_L;
+   case BRW_CONDITIONAL_GE:
+      return BRW_CONDITIONAL_LE;
    case BRW_CONDITIONAL_L:
-      return BRW_CONDITIONAL_GE;
-   case BRW_CONDITIONAL_LE:
       return BRW_CONDITIONAL_G;
+   case BRW_CONDITIONAL_LE:
+      return BRW_CONDITIONAL_GE;
    default:
       return ~0;
    }