i965/fs: Don't propagate cmod to inst with different type.
authorMatt Turner <mattst88@gmail.com>
Fri, 27 Feb 2015 18:22:21 +0000 (10:22 -0800)
committerMatt Turner <mattst88@gmail.com>
Wed, 4 Mar 2015 20:37:34 +0000 (12:37 -0800)
Cc: 10.5 <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89317
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp
src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp

index c6384ab53cf129a773d8bf9712f21a25e26164e0..58890ee9bede5086332ed9d8df526fbc513417bc 100644 (file)
@@ -80,6 +80,10 @@ opt_cmod_propagation_local(fs_visitor *v, bblock_t *block)
                 scan_inst->dst.reg_offset != inst->src[0].reg_offset)
                break;
 
+            /* Comparisons operate differently for ints and floats */
+            if (scan_inst->dst.type != inst->dst.type)
+               break;
+
             /* If the instruction generating inst's source also wrote the
              * flag, and inst is doing a simple .nz comparison, then inst
              * is redundant - the appropriate value is already in the flag
index fbe4fd90f86a66e15a0fa81e612556755a9a24c5..cb92abf43d14b23f21135b87d06b269c6b3b50e1 100644 (file)
@@ -415,3 +415,37 @@ TEST_F(cmod_propagation_test, movnz)
    EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 0)->opcode);
    EXPECT_EQ(BRW_CONDITIONAL_GE, instruction(block0, 0)->conditional_mod);
 }
+
+TEST_F(cmod_propagation_test, different_types_cmod_with_zero)
+{
+   fs_reg dest = v->vgrf(glsl_type::int_type);
+   fs_reg src0 = v->vgrf(glsl_type::int_type);
+   fs_reg src1 = v->vgrf(glsl_type::int_type);
+   fs_reg zero(0.0f);
+   v->emit(BRW_OPCODE_ADD, dest, src0, src1);
+   v->emit(BRW_OPCODE_CMP, v->reg_null_f, retype(dest, BRW_REGISTER_TYPE_F),
+                                          zero)
+      ->conditional_mod = BRW_CONDITIONAL_GE;
+
+   /* = Before =
+    *
+    * 0: add(8)        dest:D  src0:D  src1:D
+    * 1: cmp.ge.f0(8)  null:F  dest:F  0.0f
+    *
+    * = After =
+    * (no changes)
+    */
+
+   v->calculate_cfg();
+   bblock_t *block0 = v->cfg->blocks[0];
+
+   EXPECT_EQ(0, block0->start_ip);
+   EXPECT_EQ(1, block0->end_ip);
+
+   EXPECT_FALSE(cmod_propagation(v));
+   EXPECT_EQ(0, block0->start_ip);
+   EXPECT_EQ(1, block0->end_ip);
+   EXPECT_EQ(BRW_OPCODE_ADD, instruction(block0, 0)->opcode);
+   EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 1)->opcode);
+   EXPECT_EQ(BRW_CONDITIONAL_GE, instruction(block0, 1)->conditional_mod);
+}