[llvm-bugs] [Bug 41283] New: Pointless static initializer guard generated for SIMD intrinsics

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 28 13:04:35 PDT 2019


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

            Bug ID: 41283
           Summary: Pointless static initializer guard generated for SIMD
                    intrinsics
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: fabiang at radgametools.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Example:

-

#include <xmmintrin.h>

__m128i foo()
{
    static const __m128i x = _mm_set1_epi32(1234); // <-- generates init guard
    //const __m128i x = _mm_set1_epi32(1234); // <-- no guard
    return x;
}

-

The intrinsic turns into a literal constant and then the static initializer
ends up producing a guard to copy one value from .rodata to .bss that it could
just access directly.

This is easy enough to work around in the source (just avoid static consts for
this kind of SIMD constants) but I've now run into this multiple times; maybe
there is a way to handle this better on the Clang side as well?

(I suppose the tricky part is that Clang codegen doesn't know which intrinsics
get constant-folded at compile time, so it has to emit the guards just in case
they can't.)

-- 
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/20190328/21be7e14/attachment.html>


More information about the llvm-bugs mailing list