[llvm-bugs] [Bug 52407] New: cpu_specific(generic) ignores a la carte CPU features

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 4 10:52:42 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52407

            Bug ID: 52407
           Summary: cpu_specific(generic) ignores a la carte CPU features
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: andrew.kaylor at intel.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

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.

https://godbolt.org/z/hb7hf1ddn

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().

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211104/3b4e870e/attachment.html>


More information about the llvm-bugs mailing list