aboutsummaryrefslogtreecommitdiff
path: root/gcc/opts.c
diff options
context:
space:
mode:
authorliuhongt <hongtao.liu@intel.com>2021-09-06 13:48:49 +0800
committerliuhongt <hongtao.liu@intel.com>2021-10-08 10:08:50 +0800
commit2b8453c401b699ed93c085d0413ab4b5030bcdb8 (patch)
treef9a9cf8ec427c026f8a9ff7391e740b72a9cc050 /gcc/opts.c
parent50e20ee6e40643c23b53bacda4db4dd9573d7c8a (diff)
downloadgcc-2b8453c401b699ed93c085d0413ab4b5030bcdb8.zip
gcc-2b8453c401b699ed93c085d0413ab4b5030bcdb8.tar.gz
gcc-2b8453c401b699ed93c085d0413ab4b5030bcdb8.tar.bz2
Enable auto-vectorization at O2 with very-cheap cost model.
gcc/ChangeLog: * common.opt (ftree-vectorize): Add Var(flag_tree_vectorize). * doc/invoke.texi (Options That Control Optimization): Update documents. * opts.c (default_options_table): Enable auto-vectorization at O2 with very-cheap cost model. (finish_options): Use cheap cost model for explicit -ftree{,-loop}-vectorize. gcc/testsuite/ChangeLog: * c-c++-common/Wstringop-overflow-2.c: Adjust testcase. * g++.dg/tree-ssa/pr81408.C: Ditto. * g++.dg/warn/Wuninitialized-13.C: Ditto. * gcc.dg/Warray-bounds-51.c: Ditto. * gcc.dg/Warray-parameter-3.c: Ditto. * gcc.dg/Wstringop-overflow-14.c: Ditto. * gcc.dg/Wstringop-overflow-21.c: Ditto. * gcc.dg/Wstringop-overflow-68.c: Ditto. * gcc.dg/Wstringop-overflow-76.c: Ditto. * gcc.dg/gomp/pr46032-2.c: Ditto. * gcc.dg/gomp/pr46032-3.c: Ditto. * gcc.dg/gomp/simd-2.c: Ditto. * gcc.dg/gomp/simd-3.c: Ditto. * gcc.dg/graphite/fuse-1.c: Ditto. * gcc.dg/pr67089-6.c: Ditto. * gcc.dg/pr82929-2.c: Ditto. * gcc.dg/pr82929.c: Ditto. * gcc.dg/store_merging_1.c: Ditto. * gcc.dg/store_merging_11.c: Ditto. * gcc.dg/store_merging_13.c: Ditto. * gcc.dg/store_merging_15.c: Ditto. * gcc.dg/store_merging_16.c: Ditto. * gcc.dg/store_merging_19.c: Ditto. * gcc.dg/store_merging_24.c: Ditto. * gcc.dg/store_merging_25.c: Ditto. * gcc.dg/store_merging_28.c: Ditto. * gcc.dg/store_merging_30.c: Ditto. * gcc.dg/store_merging_5.c: Ditto. * gcc.dg/store_merging_7.c: Ditto. * gcc.dg/store_merging_8.c: Ditto. * gcc.dg/strlenopt-85.c: Ditto. * gcc.dg/tree-ssa/dump-6.c: Ditto. * gcc.dg/tree-ssa/pr19210-1.c: Ditto. * gcc.dg/tree-ssa/pr47059.c: Ditto. * gcc.dg/tree-ssa/pr86017.c: Ditto. * gcc.dg/tree-ssa/pr91482.c: Ditto. * gcc.dg/tree-ssa/predcom-1.c: Ditto. * gcc.dg/tree-ssa/predcom-dse-3.c: Ditto. * gcc.dg/tree-ssa/prefetch-3.c: Ditto. * gcc.dg/tree-ssa/prefetch-6.c: Ditto. * gcc.dg/tree-ssa/prefetch-8.c: Ditto. * gcc.dg/tree-ssa/prefetch-9.c: Ditto. * gcc.dg/tree-ssa/ssa-dse-18.c: Ditto. * gcc.dg/tree-ssa/ssa-dse-19.c: Ditto. * gcc.dg/uninit-40.c: Ditto. * gcc.dg/unroll-7.c: Ditto. * gcc.misc-tests/help.exp: Ditto. * gcc.target/i386/avx512vpopcntdqvl-vpopcntd-1.c: Ditto. * gcc.target/i386/pr34012.c: Ditto. * gcc.target/i386/pr49781-1.c: Ditto. * gcc.target/i386/pr95798-1.c: Ditto. * gcc.target/i386/pr95798-2.c: Ditto. * gfortran.dg/pr77498.f: Ditto.
Diffstat (limited to 'gcc/opts.c')
-rw-r--r--gcc/opts.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/opts.c b/gcc/opts.c
index 6503980..2116c29 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -634,7 +634,8 @@ static const struct default_options default_options_table[] =
{ OPT_LEVELS_2_PLUS, OPT_ftree_switch_conversion, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_ftree_tail_merge, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_ftree_vrp, NULL, 1 },
- { OPT_LEVELS_2_PLUS, OPT_fvect_cost_model_, NULL, VECT_COST_MODEL_CHEAP },
+ { OPT_LEVELS_2_PLUS, OPT_fvect_cost_model_, NULL,
+ VECT_COST_MODEL_VERY_CHEAP },
{ OPT_LEVELS_2_PLUS, OPT_finline_functions, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
@@ -646,6 +647,8 @@ static const struct default_options default_options_table[] =
{ OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_foptimize_strlen, NULL, 1 },
{ OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_freorder_blocks_algorithm_, NULL,
REORDER_BLOCKS_ALGORITHM_STC },
+ { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_ftree_loop_vectorize, NULL, 1 },
+ { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_ftree_slp_vectorize, NULL, 1 },
#ifdef INSN_SCHEDULING
/* Only run the pre-regalloc scheduling pass if optimizing for speed. */
{ OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_fschedule_insns, NULL, 1 },
@@ -663,9 +666,7 @@ static const struct default_options default_options_table[] =
{ OPT_LEVELS_3_PLUS, OPT_fsplit_loops, NULL, 1 },
{ OPT_LEVELS_3_PLUS, OPT_fsplit_paths, NULL, 1 },
{ OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribution, NULL, 1 },
- { OPT_LEVELS_3_PLUS, OPT_ftree_loop_vectorize, NULL, 1 },
{ OPT_LEVELS_3_PLUS, OPT_ftree_partial_pre, NULL, 1 },
- { OPT_LEVELS_3_PLUS, OPT_ftree_slp_vectorize, NULL, 1 },
{ OPT_LEVELS_3_PLUS, OPT_funswitch_loops, NULL, 1 },
{ OPT_LEVELS_3_PLUS, OPT_fvect_cost_model_, NULL, VECT_COST_MODEL_DYNAMIC },
{ OPT_LEVELS_3_PLUS, OPT_fversion_loops_for_strides, NULL, 1 },
@@ -1343,6 +1344,15 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
opts->x_flag_complex_method = 1;
else if (opts_set->x_flag_cx_fortran_rules)
opts->x_flag_complex_method = opts->x_flag_default_complex_method;
+
+ /* Use -fvect-cost-model=cheap instead of -fvect-cost-mode=very-cheap
+ by default with explicit -ftree-{loop,slp}-vectorize. */
+ if (opts->x_optimize == 2
+ && (opts_set->x_flag_tree_loop_vectorize
+ || opts_set->x_flag_tree_vectorize))
+ SET_OPTION_IF_UNSET (opts, opts_set, flag_vect_cost_model,
+ VECT_COST_MODEL_CHEAP);
+
}
#define LEFT_COLUMN 27