<div dir="ltr">Correction in the C snippet:<div><div><br></div><div><div>typedef signed short v8i16_t __attribute__((ext_vector_type(8)));</div><div><br></div><div><div><div>v8i16_t foo (v8i16_t a, int n)</div><div>{</div><div> return a >> n;<br></div><div>}<br></div></div></div></div><div><br></div><div class="gmail_extra">Best regards</div><div class="gmail_extra">Saurabh</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 17 February 2017 at 16:21, Saurabh Verma <span dir="ltr"><<a href="mailto:saurabh.verma@movidius.com" target="_blank">saurabh.verma@movidius.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>We are investigating a difference in code generation for vector splat instructions between llvm-3.9 and llvm-4.0, which could lead to a performance regression for our target. Here is the C snippet</div><div><br></div><div>typedef signed v8i16_t __attribute__((ext_vector_<wbr>type(8)))<br></div><div><div><br></div><div>v8i16_t foo (v8i16 a, int n)</div><div>{</div><div> return result = a >> n;<br></div><div>}<br></div></div><div><br></div><div>With llvm-3.9, the generated sequence does a trunc followed by splat, but with llvm-4.0 it is reversed to a splat to a bigger vector followed by a v8i32->v8i16 trunc. Is this by design? The earlier code sequence is definitely better for our target, but are there known scenarios where the new sequence would lead to better code?</div><div><br></div><div>Here are the instruction sequences generated in the two cases:</div><div><br></div><div>With llvm 3.9:</div><div><br></div><div><div>define <8 x i16> @foo(<8 x i16>, i32) #0 {</div><div> %3 = trunc i32 %1 to i16</div><div> %4 = insertelement <8 x i16> undef, i16 %3, i32 0</div><div> %5 = shufflevector <8 x i16> %4, <8 x i16> undef, <8 x i32> zeroinitializer</div><div> %6 = ashr <8 x i16> %0, %5</div><div> ret <8 x i16> %6</div><div>}</div></div><div><br></div><div><br></div><div>With llvm 4.0:</div><div><br></div><div><div>define <8 x i16> @foo(<8 x i16>, i32) #0 {</div><div> %3 = insertelement <8 x i32> undef, i32 %1, i32 0</div><div> %4 = shufflevector <8 x i32> %3, <8 x i32> undef, <8 x i32> zeroinitializer</div><div> %5 = trunc <8 x i32> %4 to <8 x i16></div><div> %6 = ashr <8 x i16> %0, %5</div><div> ret <8 x i16> %6</div><div>}</div></div><div><br></div><div>Best regards</div><span class="gmail-HOEnZb"><font color="#888888"><div>Saurabh Verma</div></font></span></div>
</blockquote></div><br></div></div></div>