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:
Kovid Goyal
2024-02-11 06:41:41 +05:30
parent a32e1aafa6
commit b5edd9ad57

View File

@@ -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")