aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-prop.h
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/ipa-prop.h
parentf3db1aacf836e97139c70e8240480ea7cfe6b0ba (diff)
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/ipa-prop.h')
-rw-r--r--gcc/ipa-prop.h47
1 files changed, 43 insertions, 4 deletions
diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h
index e32d078edb3..e5a56daeced 100644
--- a/gcc/ipa-prop.h
+++ b/gcc/ipa-prop.h
@@ -154,6 +154,19 @@ struct GTY(()) ipa_alignment
unsigned misalign;
};
+/* Information about zero/non-zero bits. */
+struct GTY(()) ipa_bits
+{
+ /* The propagated value. */
+ widest_int value;
+ /* Mask corresponding to the value.
+ Similar to ccp_lattice_t, if xth bit of mask is 0,
+ implies xth bit of value is constant. */
+ widest_int mask;
+ /* True if jump function is known. */
+ bool known;
+};
+
/* A jump function for a callsite represents the values passed as actual
arguments of the callsite. See enum jump_func_type for the various
types of jump functions supported. */
@@ -166,6 +179,9 @@ struct GTY (()) ipa_jump_func
/* Information about alignment of pointers. */
struct ipa_alignment alignment;
+ /* Information about zero/non-zero bits. */
+ struct ipa_bits bits;
+
enum jump_func_type type;
/* Represents a value of a jump function. pass_through is used only in jump
function context. constant represents the actual constant in constant jump
@@ -283,8 +299,11 @@ ipa_get_jf_ancestor_type_preserved (struct ipa_jump_func *jfunc)
struct ipa_param_descriptor
{
- /* PARAM_DECL of this parameter. */
- tree decl;
+ /* In analysis and modification phase, this is the PARAM_DECL of this
+ parameter, in IPA LTO phase, this is the type of the the described
+ parameter or NULL if not known. Do not read this field directly but
+ through ipa_get_param and ipa_get_type as appropriate. */
+ tree decl_or_type;
/* If all uses of the parameter are described by ipa-prop structures, this
says how many there are. If any use could not be described by means of
ipa-prop structures, this is IPA_UNDESCRIBED_USE. */
@@ -402,13 +421,31 @@ ipa_get_param_count (struct ipa_node_params *info)
/* Return the declaration of Ith formal parameter of the function corresponding
to INFO. Note there is no setter function as this array is built just once
- using ipa_initialize_node_params. */
+ using ipa_initialize_node_params. This function should not be called in
+ WPA. */
static inline tree
ipa_get_param (struct ipa_node_params *info, int i)
{
gcc_checking_assert (!flag_wpa);
- return info->descriptors[i].decl;
+ tree t = info->descriptors[i].decl_or_type;
+ gcc_checking_assert (TREE_CODE (t) == PARM_DECL);
+ return t;
+}
+
+/* Return the type of Ith formal parameter of the function corresponding
+ to INFO if it is known or NULL if not. */
+
+static inline tree
+ipa_get_type (struct ipa_node_params *info, int i)
+{
+ tree t = info->descriptors[i].decl_or_type;
+ if (!t)
+ return NULL;
+ if (TYPE_P (t))
+ return t;
+ gcc_checking_assert (TREE_CODE (t) == PARM_DECL);
+ return TREE_TYPE (t);
}
/* Return the move cost of Ith formal parameter of the function corresponding
@@ -482,6 +519,8 @@ struct GTY(()) ipcp_transformation_summary
ipa_agg_replacement_value *agg_values;
/* Alignment information for pointers. */
vec<ipa_alignment, va_gc> *alignments;
+ /* Known bits information. */
+ vec<ipa_bits, va_gc> *bits;
};
void ipa_set_node_agg_value_chain (struct cgraph_node *node,