Closed
Description
The following code does not print what I would expect:
#![feature(portable_simd)]
use std::simd::*;
fn main() {
let a = i32x4::splat(10);
let b = i32x4::from_array([1, 2, 12, -4]);
println!("{:?} {:?}", a.max(b), a.min(b));
}
I expected element-wise max/min, but I got:
[10, 10, 10, 10] [1, 2, 12, -4]
The funny thing is that portable-simd does not even define max
/min
on its integer SIMD types (only on the float ones). What happens is that it falls back to Ord::max
, and it looks like vectors implement Ord
by comparing them as arrays, which probably uses lexicographic comparison.
However this means integer and float vectors max
/min
methods behave very differently, so this is probably not intended?
Metadata
Metadata
Assignees
Labels
No labels