Commit 3d592d2d by Qing Zhao Committed by Qing Zhao

Disable strcmp/strncmp/memcmp inlining when optimization

level is lower than 2 or Os

From-SVN: r263028
parent 543f1a04
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
......
......@@ -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);
......
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
......
/* { 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
......
/* 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" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment