@@ -558,7 +558,12 @@ fn search(pos: &Pos, alpha: i32, beta: i32, depth: i32, _ply: i32) -> i32 {
558558 assert_ne ! ( bm, MOVE_NONE ) ;
559559 assert ! ( bs >= -EVAL_INF && bs <= EVAL_INF ) ;
560560
561- if _ply == 0 { bm } else { bs } //best move at the root node, best score elsewhere
561+ // best move at the root node, best score elsewhere
562+ if _ply == 0 {
563+ bm
564+ } else {
565+ bs
566+ }
562567}
563568
564569/// Evaluation function: give different scores to different patterns after a fixed depth.
@@ -570,15 +575,11 @@ fn eval(pos: &Pos, _ply: i32) -> i32 {
570575 #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
571576 {
572577 if check_x86_avx512_features ( ) {
573- unsafe {
574- if check_patternlive4_avx512 ( pos, def) {
575- return -4096 ;
576- }
577- }
578- } else {
579- if check_patternlive4 ( pos, def) {
578+ if unsafe { check_patternlive4_avx512 ( pos, def) } {
580579 return -4096 ;
581580 }
581+ } else if check_patternlive4 ( pos, def) {
582+ return -4096 ;
582583 }
583584 }
584585
@@ -593,15 +594,11 @@ fn eval(pos: &Pos, _ply: i32) -> i32 {
593594 #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
594595 {
595596 if check_x86_avx512_features ( ) {
596- unsafe {
597- if check_patternlive4_avx512 ( pos, atk) {
598- return 2560 ;
599- }
600- }
601- } else {
602- if check_patternlive4 ( pos, atk) {
597+ if unsafe { check_patternlive4_avx512 ( pos, atk) } {
603598 return 2560 ;
604599 }
600+ } else if check_patternlive4 ( pos, atk) {
601+ return 2560 ;
605602 }
606603 }
607604
@@ -616,15 +613,11 @@ fn eval(pos: &Pos, _ply: i32) -> i32 {
616613 #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
617614 {
618615 if check_x86_avx512_features ( ) {
619- unsafe {
620- if check_patterndead4_avx512 ( pos, atk) > 0 {
621- return 2560 ;
622- }
623- }
624- } else {
625- if check_patterndead4 ( pos, atk) > 0 {
616+ if unsafe { check_patterndead4_avx512 ( pos, atk) > 0 } {
626617 return 2560 ;
627618 }
619+ } else if check_patterndead4 ( pos, atk) > 0 {
620+ return 2560 ;
628621 }
629622 }
630623
@@ -909,9 +902,7 @@ fn pos_is_winner_avx512(pos: &Pos) -> bool {
909902 0b00_10_10_10_10_11_10_10_10_10_11_11_11_11_11_10 ] ;
910903 let mut count_match: i32 = 0 ;
911904
912- for dir in 0 ..2 {
913- // direction 0 and 1
914- let mut board0 = board0org[ dir] ;
905+ for mut board0 in board0org {
915906 let boardf = _mm512_and_si512 ( answer, board0) ;
916907 let temp_mask = _mm512_mask_cmpeq_epi16_mask ( answer_mask[ 0 ] , answer, boardf) ;
917908 count_match += _popcnt32 ( temp_mask as i32 ) ;
0 commit comments