<div>Hey Jan and Dave,</div><div><br></div><div>It's not obvious, but there is a significant scalar performance issue following the GCC intrinsics.</div><div><br></div><div>Let's look at the VFMADDSD pattern. We're operating on scalars with undefineds as the remaining vector elements of the operands. This sounds okay, but when one looks closer...</div>
<div><br></div> vmovsd fp4_+1088(%rip), %xmm3 # fpppp.f:647<br> vmovaps %xmm3, 18560(%rsp) # fpppp.f:647 <= 16-byte spill<br> vfmaddsd %xmm5, fp4_+3288(%rip), %xmm3, %xmm3 # fpppp.f:647<br>
<br><div>The spill here is 16-bytes. But, we're only using the low 8-bytes of xmm3. Changing the intrinsics and patterns to accept scalar operands, we end up with...</div><div><div><br> vmovsd fp4_+1056(%rip), %xmm0 # fpppp.f:666<br>
vmovsd %xmm0, 10088(%rsp) # fpppp.f:666 <= 8-byte spill<br> vfmaddsd %xmm3, fp4_+3288(%rip), %xmm0, %xmm3 # fpppp.f:666</div><div><br></div><div>I do not know the actual number of cycles offhand, but I believe on Interlagos and Sandybridge, a vmovaps takes roughly 3x as many micro-ops as a vmovsd if it involves memory.</div>
<div><br></div><div>-Cameron</div><div><br><div><div class="gmail_quote">On Thu, Jul 26, 2012 at 9:41 AM, Jan Sjodin <span dir="ltr"><<a href="mailto:jan_sjodin@yahoo.com" target="_blank">jan_sjodin@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Because the intrinsics uses vector types (same as gcc).<br>
<br>
<br>
- Jan<br>
<br>
<br>
<br>
----- Original Message -----<br>
> From: "<a href="mailto:dag@cray.com">dag@cray.com</a>" <<a href="mailto:dag@cray.com">dag@cray.com</a>><br>
> To: <a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a><br>
> Cc:<br>
> Sent: Wednesday, July 25, 2012 3:26 PM<br>
> Subject: [LLVMdev] X86 FMA4<br>
><br>
> We're migrating to LLVM 3.1 and trying to use the upstream FMA patterns.<br>
><br>
> Why is VFMADDSD4 defined with vector types? Is this simply because the<br>
> gcc intrinsic uses vector types? It's quite unnatural if you have a<br>
> compiler that generates FMAs as opposed to requiring user intrinsics.<br></blockquote></div></div></div></div>