llvm-project/clang/lib/Headers
Chandler Carruth cbe6411401 Fix the SSE4 byte sign extension in a cleaner way, and more thoroughly
test that our intrinsics behave the same under -fsigned-char and
-funsigned-char.

This further testing uncovered that AVX-2 has a broken cmpgt for 8-bit
elements, and has for a long time. This is fixed in the same way as
SSE4 handles the case.

The other ISA extensions currently work correctly because they use
specific instruction intrinsics. As soon as they are rewritten in terms
of generic IR, they will need to add these special casts. I've added the
necessary testing to catch this however, so we shouldn't have to chase
it down again.

I considered changing the core typedef to be signed, but that seems like
a bad idea. Notably, it would be an ABI break if anyone is reaching into
the innards of the intrinsic headers and passing __v16qi on an API
boundary. I can't be completely confident that this wouldn't happen due
to a macro expanding in a lambda, etc., so it seems much better to leave
it alone. It also matches GCC's behavior exactly.

A fun side note is that for both GCC and Clang, -funsigned-char really
does change the semantics of __v16qi. To observe this, consider:

  % cat x.cc
  #include <smmintrin.h>
  #include <iostream>

  int main() {
    __v16qi a = { 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    __v16qi b = _mm_set1_epi8(-1);
    std::cout << (int)(a / b)[0] << ", " << (int)(a / b)[1] << '\n';
  }
  % clang++ -o x x.cc && ./x
  -1, 1
  % clang++ -funsigned-char -o x x.cc && ./x
  0, 1

However, while this may be surprising, both Clang and GCC agree.

Differential Revision: http://reviews.llvm.org/D13324

llvm-svn: 249097
2015-10-01 23:40:12 +00:00
..
CMakeLists.txt [SystemZ] Add support for vecintrin.h vector built-in functions 2015-07-30 14:10:43 +00:00
Intrin.h ms Intrin.h: Fix __movsw's and __stosw's inline asm. 2015-09-22 00:46:21 +00:00
Makefile Rename lib/Headers/module.map to module.modulemap 2014-04-17 00:52:48 +00:00
__stddef_max_align_t.h Restore the libc++ definition of max_align_t on Apple platforms 2015-02-24 01:06:22 +00:00
__wmmintrin_aes.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
__wmmintrin_pclmul.h Update the intel intrinsic headers to use the target attribute support. 2015-06-17 07:09:32 +00:00
adxintrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
altivec.h Forgot to remove a FIXME that has been fixed. NFC. 2015-09-29 18:20:59 +00:00
ammintrin.h Clean up trailing whitespace in the builtin headers 2015-09-12 02:55:19 +00:00
arm_acle.h This patch implements clang support for the ACLE special register intrinsics 2015-06-15 17:51:01 +00:00
avx2intrin.h Fix the SSE4 byte sign extension in a cleaner way, and more thoroughly 2015-10-01 23:40:12 +00:00
avx512bwintrin.h [X86][AVX512BW] Remove whitespaces 2015-07-30 06:52:26 +00:00
avx512cdintrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
avx512dqintrin.h re-apply r.247881 2015-09-17 14:53:37 +00:00
avx512erintrin.h Use a define for per-file function attributes for the Intel intrinsic headers. 2015-06-17 07:09:20 +00:00
avx512fintrin.h [X86] Fix some non-reserved parameter names in intrinsic headers 2015-09-21 11:45:27 +00:00
avx512vlbwintrin.h Clean up trailing whitespace in the builtin headers 2015-09-12 02:55:19 +00:00
avx512vldqintrin.h Clean up trailing whitespace in the builtin headers 2015-09-12 02:55:19 +00:00
avx512vlintrin.h [X86][AVX512VL] add AVX512VL intrinsics 4 out of 4 2015-07-28 12:04:40 +00:00
avxintrin.h Fix the SSE4 byte sign extension in a cleaner way, and more thoroughly 2015-10-01 23:40:12 +00:00
bmi2intrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
bmiintrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
cpuid.h Fix trailing commas in AMD define. 2014-10-01 21:22:17 +00:00
cuda_builtin_vars.h [cuda] Added support for CUDA built-in variables. 2015-04-21 22:14:13 +00:00
emmintrin.h Fix the SSE4 byte sign extension in a cleaner way, and more thoroughly 2015-10-01 23:40:12 +00:00
f16cintrin.h [X86] Make f16c intrinsics accessible through emmintrin.h, per Intel docs 2015-09-21 13:34:47 +00:00
float.h <float.h>: Don't seek #include_next if -ffreestanding for targeting mingw. 2014-10-22 01:25:49 +00:00
fma4intrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
fmaintrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
fxsrintrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
htmintrin.h [SystemZ] Support transactional execution on zEC12 2015-04-01 12:54:25 +00:00
htmxlintrin.h Clean up trailing whitespace in the builtin headers 2015-09-12 02:55:19 +00:00
ia32intrin.h [x86] Add Clang support for intrinsic __rdpmc. 2014-06-30 18:23:58 +00:00
immintrin.h Revert r245923 since it breaks mingw. 2015-08-25 11:42:31 +00:00
inttypes.h Add an inttypes.h wrapper that fixes up some macros in Microsoft mode. 2015-06-26 00:13:18 +00:00
iso646.h
limits.h
lzcntintrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
mm3dnow.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
mm_malloc.h
mmintrin.h Clean up trailing whitespace in the builtin headers 2015-09-12 02:55:19 +00:00
module.modulemap [SystemZ] Add support for vecintrin.h vector built-in functions 2015-07-30 14:10:43 +00:00
nmmintrin.h Update the intel intrinsic headers to use the target attribute support. 2015-06-17 07:09:32 +00:00
pmmintrin.h Clean up trailing whitespace in the builtin headers 2015-09-12 02:55:19 +00:00
popcntintrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
prfchwintrin.h [X86] Add missing _m_prefetch intrinsic 2015-07-27 19:01:52 +00:00
rdseedintrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
rtmintrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
s390intrin.h [SystemZ] Add support for vecintrin.h vector built-in functions 2015-07-30 14:10:43 +00:00
shaintrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
smmintrin.h Fix the SSE4 byte sign extension in a cleaner way, and more thoroughly 2015-10-01 23:40:12 +00:00
stdalign.h
stdarg.h Added standard macro guard. In case __GNUC_VA_LIST was not 2014-07-02 15:25:03 +00:00
stdatomic.h Don't use BCPL comments here, in case someone wants to use <stdatomic.h> from C89 mode. 2015-01-29 03:34:39 +00:00
stdbool.h
stddef.h Fix interaction of max_align_t and modules. 2014-10-03 00:31:35 +00:00
stdint.h Clean up trailing whitespace in the builtin headers 2015-09-12 02:55:19 +00:00
stdnoreturn.h
tbmintrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
tgmath.h Clean up trailing whitespace in the builtin headers 2015-09-12 02:55:19 +00:00
tmmintrin.h Clean up trailing whitespace in the builtin headers 2015-09-12 02:55:19 +00:00
unwind.h Headers: Don't use attribute keywords which aren't reserved 2015-02-04 00:26:10 +00:00
vadefs.h Intercept __crt_va_* used by MSVC "14" 2014-11-20 22:44:03 +00:00
varargs.h
vecintrin.h [SystemZ] Add support for vecintrin.h vector built-in functions 2015-07-30 14:10:43 +00:00
wmmintrin.h Update the intel intrinsic headers to use the target attribute support. 2015-06-17 07:09:32 +00:00
x86intrin.h Update the intel intrinsic headers to use the target attribute support. 2015-06-17 07:09:32 +00:00
xmmintrin.h Clean up trailing whitespace in the builtin headers 2015-09-12 02:55:19 +00:00
xopintrin.h [X86] Rename DEFAULT_FN_ATTR macro to __DEFAULT_FN_ATTR 2015-06-30 13:36:19 +00:00
xtestintrin.h Move xtest to its own file to match the gcc header organization. 2015-06-17 18:42:07 +00:00