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