16bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines// RUN: %clang_cc1 %s -ffreestanding -triple x86_64-apple-macosx10.9.0 -emit-llvm -o - | FileCheck %s
2b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar//
3b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar// RUN: rm -rf %t
4b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar// RUN: %clang_cc1 %s -ffreestanding -triple x86_64-apple-macosx10.9.0 -emit-llvm -o - \
587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar// RUN:     -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -isystem %S/Inputs/include \
6b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar// RUN:     | FileCheck %s
787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar// REQUIRES: x86-registered-target
86bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines#include <xmmintrin.h>
96bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines
104967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar// CHECK: @c = common global i8 0, align 16
114967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar_MM_ALIGN16 char c;
124967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar
136bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines// Make sure the last step of _mm_cvtps_pi16 converts <4 x i32> to <4 x i16> by
146bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines// checking that clang emits PACKSSDW instead of PACKSSWB.
156bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines
166bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines// CHECK: define i64 @test_mm_cvtps_pi16
176bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines// CHECK: call x86_mmx @llvm.x86.mmx.packssdw
186bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines
196bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines__m64 test_mm_cvtps_pi16(__m128 a) {
206bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines  return _mm_cvtps_pi16(a);
216bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines}
22b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar
23b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar// Make sure that including <xmmintrin.h> also makes <emmintrin.h>'s content available.
24b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar// This is an ugly hack for GCC compatibility.
25b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar__m128 test_xmmintrin_provides_emmintrin(__m128d __a, __m128d __b) {
26b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar  return _mm_add_sd(__a, __b);
27b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar}
28b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar
294967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar#if __STDC_HOSTED__
304967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar// Make sure stdlib.h symbols are accessible.
314967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainarvoid *p = NULL;
324967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar#endif
33