Skip to content

Commit 16854e7

Browse files
authored
Merge pull request #3115 from bjorn3/fminmax_pseudo_scalar
Implement fmin_pseudo and fmax_pseudo for scalars
2 parents 4ccdcb1 + b79e598 commit 16854e7

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed

cranelift/codegen/src/isa/x64/lower.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4413,6 +4413,10 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
44134413
let ty = ty.unwrap();
44144414
ctx.emit(Inst::gen_move(dst, rhs, ty));
44154415
let sse_opcode = match (ty, op) {
4416+
(types::F32, Opcode::FminPseudo) => SseOpcode::Minss,
4417+
(types::F32, Opcode::FmaxPseudo) => SseOpcode::Maxss,
4418+
(types::F64, Opcode::FminPseudo) => SseOpcode::Minsd,
4419+
(types::F64, Opcode::FmaxPseudo) => SseOpcode::Maxsd,
44164420
(types::F32X4, Opcode::FminPseudo) => SseOpcode::Minps,
44174421
(types::F32X4, Opcode::FmaxPseudo) => SseOpcode::Maxps,
44184422
(types::F64X2, Opcode::FminPseudo) => SseOpcode::Minpd,
-5.38 KB
Binary file not shown.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
test run
2+
; target s390x TODO: Not yet implemented on s390x
3+
set enable_simd
4+
target aarch64
5+
target x86_64 machinst skylake
6+
7+
function %fmin_pseudo_f32x4(f32x4, f32x4) -> f32x4 {
8+
block0(v0:f32x4, v1:f32x4):
9+
v2 = fmin_pseudo v0, v1
10+
return v2
11+
}
12+
; run: %fmin_pseudo_f32x4([0x1.0 NaN 0x0.1 -0x0.0], [0x2.0 0x2.0 NaN 0x0.0]) == [0x1.0 NaN 0x0.1 -0x0.0]
13+
14+
function %fmax_pseudo_f32x4(f32x4, f32x4) -> f32x4 {
15+
block0(v0:f32x4, v1:f32x4):
16+
v2 = fmax_pseudo v0, v1
17+
return v2
18+
}
19+
; run: %fmax_pseudo_f32x4([0x1.0 NaN 0x0.1 -0x0.0], [0x2.0 0x2.0 NaN 0x0.0]) == [0x2.0 NaN 0x0.1 -0x0.0]
20+
21+
function %fmin_pseudo_f64x2(f64x2, f64x2) -> f64x2 {
22+
block0(v0:f64x2, v1:f64x2):
23+
v2 = fmin_pseudo v0, v1
24+
return v2
25+
}
26+
; run: %fmin_pseudo_f64x2([0x1.0 NaN], [0x2.0 0x2.0]) == [0x1.0 NaN]
27+
; run: %fmin_pseudo_f64x2([0x0.1 -0x0.0], [NaN 0x0.0]) == [0x0.1 -0x0.0]
28+
29+
function %fmax_pseudo_f64x2(f64x2, f64x2) -> f64x2 {
30+
block0(v0:f64x2, v1:f64x2):
31+
v2 = fmax_pseudo v0, v1
32+
return v2
33+
}
34+
; run: %fmax_pseudo_f64x2([0x1.0 NaN], [0x2.0 0x2.0]) == [0x2.0 NaN]
35+
; run: %fmax_pseudo_f64x2([0x0.1 -0x0.0], [NaN 0x0.0]) == [0x0.1 -0x0.0]
36+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
test run
2+
; target s390x TODO: Not yet implemented on s390x
3+
; target aarch64 TODO: Not yet implemented on aarch64
4+
set enable_simd
5+
target x86_64 machinst skylake
6+
7+
function %fmin_pseudo_f32(f32, f32) -> f32 {
8+
block0(v0:f32, v1:f32):
9+
v2 = fmin_pseudo v0, v1
10+
return v2
11+
}
12+
; run: %fmin_pseudo_f32(0x1.0, 0x2.0) == 0x1.0
13+
; run: %fmin_pseudo_f32(NaN, 0x2.0) == NaN
14+
; run: %fmin_pseudo_f32(0x0.1, NaN) == 0x0.1
15+
; run: %fmin_pseudo_f32(0x0.0, -0x0.0) == 0x0.0
16+
; run: %fmin_pseudo_f32(-0x0.0, 0x0.0) == -0x0.0
17+
18+
function %fmax_pseudo_f32(f32, f32) -> f32 {
19+
block0(v0:f32, v1:f32):
20+
v2 = fmax_pseudo v0, v1
21+
return v2
22+
}
23+
; run: %fmax_pseudo_f32(0x1.0, 0x2.0) == 0x2.0
24+
; run: %fmax_pseudo_f32(NaN, 0x2.0) == NaN
25+
; run: %fmax_pseudo_f32(0x0.1, NaN) == 0x0.1
26+
; run: %fmax_pseudo_f32(0x0.0, 0x0.0) == 0x0.0
27+
; run: %fmax_pseudo_f32(-0x0.0, 0x0.0) == -0x0.0
28+
29+
function %fmin_pseudo_f64(f64, f64) -> f64 {
30+
block0(v0:f64, v1:f64):
31+
v2 = fmin_pseudo v0, v1
32+
return v2
33+
}
34+
; run: %fmin_pseudo_f64(0x1.0, 0x2.0) == 0x1.0
35+
; run: %fmin_pseudo_f64(NaN, 0x2.0) == NaN
36+
; run: %fmin_pseudo_f64(0x0.1, NaN) == 0x0.1
37+
; run: %fmin_pseudo_f64(0x0.0, -0x0.0) == 0x0.0
38+
; run: %fmin_pseudo_f64(-0x0.0, 0x0.0) == -0x0.0
39+
40+
function %fmax_pseudo_f64(f64, f64) -> f64 {
41+
block0(v0:f64, v1:f64):
42+
v2 = fmax_pseudo v0, v1
43+
return v2
44+
}
45+
; run: %fmax_pseudo_f64(0x1.0, 0x2.0) == 0x2.0
46+
; run: %fmax_pseudo_f64(NaN, 0x2.0) == NaN
47+
; run: %fmax_pseudo_f64(0x0.1, NaN) == 0x0.1
48+
; run: %fmax_pseudo_f64(0x0.0, 0x0.0) == 0x0.0
49+
; run: %fmax_pseudo_f64(-0x0.0, 0x0.0) == -0x0.0
50+

0 commit comments

Comments
 (0)