<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Thu, Oct 18, 2018 at 3:11 PM Ian Romanick <<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 10/17/2018 11:33 AM, Jason Ekstrand wrote:<br>
> From: Connor Abbott <<a href="mailto:cwabbott0@gmail.com" target="_blank">cwabbott0@gmail.com</a>><br>
> <br>
> Shader-db results on Haswell:<br>
> <br>
> total instructions in shared programs: 2180337 -> 2154080 (-1.20%)<br>
> instructions in affected programs: 959766 -> 933509 (-2.74%)<br>
> helped: 5653<br>
> HURT: 2560<br>
> <br>
> total cycles in shared programs: 12339326 -> 12307102 (-0.26%)<br>
> cycles in affected programs: 6102794 -> 6070570 (-0.53%)<br>
> helped: 3838<br>
> HURT: 4868<br>
<br>
Here's the results I got with these 3 patches on 322a919a41f:<br>
<br>
total instructions in shared programs: 13674046 -> 13643001 (-0.23%)<br>
instructions in affected programs: 1248672 -> 1217627 (-2.49%)<br>
helped: 7168<br>
HURT: 2841<br>
helped stats (abs) min: 1 max: 39 x̄: 5.40 x̃: 3<br>
helped stats (rel) min: 0.21% max: 33.33% x̄: 4.55% x̃: 3.54%<br>
HURT stats (abs) min: 1 max: 21 x̄: 2.71 x̃: 3<br>
HURT stats (rel) min: 0.19% max: 22.73% x̄: 3.86% x̃: 3.53%<br>
95% mean confidence interval for instructions value: -3.23 -2.97<br>
95% mean confidence interval for instructions %-change: -2.28% -2.05%<br>
Instructions are helped.<br>
<br>
total cycles in shared programs: 373694400 -> 373745788 (0.01%)<br>
cycles in affected programs: 23171532 -> 23222920 (0.22%)<br>
helped: 4890<br>
HURT: 5632<br>
helped stats (abs) min: 2 max: 1268 x̄: 52.04 x̃: 34<br>
helped stats (rel) min: 0.04% max: 45.71% x̄: 7.43% x̃: 4.64%<br>
HURT stats (abs) min: 2 max: 6042 x̄: 54.30 x̃: 32<br>
HURT stats (rel) min: 0.05% max: 60.66% x̄: 8.19% x̃: 6.21%<br>
95% mean confidence interval for cycles value: 1.30 8.47<br>
95% mean confidence interval for cycles %-change: 0.73% 1.14%<br>
Cycles are HURT.<br>
<br>
total spills in shared programs: 82569 -> 82572 (<.01%)<br>
spills in affected programs: 70 -> 73 (4.29%)<br>
helped: 0<br>
HURT: 3<br>
<br>
total fills in shared programs: 93445 -> 93449 (<.01%)<br>
fills in affected programs: 71 -> 75 (5.63%)<br>
helped: 0<br>
HURT: 4<br>
<br>
This is pretty different from your result... and not good. :( What SHA<br>
of master were you on?<br></blockquote><div><br></div><div>For one thing, I scrubbed all the non-vec4 programs from the results because this doesn't affect FS. I'm not sure what master; something from the last two days; I just rebased. Maybe you have a newer shader-db?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> Most of the hurt programs seem to be because we generate extra MOV's due<br>
> to vectorizing things. For example, in<br>
> shaders/non-free/steam/anomaly-2/158.shader_test, this:<br>
> <br>
> add(8) g116<1>.xyF g12<4,4,1>.xyyyF g1.4<0,4,1>.xyyyF { align16 NoDDClr 1Q };<br>
> add(8) g117<1>.xyF g12<4,4,1>.xyyyF g1.4<0,4,1>.zwwwF { align16 NoDDClr 1Q };<br>
> add(8) g116<1>.zwF g12<4,4,1>.xxxyF -g1.4<0,4,1>.xxxyF { align16 NoDDChk 1Q };<br>
> add(8) g117<1>.zwF g12<4,4,1>.xxxyF -g1.4<0,4,1>.zzzwF { align16 NoDDChk 1Q };<br>
> <br>
> Turns into this:<br>
> <br>
> add(8) g13<1>F g12<4,4,1>.xyxyF g1.4<0,4,1>F { align16 1Q };<br>
> add(8) g14<1>F g12<4,4,1>.xyxyF -g1.4<0,4,1>F { align16 1Q };<br>
> mov(8) g116<1>.xyD g13<4,4,1>.xyyyD { align16 NoDDClr 1Q };<br>
> mov(8) g117<1>.xyD g13<4,4,1>.zwwwD { align16 NoDDClr 1Q };<br>
> mov(8) g116<1>.zwD g14<4,4,1>.xxxyD { align16 NoDDChk 1Q };<br>
> mov(8) g117<1>.zwD g14<4,4,1>.zzzwD { align16 NoDDChk 1Q };<br>
> <br>
> So we eliminated two add's, but then had to introduce four mov's to<br>
> transpose the result. Some of the hurt is because vectorization is a bit<br>
> over-aggressive and we vectorize something when we should have left it<br>
> as a scalar and CSEd it. Unfortunately, this is all really tricky to do<br>
> as it involves the interactions between many different components.<br>
> ---<br>
> src/intel/compiler/brw_nir.c | 6 ++++++<br>
> 1 file changed, 6 insertions(+)<br>
> <br>
> diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c<br>
> index 297845b89b7..564fd004a94 100644<br>
> --- a/src/intel/compiler/brw_nir.c<br>
> +++ b/src/intel/compiler/brw_nir.c<br>
> @@ -568,6 +568,12 @@ brw_nir_optimize(nir_shader *nir, const struct brw_compiler *compiler,<br>
> OPT(nir_copy_prop);<br>
> OPT(nir_opt_dce);<br>
> OPT(nir_opt_cse);<br>
> +<br>
> + if (!is_scalar) {<br>
> + OPT(nir_opt_vectorize);<br>
> + OPT(nir_copy_prop);<br>
> + }<br>
> +<br>
> OPT(nir_opt_peephole_select, 0);<br>
> OPT(nir_opt_intrinsics);<br>
> OPT(nir_opt_algebraic);<br>
> <br>
<br>
</blockquote></div></div>