Module: Mesa
Branch: master
Commit: 289cb6b59aea755ef5e60c711bb91d9f66b3c2af
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=289cb6b59aea755ef5e60c711bb91d9f66b3c2af

Author: Marcin Ślusarz <[email protected]>
Date:   Thu Jul 30 15:33:09 2020 +0200

intel/perf: don't generate logically dead code

When divisor is constant integer != 0 there's no point in checking
whether it's 0.

Complained about by Coverity.

Signed-off-by: Marcin Ślusarz <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6126>

---

 src/intel/perf/gen_perf.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/intel/perf/gen_perf.py b/src/intel/perf/gen_perf.py
index a64cb86a5f6..0d0aae90b5f 100644
--- a/src/intel/perf/gen_perf.py
+++ b/src/intel/perf/gen_perf.py
@@ -105,7 +105,11 @@ def emit_uadd(tmp_id, args):
 def emit_udiv(tmp_id, args):
     c("uint64_t tmp{0} = {1};".format(tmp_id, args[1]))
     c("uint64_t tmp{0} = {1};".format(tmp_id + 1, args[0]))
-    c("uint64_t tmp{0} = tmp{1} ? tmp{2} / tmp{1} : 0;".format(tmp_id + 2, 
tmp_id + 1, tmp_id))
+    if args[0].isdigit():
+        assert int(args[0]) > 0
+        c("uint64_t tmp{0} = tmp{2} / tmp{1};".format(tmp_id + 2, tmp_id + 1, 
tmp_id))
+    else:
+        c("uint64_t tmp{0} = tmp{1} ? tmp{2} / tmp{1} : 0;".format(tmp_id + 2, 
tmp_id + 1, tmp_id))
     return tmp_id + 3
 
 def emit_umul(tmp_id, args):

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to