<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/92906>92906</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Codegen issue with SVML vectorization on Windows. (wrong calling convention?)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
OliverHallam
</td>
</tr>
</table>
<pre>
I am building on Clang-CL 17.0.3 via Visual Studio 2022 on Windows.
I'm using SVML to vectorise some loops (with the flags `/O2 /arch:AVX2 -openmp /clang:-fveclib=SVML /clang:-fno-math-errno`), and linking against svml_dispmd.lib as shipped with the 2024.0 Intel compiler
I have a attached a [Repro solution](https://github.com/llvm/llvm-project/files/15389811/CppApp.zip) that reproduces the problem. You can see with a breakpoint in the main method that the array is filled with `-inf` when SVML is used instead of the correct values.
As far as I understand it, I think the issue is that the Intel SVML functions use a vectorcall calling convention, and the arguments should be passed in ymm0 and ymm1, however the compiler seems to be calling them using cdecl with pointers in rcx and rdx:
```
00007FF67DDF1090 vmovups ymm0,ymmword ptr [rsi+rdi]
00007FF67DDF1095 vmovaps ymmword ptr [rsp+80h],ymm0
00007FF67DDF109E vmovapd ymm0,ymmword ptr [rsp+40h]
00007FF67DDF10A4 vmovapd ymmword ptr [rsp+0A0h],ymm0
00007FF67DDF10AD lea rcx,[rsp+0A0h]
00007FF67DDF10B5 mov rdx,rbx
00007FF67DDF10B8 call __svml_pow4 (07FF67DDF1E00h)
```
Testing on [godbolt](https://godbolt.org/z/bM4EaP1ae), I see no issue with the generated assembly, so I suspect this is windows-specific.
```
vmovups ymm1, ymmword ptr [rbx + r13]
vmovupd ymm0, ymmword ptr [rsp + 48] # 32-byte Reload
call __svml_pow4@PLT
```
Unfortunately as I'm running from VS I don't have bugpoint, but hopefully the above description and repro helps narrow this down.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVk2P2zg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