4 #![feature(const_eval_select)]
5 use std::intrinsics::const_eval_select;
6 use std::arch::x86_64::*;
7 use std::mem::transmute;
9 const fn eq_ct(x: [i32; 4], y: [i32; 4]) -> bool {
10 x[0] == y[0] && x[1] == y[1] && x[2] == y[2] && x[3] == y[3]
13 fn eq_rt(x: [i32; 4], y: [i32; 4]) -> bool {
15 let x = _mm_loadu_si128(&x as *const _ as *const _);
16 let y = _mm_loadu_si128(&y as *const _ as *const _);
17 let r = _mm_cmpeq_epi32(x, y);
18 let r = _mm_movemask_ps(transmute(r) );
23 const fn eq(x: [i32; 4], y: [i32; 4]) -> bool {
25 const_eval_select((x, y), eq_ct, eq_rt)
30 const X: bool = eq([0, 1, 2, 3], [0, 1, 2, 3]);
32 let x = eq([0, 1, 2, 3], [0, 1, 2, 3]);
35 const Y: bool = eq([0, 1, 2, 3], [0, 1, 3, 2]);
37 let y = eq([0, 1, 2, 3], [0, 1, 3, 2]);