diff options
author | Qing Zhao <qing.zhao@oracle.com> | 2018-07-27 01:56:57 +0000 |
---|---|---|
committer | Qing Zhao <qinzhao@gcc.gnu.org> | 2018-07-27 01:56:57 +0000 |
commit | 3d592d2d56ccd3298ea0121de16615d27b9fb659 (patch) | |
tree | 7569ec1c9cef4945253f54093bf81810b0498774 /gcc | |
parent | 543f1a04223f839421cc170f60d8c178e2d4f1ad (diff) | |
download | gcc-3d592d2d56ccd3298ea0121de16615d27b9fb659.zip gcc-3d592d2d56ccd3298ea0121de16615d27b9fb659.tar.gz gcc-3d592d2d56ccd3298ea0121de16615d27b9fb659.tar.bz2 |
Disable strcmp/strncmp/memcmp inlining when optimization
level is lower than 2 or Os
From-SVN: r263028
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/builtins.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/strcmpopt_5.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/strcmpopt_6.c | 4 |
5 files changed, 18 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f5e8d62..c2bf139 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-07-26 Qing Zhao <qing.zhao@oracle.com> + + * builtins.c (inline_expand_builtin_string_cmp): Disable inlining + when optimization level is lower than 2 or optimize for size. + 2018-07-26 Martin Sebor <msebor@redhat.com> PR tree-optimization/86043 diff --git a/gcc/builtins.c b/gcc/builtins.c index aa3e0d8..c659611 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -6854,6 +6854,11 @@ inline_expand_builtin_string_cmp (tree exp, rtx target) unsigned HOST_WIDE_INT length = 0; bool is_ncmp = (fcode == BUILT_IN_STRNCMP || fcode == BUILT_IN_MEMCMP); + /* Do NOT apply this inlining expansion when optimizing for size or + optimization level below 2. */ + if (optimize < 2 || optimize_insn_for_size_p ()) + return NULL_RTX; + gcc_checking_assert (fcode == BUILT_IN_STRCMP || fcode == BUILT_IN_STRNCMP || fcode == BUILT_IN_MEMCMP); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eccfcd0..f48c3d3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-07-26 Qing Zhao <qing.zhao@oracle.com> + + * gcc.dg/strcmpopt_5.c: Change to O2 to enable the transformation. + * gcc.dg/strcmpopt_6.c: Likewise. + 2018-07-26 Pat Haugen <pthaugen@us.ibm.com> PR target/86612 diff --git a/gcc/testsuite/gcc.dg/strcmpopt_5.c b/gcc/testsuite/gcc.dg/strcmpopt_5.c index c30fb78..d368277 100644 --- a/gcc/testsuite/gcc.dg/strcmpopt_5.c +++ b/gcc/testsuite/gcc.dg/strcmpopt_5.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-O -fdump-rtl-expand" } */ +/* { dg-options "-O2 -fdump-rtl-expand" } */ typedef struct { char s[8]; int x; } S; __attribute__ ((noinline)) int diff --git a/gcc/testsuite/gcc.dg/strcmpopt_6.c b/gcc/testsuite/gcc.dg/strcmpopt_6.c index 0f8cf87..964b9e4 100644 --- a/gcc/testsuite/gcc.dg/strcmpopt_6.c +++ b/gcc/testsuite/gcc.dg/strcmpopt_6.c @@ -1,7 +1,7 @@ /* When the specified length exceeds one of the arguments of the call to memcmp, the call to memcmp should NOT be inlined. */ /* { dg-do run } */ -/* { dg-options "-O -fdump-rtl-expand -Wno-stringop-overflow" } */ +/* { dg-options "-O2 -fdump-rtl-expand -Wno-stringop-overflow" } */ typedef struct { char s[8]; int x; } S; @@ -33,4 +33,4 @@ int main (void) } -/* { dg-final { scan-rtl-dump-times "__builtin_memcmp" 4 "expand" } } */ +/* { dg-final { scan-rtl-dump-times "__builtin_memcmp" 6 "expand" } } */ |