522 lines · c
1// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X642// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X643// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK4// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK5// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X646// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X647// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK8// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK9 10// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X6411// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X6412// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK13// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK14// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X6415// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse4.1 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X6416// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK17// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +sse4.1 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK18 19 20#include <immintrin.h>21#include "builtin_test_helpers.h"22 23// NOTE: This should match the tests in llvm/test/CodeGen/X86/sse41-intrinsics-fast-isel.ll24 25__m128i test_mm_blend_epi16(__m128i V1, __m128i V2) {26 // CHECK-LABEL: test_mm_blend_epi1627 // CHECK: shufflevector <8 x i16> %{{.*}}, <8 x i16> %{{.*}}, <8 x i32> <i32 0, i32 9, i32 2, i32 11, i32 4, i32 13, i32 6, i32 7>28 return _mm_blend_epi16(V1, V2, 42);29}30TEST_CONSTEXPR(match_v8hi(_mm_blend_epi16(((__m128i)(__v8hi){1,2,3,4,5,6,7,8}),((__m128i)(__v8hi){-1,-2,-3,-4,-5,-6,-7,-8}),0x00),1,2,3,4,5,6,7,8));31TEST_CONSTEXPR(match_v8hi(_mm_blend_epi16(((__m128i)(__v8hi){1,2,3,4,5,6,7,8}),((__m128i)(__v8hi){-1,-2,-3,-4,-5,-6,-7,-8}),0x5A),1,-2,3,-4,-5,6,-7,8));32TEST_CONSTEXPR(match_v8hi(_mm_blend_epi16(((__m128i)(__v8hi){1,2,3,4,5,6,7,8}),((__m128i)(__v8hi){-1,-2,-3,-4,-5,-6,-7,-8}),0x94),1,2,-3,4,-5,6,7,-8));33TEST_CONSTEXPR(match_v8hi(_mm_blend_epi16(((__m128i)(__v8hi){1,2,3,4,5,6,7,8}),((__m128i)(__v8hi){-1,-2,-3,-4,-5,-6,-7,-8}),0xFF),-1,-2,-3,-4,-5,-6,-7,-8));34 35__m128d test_mm_blend_pd(__m128d V1, __m128d V2) {36 // CHECK-LABEL: test_mm_blend_pd37 // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x i32> <i32 0, i32 3>38 return _mm_blend_pd(V1, V2, 2);39}40TEST_CONSTEXPR(match_m128d(_mm_blend_pd(((__m128d){1.0, 2.0}), ((__m128d){3.0, 4.0}), 0), 1.0, 2.0));41TEST_CONSTEXPR(match_m128d(_mm_blend_pd(((__m128d){1.0, 2.0}), ((__m128d){3.0, 4.0}), 1), 3.0, 2.0));42TEST_CONSTEXPR(match_m128d(_mm_blend_pd(((__m128d){1.0, 2.0}), ((__m128d){3.0, 4.0}), 2), 1.0, 4.0));43TEST_CONSTEXPR(match_m128d(_mm_blend_pd(((__m128d){1.0, 2.0}), ((__m128d){3.0, 4.0}), 3), 3.0, 4.0));44 45__m128 test_mm_blend_ps(__m128 V1, __m128 V2) {46 // CHECK-LABEL: test_mm_blend_ps47 // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> <i32 0, i32 5, i32 6, i32 3>48 return _mm_blend_ps(V1, V2, 6);49}50TEST_CONSTEXPR(match_m128(_mm_blend_ps(((__m128){1.0f, 2.0f, 3.0f, 4.0f}), ((__m128){5.0f, 6.0f, 7.0f, 8.0f}), 0x0), 1.0f, 2.0f, 3.0f, 4.0f));51TEST_CONSTEXPR(match_m128(_mm_blend_ps(((__m128){1.0f, 2.0f, 3.0f, 4.0f}), ((__m128){5.0f, 6.0f, 7.0f, 8.0f}), 0x5), 5.0f, 2.0f, 7.0f, 4.0f));52TEST_CONSTEXPR(match_m128(_mm_blend_ps(((__m128){1.0f, 2.0f, 3.0f, 4.0f}), ((__m128){5.0f, 6.0f, 7.0f, 8.0f}), 0xA), 1.0f, 6.0f, 3.0f, 8.0f));53TEST_CONSTEXPR(match_m128(_mm_blend_ps(((__m128){1.0f, 2.0f, 3.0f, 4.0f}), ((__m128){5.0f, 6.0f, 7.0f, 8.0f}), 0xF), 5.0f, 6.0f, 7.0f, 8.0f));54 55__m128i test_mm_blendv_epi8(__m128i V1, __m128i V2, __m128i V3) {56 // CHECK-LABEL: test_mm_blendv_epi857 // CHECK: call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}})58 return _mm_blendv_epi8(V1, V2, V3);59}60TEST_CONSTEXPR(match_v16qi(_mm_blendv_epi8((__m128i)(__v16qs){0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},(__m128i)(__v16qs){-99,-98,97,-96,-95,-94,-93,-92,-91,-90,-89,-88,-87,-86,-85,-84},(__m128i)(__v16qs){-1,-1,0,-1,0,0,0,0,0,-1,-1,-1,0,0,-1,0}), -99, -98, 2, -96, 4, 5, 6, 7, 8, -90, -89, -88, 12, 13, -85, 15));61 62__m128d test_mm_blendv_pd(__m128d V1, __m128d V2, __m128d V3) {63 // CHECK-LABEL: test_mm_blendv_pd64 // CHECK: call {{.*}}<2 x double> @llvm.x86.sse41.blendvpd(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})65 return _mm_blendv_pd(V1, V2, V3);66}67TEST_CONSTEXPR(match_m128d(_mm_blendv_pd((__m128d)(__v2df){2.0, -4.0},(__m128d)(__v2df){-111.0, +222.0},(__m128d)(__v2df){2.0, -2.0}), 2.0, 222.0));68 69__m128 test_mm_blendv_ps(__m128 V1, __m128 V2, __m128 V3) {70 // CHECK-LABEL: test_mm_blendv_ps71 // CHECK: call {{.*}}<4 x float> @llvm.x86.sse41.blendvps(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})72 return _mm_blendv_ps(V1, V2, V3);73}74TEST_CONSTEXPR(match_m128(_mm_blendv_ps((__m128)(__v4sf){0.0f, 1.0f, 2.0f, 3.0f},(__m128)(__v4sf){-100.0f, -101.0f, -102.0f, -103.0f},(__m128)(__v4sf){-1.0f, 2.0f, -3.0f, 0.0f}), -100.0f, 1.0f, -102.0f, 3.0f));75 76__m128d test_mm_ceil_pd(__m128d x) {77 // CHECK-LABEL: test_mm_ceil_pd78 // CHECK: call {{.*}}<2 x double> @llvm.x86.sse41.round.pd(<2 x double> %{{.*}}, i32 2)79 return _mm_ceil_pd(x);80}81 82__m128 test_mm_ceil_ps(__m128 x) {83 // CHECK-LABEL: test_mm_ceil_ps84 // CHECK: call {{.*}}<4 x float> @llvm.x86.sse41.round.ps(<4 x float> %{{.*}}, i32 2)85 return _mm_ceil_ps(x);86}87 88__m128d test_mm_ceil_sd(__m128d x, __m128d y) {89 // CHECK-LABEL: test_mm_ceil_sd90 // CHECK: call {{.*}}<2 x double> @llvm.x86.sse41.round.sd(<2 x double> %{{.*}}, <2 x double> %{{.*}}, i32 2)91 return _mm_ceil_sd(x, y);92}93 94__m128 test_mm_ceil_ss(__m128 x, __m128 y) {95 // CHECK-LABEL: test_mm_ceil_ss96 // CHECK: call {{.*}}<4 x float> @llvm.x86.sse41.round.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i32 2)97 return _mm_ceil_ss(x, y);98}99 100__m128i test_mm_cmpeq_epi64(__m128i A, __m128i B) {101 // CHECK-LABEL: test_mm_cmpeq_epi64102 // CHECK: icmp eq <2 x i64>103 // CHECK: sext <2 x i1> %{{.*}} to <2 x i64>104 return _mm_cmpeq_epi64(A, B);105}106TEST_CONSTEXPR(match_v2di(_mm_cmpeq_epi64((__m128i)(__v2di){+1, -8}, (__m128i)(__v2di){-10, -8}), 0, -1));107 108__m128i test_mm_cvtepi8_epi16(__m128i a) {109 // CHECK-LABEL: test_mm_cvtepi8_epi16110 // CHECK: shufflevector <16 x i8> {{.*}}, <16 x i8> {{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>111 // CHECK: sext <8 x i8> {{.*}} to <8 x i16>112 return _mm_cvtepi8_epi16(a);113}114 115TEST_CONSTEXPR(match_v8hi(_mm_cvtepi8_epi16(_mm_setr_epi8(-3, 2, -1, 0, 1, -2, 3, -4, 0, 0, 0, 0, 0, 0, 0, 0)), -3, 2, -1, 0, 1, -2, 3, -4));116 117__m128i test_mm_cvtepi8_epi32(__m128i a) {118 // CHECK-LABEL: test_mm_cvtepi8_epi32119 // CHECK: shufflevector <16 x i8> {{.*}}, <16 x i8> {{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>120 // CHECK: sext <4 x i8> {{.*}} to <4 x i32>121 return _mm_cvtepi8_epi32(a);122}123 124TEST_CONSTEXPR(match_v4si(_mm_cvtepi8_epi32(_mm_setr_epi8(-3, 2, -1, 0, 1, -2, 3, -4, 0, 0, 0, 0, 0, 0, 0, 0)), -3, 2, -1, 0));125 126__m128i test_mm_cvtepi8_epi64(__m128i a) {127 // CHECK-LABEL: test_mm_cvtepi8_epi64128 // CHECK: shufflevector <16 x i8> {{.*}}, <16 x i8> {{.*}}, <2 x i32> <i32 0, i32 1>129 // CHECK: sext <2 x i8> {{.*}} to <2 x i64>130 return _mm_cvtepi8_epi64(a);131}132 133TEST_CONSTEXPR(match_v2di(_mm_cvtepi8_epi64(_mm_setr_epi8(-3, 2, -1, 0, 1, -2, 3, -4, 0, 0, 0, 0, 0, 0, 0, 0)), -3, 2));134 135__m128i test_mm_cvtepi16_epi32(__m128i a) {136 // CHECK-LABEL: test_mm_cvtepi16_epi32137 // CHECK: shufflevector <8 x i16> {{.*}}, <8 x i16> {{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>138 // CHECK: sext <4 x i16> {{.*}} to <4 x i32>139 return _mm_cvtepi16_epi32(a);140}141 142TEST_CONSTEXPR(match_v4si(_mm_cvtepi16_epi32(_mm_setr_epi16(-300, 2, -1, 0, 1, -2, 3, -4)), -300, 2, -1, 0));143 144__m128i test_mm_cvtepi16_epi64(__m128i a) {145 // CHECK-LABEL: test_mm_cvtepi16_epi64146 // CHECK: shufflevector <8 x i16> {{.*}}, <8 x i16> {{.*}}, <2 x i32> <i32 0, i32 1>147 // CHECK: sext <2 x i16> {{.*}} to <2 x i64>148 return _mm_cvtepi16_epi64(a);149}150 151TEST_CONSTEXPR(match_v2di(_mm_cvtepi16_epi64(_mm_setr_epi16(-300, 2, -1, 0, 1, -2, 3, -4)), -300, 2));152 153__m128i test_mm_cvtepi32_epi64(__m128i a) {154 // CHECK-LABEL: test_mm_cvtepi32_epi64155 // CHECK: shufflevector <4 x i32> {{.*}}, <4 x i32> {{.*}}, <2 x i32> <i32 0, i32 1>156 // CHECK: sext <2 x i32> {{.*}} to <2 x i64>157 return _mm_cvtepi32_epi64(a);158}159 160TEST_CONSTEXPR(match_v2di(_mm_cvtepi32_epi64(_mm_setr_epi32(-70000, 2, -1, 0)), -70000, 2));161 162__m128i test_mm_cvtepu8_epi16(__m128i a) {163 // CHECK-LABEL: test_mm_cvtepu8_epi16164 // CHECK: shufflevector <16 x i8> {{.*}}, <16 x i8> {{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>165 // CHECK: zext <8 x i8> {{.*}} to <8 x i16>166 return _mm_cvtepu8_epi16(a);167}168 169TEST_CONSTEXPR(match_v8hi(_mm_cvtepu8_epi16(_mm_setr_epi8(-3, 2, -1, 0, 1, -2, 3, -4, 0, 0, 0, 0, 0, 0, 0, 0)), 253, 2, 255, 0, 1, 254, 3, 252));170 171__m128i test_mm_cvtepu8_epi32(__m128i a) {172 // CHECK-LABEL: test_mm_cvtepu8_epi32173 // CHECK: shufflevector <16 x i8> {{.*}}, <16 x i8> {{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>174 // CHECK: zext <4 x i8> {{.*}} to <4 x i32>175 return _mm_cvtepu8_epi32(a);176}177 178TEST_CONSTEXPR(match_v4si(_mm_cvtepu8_epi32(_mm_setr_epi8(-3, 2, -1, 0, 1, -2, 3, -4, 0, 0, 0, 0, 0, 0, 0, 0)), 253, 2, 255, 0));179 180__m128i test_mm_cvtepu8_epi64(__m128i a) {181 // CHECK-LABEL: test_mm_cvtepu8_epi64182 // CHECK: shufflevector <16 x i8> {{.*}}, <16 x i8> {{.*}}, <2 x i32> <i32 0, i32 1>183 // CHECK: zext <2 x i8> {{.*}} to <2 x i64>184 return _mm_cvtepu8_epi64(a);185}186 187TEST_CONSTEXPR(match_v2di(_mm_cvtepu8_epi64(_mm_setr_epi8(-3, 2, -1, 0, 1, -2, 3, -4, 0, 0, 0, 0, 0, 0, 0, 0)), 253, 2));188 189__m128i test_mm_cvtepu16_epi32(__m128i a) {190 // CHECK-LABEL: test_mm_cvtepu16_epi32191 // CHECK: shufflevector <8 x i16> {{.*}}, <8 x i16> {{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>192 // CHECK: zext <4 x i16> {{.*}} to <4 x i32>193 return _mm_cvtepu16_epi32(a);194}195 196TEST_CONSTEXPR(match_v4si(_mm_cvtepu16_epi32(_mm_setr_epi16(-300, 2, -1, 0, 1, -2, 3, -4)), 65236, 2, 65535, 0));197 198__m128i test_mm_cvtepu16_epi64(__m128i a) {199 // CHECK-LABEL: test_mm_cvtepu16_epi64200 // CHECK: shufflevector <8 x i16> {{.*}}, <8 x i16> {{.*}}, <2 x i32> <i32 0, i32 1>201 // CHECK: zext <2 x i16> {{.*}} to <2 x i64>202 return _mm_cvtepu16_epi64(a);203}204 205TEST_CONSTEXPR(match_v2di(_mm_cvtepu16_epi64(_mm_setr_epi16(-300, 2, -1, 0, 1, -2, 3, -4)), 65236, 2));206 207__m128i test_mm_cvtepu32_epi64(__m128i a) {208 // CHECK-LABEL: test_mm_cvtepu32_epi64209 // CHECK: shufflevector <4 x i32> {{.*}}, <4 x i32> {{.*}}, <2 x i32> <i32 0, i32 1>210 // CHECK: zext <2 x i32> {{.*}} to <2 x i64>211 return _mm_cvtepu32_epi64(a);212}213 214TEST_CONSTEXPR(match_v2di(_mm_cvtepu32_epi64(_mm_setr_epi32(-70000, 2, -1, 0)), 4294897296, 2));215 216__m128d test_mm_dp_pd(__m128d x, __m128d y) {217 // CHECK-LABEL: test_mm_dp_pd218 // CHECK: call {{.*}}<2 x double> @llvm.x86.sse41.dppd(<2 x double> {{.*}}, <2 x double> {{.*}}, i8 7)219 return _mm_dp_pd(x, y, 7);220}221 222__m128 test_mm_dp_ps(__m128 x, __m128 y) {223 // CHECK-LABEL: test_mm_dp_ps224 // CHECK: call {{.*}}<4 x float> @llvm.x86.sse41.dpps(<4 x float> {{.*}}, <4 x float> {{.*}}, i8 7)225 return _mm_dp_ps(x, y, 7);226}227 228int test_mm_extract_epi8(__m128i x) {229 // CHECK-LABEL: test_mm_extract_epi8230 // CHECK: extractelement <16 x i8> %{{.*}}, {{i32|i64}} 1231 // CHECK: zext i8 %{{.*}} to i32232 return _mm_extract_epi8(x, 1);233}234TEST_CONSTEXPR(_mm_extract_epi8(((__m128i)(__v16qi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}), 20) == 4);235 236int test_mm_extract_epi32(__m128i x) {237 // CHECK-LABEL: test_mm_extract_epi32238 // CHECK: extractelement <4 x i32> %{{.*}}, {{i32|i64}} 1239 return _mm_extract_epi32(x, 1);240}241TEST_CONSTEXPR(_mm_extract_epi32(((__m128i)(__v4si){1, 3, 5, 7}), 10) == 5);242 243long long test_mm_extract_epi64(__m128i x) {244 // CHECK-LABEL: test_mm_extract_epi64245 // CHECK: extractelement <2 x i64> %{{.*}}, {{i32|i64}} 1246 return _mm_extract_epi64(x, 1);247}248TEST_CONSTEXPR(_mm_extract_epi64(((__m128i)(__v2di){11, 22}), 5) == 22);249 250int test_mm_extract_ps(__m128 x) {251 // CHECK-LABEL: test_mm_extract_ps252 // CHECK: extractelement <4 x float> %{{.*}}, {{i32|i64}} 1253 return _mm_extract_ps(x, 1);254}255TEST_CONSTEXPR(_mm_extract_ps(((__m128){1.25f, 2.5f, 3.75f, 5.0f}), 6) == __builtin_bit_cast(int, 3.75f));256 257__m128d test_mm_floor_pd(__m128d x) {258 // CHECK-LABEL: test_mm_floor_pd259 // CHECK: call {{.*}}<2 x double> @llvm.x86.sse41.round.pd(<2 x double> %{{.*}}, i32 1)260 return _mm_floor_pd(x);261}262 263__m128 test_mm_floor_ps(__m128 x) {264 // CHECK-LABEL: test_mm_floor_ps265 // CHECK: call {{.*}}<4 x float> @llvm.x86.sse41.round.ps(<4 x float> %{{.*}}, i32 1)266 return _mm_floor_ps(x);267}268 269__m128d test_mm_floor_sd(__m128d x, __m128d y) {270 // CHECK-LABEL: test_mm_floor_sd271 // CHECK: call {{.*}}<2 x double> @llvm.x86.sse41.round.sd(<2 x double> %{{.*}}, <2 x double> %{{.*}}, i32 1)272 return _mm_floor_sd(x, y);273}274 275__m128 test_mm_floor_ss(__m128 x, __m128 y) {276 // CHECK-LABEL: test_mm_floor_ss277 // CHECK: call {{.*}}<4 x float> @llvm.x86.sse41.round.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i32 1)278 return _mm_floor_ss(x, y);279}280 281__m128i test_mm_insert_epi8(__m128i x, char b) {282 // CHECK-LABEL: test_mm_insert_epi8283 // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, {{i32|i64}} 1284 return _mm_insert_epi8(x, b, 1);285}286TEST_CONSTEXPR(match_v16qi(_mm_insert_epi8(((__m128i)(__v16qi){ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}), 101, 33), 0, 101, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15));287 288__m128i test_mm_insert_epi32(__m128i x, int b) {289 // CHECK-LABEL: test_mm_insert_epi32290 // CHECK: insertelement <4 x i32> %{{.*}}, i32 %{{.*}}, {{i32|i64}} 1291 return _mm_insert_epi32(x, b, 1);292}293TEST_CONSTEXPR(match_v4si(_mm_insert_epi32(((__m128i)(__v4si){0, 1, 2, 3}), 5678, 18), 0, 1, 5678, 3));294 295#ifdef __x86_64__296__m128i test_mm_insert_epi64(__m128i x, long long b) {297 // X64-LABEL: test_mm_insert_epi64298 // X64: insertelement <2 x i64> %{{.*}}, i64 %{{.*}}, {{i32|i64}} 1299 return _mm_insert_epi64(x, b, 1);300}301TEST_CONSTEXPR(match_v2di(_mm_insert_epi64(((__m128i)(__v2di){100, 200}), -999, 9), 100, -999));302#endif303 304__m128 test_mm_insert_ps(__m128 x, __m128 y) {305 // CHECK-LABEL: test_mm_insert_ps306 // CHECK: call {{.*}}<4 x float> @llvm.x86.sse41.insertps(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 4)307 return _mm_insert_ps(x, y, 4);308}309 310TEST_CONSTEXPR((match_m128(_mm_insert_ps(((__m128)(__v4sf){1.0f, 2.0f, 3.0f, 4.0f}), ((__m128)(__v4sf){10.0f, 20.0f, 30.0f, 40.0f}), 0x10), 1.0f, 10.0f, 3.0f, 4.0f))); // Insert Y[0] into X[1]311TEST_CONSTEXPR((match_m128(_mm_insert_ps(((__m128)(__v4sf){1.0f, 2.0f, 3.0f, 4.0f}), ((__m128)(__v4sf){10.0f, 20.0f, 30.0f, 40.0f}), 0x00), 10.0f, 2.0f, 3.0f, 4.0f))); // Insert Y[0] into X[0]312TEST_CONSTEXPR((match_m128(_mm_insert_ps(((__m128)(__v4sf){1.0f, 2.0f, 3.0f, 4.0f}), ((__m128)(__v4sf){10.0f, 20.0f, 30.0f, 40.0f}), 0x20), 1.0f, 2.0f, 10.0f, 4.0f))); // Insert Y[0] into X[2]313TEST_CONSTEXPR((match_m128(_mm_insert_ps(((__m128)(__v4sf){1.0f, 2.0f, 3.0f, 4.0f}), ((__m128)(__v4sf){10.0f, 20.0f, 30.0f, 40.0f}), 0x30), 1.0f, 2.0f, 3.0f, 10.0f))); // Insert Y[0] into X[3]314TEST_CONSTEXPR((match_m128(_mm_insert_ps(((__m128)(__v4sf){1.0f, 2.0f, 3.0f, 4.0f}), ((__m128)(__v4sf){10.0f, 20.0f, 30.0f, 40.0f}), 0x80), 30.0f, 2.0f, 3.0f, 4.0f))); // Insert Y[2] into X[0]315TEST_CONSTEXPR((match_m128(_mm_insert_ps(((__m128)(__v4sf){1.0f, 2.0f, 3.0f, 4.0f}), ((__m128)(__v4sf){10.0f, 20.0f, 30.0f, 40.0f}), 0x01), 0.0f, 2.0f, 3.0f, 4.0f))); // Insert Y[0] into X[0], zero X[0]316TEST_CONSTEXPR((match_m128(_mm_insert_ps(((__m128)(__v4sf){1.0f, 2.0f, 3.0f, 4.0f}), ((__m128)(__v4sf){10.0f, 20.0f, 30.0f, 40.0f}), 0x0A), 10.0f, 0.0f, 3.0f, 0.0f))); // Insert Y[0] into X[0], zero X[1] and X[3]317TEST_CONSTEXPR((match_m128(_mm_insert_ps(((__m128)(__v4sf){1.0f, 2.0f, 3.0f, 4.0f}), ((__m128)(__v4sf){10.0f, 20.0f, 30.0f, 40.0f}), 0x0F), 0.0f, 0.0f, 0.0f, 0.0f))); // Insert Y[0] into X[0], zero all318TEST_CONSTEXPR((match_m128(_mm_insert_ps(((__m128)(__v4sf){1.0f, 2.0f, 3.0f, 4.0f}), ((__m128)(__v4sf){10.0f, 20.0f, 30.0f, 40.0f}), 0xCF), 0.0f, 0.0f, 0.0f, 0.0f))); // Insert Y[3] into X[0], zero all319 320__m128i test_mm_max_epi8(__m128i x, __m128i y) {321 // CHECK-LABEL: test_mm_max_epi8322 // CHECK: call <16 x i8> @llvm.smax.v16i8(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})323 return _mm_max_epi8(x, y);324}325 326TEST_CONSTEXPR(match_v16qi(_mm_max_epi8((__m128i)(__v16qs){-1, +2, -3, +4, -5, +6, -7, +8, -9, +10, -11, +12, -13, +14, -15, +16}, (__m128i)(__v16qs){+1, -2, +3, -4, +5, -6, +7, -8, +9, -10, +11, -12, +13, -14, +15, -16}), +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16));327 328__m128i test_mm_max_epi32(__m128i x, __m128i y) {329 // CHECK-LABEL: test_mm_max_epi32330 // CHECK: call <4 x i32> @llvm.smax.v4i32(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})331 return _mm_max_epi32(x, y);332}333 334TEST_CONSTEXPR(match_v4si(_mm_max_epi32((__m128i)(__v4si){-1, +2, -3, +4}, (__m128i)(__v4si){+1, -2, +3, -4}), +1, +2, +3, +4 ));335 336__m128i test_mm_max_epu16(__m128i x, __m128i y) {337 // CHECK-LABEL: test_mm_max_epu16338 // CHECK: call <8 x i16> @llvm.umax.v8i16(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})339 return _mm_max_epu16(x, y);340}341 342TEST_CONSTEXPR(match_v8hu(_mm_max_epu16((__m128i)(__v8hu){1, 3, 5, 7, 9, 11, 13, 15}, (__m128i)(__v8hu){3, 4, 5, 6, 7, 8, 9, 10}), 3, 4, 5, 7, 9, 11, 13, 15));343 344__m128i test_mm_max_epu32(__m128i x, __m128i y) {345 // CHECK-LABEL: test_mm_max_epu32346 // CHECK: call <4 x i32> @llvm.umax.v4i32(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})347 return _mm_max_epu32(x, y);348}349 350TEST_CONSTEXPR(match_v4su(_mm_max_epu32((__m128i)(__v4su){1, 3, 5, 7}, (__m128i)(__v4su){3, 4, 5, 6}), 3, 4, 5, 7));351 352__m128i test_mm_min_epi8(__m128i x, __m128i y) {353 // CHECK-LABEL: test_mm_min_epi8354 // CHECK: call <16 x i8> @llvm.smin.v16i8(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})355 return _mm_min_epi8(x, y);356}357 358TEST_CONSTEXPR(match_v16qi(_mm_min_epi8((__m128i)(__v16qs){-1, +2, -3, +4, -5, +6, -7, +8, -9, +10, -11, +12, -13, +14, -15, +16}, (__m128i)(__v16qs){+1, -2, +3, -4, +5, -6, +7, -8, +9, -10, +11, -12, +13, -14, +15, -16}), -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16));359 360__m128i test_mm_min_epi32(__m128i x, __m128i y) {361 // CHECK-LABEL: test_mm_min_epi32362 // CHECK: call <4 x i32> @llvm.smin.v4i32(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})363 return _mm_min_epi32(x, y);364}365 366TEST_CONSTEXPR(match_v4si(_mm_min_epi32((__m128i)(__v4si){-1, +2, -3, +4}, (__m128i)(__v4si){+1, -2, +3, -4}), -1, -2, -3, -4 ));367 368__m128i test_mm_min_epu16(__m128i x, __m128i y) {369 // CHECK-LABEL: test_mm_min_epu16370 // CHECK: call <8 x i16> @llvm.umin.v8i16(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})371 return _mm_min_epu16(x, y);372}373 374TEST_CONSTEXPR(match_v8hu(_mm_min_epu16((__m128i)(__v8hu){1, 3, 5, 7, 9, 11, 13, 15}, (__m128i)(__v8hu){3, 4, 5, 6, 7, 8, 9, 10}), 1, 3, 5, 6, 7, 8, 9, 10));375 376__m128i test_mm_min_epu32(__m128i x, __m128i y) {377 // CHECK-LABEL: test_mm_min_epu32378 // CHECK: call <4 x i32> @llvm.umin.v4i32(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})379 return _mm_min_epu32(x, y);380}381 382TEST_CONSTEXPR(match_v4su(_mm_min_epu32((__m128i)(__v4su){1, 3, 5, 7}, (__m128i)(__v4su){3, 4, 5, 6}), 1, 3, 5, 6));383 384__m128i test_mm_minpos_epu16(__m128i x) {385 // CHECK-LABEL: test_mm_minpos_epu16386 // CHECK: call <8 x i16> @llvm.x86.sse41.phminposuw(<8 x i16> %{{.*}})387 return _mm_minpos_epu16(x);388}389TEST_CONSTEXPR(match_v8hu(_mm_minpos_epu16((__m128i)(__v8hu){0,0,0,0, 0,0,0,0}), 0,0,0,0, 0,0,0,0));390TEST_CONSTEXPR(match_v8hu(_mm_minpos_epu16((__m128i)(__v8hu){1,0,0,0, 0,0,0,0}), 0,1,0,0, 0,0,0,0));391TEST_CONSTEXPR(match_v8hu(_mm_minpos_epu16((__m128i)(__v8hu){65535,65535,65535,65535,65535,65535,65535,65535}), 65535,0,0,0, 0,0,0,0));392TEST_CONSTEXPR(match_v8hu(_mm_minpos_epu16((__m128i)(__v8hu){9,8,7,6,5,4,3,2}), 2,7,0,0, 0,0,0,0));393TEST_CONSTEXPR(match_v8hu(_mm_minpos_epu16((__m128i)(__v8hu){5,5,5,5,5,5,5,5}), 5,0,0,0, 0,0,0,0));394TEST_CONSTEXPR(match_v8hu(_mm_minpos_epu16((__m128i)(__v8hu){5,7,9,4,10,4,11,12}), 4,3,0,0, 0,0,0,0));395TEST_CONSTEXPR(match_v8hu(_mm_minpos_epu16((__m128i)(__v8hu){6,0,0,0,0,0,0,0}), 0,1,0,0, 0,0,0,0));396TEST_CONSTEXPR(match_v8hu(_mm_minpos_epu16((__m128i)(__v8hu){1000,2000,3000,4000,5000,6000,7000,1}), 1,7,0,0, 0,0,0,0));397TEST_CONSTEXPR(match_v8hu(_mm_minpos_epu16((__m128i)(__v8hu){1234,5678,42,9999,65535,0,4242,42}), 0,5,0,0, 0,0,0,0));398TEST_CONSTEXPR(match_v8hu(_mm_minpos_epu16((__m128i)(__v8hu){400,500,12,600,12,700,800,900}), 12,2,0,0, 0,0,0,0));399 400__m128i test_mm_mpsadbw_epu8(__m128i x, __m128i y) {401 // CHECK-LABEL: test_mm_mpsadbw_epu8402 // CHECK: call <8 x i16> @llvm.x86.sse41.mpsadbw(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}, i8 1)403 return _mm_mpsadbw_epu8(x, y, 1);404}405 406__m128i test_mm_mul_epi32(__m128i x, __m128i y) {407 // CHECK-LABEL: test_mm_mul_epi32408 // CHECK: shl <2 x i64> %{{.*}}, splat (i64 32)409 // CHECK: ashr <2 x i64> %{{.*}}, splat (i64 32)410 // CHECK: shl <2 x i64> %{{.*}}, splat (i64 32)411 // CHECK: ashr <2 x i64> %{{.*}}, splat (i64 32)412 // CHECK: mul <2 x i64> %{{.*}}, %{{.*}}413 return _mm_mul_epi32(x, y);414}415TEST_CONSTEXPR(match_m128i(_mm_mul_epi32((__m128i)(__v4si){+1, -2, +3, -4}, (__m128i)(__v4si){-16, -14, +12, +10}), -16, 36));416 417__m128i test_mm_mullo_epi32(__m128i x, __m128i y) {418 // CHECK-LABEL: test_mm_mullo_epi32419 // CHECK: mul <4 x i32>420 return _mm_mullo_epi32(x, y);421}422TEST_CONSTEXPR(match_v4si(_mm_mullo_epi32((__m128i)(__v4si){+1, -2, +3, -4}, (__m128i)(__v4si){-16, +14, +12, -10}), -16, -28, +36, +40));423 424__m128i test_mm_packus_epi32(__m128i x, __m128i y) {425 // CHECK-LABEL: test_mm_packus_epi32426 // CHECK: call <8 x i16> @llvm.x86.sse41.packusdw(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})427 return _mm_packus_epi32(x, y);428}429TEST_CONSTEXPR(match_v8hi(_mm_packus_epi32((__m128i)(__v4si){40000, -50000, 32767, -32768}, (__m128i)(__v4si){0, 1, -1, 70000}), -25536, 0, 32767, 0, 0, 1, 0, -1));430 431__m128d test_mm_round_pd(__m128d x) {432 // CHECK-LABEL: test_mm_round_pd433 // CHECK: call {{.*}}<2 x double> @llvm.x86.sse41.round.pd(<2 x double> %{{.*}}, i32 4)434 return _mm_round_pd(x, 4);435}436 437__m128 test_mm_round_ps(__m128 x) {438 // CHECK-LABEL: test_mm_round_ps439 // CHECK: call {{.*}}<4 x float> @llvm.x86.sse41.round.ps(<4 x float> %{{.*}}, i32 4)440 return _mm_round_ps(x, 4);441}442 443__m128d test_mm_round_sd(__m128d x, __m128d y) {444 // CHECK-LABEL: test_mm_round_sd445 // CHECK: call {{.*}}<2 x double> @llvm.x86.sse41.round.sd(<2 x double> %{{.*}}, <2 x double> %{{.*}}, i32 4)446 return _mm_round_sd(x, y, 4);447}448 449__m128 test_mm_round_ss(__m128 x, __m128 y) {450 // CHECK-LABEL: test_mm_round_ss451 // CHECK: call {{.*}}<4 x float> @llvm.x86.sse41.round.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i32 4)452 return _mm_round_ss(x, y, 4);453}454 455__m128i test_mm_stream_load_si128(__m128i const *a) {456 // CHECK-LABEL: test_mm_stream_load_si128457 // CHECK: load <2 x i64>, ptr %{{.*}}, align 16, !nontemporal458 return _mm_stream_load_si128(a);459}460 461__m128i test_mm_stream_load_si128_void(const void *a) {462 // CHECK-LABEL: test_mm_stream_load_si128_void463 // CHECK: load <2 x i64>, ptr %{{.*}}, align 16, !nontemporal464 return _mm_stream_load_si128(a);465}466 467int test_mm_test_all_ones(__m128i x) {468 // CHECK-LABEL: test_mm_test_all_ones469 // CHECK: call {{.*}}i32 @llvm.x86.sse41.ptestc(<2 x i64> %{{.*}}, <2 x i64> %{{.*}})470 return _mm_test_all_ones(x);471}472TEST_CONSTEXPR(_mm_test_all_ones(((__m128i)(__v2di){-1, -1})) == 1);473TEST_CONSTEXPR(_mm_test_all_ones(((__m128i)(__v2di){-1, 0})) == 0);474TEST_CONSTEXPR(_mm_test_all_ones(((__m128i)(__v4si){-1, -1, -1, 0x7FFFFFFF})) == 0);475 476int test_mm_test_all_zeros(__m128i x, __m128i y) {477 // CHECK-LABEL: test_mm_test_all_zeros478 // CHECK: call {{.*}}i32 @llvm.x86.sse41.ptestz(<2 x i64> %{{.*}}, <2 x i64> %{{.*}})479 return _mm_test_all_zeros(x, y);480}481TEST_CONSTEXPR(_mm_test_all_zeros(((__m128i)(__v2di){0,0}), ((__m128i)(__v2di){0,0})) == 1);482TEST_CONSTEXPR(_mm_test_all_zeros(((__m128i)(__v2di){0xFF00,0}), ((__m128i)(__v2di){0x00FF,0})) == 1);483TEST_CONSTEXPR(_mm_test_all_zeros(((__m128i)(__v2di){1,0}), ((__m128i)(__v2di){-1,0})) == 0);484TEST_CONSTEXPR(_mm_test_all_zeros(((__m128i)(__v2di){0,1}), ((__m128i)(__v2di){0,-1})) == 0);485 486int test_mm_test_mix_ones_zeros(__m128i x, __m128i y) {487 // CHECK-LABEL: test_mm_test_mix_ones_zeros488 // CHECK: call {{.*}}i32 @llvm.x86.sse41.ptestnzc(<2 x i64> %{{.*}}, <2 x i64> %{{.*}})489 return _mm_test_mix_ones_zeros(x, y);490}491TEST_CONSTEXPR(_mm_test_mix_ones_zeros(((__m128i)(__v2di){0xFF, 0}), ((__m128i)(__v2di){0xF0, 1})) == 1);492TEST_CONSTEXPR(_mm_test_mix_ones_zeros(((__m128i)(__v2di){0xF0, 0}), ((__m128i)(__v2di){0x0F, 0})) == 0);493TEST_CONSTEXPR(_mm_test_mix_ones_zeros(((__m128i)(__v2di){-1, -1}), ((__m128i)(__v2di){1, 0})) == 0);494TEST_CONSTEXPR(_mm_test_mix_ones_zeros(((__m128i)(__v2di){0, 0}), ((__m128i)(__v2di){0, 0})) == 0);495 496int test_mm_testc_si128(__m128i x, __m128i y) {497 // CHECK-LABEL: test_mm_testc_si128498 // CHECK: call {{.*}}i32 @llvm.x86.sse41.ptestc(<2 x i64> %{{.*}}, <2 x i64> %{{.*}})499 return _mm_testc_si128(x, y);500}501TEST_CONSTEXPR(_mm_testc_si128((__m128i)(__v2di){0,0}, (__m128i)(__v2di){0,0}) == 1);502TEST_CONSTEXPR(_mm_testc_si128((__m128i)(__v2di){1,0}, (__m128i)(__v2di){-1,0}) == 0);503TEST_CONSTEXPR(_mm_testc_si128((__m128i)(__v2di){0,-1}, (__m128i)(__v2di){0,1}) == 1);504 505int test_mm_testnzc_si128(__m128i x, __m128i y) {506 // CHECK-LABEL: test_mm_testnzc_si128507 // CHECK: call {{.*}}i32 @llvm.x86.sse41.ptestnzc(<2 x i64> %{{.*}}, <2 x i64> %{{.*}})508 return _mm_testnzc_si128(x, y);509}510TEST_CONSTEXPR(_mm_testnzc_si128((__m128i)(__v2di){3,0}, (__m128i)(__v2di){1,1}) == 1);511TEST_CONSTEXPR(_mm_testnzc_si128((__m128i)(__v2di){32,-1}, (__m128i)(__v2di){15,0}) == 0);512TEST_CONSTEXPR(_mm_testnzc_si128((__m128i)(__v2di){0,999}, (__m128i)(__v2di){0,999}) == 0);513 514int test_mm_testz_si128(__m128i x, __m128i y) {515 // CHECK-LABEL: test_mm_testz_si128516 // CHECK: call {{.*}}i32 @llvm.x86.sse41.ptestz(<2 x i64> %{{.*}}, <2 x i64> %{{.*}})517 return _mm_testz_si128(x, y);518}519TEST_CONSTEXPR(_mm_testz_si128((__m128i)(__v2di){0,0}, (__m128i)(__v2di){0,0}) == 1);520TEST_CONSTEXPR(_mm_testz_si128((__m128i)(__v2di){1,0}, (__m128i)(__v2di){-1,0}) == 0);521TEST_CONSTEXPR(_mm_testz_si128((__m128i)(__v2di){1,0}, (__m128i)(__v2di){0,1}) == 1);522