<div dir="ltr">Hi there folks,<div><br></div><div>I wonder if anybody can shed some light on this. I'm looking at a function with a parameter pack argument and one without, that should do the exact same thing.</div><div><br></div><div><a href="https://godbolt.org/z/Keqzcj">https://godbolt.org/z/Keqzcj</a> <br clear="all"><div><br></div><div>However, the version with the parameter pack expands (at -O3 -march=broadwell, on clang 10.0.1, on godbolt) into a loop per 128 bytes, plus a loop per 64 bytes, plus nonvectorized instructions to process the remaining <=63 bytes. The manual version expands to just a loop per 128 bytes (256-bit vectors, unrolled 4x), and nonvectorized instructions to process the remaining <=127 bytes.</div><div><br></div><div>It's not about the fold expression. I replaced the inner loop of the first function by:</div><div><br></div><div><div style=""><div style="color:rgb(0,0,0);font-family:"Consolas, ";background-color:rgb(255,255,254)">    <span style="color:rgb(0,0,255)">auto</span> tuple = std::make_tuple(input[i]...);</div><div style="color:rgb(0,0,0);font-family:"Consolas, ";background-color:rgb(255,255,254)">    out[i] = get<<span style="color:rgb(9,134,88)">0</span>>(tuple) | get<<span style="color:rgb(9,134,88)">1</span>>(tuple) | get<<span style="color:rgb(9,134,88)">2</span>>(tuple);</div><div style=""><br></div>And it generates the same code AFAICT.</div><div style=""><br></div><div style="">It may be about __restrict__ expansion for parameter pack arguments. But I don't see how __restrict__ could lead to *these* differences.<br><br>FWIW, my benchmarks seem to indicate that the variadic version is about 50% slower. I have no idea why. The instruction order in the inner loop is different, which may make a difference?</div></div><div style=""><br></div><div style="">Any clues would be appreciated!</div><div style=""><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px"><div style="color:rgb(136,136,136);font-size:12.8px"><span style="font-size:12.8px;color:rgb(34,34,34)">Bart Samwel</span><br></div><div style="font-size:12.8px"><a href="mailto:bart.samwel@databricks.com" target="_blank">bart.samwel@databricks.com</a></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><img src="https://docs.google.com/uc?export=download&id=1iplOU5OHdtakkH1xKbxfcB-4BA6DXfKc&revid=0B9RlGdocqKy4L2hpckhpbmM4dmNIekJpVVhNamlndmFzYUprPQ" width="200" height="32"><br></div><div style="font-size:12.8px"><p dir="ltr" style="font-size:12.8px;line-height:1.2;margin-top:0pt;margin-bottom:0pt"></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>