aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: add NV_viewport_array2 supportIlia Mirkin2020-04-157-3/+141
| | | | | | | | | | This enables gl_Layer/gl_ViewportIndex when the ext is enabled, as well as adding the new gl_ViewportMask[] array and viewport_relative layout qualifier for gl_Layer. Signed-off-by: Ilia Mirkin <[email protected]> Acked-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4529>
* glsl/list: Fix undefined behaviour of foreach_* macrosDanylo Piliaiev2020-04-143-60/+352
| | | | | | | | | | | | | | | | | | | | | | | | | These macros produced a lot of errors with ubsan preventing us from expanding the ubsan coverage on CIs. C++ spec has such clause: "If the prvalue of type "pointer to cv1 B" points to a B that is actually a subobject of an object of type D, the resulting pointer points to the enclosing object of type D. Otherwise, the result of the cast is undefined." Ubsan error example: ../src/compiler/glsl/builtin_functions.cpp:4945:4: runtime error: downcast of address 0x559b926abb50 which does not point to an object of type 'ir_instruction' 0x559b926abb50: note: object has invalid vptr 9b 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 ba 6a 92 9b 55 00 00 01 00 00 00 ^~~~~~~~~~~~~~~~~~~~~~~ invalid vptr #0 0x559b914dbe1a in call ../src/compiler/glsl/builtin_functions.cpp:4945 Signed-off-by: Danylo Piliaiev <[email protected]> Acked-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4129>
* glsl: stop processing function parameters if error happenedTapani Pälli2020-04-131-0/+4
| | | | | | | | Fixes: d1fa69ed61d ("glsl: do not attempt assignment if operand type not parsed correctly") Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2696 Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4341>
* glsl: remove redudant assignmentTapani Pälli2020-04-121-1/+0
| | | | | | | CID: 1461087 Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Andres Gomez <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4500>
* glsl: don't limit fp16 lowering to fragRob Clark2020-04-041-1/+1
| | | | | | | | This restriction doesn't belong in core code. Signed-off-by: Rob Clark <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4423> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4423>
* glsl/lower_precision: Use vector.back() instead of vector.end()[-1]Neil Roberts2020-04-031-13/+13
| | | | | | | | | | | | | | | | The use of vector.end()[-1] seems to generate warnings in Coverity about not allowing a negative argument to a parameter. The intention with the code snippet is just to access the last element of the vector. The vector.back() call acheives the same thing, is clearer and will hopefully fix the Coverity warning. I’m not exactly sure why Coverity thinks the array index can’t be negative. cplusplus.com says that vector::end() returns a random access iterator and that the type of the array index operator argument to that should be the difference type for the container. It then also says that difference_type for a vector is "a signed integral type". Reviewed-by: Eric Anholt <[email protected]>
* glsl_to_nir: remove dead codeTimothy Arceri2020-04-021-142/+11
| | | | | | | | | | | This code was made unused by the changes described in be2990d8fbcd. NIR based Gallium drivers switched to the NIR based lowering in efa4fc0ebd96. Reviewed-by: Jason Ekstrand <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4415> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4415>
* nir: Use b2b opcodes for shared and constant memoryJason Ekstrand2020-03-301-2/+2
| | | | | | | | No shader-db changes on ICL with iris Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4338>
* meson: inline `inc_common`Eric Engestrom2020-03-283-11/+11
| | | | | | | | | Let's make it clear what includes are being added everywhere, so that they can be cleaned up. Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4360>
* Move compiler.h and imports.h/c from src/mesa/main into src/utilMarek Olšák2020-03-2713-13/+13
| | | | | Reviewed-by: Timothy Arceri <[email protected] Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4324>
* glsl: fix varying packing for 64bit integersTimothy Arceri2020-03-271-1/+1
| | | | | | | | | Without this we can incorrectly end up marking things as making use of ARB_enhanced_layouts style packing. Cc: 19.3 20.0 <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4328>
* glsl: set error_emitted true if type not ok for assignmentTapani Pälli2020-03-261-2/+5
| | | | | | | | | | | | | | Patch changes also existing assert to not trigger when we have error types in assignment. v2: simplify, cleanup (Ian) Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2629 Fixes: d1fa69ed61d ("glsl: do not attempt assignment if operand type not parsed correctly") Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4178> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4178>
* glsl/lower_precision: Lower builtins depending on argumentsNeil Roberts2020-03-241-2/+105
| | | | | | | | | | | | | | | | | | | | | | When an ir_call is encountered that invokes a builtin, it will now try to generate a lowered version of the builtin. This only happens if all of the arguments to the function are lowerable. Previously the builtin would be inlined before the lowering pass is invoked and then the implementation would be lowered as a consequence of the pass. However this causes problems if the builtin has multiple arguments and the implementation has operations on only a few of the arguments before combining it with the others. In that case the entire builtin should only be lowered if all of the arguments are lower precision. The previous approach would end up lowering only parts of the implementation. The lowered implementations are cached in a hash table in case they can be reused. Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3885> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3885>
* glsl: Inline builtins in a separate passNeil Roberts2020-03-245-5/+67
| | | | | | | | | | | | | | | Previously, the ir_call functions for builtin functions were replaced with the inline implementation immediately after being added to the instruction list. This patch replaces that with a separate pass that lowers them after the conversion from AST to IR is complete. This will be useful to be able to insert some handling for the precision lowering pass before the inlining. This needs to happen because the precision of the operations in the inlined implementation depends on the highest precision of all of the arguments to the call. Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3885>
* glsl: Add unit tests for the lower_precision passNeil Roberts2020-03-242-0/+400
| | | | | | | | | Adds a unit tests script that invokes the standalone compiler with --lower-precision and verifies that lowered operations are being used. Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3885>
* glsl/standalone: Add an option to lower the precisionNeil Roberts2020-03-243-0/+10
| | | | | | | | | | Adds a --lower-precision option that just sets the LowerPrecision compiler option. That way it can be used in unit tests to test the precision lowering pass. Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3885>
* glsl: Add an IR lowering pass to convert mediump operations to 16-bitNeil Roberts2020-03-245-0/+629
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This works by finding the first rvalue that it can lower using an ir_rvalue_visitor. In that case it adds a conversion to float16 after each rvalue and a conversion back to float before storing the assignment. Also it uses a set to keep track of rvalues that have been lowred already. The handle_rvalue method of the rvalue visitor doesn’t provide any way to stop iteration. If we handle a value in find_precision_visitor we want to be able to stop it from descending into the lowered rvalue again. Additionally this pass disallows converting nodes containing non-float. The can_lower_rvalue function explicitly excludes any branches that have non-float types except bools. This avoids the need to have special handling for functions that convert to int or double. Co-authored-by: Hyunjun Ko <[email protected]> v2. Adds lowering for texture samples v3. Instead of checking whether each node can be lowered while walking the tree, a separate tree walk is now done to check all of the nodes in a single pass. The lowerable nodes are added to a set which is checked during find_precision_visitor instead of calling can_lower_rvalue. v4. Move the special case for temporaries to find_lowerable_rvalues. This needs to be handled while checking for lowerable rvalues so that any later dereferences of the variable will see the right precision. v5. Add an override to visit ir_call instructions and apply the same technique to override the precision of the temporary variable in the same way as done for builtin temporaries and ir_assignment calls. v6. Changes the pass so that it doesn’t need to lower an entire subtree in order do perform a lowering. Instead, certain instructions can be marked as being indepedent of their child instructions. For example, this is the case with array dereferences. The precision of the array index doesn’t have any bearing on whether things using the result of the array deref can be lowered. Now, only toplevel lowerable nodes are added to the lowerable_rvalues instead instead of additionally adding all of the subnodes. It now also only needs one hash table instead of two. v7. Don’t try to lower sampler types. Instead, the sample instruction is now treated as an independent point where the result of the sample can be used in a lowered section. The precision of the sampler type determines the precision of the sample instruction. This also means the coordinates to the sampler can be lowered. v8. Use f2fmp instead of f2f16. v9. Disable lowering derivatives calcualtions, which might not work properly on some hw backends. Reviewed-by: Kristian H. Kristensen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3885>
* glsl/hierarchical_visitor: Call leave_callback on leaf nodesNeil Roberts2020-03-242-12/+20
| | | | | | | | | | | Previously for leaf ir_instructions only the enter callback was called. This makes it a bit difficult to make a pass that wants to visit every instruction using a stack. Making it call the leave callback as well makes it behave less surprisingly. Reviewed-by: Kristian H. Kristensen <[email protected]> Acked-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3885>
* glsl: Add a method to get precision from a deref instructionNeil Roberts2020-03-241-0/+28
| | | | | | | | | | | | Adds ir_dereference::precision(). For a normal variable dereference, the precision comes from the variable. For a record member it comes from the field within the record. For an array it can come from either, depending on where the underlying array is stored. The method recursively walks the derefs until it finds one of the first two. Reviewed-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3885>
* glsl: Restore the IsES flag on the shader when reading from cache.Eric Anholt2020-03-221-0/+2
| | | | | | | | | | | I found that when trying to MESA_SHADER_CAPTURE_PATH a trace, I was getting "GLSL >= 3.00" for the ES shaders I was trying to capture. Keeping this metadata in the cached shader program lets us capture correctly. Reviewed-by: Timothy Arceri <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4219> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4219>
* soft-fp64: Split a block that was missing a cast on a comparisonIan Romanick2020-03-181-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function has code like: if (0x7FD <= zExp) { if ((0x7FD < zExp) || ((zExp == 0x7FD) && (0x001FFFFFu == zFrac0 && 0xFFFFFFFFu == zFrac1) && increment)) { ... return ...; } if (zExp < 0) { I saw that, and I thought, "Uh... what? Dead code?" I thought it was a bit fishy, so I grabbed the Berkeley SoftFloat Library 3e code, and there is similar code in softfloat_roundPackToF64 (source/s_roundPackToF64.c), but it has an extra (uint16_t) cast in the first comparison. This is basicially a shortcut for if (zExp < 0 || zExp >= 0x7FD) { So, having the nesting kind of makes sense. On a CPU, nesting the flow control can be an optimization. On a GPU, it's just fail. Split the block so that we don't need the uint16_t cast magic. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 683638 -> 658127 (-3.73%) instructions in affected programs: 666839 -> 641328 (-3.83%) helped: 92 HURT: 0 helped stats (abs) min: 26 max: 2456 x̄: 277.29 x̃: 144 helped stats (rel) min: 3.21% max: 4.22% x̄: 3.79% x̃: 3.90% 95% mean confidence interval for instructions value: -345.84 -208.75 95% mean confidence interval for instructions %-change: -3.86% -3.73% Instructions are helped. total cycles in shared programs: 5458858 -> 5344600 (-2.09%) cycles in affected programs: 5360114 -> 5245856 (-2.13%) helped: 92 HURT: 0 helped stats (abs) min: 126 max: 10300 x̄: 1241.93 x̃: 655 helped stats (rel) min: 1.71% max: 2.37% x̄: 2.12% x̃: 2.17% 95% mean confidence interval for cycles value: -1539.93 -943.94 95% mean confidence interval for cycles %-change: -2.16% -2.08% Cycles are helped. Fixes: f111d72596c ("glsl: Add "built-in" functions to do add(fp64, fp64)") Reviewed-by: Matt Turner <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fadd: Common code optimization for differing sign caseIan Romanick2020-03-181-21/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is basically the same ideas from the previous 4 commits applied to the aSign != bSign part... and all smashed into one commit. The shader hurt for spill and / or fills is from KHR-GL46.gpu_shader_fp64.builtin.inverse_dmat4. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake total instructions in shared programs: 787258 -> 683638 (-13.16%) instructions in affected programs: 725435 -> 621815 (-14.28%) helped: 74 HURT: 0 helped stats (abs) min: 152 max: 10261 x̄: 1400.27 x̃: 975 helped stats (rel) min: 11.61% max: 20.92% x̄: 15.40% x̃: 14.86% 95% mean confidence interval for instructions value: -1740.11 -1060.43 95% mean confidence interval for instructions %-change: -16.01% -14.79% Instructions are helped. total cycles in shared programs: 6483227 -> 5458858 (-15.80%) cycles in affected programs: 6051245 -> 5026876 (-16.93%) helped: 74 HURT: 0 helped stats (abs) min: 1566 max: 95474 x̄: 13842.82 x̃: 9757 helped stats (rel) min: 13.94% max: 23.26% x̄: 17.98% x̃: 17.57% 95% mean confidence interval for cycles value: -17104.25 -10581.40 95% mean confidence interval for cycles %-change: -18.61% -17.35% Cycles are helped. total spills in shared programs: 553 -> 445 (-19.53%) spills in affected programs: 553 -> 445 (-19.53%) helped: 1 HURT: 0 total fills in shared programs: 1307 -> 1323 (1.22%) fills in affected programs: 1307 -> 1323 (1.22%) helped: 0 HURT: 1 Ice Lake total instructions in shared programs: 781216 -> 678470 (-13.15%) instructions in affected programs: 720088 -> 617342 (-14.27%) helped: 74 HURT: 0 helped stats (abs) min: 153 max: 8863 x̄: 1388.46 x̃: 975 helped stats (rel) min: 11.24% max: 21.03% x̄: 15.47% x̃: 15.01% 95% mean confidence interval for instructions value: -1703.57 -1073.35 95% mean confidence interval for instructions %-change: -16.09% -14.85% Instructions are helped. total cycles in shared programs: 6464085 -> 5453997 (-15.63%) cycles in affected programs: 6031771 -> 5021683 (-16.75%) helped: 74 HURT: 0 helped stats (abs) min: 1552 max: 90317 x̄: 13649.84 x̃: 9650 helped stats (rel) min: 13.84% max: 23.11% x̄: 17.83% x̃: 17.41% 95% mean confidence interval for cycles value: -16802.89 -10496.79 95% mean confidence interval for cycles %-change: -18.46% -17.21% Cycles are helped. total spills in shared programs: 279 -> 368 (31.90%) spills in affected programs: 279 -> 368 (31.90%) helped: 0 HURT: 1 total fills in shared programs: 973 -> 1155 (18.71%) fills in affected programs: 973 -> 1155 (18.71%) helped: 0 HURT: 1 Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fadd: Move common code out of both branches of an if-statementIan Romanick2020-03-181-22/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous two commits were just setting the scene for this change. The mix(..., __propagateFloat64NaN(a, b), propagate) statements are not identical in the two halves, but they are equivalent. The first clause of the mix in the else-branch is trivally ±Inf. The first clause in the then-branch __packFloat64(aSign, aExp, aFracHi, aFracLo). The preceeding conditions prove that aExp=0x7ff, aFracHi=0, and aFracLo=0. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 819560 -> 787258 (-3.94%) instructions in affected programs: 757737 -> 725435 (-4.26%) helped: 74 HURT: 0 helped stats (abs) min: 43 max: 3545 x̄: 436.51 x̃: 296 helped stats (rel) min: 3.54% max: 6.16% x̄: 4.52% x̃: 4.36% 95% mean confidence interval for instructions value: -548.42 -324.61 95% mean confidence interval for instructions %-change: -4.68% -4.37% Instructions are helped. total cycles in shared programs: 6817254 -> 6483227 (-4.90%) cycles in affected programs: 6385272 -> 6051245 (-5.23%) helped: 74 HURT: 0 helped stats (abs) min: 430 max: 33271 x̄: 4513.88 x̃: 3047 helped stats (rel) min: 4.28% max: 7.45% x̄: 5.48% x̃: 5.31% 95% mean confidence interval for cycles value: -5610.46 -3417.30 95% mean confidence interval for cycles %-change: -5.65% -5.32% Cycles are helped. total spills in shared programs: 591 -> 553 (-6.43%) spills in affected programs: 591 -> 553 (-6.43%) helped: 1 HURT: 0 total fills in shared programs: 1353 -> 1307 (-3.40%) fills in affected programs: 1353 -> 1307 (-3.40%) helped: 1 HURT: 0 Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fadd: Use absolute value of expDiffIan Romanick2020-03-181-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In one branch we know that expDiff is already positive. In the other branch we know the expDiff is negative. Previously in that branch the code was -(expDiff + 1). This is equvialent to (-expDiff) - 1, and since expDiff is negative, abs(expDiff) - 1. The main purpose of this commit is to prepare for "soft-fp64/fadd: Move common code out of both branches of an if-statement". Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 818246 -> 819560 (0.16%) instructions in affected programs: 756423 -> 757737 (0.17%) helped: 1 HURT: 73 helped stats (abs) min: 1205 max: 1205 x̄: 1205.00 x̃: 1205 helped stats (rel) min: 1.36% max: 1.36% x̄: 1.36% x̃: 1.36% HURT stats (abs) min: 2 max: 149 x̄: 34.51 x̃: 27 HURT stats (rel) min: 0.14% max: 1.09% x̄: 0.41% x̃: 0.30% 95% mean confidence interval for instructions value: -16.56 52.07 95% mean confidence interval for instructions %-change: 0.30% 0.47% Inconclusive result (value mean confidence interval includes 0). total cycles in shared programs: 6816686 -> 6817254 (<.01%) cycles in affected programs: 6384704 -> 6385272 (<.01%) helped: 37 HURT: 37 helped stats (abs) min: 30 max: 5790 x̄: 289.05 x̃: 102 helped stats (rel) min: 0.04% max: 0.86% x̄: 0.29% x̃: 0.31% HURT stats (abs) min: 2 max: 1020 x̄: 304.41 x̃: 232 HURT stats (rel) min: <.01% max: 1.58% x̄: 0.55% x̃: 0.43% 95% mean confidence interval for cycles value: -165.37 180.72 95% mean confidence interval for cycles %-change: <.01% 0.27% Inconclusive result (value mean confidence interval includes 0). total spills in shared programs: 705 -> 591 (-16.17%) spills in affected programs: 705 -> 591 (-16.17%) helped: 1 HURT: 0 total fills in shared programs: 1501 -> 1353 (-9.86%) fills in affected programs: 1501 -> 1353 (-9.86%) helped: 1 HURT: 0 Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fadd: Rename aFrac and bFrac variablesIan Romanick2020-03-181-6/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Exchanging aFracHi / bFracHi and aFracLo / bFracLo should not affect the result of the later call to __add64. The main purpose of this commit is to prepare for "soft-fp64/fadd: Move common code out of both branches of an if-statement". v2: Fix a typo in a comment. Noticed by Matt. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 812094 -> 818246 (0.76%) instructions in affected programs: 750271 -> 756423 (0.82%) helped: 0 HURT: 74 HURT stats (abs) min: 7 max: 520 x̄: 83.14 x̃: 59 HURT stats (rel) min: 0.52% max: 1.48% x̄: 0.89% x̃: 0.84% 95% mean confidence interval for instructions value: 63.96 102.31 95% mean confidence interval for instructions %-change: 0.83% 0.95% Instructions are HURT. total cycles in shared programs: 6797157 -> 6816686 (0.29%) cycles in affected programs: 6365175 -> 6384704 (0.31%) helped: 0 HURT: 74 HURT stats (abs) min: 16 max: 1690 x̄: 263.91 x̃: 181 HURT stats (rel) min: 0.14% max: 0.68% x̄: 0.32% x̃: 0.27% 95% mean confidence interval for cycles value: 199.74 328.07 95% mean confidence interval for cycles %-change: 0.29% 0.36% Cycles are HURT. total spills in shared programs: 703 -> 705 (0.28%) spills in affected programs: 703 -> 705 (0.28%) helped: 0 HURT: 1 total fills in shared programs: 1499 -> 1501 (0.13%) fills in affected programs: 1499 -> 1501 (0.13%) helped: 0 HURT: 1 Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fadd: Combine an if-statement into the preceeding else-clauseIan Romanick2020-03-181-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main purpose of this commit is to prepare for "soft-fp64/fadd: Move common code out of both branches of an if-statement". Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 812590 -> 812094 (-0.06%) instructions in affected programs: 672135 -> 671639 (-0.07%) helped: 57 HURT: 0 helped stats (abs) min: 1 max: 32 x̄: 8.70 x̃: 7 helped stats (rel) min: <.01% max: 0.49% x̄: 0.12% x̃: 0.09% 95% mean confidence interval for instructions value: -10.46 -6.94 95% mean confidence interval for instructions %-change: -0.15% -0.09% Instructions are helped. total cycles in shared programs: 6798039 -> 6797157 (-0.01%) cycles in affected programs: 5810059 -> 5809177 (-0.02%) helped: 54 HURT: 2 helped stats (abs) min: 2 max: 68 x̄: 16.44 x̃: 12 helped stats (rel) min: <.01% max: 0.12% x̄: 0.03% x̃: 0.02% HURT stats (abs) min: 2 max: 4 x̄: 3.00 x̃: 3 HURT stats (rel) min: <.01% max: <.01% x̄: <.01% x̃: <.01% 95% mean confidence interval for cycles value: -19.50 -12.00 95% mean confidence interval for cycles %-change: -0.03% -0.02% Cycles are helped. Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fadd: Reformat after previous commitIan Romanick2020-03-181-19/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | Convert } else if (...) { ... } else { ... } to } else { if (...) { ... } else { ... } } Not doing this reformatting in the previous commit makes the previous commit easier to review, and doing it before the next commit makes the next commit easier to review. Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fadd: Delete a redundant condition checkIan Romanick2020-03-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previous condition checks already guaranteen that expDiff != 0 and !(expDiff > 0), so expDiff < 0 is the only option left. The main purpose of this commit is to prepare for "soft-fp64/fadd: Move common code out of both branches of an if-statement". Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 815491 -> 812590 (-0.36%) instructions in affected programs: 753668 -> 750767 (-0.38%) helped: 74 HURT: 0 helped stats (abs) min: 3 max: 281 x̄: 39.20 x̃: 25 helped stats (rel) min: 0.29% max: 0.73% x̄: 0.42% x̃: 0.40% 95% mean confidence interval for instructions value: -48.50 -29.91 95% mean confidence interval for instructions %-change: -0.45% -0.40% Instructions are helped. total cycles in shared programs: 6813681 -> 6798039 (-0.23%) cycles in affected programs: 6381699 -> 6366057 (-0.25%) helped: 74 HURT: 0 helped stats (abs) min: 24 max: 1488 x̄: 211.38 x̃: 149 helped stats (rel) min: 0.20% max: 0.44% x̄: 0.26% x̃: 0.25% 95% mean confidence interval for cycles value: -261.68 -161.08 95% mean confidence interval for cycles %-change: -0.28% -0.25% Cycles are helped. Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fadd: Just let the subtraction happen when the result will be zeroIan Romanick2020-03-181-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main purpose of this commit is to prepare for "soft-fp64/fadd: Move common code out of both branches of an if-statement". Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 815717 -> 815491 (-0.03%) instructions in affected programs: 735489 -> 735263 (-0.03%) helped: 39 HURT: 34 helped stats (abs) min: 2 max: 192 x̄: 20.79 x̃: 12 helped stats (rel) min: 0.01% max: 0.46% x̄: 0.26% x̃: 0.28% HURT stats (abs) min: 1 max: 65 x̄: 17.21 x̃: 11 HURT stats (rel) min: <.01% max: 1.11% x̄: 0.35% x̃: 0.19% 95% mean confidence interval for instructions value: -10.40 4.21 95% mean confidence interval for instructions %-change: -0.07% 0.13% Inconclusive result (value mean confidence interval includes 0). total cycles in shared programs: 6820707 -> 6813681 (-0.10%) cycles in affected programs: 6388725 -> 6381699 (-0.11%) helped: 51 HURT: 23 helped stats (abs) min: 3 max: 1837 x̄: 184.76 x̃: 120 helped stats (rel) min: <.01% max: 0.48% x̄: 0.25% x̃: 0.25% HURT stats (abs) min: 18 max: 216 x̄: 104.22 x̃: 98 HURT stats (rel) min: 0.06% max: 0.73% x̄: 0.31% x̃: 0.11% 95% mean confidence interval for cycles value: -154.67 -35.22 95% mean confidence interval for cycles %-change: -0.15% <.01% Inconclusive result (%-change mean confidence interval includes 0). total spills in shared programs: 702 -> 703 (0.14%) spills in affected programs: 702 -> 703 (0.14%) helped: 0 HURT: 1 total fills in shared programs: 1497 -> 1499 (0.13%) fills in affected programs: 1497 -> 1499 (0.13%) helped: 0 HURT: 1 Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fadd: Pick zero or non-zero result based on subtraction resultIan Romanick2020-03-181-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main purpose of this commit is to prepare for "soft-fp64/fadd: Move common code out of both branches of an if-statement". Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 817327 -> 815717 (-0.20%) instructions in affected programs: 755504 -> 753894 (-0.21%) helped: 73 HURT: 1 helped stats (abs) min: 1 max: 159 x̄: 22.12 x̃: 14 helped stats (rel) min: 0.05% max: 0.40% x̄: 0.22% x̃: 0.23% HURT stats (abs) min: 5 max: 5 x̄: 5.00 x̃: 5 HURT stats (rel) min: 0.07% max: 0.07% x̄: 0.07% x̃: 0.07% 95% mean confidence interval for instructions value: -27.27 -16.24 95% mean confidence interval for instructions %-change: -0.24% -0.20% Instructions are helped. total cycles in shared programs: 6822826 -> 6820707 (-0.03%) cycles in affected programs: 6390844 -> 6388725 (-0.03%) helped: 71 HURT: 3 helped stats (abs) min: 2 max: 537 x̄: 30.72 x̃: 18 helped stats (rel) min: <.01% max: 0.08% x̄: 0.03% x̃: 0.03% HURT stats (abs) min: 10 max: 32 x̄: 20.67 x̃: 20 HURT stats (rel) min: 0.01% max: 0.02% x̄: 0.02% x̃: 0.02% 95% mean confidence interval for cycles value: -43.41 -13.86 95% mean confidence interval for cycles %-change: -0.04% -0.03% Cycles are helped. Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fadd: Massively split the live range of zFrac0 and zFrac1Ian Romanick2020-03-181-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main purpose of this commit is to prepare for "soft-fp64/fadd: Move common code out of both branches of an if-statement". Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 822766 -> 817327 (-0.66%) instructions in affected programs: 760943 -> 755504 (-0.71%) helped: 74 HURT: 0 helped stats (abs) min: 8 max: 515 x̄: 73.50 x̃: 51 helped stats (rel) min: 0.58% max: 1.10% x̄: 0.77% x̃: 0.73% 95% mean confidence interval for instructions value: -91.17 -55.83 95% mean confidence interval for instructions %-change: -0.81% -0.74% Instructions are helped. total cycles in shared programs: 6816791 -> 6822826 (0.09%) cycles in affected programs: 6384809 -> 6390844 (0.09%) helped: 0 HURT: 74 HURT stats (abs) min: 6 max: 1179 x̄: 81.55 x̃: 50 HURT stats (rel) min: 0.02% max: 0.17% x̄: 0.09% x̃: 0.09% 95% mean confidence interval for cycles value: 48.99 114.12 95% mean confidence interval for cycles %-change: 0.09% 0.10% Cycles are HURT. Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fadd: Instead of tracking "b < a", track sign of the differenceIan Romanick2020-03-181-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 824403 -> 822766 (-0.20%) instructions in affected programs: 756260 -> 754623 (-0.22%) helped: 68 HURT: 1 helped stats (abs) min: 1 max: 118 x̄: 26.26 x̃: 18 helped stats (rel) min: 0.02% max: 0.97% x̄: 0.31% x̃: 0.23% HURT stats (abs) min: 149 max: 149 x̄: 149.00 x̃: 149 HURT stats (rel) min: 0.17% max: 0.17% x̄: 0.17% x̃: 0.17% 95% mean confidence interval for instructions value: -31.94 -15.51 95% mean confidence interval for instructions %-change: -0.37% -0.23% Instructions are helped. total cycles in shared programs: 6828935 -> 6816791 (-0.18%) cycles in affected programs: 6385191 -> 6373047 (-0.19%) helped: 73 HURT: 0 helped stats (abs) min: 2 max: 852 x̄: 166.36 x̃: 120 helped stats (rel) min: <.01% max: 0.80% x̄: 0.22% x̃: 0.17% 95% mean confidence interval for cycles value: -210.80 -121.91 95% mean confidence interval for cycles %-change: -0.27% -0.17% Cycles are helped. total fills in shared programs: 1442 -> 1497 (3.81%) fills in affected programs: 1442 -> 1497 (3.81%) helped: 0 HURT: 1 Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64: Optimize __fmin64 and __fmax64 by using different evaluation ↵Ian Romanick2020-03-181-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | order [v2] v2: Go to extra effort to avoid flow control inserted to implement short-circuit evaluation rules. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 797779 -> 796849 (-0.12%) instructions in affected programs: 3499 -> 2569 (-26.58%) helped: 21 HURT: 0 helped stats (abs) min: 8 max: 112 x̄: 44.29 x̃: 44 helped stats (rel) min: 16.09% max: 33.15% x̄: 25.72% x̃: 24.62% 95% mean confidence interval for instructions value: -55.94 -32.63 95% mean confidence interval for instructions %-change: -28.14% -23.30% Instructions are helped. total cycles in shared programs: 6601355 -> 6588351 (-0.20%) cycles in affected programs: 25376 -> 12372 (-51.25%) helped: 21 HURT: 0 helped stats (abs) min: 156 max: 1410 x̄: 619.24 x̃: 526 helped stats (rel) min: 42.39% max: 53.98% x̄: 50.12% x̃: 50.75% 95% mean confidence interval for cycles value: -776.58 -461.89 95% mean confidence interval for cycles %-change: -51.57% -48.67% Cycles are helped. Reviewed-by: Jason Ekstrand <[email protected]> [v1] Reviewed-by: Matt Turner <[email protected]> [v1] Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/ffloor: Simplify the >= 0 comparisonIan Romanick2020-03-181-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 797951 -> 797779 (-0.02%) instructions in affected programs: 126482 -> 126310 (-0.14%) helped: 15 HURT: 0 helped stats (abs) min: 1 max: 20 x̄: 11.47 x̃: 10 helped stats (rel) min: <.01% max: 0.60% x̄: 0.28% x̃: 0.29% 95% mean confidence interval for instructions value: -14.79 -8.14 95% mean confidence interval for instructions %-change: -0.40% -0.16% Instructions are helped. total cycles in shared programs: 6601437 -> 6601355 (<.01%) cycles in affected programs: 1089336 -> 1089254 (<.01%) helped: 15 HURT: 0 helped stats (abs) min: 2 max: 12 x̄: 5.47 x̃: 6 helped stats (rel) min: <.01% max: 0.04% x̄: 0.01% x̃: 0.01% 95% mean confidence interval for cycles value: -7.06 -3.87 95% mean confidence interval for cycles %-change: -0.02% <.01% Cycles are helped. Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64: Relax the way NaN is propagatedIan Romanick2020-03-181-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also reassociate a couple expressions to encourage some CSE. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 813599 -> 797951 (-1.92%) instructions in affected programs: 796110 -> 780462 (-1.97%) helped: 92 HURT: 0 helped stats (abs) min: 3 max: 5198 x̄: 170.09 x̃: 83 helped stats (rel) min: 0.36% max: 5.50% x̄: 1.57% x̃: 1.40% 95% mean confidence interval for instructions value: -282.42 -57.75 95% mean confidence interval for instructions %-change: -1.71% -1.42% Instructions are helped. total cycles in shared programs: 6687128 -> 6601437 (-1.28%) cycles in affected programs: 6582246 -> 6496555 (-1.30%) helped: 92 HURT: 0 helped stats (abs) min: 36 max: 14442 x̄: 931.42 x̃: 592 helped stats (rel) min: 0.45% max: 3.16% x̄: 1.44% x̃: 1.23% 95% mean confidence interval for cycles value: -1257.58 -605.27 95% mean confidence interval for cycles %-change: -1.58% -1.30% Cycles are helped. total spills in shared programs: 759 -> 702 (-7.51%) spills in affected programs: 759 -> 702 (-7.51%) helped: 3 HURT: 0 total fills in shared programs: 2412 -> 1442 (-40.22%) fills in affected programs: 2412 -> 1442 (-40.22%) helped: 3 HURT: 0 Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fsat: Micro-optimize x >= 1 testIan Romanick2020-03-181-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 841590 -> 841332 (-0.03%) instructions in affected programs: 121957 -> 121699 (-0.21%) helped: 7 HURT: 0 helped stats (abs) min: 15 max: 54 x̄: 36.86 x̃: 41 helped stats (rel) min: 0.16% max: 0.33% x̄: 0.23% x̃: 0.18% 95% mean confidence interval for instructions value: -49.73 -23.98 95% mean confidence interval for instructions %-change: -0.29% -0.16% Instructions are helped. total cycles in shared programs: 6926828 -> 6923967 (-0.04%) cycles in affected programs: 1038569 -> 1035708 (-0.28%) helped: 7 HURT: 0 helped stats (abs) min: 128 max: 616 x̄: 408.71 x̃: 446 helped stats (rel) min: 0.18% max: 0.44% x̄: 0.29% x̃: 0.22% 95% mean confidence interval for cycles value: -571.72 -245.70 95% mean confidence interval for cycles %-change: -0.38% -0.19% Cycles are helped. Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fsat: Micro-optimize x < 0 testIan Romanick2020-03-181-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 841647 -> 841590 (<.01%) instructions in affected programs: 122014 -> 121957 (-0.05%) helped: 7 HURT: 0 helped stats (abs) min: 3 max: 12 x̄: 8.14 x̃: 9 helped stats (rel) min: 0.04% max: 0.07% x̄: 0.05% x̃: 0.04% 95% mean confidence interval for instructions value: -11.23 -5.06 95% mean confidence interval for instructions %-change: -0.06% -0.03% Instructions are helped. total cycles in shared programs: 6926904 -> 6926828 (<.01%) cycles in affected programs: 1038645 -> 1038569 (<.01%) helped: 7 HURT: 0 helped stats (abs) min: 4 max: 16 x̄: 10.86 x̃: 12 helped stats (rel) min: <.01% max: 0.01% x̄: <.01% x̃: <.01% 95% mean confidence interval for cycles value: -14.97 -6.74 95% mean confidence interval for cycles %-change: -0.01% <.01% Cycles are helped. Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fsat: Correctly handle NaNIan Romanick2020-03-181-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fsat is defined as min(max(a, 0.0), 1.0), and IEEE defines both min and max to return the non-NaN value when one value is NaN. Based on this, fsat should definitely return 0.0 for NaN. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 841666 -> 841647 (<.01%) instructions in affected programs: 122033 -> 122014 (-0.02%) helped: 7 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 2.71 x̃: 3 helped stats (rel) min: 0.01% max: 0.02% x̄: 0.02% x̃: 0.01% 95% mean confidence interval for instructions value: -3.74 -1.69 95% mean confidence interval for instructions %-change: -0.02% -0.01% Instructions are helped. total cycles in shared programs: 6927246 -> 6926904 (<.01%) cycles in affected programs: 1038987 -> 1038645 (-0.03%) helped: 7 HURT: 0 helped stats (abs) min: 18 max: 72 x̄: 48.86 x̃: 54 helped stats (rel) min: 0.03% max: 0.05% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -67.38 -30.33 95% mean confidence interval for cycles %-change: -0.05% -0.02% Cycles are helped. Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]> Fixes: a42163cbbc1 ("compiler: Add lowering support for 64-bit saturate operations to software") Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2585 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/flt: Perform checks in a different orderIan Romanick2020-03-181-16/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The change to nir_opt_algebraic cleans up a pattern that was never produced before the rest of this commit was added. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 843005 -> 841666 (-0.16%) instructions in affected programs: 460655 -> 459316 (-0.29%) helped: 64 HURT: 17 helped stats (abs) min: 1 max: 72 x̄: 21.72 x̃: 20 helped stats (rel) min: 0.01% max: 28.07% x̄: 12.67% x̃: 16.07% HURT stats (abs) min: 1 max: 7 x̄: 3.00 x̃: 2 HURT stats (rel) min: 0.01% max: 0.04% x̄: 0.02% x̃: 0.02% 95% mean confidence interval for instructions value: -20.87 -12.19 95% mean confidence interval for instructions %-change: -12.35% -7.66% Instructions are helped. total cycles in shared programs: 6944998 -> 6927246 (-0.26%) cycles in affected programs: 3891872 -> 3874120 (-0.46%) helped: 71 HURT: 10 helped stats (abs) min: 2 max: 772 x̄: 254.21 x̃: 156 helped stats (rel) min: <.01% max: 66.44% x̄: 21.72% x̃: 18.40% HURT stats (abs) min: 18 max: 69 x̄: 29.70 x̃: 20 HURT stats (rel) min: 0.02% max: 0.04% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -270.82 -167.50 95% mean confidence interval for cycles %-change: -24.41% -13.65% Cycles are helped. Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/fneg: Don't treat NaN speciallyIan Romanick2020-03-181-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | __fabs64 doesn't do anything special, and the value is still NaN regardless of the value of the MSB. In a strict sense, it's possible that both functions should set the "signal" bit. lts on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 844558 -> 843005 (-0.18%) instructions in affected programs: 725975 -> 724422 (-0.21%) helped: 53 HURT: 4 helped stats (abs) min: 1 max: 313 x̄: 29.87 x̃: 21 helped stats (rel) min: 0.01% max: 0.94% x̄: 0.30% x̃: 0.22% HURT stats (abs) min: 4 max: 11 x̄: 7.50 x̃: 7 HURT stats (rel) min: 0.03% max: 0.09% x̄: 0.05% x̃: 0.04% 95% mean confidence interval for instructions value: -39.02 -15.47 95% mean confidence interval for instructions %-change: -0.34% -0.21% Instructions are helped. total cycles in shared programs: 6962024 -> 6944998 (-0.24%) cycles in affected programs: 6185470 -> 6168444 (-0.28%) helped: 59 HURT: 0 helped stats (abs) min: 64 max: 2863 x̄: 288.58 x̃: 208 helped stats (rel) min: 0.11% max: 0.87% x̄: 0.33% x̃: 0.27% 95% mean confidence interval for cycles value: -387.15 -190.00 95% mean confidence interval for cycles %-change: -0.38% -0.28% Cycles are helped. Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64: Store sign value as 0 or 0x80000000Ian Romanick2020-03-181-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...instead of 0 or 1. Many places the sign bit is extracted, then later put back in the same position. This saves some left-shift operations. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 848106 -> 844558 (-0.42%) instructions in affected programs: 833480 -> 829932 (-0.43%) helped: 106 HURT: 1 helped stats (abs) min: 1 max: 995 x̄: 33.48 x̃: 12 helped stats (rel) min: 0.15% max: 2.20% x̄: 0.60% x̃: 0.35% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: <.01% max: <.01% x̄: <.01% x̃: <.01% 95% mean confidence interval for instructions value: -51.88 -14.43 95% mean confidence interval for instructions %-change: -0.71% -0.47% Instructions are helped. total cycles in shared programs: 6969125 -> 6962024 (-0.10%) cycles in affected programs: 6717689 -> 6710588 (-0.11%) helped: 78 HURT: 7 helped stats (abs) min: 2 max: 2083 x̄: 110.27 x̃: 56 helped stats (rel) min: <.01% max: 0.30% x̄: 0.11% x̃: 0.11% HURT stats (abs) min: 2 max: 1340 x̄: 214.29 x̃: 4 HURT stats (rel) min: 0.01% max: 0.71% x̄: 0.13% x̃: 0.02% 95% mean confidence interval for cycles value: -144.02 -23.06 95% mean confidence interval for cycles %-change: -0.12% -0.07% Cycles are helped. total spills in shared programs: 814 -> 759 (-6.76%) spills in affected programs: 814 -> 759 (-6.76%) helped: 2 HURT: 1 total fills in shared programs: 2488 -> 2412 (-3.05%) fills in affected programs: 2488 -> 2412 (-3.05%) helped: 2 HURT: 1 Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64: Pick a single idiom for treating sign value as a BooleanIan Romanick2020-03-181-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | Replace all of the bool(qSign) with qSign != 0u. Remove unnecessary parenthesis from around most of the existing qSign != 0u. This dramatically simplifies the next commit. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 848109 -> 848106 (<.01%) instructions in affected programs: 53 -> 50 (-5.66%) helped: 1 HURT: 0 total cycles in shared programs: 6969145 -> 6969125 (<.01%) cycles in affected programs: 396 -> 376 (-5.05%) helped: 1 HURT: 0 Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64: Simplify __countLeadingZeros32 functionIan Romanick2020-03-181-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | findMSB returns -1 for an input of zero, so 31 - findMSB(a) is sufficient on its own. There's only one user of findMSB in shader-db, and it does not match this pattern. TODO: Add a pattern in the backend code generator that emits 31 - nir_op_ufind_msb(a) as if it were nir_op_uclz. That should save a couple instructions. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 859509 -> 848109 (-1.33%) instructions in affected programs: 841058 -> 829658 (-1.36%) helped: 97 HURT: 0 helped stats (abs) min: 3 max: 1161 x̄: 117.53 x̃: 72 helped stats (rel) min: 0.98% max: 6.74% x̄: 1.70% x̃: 1.35% 95% mean confidence interval for instructions value: -147.21 -87.84 95% mean confidence interval for instructions %-change: -1.94% -1.46% Instructions are helped. total cycles in shared programs: 7072275 -> 6969145 (-1.46%) cycles in affected programs: 6955767 -> 6852637 (-1.48%) helped: 97 HURT: 0 helped stats (abs) min: 32 max: 10900 x̄: 1063.20 x̃: 560 helped stats (rel) min: 1.18% max: 7.58% x̄: 1.84% x̃: 1.45% 95% mean confidence interval for cycles value: -1339.43 -786.96 95% mean confidence interval for cycles %-change: -2.11% -1.57% Cycles are helped. Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64: Don't open-code umulExtendedIan Romanick2020-03-181-32/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 928859 -> 859509 (-7.47%) instructions in affected programs: 866293 -> 796943 (-8.01%) helped: 76 HURT: 0 helped stats (abs) min: 75 max: 8042 x̄: 912.50 x̃: 688 helped stats (rel) min: 5.35% max: 21.02% x̄: 10.35% x̃: 7.58% 95% mean confidence interval for instructions value: -1138.37 -686.63 95% mean confidence interval for instructions %-change: -11.69% -9.00% Instructions are helped. total cycles in shared programs: 7272912 -> 7072275 (-2.76%) cycles in affected programs: 6763486 -> 6562849 (-2.97%) helped: 76 HURT: 0 helped stats (abs) min: 214 max: 30136 x̄: 2639.96 x̃: 1923 helped stats (rel) min: 1.75% max: 9.20% x̄: 4.04% x̃: 2.41% 95% mean confidence interval for cycles value: -3455.29 -1824.63 95% mean confidence interval for cycles %-change: -4.69% -3.39% Cycles are helped. total spills in shared programs: 817 -> 814 (-0.37%) spills in affected programs: 791 -> 788 (-0.38%) helped: 2 HURT: 0 total fills in shared programs: 2438 -> 2488 (2.05%) fills in affected programs: 2392 -> 2442 (2.09%) helped: 0 HURT: 2 Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* soft-fp64/b2f: Reimplement using bitwise logic opsIan Romanick2020-03-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This doesn't help a lot of shaders, but it helps those few a LOT. This could also be implemented using bcsel. That version is very slightly worse because the generated SEL instruction wants to have two immediate sources, so one of them usually needs an extra MOV instruction to load. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake and Ice Lake had similar results. (Tiger Lake shown) total instructions in shared programs: 929619 -> 928859 (-0.08%) instructions in affected programs: 1651 -> 891 (-46.03%) helped: 8 HURT: 0 helped stats (abs) min: 38 max: 152 x̄: 95.00 x̃: 95 helped stats (rel) min: 42.70% max: 86.36% x̄: 49.88% x̃: 44.66% 95% mean confidence interval for instructions value: -132.97 -57.03 95% mean confidence interval for instructions %-change: -62.28% -37.49% Instructions are helped. total cycles in shared programs: 7280180 -> 7272912 (-0.10%) cycles in affected programs: 12960 -> 5692 (-56.08%) helped: 8 HURT: 0 helped stats (abs) min: 352 max: 1456 x̄: 908.50 x̃: 910 helped stats (rel) min: 52.45% max: 91.19% x̄: 59.24% x̃: 55.15% 95% mean confidence interval for cycles value: -1274.03 -542.97 95% mean confidence interval for cycles %-change: -70.06% -48.41% Cycles are helped. Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
* meson: Avoid duplicate symbols.Jose Fonseca2020-03-162-4/+13
| | | | | | | | | | | | | | | | All the stubs in src/compiler/glsl/glcpp/pp_standalone_scaffolding.c are duplicate symbols. They should only be used as replacement for Mesa functions when building glcpp and glsl standalone compilers, but in fact they are getting linked with Mesa. This change fixes this by moving the standalone stubs to a libglcpp_standalone target, that's only linked with the glcpp/glsl tools. Reviewed-by: Dylan Baker <[email protected]> Reviewed-by: Neha Bhende <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4186> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4186>
* nir/glsl: gather bitmask of images used by programTapani Pälli2020-03-161-0/+18
| | | | | | | In a similar fashion as commit f5c7df4dc95 does for textures. Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4080>
* glsl: do not crash if string literal is used outside of #include/#lineDanylo Piliaiev2020-03-131-0/+1
| | | | | | | | | Fixes: 67b32190f3c953c5b7091d76ddeff95c0cbfb439 Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2619 Signed-off-by: Danylo Piliaiev <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4146> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4146>
* glsl/tests: Fix waiting for disk_cache_put() to finish.Eric Anholt2020-03-121-42/+11
| | | | | | | | | | | | We were wasting 4s on waiting for expected-not-to-appear files to show up on every test. Using timeouts in test code is error-prone anyway, as our shared runners may be busy on other jobs. Fixes: 50989f87e62e ("util/disk_cache: use a thread queue to write to shader cache") Link: https://gitlab.freedesktop.org/mesa/mesa/issues/2505 Reviewed-by: Timothy Arceri <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4140> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4140>
* glsl/tests: Catch mkdir errors to help explain when they happen.Eric Anholt2020-03-121-2/+14
| | | | | | | | | | | | A recent pipeline (https://gitlab.freedesktop.org/Venemo/mesa/-/jobs/1893357) failed with what looks like an intermittent error related to making files for the cache test inside of the core of the cache. Given some of the errors, it looks like maybe a mkdir failed, so log those errors earlier so we can debug what's going on next time. Reviewed-by: Timothy Arceri <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4140>