Skip to content

Commit

Permalink
Use special rule for BlockedByKing bench 5512000
Browse files Browse the repository at this point in the history
  • Loading branch information
CounterPly committed Jul 5, 2018
1 parent b260036 commit c4007bc
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 37 deletions.
34 changes: 25 additions & 9 deletions arm/Evaluate.arm
Original file line number Diff line number Diff line change
Expand Up @@ -830,15 +830,19 @@ macro ShelterStorm Us
if Us = White
Them = Black
Up = DELTA_N
Down = DELTA_S
Pieces_Pawn = x19
Pieces_Us = x28
Pieces_Them = x29
BlockRanks = Rank1BB or Rank2BB
else
Them = White
Up = DELTA_S
Down = DELTA_N
Pieces_Pawn = x19
Pieces_Us = x29
Pieces_Them = x28
BlockRanks = Rank8BB or Rank7BB
end if

stp x26, x27, [sp, -16]!
Expand Down Expand Up @@ -869,6 +873,23 @@ macro ShelterStorm Us
cmp x2, 0
csneg w0, w0, w0, eq
; w0 = saftey

;if ((shift<Down>(theirPawns) & (FileABB | FileHBB) & BlockRanks) & ksq)
mov x11, x10
ShiftBB Down, x11, x11
mov x22, x11 ; r12 = shift<Down>(theirPawns)
mov x11, FileABB or FileHBB
and x22, x22, x11 ; r12 & (FileABB|FileHBB)
mov x11, BlockRanks
and x22, x22, x11 ; r12 & BlockRanks
mov x11, Pieces_Us
ldr x2, [x20, Pos.typeBB + 8*King]
and x11, x11, x2
and x22, x22, x11 ; r12 & ksq
cmp x22, 0
beq @f
add w0, w0, 374
@@:
if Us = Black
eor w23, w23, 7
end if
Expand Down Expand Up @@ -932,18 +953,12 @@ macro ShelterStorm Us
add w26, w26, 1
; esi = rkUs+1

_lea x11, StormDanger_BlockedByKing
_lea x8, ShelterStrengthArray - 4*1
add x8, x8, x2
add x11, x11, x2
cmp w1, w22
add w22, w22, 1
bne @1f
_lea x8, ShelterStrengthArray - 4*1
add x8, x8, x2
cmp w27, w23
beq @2f
; Rank Comparisons
@1:
_lea x8, ShelterStrengthArray - 4*1
add x8, x8, x2
_lea x11, StormDanger_NoFriendlyPawn
add x11, x11, x2
cmp w26, 1
Expand All @@ -959,6 +974,7 @@ macro ShelterStorm Us
add w0, w0, w4
ldr w4, [x11, x27, lsl 2]
sub w0, w0, w4
add x22, x22, 1

end repeat

Expand Down
9 changes: 0 additions & 9 deletions arm/Evaluate_Init.arm
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,6 @@ dd 0, 0, 101, 16, 1, 0,0,0
dd 0, 0, 88, 27, 2, 0,0,0
dd 0, 0, 19, 23, 1, 0,0,0

dd 0, -290, -274, 57, 41 , 0,0,0
dd 0, 60, 144, 39, 13 , 0,0,0
dd 0, 65, 141, 41, 34 , 0,0,0
dd 0, 53, 127, 56, 14 , 0,0,0
dd 0, 53, 127, 56, 14 , 0,0,0
dd 0, 65, 141, 41, 34 , 0,0,0
dd 0, 60, 144, 39, 13 , 0,0,0
dd 0, -290, -274, 57, 41 , 0,0,0

Evaluate_Init.Threat_Minor:
dd (0 shl 16) + (0)
dd (0 shl 16) + (0)
Expand Down
39 changes: 29 additions & 10 deletions x86/Evaluate.asm
Original file line number Diff line number Diff line change
Expand Up @@ -743,13 +743,17 @@ macro ShelterStorm Us
if Us = White
Them = Black
Up = DELTA_N
Down = DELTA_S
PiecesUs equ r14
PiecesThem equ r15
BlockRanks = Rank1BB or Rank2BB
else
Them = White
Up = DELTA_S
Down = DELTA_N
PiecesUs equ r15
PiecesThem equ r14
BlockRanks = Rank8BB or Rank7BB
end if

push rsi rdi r11 r12 r13
Expand All @@ -768,18 +772,35 @@ macro ShelterStorm Us
mov r9, PiecesUs
and r9, r8
; r9 = ourPawns
and ecx, 7
; ecx = file of ksq
and ecx, 7
; ecx = file of ksq
mov r10, PiecesThem
and r10, r8
; r10 = theirPawns
mov rax, qword[FileBB+8*rcx]
mov rax, qword[FileBB+8*rcx]
and rax, r9
cmp rax, 1
sbb eax, eax
and eax, -10
and eax, -10 ; saves instructions and keeps code linear
add eax, 5
; eax = saftey

; if ((shift<Down>(theirPawns) & (FileABB | FileHBB) & BlockRanks) & ksq)
mov r11, r10
ShiftBB Down, r11, r11
mov r12, r11 ; r12 = shift<Down>(theirPawns)
mov r11, FileABB or FileHBB
and r12, r11 ; r12 & (FileABB|FileHBB)
mov r11, BlockRanks
and r12, r11 ; r12 & BlockRanks
mov r11, PiecesUs
and r11, qword [rbp+Pos.typeBB+8*King]
and r12, r11 ; r12 & ksq
test r12, r12
jz @f
add eax, 374

@@:
if Us eq Black
xor r13d, 7
end if
Expand Down Expand Up @@ -844,15 +865,12 @@ macro ShelterStorm Us
add esi, 1
; esi = rkUs+1

lea r11, [StormDanger_BlockedByKing+rdx]
lea r8, [ShelterStrengthArray - 4*1 + rdx]
cmp ecx, r12d
lea r12d, [r12+1]
jne @f
lea r8, [ShelterStrengthArray - 4*1 + rdx]
cmp edi, r13d
je @1f

; Rank Comparisons
@@:
lea r8, [ShelterStrengthArray - 4*1 + rdx]
lea r11, [StormDanger_NoFriendlyPawn + rdx]
cmp esi, 1
je @1f
Expand All @@ -863,6 +881,7 @@ macro ShelterStorm Us
@1:
add eax, dword[r8 + 4*rsi]
sub eax, dword[r11 + 4*rdi]
lea r12d, [r12+1]
end macro

ShelterStormAcc
Expand Down
9 changes: 0 additions & 9 deletions x86/Evaluate_Init.asm
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,6 @@ dd 0, 0 , 101, 16, 1, 0, 0, 0
dd 0, 0 , 88, 27, 2, 0, 0, 0
dd 0, 0 , 19, 23, 1, 0, 0, 0

dd 0, -290, -274, 57, 41, 0, 0, 0
dd 0, 60, 144 , 39, 13, 0, 0, 0
dd 0, 65, 141 , 41, 34, 0, 0, 0
dd 0, 53, 127 , 56, 14, 0, 0, 0
dd 0, 53, 127 , 56, 14, 0, 0, 0
dd 0, 65, 141 , 41, 34, 0, 0, 0
dd 0, 60, 144 , 39, 13, 0, 0, 0
dd 0, -290, -274, 57, 41, 0, 0, 0

.Threat_Minor:
dd (0 shl 16) + (0)
dd (0 shl 16) + (0)
Expand Down

0 comments on commit c4007bc

Please sign in to comment.