Limit SH strncmp inline expansion (PR target/78460).
commit65ebf6e9252612c365a73afd51e7e74acba5f3b2
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Aug 2017 23:42:23 +0000 (15 23:42 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Aug 2017 23:42:23 +0000 (15 23:42 +0000)
tree01bb4b9c7a8279f28e5be23b7a59629bf0c42da9
parent0f9b3b5e8f0eedd22b99a0afabd84c27db0c0eab
Limit SH strncmp inline expansion (PR target/78460).

GCC mainline built for sh4-linux-gnu runs out of memory building a
glibc test, which calls strncmp with very large constant size
argument, resulting in the SH inline strncmp expansion trying to
inline a fully unrolled expansion of strncmp for that size.

This patch limits that fully unrolled expansion to the case of less
than 32 bytes.  This is explicitly *not* trying to be optimal in any
way (very likely a lower threshold makes sense), just to limit enough
to avoid the out-of-memory issue in the glibc testsuite.

I have *not* run the GCC testsuite for SH.  I have verified that this
allows the glibc testsuite to build OK, with both GCC mainline and GCC
7 branch (and that the included test builds quickly with patched GCC,
runs out of memory with unpatched GCC).

PR target/78460
PR target/67712
gcc:
* config/sh/sh-mem.cc (sh_expand_cmpnstr): Only unroll for
constant count if that count is less than 32.

gcc/testsuite:
* gcc.c-torture/compile/string-large-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251108 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/config/sh/sh-mem.cc
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/string-large-1.c [new file with mode: 0644]