@@ -3,7 +3,7 @@ use core::mem;
33use alloc:: vec:: Vec ;
44
55use ir:: {
6- node:: { FcmpKind , FunctionRef , IcmpKind , MemSize , NodeKind , Type } ,
6+ node:: { BitwiseF64 , FcmpKind , FunctionRef , IcmpKind , MemSize , NodeKind , Type } ,
77 valgraph:: { DepValue , Node } ,
88} ;
99use smallvec:: { SmallVec , smallvec} ;
@@ -191,6 +191,7 @@ impl MachineLower for X64Machine {
191191 // `setcc` output register.
192192 emit_setcc_sequence ( ctx, output, |ctx| select_icmp ( ctx, node, kind) ) ;
193193 }
194+ & NodeKind :: Fconst64 ( val) => select_fconst64 ( ctx, node, val) ?,
194195 NodeKind :: Fadd => emit_fpu_rr ( ctx, node, SseFpuBinOp :: Add ) ,
195196 NodeKind :: Fsub => emit_fpu_rr ( ctx, node, SseFpuBinOp :: Sub ) ,
196197 NodeKind :: Fmul => emit_fpu_rr ( ctx, node, SseFpuBinOp :: Mul ) ,
@@ -401,6 +402,22 @@ fn select_icmp(ctx: &mut IselContext<'_, '_, X64Machine>, node: Node, kind: Icmp
401402 cond_code_for_icmp ( kind)
402403}
403404
405+ fn select_fconst64 (
406+ ctx : & mut IselContext < ' _ , ' _ , X64Machine > ,
407+ node : Node ,
408+ val : BitwiseF64 ,
409+ ) -> Result < ( ) , MachineIselError > {
410+ let [ output] = ctx. node_outputs_exact ( node) ;
411+ let output = ctx. get_value_vreg ( output) ;
412+
413+ if val. bits ( ) == 0 {
414+ ctx. emit_instr ( X64Instr :: SseMovRZ , & [ DefOperand :: any_reg ( output) ] , & [ ] ) ;
415+ return Ok ( ( ) ) ;
416+ }
417+
418+ Err ( MachineIselError )
419+ }
420+
404421fn select_direct_fcmp ( ctx : & mut IselContext < ' _ , ' _ , X64Machine > , node : Node , kind : FcmpKind ) {
405422 let [ output] = ctx. node_outputs_exact ( node) ;
406423 let [ op1, op2] = ctx. node_inputs_exact ( node) ;
0 commit comments