Skip to content

Commit 41af17a

Browse files
committed
Implement more _mm_cmp*_{ps,pd} intrinsics
1 parent 0311202 commit 41af17a

File tree

1 file changed

+85
-8
lines changed

1 file changed

+85
-8
lines changed

src/intrinsics/llvm_x86.rs

Lines changed: 85 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,95 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
6666
let flt_cc = match kind
6767
.try_to_bits(Size::from_bytes(1))
6868
.unwrap_or_else(|| panic!("kind not scalar: {:?}", kind))
69+
.try_into()
70+
.unwrap()
6971
{
70-
0 => FloatCC::Equal,
71-
1 => FloatCC::LessThan,
72-
2 => FloatCC::LessThanOrEqual,
73-
7 => FloatCC::Ordered,
74-
3 => FloatCC::Unordered,
75-
4 => FloatCC::NotEqual,
76-
5 => FloatCC::UnorderedOrGreaterThanOrEqual,
77-
6 => FloatCC::UnorderedOrGreaterThan,
72+
_CMP_EQ_OQ | _CMP_EQ_OS => FloatCC::Equal,
73+
_CMP_LT_OS | _CMP_LT_OQ => FloatCC::LessThan,
74+
_CMP_LE_OS | _CMP_LE_OQ => FloatCC::LessThanOrEqual,
75+
_CMP_UNORD_Q | _CMP_UNORD_S => FloatCC::Unordered,
76+
_CMP_NEQ_UQ | _CMP_NEQ_US => FloatCC::NotEqual,
77+
_CMP_NLT_US | _CMP_NLT_UQ => FloatCC::UnorderedOrGreaterThanOrEqual,
78+
_CMP_NLE_US | _CMP_NLE_UQ => FloatCC::UnorderedOrGreaterThan,
79+
_CMP_ORD_Q | _CMP_ORD_S => FloatCC::Ordered,
80+
_CMP_EQ_UQ | _CMP_EQ_US => FloatCC::UnorderedOrEqual,
81+
_CMP_NGE_US | _CMP_NGE_UQ => FloatCC::UnorderedOrLessThan,
82+
_CMP_NGT_US | _CMP_NGT_UQ => FloatCC::UnorderedOrLessThanOrEqual,
83+
_CMP_FALSE_OQ | _CMP_FALSE_OS => todo!(),
84+
_CMP_NEQ_OQ | _CMP_NEQ_OS => FloatCC::OrderedNotEqual,
85+
_CMP_GE_OS | _CMP_GE_OQ => FloatCC::GreaterThanOrEqual,
86+
_CMP_GT_OS | _CMP_GT_OQ => FloatCC::GreaterThan,
87+
_CMP_TRUE_UQ | _CMP_TRUE_US => todo!(),
88+
7889
kind => unreachable!("kind {:?}", kind),
7990
};
8091

92+
// Copied from stdarch
93+
/// Equal (ordered, non-signaling)
94+
const _CMP_EQ_OQ: i32 = 0x00;
95+
/// Less-than (ordered, signaling)
96+
const _CMP_LT_OS: i32 = 0x01;
97+
/// Less-than-or-equal (ordered, signaling)
98+
const _CMP_LE_OS: i32 = 0x02;
99+
/// Unordered (non-signaling)
100+
const _CMP_UNORD_Q: i32 = 0x03;
101+
/// Not-equal (unordered, non-signaling)
102+
const _CMP_NEQ_UQ: i32 = 0x04;
103+
/// Not-less-than (unordered, signaling)
104+
const _CMP_NLT_US: i32 = 0x05;
105+
/// Not-less-than-or-equal (unordered, signaling)
106+
const _CMP_NLE_US: i32 = 0x06;
107+
/// Ordered (non-signaling)
108+
const _CMP_ORD_Q: i32 = 0x07;
109+
/// Equal (unordered, non-signaling)
110+
const _CMP_EQ_UQ: i32 = 0x08;
111+
/// Not-greater-than-or-equal (unordered, signaling)
112+
const _CMP_NGE_US: i32 = 0x09;
113+
/// Not-greater-than (unordered, signaling)
114+
const _CMP_NGT_US: i32 = 0x0a;
115+
/// False (ordered, non-signaling)
116+
const _CMP_FALSE_OQ: i32 = 0x0b;
117+
/// Not-equal (ordered, non-signaling)
118+
const _CMP_NEQ_OQ: i32 = 0x0c;
119+
/// Greater-than-or-equal (ordered, signaling)
120+
const _CMP_GE_OS: i32 = 0x0d;
121+
/// Greater-than (ordered, signaling)
122+
const _CMP_GT_OS: i32 = 0x0e;
123+
/// True (unordered, non-signaling)
124+
const _CMP_TRUE_UQ: i32 = 0x0f;
125+
/// Equal (ordered, signaling)
126+
const _CMP_EQ_OS: i32 = 0x10;
127+
/// Less-than (ordered, non-signaling)
128+
const _CMP_LT_OQ: i32 = 0x11;
129+
/// Less-than-or-equal (ordered, non-signaling)
130+
const _CMP_LE_OQ: i32 = 0x12;
131+
/// Unordered (signaling)
132+
const _CMP_UNORD_S: i32 = 0x13;
133+
/// Not-equal (unordered, signaling)
134+
const _CMP_NEQ_US: i32 = 0x14;
135+
/// Not-less-than (unordered, non-signaling)
136+
const _CMP_NLT_UQ: i32 = 0x15;
137+
/// Not-less-than-or-equal (unordered, non-signaling)
138+
const _CMP_NLE_UQ: i32 = 0x16;
139+
/// Ordered (signaling)
140+
const _CMP_ORD_S: i32 = 0x17;
141+
/// Equal (unordered, signaling)
142+
const _CMP_EQ_US: i32 = 0x18;
143+
/// Not-greater-than-or-equal (unordered, non-signaling)
144+
const _CMP_NGE_UQ: i32 = 0x19;
145+
/// Not-greater-than (unordered, non-signaling)
146+
const _CMP_NGT_UQ: i32 = 0x1a;
147+
/// False (ordered, signaling)
148+
const _CMP_FALSE_OS: i32 = 0x1b;
149+
/// Not-equal (ordered, signaling)
150+
const _CMP_NEQ_OS: i32 = 0x1c;
151+
/// Greater-than-or-equal (ordered, non-signaling)
152+
const _CMP_GE_OQ: i32 = 0x1d;
153+
/// Greater-than (ordered, non-signaling)
154+
const _CMP_GT_OQ: i32 = 0x1e;
155+
/// True (unordered, signaling)
156+
const _CMP_TRUE_US: i32 = 0x1f;
157+
81158
simd_pair_for_each_lane(fx, x, y, ret, &|fx, lane_ty, res_lane_ty, x_lane, y_lane| {
82159
let res_lane = match lane_ty.kind() {
83160
ty::Float(_) => fx.bcx.ins().fcmp(flt_cc, x_lane, y_lane),

0 commit comments

Comments
 (0)