diff --git a/.pick_status.json b/.pick_status.json index 326a95e0de1..75db7b2dc36 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1144,7 +1144,7 @@ "description": "brw/algebraic: Don't optimize SEL.L.SAT or SEL.G.SAT", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "ca675b73d3ac2e1b57ec385c2c80b05b6382f6b6", "notes": null diff --git a/src/intel/compiler/brw/brw_opt_algebraic.cpp b/src/intel/compiler/brw/brw_opt_algebraic.cpp index 4a17a5855cc..ff1932e1def 100644 --- a/src/intel/compiler/brw/brw_opt_algebraic.cpp +++ b/src/intel/compiler/brw/brw_opt_algebraic.cpp @@ -553,39 +553,6 @@ brw_opt_algebraic(brw_shader &s) inst->predicate_inverse = false; inst->conditional_mod = BRW_CONDITIONAL_NONE; progress = true; - } else if (inst->saturate && inst->src[1].file == IMM) { - switch (inst->conditional_mod) { - case BRW_CONDITIONAL_LE: - case BRW_CONDITIONAL_L: - switch (inst->src[1].type) { - case BRW_TYPE_F: - if (inst->src[1].f >= 1.0f) { - inst = brw_transform_inst(s, inst, BRW_OPCODE_MOV); - inst->conditional_mod = BRW_CONDITIONAL_NONE; - progress = true; - } - break; - default: - break; - } - break; - case BRW_CONDITIONAL_GE: - case BRW_CONDITIONAL_G: - switch (inst->src[1].type) { - case BRW_TYPE_F: - if (inst->src[1].f <= 0.0f) { - inst = brw_transform_inst(s, inst, BRW_OPCODE_MOV); - inst->conditional_mod = BRW_CONDITIONAL_NONE; - progress = true; - } - break; - default: - break; - } - break; - default: - break; - } } break; case BRW_OPCODE_CSEL: diff --git a/src/intel/compiler/brw/test_opt_algebraic.cpp b/src/intel/compiler/brw/test_opt_algebraic.cpp index 397b6aefd90..68478600425 100644 --- a/src/intel/compiler/brw/test_opt_algebraic.cpp +++ b/src/intel/compiler/brw/test_opt_algebraic.cpp @@ -59,6 +59,27 @@ TEST_F(algebraic_test, fmax_a_a) EXPECT_NO_PROGRESS(brw_opt_algebraic, bld); } +TEST_F(algebraic_test, fmin_sat_a_1) +{ + brw_builder bld = make_shader(MESA_SHADER_FRAGMENT, 16); + + brw_reg dst0 = vgrf(bld, BRW_TYPE_F); + brw_reg src0 = vgrf(bld, BRW_TYPE_F); + + /* This is NaN. The definition of NAN in math.h has a scary comment about + * possibly raising an exception outside static initializers. + */ + bld.MOV(retype(src0, BRW_TYPE_UD), brw_imm_ud(0x7fc00000)); + bld.emit_minmax(dst0, src0, brw_imm_f(1.0), BRW_CONDITIONAL_L) + ->saturate = true; + + /* SEL.L of NaN should produce 1.0, and the .SAT should occur + * afterwards. This means the SEL.L.SAT cannot be optimized to a simple + * MOV.SAT since that would saturate NaN to 0.0 instead. + */ + EXPECT_NO_PROGRESS(brw_opt_algebraic, bld); +} + TEST_F(algebraic_test, mad_with_all_immediates) { brw_builder bld = make_shader();