https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127773

--- Comment #12 from Michiel van Slobbe <michiel.van.slobbe at gmail dot com> 
---
Thanks for the patch, Hongtao, and for checking it against simdutf.

I looked a bit further and I think I found one case that the patch doesn't
handle yet: validate_utf8_with_counts, when the input is at least 129 bytes
long and the error is roughly in bytes 63–126. On releases/gcc-16 with your
patch at -O2, that call still takes about 220 ns and 2 SSE/AVX assists, the
same as without the patch. With 128 bytes it drops to about 37 ns and 0
assists. The repro is attachment 65822. It doesn't show up at -O3, where the
code is laid out differently. It also doesn't show up with current trunk, which
compiles simdutf's scalar tail routines without SSE.

The cause seems to be a 128-bit value that stays live in an XMM register across
the call. With IPA-RA that register counts as preserved, so the vzeroupper goes
after the call, even though it would be safe before it. Attachment 65823 is a
smaller testcase that doesn't need simdutf.

Reply via email to