https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81481
Bug ID: 81481
Summary: [7/8 Regression] Spills %xmm to stack in glibc strspn
SSE 4.2 variant
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Keywords: missed-optimization, ra
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: rguenth at gcc dot gnu.org
Target Milestone: ---
Target: i?86-*-*
Created attachment 41787
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41787&action=edit
reduced testcase
We're seeing crashes in 32bit programs violating the ABI by not properly
aligning the outgoing stack when calling strspn which eventually dispatches to
__strspn_sse42. This is because GCC 7 and trunk compile this to
.L28:
.cfi_restore_state
movdqu ___m128i_shift_right@GOTOFF(%edi,%ebx), %xmm3
movl %esi, %ebp
andl $-16, %ebp
movl $16, %eax
movaps %xmm3, (%esp)
movdqa 0(%ebp), %xmm0
pshufb (%esp), %xmm0
pcmpistri $58, %xmm0, %xmm0
spilling %xmm3 for no good reason. GCC 4.8 at least did better here and
avoided
spilling (and the crashes). There are other string routines similarly
affected.
movdqu ___m128i_shift_right@GOTOFF(%ebx,%eax), %xmm0
andl $-16, %ebp
movdqa 0(%ebp), %xmm1
pshufb %xmm0, %xmm1
pcmpistri $58, %xmm1, %xmm1
Reduced testcase attached, compile with -O2 -m32 -fPIC.