| 1 |
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse -fclangir -emit-cir -o %t.cir -Wall -Werror |
| 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-unknown-linux -target-feature +sse -fclangir -emit-llvm -o %t.ll -Wall -Werror |
| 4 |
// RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s |
| 5 |
|
| 6 |
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse -fno-signed-char -fclangir -emit-cir -o %t.cir -Wall -Werror |
| 7 |
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s |
| 8 |
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse -fclangir -emit-llvm -o %t.ll -Wall -Werror |
| 9 |
// RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s |
| 10 |
|
| 11 |
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG |
| 12 |
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG |
| 13 |
|
| 14 |
// This test mimics clang/test/CodeGen/X86/sse-builtins.c, which eventually |
| 15 |
// CIR shall be able to support fully. |
| 16 |
|
| 17 |
#include <immintrin.h> |
| 18 |
|
| 19 |
void test_mm_setcsr(unsigned int A) { |
| 20 |
// CIR-LABEL: test_mm_setcsr |
| 21 |
// CIR: cir.store {{.*}}, {{.*}} : !u32i |
| 22 |
// CIR: cir.call_llvm_intrinsic "x86.sse.ldmxcsr" {{.*}} : (!cir.ptr<!u32i>) -> !void |
| 23 |
|
| 24 |
// LLVM-LABEL: test_mm_setcsr |
| 25 |
// LLVM: store i32 |
| 26 |
// LLVM: call void @llvm.x86.sse.ldmxcsr(ptr {{.*}}) |
| 27 |
|
| 28 |
// OGCG-LABEL: test_mm_setcsr |
| 29 |
// OGCG: store i32 |
| 30 |
// OGCG: call void @llvm.x86.sse.ldmxcsr(ptr {{.*}}) |
| 31 |
_mm_setcsr(A); |
| 32 |
} |
| 33 |
|
| 34 |
unsigned int test_mm_getcsr(void) { |
| 35 |
// CIR-LABEL: test_mm_getcsr |
| 36 |
// CIR: cir.call_llvm_intrinsic "x86.sse.stmxcsr" %{{.*}} : (!cir.ptr<!u32i>) -> !void |
| 37 |
// CIR: cir.load {{.*}} : !cir.ptr<!u32i>, !u32i |
| 38 |
|
| 39 |
// LLVM-LABEL: test_mm_getcsr |
| 40 |
// LLVM: call void @llvm.x86.sse.stmxcsr(ptr %{{.*}}) |
| 41 |
// LLVM: load i32 |
| 42 |
|
| 43 |
// OGCG-LABEL: test_mm_getcsr |
| 44 |
// OGCG: call void @llvm.x86.sse.stmxcsr(ptr %{{.*}}) |
| 45 |
// OGCG: load i32 |
| 46 |
return _mm_getcsr(); |
| 47 |
} |
| 48 |
|
| 49 |
void test_mm_sfence(void) { |
| 50 |
// CIR-LABEL: test_mm_sfence |
| 51 |
// LLVM-LABEL: test_mm_sfence |
| 52 |
// OGCG-LABEL: test_mm_sfence |
| 53 |
_mm_sfence(); |
| 54 |
// CIR: {{%.*}} = cir.call_llvm_intrinsic "x86.sse.sfence" : () -> !void |
| 55 |
// LLVM: call void @llvm.x86.sse.sfence() |
| 56 |
// OGCG: call void @llvm.x86.sse.sfence() |
| 57 |
} |
| 58 |
|
| 59 |
__m128 test_mm_undefined_ps(void) { |
| 60 |
// CIR-LABEL: _mm_undefined_ps |
| 61 |
// CIR: %[[A:.*]] = cir.const #cir.zero : !cir.vector<2 x !cir.double> |
| 62 |
// CIR: %{{.*}} = cir.cast bitcast %[[A]] : !cir.vector<2 x !cir.double> -> !cir.vector<4 x !cir.float> |
| 63 |
// CIR: cir.return %{{.*}} : !cir.vector<4 x !cir.float> |
| 64 |
|
| 65 |
// LLVM-LABEL: test_mm_undefined_ps |
| 66 |
// LLVM: store <4 x float> zeroinitializer, ptr %[[A:.*]], align 16 |
| 67 |
// LLVM: %{{.*}} = load <4 x float>, ptr %[[A]], align 16 |
| 68 |
// LLVM: ret <4 x float> %{{.*}} |
| 69 |
|
| 70 |
// OGCG-LABEL: test_mm_undefined_ps |
| 71 |
// OGCG: ret <4 x float> zeroinitializer |
| 72 |
return _mm_undefined_ps(); |
| 73 |
} |
| 74 |
|
| 75 |
__m128 test_mm_shuffle_ps(__m128 A, __m128 B) { |
| 76 |
// CIR-LABEL: _mm_shuffle_ps |
| 77 |
// CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<4 x !cir.float>) [#cir.int<0> : !s32i, #cir.int<0> : !s32i, #cir.int<4> : !s32i, #cir.int<4> : !s32i] : !cir.vector<4 x !cir.float> |
| 78 |
|
| 79 |
// LLVM-LABEL: test_mm_shuffle_ps |
| 80 |
// LLVM: shufflevector <4 x float> {{.*}}, <4 x float> {{.*}}, <4 x i32> <i32 0, i32 0, i32 4, i32 4> |
| 81 |
|
| 82 |
// OGCG-LABEL: test_mm_shuffle_ps |
| 83 |
// OGCG: shufflevector <4 x float> {{.*}}, <4 x float> {{.*}}, <4 x i32> <i32 0, i32 0, i32 4, i32 4> |
| 84 |
return _mm_shuffle_ps(A, B, 0); |
| 85 |
} |