|
| 1 | +// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -emit-cir -o %t.cir |
| 2 | +// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s |
| 3 | +// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -emit-cir -o %t.cir |
| 4 | +// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s |
| 5 | + |
| 6 | +// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fclangir -emit-llvm -o %t.ll |
| 7 | +// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s |
| 8 | +// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -fclangir -emit-llvm -o %t.ll |
| 9 | +// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s |
| 10 | + |
| 11 | +// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -emit-cir -o %t.cir |
| 12 | +// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s |
| 13 | +// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -emit-cir -o %t.cir |
| 14 | +// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s |
| 15 | + |
| 16 | +// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fclangir -emit-llvm -o %t.ll |
| 17 | +// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s |
| 18 | +// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -fclangir -emit-llvm -o %t.ll |
| 19 | +// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s |
| 20 | + |
| 21 | +// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG |
| 22 | +// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG |
| 23 | +// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG |
| 24 | +// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG |
| 25 | + |
| 26 | +#include <x86intrin.h> |
| 27 | + |
| 28 | +// This test mimics clang/test/CodeGen/X86/xop-builtins.c, which eventually |
| 29 | +// CIR shall be able to support fully. |
| 30 | + |
| 31 | +__m128i test_mm_roti_epi8(__m128i a) { |
| 32 | + // CIR-LABEL: test_mm_roti_epi8 |
| 33 | + // CIR: cir.vec.splat %{{.*}} : !{{[us]}}8i, !cir.vector<16 x !{{[us]}}8i> |
| 34 | + // CIR: cir.call_llvm_intrinsic "fshl" %{{.*}} : (!cir.vector<16 x !{{[su]}}8i>, !cir.vector<16 x !{{[su]}}8i>, !cir.vector<16 x !{{[su]}}8i>) -> !cir.vector<16 x !{{[su]}}8i> |
| 35 | + |
| 36 | + // LLVM-LABEL: test_mm_roti_epi8 |
| 37 | + // LLVM: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <16 x i8> |
| 38 | + // LLVM: call <16 x i8> @llvm.fshl.v16i8(<16 x i8> %[[CASTED_VAR]], <16 x i8> %[[CASTED_VAR]], <16 x i8> splat (i8 1)) |
| 39 | + |
| 40 | + // OGCG-LABEL: test_mm_roti_epi8 |
| 41 | + // OGCG: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <16 x i8> |
| 42 | + // OGCG: call <16 x i8> @llvm.fshl.v16i8(<16 x i8> %[[CASTED_VAR]], <16 x i8> %[[CASTED_VAR]], <16 x i8> splat (i8 1)) |
| 43 | + return _mm_roti_epi8(a, 1); |
| 44 | +} |
| 45 | + |
| 46 | +__m128i test_mm_roti_epi16(__m128i a) { |
| 47 | + // CIR-LABEL: test_mm_roti_epi16 |
| 48 | + // CIR: cir.cast integral %{{.*}} : !u8i -> !u16i |
| 49 | + // CIR: cir.vec.splat %{{.*}} : !{{[us]}}16i, !cir.vector<8 x !u16i> |
| 50 | + // CIR: cir.call_llvm_intrinsic "fshl" %{{.*}} : (!cir.vector<8 x !{{[su]}}16i>, !cir.vector<8 x !{{[su]}}16i>, !cir.vector<8 x !u16i>) -> !cir.vector<8 x !{{[su]}}16i> |
| 51 | + |
| 52 | + // LLVM-LABEL: test_mm_roti_epi16 |
| 53 | + // LLVM: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <8 x i16> |
| 54 | + // LLVM: call <8 x i16> @llvm.fshl.v8i16(<8 x i16> %[[CASTED_VAR]], <8 x i16> %[[CASTED_VAR]], <8 x i16> splat (i16 50)) |
| 55 | + |
| 56 | + // OGCG-LABEL: test_mm_roti_epi16 |
| 57 | + // OGCG: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <8 x i16> |
| 58 | + // OGCG: call <8 x i16> @llvm.fshl.v8i16(<8 x i16> %[[CASTED_VAR]], <8 x i16> %[[CASTED_VAR]], <8 x i16> splat (i16 50)) |
| 59 | + return _mm_roti_epi16(a, 50); |
| 60 | + } |
| 61 | + |
| 62 | +__m128i test_mm_roti_epi32(__m128i a) { |
| 63 | + // CIR-LABEL: test_mm_roti_epi32 |
| 64 | + // CIR: cir.cast integral %{{.*}} : !u8i -> !u32i |
| 65 | + // CIR: cir.vec.splat %{{.*}} : !{{[us]}}32i, !cir.vector<4 x !u32i> |
| 66 | + // CIR: cir.call_llvm_intrinsic "fshl" %{{.*}} : (!cir.vector<4 x !{{[su]}}32i>, !cir.vector<4 x !{{[su]}}32i>, !cir.vector<4 x !u32i>) -> !cir.vector<4 x !{{[su]}}32i> |
| 67 | + |
| 68 | + // LLVM-LABEL: test_mm_roti_epi32 |
| 69 | + // LLVM: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <4 x i32> |
| 70 | + // LLVM: call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %[[CASTED_VAR]], <4 x i32> %[[CASTED_VAR]], <4 x i32> splat (i32 226)) |
| 71 | + |
| 72 | + // OGCG-LABEL: test_mm_roti_epi32 |
| 73 | + // OGCG: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <4 x i32> |
| 74 | + // OGCG: call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %[[CASTED_VAR]], <4 x i32> %[[CASTED_VAR]], <4 x i32> splat (i32 226)) |
| 75 | + return _mm_roti_epi32(a, -30); |
| 76 | + } |
| 77 | + |
| 78 | +__m128i test_mm_roti_epi64(__m128i a) { |
| 79 | + // CIR-LABEL: test_mm_roti_epi64 |
| 80 | + // CIR: cir.cast integral %{{.*}} : !u8i -> !u64i |
| 81 | + // CIR: cir.vec.splat %{{.*}} : !u64i, !cir.vector<2 x !u64i> |
| 82 | + // CIR: cir.call_llvm_intrinsic "fshl" %{{.*}} : (!cir.vector<2 x !{{[su]}}64i>, !cir.vector<2 x !{{[su]}}64i>, !cir.vector<2 x !u64i>) -> !cir.vector<2 x !s64i> |
| 83 | + |
| 84 | + // LLVM-LABEL: test_mm_roti_epi64 |
| 85 | + // LLVM: %[[VAR:.*]] = load <2 x i64>, ptr %{{.*}}, align 16 |
| 86 | + // LLVM: call <2 x i64> @llvm.fshl.v2i64(<2 x i64> %[[VAR]], <2 x i64> %[[VAR]], <2 x i64> splat (i64 100)) |
| 87 | + |
| 88 | + // OGCG-LABEL: test_mm_roti_epi64 |
| 89 | + // OGCG: %[[VAR:.*]] = load <2 x i64>, ptr %{{.*}}, align 16 |
| 90 | + // OGCG: call <2 x i64> @llvm.fshl.v2i64(<2 x i64> %[[VAR]], <2 x i64> %[[VAR]], <2 x i64> splat (i64 100)) |
| 91 | + return _mm_roti_epi64(a, 100); |
| 92 | + } |
0 commit comments