Summary: | Compute shaders generate stupid divides | ||
---|---|---|---|
Product: | Mesa | Reporter: | Ian Romanick <idr> |
Component: | glsl-compiler | Assignee: | mesa-dev |
Status: | RESOLVED FIXED | QA Contact: | Intel 3D Bugs Mailing List <intel-3d-bugs> |
Severity: | enhancement | ||
Priority: | medium | CC: | eero.t.tamminen, jljusten, robclark |
Version: | git | ||
Hardware: | Other | ||
OS: | All | ||
See Also: | https://bugs.freedesktop.org/show_bug.cgi?id=98409 | ||
Whiteboard: | |||
i915 platform: | i915 features: |
Description
Ian Romanick
2016-10-17 22:29:04 UTC
In case it isn't obvious in the wall of shader code... these are the dumb divides: math intdiv(8) g6<1>D g4<8,8,1>D 1D { align1 1Q compacted }; math intdiv(8) g7<1>D g5<8,8,1>D 1D { align1 2Q compacted }; .... math intmod(8) g12<1>D g8<8,8,1>D 1D { align1 1Q compacted }; math intmod(8) g13<1>D g9<8,8,1>D 1D { align1 2Q compacted }; Rob Clark has some nir arithmetic optimizations that ought to fix this. "[RFC] nir/algebraic: support for power-of-two optimizations" I was going to pursue cleaning this code up, but (back then) it seemed better to just wait for Rob's patch. Any updates Rob? (In reply to Jordan Justen from comment #2) > Rob Clark has some nir arithmetic optimizations > that ought to fix this. Ah... I did not previously notice that the divides (and mods) exist in the NIR. I think I can propose a NIR algebraic optimization for x/1 and x%1 easy enough. :) Fixed by: commit 4d35683d91e3d61bf14b76d801bf6ae17237e162 Author: Ian Romanick <ian.d.romanick@intel.com> Date: Wed Oct 19 08:53:10 2016 -0700 nir: Optimize integer division and modulus with 1 The previous power-of-two rules didn't catch idiv (because i965 doesn't set lower_idiv) and imod cases. The udiv and umod cases should have been caught, but I included them for orthogonality. This fixes silly code observed from compute shaders with local_size_[xy] = 1. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98299 Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.