<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - cpu_specific(generic) ignores a la carte CPU features"
href="https://bugs.llvm.org/show_bug.cgi?id=52407">52407</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>cpu_specific(generic) ignores a la carte CPU features
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>andrew.kaylor@intel.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>If I use cpu_dispatch+cpu_specific with a 'generic' implementation, the CPU
feature set for the 'generic' implementation does not include features that are
enabled on the command line by -m options, such as -mavx. For example:
extern __m256d _simd_drand48_pd64x4_avx1(void);
extern __m256d _simd_drand48_pd64x4_avx2(void);
// AVX1/AVX2 dispatcher
__attribute__((cpu_dispatch(generic, core_4th_gen_avx))) __m256d
_simd_drand48_pd64x4(void){}
__attribute__((cpu_specific(generic))) __m256d
_simd_drand48_pd64x4(void){ return _simd_drand48_pd64x4_avx1(); }
__attribute__((cpu_specific(core_4th_gen_avx))) __m256d
_simd_drand48_pd64x4(void){ return _simd_drand48_pd64x4_avx2(); }
If I compile this code with 'clang -O2 -mavx' I get the following error:
error: AVX vector return of type '__m256d' (vector of 4 'double' values)
without 'avx' enabled changes the ABI
However, if I compile with 'clang -O2 -march=sandybridge' it works.
<a href="https://godbolt.org/z/hb7hf1ddn">https://godbolt.org/z/hb7hf1ddn</a>
When ASTContext::getFunctionFeatureMap() calls
TargetInfo::getCPUSpecificCPUDispatchFeatures() for the 'generic' function, it
gets back an empty feature list, which I think makes sense. Then it calls
TargetInfo::initFeatureList() with CPU name set to 'x86_64' and passes the
empty feature list. I think ASTContext::getFunctionFeatureMap() needs to check
for 'generic' and specifically add the clang::TargetOptions::Features list to
the list it passes to TargetInfo::initFeatureList().</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>