aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
AgeCommit message (Collapse)AuthorFilesLines
2016-10-24tree-vrp.c (evrp_dom_walker::before_dom_children): Ignore backedges when ↵Richard Biener1-11/+39
identifying the single predecessor to take conditional... 2016-10-24 Richard Biener <rguenther@suse.de> * tree-vrp.c (evrp_dom_walker::before_dom_children): Ignore backedges when identifying the single predecessor to take conditional info from. Use SCEV to get at ranges for loop IVs. * lto-streamer-out.c (lto_write_mode_table): CSE inner mode to avoid false warning. * gcc.dg/tree-ssa/cunroll-13.c: Disable EVRP. * gcc.dg/tree-ssa/pr21458.c: Likewise. * gcc.dg/tree-ssa/pr21458-2.c: New testcase for EVRP. From-SVN: r241470
2016-10-21re PR c++/78051 (error: dead STMT in EH table when using -O2)Richard Biener1-1/+5
2016-10-21 Richard Biener <rguenther@suse.de> PR tree-optimization/78051 * tree-vrp.c (evrp_dom_walker::before_dom_children): Update stmt and mark replaced if folding did something. * g++.dg/torture/pr78051.C: New testcase. From-SVN: r241394
2016-10-19tree-vrp.c (evrp_dom_walker::evrp_dom_walker): Initialize stmts_to_remove.Richard Biener1-10/+65
2016-10-19 Richard Biener <rguenther@suse.de> * tree-vrp.c (evrp_dom_walker::evrp_dom_walker): Initialize stmts_to_remove. (evrp_dom_walker::~evrp_dom_walker): Free it. (evrp_dom_walker::stmts_to_remove): Add. (evrp_dom_walker::before_dom_children): Mark PHIs and stmts whose output we fully propagate for removal. Propagate into BB destination PHI arguments. (execute_early_vrp): Remove queued stmts. Dump value ranges before stmt removal. * gcc.dg/tree-ssa/pr61839_2.c: Fix testcase. From-SVN: r241327
2016-10-18tree-vrp.c (evrp_dom_walker::before_dom_children): Handle not visited but ↵Richard Biener1-62/+72
non-executable predecessors. 2016-10-18 Richard Biener <rguenther@suse.de> * tree-vrp.c (evrp_dom_walker::before_dom_children): Handle not visited but non-executable predecessors. Return taken edge. Simplify conditions and refactor propagation vs. folding step. * gcc.dg/tree-ssa/pr20318.c: Disable EVRP. * gcc.dg/tree-ssa/pr21001.c: Likewise. * gcc.dg/tree-ssa/pr21090.c: Likewise. * gcc.dg/tree-ssa/pr21294.c: Likewise. * gcc.dg/tree-ssa/pr21563.c: Likewise. * gcc.dg/tree-ssa/pr23744.c: Likewise. * gcc.dg/tree-ssa/pr25382.c: Likewise. * gcc.dg/tree-ssa/pr68431.c: Likewise. * gcc.dg/tree-ssa/vrp03.c: Likewise. * gcc.dg/tree-ssa/vrp06.c: Likewise. * gcc.dg/tree-ssa/vrp07.c: Likewise. * gcc.dg/tree-ssa/vrp09.c: Likewise. * gcc.dg/tree-ssa/vrp19.c: Likewise. * gcc.dg/tree-ssa/vrp20.c: Likewise. * gcc.dg/tree-ssa/vrp92.c: Likewise. * gcc.dg/pr68217.c: Likewise. * gcc.dg/predict-9.c: Likewise. * gcc.dg/tree-prof/val-prof-5.c: Adjust. * gcc.dg/predict-1.c: Likewise. From-SVN: r241300
2016-10-18tree-ssa-propagate.h (substitute_and_fold): Adjust prototype.Richard Biener1-4/+1
2016-10-18 Richard Biener <rguenther@suse.de> * tree-ssa-propagate.h (substitute_and_fold): Adjust prototype. * tree-ssa-propagate.c (ssa_prop_fini): Remove final BB_VISITED clearing. (substitute_and_fold_dom_walker): Adjust constructor. (substitute_and_fold_dom_walker::before_dom_children): Remove do_dce flag and handling (always true). (substitute_and_fold): Likewise. * tree-vrp.c (vrp_finalize): Adjust. (execute_early_vrp): Remove final BB_VISITED clearing. * tree-ssa-ccp.c (ccp_finalize): Adjust. * tree-ssa-copy.c (fini_copy_prop): Likewise. * ira.c (ira): Call clear_bb_flags. From-SVN: r241296
2016-10-17Use get_ptr_nonnull in tree-vrpKugan Vivekanandarajah1-1/+2
Use get_ptr_nonnull in tree-vrp gcc/testsuite/ChangeLog: 2016-10-18 Kugan Vivekanandarajah <kuganv@linaro.org> * gcc.dg/ipa/vrp4.c: Adjust testcase. gcc/ChangeLog: 2016-10-18 Kugan Vivekanandarajah <kuganv@linaro.org> * tree-vrp.c (get_value_range): Check get_ptr_nonnull. From-SVN: r241289
2016-10-17Set nonnull attribute to ptr_info_def based on VRPKugan Vivekanandarajah1-15/+29
Set nonnull attribute to ptr_info_def based on VRP gcc/ChangeLog: 2016-10-18 Kugan Vivekanandarajah <kuganv@linaro.org> * tree-ssa-alias.h (pt_solution_singleton_or_null_p): Renamed from pt_solution_singleton_p. * tree-ssa-ccp.c (fold_builtin_alloca_with_align): Use renamed pt_solution_singleton_or_null_p from pt_solution_singleton_p. * tree-ssa-structalias.c (find_what_p_points_to): Preserve pointer nonnull computed by VRP. Also Conservatively set pt.null to 1. (pt_solution_reset): Conservatively set pt.null to 1. (pt_solution_singleton_or_null_p): Renamed from pt_solution_singleton_p. * tree-ssanames.h (set_ptr_nonnull): Declare. (get_ptr_nonnull): Likewise. * tree-ssanames.c (set_ptr_nonnull): New. (get_ptr_nonnull): Likewise. * tree-vrp.c (vrp_finalize): Set ptr that are nonnull. (evrp_dom_walker::before_dom_children): Likewise. gcc/testsuite/ChangeLog: 2016-10-18 Kugan Vivekanandarajah <kuganv@linaro.org> * gcc.dg/torture/pr39074-2.c: Adjust testcase. * gcc.dg/torture/pr39074.c: Likewise. From-SVN: r241287
2016-10-17re PR tree-optimization/77988 (ICE on valid code at -Os and above on ↵Richard Biener1-9/+1
x86_64-linux-gnu: verify_gimple failed) 2016-10-17 Richard Biener <rguenther@suse.de> PR tree-optimization/77988 * tree-vrp.c (remove_range_assertions): Use replace_uses_by. * gcc.dg/torture/pr77988.c: New testcase. From-SVN: r241242
2016-10-14re PR tree-optimization/77979 (ICE on valid code at -Os and above on ↵Richard Biener1-2/+12
x86_64-linux-gnu: Segmentation fault) 2016-10-14 Richard Biener <rguenther@suse.de> PR tree-optimization/77979 * tree-vrp.c (compare_name_with_value): Handle released SSA names in the equivalency sets. (compare_names): Likewise. * gcc.dg/torture/pr77979.c: New testcase. From-SVN: r241162
2016-10-13EVRP - Push op1 value range before pushing op0 value range.Kugan Vivekanandarajah1-7/+13
gcc/ChangeLog: 2016-10-12 Richard Biener <rguenther@suse.de> * tree-vrp.c (evrp_dom_walker::try_find_new_range): Renamed from try_add_new_range and made to eturn new range. (evrp_dom_walker::before_dom_children): Push op1 value range before pushing op0 value range. gcc/testsuite/ChangeLog: 2016-10-12 Kugan Vivekanandarajah <kuganv@linaro.org> * gcc.dg/tree-ssa/evrp6.c: New test. From-SVN: r241083
2016-10-122016-10-12 Richard Biener <rguenther@suse.de>Richard Biener1-5/+8
* tree-ssa-propagate.c (substitute_and_fold_dom_walker::before_dom_children): Do not ignore ASSERT_EXPRs but only preserve them. * tree-vrp.c (remove_range_assertions): Deal with ASSERT_EXPRs that have been propagated into. (vrp_finalize): Enable DCE for substitute_and_fold. * gcc.dg/tree-ssa/vrp35.c: Adjust. * gcc.dg/tree-ssa/vrp36.c: Likewise. * gcc.dg/tree-ssa/vrp46.c: Likewise. From-SVN: r241021
2016-10-12re PR middle-end/77920 (186.crafty doesn't compile)Richard Biener1-17/+10
2016-10-12 Richard Biener <rguenther@suse.de> PR tree-optimization/77920 * tree-vrp.c (simplify_div_or_mod_using_ranges): Simplify. (simplify_min_or_max_using_ranges): Pass in gsi and use it. (simplify_abs_using_ranges): Likewise. (simplify_conversion_using_ranges): Likewise. (simplify_stmt_using_ranges): Adjust. * gcc.dg/torture/pr77920.c: New testcase. From-SVN: r241020
2016-10-10Infer and push new value ranges for x in y < x.Kugan Vivekanandarajah1-14/+39
gcc/ChangeLog: 2016-10-11 Kugan Vivekanandarajah <kuganv@linaro.org> * tree-vrp.c (evrp_dom_walker::try_add_new_range): New. (evrp_dom_walker::before_dom_children): Infer and push new value ranges for x in y < x. From-SVN: r240957
2016-10-10Allocate bitmap before copyingKugan Vivekanandarajah1-1/+4
Allocate bitmap before copying gcc/ChangeLog: 2016-10-11 Kugan Vivekanandarajah <kuganv@linaro.org> * tree-vrp.c (vrp_intersect_ranges_1): Allocate bitmap before copying. From-SVN: r240950
2016-10-07tree-ssa-propagate.c (replace_phi_args_in): Remove no longer required hack.Richard Biener1-2/+9
2016-10-07 Richard Biener <rguenther@suse.de> * tree-ssa-propagate.c (replace_phi_args_in): Remove no longer required hack. (substitute_and_fold_dom_walker::before_dom_children): Substitute and fold before pass specific folding to avoid feeding that with SSA names that will be later released. * tree-ssa-ccp.c (get_value_for_expr): Guard for new SSA names introduced by folding and visited by evaluate_stmt called during ccp_fold_stmt. (likely_value): Likewise. (evaluate_stmt): Likewise. * tree-vrp.c (simplify_truth_ops_using_ranges): Fold modified stmt. (simplify_div_or_mod_using_ranges): Likewise. (simplify_min_or_max_using_ranges): Likewise. (simplify_abs_using_ranges): Likewise. (simplify_conversion_using_ranges): Likewise. (simplify_float_conversion_using_ranges): Likewise. (simplify_stmt_using_ranges): Likewise. * gcc.dg/tree-ssa/vrp01.c: Adjust. * gcc.dg/tree-ssa/vrp34.c: Likewise. From-SVN: r240865
2016-10-06re PR tree-optimization/77862 (ice in add_equivalence)Kugan Vivekanandarajah1-1/+1
Fix PR77862 gcc/testsuite/ChangeLog: 2016-10-06 Kugan Vivekanandarajah <kuganv@linaro.org> PR tree-optimization/77862 * gcc.dg/pr77862.c: New test. gcc/ChangeLog: 2016-10-06 Kugan Vivekanandarajah <kuganv@linaro.org> PR tree-optimization/77862 * tree-vrp.c (add_equivalence): Use get_value_range so that num_vr_values is checked before accessing vr_values. From-SVN: r240842
2016-10-06Handle POINTER_TYPE_P in EVRPKugan Vivekanandarajah1-1/+2
Handle POINTER_TYPE_P in EVRP gcc/ChangeLog: 2016-10-06 Kugan Vivekanandarajah <kuganv@linaro.org> * tree-vrp.c (evrp_dom_walker::before_dom_children): Handle POINTER_TYPE_P. gcc/testsuite/ChangeLog: 2016-10-06 Kugan Vivekanandarajah <kuganv@linaro.org> * gcc.dg/tree-ssa/evrp4.c: New test. From-SVN: r240841
2016-09-30tree-vrp.c (intersect_ranges): If we failed to handle the intersection ↵Richard Biener1-1/+10
choose a constant singleton range if... 2016-09-30 Richard Biener <rguenther@suse.de> * tree-vrp.c (intersect_ranges): If we failed to handle the intersection choose a constant singleton range if available. From-SVN: r240647
2016-09-29tree-vrp.c (set_defs_to_varying): New helper avoiding writing to ↵Richard Biener1-20/+21
vr_const_varying. 2016-09-29 Richard Biener <rguenther@suse.de> * tree-vrp.c (set_defs_to_varying): New helper avoiding writing to vr_const_varying. (vrp_initialize): Call it. (vrp_visit_stmt): Likewise. (evrp_dom_walker::before_dom_children): Likewise. From-SVN: r240612
2016-09-27auto-inc-dec.c (try_merge): Remove break after return.Jakub Jelinek1-1/+0
* auto-inc-dec.c (try_merge): Remove break after return. * cselib.c (autoinc_split): Likewise. * explow.c (promote_mode): Likewise. * fixed-value.c (fixed_arithmetic): Likewise. * hsa.c (hsa_internal_fn::get_arity): Likewise. * rtlanal.c (modified_between_p, modified_in_p): Likewise. * trans-mem.c (get_attrs_for): Likewise. * tree-if-conv.c (if_convertible_stmt_p): Likewise. * tree-vrp.c (simplify_stmt_using_ranges): Likewise. * config/aarch64/aarch64-builtins.c (aarch64_fold_builtin): Likewise. * config/aarch64/aarch64.c (aarch64_get_condition_code_1): Likewise. * config/c6x/c6x.c (c6x_get_unit_specifier): Likewise. * config/cr16/cr16.c (legitimate_pic_operand_p): Likewise. * config/cris/cris.c (cris_op_str): Likewise. * config/mn10300/mn10300.c (cc_flags_for_code): Likewise. * config/tilepro/tilepro.c (tilepro_emit_setcc_internal_di): Likewise. c-family/ * c-ada-spec.c (print_ada_declaration): Remove break after return. objc/ * objc-act.c (continue_class): Remove break after return. (objc_maybe_printable_name): Likewise. fortran/ * dependency.c (gfc_dep_compare_expr): Remove break after return. * frontend-passes.c (optimize_op): Likewise. * interface.c (gfc_current_interface_head): Likewise. * symbol.c (check_conflict): Likewise. * trans-intrinsic.c (build_fix_expr): Likewise. ada/ * terminals.c (is_gui_app): Remove break after return. From-SVN: r240554
2016-09-27Fix ipa-vrp convert value_rangeKugan Vivekanandarajah1-8/+8
gcc/ChangeLog: 2016-09-27 Kugan Vivekanandarajah <kuganv@linaro.org> PR ipa/77677 * ipa-prop.c (ipa_compute_jump_functions_for_edge): Use extract_range_from_unary_expr to convert value_range. * tree-vrp.c (extract_range_from_unary_expr_1): Rename to. (extract_range_from_unary_expr): This. * tree-vrp.h (extract_range_from_unary_expr): Declare. gcc/testsuite/ChangeLog: 2016-09-27 Kugan Vivekanandarajah <kuganv@linaro.org> PR ipa/77677 * gcc.dg/torture/pr77677-2.c: New test. From-SVN: r240517
2016-09-20Use ipa-vrp result in tree-vrpKugan Vivekanandarajah1-0/+12
gcc/ChangeLog: 2016-09-21 Kugan Vivekanandarajah <kuganv@linaro.org> * tree-vrp.c (get_value_range): Teach PARM_DECL to use ipa-vrp results. gcc/testsuite/ChangeLog: 2016-09-21 Kugan Vivekanandarajah <kuganv@linaro.org> * gcc.dg/guality/pr54519-1.c: Add -fno-ipa-vrp. Else constant arguments/compare will be optimized away. * gcc.dg/torture/ftrapv-1.c: Likewise. From-SVN: r240293
2016-09-20Add Early VRPKugan Vivekanandarajah1-53/+414
gcc/ChangeLog: 2016-09-21 Kugan Vivekanandarajah <kuganv@linaro.org> * doc/invoke.texi: Document -fdump-tree-evrp. * passes.def: Define new pass_early_vrp. * timevar.def: Define new TV_TREE_EARLY_VRP. * tree-pass.h (make_pass_early_vrp): New. * tree-ssa-propagate.c: Make replace_uses_in non static. * tree-ssa-propagate.h: Export replace_uses_in. * tree-vrp.c (extract_range_for_var_from_comparison_expr): New. (extract_range_from_assert): Factor out extract_range_for_var_from_comparison_expr. (vrp_initialize_lattice): New. (vrp_initialize): Factor out vrp_initialize_lattice. (vrp_valueize): Fix it to reject complex value ranges. (vrp_free_lattice): New. (evrp_dom_walker::before_dom_children): Likewise. (evrp_dom_walker::after_dom_children): Likewise. (evrp_dom_walker::push_value_range): Likewise. (evrp_dom_walker::pop_value_range): Likewise. (execute_early_vrp): Likewise. (execute_vrp): Call vrp_initialize_lattice and vrp_free_lattice. (make_pass_early_vrp): New. gcc/testsuite/ChangeLog: 2016-09-21 Kugan Vivekanandarajah <kuganv@linaro.org> * g++.dg/tree-ssa/pr31146-2.C: Run with -fno-tree-evrp as evrp also does the same transformation. * g++.dg/warn/pr33738.C: XFAIL as optimization now happens in ccp. * gcc.dg/tree-ssa/evrp1.c: New test. * gcc.dg/tree-ssa/evrp2.c: New test. * gcc.dg/tree-ssa/evrp3.c: New test. * gcc.dg/tree-ssa/pr20657.c: Check for the pattern in evrp dump. * gcc.dg/tree-ssa/pr22117.c: Likewise. * gcc.dg/tree-ssa/pr61839_2.c: Likewise. * gcc.dg/tree-ssa/pr64130.c: Likewise. * gcc.dg/tree-ssa/pr37508.c: Change the pattern to be checked as foling now happens early. * gcc.dg/tree-ssa/vrp04.c: Likewise. * gcc.dg/tree-ssa/vrp06.c: Likewise. * gcc.dg/tree-ssa/vrp16.c: Likewise. * gcc.dg/tree-ssa/vrp25.c: Likewise. * gcc.dg/tree-ssa/vrp67.c: Likewise. From-SVN: r240291
2016-09-06re PR tree-optimization/77479 (Compile time hog w/ -O2 (-Os))Richard Biener1-13/+19
2016-09-06 Richard Biener <rguenther@suse.de> PR tree-optimization/77479 * tree-vrp.c (update_value_range): Extend overflow handling to VARYING. * gcc.dg/torture/pr77479.c: New testcase. From-SVN: r240007
2016-08-23re PR middle-end/27336 (delete null checks in callers to nonnull functions)Richard Biener1-8/+3
2016-08-23 Richard Biener <rguenther@suse.de> PR tree-optimization/27336 * tree-vrp.c (infer_value_range): Handle stmts that can throw by looking for a non-EH edge. (process_assert_insertions_for): Likewise. * c-c++-common/pr27336.c: New testcase. From-SVN: r239684
2016-08-20tree-vrp.c (vrp_visit_assignment_or_call): Changed to Return VR.Kugan Vivekanandarajah1-160/+175
gcc/ChangeLog: 2016-08-20 Kugan Vivekanandarajah <kuganv@linaro.org> * tree-vrp.c (vrp_visit_assignment_or_call): Changed to Return VR. (vrp_visit_cond_stmt): Just sets TAKEN_EDGE_P. (vrp_visit_switch_stmt): Likewise. (extract_range_from_stmt): Factored out from vrp_visit_stmt. (extract_range_from_phi_node): Factored out from vrp_visit_phi_stmt. (vrp_visit_stmt): Use extract_range_from_stmt. (vrp_visit_phi_node): Use extract_range_from_phi_node. From-SVN: r239639
2016-08-20Makefile.in: Add tree-vrp.h to GTFILES.Kugan Vivekanandarajah1-34/+6
gcc/ChangeLog: 2016-08-20 Kugan Vivekanandarajah <kuganv@linaro.org> * Makefile.in: Add tree-vrp.h to GTFILES. * gengtype.c (open_base_files): Add tree-vrp.h. * asan.c: Add tree-vrp.h which now has the definition value_range_type. * builtins.c: Likewise. * fold-const.c: Likewise. * gimple-builder.c: Likewise. * gimple-laddress.c: Likewise. * hsa-gen.c: Likewise. * internal-fn.c: Likewise. * ssa.h: Likewise. * targhooks.c: Liewise, * tree-ssa-address.c: Likewise. * tree-ssanames.h (value_range_type: Move to tree-vrp.h. * tree-vrp.c (struct value_range): Move to tree-vrp.h * tree-vrp.h: New file. From-SVN: r239638
2016-08-20re PR tree-optimization/61839 (More optimize opportunity for VRP)Kugan Vivekanandarajah1-0/+96
gcc/testsuite/ChangeLog: 2016-08-20 Kugan Vivekanandarajah <kuganv@linaro.org> PR tree-optimization/61839 * gcc.dg/tree-ssa/pr61839_1.c: New test. * gcc.dg/tree-ssa/pr61839_2.c: New test. * gcc.dg/tree-ssa/pr61839_3.c: New test. * gcc.dg/tree-ssa/pr61839_4.c: New test. gcc/ChangeLog: 2016-08-20 Kugan Vivekanandarajah <kuganv@linaro.org> PR tree-optimization/61839 * tree-vrp.c (two_valued_val_range_p): New. (simplify_stmt_using_ranges): Convert CST BINOP VAR where VAR is two-valued to VAR == VAL1 ? (CST BINOP VAL1) : (CST BINOP VAL2). Also Convert VAR BINOP CST where VAR is two-valued to VAR == VAL1 ? (VAL1 BINOP CST) : (VAL2 BINOP CST). From-SVN: r239637
2016-08-17re PR tree-optimization/76490 (when use -O2 -fcheck-founds compiler appears ↵Richard Biener1-16/+30
to hang and consumes all memory) 2016-08-17 Richard Biener <rguenther@suse.de> PR tree-optimization/76490 * tree-vrp.c (update_value_range): Preserve overflow infinities when intersecting with ranges from get_range_info. (operand_less_p): Handle overflow infinities correctly. (value_range_constant_singleton): Use vrp_operand_equal_p to handle overflow max/min correctly. (vrp_valueize): Likewise. (union_ranges): Likewise. (intersect_ranges): Likewise. (vrp_visit_phi_node): Improve iteration limitation to only apply when we'll possibly re-visit the PHI via a changed argument on the backedge. * gfortran.fortran-torture/compile/pr76490.f90: New testcase. * gcc.dg/pr52904.c: XFAIL. From-SVN: r239529
2016-08-12tree-vrp.c (vrp_visit_phi_node): Allow a last iteration if the currently ↵Richard Biener1-27/+37
executable edges have fixed ranges. 2016-08-12 Richard Biener <rguenther@suse.de> * tree-vrp.c (vrp_visit_phi_node): Allow a last iteration if the currently executable edges have fixed ranges. Always go through update_value_range. From-SVN: r239404
2016-08-09Fix warning breaking profiled bootstrapAndi Kleen1-0/+3
This patch fixes an bootstrap error with autoprofiledbootstrap due to uninitiliazed variables, because the compiler cannot figure out they don't need to be initialized in an error path. Just always initialize them. gcc/: 2016-08-08 Andi Kleen <ak@linux.intel.com> * tree-vrp.c (get_single_symbol): Always initialize inv and neg. From-SVN: r239266
2016-08-05Improve forward jump threading of switch statements (PR18046)Patrick Palka1-0/+61
gcc/ChangeLog: PR tree-optimization/18046 * tree-ssa-threadedge.c: Include cfganal.h. (simplify_control_statement_condition): If simplifying a GIMPLE_SWITCH, replace the index operand of the GIMPLE_SWITCH with the dominating ASSERT_EXPR before handing it off to VRP. Mention that a CASE_LABEL_EXPR may be returned. (thread_around_empty_blocks): Adjust to handle simplify_control_statement_condition() returning a CASE_LABEL_EXPR. (thread_through_normal_block): Likewise. * tree-vrp.c (simplify_stmt_for_jump_threading): Simplify a switch statement by trying to determine which case label will be taken. gcc/testsuite/ChangeLog: PR tree-optimization/18046 * gcc.dg/tree-ssa/vrp105.c: New test. * gcc.dg/tree-ssa/vrp106.c: New test. From-SVN: r239181
2016-08-05re PR tree-optimization/72810 (error: type mismatch for case label in switch ↵Patrick Palka1-19/+24
statement) Fix PR tree-optimization/72810 gcc/ChangeLog: PR tree-optimization/72810 * tree-vrp.c (simplify_switch_using_ranges): Avoid changing the type of the case labels when truncating. gcc/testsuite/ChangeLog: PR tree-optimization/72810 * gcc.dg/tree-ssa/vrp110.c: New test. From-SVN: r239174
2016-08-05tree-vrp.c (extract_range_basic): Check cfun->after_inlining before folding ↵Kugan Vivekanandarajah1-1/+2
call to __builtin_constant_p with... gcc/ChangeLog: 2016-08-05 Kugan Vivekanandarajah <kuganv@linaro.org> * tree-vrp.c (extract_range_basic): Check cfun->after_inlining before folding call to __builtin_constant_p with parameters to false. From-SVN: r239162
2016-08-05Teach VRP to truncate the case ranges of a switchPatrick Palka1-1/+79
gcc/ChangeLog: * tree-vrp.c (simplify_switch_using_ranges): Try to truncate the case label ranges that partially overlap with OP's value range. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/vrp107.c: New test. * gcc.dg/tree-ssa/vrp108.c: New test. * gcc.dg/tree-ssa/vrp109.c: New test. From-SVN: r239157
2016-08-04tree-vrp.c (set_value_range): Use vrp_equiv_obstack with BITMAP_ALLOC.Kugan Vivekanandarajah1-10/+12
gcc/ChangeLog: 2016-08-04 Kugan Vivekanandarajah <kuganv@linaro.org> * tree-vrp.c (set_value_range): Use vrp_equiv_obstack with BITMAP_ALLOC. (add_equivalence): Likewise. (get_value_range): Allocate value range with vrp_value_range_pool. (vrp_initialize): Initialize vrp_equiv_obstack for equiv allocation. (vrp_finalize): Relase vrp_equiv_obstack and vrp_value_range_pool. From-SVN: r239113
2016-07-29re PR rtl-optimization/68217 (Wrong constant folding)Kugan Vivekanandarajah1-0/+18
gcc/ChangeLog: 2016-07-29 Kugan Vivekanandarajah <kuganv@linaro.org> PR middle-end/68217 * tree-vrp.c (extract_range_from_binary_expr_1): In case of signed & sign-bit-CST, generate [-INF, 0] instead of [-INF, INF]. gcc/testsuite/ChangeLog: 2016-07-29 Kugan Vivekanandarajah <kuganv@linaro.org> PR middle-end/68217 * gcc.dg/pr68217.c: New test. From-SVN: r238846
2016-07-26Minor changes in tree-vrp.cPatrick Palka1-2/+4
gcc/ChangeLog: * tree-vrp.c (dump_asserts_for): Print loc->expr instead of name. (extract_code_and_val_from_cond_with_ops): Verify that name is either cond_op0 or cond_op1. From-SVN: r238762
2016-07-26Teach VRP to register assertions along default switch labels (PR18046)Patrick Palka1-2/+60
gcc/ChangeLog: PR tree-optimization/18046 * genmodes.c (emit_mode_size_inline): Emit an assert that verifies that mode is a valid array index. (emit_mode_nuinits_inline): Likewise. (emit_mode_inner_inline): Likewise. (emit_mode_unit_size_inline): Likewise. (emit_mode_unit_precision_inline): Likewise. * tree-vrp.c: Include params.h. (find_switch_asserts): Register edge assertions for the default label which correspond to the anti-ranges of each case label. * params.def (PARAM_MAX_VRP_SWITCH_ASSERTIONS): New. * doc/invoke.texi: Document it. gcc/testsuite/ChangeLog: PR tree-optimization/18046 * gcc.dg/tree-ssa/ssa-dom-thread-6.c: Bump FSM count to 5. * gcc.dg/tree-ssa/vrp103.c: New test. * gcc.dg/tree-ssa/vrp104.c: New test. From-SVN: r238761
2016-07-21re PR tree-optimization/71947 (x ^ y not folded to 0 if x == y by DOM)Richard Biener1-4/+7
2016-07-21 Richard Biener <rguenther@suse.de> PR tree-optimization/71947 * tree-vrp.c (extract_range_from_assert): Singleton symbolic ranges have useful limit_vr information. * gcc.dg/tree-ssa/vrp102.c: New testcase. From-SVN: r238591
2016-07-21tree-chrec.c (convert_affine_scev): New parameter.Bin Cheng1-2/+2
* tree-chrec.c (convert_affine_scev): New parameter. Pass new arg. (chrec_convert_1, chrec_convert): Ditto. * tree-chrec.h (chrec_convert, convert_affine_scev): New parameter. * tree-scalar-evolution.c (interpret_rhs_expr): Pass new arg. * tree-vrp.c (adjust_range_with_scev): Ditto. * tree-ssa-loop-niter.c (idx_infer_loop_bounds): Ditto. (scev_var_range_cant_overflow): New function. (scev_probably_wraps_p): New parameter. Call above function. * tree-ssa-loop-niter.h (scev_probably_wraps_p): New parameter. gcc/testsuite * gcc.dg/tree-ssa/scev-15.c: New. From-SVN: r238586
2016-06-24internal-fn.c (expand_arith_set_overflow): New function.Jakub Jelinek1-0/+3
* internal-fn.c (expand_arith_set_overflow): New function. (expand_addsub_overflow, expand_neg_overflow, expand_mul_overflow): Use it. (expand_arith_overflow_result_store): Likewise. Handle precision smaller than mode precision. * tree-vrp.c (extract_range_basic): For imag part, handle properly signed 1-bit precision result. * doc/extend.texi (__builtin_add_overflow): Document that last argument can't be pointer to enumerated or boolean type. (__builtin_add_overflow_p): Document that last argument can't have enumerated or boolean type. * c-common.c (check_builtin_function_arguments): Require last argument of BUILT_IN_*_OVERFLOW_P to have INTEGER_TYPE type. Adjust wording of diagnostics for BUILT_IN_*_OVERLFLOW if the last argument is pointer to enumerated or boolean type. * c-c++-common/builtin-arith-overflow-1.c (generic_wrong_type, f3, f4): Adjust expected diagnostics. * c-c++-common/torture/builtin-arith-overflow.h (TP): New macro. (T): If OVFP is defined, redefine to TP. * c-c++-common/torture/builtin-arith-overflow-12.c: Adjust comment. * c-c++-common/torture/builtin-arith-overflow-p-1.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-2.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-3.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-4.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-5.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-6.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-7.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-8.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-9.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-10.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-11.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-12.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-13.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-14.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-15.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-16.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-17.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-18.c: New test. * c-c++-common/torture/builtin-arith-overflow-p-19.c: New test. * g++.dg/ext/builtin-arith-overflow-1.C: Pass 0 instead of C as last argument to __builtin_add_overflow_p. From-SVN: r237754
2016-06-14re PR tree-optimization/71521 (Regression in GCC-7.0.0's optimizer)Richard Biener1-1/+2
2016-06-14 Richard Biener <rguenther@suse.de> PR tree-optimization/71521 * tree-vrp.c (extract_range_from_binary_expr_1): Guard division int_const_binop against zero divisor. * gcc.dg/tree-ssa/vrp101.c: New testcase. From-SVN: r237425
2016-05-20tree-vrp.c (compare_values_warnv): Simplify handling of symbolic ranges by ↵Eric Botcazou1-108/+56
calling get_single_symbol and tidy up. * tree-vrp.c (compare_values_warnv): Simplify handling of symbolic ranges by calling get_single_symbol and tidy up. Look more closely into NAME + CST1 vs CST2 comparisons if type overflow is undefined. ada/ * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Signed_Integer_Subtype>: Make same-sized subtypes of signed base types signed. * gcc-interface/utils.c (make_type_from_size): Adjust to above change. (unchecked_convert): Likewise. From-SVN: r236548
2016-05-19re PR tree-optimization/71031 (ICE in extract_range_from_binary_expr_1, at ↵Marek Polacek1-9/+8
tree-vrp.c:2535 w/ -Os) PR tree-optimization/71031 * tree-vrp.c (extract_range_from_binary_expr_1): Turn assert into a condition and adjust the code a bit. * gcc.dg/tree-ssa/vrp100.c: New test. From-SVN: r236477
2016-05-17VRP: range info of new variablesMarc Glisse1-9/+12
2016-05-17 Marc Glisse <marc.glisse@inria.fr> gcc/ * tree-vrp.c (simplify_truth_ops_using_ranges): Set range information for new SSA_NAME. (simplify_conversion_using_ranges): Get range through get_range_info instead of get_value_range. gcc/testsuite/ * gcc.dg/tree-ssa/pr69270.c: Adjust. * gcc.dg/tree-ssa/vrp99.c: New testcase. From-SVN: r236336
2016-05-02Support <, <=, > and >= for offset_int and widest_intRichard Sandiford1-8/+8
offset_int and widest_int are supposed to be at least one bit wider than all the values they need to represent, with the extra bits being signs. Thus offset_int is effectively int128_t and widest_int is effectively intNNN_t, for target-dependent NNN. Because the types are signed, there's not really any need to specify a sign for operations like comparison. I think things would be clearer if we supported <, <=, > and >= for them (but not for wide_int, which doesn't have a sign). Tested on x86_64-linux-gnu and aarch64-linux-gnu. gcc/ * wide-int.h: Update offset_int and widest_int documentation. (WI_SIGNED_BINARY_PREDICATE_RESULT): New macro. (wi::binary_traits): Allow ordered comparisons between offset_int and offset_int, between widest_int and widest_int, and between either of these types and basic C types. (operator <, <=, >, >=): Define for the same combinations. * tree.h (tree_int_cst_lt): Use comparison operators instead of wi:: comparisons. (tree_int_cst_le): Likewise. * gimple-fold.c (fold_array_ctor_reference): Likewise. (fold_nonarray_ctor_reference): Likewise. * gimple-ssa-strength-reduction.c (record_increment): Likewise. * tree-affine.c (aff_comb_cannot_overlap_p): Likewise. * tree-parloops.c (try_transform_to_exit_first_loop_alt): Likewise. * tree-sra.c (completely_scalarize): Likewise. * tree-ssa-alias.c (stmt_kills_ref_p): Likewise. * tree-ssa-reassoc.c (extract_bit_test_mask): Likewise. * tree-vrp.c (extract_range_from_binary_expr_1): Likewise. (check_for_binary_op_overflow): Likewise. (search_for_addr_array): Likewise. * ubsan.c (ubsan_expand_objsize_ifn): Likewise. From-SVN: r235719
2016-04-21vrp: remove redundant has_single_use testsPatrick Palka1-19/+10
gcc/ChangeLog: * tree-vrp.c (register_edge_assert_for_2): Remove redundant has_single_use() tests. (register_edge_assert_for_1): Likewise. (find_assert_locations_1): Check the liveness bitmap instead of checking has_single_use(). From-SVN: r235352
2016-03-30PR tree-optimization/59124 (bogus -Warray-bounds warning)Patrick Palka1-0/+21
gcc/ChangeLog: PR tree-optimization/59124 * tree-vrp.c (register_edge_assert_for_2): For NAME != CST1 where NAME = A +- CST2 add the assertion A != (CST1 -+ CST2). gcc/testsuite/ChangeLog: PR tree-optimization/59124 * gcc.dg/Warray-bounds-19.c: New test. From-SVN: r234544
2016-03-03re PR tree-optimization/55936 (Missed VRP optimization)Richard Biener1-19/+21
2016-03-03 Richard Biener <rguenther@suse.de> PR tree-optimization/55936 * tree-vrp.c (compare_name_with_value): Add use_equiv_p parameter and guard unsafe equivalence use. (vrp_evaluate_conditional_warnv_with_ops): Always use safe equivalences but not via the quadratic compare_names helper. * gcc.dg/tree-ssa/vrp06.c: Remove XFAIL. From-SVN: r233928