about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-03-27 04:46:32 +0000
committerbors <bors@rust-lang.org>2018-03-27 04:46:32 +0000
commit31ae4f9fde9b23100c26e5642030128a7e1444ef (patch)
treeb63dae1cd9281a7e71732837b10dbad0f94ac929 /src/test/codegen
parent989b25718bbfdcc5615cdc5880e5573eb8b9688f (diff)
parent56aaf344c444943f3c9cefe9d88ed27b43f0a731 (diff)
downloadrust-31ae4f9fde9b23100c26e5642030128a7e1444ef.tar.gz
rust-31ae4f9fde9b23100c26e5642030128a7e1444ef.zip
Auto merge of #49249 - gnzlbg:simd_minmax, r=alexcrichton
implement minmax intrinsics

This adds the `simd_{fmin,fmax}` intrinsics, which do a vertical (lane-wise) `min`/`max` for floating point vectors that's equivalent to Rust's `min`/`max` for `f32`/`f64`.

It might make sense to make `{f32,f64}::{min,max}` use the `minnum` and `minmax` intrinsics as well.

---

~~HELP: I need some help with these. Either I should go to sleep or there must be something that I must be missing. AFAICT I am calling the `maxnum` builder correctly, yet rustc/LLVM seem to insert a call to `llvm.minnum` there instead...~~ EDIT: Rust's LLVM version is too old :/
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/simd-intrinsic-float-minmax.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/test/codegen/simd-intrinsic-float-minmax.rs b/src/test/codegen/simd-intrinsic-float-minmax.rs
new file mode 100644
index 00000000000..6663b841808
--- /dev/null
+++ b/src/test/codegen/simd-intrinsic-float-minmax.rs
@@ -0,0 +1,43 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-emscripten
+// min-llvm-version 6.0
+
+// compile-flags: -C no-prepopulate-passes
+
+#![crate_type = "lib"]
+
+#![feature(repr_simd, platform_intrinsics)]
+#[allow(non_camel_case_types)]
+
+#[repr(simd)]
+#[derive(Copy, Clone, PartialEq, Debug)]
+pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
+
+extern "platform-intrinsic" {
+    fn simd_fmin<T>(x: T, y: T) -> T;
+    fn simd_fmax<T>(x: T, y: T) -> T;
+}
+
+// CHECK-LABEL: @fmin
+#[no_mangle]
+pub unsafe fn fmin(a: f32x4, b: f32x4) -> f32x4 {
+    // CHECK: call <4 x float> @llvm.minnum.v4f32
+    simd_fmin(a, b)
+}
+
+// FIXME(49261)
+// // C_HECK-LABEL: @fmax
+// #[no_mangle]
+// pub unsafe fn fmax(a: f32x4, b: f32x4) -> f32x4 {
+// // C_HECK: call <4 x float> @llvm.maxnum.v4f32
+//     simd_fmax(a, b)
+// }