|
| 1 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -fclangir -emit-cir %s -o %t.cir |
| 2 | +// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR |
| 3 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -fclangir -emit-llvm %s -o %t-cir.ll |
| 4 | +// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM |
| 5 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -emit-llvm %s -o %t.ll |
| 6 | +// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG |
| 7 | + |
| 8 | +typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16))); |
| 9 | +typedef double __m128d __attribute__((__vector_size__(16), __aligned__(16))); |
| 10 | + |
| 11 | +__m128 test_cmpnleps(__m128 A, __m128 B) { |
| 12 | + // CIR-LABEL: @test_cmpnleps |
| 13 | + // CIR: [[CMP:%.*]] = cir.vec.cmp(le, [[A:%.*]], [[B:%.*]]) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> |
| 14 | + // CIR: [[NOTCMP:%.*]] = cir.unary(not, [[CMP]]) : !cir.vector<4 x !s32i>, !cir.vector<4 x !s32i> |
| 15 | + // CIR-NEXT: [[CAST:%.*]] = cir.cast bitcast [[NOTCMP:%.*]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float> |
| 16 | + // CIR-NEXT: cir.store [[CAST]], [[ALLOCA:%.*]] : !cir.vector<4 x !cir.float>, !cir.ptr<!cir.vector<4 x !cir.float>> |
| 17 | + // CIR-NEXT: [[LD:%.*]] = cir.load [[ALLOCA]] : |
| 18 | + // CIR-NEXT: cir.return [[LD]] : !cir.vector<4 x !cir.float> |
| 19 | + |
| 20 | + // LLVM-LABEL: test_cmpnleps |
| 21 | + // LLVM: [[CMP:%.*]] = fcmp ugt <4 x float> {{.*}}, {{.*}} |
| 22 | + // LLVM-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32> |
| 23 | + // LLVM-NEXT: [[CAST:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float> |
| 24 | + // LLVM-NEXT: ret <4 x float> [[CAST]] |
| 25 | + |
| 26 | + // OGCG-LABEL: test_cmpnleps |
| 27 | + // OGCG: [[CMP:%.*]] = fcmp ugt <4 x float> {{.*}}, {{.*}} |
| 28 | + // OGCG-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32> |
| 29 | + // OGCG-NEXT: [[CAST:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float> |
| 30 | + // OGCG-NEXT: ret <4 x float> [[CAST]] |
| 31 | + return __builtin_ia32_cmpnleps(A, B); |
| 32 | +} |
| 33 | + |
| 34 | + |
| 35 | +__m128d test_cmpnlepd(__m128d A, __m128d B) { |
| 36 | + // CIR-LABEL: @test_cmpnlepd |
| 37 | + // CIR: [[CMP:%.*]] = cir.vec.cmp(le, [[A:%.*]], [[B:%.*]]) : !cir.vector<2 x !cir.double>, !cir.vector<2 x !s64i> |
| 38 | + // CIR-NEXT: [[NOTCMP:%.*]] = cir.unary(not, [[CMP]]) : !cir.vector<2 x !s64i>, !cir.vector<2 x !s64i> |
| 39 | + // CIR-NEXT: [[CAST:%.*]] = cir.cast bitcast [[NOTCMP]] : !cir.vector<2 x !s64i> -> !cir.vector<2 x !cir.double> |
| 40 | + // CIR-NEXT: cir.store [[CAST]], [[ALLOCA:%.*]] : !cir.vector<2 x !cir.double>, !cir.ptr<!cir.vector<2 x !cir.double>> |
| 41 | + // CIR-NEXT: [[LD:%.*]] = cir.load [[ALLOCA]] : |
| 42 | + // CIR-NEXT: cir.return [[LD]] : !cir.vector<2 x !cir.double> |
| 43 | + |
| 44 | + // LLVM-LABEL: test_cmpnlepd |
| 45 | + // LLVM: [[CMP:%.*]] = fcmp ugt <2 x double> {{.*}}, {{.*}} |
| 46 | + // LLVM-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64> |
| 47 | + // LLVM-NEXT: [[CAST:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double> |
| 48 | + // LLVM-NEXT: ret <2 x double> [[CAST]] |
| 49 | + |
| 50 | + // OGCG-LABEL: test_cmpnlepd |
| 51 | + // OGCG: [[CMP:%.*]] = fcmp ugt <2 x double> {{.*}}, {{.*}} |
| 52 | + // OGCG-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64> |
| 53 | + // OGCG-NEXT: [[CAST:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double> |
| 54 | + // OGCG-NEXT: ret <2 x double> [[CAST]] |
| 55 | + return __builtin_ia32_cmpnlepd(A, B); |
| 56 | +} |
| 57 | + |
| 58 | + |
| 59 | +__m128 test_cmpnltps(__m128 A, __m128 B) { |
| 60 | + // CIR-LABEL: @test_cmpnltps |
| 61 | + // CIR: [[CMP:%.*]] = cir.vec.cmp(lt, [[A:%.*]], [[B:%.*]]) : !cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> |
| 62 | + // CIR: [[NOTCMP:%.*]] = cir.unary(not, [[CMP]]) : !cir.vector<4 x !s32i>, !cir.vector<4 x !s32i> |
| 63 | + // CIR-NEXT: [[CAST:%.*]] = cir.cast bitcast [[NOTCMP:%.*]] : !cir.vector<4 x !s32i> -> !cir.vector<4 x !cir.float> |
| 64 | + // CIR-NEXT: cir.store [[CAST]], [[ALLOCA:%.*]] : !cir.vector<4 x !cir.float>, !cir.ptr<!cir.vector<4 x !cir.float>> |
| 65 | + // CIR-NEXT: [[LD:%.*]] = cir.load [[ALLOCA]] : |
| 66 | + // CIR-NEXT: cir.return [[LD]] : !cir.vector<4 x !cir.float> |
| 67 | + |
| 68 | + // LLVM-LABEL: test_cmpnltps |
| 69 | + // LLVM: [[CMP:%.*]] = fcmp uge <4 x float> {{.*}}, {{.*}} |
| 70 | + // LLVM-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32> |
| 71 | + // LLVM-NEXT: [[CAST:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float> |
| 72 | + // LLVM-NEXT: ret <4 x float> [[CAST]] |
| 73 | + |
| 74 | + // OGCG-LABEL: test_cmpnltps |
| 75 | + // OGCG: [[CMP:%.*]] = fcmp uge <4 x float> {{.*}}, {{.*}} |
| 76 | + // OGCG-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32> |
| 77 | + // OGCG-NEXT: [[CAST:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float> |
| 78 | + // OGCG-NEXT: ret <4 x float> [[CAST]] |
| 79 | + return __builtin_ia32_cmpnltps(A, B); |
| 80 | +} |
| 81 | + |
| 82 | + |
| 83 | +__m128d test_cmpnltpd(__m128d A, __m128d B) { |
| 84 | + // CIR-LABEL: @test_cmpnltpd |
| 85 | + // CIR: [[CMP:%.*]] = cir.vec.cmp(lt, [[A:%.*]], [[B:%.*]]) : !cir.vector<2 x !cir.double>, !cir.vector<2 x !s64i> |
| 86 | + // CIR-NEXT: [[NOTCMP:%.*]] = cir.unary(not, [[CMP]]) : !cir.vector<2 x !s64i>, !cir.vector<2 x !s64i> |
| 87 | + // CIR-NEXT: [[CAST:%.*]] = cir.cast bitcast [[NOTCMP]] : !cir.vector<2 x !s64i> -> !cir.vector<2 x !cir.double> |
| 88 | + // CIR-NEXT: cir.store [[CAST]], [[ALLOCA:%.*]] : !cir.vector<2 x !cir.double>, !cir.ptr<!cir.vector<2 x !cir.double>> |
| 89 | + // CIR-NEXT: [[LD:%.*]] = cir.load [[ALLOCA]] : |
| 90 | + // CIR-NEXT: cir.return [[LD]] : !cir.vector<2 x !cir.double> |
| 91 | + |
| 92 | + // LLVM-LABEL: test_cmpnltpd |
| 93 | + // LLVM: [[CMP:%.*]] = fcmp uge <2 x double> {{.*}}, {{.*}} |
| 94 | + // LLVM-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64> |
| 95 | + // LLVM-NEXT: [[CAST:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double> |
| 96 | + // LLVM-NEXT: ret <2 x double> [[CAST]] |
| 97 | + |
| 98 | + // OGCG-LABEL: test_cmpnltpd |
| 99 | + // OGCG: [[CMP:%.*]] = fcmp uge <2 x double> {{.*}}, {{.*}} |
| 100 | + // OGCG-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64> |
| 101 | + // OGCG-NEXT: [[CAST:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double> |
| 102 | + // OGCG-NEXT: ret <2 x double> [[CAST]] |
| 103 | + return __builtin_ia32_cmpnltpd(A, B); |
| 104 | +} |
0 commit comments