@@ -558,7 +558,12 @@ fn search(pos: &Pos, alpha: i32, beta: i32, depth: i32, _ply: i32) -> i32 {
558
558
assert_ne ! ( bm, MOVE_NONE ) ;
559
559
assert ! ( bs >= -EVAL_INF && bs <= EVAL_INF ) ;
560
560
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
+ }
562
567
}
563
568
564
569
/// Evaluation function: give different scores to different patterns after a fixed depth.
@@ -570,15 +575,11 @@ fn eval(pos: &Pos, _ply: i32) -> i32 {
570
575
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
571
576
{
572
577
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) } {
580
579
return -4096 ;
581
580
}
581
+ } else if check_patternlive4 ( pos, def) {
582
+ return -4096 ;
582
583
}
583
584
}
584
585
@@ -593,15 +594,11 @@ fn eval(pos: &Pos, _ply: i32) -> i32 {
593
594
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
594
595
{
595
596
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) } {
603
598
return 2560 ;
604
599
}
600
+ } else if check_patternlive4 ( pos, atk) {
601
+ return 2560 ;
605
602
}
606
603
}
607
604
@@ -616,15 +613,11 @@ fn eval(pos: &Pos, _ply: i32) -> i32 {
616
613
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
617
614
{
618
615
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 } {
626
617
return 2560 ;
627
618
}
619
+ } else if check_patterndead4 ( pos, atk) > 0 {
620
+ return 2560 ;
628
621
}
629
622
}
630
623
@@ -909,9 +902,7 @@ fn pos_is_winner_avx512(pos: &Pos) -> bool {
909
902
0b00_10_10_10_10_11_10_10_10_10_11_11_11_11_11_10 ] ;
910
903
let mut count_match: i32 = 0 ;
911
904
912
- for dir in 0 ..2 {
913
- // direction 0 and 1
914
- let mut board0 = board0org[ dir] ;
905
+ for mut board0 in board0org {
915
906
let boardf = _mm512_and_si512 ( answer, board0) ;
916
907
let temp_mask = _mm512_mask_cmpeq_epi16_mask ( answer_mask[ 0 ] , answer, boardf) ;
917
908
count_match += _popcnt32 ( temp_mask as i32 ) ;
0 commit comments