mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 15:04:50 +02:00
Dont precalculate mask in loop body
No need since we dont shift. Avoids the extra mask instructions for the not found case.
This commit is contained in:
@@ -1368,7 +1368,7 @@ func (s *State) index_func(f *Function, test_bytes func(bytes_to_test, test_ans
|
||||
f.MaskForCountDestructive(test_ans, mask)
|
||||
f.Comment("We need to shift out the possible extra bytes at the start of the string caused by the unaligned read")
|
||||
f.ShiftMaskRightDestructive(mask, extra_bytes)
|
||||
f.JumpIfNonZero(mask, "byte_found")
|
||||
f.JumpIfNonZero(mask, "byte_found_in_mask")
|
||||
}()
|
||||
|
||||
f.Comment("Now loop over aligned blocks")
|
||||
@@ -1383,12 +1383,13 @@ func (s *State) index_func(f *Function, test_bytes func(bytes_to_test, test_ans
|
||||
f.Label("loop_body")
|
||||
f.LoadPointerAligned(pos, bytes_to_test)
|
||||
test_bytes(bytes_to_test, test_ans)
|
||||
f.MaskForCountDestructive(test_ans, mask)
|
||||
f.JumpIfNonZero(mask, "byte_found")
|
||||
f.JumpIfNonZero(test_ans, "byte_found_in_vec")
|
||||
f.JumpTo("loop_start")
|
||||
|
||||
f.Label("byte_found_in_vec")
|
||||
f.MaskForCountDestructive(test_ans, mask)
|
||||
f.Comment("Get the result from", mask, "and return it")
|
||||
f.Label("byte_found")
|
||||
f.Label("byte_found_in_mask")
|
||||
f.CountLeadingZeroBytesInMask(mask, mask)
|
||||
f.AddToSelf(mask, pos)
|
||||
f.JumpIfLessThan(mask, limit, "result_in_bounds")
|
||||
|
||||
Reference in New Issue
Block a user