aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
authorPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>2016-08-26 08:05:39 +0000
committerPrathamesh Kulkarni <prathamesh3492@gcc.gnu.org>2016-08-26 08:05:39 +0000
commit209ca542cadd7ae7dc174bc74e066ed1de246672 (patch)
treef2ddd305549d6c54fec0b9320813b9142aec89ff /gcc/testsuite/gcc.dg
parentf3db1aacf836e97139c70e8240480ea7cfe6b0ba (diff)
downloadgcc-209ca542cadd7ae7dc174bc74e066ed1de246672.zip
gcc-209ca542cadd7ae7dc174bc74e066ed1de246672.tar.gz
gcc-209ca542cadd7ae7dc174bc74e066ed1de246672.tar.bz2
Patch for performing interprocedural bitwise constant propagation.
2016-08-26 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> Martin Jambhor <mjambor@suse.cz> * common.opt: New option -fipa-bit-cp. * doc/invoke.texi: Document -fipa-bit-cp. * opts.c (default_options_table): Add entry for -fipa-bit-cp. (enable_fdo_optimizations): Check for flag_ipa_bit_cp. * tree-ssa-ccp.h: New header file. * tree-ssa-ccp.c: Include tree-ssa-ccp.h (bit_value_binop_1): Change to bit_value_binop_1 and export it. Replace all occurences of tree parameter by two new params: signop, int. (bit_value_unop_1): Change to bit_value_unop and export it. Replace all occurences of tree parameter by two new params: signop, int. (bit_value_binop): Change call from bit_value_binop_1 to bit_value_binop. (bit_value_assume_aligned): Likewise. (bit_value_unop): Change call from bit_value_unop_1 to bit_value_unop. (do_ssa_ccp): Pass nonzero_p || flag_ipa_cp_bit instead of nonzero_p to ccp_finalize. (ccp_finalize): Skip processing if val->mask == 0. * ipa-cp.c: Include tree-ssa-ccp.h (ipcp_bits_lattice): New class. (ipcp_param_lattice (bits_lattice): New member. (print_all_lattices): Call ipcp_bits_lattice::print. (set_all_contains_variable): Call ipcp_bits_lattice::set_to_bottom. (initialize_node_lattices): Likewise. (propagate_bits_accross_jump_function): New function. (propagate_constants_accross_call): Call propagate_bits_accross_jump_function. (ipcp_propagate_stage): Store parameter types when in_lto_p is true. (ipcp_store_bits_results): New function. (ipcp_driver): Call ipcp_store_bits_results. * ipa-prop.h (ipa_bits): New struct. (ipa_jump_func): Add new member bits of type ipa_bits. (ipa_param_descriptor): Change decl to decl_or_type. (ipa_get_param): Change decl to decl_or_type and assert on PARM_DECL. (ipa_get_type): New function. (ipcp_transformation_summary): New member bits. * ipa-prop.c (ipa_get_param_decl_index_1): s/decl/decl_or_type. (ipa_populate_param_decls): Likewise. (ipa_dump_param): Likewise. (ipa_print_node_jump_functions_for_edge): Pretty-print ipa_bits jump function. (ipa_set_jf_unknown): Set ipa_bits::known to false. (ipa_compute_jump_functions_for_edge): Compute jump function for bits propagation. (ipa_node_params_t::duplicate): Copy src->bits into dst->bits. (ipa_write_jump_function): Add streaming for ipa_bits. (ipa_read_jump_function): Add support for reading streamed ipa_bits. (write_ipcp_transformation_info): Add streaming for ipa_bits summary for ltrans. (read_ipcp_transfomration_info): Add support for reading streamed ipa_bits. (ipcp_update_bits): New function. (ipcp_transform_function): Call ipcp_update_bits. testsuite/ * gcc.dg/ipa/propbits-1.c: New test-case. * gcc.dg/ipa/propbits-2.c: Likewise. * gcc.dg/ipa/propbits-3.c: Likewise. Co-Authored-By: Martin Jambor <mjambor@suse.cz> From-SVN: r239769
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/ipa/propbits-1.c19
-rw-r--r--gcc/testsuite/gcc.dg/ipa/propbits-2.c41
-rw-r--r--gcc/testsuite/gcc.dg/ipa/propbits-3.c22
3 files changed, 82 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/ipa/propbits-1.c b/gcc/testsuite/gcc.dg/ipa/propbits-1.c
new file mode 100644
index 0000000..8ec372d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/propbits-1.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-early-inlining -fdump-ipa-cp" } */
+
+__attribute__((noinline))
+static int f(int x)
+{
+ int some_op(int);
+ return some_op (x);
+}
+
+int main(void)
+{
+ int a = f(1);
+ int b = f(2);
+ int c = f(4);
+ return a + b + c;
+}
+
+/* { dg-final { scan-ipa-dump "Adjusting mask for param 0 to 0x7" "cp" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/propbits-2.c b/gcc/testsuite/gcc.dg/ipa/propbits-2.c
new file mode 100644
index 0000000..3a960f0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/propbits-2.c
@@ -0,0 +1,41 @@
+/* x's mask should be meet(0xc, 0x3) == 0xf */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-early-inlining -fdump-ipa-cp" } */
+
+extern int pass_test ();
+extern int fail_test ();
+
+__attribute__((noinline))
+static int f1(int x)
+{
+ if ((x & ~0xf) == 0)
+ return pass_test ();
+ else
+ return fail_test ();
+}
+
+__attribute__((noinline))
+static int f2(int y)
+{
+ return f1(y & 0x03);
+}
+
+__attribute__((noinline))
+static int f3(int z)
+{
+ return f1(z & 0xc);
+}
+
+extern int a;
+extern int b;
+
+int main(void)
+{
+ int k = f2(a);
+ int l = f3(b);
+ return k + l;
+}
+
+/* { dg-final { scan-ipa-dump "Adjusting mask for param 0 to 0xf" "cp" } } */
+/* { dg-final { scan-dump-tree-not "fail_test" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/propbits-3.c b/gcc/testsuite/gcc.dg/ipa/propbits-3.c
new file mode 100644
index 0000000..44744cd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/propbits-3.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-early-inlining -fdump-ipa-cp" } */
+
+__attribute__((noinline))
+static int f(int x)
+{
+ extern int limit;
+ extern int f2(int);
+
+ if (x == limit)
+ return x;
+ int k = f(x + 1);
+ return f2 (k);
+}
+
+int main(int argc, char **argv)
+{
+ int k = f(argc & 0xff);
+ return k;
+}
+
+/* { dg-final { scan-ipa-dump-not "Adjusting mask for" "cp" } } */