Skip to content

Commit 291c4ad

Browse files
committed
Add support for cmpnltps and test_cmpnltpd
1 parent 955d33f commit 291c4ad

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,8 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned BuiltinID,
17401740
llvm_unreachable("cmpneqps NYI");
17411741
case X86::BI__builtin_ia32_cmpnltps:
17421742
case X86::BI__builtin_ia32_cmpnltpd:
1743-
llvm_unreachable("cmpnltps NYI");
1743+
return getVectorFCmpIR(cir::CmpOpKind::lt, /*shouldInvert=*/true,
1744+
/*isSignaling=*/true);
17441745
case X86::BI__builtin_ia32_cmpnleps:
17451746
case X86::BI__builtin_ia32_cmpnlepd:
17461747
return getVectorFCmpIR(cir::CmpOpKind::le, /*shouldInvert=*/true,

clang/test/CIR/CodeGen/builtin-fcmp-sse.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,54 @@ __m128d test_cmpnlepd(__m128d A, __m128d B) {
5353
// OG-NEXT: ret <2 x double> [[CAST]]
5454
return __builtin_ia32_cmpnlepd(A, B);
5555
}
56+
57+
58+
__m128 test_cmpnltps(__m128 A, __m128 B) {
59+
60+
// CIR-LABEL: @test_cmpnltps
61+
// CIR: [[CMP:%.*]] = cir.vec.cmp(lt, [[A:%.*]], [[B:%.*]]) : !cir.vector<!cir.float x 4>, !cir.vector<!s32i x 4>
62+
// CIR: [[NOTCMP:%.*]] = cir.unary(not, [[CMP]]) : !cir.vector<!s32i x 4>, !cir.vector<!s32i x 4>
63+
// CIR-NEXT: [[CAST:%.*]] = cir.cast(bitcast, [[NOTCMP:%.*]] : !cir.vector<!s32i x 4>), !cir.vector<!cir.float x 4>
64+
// CIR-NEXT: cir.store [[CAST]], [[ALLOCA:%.*]] : !cir.vector<!cir.float x 4>, !cir.ptr<!cir.vector<!cir.float x 4>>
65+
// CIR-NEXT: [[LD:%.*]] = cir.load [[ALLOCA]] :
66+
// CIR-NEXT: cir.return [[LD]] : !cir.vector<!cir.float x 4>
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+
// OG-LABEL: test_cmpnltps
75+
// OG: [[CMP:%.*]] = fcmp uge <4 x float> {{.*}}, {{.*}}
76+
// OG-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
77+
// OG-NEXT: [[CAST:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
78+
// OG-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+
85+
// CIR-LABEL: @test_cmpnltpd
86+
// CIR: [[CMP:%.*]] = cir.vec.cmp(lt, [[A:%.*]], [[B:%.*]]) : !cir.vector<!cir.double x 2>, !cir.vector<!s64i x 2>
87+
// CIR-NEXT: [[NOTCMP:%.*]] = cir.unary(not, [[CMP]]) : !cir.vector<!s64i x 2>, !cir.vector<!s64i x 2>
88+
// CIR-NEXT: [[CAST:%.*]] = cir.cast(bitcast, [[NOTCMP]] : !cir.vector<!s64i x 2>), !cir.vector<!cir.double x 2>
89+
// CIR-NEXT: cir.store [[CAST]], [[ALLOCA:%.*]] : !cir.vector<!cir.double x 2>, !cir.ptr<!cir.vector<!cir.double x 2>>
90+
// CIR-NEXT: [[LD:%.*]] = cir.load [[ALLOCA]] :
91+
// CIR-NEXT: cir.return [[LD]] : !cir.vector<!cir.double x 2>
92+
93+
// LLVM-LABEL: test_cmpnltpd
94+
// LLVM: [[CMP:%.*]] = fcmp uge <2 x double> {{.*}}, {{.*}}
95+
// LLVM-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
96+
// LLVM-NEXT: [[CAST:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
97+
// LLVM-NEXT: ret <2 x double> [[CAST]]
98+
99+
// OG-LABEL: test_cmpnltpd
100+
// OG: [[CMP:%.*]] = fcmp uge <2 x double> {{.*}}, {{.*}}
101+
// OG-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
102+
// OG-NEXT: [[CAST:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
103+
// OG-NEXT: ret <2 x double> [[CAST]]
104+
return __builtin_ia32_cmpnltpd(A, B);
105+
}
106+

0 commit comments

Comments
 (0)