|
| 1 | +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 |
| 2 | +// REQUIRES: x86-registered-target |
| 3 | +// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx -disable-O0-optnone -fclangir -emit-cir -o %t.cir | opt -S -passes=mem2reg |
| 4 | +// RUN: FileCheck --check-prefixes=CIR --input-file=%t.cir %s |
| 5 | + |
| 6 | +// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx -disable-O0-optnone -fclangir -emit-llvm -o %t.ll | opt -S -passes=mem2reg |
| 7 | +// RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s |
| 8 | + |
| 9 | +#include <immintrin.h> |
| 10 | + |
| 11 | +__m256d test0_mm256_insertf128_pd(__m256d a, __m128d b) { |
| 12 | + // CIR-LABEL: @test0_mm256_insertf128_pd( |
| 13 | + // CIR: [[A:%.*]] = cir.load align(32) %0 : !cir.ptr<!cir.vector<4 x !cir.double>>, !cir.vector<4 x !cir.double> |
| 14 | + // CIR: [[B:%.*]] = cir.load align(16) %1 : !cir.ptr<!cir.vector<2 x !cir.double>>, !cir.vector<2 x !cir.double> |
| 15 | + // CIR: %{{.*}} = cir.vec.shuffle([[B]], %{{.*}} : !cir.vector<2 x !cir.double>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i] : !cir.vector<4 x !cir.double> |
| 16 | + // CIR-NEXT: %{{.*}} = cir.vec.shuffle([[A]], %{{.*}} : !s32i, #cir.int<5> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i] : !cir.vector<4 x !cir.double> |
| 17 | + // CIR: cir.return %{{.*}} : !cir.vector<4 x !cir.double> |
| 18 | + |
| 19 | + // LLVM-LABEL: @test0_mm256_insertf128_pd |
| 20 | + // LLVM: [[A:%.*]] = load <4 x double>, ptr %{{.*}}, align 32 |
| 21 | + // LLVM: [[B:%.*]] = load <2 x double>, ptr %{{.*}}, align 16 |
| 22 | + // LLVM-NEXT: [[WIDEN:%.*]] = shufflevector <2 x double> [[B]], <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3> |
| 23 | + // LLVM-NEXT: [[INSERT:%.*]] = shufflevector <4 x double> [[A]], <4 x double> [[WIDEN]], <4 x i32> <i32 4, i32 5, i32 2, i32 3> |
| 24 | + // LLVM: ret <4 x double> |
| 25 | + return _mm256_insertf128_pd(a, b, 0); |
| 26 | +} |
| 27 | + |
| 28 | +__m256 test0_mm256_insertf128_ps(__m256 a, __m128 b) { |
| 29 | + // CIR-LABEL: @test0_mm256_insertf128_ps( |
| 30 | + // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<4 x !cir.float>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i] : !cir.vector<8 x !cir.float> |
| 31 | + // CIR-NEXT: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !cir.float>) [#cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i] : !cir.vector<8 x !cir.float> |
| 32 | + // CIR: cir.return %{{.*}} : !cir.vector<8 x !cir.float> |
| 33 | + |
| 34 | + // LLVM-LABEL: @test0_mm256_insertf128_ps( |
| 35 | + // LLVM: %{{.*}} = shufflevector <4 x float> %{{.*}}, <4 x float> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> |
| 36 | + // LLVM-NEXT: %{{.*}} = shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 4, i32 5, i32 6, i32 7> |
| 37 | + // LLVM: ret <8 x float> %{{.*}} |
| 38 | + return _mm256_insertf128_ps(a, b, 0); |
| 39 | +} |
| 40 | + |
| 41 | +__m256 test1_mm256_insertf128_ps(__m256 a, __m128 b) { |
| 42 | + // CIR-LABEL: @test1_mm256_insertf128_ps( |
| 43 | + // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<4 x !cir.float>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i] : !cir.vector<8 x !cir.float> |
| 44 | + // CIR-NEXT: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !cir.float>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i] : !cir.vector<8 x !cir.float> |
| 45 | + // CIR: cir.return %{{.*}} : !cir.vector<8 x !cir.float> |
| 46 | + |
| 47 | + // LLVM-LABEL: define dso_local <8 x float> @test1_mm256_insertf128_ps( |
| 48 | + // LLVM: %{{.*}} = shufflevector <4 x float> %{{.*}}, <4 x float> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> |
| 49 | + // LLVM-NEXT: %{{.*}} = shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11> |
| 50 | + // LLVM: ret <8 x float> %{{.*}} |
| 51 | + return _mm256_insertf128_ps(a, b, 1); |
| 52 | +} |
| 53 | + |
| 54 | +__m256i test0_mm256_insertf128_si256(__m256i a, __m128i b) { |
| 55 | + // CIR-LABEL: @test0_mm256_insertf128_si256( |
| 56 | + // CIR: [[TMP0:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<4 x !s64i> -> !cir.vector<8 x !s32i> |
| 57 | + // CIR: [[TMP1:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<4 x !s32i> |
| 58 | + // CIR: %{{.*}} = cir.vec.shuffle([[TMP1]], %{{.*}} : !cir.vector<4 x !s32i>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i] : !cir.vector<8 x !s32i> |
| 59 | + // CIR-NEXT: %{{.*}} = cir.vec.shuffle([[TMP0]], %{{.*}} : !cir.vector<8 x !s32i>) [#cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i] : !cir.vector<8 x !s32i> |
| 60 | + // CIR: %{{.*}} = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s32i> -> !cir.vector<4 x !s64i> |
| 61 | + // CIR: cir.return %{{.*}} : !cir.vector<4 x !s64i> |
| 62 | + |
| 63 | + // LLVM-LABEL: @test0_mm256_insertf128_si256 |
| 64 | + // LLVM: [[TMP0:%.*]] = bitcast <4 x i64> %{{.*}} to <8 x i32> |
| 65 | + // LLVM: [[TMP1:%.*]] = bitcast <2 x i64> %{{.*}} to <4 x i32> |
| 66 | + // LLVM: [[WIDEN:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> |
| 67 | + // LLVM-NEXT: [[INSERT:%.*]] = shufflevector <8 x i32> [[TMP0]], <8 x i32> [[WIDEN]], <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 4, i32 5, i32 6, i32 7> |
| 68 | + // LLVM: [[TMP2:%.*]] = bitcast <8 x i32> [[INSERT]] to <4 x i64> |
| 69 | + // LLVM: ret <4 x i64> %{{.*}} |
| 70 | + return _mm256_insertf128_si256(a, b, 0); |
| 71 | +} |
| 72 | + |
| 73 | +__m256i test1_mm256_insertf128_si256(__m256i a, __m128i b) { |
| 74 | + // CIR-LABEL: @test1_mm256_insertf128_si256( |
| 75 | + // CIR: [[TMP0:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<4 x !s64i> -> !cir.vector<8 x !s32i> |
| 76 | + // CIR: [[TMP1:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<4 x !s32i> |
| 77 | + // CIR: %{{.*}} = cir.vec.shuffle([[TMP1]], %{{.*}} : !cir.vector<4 x !s32i>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i] : !cir.vector<8 x !s32i> |
| 78 | + // CIR-NEXT: %{{.*}} = cir.vec.shuffle([[TMP0]], %{{.*}} : !cir.vector<8 x !s32i>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i] : !cir.vector<8 x !s32i> |
| 79 | + // CIR: %{{.*}} = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s32i> -> !cir.vector<4 x !s64i> |
| 80 | + // CIR: cir.return %{{.*}} : !cir.vector<4 x !s64i> |
| 81 | + |
| 82 | + // LLVM-LABEL: @test1_mm256_insertf128_si256 |
| 83 | + // LLVM: [[TMP0:%.*]] = bitcast <4 x i64> %{{.*}} to <8 x i32> |
| 84 | + // LLVM: [[TMP1:%.*]] = bitcast <2 x i64> %{{.*}} to <4 x i32> |
| 85 | + // LLVM: [[WIDEN:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> |
| 86 | + // LLVM-NEXT: [[INSERT:%.*]] = shufflevector <8 x i32> [[TMP0]], <8 x i32> [[WIDEN]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11> |
| 87 | + // LLVM: [[TMP2:%.*]] = bitcast <8 x i32> [[INSERT]] to <4 x i64> |
| 88 | + // LLVM: ret <4 x i64> %{{.*}} |
| 89 | + return _mm256_insertf128_si256(a, b, 1); |
| 90 | +} |
0 commit comments