<div dir="ltr"><div>128-bit wide vectorization is the limit for the SLP vectorizer:<br><a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D17170-23c8&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=MscTk3Y2h8b9moqXdTM49agD3I_wR72UcbmBXa9ME7g&s=Vkyhh03QcYGCXCRCBWlHrD2R7YfLyUj990z-358RghM&e=">https://llvm.org/bugs/show_bug.cgi?id=17170#c8</a><br><br></div>Is it possible that the cases where you saw 256-bit ops were transformed by the loop vectorizer rather than the SLP vectorizer?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 1, 2015 at 1:18 PM, Frank Winter <span dir="ltr"><<a href="mailto:fwinter@jlab.org" target="_blank">fwinter@jlab.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Nadav,<br>
<br>
I can check if we have a Haswell CPU somewhere running..<br>
<br>
In the meantime I send the link to the debug output of the SLP vectorizer. I don't understand all of it quite yet, but it seems it's not mentioning the 8-fold vectorization opportunity... (please find it here as it's 150KB and slightly over the list attachment limit of 100KB <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__www.dropbox.com_s_aarivrzees30zrj_SLP.txt-3Fdl-3D0&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=MscTk3Y2h8b9moqXdTM49agD3I_wR72UcbmBXa9ME7g&s=BFG-lh_dx6O3FZdCwUw704MbNZ_GdmDSTk0EVurNjZE&e=" rel="noreferrer" target="_blank">https://www.dropbox.com/s/aarivrzees30zrj/SLP.txt?dl=0</a>)<br>
<br>
Also, in a earlier version of my application I saw on similar functions that the SLP vectorizer uses 8xfloat on the same hardward (Sandy Bridge). In those versions I used LLVM 3.4 or 3.5 (trunk).<br>
<br>
Thanks,<br>
Frank<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On 07/01/2015 03:02 PM, Nadav Rotem wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Frank,<br>
<br>
It sounds like the SLP vectorizer thinks that it is more profitable to use 128bit wide operations (because 256bit operations are double pumped on Sandybridge). Did you see a different result on Haswell?<br>
<br>
Thanks,<br>
Nadav<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Jul 1, 2015, at 11:06 AM, Frank Winter <<a href="mailto:fwinter@jlab.org" target="_blank">fwinter@jlab.org</a>> wrote:<br>
<br>
I realized that the function parameters had no alignment attributes on them. However, even adding an alignment suitable for aligned loads on YMM, i.e. 32 bytes, didn't convince the vectorizer to use [8 x float].<br>
<br>
define void @main(i64 %lo, i64 %hi, float* noalias align 32 %arg0, float* noalias align 32 %arg1, float* noalias align 32 %arg2) {<br>
...<br>
<br>
results still in code using only [4 x float].<br>
<br>
Thanks,<br>
Frank<br>
<br>
<br>
On 07/01/2015 10:51 AM, Frank Winter wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I seem to have problem to get the SLP vectorizer to make use of the full 8 floats available in a SIMD vector on a Sandy Bridge CPU with AVX. The function is attached, the CPU flags are:<br>
<br>
flags        : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 x2apic popcnt aes xsave avx lahf_lm ida arat epb xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid<br>
<br>
I use LLVM 3.6 checked out yesterday<br>
<br>
~/toolchain/install/llvm-3.6/bin/opt -datalayout -basicaa -slp-vectorizer -instcombine < func_4x4x4_scalar_p_scalar.ll -S<br>
<br>
the output goes like:<br>
<br>
; ModuleID = '<stdin>'<br>
<br>
define void @main(i64 %lo, i64 %hi, float* noalias %arg0, float* noalias %arg1, float* noalias %arg2) {<br>
entrypoint:<br>
  %0 = bitcast float* %arg1 to <4 x float>*<br>
  %1 = load <4 x float>* %0, align 4<br>
  %2 = bitcast float* %arg2 to <4 x float>*<br>
  %3 = load <4 x float>* %2, align 4<br>
  %4 = fadd <4 x float> %3, %1<br>
  %5 = bitcast float* %arg0 to <4 x float>*<br>
  store <4 x float> %4, <4 x float>* %5, align 4<br>
....<br>
<br>
So, it could make use of <8 x float> available in that machine. But it doesn't. Then I thought, that maybe the YMM registers get used when lowering the IR to machine code. However, the generated assembly doesn't seem to support this assumption :-(<br>
<br>
<br>
main:<br>
    .cfi_startproc<br>
    xorl    %eax, %eax<br>
    xorl    %esi, %esi<br>
    .align    16, 0x90<br>
.LBB0_1:<br>
    vmovups    (%r8,%rax), %xmm0<br>
    vaddps    (%rcx,%rax), %xmm0, %xmm0<br>
    vmovups    %xmm0, (%rdx,%rax)<br>
    addq    $4, %rsi<br>
    addq    $16, %rax<br>
    cmpq    $61, %rsi<br>
    jb    .LBB0_1<br>
    retq<br>
<br>
I played with -mcpu and -march switches without success. In any case, the target architecture should be detected with the -datalayout pass, right?<br>
<br>
Any idea what I am missing?<br>
<br>
Frank<br>
<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></blockquote>
<br>
<br></div></div><span class="HOEnZb"><font color="#888888">
-- <br>
----------------------------------------------<br>
Dr Frank Winter,               Staff Scientist<br>
Thomas Jefferson National Accelerator Facility<br>
12000 Jefferson Ave, Newport News, 23606, USA<br>
<a href="tel:%2B1-757-269-6448" value="+17572696448" target="_blank">+1-757-269-6448</a>, <a href="mailto:fwinter@jlab.org" target="_blank">fwinter@jlab.org</a><br>
----------------------------------------------</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>