<div dir="ltr"><pre><code>For the list of cpus and features for the current target, you can try:<br>$ llvm-as < /dev/null | llc -mcpu=help</code></pre></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Dec 12, 2013 at 8:57 AM, Arnold Schwaighofer <span dir="ltr"><<a href="mailto:aschwaighofer@apple.com" target="_blank">aschwaighofer@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It probably does not pick the right processor architecture.<br>
<br>
You could try “clang -mavx” or “clang -march=corei7-avx” for ivy-bridge and “clang -march=core-avx2” or “clang -mavx2" for haswell.<br>
<br>
$ clang -march=core-avx2 -O3 -S -o - test.c<br>
<br>
.section __TEXT,__text,regular,pure_instructions<br>
.globl _f<br>
.align 4, 0x90<br>
_f: ## @f<br>
.cfi_startproc<br>
## BB#0: ## %entry<br>
pushq %rbp<br>
Ltmp2:<br>
.cfi_def_cfa_offset 16<br>
Ltmp3:<br>
.cfi_offset %rbp, -16<br>
movq %rsp, %rbp<br>
Ltmp4:<br>
.cfi_def_cfa_register %rbp<br>
xorl %eax, %eax<br>
.align 4, 0x90<br>
LBB0_1: ## %vector.body<br>
## =>This Inner Loop Header: Depth=1<br>
vmovups (%rdx,%rax,4), %ymm0<br>
vmulps (%rsi,%rax,4), %ymm0, %ymm0<br>
vaddps (%rdi,%rax,4), %ymm0, %ymm0<br>
vmovups %ymm0, (%rdi,%rax,4)<br>
addq $8, %rax<br>
cmpq $256, %rax ## imm = 0x100<br>
jne LBB0_1<br>
## BB#2: ## %for.end<br>
popq %rbp<br>
vzeroupper<br>
ret<br>
.cfi_endproc<br>
$ cat test.c<br>
void f(float * restrict A, float * restrict B, float * restrict C) {<br>
for (int i = 0; i < 256; ++i)<br>
A[i] += C[i] *B[i];<br>
}<br>
<br>
$ clang -v<br>
clang version 3.5 (trunk 195376) (llvm/trunk 195372)<br>
<br>
<br>
Best,<br>
Arnold<br>
<div><div class="h5"><br>
On Dec 11, 2013, at 2:59 PM, Ken Gahagan <<a href="mailto:ken.gahagan@gmail.com">ken.gahagan@gmail.com</a>> wrote:<br>
<br>
> Hello -<br>
><br>
> I found this post on the llvm blog: <a href="http://blog.llvm.org/2012/12/new-loop-vectorizer.html" target="_blank">http://blog.llvm.org/2012/12/new-loop-vectorizer.html</a> which makes me think that clang / llvm are capable of generating AVX with packed instructions as well as utilizing the full width of the YMM registers… I have an environment where icc generates these instructions (vmulps %ymm1, %ymm3, %ymm2 for example) but I can not get clang/llvm to generate such instructions (using the 3.3 release or either 3.4 rc1 or 3.4 rc2). I am new to clang / llvm so I may not be invoking the tools correctly but given that –fvectorize and –fslp-vectorize are on by default at 3.4 I would have thought that if the code is AVX-able by icc that clang / llvm would be able to do the same… The code is basic matrix multiplication written a number of ways (with and without transposition and such) as a performance measurement exercise.<br>
><br>
> The environments I’ve tried are:<br>
> Intel Ivy Bridge-EX (pre-release hardware) running Red Hat Linux 6.5<br>
> Generic desktop with Haswell processor running Fedora 18<br>
><br>
> If you have a moment to point me to the appropriate docs I’m happy to go learn on my own – but I’ve now googled for the better part of 3 days trying to find what invocation parameters I should use to get the desired use of packed AVX instructions and the YMM registers and I just can’t seem to get it right. I’m also grateful if you just send the correct invocation.<br>
><br>
> I’ve actually started digging through the code as well - but since I am starting from zero it could take me a while to find an answer this way - just didn’t want you to think I’m not willing to try to find the answer on my own :-)<br>
><br>
> Thank you,<br>
> Ken<br>
><br>
</div></div>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br></div>