Commit ad83025e by Xinliang David Li Committed by Xinliang David Li

Implement -mmemcpy-strategy= and -mmemset-strategy= options

From-SVN: r201645
parent 7d1d0560
2013-08-09 Xinliang David Li <davidxl@google.com>
* config/i386/stringop.def: New file.
* config/i386/stringop.opt: New file.
* config/i386/i386-opts.h: Include stringopt.def.
* config/i386/i386.opt: Include stringopt.opt.
* config/i386/i386.c (ix86_option_override_internal):
Override default size based stringop inline strategies
with options.
* config/i386/i386.c (ix86_parse_stringop_strategy_string):
New function.
2013-08-09 Jan Hubicka <jh@suse.cz> 2013-08-09 Jan Hubicka <jh@suse.cz>
* ipa-ref.c (ipa_clear_stmts_in_references): Clear lto_stmt_uid, too. * ipa-ref.c (ipa_clear_stmts_in_references): Clear lto_stmt_uid, too.
......
...@@ -28,15 +28,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -28,15 +28,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* Algorithm to expand string function with. */ /* Algorithm to expand string function with. */
enum stringop_alg enum stringop_alg
{ {
no_stringop, #undef DEF_ENUM
libcall, #define DEF_ENUM
rep_prefix_1_byte,
rep_prefix_4_byte, #undef DEF_ALG
rep_prefix_8_byte, #define DEF_ALG(alg, name) alg,
loop_1_byte,
loop, #include "stringop.def"
unrolled_loop, last_alg
vector_loop
#undef DEF_ENUM
#undef DEF_ALG
}; };
/* Available call abi. */ /* Available call abi. */
......
...@@ -170,7 +170,7 @@ struct processor_costs { ...@@ -170,7 +170,7 @@ struct processor_costs {
const int fsqrt; /* cost of FSQRT instruction. */ const int fsqrt; /* cost of FSQRT instruction. */
/* Specify what algorithm /* Specify what algorithm
to use for stringops on unknown size. */ to use for stringops on unknown size. */
struct stringop_algs memcpy[2], memset[2]; struct stringop_algs *memcpy, *memset;
const int scalar_stmt_cost; /* Cost of any scalar operation, excluding const int scalar_stmt_cost; /* Cost of any scalar operation, excluding
load and store. */ load and store. */
const int scalar_load_cost; /* Cost of scalar load. */ const int scalar_load_cost; /* Cost of scalar load. */
......
...@@ -316,6 +316,14 @@ mstack-arg-probe ...@@ -316,6 +316,14 @@ mstack-arg-probe
Target Report Mask(STACK_PROBE) Save Target Report Mask(STACK_PROBE) Save
Enable stack probing Enable stack probing
mmemcpy-strategy=
Target RejectNegative Joined Var(ix86_tune_memcpy_strategy)
Specify memcpy expansion strategy when expected size is known
mmemset-strategy=
Target RejectNegative Joined Var(ix86_tune_memset_strategy)
Specify memset expansion strategy when expected size is known
mstringop-strategy= mstringop-strategy=
Target RejectNegative Joined Enum(stringop_alg) Var(ix86_stringop_alg) Init(no_stringop) Target RejectNegative Joined Enum(stringop_alg) Var(ix86_stringop_alg) Init(no_stringop)
Chose strategy to generate stringop using Chose strategy to generate stringop using
......
/* Definitions for stringop strategy for IA-32.
Copyright (C) 2013 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the files COPYING3. If not,
see <http://www.gnu.org/licenses/>. */
DEF_ENUM
DEF_ALG (no_stringop, no_stringop)
DEF_ENUM
DEF_ALG (libcall, libcall)
DEF_ENUM
DEF_ALG (rep_prefix_1_byte, rep_byte)
DEF_ENUM
DEF_ALG (rep_prefix_4_byte, rep_4byte)
DEF_ENUM
DEF_ALG (rep_prefix_8_byte, rep_8byte)
DEF_ENUM
DEF_ALG (loop_1_byte, byte_loop)
DEF_ENUM
DEF_ALG (loop, loop)
DEF_ENUM
DEF_ALG (unrolled_loop, unrolled_loop)
DEF_ENUM
DEF_ALG (vector_loop, vector_loop)
/* Definitions for stringop option handling for IA-32.
Copyright (C) 2013 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the files COPYING3. If not,
see <http://www.gnu.org/licenses/>. */
Enum(stringop_alg) String(rep_byte) Value(rep_prefix_1_byte)
#undef DEF_ENUM
#define DEF_ENUM EnumValue
#undef DEF_ALG
#define DEF_ALG(alg, name) Enum(stringop_alg) String(name) Value(alg)
#include "stringop.def"
#undef DEF_ENUM
#undef DEF_ALG
...@@ -652,6 +652,7 @@ Objective-C and Objective-C++ Dialects}. ...@@ -652,6 +652,7 @@ Objective-C and Objective-C++ Dialects}.
-mbmi2 -mrtm -mlwp -mthreads @gol -mbmi2 -mrtm -mlwp -mthreads @gol
-mno-align-stringops -minline-all-stringops @gol -mno-align-stringops -minline-all-stringops @gol
-minline-stringops-dynamically -mstringop-strategy=@var{alg} @gol -minline-stringops-dynamically -mstringop-strategy=@var{alg} @gol
-mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy}
-mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol -mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
-m96bit-long-double -mlong-double-64 -mlong-double-80 @gol -m96bit-long-double -mlong-double-64 -mlong-double-80 @gol
-mregparm=@var{num} -msseregparm @gol -mregparm=@var{num} -msseregparm @gol
...@@ -14651,6 +14652,24 @@ Expand into an inline loop. ...@@ -14651,6 +14652,24 @@ Expand into an inline loop.
Always use a library call. Always use a library call.
@end table @end table
@item -mmemcpy-strategy=@var{strategy}
@opindex mmemcpy-strategy=@var{strategy}
Override the internal decision heuristic to decide if @code{__builtin_memcpy}
should be inlined and what inline algorithm to use when the expected size
of the copy operation is known. @var{strategy}
is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
@var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
the max byte size with which inline algorithm @var{alg} is allowed. For the last
triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
in the list must be specified in increasing order. The minimal byte size for
@var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
preceding range.
@item -mmemset-strategy=@var{strategy}
@opindex mmemset-strategy=@var{strategy}
The option is similar to @option{-mmemcpy-strategy=} except that it is to control
@code{__builtin_memset} expansion.
@item -momit-leaf-frame-pointer @item -momit-leaf-frame-pointer
@opindex momit-leaf-frame-pointer @opindex momit-leaf-frame-pointer
Don't keep the frame pointer in a register for leaf functions. This Don't keep the frame pointer in a register for leaf functions. This
......
2013-08-09 Xinliang David Li <davidxl@google.com>
* gcc.target/i386/memcpy-strategy-1.c: New test.
* gcc.target/i386/memcpy-strategy-2.c: Ditto.
* gcc.target/i386/memset-strategy-1.c: Ditto.
* gcc.target/i386/memcpy-strategy-3.c: Ditto.
2013-08-09 Jan Hubicka <jh@suse.cz> 2013-08-09 Jan Hubicka <jh@suse.cz>
* gcc.dg/tree-prof/crossmodule-indircall-1.c: New testcase. * gcc.dg/tree-prof/crossmodule-indircall-1.c: New testcase.
......
/* { dg-do compile } */
/* { dg-options "-O2 -march=atom -mmemcpy-strategy=vector_loop:-1:align" } */
/* { dg-final { scan-assembler-times "movdqa" 8 { target { ! { ia32 } } } } } */
/* { dg-final { scan-assembler-times "movdqa" 4 { target { ia32 } } } } */
char a[2048];
char b[2048];
void t (void)
{
__builtin_memcpy (a, b, 2048);
}
/* { dg-do compile } */
/* { dg-options "-O2 -march=atom -mmemcpy-strategy=vector_loop:3000:align,libcall:-1:align" } */
/* { dg-final { scan-assembler-times "movdqa" 8 { target { ! { ia32 } } } } } */
/* { dg-final { scan-assembler-times "movdqa" 4 { target { ia32 } } } } */
char a[2048];
char b[2048];
void t (void)
{
__builtin_memcpy (a, b, 2048);
}
/* { dg-do compile } */
/* { dg-options "-O2 -march=atom -mmemcpy-strategy=vector_loop:2000:align,libcall:-1:align" } */
/* { dg-final { scan-assembler-times "memcpy" 2 } } */
char a[2048];
char b[2048];
void t (void)
{
__builtin_memcpy (a, b, 2048);
}
/* { dg-do compile } */
/* { dg-options "-O2 -march=atom -mmemset-strategy=libcall:-1:align" } */
/* { dg-final { scan-assembler-times "memset" 2 } } */
char a[2048];
void t (void)
{
__builtin_memset (a, 1, 2048);
}
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