@@ -170,15 +170,16 @@ let phys_reg ty n =
170170
171171let rax = phys_reg Int 0
172172let rdx = phys_reg Int 4
173+ let rcx = phys_reg Int 5
173174let r10 = phys_reg Int 10
174175let r11 = phys_reg Int 11
175176let rbp = phys_reg Int 12
176177
177178(* CSE needs to know that all versions of xmm15 are destroyed. *)
178- let destroy_xmm15 () =
179+ let destroy_xmm n =
179180 if Language_extension. is_enabled SIMD
180- then [| phys_reg Float 115 ; phys_reg Vec128 115 |]
181- else [| phys_reg Float 115 |]
181+ then [| phys_reg Float ( 100 + n) ; phys_reg Vec128 ( 100 + n) |]
182+ else [| phys_reg Float ( 100 + n) |]
182183
183184let destroyed_by_plt_stub =
184185 if not X86_proc. use_plt then [| |] else [| r10; r11 |]
@@ -399,6 +400,21 @@ let destroyed_at_pushtrap =
399400let has_pushtrap traps =
400401 List. exists (function Cmm. Push _ -> true | Pop _ -> false ) traps
401402
403+ let destroyed_by_simd_op op =
404+ match Simd_proc. register_behavior op with
405+ | R_RM_rax_rdx_to_xmm0
406+ | R_RM_to_xmm0 -> destroy_xmm 0
407+ | R_RM_rax_rdx_to_rcx
408+ | R_RM_to_rcx -> [| rcx |]
409+ | R_to_fst
410+ | R_to_R
411+ | R_to_RM
412+ | RM_to_R
413+ | R_R_to_fst
414+ | R_RM_to_fst
415+ | R_RM_to_R
416+ | R_RM_xmm0_to_fst -> [||]
417+
402418(* note: keep this function in sync with `destroyed_at_{basic,terminator}` below. *)
403419let destroyed_at_oper = function
404420 Iop (Icall_ind | Icall_imm _ ) ->
@@ -410,7 +426,7 @@ let destroyed_at_oper = function
410426 | Iop (Iintop (Idiv | Imod )) | Iop (Iintop_imm ((Idiv | Imod ), _))
411427 -> [| rax; rdx |]
412428 | Iop (Istore (Single , _, _))
413- -> destroy_xmm15 ()
429+ -> destroy_xmm 15
414430 | Iop (Ialloc _ | Ipoll _ ) -> destroyed_at_alloc_or_poll
415431 | Iop (Iintop (Imulh _ | Icomp _) | Iintop_imm ((Icomp _), _))
416432 -> [| rax |]
@@ -420,9 +436,10 @@ let destroyed_at_oper = function
420436 | Ireturn traps when has_pushtrap traps -> assert false
421437 | Iop (Ispecific (Irdtsc | Irdpmc )) -> [| rax; rdx |]
422438 | Iop (Ispecific (Ilfence | Isfence | Imfence )) -> [||]
439+ | Iop (Ispecific(Isimd op )) -> destroyed_by_simd_op op
423440 | Iop (Ispecific (Isextend32 | Izextend32 | Ilea _
424441 | Istore_int (_, _, _) | Ioffset_loc (_, _)
425- | Ipause | Iprefetch _ | Isimd _
442+ | Ipause | Iprefetch _
426443 | Ifloatarithmem (_, _) | Ifloatsqrtf _ | Ibswap _))
427444 | Iop (Iintop (Iadd | Isub | Imul | Iand | Ior | Ixor | Ilsl | Ilsr | Iasr
428445 | Ipopcnt | Iclz _ | Ictz _ ))
@@ -465,14 +482,15 @@ let destroyed_at_basic (basic : Cfg_intf.S.basic) =
465482 | Op (Intop (Idiv | Imod )) | Op (Intop_imm ((Idiv | Imod ), _ )) ->
466483 [| rax; rdx |]
467484 | Op (Store(Single, _ , _ )) ->
468- destroy_xmm15 ()
485+ destroy_xmm 15
469486 | Op (Intop (Imulh _ | Icomp _ ) | Intop_imm ((Icomp _ ), _ )) ->
470487 [| rax |]
471488 | Op (Specific (Irdtsc | Irdpmc )) ->
472489 [| rax; rdx |]
473490 | Op Poll -> destroyed_at_alloc_or_poll
474491 | Op (Alloc _ ) ->
475492 destroyed_at_alloc_or_poll
493+ | Op (Specific (Isimd op )) -> destroyed_by_simd_op op
476494 | Op (Move | Spill | Reload
477495 | Const_int _ | Const_float _ | Const_symbol _ | Const_vec128 _
478496 | Stackoffset _
@@ -497,7 +515,7 @@ let destroyed_at_basic (basic : Cfg_intf.S.basic) =
497515 | Begin_region
498516 | End_region
499517 | Specific (Ilea _ | Istore_int _ | Ioffset_loc _
500- | Ifloatarithmem _ | Ifloatsqrtf _ | Ibswap _ | Isimd _
518+ | Ifloatarithmem _ | Ifloatsqrtf _ | Ibswap _
501519 | Isextend32 | Izextend32 | Ipause
502520 | Iprefetch _ | Ilfence | Isfence | Imfence )
503521 | Name_for_debugger _ | Dls_get )
@@ -596,6 +614,20 @@ let max_register_pressure =
596614 consumes ~int: 1 ~float: 0
597615 | Istore (Single , _ , _ ) | Icompf _ ->
598616 consumes ~int: 0 ~float: 1
617+ | Ispecific (Isimd op ) ->
618+ (match Simd_proc. register_behavior op with
619+ | R_RM_rax_rdx_to_xmm0
620+ | R_RM_to_xmm0 -> consumes ~int: 0 ~float: 1
621+ | R_RM_rax_rdx_to_rcx
622+ | R_RM_to_rcx -> consumes ~int: 1 ~float: 0
623+ | R_to_fst
624+ | R_to_R
625+ | R_to_RM
626+ | RM_to_R
627+ | R_R_to_fst
628+ | R_RM_to_fst
629+ | R_RM_to_R
630+ | R_RM_xmm0_to_fst -> consumes ~int: 0 ~float: 0 )
599631 | Iintop (Iadd | Isub | Imul | Imulh _ | Iand | Ior | Ixor | Ilsl | Ilsr | Iasr
600632 | Ipopcnt | Iclz _| Ictz _)
601633 | Iintop_imm ((Iadd | Isub | Imul | Imulh _ | Iand | Ior | Ixor | Ilsl | Ilsr
@@ -613,7 +645,7 @@ let max_register_pressure =
613645 | Istackoffset _ | Iload _
614646 | Ispecific (Ilea _ | Isextend32 | Izextend32 | Iprefetch _ | Ipause
615647 | Irdtsc | Irdpmc | Istore_int (_, _, _)
616- | Ilfence | Isfence | Imfence | Isimd _
648+ | Ilfence | Isfence | Imfence
617649 | Ioffset_loc (_, _) | Ifloatarithmem (_, _) | Ifloatsqrtf _
618650 | Ibswap _)
619651 | Iname_for_debugger _ | Iprobe _ | Iprobe_is_enabled _ | Iopaque
0 commit comments