1 // RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -target-feature +relaxed-simd -target-feature +nontrapping-fptoint -target-feature +exception-handling -target-feature +bulk-memory -target-feature +atomics -flax-vector-conversions=none -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32 2 // RUN: %clang_cc1 -triple wasm64-unknown-unknown -target-feature +simd128 -target-feature +relaxed-simd -target-feature +nontrapping-fptoint -target-feature +exception-handling -target-feature +bulk-memory -target-feature +atomics -flax-vector-conversions=none -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64 3 // RUN: not %clang_cc1 -triple wasm64-unknown-unknown -target-feature +nontrapping-fptoint -target-feature +exception-handling -target-feature +bulk-memory -target-feature +atomics -flax-vector-conversions=none -O3 -emit-llvm -o - %s 2>&1 | FileCheck %s -check-prefixes MISSING-SIMD 4 5 // SIMD convenience types 6 typedef signed char i8x16 __attribute((vector_size(16))); 7 typedef short i16x8 __attribute((vector_size(16))); 8 typedef int i32x4 __attribute((vector_size(16))); 9 typedef long long i64x2 __attribute((vector_size(16))); 10 typedef unsigned char u8x16 __attribute((vector_size(16))); 11 typedef unsigned short u16x8 __attribute((vector_size(16))); 12 typedef unsigned int u32x4 __attribute((vector_size(16))); 13 typedef unsigned long long u64x2 __attribute((vector_size(16))); 14 typedef float f32x4 __attribute((vector_size(16))); 15 typedef double f64x2 __attribute((vector_size(16))); 16 17 __SIZE_TYPE__ memory_size(void) { 18 return __builtin_wasm_memory_size(0); 19 // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.memory.size.i32(i32 0) 20 // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.memory.size.i64(i32 0) 21 } 22 23 __SIZE_TYPE__ memory_grow(__SIZE_TYPE__ delta) { 24 return __builtin_wasm_memory_grow(0, delta); 25 // WEBASSEMBLY32: call i32 @llvm.wasm.memory.grow.i32(i32 0, i32 %{{.*}}) 26 // WEBASSEMBLY64: call i64 @llvm.wasm.memory.grow.i64(i32 0, i64 %{{.*}}) 27 } 28 29 __SIZE_TYPE__ tls_size(void) { 30 return __builtin_wasm_tls_size(); 31 // WEBASSEMBLY32: call i32 @llvm.wasm.tls.size.i32() 32 // WEBASSEMBLY64: call i64 @llvm.wasm.tls.size.i64() 33 } 34 35 __SIZE_TYPE__ tls_align(void) { 36 return __builtin_wasm_tls_align(); 37 // WEBASSEMBLY32: call i32 @llvm.wasm.tls.align.i32() 38 // WEBASSEMBLY64: call i64 @llvm.wasm.tls.align.i64() 39 } 40 41 void *tls_base(void) { 42 return __builtin_wasm_tls_base(); 43 // WEBASSEMBLY: call ptr @llvm.wasm.tls.base() 44 } 45 46 void throw(void *obj) { 47 return __builtin_wasm_throw(0, obj); 48 // WEBASSEMBLY: call void @llvm.wasm.throw(i32 0, ptr %{{.*}}) 49 } 50 51 void rethrow(void) { 52 return __builtin_wasm_rethrow(); 53 // WEBASSEMBLY32: call void @llvm.wasm.rethrow() 54 // WEBASSEMBLY64: call void @llvm.wasm.rethrow() 55 } 56 57 int memory_atomic_wait32(int *addr, int expected, long long timeout) { 58 return __builtin_wasm_memory_atomic_wait32(addr, expected, timeout); 59 // WEBASSEMBLY: call i32 @llvm.wasm.memory.atomic.wait32(ptr %{{.*}}, i32 %{{.*}}, i64 %{{.*}}) 60 } 61 62 int memory_atomic_wait64(long long *addr, long long expected, long long timeout) { 63 return __builtin_wasm_memory_atomic_wait64(addr, expected, timeout); 64 // WEBASSEMBLY: call i32 @llvm.wasm.memory.atomic.wait64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}) 65 } 66 67 unsigned int memory_atomic_notify(int *addr, unsigned int count) { 68 return __builtin_wasm_memory_atomic_notify(addr, count); 69 // WEBASSEMBLY: call i32 @llvm.wasm.memory.atomic.notify(ptr %{{.*}}, i32 %{{.*}}) 70 } 71 72 int trunc_s_i32_f32(float f) { 73 return __builtin_wasm_trunc_s_i32_f32(f); 74 // WEBASSEMBLY: call i32 @llvm.wasm.trunc.signed.i32.f32(float %f) 75 // WEBASSEMBLY-NEXT: ret 76 } 77 78 int trunc_u_i32_f32(float f) { 79 return __builtin_wasm_trunc_u_i32_f32(f); 80 // WEBASSEMBLY: call i32 @llvm.wasm.trunc.unsigned.i32.f32(float %f) 81 // WEBASSEMBLY-NEXT: ret 82 } 83 84 int trunc_s_i32_f64(double f) { 85 return __builtin_wasm_trunc_s_i32_f64(f); 86 // WEBASSEMBLY: call i32 @llvm.wasm.trunc.signed.i32.f64(double %f) 87 // WEBASSEMBLY-NEXT: ret 88 } 89 90 int trunc_u_i32_f64(double f) { 91 return __builtin_wasm_trunc_u_i32_f64(f); 92 // WEBASSEMBLY: call i32 @llvm.wasm.trunc.unsigned.i32.f64(double %f) 93 // WEBASSEMBLY-NEXT: ret 94 } 95 96 long long trunc_s_i64_f32(float f) { 97 return __builtin_wasm_trunc_s_i64_f32(f); 98 // WEBASSEMBLY: call i64 @llvm.wasm.trunc.signed.i64.f32(float %f) 99 // WEBASSEMBLY-NEXT: ret 100 } 101 102 long long trunc_u_i64_f32(float f) { 103 return __builtin_wasm_trunc_u_i64_f32(f); 104 // WEBASSEMBLY: call i64 @llvm.wasm.trunc.unsigned.i64.f32(float %f) 105 // WEBASSEMBLY-NEXT: ret 106 } 107 108 long long trunc_s_i64_f64(double f) { 109 return __builtin_wasm_trunc_s_i64_f64(f); 110 // WEBASSEMBLY: call i64 @llvm.wasm.trunc.signed.i64.f64(double %f) 111 // WEBASSEMBLY-NEXT: ret 112 } 113 114 long long trunc_u_i64_f64(double f) { 115 return __builtin_wasm_trunc_u_i64_f64(f); 116 // WEBASSEMBLY: call i64 @llvm.wasm.trunc.unsigned.i64.f64(double %f) 117 // WEBASSEMBLY-NEXT: ret 118 } 119 120 int trunc_saturate_s_i32_f32(float f) { 121 return __builtin_wasm_trunc_saturate_s_i32_f32(f); 122 // WEBASSEMBLY: call i32 @llvm.fptosi.sat.i32.f32(float %f) 123 // WEBASSEMBLY-NEXT: ret 124 } 125 126 int trunc_saturate_u_i32_f32(float f) { 127 return __builtin_wasm_trunc_saturate_u_i32_f32(f); 128 // WEBASSEMBLY: call i32 @llvm.fptoui.sat.i32.f32(float %f) 129 // WEBASSEMBLY-NEXT: ret 130 } 131 132 int trunc_saturate_s_i32_f64(double f) { 133 return __builtin_wasm_trunc_saturate_s_i32_f64(f); 134 // WEBASSEMBLY: call i32 @llvm.fptosi.sat.i32.f64(double %f) 135 // WEBASSEMBLY-NEXT: ret 136 } 137 138 int trunc_saturate_u_i32_f64(double f) { 139 return __builtin_wasm_trunc_saturate_u_i32_f64(f); 140 // WEBASSEMBLY: call i32 @llvm.fptoui.sat.i32.f64(double %f) 141 // WEBASSEMBLY-NEXT: ret 142 } 143 144 long long trunc_saturate_s_i64_f32(float f) { 145 return __builtin_wasm_trunc_saturate_s_i64_f32(f); 146 // WEBASSEMBLY: call i64 @llvm.fptosi.sat.i64.f32(float %f) 147 // WEBASSEMBLY-NEXT: ret 148 } 149 150 long long trunc_saturate_u_i64_f32(float f) { 151 return __builtin_wasm_trunc_saturate_u_i64_f32(f); 152 // WEBASSEMBLY: call i64 @llvm.fptoui.sat.i64.f32(float %f) 153 // WEBASSEMBLY-NEXT: ret 154 } 155 156 long long trunc_saturate_s_i64_f64(double f) { 157 return __builtin_wasm_trunc_saturate_s_i64_f64(f); 158 // WEBASSEMBLY: call i64 @llvm.fptosi.sat.i64.f64(double %f) 159 // WEBASSEMBLY-NEXT: ret 160 } 161 162 long long trunc_saturate_u_i64_f64(double f) { 163 return __builtin_wasm_trunc_saturate_u_i64_f64(f); 164 // WEBASSEMBLY: call i64 @llvm.fptoui.sat.i64.f64(double %f) 165 // WEBASSEMBLY-NEXT: ret 166 } 167 168 float min_f32(float x, float y) { 169 return __builtin_wasm_min_f32(x, y); 170 // WEBASSEMBLY: call float @llvm.minimum.f32(float %x, float %y) 171 // WEBASSEMBLY-NEXT: ret 172 } 173 174 float max_f32(float x, float y) { 175 return __builtin_wasm_max_f32(x, y); 176 // WEBASSEMBLY: call float @llvm.maximum.f32(float %x, float %y) 177 // WEBASSEMBLY-NEXT: ret 178 } 179 180 double min_f64(double x, double y) { 181 return __builtin_wasm_min_f64(x, y); 182 // WEBASSEMBLY: call double @llvm.minimum.f64(double %x, double %y) 183 // WEBASSEMBLY-NEXT: ret 184 } 185 186 double max_f64(double x, double y) { 187 return __builtin_wasm_max_f64(x, y); 188 // WEBASSEMBLY: call double @llvm.maximum.f64(double %x, double %y) 189 // WEBASSEMBLY-NEXT: ret 190 } 191 192 i8x16 add_sat_s_i8x16(i8x16 x, i8x16 y) { 193 return __builtin_wasm_add_sat_s_i8x16(x, y); 194 // MISSING-SIMD: error: '__builtin_wasm_add_sat_s_i8x16' needs target feature simd128 195 // WEBASSEMBLY: call <16 x i8> @llvm.sadd.sat.v16i8( 196 // WEBASSEMBLY-SAME: <16 x i8> %x, <16 x i8> %y) 197 // WEBASSEMBLY-NEXT: ret 198 } 199 200 u8x16 add_sat_u_i8x16(u8x16 x, u8x16 y) { 201 return __builtin_wasm_add_sat_u_i8x16(x, y); 202 // WEBASSEMBLY: call <16 x i8> @llvm.uadd.sat.v16i8( 203 // WEBASSEMBLY-SAME: <16 x i8> %x, <16 x i8> %y) 204 // WEBASSEMBLY-NEXT: ret 205 } 206 207 i16x8 add_sat_s_i16x8(i16x8 x, i16x8 y) { 208 return __builtin_wasm_add_sat_s_i16x8(x, y); 209 // WEBASSEMBLY: call <8 x i16> @llvm.sadd.sat.v8i16( 210 // WEBASSEMBLY-SAME: <8 x i16> %x, <8 x i16> %y) 211 // WEBASSEMBLY-NEXT: ret 212 } 213 214 u16x8 add_sat_u_i16x8(u16x8 x, u16x8 y) { 215 return __builtin_wasm_add_sat_u_i16x8(x, y); 216 // WEBASSEMBLY: call <8 x i16> @llvm.uadd.sat.v8i16( 217 // WEBASSEMBLY-SAME: <8 x i16> %x, <8 x i16> %y) 218 // WEBASSEMBLY-NEXT: ret 219 } 220 221 i8x16 sub_sat_s_i8x16(i8x16 x, i8x16 y) { 222 return __builtin_wasm_sub_sat_s_i8x16(x, y); 223 // WEBASSEMBLY: call <16 x i8> @llvm.wasm.sub.sat.signed.v16i8( 224 // WEBASSEMBLY-SAME: <16 x i8> %x, <16 x i8> %y) 225 // WEBASSEMBLY-NEXT: ret 226 } 227 228 u8x16 sub_sat_u_i8x16(u8x16 x, u8x16 y) { 229 return __builtin_wasm_sub_sat_u_i8x16(x, y); 230 // WEBASSEMBLY: call <16 x i8> @llvm.wasm.sub.sat.unsigned.v16i8( 231 // WEBASSEMBLY-SAME: <16 x i8> %x, <16 x i8> %y) 232 // WEBASSEMBLY-NEXT: ret 233 } 234 235 i8x16 abs_i8x16(i8x16 v) { 236 return __builtin_wasm_abs_i8x16(v); 237 // WEBASSEMBLY: call <16 x i8> @llvm.abs.v16i8(<16 x i8> %v, i1 false) 238 // WEBASSEMBLY-NEXT: ret 239 } 240 241 i16x8 abs_i16x8(i16x8 v) { 242 return __builtin_wasm_abs_i16x8(v); 243 // WEBASSEMBLY: call <8 x i16> @llvm.abs.v8i16(<8 x i16> %v, i1 false) 244 // WEBASSEMBLY-NEXT: ret 245 } 246 247 i32x4 abs_i32x4(i32x4 v) { 248 return __builtin_wasm_abs_i32x4(v); 249 // WEBASSEMBLY: call <4 x i32> @llvm.abs.v4i32(<4 x i32> %v, i1 false) 250 // WEBASSEMBLY-NEXT: ret 251 } 252 253 i64x2 abs_i64x2(i64x2 v) { 254 return __builtin_wasm_abs_i64x2(v); 255 // WEBASSEMBLY: call <2 x i64> @llvm.abs.v2i64(<2 x i64> %v, i1 false) 256 // WEBASSEMBLY-NEXT: ret 257 } 258 259 i8x16 min_s_i8x16(i8x16 x, i8x16 y) { 260 return __builtin_wasm_min_s_i8x16(x, y); 261 // WEBASSEMBLY: call <16 x i8> @llvm.smin.v16i8(<16 x i8> %x, <16 x i8> %y) 262 // WEBASSEMBLY-NEXT: ret 263 } 264 265 u8x16 min_u_i8x16(u8x16 x, u8x16 y) { 266 return __builtin_wasm_min_u_i8x16(x, y); 267 // WEBASSEMBLY: call <16 x i8> @llvm.umin.v16i8(<16 x i8> %x, <16 x i8> %y) 268 // WEBASSEMBLY-NEXT: ret 269 } 270 271 i8x16 max_s_i8x16(i8x16 x, i8x16 y) { 272 return __builtin_wasm_max_s_i8x16(x, y); 273 // WEBASSEMBLY: call <16 x i8> @llvm.smax.v16i8(<16 x i8> %x, <16 x i8> %y) 274 // WEBASSEMBLY-NEXT: ret 275 } 276 277 u8x16 max_u_i8x16(u8x16 x, u8x16 y) { 278 return __builtin_wasm_max_u_i8x16(x, y); 279 // WEBASSEMBLY: call <16 x i8> @llvm.umax.v16i8(<16 x i8> %x, <16 x i8> %y) 280 // WEBASSEMBLY-NEXT: ret 281 } 282 283 i16x8 min_s_i16x8(i16x8 x, i16x8 y) { 284 return __builtin_wasm_min_s_i16x8(x, y); 285 // WEBASSEMBLY: call <8 x i16> @llvm.smin.v8i16(<8 x i16> %x, <8 x i16> %y) 286 // WEBASSEMBLY-NEXT: ret 287 } 288 289 u16x8 min_u_i16x8(u16x8 x, u16x8 y) { 290 return __builtin_wasm_min_u_i16x8(x, y); 291 // WEBASSEMBLY: call <8 x i16> @llvm.umin.v8i16(<8 x i16> %x, <8 x i16> %y) 292 // WEBASSEMBLY-NEXT: ret 293 } 294 295 i16x8 max_s_i16x8(i16x8 x, i16x8 y) { 296 return __builtin_wasm_max_s_i16x8(x, y); 297 // WEBASSEMBLY: call <8 x i16> @llvm.smax.v8i16(<8 x i16> %x, <8 x i16> %y) 298 // WEBASSEMBLY-NEXT: ret 299 } 300 301 u16x8 max_u_i16x8(u16x8 x, u16x8 y) { 302 return __builtin_wasm_max_u_i16x8(x, y); 303 // WEBASSEMBLY: call <8 x i16> @llvm.umax.v8i16(<8 x i16> %x, <8 x i16> %y) 304 // WEBASSEMBLY-NEXT: ret 305 } 306 307 i32x4 min_s_i32x4(i32x4 x, i32x4 y) { 308 return __builtin_wasm_min_s_i32x4(x, y); 309 // WEBASSEMBLY: call <4 x i32> @llvm.smin.v4i32(<4 x i32> %x, <4 x i32> %y) 310 // WEBASSEMBLY-NEXT: ret 311 } 312 313 u32x4 min_u_i32x4(u32x4 x, u32x4 y) { 314 return __builtin_wasm_min_u_i32x4(x, y); 315 // WEBASSEMBLY: call <4 x i32> @llvm.umin.v4i32(<4 x i32> %x, <4 x i32> %y) 316 // WEBASSEMBLY-NEXT: ret 317 } 318 319 i32x4 max_s_i32x4(i32x4 x, i32x4 y) { 320 return __builtin_wasm_max_s_i32x4(x, y); 321 // WEBASSEMBLY: call <4 x i32> @llvm.smax.v4i32(<4 x i32> %x, <4 x i32> %y) 322 // WEBASSEMBLY-NEXT: ret 323 } 324 325 u32x4 max_u_i32x4(u32x4 x, u32x4 y) { 326 return __builtin_wasm_max_u_i32x4(x, y); 327 // WEBASSEMBLY: call <4 x i32> @llvm.umax.v4i32(<4 x i32> %x, <4 x i32> %y) 328 // WEBASSEMBLY-NEXT: ret 329 } 330 331 i16x8 sub_sat_s_i16x8(i16x8 x, i16x8 y) { 332 return __builtin_wasm_sub_sat_s_i16x8(x, y); 333 // WEBASSEMBLY: call <8 x i16> @llvm.wasm.sub.sat.signed.v8i16( 334 // WEBASSEMBLY-SAME: <8 x i16> %x, <8 x i16> %y) 335 // WEBASSEMBLY-NEXT: ret 336 } 337 338 u16x8 sub_sat_u_i16x8(u16x8 x, u16x8 y) { 339 return __builtin_wasm_sub_sat_u_i16x8(x, y); 340 // WEBASSEMBLY: call <8 x i16> @llvm.wasm.sub.sat.unsigned.v8i16( 341 // WEBASSEMBLY-SAME: <8 x i16> %x, <8 x i16> %y) 342 // WEBASSEMBLY-NEXT: ret 343 } 344 345 u8x16 avgr_u_i8x16(u8x16 x, u8x16 y) { 346 return __builtin_wasm_avgr_u_i8x16(x, y); 347 // WEBASSEMBLY: call <16 x i8> @llvm.wasm.avgr.unsigned.v16i8( 348 // WEBASSEMBLY-SAME: <16 x i8> %x, <16 x i8> %y) 349 // WEBASSEMBLY-NEXT: ret 350 } 351 352 u16x8 avgr_u_i16x8(u16x8 x, u16x8 y) { 353 return __builtin_wasm_avgr_u_i16x8(x, y); 354 // WEBASSEMBLY: call <8 x i16> @llvm.wasm.avgr.unsigned.v8i16( 355 // WEBASSEMBLY-SAME: <8 x i16> %x, <8 x i16> %y) 356 // WEBASSEMBLY-NEXT: ret 357 } 358 359 i16x8 q15mulr_sat_s_i16x8(i16x8 x, i16x8 y) { 360 return __builtin_wasm_q15mulr_sat_s_i16x8(x, y); 361 // WEBASSEMBLY: call <8 x i16> @llvm.wasm.q15mulr.sat.signed( 362 // WEBASSEMBLY-SAME: <8 x i16> %x, <8 x i16> %y) 363 // WEBASSEMBLY-NEXT: ret 364 } 365 366 i16x8 extadd_pairwise_i8x16_s_i16x8(i8x16 v) { 367 return __builtin_wasm_extadd_pairwise_i8x16_s_i16x8(v); 368 // WEBASSEMBLY: call <8 x i16> @llvm.wasm.extadd.pairwise.signed.v8i16( 369 // WEBASSEMBLY-SAME: <16 x i8> %v) 370 // WEBASSEMBLY-NEXT: ret 371 } 372 373 u16x8 extadd_pairwise_i8x16_u_i16x8(u8x16 v) { 374 return __builtin_wasm_extadd_pairwise_i8x16_u_i16x8(v); 375 // WEBASSEMBLY: call <8 x i16> @llvm.wasm.extadd.pairwise.unsigned.v8i16( 376 // WEBASSEMBLY-SAME: <16 x i8> %v) 377 // WEBASSEMBLY-NEXT: ret 378 } 379 380 i32x4 extadd_pairwise_i16x8_s_i32x4(i16x8 v) { 381 return __builtin_wasm_extadd_pairwise_i16x8_s_i32x4(v); 382 // WEBASSEMBLY: call <4 x i32> @llvm.wasm.extadd.pairwise.signed.v4i32( 383 // WEBASSEMBLY-SAME: <8 x i16> %v) 384 // WEBASSEMBLY-NEXT: ret 385 } 386 387 u32x4 extadd_pairwise_i16x8_u_i32x4(u16x8 v) { 388 return __builtin_wasm_extadd_pairwise_i16x8_u_i32x4(v); 389 // WEBASSEMBLY: call <4 x i32> @llvm.wasm.extadd.pairwise.unsigned.v4i32( 390 // WEBASSEMBLY-SAME: <8 x i16> %v) 391 // WEBASSEMBLY-NEXT: ret 392 } 393 394 i32x4 dot_i16x8_s(i16x8 x, i16x8 y) { 395 return __builtin_wasm_dot_s_i32x4_i16x8(x, y); 396 // WEBASSEMBLY: call <4 x i32> @llvm.wasm.dot(<8 x i16> %x, <8 x i16> %y) 397 // WEBASSEMBLY-NEXT: ret 398 } 399 400 i32x4 bitselect(i32x4 x, i32x4 y, i32x4 c) { 401 return __builtin_wasm_bitselect(x, y, c); 402 // WEBASSEMBLY: call <4 x i32> @llvm.wasm.bitselect.v4i32( 403 // WEBASSEMBLY-SAME: <4 x i32> %x, <4 x i32> %y, <4 x i32> %c) 404 // WEBASSEMBLY-NEXT: ret 405 } 406 407 i8x16 popcnt(i8x16 x) { 408 return __builtin_wasm_popcnt_i8x16(x); 409 // WEBASSEMBLY: call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %x) 410 // WEBASSEMBLY-NEXT: ret 411 } 412 413 int any_true_v128(i8x16 x) { 414 return __builtin_wasm_any_true_v128(x); 415 // WEBASSEMBLY: call i32 @llvm.wasm.anytrue.v16i8(<16 x i8> %x) 416 // WEBASSEMBLY: ret 417 } 418 419 int all_true_i8x16(i8x16 x) { 420 return __builtin_wasm_all_true_i8x16(x); 421 // WEBASSEMBLY: call i32 @llvm.wasm.alltrue.v16i8(<16 x i8> %x) 422 // WEBASSEMBLY: ret 423 } 424 425 int all_true_i16x8(i16x8 x) { 426 return __builtin_wasm_all_true_i16x8(x); 427 // WEBASSEMBLY: call i32 @llvm.wasm.alltrue.v8i16(<8 x i16> %x) 428 // WEBASSEMBLY: ret 429 } 430 431 int all_true_i32x4(i32x4 x) { 432 return __builtin_wasm_all_true_i32x4(x); 433 // WEBASSEMBLY: call i32 @llvm.wasm.alltrue.v4i32(<4 x i32> %x) 434 // WEBASSEMBLY: ret 435 } 436 437 int all_true_i64x2(i64x2 x) { 438 return __builtin_wasm_all_true_i64x2(x); 439 // WEBASSEMBLY: call i32 @llvm.wasm.alltrue.v2i64(<2 x i64> %x) 440 // WEBASSEMBLY: ret 441 } 442 443 int bitmask_i8x16(i8x16 x) { 444 return __builtin_wasm_bitmask_i8x16(x); 445 // WEBASSEMBLY: call i32 @llvm.wasm.bitmask.v16i8(<16 x i8> %x) 446 // WEBASSEMBLY: ret 447 } 448 449 int bitmask_i16x8(i16x8 x) { 450 return __builtin_wasm_bitmask_i16x8(x); 451 // WEBASSEMBLY: call i32 @llvm.wasm.bitmask.v8i16(<8 x i16> %x) 452 // WEBASSEMBLY: ret 453 } 454 455 int bitmask_i32x4(i32x4 x) { 456 return __builtin_wasm_bitmask_i32x4(x); 457 // WEBASSEMBLY: call i32 @llvm.wasm.bitmask.v4i32(<4 x i32> %x) 458 // WEBASSEMBLY: ret 459 } 460 461 int bitmask_i64x2(i64x2 x) { 462 return __builtin_wasm_bitmask_i64x2(x); 463 // WEBASSEMBLY: call i32 @llvm.wasm.bitmask.v2i64(<2 x i64> %x) 464 // WEBASSEMBLY: ret 465 } 466 467 f32x4 abs_f32x4(f32x4 x) { 468 return __builtin_wasm_abs_f32x4(x); 469 // WEBASSEMBLY: call <4 x float> @llvm.fabs.v4f32(<4 x float> %x) 470 // WEBASSEMBLY: ret 471 } 472 473 f64x2 abs_f64x2(f64x2 x) { 474 return __builtin_wasm_abs_f64x2(x); 475 // WEBASSEMBLY: call <2 x double> @llvm.fabs.v2f64(<2 x double> %x) 476 // WEBASSEMBLY: ret 477 } 478 479 f32x4 min_f32x4(f32x4 x, f32x4 y) { 480 return __builtin_wasm_min_f32x4(x, y); 481 // WEBASSEMBLY: call <4 x float> @llvm.minimum.v4f32( 482 // WEBASSEMBLY-SAME: <4 x float> %x, <4 x float> %y) 483 // WEBASSEMBLY-NEXT: ret 484 } 485 486 f32x4 max_f32x4(f32x4 x, f32x4 y) { 487 return __builtin_wasm_max_f32x4(x, y); 488 // WEBASSEMBLY: call <4 x float> @llvm.maximum.v4f32( 489 // WEBASSEMBLY-SAME: <4 x float> %x, <4 x float> %y) 490 // WEBASSEMBLY-NEXT: ret 491 } 492 493 f32x4 pmin_f32x4(f32x4 x, f32x4 y) { 494 return __builtin_wasm_pmin_f32x4(x, y); 495 // WEBASSEMBLY: call <4 x float> @llvm.wasm.pmin.v4f32( 496 // WEBASSEMBLY-SAME: <4 x float> %x, <4 x float> %y) 497 // WEBASSEMBLY-NEXT: ret 498 } 499 500 f32x4 pmax_f32x4(f32x4 x, f32x4 y) { 501 return __builtin_wasm_pmax_f32x4(x, y); 502 // WEBASSEMBLY: call <4 x float> @llvm.wasm.pmax.v4f32( 503 // WEBASSEMBLY-SAME: <4 x float> %x, <4 x float> %y) 504 // WEBASSEMBLY-NEXT: ret 505 } 506 507 f64x2 min_f64x2(f64x2 x, f64x2 y) { 508 return __builtin_wasm_min_f64x2(x, y); 509 // WEBASSEMBLY: call <2 x double> @llvm.minimum.v2f64( 510 // WEBASSEMBLY-SAME: <2 x double> %x, <2 x double> %y) 511 // WEBASSEMBLY-NEXT: ret 512 } 513 514 f64x2 max_f64x2(f64x2 x, f64x2 y) { 515 return __builtin_wasm_max_f64x2(x, y); 516 // WEBASSEMBLY: call <2 x double> @llvm.maximum.v2f64( 517 // WEBASSEMBLY-SAME: <2 x double> %x, <2 x double> %y) 518 // WEBASSEMBLY-NEXT: ret 519 } 520 521 f64x2 pmin_f64x2(f64x2 x, f64x2 y) { 522 return __builtin_wasm_pmin_f64x2(x, y); 523 // WEBASSEMBLY: call <2 x double> @llvm.wasm.pmin.v2f64( 524 // WEBASSEMBLY-SAME: <2 x double> %x, <2 x double> %y) 525 // WEBASSEMBLY-NEXT: ret 526 } 527 528 f64x2 pmax_f64x2(f64x2 x, f64x2 y) { 529 return __builtin_wasm_pmax_f64x2(x, y); 530 // WEBASSEMBLY: call <2 x double> @llvm.wasm.pmax.v2f64( 531 // WEBASSEMBLY-SAME: <2 x double> %x, <2 x double> %y) 532 // WEBASSEMBLY-NEXT: ret 533 } 534 535 f32x4 ceil_f32x4(f32x4 x) { 536 return __builtin_wasm_ceil_f32x4(x); 537 // WEBASSEMBLY: call <4 x float> @llvm.ceil.v4f32(<4 x float> %x) 538 // WEBASSEMBLY: ret 539 } 540 541 f32x4 floor_f32x4(f32x4 x) { 542 return __builtin_wasm_floor_f32x4(x); 543 // WEBASSEMBLY: call <4 x float> @llvm.floor.v4f32(<4 x float> %x) 544 // WEBASSEMBLY: ret 545 } 546 547 f32x4 trunc_f32x4(f32x4 x) { 548 return __builtin_wasm_trunc_f32x4(x); 549 // WEBASSEMBLY: call <4 x float> @llvm.trunc.v4f32(<4 x float> %x) 550 // WEBASSEMBLY: ret 551 } 552 553 f32x4 nearest_f32x4(f32x4 x) { 554 return __builtin_wasm_nearest_f32x4(x); 555 // WEBASSEMBLY: call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %x) 556 // WEBASSEMBLY: ret 557 } 558 559 f64x2 ceil_f64x2(f64x2 x) { 560 return __builtin_wasm_ceil_f64x2(x); 561 // WEBASSEMBLY: call <2 x double> @llvm.ceil.v2f64(<2 x double> %x) 562 // WEBASSEMBLY: ret 563 } 564 565 f64x2 floor_f64x2(f64x2 x) { 566 return __builtin_wasm_floor_f64x2(x); 567 // WEBASSEMBLY: call <2 x double> @llvm.floor.v2f64(<2 x double> %x) 568 // WEBASSEMBLY: ret 569 } 570 571 f64x2 trunc_f64x2(f64x2 x) { 572 return __builtin_wasm_trunc_f64x2(x); 573 // WEBASSEMBLY: call <2 x double> @llvm.trunc.v2f64(<2 x double> %x) 574 // WEBASSEMBLY: ret 575 } 576 577 f64x2 nearest_f64x2(f64x2 x) { 578 return __builtin_wasm_nearest_f64x2(x); 579 // WEBASSEMBLY: call <2 x double> @llvm.nearbyint.v2f64(<2 x double> %x) 580 // WEBASSEMBLY: ret 581 } 582 583 f32x4 sqrt_f32x4(f32x4 x) { 584 return __builtin_wasm_sqrt_f32x4(x); 585 // WEBASSEMBLY: call <4 x float> @llvm.sqrt.v4f32(<4 x float> %x) 586 // WEBASSEMBLY: ret 587 } 588 589 f64x2 sqrt_f64x2(f64x2 x) { 590 return __builtin_wasm_sqrt_f64x2(x); 591 // WEBASSEMBLY: call <2 x double> @llvm.sqrt.v2f64(<2 x double> %x) 592 // WEBASSEMBLY: ret 593 } 594 595 i32x4 trunc_saturate_s_i32x4_f32x4(f32x4 f) { 596 return __builtin_wasm_trunc_saturate_s_i32x4_f32x4(f); 597 // WEBASSEMBLY: call <4 x i32> @llvm.fptosi.sat.v4i32.v4f32(<4 x float> %f) 598 // WEBASSEMBLY-NEXT: ret 599 } 600 601 i32x4 trunc_saturate_u_i32x4_f32x4(f32x4 f) { 602 return __builtin_wasm_trunc_saturate_u_i32x4_f32x4(f); 603 // WEBASSEMBLY: call <4 x i32> @llvm.fptoui.sat.v4i32.v4f32(<4 x float> %f) 604 // WEBASSEMBLY-NEXT: ret 605 } 606 607 i8x16 narrow_s_i8x16_i16x8(i16x8 low, i16x8 high) { 608 return __builtin_wasm_narrow_s_i8x16_i16x8(low, high); 609 // WEBASSEMBLY: call <16 x i8> @llvm.wasm.narrow.signed.v16i8.v8i16( 610 // WEBASSEMBLY-SAME: <8 x i16> %low, <8 x i16> %high) 611 // WEBASSEMBLY: ret 612 } 613 614 u8x16 narrow_u_i8x16_i16x8(i16x8 low, i16x8 high) { 615 return __builtin_wasm_narrow_u_i8x16_i16x8(low, high); 616 // WEBASSEMBLY: call <16 x i8> @llvm.wasm.narrow.unsigned.v16i8.v8i16( 617 // WEBASSEMBLY-SAME: <8 x i16> %low, <8 x i16> %high) 618 // WEBASSEMBLY: ret 619 } 620 621 i16x8 narrow_s_i16x8_i32x4(i32x4 low, i32x4 high) { 622 return __builtin_wasm_narrow_s_i16x8_i32x4(low, high); 623 // WEBASSEMBLY: call <8 x i16> @llvm.wasm.narrow.signed.v8i16.v4i32( 624 // WEBASSEMBLY-SAME: <4 x i32> %low, <4 x i32> %high) 625 // WEBASSEMBLY: ret 626 } 627 628 u16x8 narrow_u_i16x8_i32x4(i32x4 low, i32x4 high) { 629 return __builtin_wasm_narrow_u_i16x8_i32x4(low, high); 630 // WEBASSEMBLY: call <8 x i16> @llvm.wasm.narrow.unsigned.v8i16.v4i32( 631 // WEBASSEMBLY-SAME: <4 x i32> %low, <4 x i32> %high) 632 // WEBASSEMBLY: ret 633 } 634 635 i32x4 trunc_sat_s_zero_f64x2_i32x4(f64x2 x) { 636 return __builtin_wasm_trunc_sat_s_zero_f64x2_i32x4(x); 637 // WEBASSEMBLY: %0 = tail call <2 x i32> @llvm.fptosi.sat.v2i32.v2f64(<2 x double> %x) 638 // WEBASSEMBLY: %1 = shufflevector <2 x i32> %0, <2 x i32> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3> 639 // WEBASSEMBLY: ret <4 x i32> %1 640 } 641 642 u32x4 trunc_sat_u_zero_f64x2_i32x4(f64x2 x) { 643 return __builtin_wasm_trunc_sat_u_zero_f64x2_i32x4(x); 644 // WEBASSEMBLY: %0 = tail call <2 x i32> @llvm.fptoui.sat.v2i32.v2f64(<2 x double> %x) 645 // WEBASSEMBLY: %1 = shufflevector <2 x i32> %0, <2 x i32> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3> 646 // WEBASSEMBLY: ret <4 x i32> %1 647 } 648 649 i8x16 swizzle_i8x16(i8x16 x, i8x16 y) { 650 return __builtin_wasm_swizzle_i8x16(x, y); 651 // WEBASSEMBLY: call <16 x i8> @llvm.wasm.swizzle(<16 x i8> %x, <16 x i8> %y) 652 } 653 654 i8x16 shuffle(i8x16 x, i8x16 y) { 655 return __builtin_wasm_shuffle_i8x16(x, y, 0, 1, 2, 3, 4, 5, 6, 7, 656 8, 9, 10, 11, 12, 13, 14, 15); 657 // WEBASSEMBLY: call <16 x i8> @llvm.wasm.shuffle(<16 x i8> %x, <16 x i8> %y, 658 // WEBASSEMBLY-SAME: i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, 659 // WEBASSEMBLY-SAME: i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, 660 // WEBASSEMBLY-SAME: i32 15 661 // WEBASSEMBLY-NEXT: ret 662 } 663 664 f32x4 fma_f32x4(f32x4 a, f32x4 b, f32x4 c) { 665 return __builtin_wasm_fma_f32x4(a, b, c); 666 // WEBASSEMBLY: call <4 x float> @llvm.wasm.fma.v4f32( 667 // WEBASSEMBLY-SAME: <4 x float> %a, <4 x float> %b, <4 x float> %c) 668 // WEBASSEMBLY-NEXT: ret 669 } 670 671 f32x4 fms_f32x4(f32x4 a, f32x4 b, f32x4 c) { 672 return __builtin_wasm_fms_f32x4(a, b, c); 673 // WEBASSEMBLY: call <4 x float> @llvm.wasm.fms.v4f32( 674 // WEBASSEMBLY-SAME: <4 x float> %a, <4 x float> %b, <4 x float> %c) 675 // WEBASSEMBLY-NEXT: ret 676 } 677 678 f64x2 fma_f64x2(f64x2 a, f64x2 b, f64x2 c) { 679 return __builtin_wasm_fma_f64x2(a, b, c); 680 // WEBASSEMBLY: call <2 x double> @llvm.wasm.fma.v2f64( 681 // WEBASSEMBLY-SAME: <2 x double> %a, <2 x double> %b, <2 x double> %c) 682 // WEBASSEMBLY-NEXT: ret 683 } 684 685 f64x2 fms_f64x2(f64x2 a, f64x2 b, f64x2 c) { 686 return __builtin_wasm_fms_f64x2(a, b, c); 687 // WEBASSEMBLY: call <2 x double> @llvm.wasm.fms.v2f64( 688 // WEBASSEMBLY-SAME: <2 x double> %a, <2 x double> %b, <2 x double> %c) 689 // WEBASSEMBLY-NEXT: ret 690 } 691 692 i8x16 laneselect_i8x16(i8x16 a, i8x16 b, i8x16 c) { 693 return __builtin_wasm_laneselect_i8x16(a, b, c); 694 // WEBASSEMBLY: call <16 x i8> @llvm.wasm.laneselect.v16i8( 695 // WEBASSEMBLY-SAME: <16 x i8> %a, <16 x i8> %b, <16 x i8> %c) 696 // WEBASSEMBLY-NEXT: ret 697 } 698 699 i16x8 laneselect_i16x8(i16x8 a, i16x8 b, i16x8 c) { 700 return __builtin_wasm_laneselect_i16x8(a, b, c); 701 // WEBASSEMBLY: call <8 x i16> @llvm.wasm.laneselect.v8i16( 702 // WEBASSEMBLY-SAME: <8 x i16> %a, <8 x i16> %b, <8 x i16> %c) 703 // WEBASSEMBLY-NEXT: ret 704 } 705 706 i32x4 laneselect_i32x4(i32x4 a, i32x4 b, i32x4 c) { 707 return __builtin_wasm_laneselect_i32x4(a, b, c); 708 // WEBASSEMBLY: call <4 x i32> @llvm.wasm.laneselect.v4i32( 709 // WEBASSEMBLY-SAME: <4 x i32> %a, <4 x i32> %b, <4 x i32> %c) 710 // WEBASSEMBLY-NEXT: ret 711 } 712 713 i64x2 laneselect_i64x2(i64x2 a, i64x2 b, i64x2 c) { 714 return __builtin_wasm_laneselect_i64x2(a, b, c); 715 // WEBASSEMBLY: call <2 x i64> @llvm.wasm.laneselect.v2i64( 716 // WEBASSEMBLY-SAME: <2 x i64> %a, <2 x i64> %b, <2 x i64> %c) 717 // WEBASSEMBLY-NEXT: ret 718 } 719 720 i8x16 relaxed_swizzle_i8x16(i8x16 x, i8x16 y) { 721 return __builtin_wasm_relaxed_swizzle_i8x16(x, y); 722 // WEBASSEMBLY: call <16 x i8> @llvm.wasm.relaxed.swizzle(<16 x i8> %x, <16 x i8> %y) 723 } 724 725 f32x4 relaxed_min_f32x4(f32x4 a, f32x4 b) { 726 return __builtin_wasm_relaxed_min_f32x4(a, b); 727 // WEBASSEMBLY: call <4 x float> @llvm.wasm.relaxed.min.v4f32( 728 // WEBASSEMBLY-SAME: <4 x float> %a, <4 x float> %b) 729 // WEBASSEMBLY-NEXT: ret 730 } 731 732 f32x4 relaxed_max_f32x4(f32x4 a, f32x4 b) { 733 return __builtin_wasm_relaxed_max_f32x4(a, b); 734 // WEBASSEMBLY: call <4 x float> @llvm.wasm.relaxed.max.v4f32( 735 // WEBASSEMBLY-SAME: <4 x float> %a, <4 x float> %b) 736 // WEBASSEMBLY-NEXT: ret 737 } 738 739 f64x2 relaxed_min_f64x2(f64x2 a, f64x2 b) { 740 return __builtin_wasm_relaxed_min_f64x2(a, b); 741 // WEBASSEMBLY: call <2 x double> @llvm.wasm.relaxed.min.v2f64( 742 // WEBASSEMBLY-SAME: <2 x double> %a, <2 x double> %b) 743 // WEBASSEMBLY-NEXT: ret 744 } 745 746 f64x2 relaxed_max_f64x2(f64x2 a, f64x2 b) { 747 return __builtin_wasm_relaxed_max_f64x2(a, b); 748 // WEBASSEMBLY: call <2 x double> @llvm.wasm.relaxed.max.v2f64( 749 // WEBASSEMBLY-SAME: <2 x double> %a, <2 x double> %b) 750 // WEBASSEMBLY-NEXT: ret 751 } 752 753 i32x4 relaxed_trunc_s_i32x4_f32x4(f32x4 f) { 754 return __builtin_wasm_relaxed_trunc_s_i32x4_f32x4(f); 755 // WEBASSEMBLY: call <4 x i32> @llvm.wasm.relaxed.trunc.signed(<4 x float> %f) 756 // WEBASSEMBLY-NEXT: ret 757 } 758 759 u32x4 relaxed_trunc_u_i32x4_f32x4(f32x4 f) { 760 return __builtin_wasm_relaxed_trunc_u_i32x4_f32x4(f); 761 // WEBASSEMBLY: call <4 x i32> @llvm.wasm.relaxed.trunc.unsigned(<4 x float> %f) 762 // WEBASSEMBLY-NEXT: ret 763 } 764 765 i32x4 relaxed_trunc_s_zero_i32x4_f64x2(f64x2 x) { 766 return __builtin_wasm_relaxed_trunc_s_zero_i32x4_f64x2(x); 767 // WEBASSEMBLY: call <4 x i32> @llvm.wasm.relaxed.trunc.signed.zero(<2 x double> %x) 768 // WEBASSEMBLY-NEXT: ret 769 } 770 771 u32x4 relaxed_trunc_u_zero_i32x4_f64x2(f64x2 x) { 772 return __builtin_wasm_relaxed_trunc_u_zero_i32x4_f64x2(x); 773 // WEBASSEMBLY: call <4 x i32> @llvm.wasm.relaxed.trunc.unsigned.zero(<2 x double> %x) 774 // WEBASSEMBLY-NEXT: ret 775 } 776 777 i16x8 relaxed_q15mulr_s_i16x8(i16x8 a, i16x8 b) { 778 return __builtin_wasm_relaxed_q15mulr_s_i16x8(a, b); 779 // WEBASSEMBLY: call <8 x i16> @llvm.wasm.relaxed.q15mulr.signed( 780 // WEBASSEMBLY-SAME: <8 x i16> %a, <8 x i16> %b) 781 // WEBASSEMBLY-NEXT: ret 782 } 783 784 i16x8 dot_i8x16_i7x16_s_i16x8(i8x16 a, i8x16 b) { 785 return __builtin_wasm_dot_i8x16_i7x16_s_i16x8(a, b); 786 // WEBASSEMBLY: call <8 x i16> @llvm.wasm.dot.i8x16.i7x16.signed( 787 // WEBASSEMBLY-SAME: <16 x i8> %a, <16 x i8> %b) 788 // WEBASSEMBLY-NEXT: ret 789 } 790 791 i32x4 dot_i8x16_i7x16_add_s_i32x4(i8x16 a, i8x16 b, i32x4 c) { 792 return __builtin_wasm_dot_i8x16_i7x16_add_s_i32x4(a, b, c); 793 // WEBASSEMBLY: call <4 x i32> @llvm.wasm.dot.i8x16.i7x16.add.signed( 794 // WEBASSEMBLY-SAME: <16 x i8> %a, <16 x i8> %b, <4 x i32> %c) 795 // WEBASSEMBLY-NEXT: ret 796 } 797