The remove_extra_rounding_modes() optimization will remove duplicated
rounding mode changes.

v2:
- Fix bug in the rounding mode change (Alejandro)

v3:
- Fix rounding modes.

Signed-off-by: Samuel Iglesias Gonsálvez <sigles...@igalia.com>
---
 src/intel/compiler/brw_fs.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index dfa6176340a..a5f5566951c 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -3449,9 +3449,20 @@ bool
 fs_visitor::remove_extra_rounding_modes()
 {
    bool progress = false;
+   unsigned execution_mode = 
this->nir->info.shader_float_controls_execution_mode;
+
+   brw_rnd_mode base_mode = BRW_RND_MODE_UNSPECIFIED;
+   if ((execution_mode & SHADER_ROUNDING_MODE_RTE_FP16) ||
+       (execution_mode & SHADER_ROUNDING_MODE_RTE_FP32) ||
+       (execution_mode & SHADER_ROUNDING_MODE_RTE_FP64))
+      base_mode = BRW_RND_MODE_RTNE;
+   if ((execution_mode & SHADER_ROUNDING_MODE_RTZ_FP16) ||
+       (execution_mode & SHADER_ROUNDING_MODE_RTZ_FP32) ||
+       (execution_mode & SHADER_ROUNDING_MODE_RTZ_FP64))
+      base_mode = BRW_RND_MODE_RTZ;
 
    foreach_block (block, cfg) {
-      brw_rnd_mode prev_mode = BRW_RND_MODE_UNSPECIFIED;
+      brw_rnd_mode prev_mode = base_mode;
 
       foreach_inst_in_block_safe (fs_inst, inst, block) {
          if (inst->opcode == SHADER_OPCODE_RND_MODE) {
-- 
2.19.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to