]> git.lizzy.rs Git - rust.git/blob - tests/assembly/x86_64-floating-point-clamp.rs
Rollup merge of #106144 - tgross35:patch-1, r=Mark-Simulacrum
[rust.git] / tests / assembly / x86_64-floating-point-clamp.rs
1 // Floating-point clamp is designed to be implementable as max+min,
2 // so check to make sure that's what it's actually emitting.
3
4 // assembly-output: emit-asm
5 // compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
6 // only-x86_64
7
8 // CHECK-LABEL: clamp_demo:
9 #[no_mangle]
10 pub fn clamp_demo(a: f32, x: f32, y: f32) -> f32 {
11     // CHECK: maxss
12     // CHECK: minss
13     a.clamp(x, y)
14 }
15
16 // CHECK-LABEL: clamp12_demo:
17 #[no_mangle]
18 pub fn clamp12_demo(a: f32) -> f32 {
19     // CHECK: movss   xmm1
20     // CHECK-NEXT: maxss   xmm1, xmm0
21     // CHECK-NEXT: movss   xmm0
22     // CHECK-NEXT: minss   xmm0, xmm1
23     // CHECK: ret
24     a.clamp(1.0, 2.0)
25 }