|
| 1 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -fclangir -emit-cir %s -o - | FileCheck %s --check-prefix=CIR |
| 2 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -fclangir -emit-llvm %s -o - | FileCheck %s -check-prefix=LLVM |
| 3 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -fclangir -emit-llvm %s -o - | FileCheck %s -check-prefix=OG |
| 4 | + |
| 5 | +typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16))); |
| 6 | + |
| 7 | + |
| 8 | +__m128 test_cmpnleps(__m128 A, __m128 B) { |
| 9 | + |
| 10 | + // CIR-LABEL: @test_cmpnleps |
| 11 | + // CIR: [[CMP:%.*]] = cir.vec.cmp(gt, [[A:%.*]], [[B:%.*]]) : !cir.vector<!cir.float x 4>, !cir.vector<!s32i x 4> |
| 12 | + // CIR-NEXT: [[CAST:%.*]] = cir.cast(bitcast, [[ALLOCA:%.*]] : !cir.ptr<!cir.vector<!cir.float x 4>>), !cir.ptr<!cir.vector<!s32i x 4>> |
| 13 | + // CIR-NEXT: cir.store [[CMP]], [[CAST]] : !cir.vector<!s32i x 4>, !cir.ptr<!cir.vector<!s32i x 4>> |
| 14 | + // CIR-NEXT: [[LD:%.*]] = cir.load [[ALLOCA]] : |
| 15 | + // CIR-NEXT: cir.return [[LD]] : !cir.vector<!cir.float x 4> |
| 16 | + |
| 17 | + // LLVM-LABEL: test_cmpnleps |
| 18 | + // LLVM: [[CMP:%.*]] = fcmp ugt <4 x float> {{.*}}, {{.*}} |
| 19 | + // LLVM-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32> |
| 20 | + // LLVM-NEXT: [[CAST:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float> |
| 21 | + // LLVM-NEXT: ret <4 x float> [[CAST]] |
| 22 | + |
| 23 | + // OG-LABEL: test_cmpnleps |
| 24 | + // OG: [[CMP:%.*]] = fcmp ugt <4 x float> {{.*}}, {{.*}} |
| 25 | + // OG-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32> |
| 26 | + // OG-NEXT: [[CAST:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float> |
| 27 | + // OG-NEXT: ret <4 x float> [[CAST]] |
| 28 | + return __builtin_ia32_cmpnleps(A, B); |
| 29 | +} |
| 30 | + |
| 31 | + |
| 32 | +__m128 test_cmpnlepd(__m128 A, __m128 B) { |
| 33 | + |
| 34 | + // CIR-LABEL: @test_cmpnlepd |
| 35 | + // CIR: [[CMP:%.*]] = cir.vec.cmp(gt, [[A:%.*]], [[B:%.*]]) : !cir.vector<!cir.double x 2>, !cir.vector<!s64i x 2> |
| 36 | + // CIR-NEXT: [[CAST:%.*]] = cir.cast(bitcast, [[CMP]] : !cir.vector<!s64i x 2>), !cir.vector<!cir.float x 4> |
| 37 | + // CIR-NEXT: cir.store [[CAST]], [[ALLOCA:%.*]] : !cir.vector<!cir.float x 4>, !cir.ptr<!cir.vector<!cir.float x 4>> |
| 38 | + // CIR-NEXT: [[LD:%.*]] = cir.load [[ALLOCA]] : |
| 39 | + // CIR-NEXT: cir.return [[LD]] : !cir.vector<!cir.float x 4> |
| 40 | + |
| 41 | + // LLVM-LABEL: test_cmpnlepd |
| 42 | + // LLVM: [[CMP:%.*]] = fcmp ugt <2 x double> {{.*}}, {{.*}} |
| 43 | + // LLVM-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64> |
| 44 | + // LLVM-NEXT: [[CAST:%.*]] = bitcast <2 x i64> [[SEXT]] to <4 x float> |
| 45 | + // LLVM-NEXT: ret <4 x float> [[CAST]] |
| 46 | + |
| 47 | + // OG-LABEL: test_cmpnlepd |
| 48 | + // OG: [[CMP:%.*]] = fcmp ugt <2 x double> {{.*}}, {{.*}} |
| 49 | + // OG-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64> |
| 50 | + // OG-NEXT: [[CAST:%.*]] = bitcast <2 x i64> [[SEXT]] to <4 x float> |
| 51 | + // OG-NEXT: ret <4 x float> [[CAST]] |
| 52 | + return __builtin_ia32_cmpnlepd(A, B); |
| 53 | +} |
0 commit comments