On Thu, Sep 4, 2014 at 5:41 AM, Kugan <kugan.vivekanandara...@linaro.org> wrote: >>> I added this part of the code (in cfgexpand.c) to handle binary/unary/.. >>> gimple operations and used the LHS value range to infer the assigned >>> value range. I will revert this part of the code as this is wrong. >>> >>> I dont think checking promoted_mode for temp will be necessary here as >>> convert_move will handle it correctly if promoted_mode is set for temp. >>> >>> Thus, I will reimplement setting promoted_mode to temp (in >>> expand_expr_real_2) based on the gimple statement content on RHS. i.e. >>> by looking at the RHS operands and its value ranges and by calculating >>> the resulting value range. Does this sound OK to you. >> >> No, this sounds backward again and won't work because those operands >> again could be just truncated - thus you can't rely on their value-range. >> >> What you would need is VRP computing value-ranges in the promoted >> mode from the start (and it doesn't do that). > > > Hi Richard, > > Here is an attempt to do the value range computation in promoted_mode's > type when it is overflowing. Bootstrapped on x86-84.
Err - I think you misunderstood this as a suggestion to do this ;) value-ranges should be computed according to the type not according to the (promoted) mode. Otherwise we will miss optimization opportunities. Richard. > Based on your feedback, I will do more testing on this. > > Thanks for your time, > Kugan > > gcc/ChangeLog: > > 2014-09-04 Kugan Vivekanandarajah <kug...@linaro.org> > > * tree-ssa-ccp.c (ccp_finalize): Adjust the nonzero_bits precision to > the type. > (evaluate_stmt): Likewise. > * tree-ssanames.c (set_range_info): Adjust if the precision of stored > value range is different. > * tree-vrp.c (normalize_int_cst_precision): New function. > (set_value_range): Add assert to check precision. > (set_and_canonicalize_value_range): Call normalize_int_cst_precision > on min and max. > (promoted_type): New function. > (promote_unary_vr): Likewise. > (promote_binary_vr): Likewise. > (extract_range_from_binary_expr_1): Adjust type to match value range. > Store value ranges in promoted type if they overflow. > (extract_range_from_unary_expr_1): Likewise. > (adjust_range_with_scev): Call normalize_int_cst_precision > on min and max. > (vrp_visit_assignment_or_call): Likewise. > (simplify_bit_ops_using_ranges): Adjust the value range precision. > (test_for_singularity): Likewise. > (simplify_stmt_for_jump_threading): Likewise. > (extract_range_from_assert): Likewise.