aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorH.J. Lu <hongjiu.lu@intel.com>2015-02-17 21:25:56 +0000
committerH.J. Lu <hjl@gcc.gnu.org>2015-02-17 13:25:56 -0800
commit3c99176a7f968bdb8b7a3225265246f643551c80 (patch)
treed04bf3e89fcf482728834b7a88ea6c6667b145fa /gcc
parentd420206ea581d85273f6d05280e658d3fdab604e (diff)
downloadgcc-3c99176a7f968bdb8b7a3225265246f643551c80.zip
gcc-3c99176a7f968bdb8b7a3225265246f643551c80.tar.gz
gcc-3c99176a7f968bdb8b7a3225265246f643551c80.tar.bz2
Add -fipa-cp-alignment
This patch adds -fipa-cp-alignment to provide a way to enable/disable alignment discovery and propagation in IPA-CP. gcc/ * common.opt (fipa-cp-alignment): New. * ipa-cp.c (ipcp_store_alignment_results): Check flag_ipa_cp_alignment. * opts.c (default_options_table): Enable -fipa-cp-alignment for -O2. (enable_fdo_optimizations): Set x_flag_ipa_cp_alignment. * doc/invoke.texi: Document -fipa-cp-alignment. gcc/testsuite/ * gcc.dg/ipa/propalign-3.c: New test. From-SVN: r220773
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/common.opt4
-rw-r--r--gcc/doc/invoke.texi11
-rw-r--r--gcc/ipa-cp.c9
-rw-r--r--gcc/opts.c4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/ipa/propalign-3.c58
7 files changed, 99 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 754c373..4011f74 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2015-02-17 H.J. Lu <hongjiu.lu@intel.com>
+
+ * common.opt (fipa-cp-alignment): New.
+ * ipa-cp.c (ipcp_store_alignment_results): Check
+ flag_ipa_cp_alignment.
+ * opts.c (default_options_table): Enable -fipa-cp-alignment for
+ -O2.
+ (enable_fdo_optimizations): Set x_flag_ipa_cp_alignment.
+ * doc/invoke.texi: Document -fipa-cp-alignment.
+
2015-02-17 Oleg Endo <olegendo@gcc.gnu.org>
PR target/64793
diff --git a/gcc/common.opt b/gcc/common.opt
index 0c60e84..e0d4a1d 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1458,6 +1458,10 @@ fipa-cp-clone
Common Report Var(flag_ipa_cp_clone) Optimization
Perform cloning to make Interprocedural constant propagation stronger
+fipa-cp-alignment
+Common Report Var(flag_ipa_cp_alignment) Optimization
+Perform alignment discovery and propagation to make Interprocedural constant propagation stronger
+
fipa-profile
Common Report Var(flag_ipa_profile) Init(0) Optimization
Perform interprocedural profile propagation
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 62bcece..931002e 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -387,7 +387,7 @@ Objective-C and Objective-C++ Dialects}.
-fgcse-sm -fhoist-adjacent-loads -fif-conversion @gol
-fif-conversion2 -findirect-inlining @gol
-finline-functions -finline-functions-called-once -finline-limit=@var{n} @gol
--finline-small-functions -fipa-cp -fipa-cp-clone @gol
+-finline-small-functions -fipa-cp -fipa-cp-clone -fipa-cp-alignment @gol
-fipa-pta -fipa-profile -fipa-pure-const -fipa-reference -fipa-icf @gol
-fira-algorithm=@var{algorithm} @gol
-fira-region=@var{region} -fira-hoist-pressure @gol
@@ -7323,6 +7323,7 @@ also turns on the following optimization flags:
-finline-small-functions @gol
-findirect-inlining @gol
-fipa-cp @gol
+-fipa-cp-alignment @gol
-fipa-sra @gol
-fipa-icf @gol
-fisolate-erroneous-paths-dereference @gol
@@ -8302,6 +8303,14 @@ it may significantly increase code size
(see @option{--param ipcp-unit-growth=@var{value}}).
This flag is enabled by default at @option{-O3}.
+@item -fipa-cp-alignment
+@opindex -fipa-cp-alignment
+When enabled, this optimization propagates alignment of function
+parameters to support better vectorization and string operations.
+
+This flag is enabled by default at @option{-O2} and @option{-Os}. It
+requires that @option{-fipa-cp} is enabled.
+
@item -fipa-icf
@opindex fipa-icf
Perform Identical Code Folding for functions and read-only variables.
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 440ced4..103ac99a 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -4323,6 +4323,15 @@ ipcp_store_alignment_results (void)
bool dumped_sth = false;
bool found_useful_result = false;
+ if (!opt_for_fn (node->decl, flag_ipa_cp_alignment))
+ {
+ if (dump_file)
+ fprintf (dump_file, "Not considering %s for alignment discovery "
+ "and propagate; -fipa-cp-alignment: disabled.\n",
+ node->name ());
+ continue;
+ }
+
if (info->ipcp_orig_node)
info = IPA_NODE_REF (info->ipcp_orig_node);
diff --git a/gcc/opts.c b/gcc/opts.c
index 4a1ed0e..39c190d 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -493,6 +493,7 @@ static const struct default_options default_options_table[] =
{ OPT_LEVELS_2_PLUS, OPT_ftree_pre, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_ftree_switch_conversion, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_fipa_cp, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fipa_cp_alignment, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_fdevirtualize, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_fdevirtualize_speculatively, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_fipa_sra, NULL, 1 },
@@ -1330,6 +1331,9 @@ enable_fdo_optimizations (struct gcc_options *opts,
if (!opts_set->x_flag_ipa_cp_clone
&& value && opts->x_flag_ipa_cp)
opts->x_flag_ipa_cp_clone = value;
+ if (!opts_set->x_flag_ipa_cp_alignment
+ && value && opts->x_flag_ipa_cp)
+ opts->x_flag_ipa_cp_alignment = value;
if (!opts_set->x_flag_predictive_commoning)
opts->x_flag_predictive_commoning = value;
if (!opts_set->x_flag_unswitch_loops)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1bd4bac..69c7c50 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2015-02-17 H.J. Lu <hongjiu.lu@intel.com>
+
+ * gcc.dg/ipa/propalign-3.c: New test.
+
2015-02-17 Oleg Endo <olegendo@gcc.gnu.org>
PR target/64793
diff --git a/gcc/testsuite/gcc.dg/ipa/propalign-3.c b/gcc/testsuite/gcc.dg/ipa/propalign-3.c
new file mode 100644
index 0000000..e647cb1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/propalign-3.c
@@ -0,0 +1,58 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-ipa-cp-alignment -fno-early-inlining -fdump-ipa-cp -fdump-tree-optimized" } */
+
+#include <stdint.h>
+
+extern int fail_the_test(void *);
+extern int pass_the_test(void *);
+extern int diversion (void *);
+
+struct somestruct
+{
+ void *whee;
+ void *oops;
+};
+
+struct container
+{
+ struct somestruct first;
+ struct somestruct buf[32];
+};
+
+static int __attribute__((noinline))
+foo (void *p)
+{
+ uintptr_t a = (uintptr_t) p;
+
+ if (a % 4)
+ return fail_the_test (p);
+ else
+ return pass_the_test (p);
+}
+
+int
+bar (void)
+{
+ struct container c;
+ return foo (c.buf);
+}
+
+
+static int
+through (struct somestruct *p)
+{
+ diversion (p);
+ return foo (&p[16]);
+}
+
+int
+bar2 (void)
+{
+ struct container c;
+ through (c.buf);
+}
+
+/* { dg-final { scan-ipa-dump-not "Adjusting alignment of param" "cp" } } */
+/* { dg-final { scan-tree-dump "fail_the_test" "optimized" } } */
+/* { dg-final { cleanup-ipa-dump "cp" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */