From 3f152273d3629689ed26a8120f631537d6452b2d Mon Sep 17 00:00:00 2001 From: Johnnie Birch Date: Mon, 6 Jun 2022 14:47:44 -0700 Subject: [PATCH] X64: Port fpromote to ISLE (#4230) --- cranelift/codegen/src/isa/x64/inst.isle | 7 +++++++ cranelift/codegen/src/isa/x64/lower.isle | 4 ++++ cranelift/codegen/src/isa/x64/lower.rs | 6 +----- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cranelift/codegen/src/isa/x64/inst.isle b/cranelift/codegen/src/isa/x64/inst.isle index 8a403c5244..4480fce524 100644 --- a/cranelift/codegen/src/isa/x64/inst.isle +++ b/cranelift/codegen/src/isa/x64/inst.isle @@ -2817,6 +2817,13 @@ (_ Unit (emit (MInst.XmmUnaryRmR (SseOpcode.Sqrtpd) x dst)))) dst)) +;; Helper for creating `cvtss2sd` instructions. +(decl x64_cvtss2sd (Xmm) Xmm) +(rule (x64_cvtss2sd x) + (let ((dst WritableXmm (temp_writable_xmm)) + (_ Unit (emit (MInst.XmmUnaryRmR (SseOpcode.Cvtss2sd) x dst)))) + dst)) + ;; Helpers for creating `pcmpeq*` instructions. (decl x64_pcmpeq (Type Xmm XmmMem) Xmm) (rule (x64_pcmpeq $I8X16 x y) (x64_pcmpeqb x y)) diff --git a/cranelift/codegen/src/isa/x64/lower.isle b/cranelift/codegen/src/isa/x64/lower.isle index 13419cade9..bbdd1fd555 100644 --- a/cranelift/codegen/src/isa/x64/lower.isle +++ b/cranelift/codegen/src/isa/x64/lower.isle @@ -2318,6 +2318,10 @@ (rule (lower (has_type $F64X2 (sqrt x))) (x64_sqrtpd x)) +;; Rules for `fpromote` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(rule (lower (has_type $F64 (fpromote x))) + (x64_cvtss2sd x)) + ;; Rules for `fmin` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule (lower (has_type $F32 (fmin x y))) diff --git a/cranelift/codegen/src/isa/x64/lower.rs b/cranelift/codegen/src/isa/x64/lower.rs index 0b049942d9..0123a4f9f0 100644 --- a/cranelift/codegen/src/isa/x64/lower.rs +++ b/cranelift/codegen/src/isa/x64/lower.rs @@ -1041,11 +1041,7 @@ fn lower_insn_to_regs>( } Opcode::Fpromote => { - // We can't guarantee the RHS (if a load) is 128-bit aligned, so we - // must avoid merging a load here. - let src = RegMem::reg(put_input_in_reg(ctx, inputs[0])); - let dst = get_output_reg(ctx, outputs[0]).only_reg().unwrap(); - ctx.emit(Inst::xmm_unary_rm_r(SseOpcode::Cvtss2sd, src, dst)); + implemented_in_isle(ctx); } Opcode::FvpromoteLow => {