1 // RUN: %clang_cc1 -std=c++2a -emit-llvm %s -o - -triple %itanium_abi_triple | \
3 // RUN: '-DSO="class.std::__1::strong_ordering"' \
4 // RUN: '-DPO="class.std::__1::partial_ordering"' \
5 // RUN: -DEQ=0 -DLT=-1 -DGT=1 -DUNORD=-127 -DNE=1
7 #include "Inputs/std-compare.h"
9 // Ensure we don't emit definitions for the global variables
10 // since the builtins shouldn't ODR use them.
11 // CHECK-NOT: constant %[[SO]]
12 // CHECK-NOT: constant %[[PO]]
14 // CHECK-LABEL: @_Z11test_signedii
15 auto test_signed(int x
, int y
) {
16 // CHECK: %[[DEST:retval|agg.result]]
17 // CHECK: %cmp.lt = icmp slt i32 %{{.+}}, %{{.+}}
18 // CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 [[GT]]
19 // CHECK: %cmp.eq = icmp eq i32 %{{.+}}, %{{.+}}
20 // CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 %sel.lt
21 // CHECK: %__value_ = getelementptr inbounds %[[SO]], %[[SO]]* %[[DEST]]
22 // CHECK: store i8 %sel.eq, i8* %__value_, align 1
27 // CHECK-LABEL: @_Z13test_unsignedjj
28 auto test_unsigned(unsigned x
, unsigned y
) {
29 // CHECK: %[[DEST:retval|agg.result]]
30 // CHECK: %cmp.lt = icmp ult i32 %{{.+}}, %{{.+}}
31 // CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 [[GT]]
32 // CHECK: %cmp.eq = icmp eq i32 %{{.+}}, %{{.+}}
33 // CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 %sel.lt
34 // CHECK: %__value_ = getelementptr inbounds %[[SO]], %[[SO]]* %[[DEST]]
35 // CHECK: store i8 %sel.eq, i8* %__value_
40 // CHECK-LABEL: @_Z10float_testdd
41 auto float_test(double x
, double y
) {
42 // CHECK: %[[DEST:retval|agg.result]]
43 // CHECK: %cmp.eq = fcmp oeq double %{{.+}}, %{{.+}}
44 // CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 [[UNORD]]
45 // CHECK: %cmp.gt = fcmp ogt double %{{.+}}, %{{.+}}
46 // CHECK: %sel.gt = select i1 %cmp.gt, i8 [[GT]], i8 %sel.eq
47 // CHECK: %cmp.lt = fcmp olt double %{{.+}}, %{{.+}}
48 // CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 %sel.gt
49 // CHECK: %__value_ = getelementptr inbounds %[[PO]], %[[PO]]* %[[DEST]]
50 // CHECK: store i8 %sel.lt, i8* %__value_
55 // CHECK-LABEL: @_Z8ptr_testPiS_
56 auto ptr_test(int *x
, int *y
) {
57 // CHECK: %[[DEST:retval|agg.result]]
58 // CHECK: %cmp.lt = icmp ult i32* %{{.+}}, %{{.+}}
59 // CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 [[GT]]
60 // CHECK: %cmp.eq = icmp eq i32* %{{.+}}, %{{.+}}
61 // CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 %sel.lt
62 // CHECK: %__value_ = getelementptr inbounds %[[SO]], %[[SO]]* %[[DEST]]
63 // CHECK: store i8 %sel.eq, i8* %__value_, align 1
68 // CHECK-LABEL: @_Z13test_constantv
69 auto test_constant() {
70 // CHECK: %[[DEST:retval|agg.result]]
72 // CHECK: %__value_ = getelementptr inbounds %[[SO]], %[[SO]]* %[[DEST]]
73 // CHECK-NEXT: store i8 -1, i8* %__value_
80 // CHECK-LABEL: @_Z18unscoped_enum_testijxy
81 void unscoped_enum_test(int i
, unsigned u
, long long l
, unsigned long long ul
) {
82 enum EnumA
: int { A
};
83 enum EnumB
: unsigned { B
};
84 // CHECK: %[[I:.*]] = load {{.*}} %i.addr
85 // CHECK: icmp slt i32 {{.*}} %[[I]]
88 // CHECK: %[[U:.*]] = load {{.*}} %u.addr
89 // CHECK: icmp ult i32 {{.*}} %[[U]]
92 // CHECK: %[[L:.*]] = load {{.*}} %l.addr
93 // CHECK: icmp slt i64 {{.*}} %[[L]]
96 // CHECK: %[[U2:.*]] = load {{.*}} %u.addr
97 // CHECK: icmp ult i32 {{.*}} %[[U2]]
100 // CHECK: %[[UL:.*]] = load {{.*}} %ul.addr
101 // CHECK: icmp ult i64 {{.*}} %[[UL]]