aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
AgeCommit message (Collapse)AuthorFilesLines
2018-05-23re PR tree-optimization/85822 (Maybe wrong code in VRP since r249150)Yury Gribov1-5/+6
PR tree-optimization/85822 From-SVN: r260566
2018-03-19re PR tree-optimization/84933 (ICE in set_value_range, at tree-vrp.c:288 ↵Richard Biener1-2/+7
since r257852) 2018-03-19 Richard Biener <rguenther@suse.de> PR tree-optimization/84933 * tree-vrp.c (set_and_canonicalize_value_range): Treat out-of-bound values as -INF/INF when canonicalizing an ANTI_RANGE to a RANGE. * g++.dg/pr84933.C: New testcase. From-SVN: r258646
2018-02-13re PR tree-optimization/84321 (ice in intersect_range_with_nonzero_bits, at ↵Richard Sandiford1-20/+44
tree-vrp.c:213) 2018-02-12 Richard Sandiford <richard.sandiford@linaro.org> gcc/ PR tree-optimization/84321 * tree-vrp.c (intersect_range_with_nonzero_bits): Fix VR_ANTI_RANGE handling. Also check whether the anti-range contains any values that satisfy the mask; switch to a VR_RANGE if not. gcc/testsuite/ PR tree-optimization/84321 * gcc.dg/pr84321.c: New test. From-SVN: r257629
2018-02-08Use nonzero bits to refine range in split_constant_offset (PR 81635)Richard Sandiford1-0/+47
This patch is part 2 of the fix for PR 81635. It means that split_constant_offset can handle loops like: for (unsigned int i = 0; i < n; i += 4) { a[i] = ...; a[i + 1] = ...; } CCP records that "i" must have its low 2 bits clear, but we don't include this information in the range of "i", which remains [0, +INF]. I tried making set_nonzero_bits update the range info in the same way that set_range_info updates the nonzero bits, but it regressed cases like vrp117.c and made some other tests worse. vrp117.c has a multiplication by 10, so CCP can infer that the low bit of the result is clear. If we included that in the range, the range would go from [-INF, +INF] to [-INF, not-quite-+INF]. However, the multiplication is also known to overflow in all cases, so VRP saturates the result to [INT_MAX, INT_MAX]. This obviously creates a contradiction with the nonzero bits, and intersecting the new saturated range with an existing not-quite-+INF range would make us drop to VR_UNDEFINED. We're prepared to fold a comparison with an [INT_MAX, INT_MAX] value but not with a VR_UNDEFINED value. The other problems were created when intersecting [-INF, not-quite-+INF] with a useful VR_ANTI_RANGE like ~[-1, 1]. The intersection would keep the former range rather than the latter. The patch therefore keeps the adjustment local to split_constant_offset for now, but adds a helper routine so that it's easy to move this later. 2018-02-08 Richard Sandiford <richard.sandiford@linaro.org> gcc/ PR tree-optimization/81635 * wide-int.h (wi::round_down_for_mask, wi::round_up_for_mask): Declare. * wide-int.cc (wi::round_down_for_mask, wi::round_up_for_mask) (test_round_for_mask): New functions. (wide_int_cc_tests): Call test_round_for_mask. * tree-vrp.h (intersect_range_with_nonzero_bits): Declare. * tree-vrp.c (intersect_range_with_nonzero_bits): New function. * tree-data-ref.c (split_constant_offset_1): Use it to refine the range returned by get_range_info. gcc/testsuite/ PR tree-optimization/81635 * gcc.dg/vect/bb-slp-pr81635-3.c: New test. * gcc.dg/vect/bb-slp-pr81635-4.c: Likewise. From-SVN: r257491
2018-01-23-Warray-bounds: Fix false positive in some "switch" stmts (PR ↵David Malcolm1-2/+19
tree-optimization/83510) PR tree-optimization/83510 reports that r255649 (for PR tree-optimization/83312) introduced a false positive for -Warray-bounds for array accesses within certain switch statements: those for which value-ranges allow more than one case to be reachable, but for which one or more of the VR-unreachable cases contain out-of-range array accesses. In the reproducer, after the switch in f is inlined into g, we have 3 cases for the switch (case 9, case 10-19, and default), within a loop that ranges from 0..9. With both the old and new code, vr_values::simplify_switch_using_ranges clears the EDGE_EXECUTABLE flag on the edge to the "case 10-19" block. This happens during the dom walk within the substitute_and_fold_engine. With the old code, the clearing of that EDGE_EXECUTABLE flag led to the /* Skip blocks that were found to be unreachable. */ code in the old implementation of vrp_prop::check_all_array_refs skipping the "case 10-19" block. With the new code, we have a second dom walk, and that dom_walker's ctor sets all edges to be EDGE_EXECUTABLE, losing that information. Then, dom_walker::before_dom_children (here, the subclass' check_array_bounds_dom_walker::before_dom_children) can return one edge, if there's a unique successor edge, and dom_walker::walk filters the dom walk to just that edge. Here we have two VR-valid edges (case 9 and default), and an VR-invalid successor edge (case 10-19). There's no *unique* valid successor edge, and hence taken_edge is NULL, and the filtering in dom_walker::walk doesn't fire. Hence we've lost the filtering of the "case 10-19" BB, hence the false positive. The issue is that we have two dom walks: first within vr_values' substitute_and_fold_dom_walker (which has skip_unreachable_blocks == false), then another within vrp_prop::check_all_array_refs (with skip_unreachable_blocks == true). Each has different "knowledge" about ruling out edges due to value-ranges, but we aren't combining that information. The former "knows" about out-edges at a particular control construct (e.g. at a switch), the latter "knows" about dominance, but only about unique successors (hence the problem when two out of three switch cases are valid). This patch combines the information by preserving the EDGE_EXECUTABLE flags from the first dom walk, and using it in the second dom walk, potentially rejecting additional edges. Doing so fixes the false positive. I attempted an alternative fix, merging the two dom walks into one, but that led to crashes in identify_jump_threads, so I went with this, as a less invasive fix. gcc/ChangeLog: PR tree-optimization/83510 * domwalk.c (set_all_edges_as_executable): New function. (dom_walker::dom_walker): Convert bool param "skip_unreachable_blocks" to enum reachability. Move setup of edge flags to set_all_edges_as_executable and only do it when reachability is REACHABLE_BLOCKS. * domwalk.h (enum dom_walker::reachability): New enum. (dom_walker::dom_walker): Convert bool param "skip_unreachable_blocks" to enum reachability. (set_all_edges_as_executable): New decl. * graphite-scop-detection.c (gather_bbs::gather_bbs): Convert from false for "skip_unreachable_blocks" to ALL_BLOCKS for "reachability". * tree-ssa-dom.c (dom_opt_dom_walker::dom_opt_dom_walker): Likewise, but converting true to REACHABLE_BLOCKS. * tree-ssa-sccvn.c (sccvn_dom_walker::sccvn_dom_walker): Likewise. * tree-vrp.c (check_array_bounds_dom_walker::check_array_bounds_dom_walker): Likewise, but converting it to REACHABLE_BLOCKS_PRESERVING_FLAGS. (vrp_dom_walker::vrp_dom_walker): Likewise, but converting it to REACHABLE_BLOCKS. (vrp_prop::vrp_finalize): Call set_all_edges_as_executable if check_all_array_refs will be called. gcc/testsuite/ChangeLog: PR tree-optimization/83510 * gcc.c-torture/compile/pr83510.c: New test case. From-SVN: r256980
2018-01-11re PR tree-optimization/83435 (ICE in set_value_range, at tree-vrp.c:211)Richard Biener1-0/+2
2018-01-11 Richard Biener <rguenther@suse.de> PR tree-optimization/83435 * graphite.c (canonicalize_loop_form): Ignore fake loop exit edges. * graphite-scop-detection.c (scop_detection::get_sese): Likewise. * tree-vrp.c (add_assert_info): Drop TREE_OVERFLOW if they appear. * gcc.dg/graphite/pr83435.c: New testcase. From-SVN: r256535
2018-01-04Protect second call to extract_range_from_multiplicative_op_1Richard Sandiford1-1/+1
Following on from: * tree-vrp.c (extract_range_from_multiplicative_op_1): Assert for VR_RANGE only; don't allow VR_ANTI_RANGE. (extract_range_from_binary_expr_1): Don't call extract_range_from_multiplicative_op_1 if !range_int_cst_p. there was a later call to extract_range_from_multiplicative_op_1 too, that used a negative test for a symbolic (!is_gimple_min_invariant) range rather than a positive test for an integer range. 2017-11-04 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * tree-vrp.c (extract_range_from_binary_expr_1): Check range_int_cst_p rather than !symbolic_range_p before calling extract_range_from_multiplicative_op_1. From-SVN: r256262
2018-01-03Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r256169
2017-12-21poly_int: MEM_REF offsetsRichard Sandiford1-2/+3
This patch allows MEM_REF offsets to be polynomial, with mem_ref_offset now returning a poly_offset_int instead of an offset_int. The non-mechanical changes to callers of mem_ref_offset were handled by previous patches. 2017-12-21 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * fold-const.h (mem_ref_offset): Return a poly_offset_int rather than an offset_int. * tree.c (mem_ref_offset): Likewise. (build_simple_mem_ref_loc): Treat MEM_REF offsets as poly_ints. * builtins.c (get_object_alignment_2): Likewise. * expr.c (get_inner_reference, expand_expr_real_1): Likewise. * gimple-fold.c (get_base_constructor): Likewise. * gimple-ssa-strength-reduction.c (restructure_reference): Likewise. * gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Likewise. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::ipa_polymorphic_call_context): Likewise. * ipa-prop.c (compute_complex_assign_jump_func): Likewise. (get_ancestor_addr_info): Likewise. * ipa-param-manipulation.c (ipa_get_adjustment_candidate): Likewise. * match.pd: Likewise. * tree-data-ref.c (dr_analyze_innermost): Likewise. * tree-dfa.c (get_addr_base_and_unit_offset_1): Likewise. * tree-eh.c (tree_could_trap_p): Likewise. * tree-object-size.c (addr_object_size): Likewise. * tree-ssa-address.c (copy_ref_info): Likewise. * tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Likewise. (indirect_refs_may_alias_p): Likewise. * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Likewise. * tree-ssa.c (maybe_rewrite_mem_ref_base): Likewise. (non_rewritable_mem_ref_base): Likewise. * tree-vect-data-refs.c (vect_check_gather_scatter): Likewise. * tree-vrp.c (vrp_prop::check_array_ref): Likewise. * varasm.c (decode_addr_const): Likewise. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r255930
2017-12-20poly_int: get_addr_base_and_unit_offsetRichard Sandiford1-2/+2
This patch changes the values returned by get_addr_base_and_unit_offset from HOST_WIDE_INT to poly_int64. maxsize in gimple_fold_builtin_memory_op goes from HOST_WIDE_INT to poly_uint64 (rather than poly_int) to match the previous use of tree_fits_uhwi_p. 2017-12-20 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree-dfa.h (get_addr_base_and_unit_offset_1): Return the offset as a poly_int64_pod rather than a HOST_WIDE_INT. (get_addr_base_and_unit_offset): Likewise. * tree-dfa.c (get_addr_base_and_unit_offset_1): Likewise. (get_addr_base_and_unit_offset): Likewise. * doc/match-and-simplify.texi: Change off from HOST_WIDE_INT to poly_int64 in example. * fold-const.c (fold_binary_loc): Update call to get_addr_base_and_unit_offset. * gimple-fold.c (gimple_fold_builtin_memory_op): Likewise. (maybe_canonicalize_mem_ref_addr): Likewise. (gimple_fold_stmt_to_constant_1): Likewise. * gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Likewise. * ipa-param-manipulation.c (ipa_modify_call_arguments): Likewise. * match.pd: Likewise. * omp-low.c (lower_omp_target): Likewise. * tree-sra.c (build_ref_for_offset): Likewise. (build_debug_ref_for_model): Likewise. * tree-ssa-address.c (maybe_fold_tmr): Likewise. * tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Likewise. * tree-ssa-ccp.c (optimize_memcpy): Likewise. * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Likewise. (constant_pointer_difference): Likewise. * tree-ssa-loop-niter.c (expand_simple_operations): Likewise. * tree-ssa-phiopt.c (jump_function_from_stmt): Likewise. * tree-ssa-pre.c (create_component_ref_by_pieces_1): Likewise. * tree-ssa-sccvn.c (vn_reference_fold_indirect): Likewise. (vn_reference_maybe_forwprop_address, vn_reference_lookup_3): Likewise. (set_ssa_val_to): Likewise. * tree-ssa-strlen.c (get_addr_stridx, addr_stridxptr) (maybe_diag_stxncpy_trunc): Likewise. * tree-vrp.c (vrp_prop::check_array_ref): Likewise. * tree.c (build_simple_mem_ref_loc): Likewise. (array_at_struct_end_p): Likewise. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r255887
2017-12-20poly_int: tree constantsRichard Sandiford1-1/+18
This patch adds a tree representation for poly_ints. Unlike the rtx version, the coefficients are INTEGER_CSTs rather than plain integers, so that we can easily access them as poly_widest_ints and poly_offset_ints. The patch also adjusts some places that previously relied on "constant" meaning "INTEGER_CST". It also makes sure that the TYPE_SIZE agrees with the TYPE_SIZE_UNIT for vector booleans, given the existing: /* Several boolean vector elements may fit in a single unit. */ if (VECTOR_BOOLEAN_TYPE_P (type) && type->type_common.mode != BLKmode) TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (type->type_common.mode)); else TYPE_SIZE_UNIT (type) = int_const_binop (MULT_EXPR, TYPE_SIZE_UNIT (innertype), size_int (nunits)); 2017-12-20 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * doc/generic.texi (POLY_INT_CST): Document. * tree.def (POLY_INT_CST): New tree code. * treestruct.def (TS_POLY_INT_CST): New tree layout. * tree-core.h (tree_poly_int_cst): New struct. (tree_node): Add a poly_int_cst field. * tree.h (POLY_INT_CST_P, POLY_INT_CST_COEFF): New macros. (wide_int_to_tree, force_fit_type): Take a poly_wide_int_ref instead of a wide_int_ref. (build_int_cst, build_int_cst_type): Take a poly_int64 instead of a HOST_WIDE_INT. (build_int_cstu, build_array_type_nelts): Take a poly_uint64 instead of an unsigned HOST_WIDE_INT. (build_poly_int_cst, tree_fits_poly_int64_p, tree_fits_poly_uint64_p) (ptrdiff_tree_p): Declare. (tree_to_poly_int64, tree_to_poly_uint64): Likewise. Provide extern inline implementations if the target doesn't use POLY_INT_CST. (poly_int_tree_p): New function. (wi::unextended_tree): New class. (wi::int_traits <unextended_tree>): New override. (wi::extended_tree): Add a default constructor. (wi::extended_tree::get_tree): New function. (wi::widest_extended_tree, wi::offset_extended_tree): New typedefs. (wi::tree_to_widest_ref, wi::tree_to_offset_ref): Use them. (wi::tree_to_poly_widest_ref, wi::tree_to_poly_offset_ref) (wi::tree_to_poly_wide_ref): New typedefs. (wi::ints_for): Provide overloads for extended_tree and unextended_tree. (poly_int_cst_value, wi::to_poly_widest, wi::to_poly_offset) (wi::to_wide): New functions. (wi::fits_to_boolean_p, wi::fits_to_tree_p): Handle poly_ints. * tree.c (poly_int_cst_hasher): New struct. (poly_int_cst_hash_table): New variable. (tree_node_structure_for_code, tree_code_size, simple_cst_equal) (valid_constant_size_p, add_expr, drop_tree_overflow): Handle POLY_INT_CST. (initialize_tree_contains_struct): Handle TS_POLY_INT_CST. (init_ttree): Initialize poly_int_cst_hash_table. (build_int_cst, build_int_cst_type, build_invariant_address): Take a poly_int64 instead of a HOST_WIDE_INT. (build_int_cstu, build_array_type_nelts): Take a poly_uint64 instead of an unsigned HOST_WIDE_INT. (wide_int_to_tree): Rename to... (wide_int_to_tree_1): ...this. (build_new_poly_int_cst, build_poly_int_cst): New functions. (force_fit_type): Take a poly_wide_int_ref instead of a wide_int_ref. (wide_int_to_tree): New function that takes a poly_wide_int_ref. (ptrdiff_tree_p, tree_to_poly_int64, tree_to_poly_uint64) (tree_fits_poly_int64_p, tree_fits_poly_uint64_p): New functions. * lto-streamer-out.c (DFS::DFS_write_tree_body, hash_tree): Handle TS_POLY_INT_CST. * tree-streamer-in.c (lto_input_ts_poly_tree_pointers): Likewise. (streamer_read_tree_body): Likewise. * tree-streamer-out.c (write_ts_poly_tree_pointers): Likewise. (streamer_write_tree_body): Likewise. * tree-streamer.c (streamer_check_handled_ts_structures): Likewise. * asan.c (asan_protect_global): Require the size to be an INTEGER_CST. * cfgexpand.c (expand_debug_expr): Handle POLY_INT_CST. * expr.c (expand_expr_real_1, const_vector_from_tree): Likewise. * gimple-expr.h (is_gimple_constant): Likewise. * gimplify.c (maybe_with_size_expr): Likewise. * print-tree.c (print_node): Likewise. * tree-data-ref.c (data_ref_compare_tree): Likewise. * tree-pretty-print.c (dump_generic_node): Likewise. * tree-ssa-address.c (addr_for_mem_ref): Likewise. * tree-vect-data-refs.c (dr_group_sort_cmp): Likewise. * tree-vrp.c (compare_values_warnv): Likewise. * tree-ssa-loop-ivopts.c (determine_base_object, constant_multiple_of) (get_loop_invariant_expr, add_candidate_1, get_computation_aff_1) (force_expr_to_var_cost): Likewise. * tree-ssa-loop.c (for_each_index): Likewise. * fold-const.h (build_invariant_address, size_int_kind): Take a poly_int64 instead of a HOST_WIDE_INT. * fold-const.c (fold_negate_expr_1, const_binop, const_unop) (fold_convert_const, multiple_of_p, fold_negate_const): Handle POLY_INT_CST. (size_binop_loc): Likewise. Allow int_const_binop_1 to fail. (int_const_binop_2): New function, split out from... (int_const_binop_1): ...here. Handle POLY_INT_CST. (size_int_kind): Take a poly_int64 instead of a HOST_WIDE_INT. * expmed.c (make_tree): Handle CONST_POLY_INT_P. * gimple-ssa-strength-reduction.c (slsr_process_add) (slsr_process_mul): Check for INTEGER_CSTs before using them as candidates. * stor-layout.c (bits_from_bytes): New function. (bit_from_pos): Use it. (layout_type): Likewise. For vectors, multiply the TYPE_SIZE_UNIT by BITS_PER_UNIT to get the TYPE_SIZE. * tree-cfg.c (verify_expr, verify_types_in_gimple_reference): Allow MEM_REF and TARGET_MEM_REF offsets to be a POLY_INT_CST. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r255863
2017-12-14vrp_prop: Use dom_walker for -Warray-bounds (PR tree-optimization/83312)David Malcolm1-29/+47
gcc/ChangeLog: PR tree-optimization/83312 * domwalk.h (dom_walker::dom_walker): Fix typo in comment. * tree-cfg.c (find_taken_edge): Update to handle NULL_TREE for "val" param, and to cope with arbitrary basic blocks. (find_taken_edge_cond_expr): Add "cond_stmt" param and use it to handle NULL_TREE for "val", dropping "bb" param. (find_taken_edge_switch_expr): Make "switch_stmt" param const and drop "bb" param. Handle NULL_TREE for "val". (find_case_label_for_value): Make "switch_stmt" param const. * tree-vrp.c (class check_array_bounds_dom_walker): New subclass of dom_walker. (vrp_prop::check_all_array_refs): Reimplement as... (check_array_bounds_dom_walker::before_dom_children): ...this new vfunc. Replace linear search through BB block list, excluding those with non-executable in-edges via dominator walk. gcc/testsuite/ChangeLog: PR tree-optimization/83312 * gcc.dg/pr83312.c: New test case. From-SVN: r255649
2017-12-12re PR tree-optimization/83298 (wrong code at -O1, -O2 and -O3 on ↵Jeff Law1-1/+1
x86_64-linux-gnu) PR tree-optimization/83298 PR tree-optimization/83362 PR tree-optimization/83383 * gimple-ssa-evrp-analyze.h (class evrp_range_analyzer): Make push_value_range a public interface. Add new argument to record_ranges_from_stmt. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_stmt): Add new argument. Update comments. Handle recording temporary equivalences. * tree-ssa-dom.c (dom_opt_opt_walker::before_dom_children): Add new argument to call to evrp_range_analyzer::record_ranges_from_stmt. * gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children): Likewise. * tree-ssa-threadedge.c: Include alloc-pool.h, vr-values.h and gimple-ssa-evrp-analyze.h. (record_temporary_equivalences_from_phis): Add new argument. When the PHI arg is an SSA_NAME, set the result's range to the range of the PHI arg. (record_temporary_equivalences_from_stmts_at_dest): Record ranges from statements too. (thread_through_normal_block): Accept new argument, evrp_range_analyzer. Pass it down to children as needed. (thread_outgoing_edges): Likewise. (thread_across_edge): Likewise. Push/pop range state as needed. * tree-ssa-threadedge.h (thread_outgoing_edges): Update prototype. PR tree-optimization/83298 PR tree-optimization/83362 PR tree-optimization/83383 * gcc.c-torture/execute/pr83298.c: New test. * gcc.c-torture/execute/pr83362.c New test. * gcc.c-torture/execute/pr83383.c New test. From-SVN: r255593
2017-11-28re PR tree-optimization/80776 (-Wformat-overflow false positive for %d on ↵Richard Biener1-4/+3
integer bounded by __builtin_unreachable) 2017-11-28 Richard Biener <rguenther@suse.de> PR tree-optimization/80776 * gimple-ssa-evrp-analyze.h (evrp_range_analyzer::set_ssa_range_info): Declare. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::set_ssa_range_info): New function. (evrp_range_analyzer::record_ranges_from_incoming_edges): If the incoming edge is an effective fallthru because the other edge only reaches a __builtin_unreachable () then record ranges derived from the controlling condition in SSA info. (evrp_range_analyzer::record_ranges_from_phis): Use set_ssa_range_info. (evrp_range_analyzer::record_ranges_from_stmt): Likewise. * gcc.dg/pr80776-1.c: New testcase. * gcc.dg/pr80776-2.c: Likewise. From-SVN: r255201
2017-11-28re PR target/83158 (gcc.target/i386/pr78057.c fail)Richard Biener1-3/+6
2017-11-28 Richard Biener <rguenther@suse.de> PR tree-optimization/83158 * tree-vrp.c (intersect_ranges): Prefer ~[0, 0] in a few more cases. From-SVN: r255190
2017-11-22gimple-ssa-evrp-analyze.c (evrp_range_analyzer::try_find_new_range): Use new ↵Jeff Law1-5/+9
method allocate_value_range rather than accessing the... * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::try_find_new_range): Use new method allocate_value_range rather than accessing the vrp_value_range_pool data member directly. * tree-vrp.c (simplify_stmt_for_jump_threading): Tweak slightly to use extract_range_from_stmt method to avoid need for extract_range_from_assignment method. (vrp_prop::vrp_finalize): Use set_lattice_propagation_complete method rather than setting values_propgated data member directly. * vr-values.h (class vr_values): Privatize vrp_value_range_pool, and values propagated data members and extract_range_from_assignment method. Reorder private data members to conform to standards. Add new methods set_lattice_propagation_complete and allocate_value_range. From-SVN: r255086
2017-11-22re PR tree-optimization/83044 (ice in contains_struct_check)Jakub Jelinek1-19/+27
PR tree-optimization/83044 * tree-vrp.c (vrp_prop::check_array_ref): If eltsize is not INTEGER_CST or is 0, clear up_bound{,_p1} and later ignore tests that need the upper bound. Subtract offset from get_addr_base_and_unit_offset only if positive and subtract it before division by eltsize rather than after it. * gcc.dg/pr83044.c: New test. * c-c++-common/Warray-bounds.c (fb): Fix up MAX value. From-SVN: r255054
2017-11-16PR tree-optimization/82588 - missing -Warray-bounds on a excessively large indexMartin Sebor1-16/+48
PR tree-optimization/82588 - missing -Warray-bounds on a excessively large index PR tree-optimization/82583 - missing -Warray-bounds on out-of-bounds inner indic gcc/ChangeLog: PR tree-optimization/82588 PR tree-optimization/82583 * tree-vrp.c (check_array_ref): Handle flexible array members, string literals, and inner indices. (search_for_addr_array): Add detail to diagnostics. gcc/testsuite/ChangeLog: PR tree-optimization/82588 PR tree-optimization/82583 * c-c++-common/Warray-bounds.c: New test. * gcc.dg/Warray-bounds-11.c: Adjust. * gcc.dg/Warray-bounds-22.c: New test. From-SVN: r254830
2017-11-14vr-values.c: New file with contents extracted from tree-vrp.c.Jeff Law1-4181/+31
* vr-values.c: New file with contents extracted from tree-vrp.c. * Makefile.in (OBJS): Add vr-values.o * tree-vrp.h (set_value_range_to_nonnull): Prototype. (set_value_range, set_and_canonicalize_value_range): Likewise. (vrp_bitmap_equal_p, range_is_nonnull): Likewise. (value_range_constant_singleton, symbolic_range_p): Likewise. (compare_values, compare_values_warnv, vrp_val_is_min): Likewise. (vrp_val_is_max, copy_value_range, set_value_range_to_value): Likewise. (extract_range_from_binary_expr_1, vrp_val_min, vrp_val_max): Likewise. (set_value_range_to_null, range_int_cst_p, opreand_less_p): Likewise. (find_case_label_range, find_case_label_index): Likewise. (zero_nonzero_bits_from_vr, overflow_comparison_p): Likewise. (range_int_cst_singleton_p, value_inside_range): Likewise. (get_single_symbol): Likewise. (switch_update): Move structure definition here. (to_remove_edges, to_update_switch_stmts): Provide externs. * tree-vrp.c: Move all methods for vr-values class to vr-values.c (vrp_val_max, vrp_val_min, vrp_val_is_max): Make externally visible. (vrp_val_is_min, set_value_range): Likewise. (set_and_canonicalize_value_range, copy_value_range): Likewise. (set_value_range_to_value, set_value_range_to_nonnull): Likewise. (set_value_range_to_null, vrp_bitmap_equal_p): Likewise. (range_is_nonnull, range_int_cst_p): Likewwise. (range_int_cst_singleton_p, symbolic_range_p): Likewise. (get_single_symbol, operand_less_p): Likewise (compare_values_warnv, compare_values): Likewise. (value_inside_range, value_range_constant_singleton): Likewise. (zero_nonzero_bitgs_from_vr): Likewise. (extract_range_from_binary_expr_1): Likewise. (overflow_comparison_p): Likewise. (to_remove_edges, to_update_switch_stmts): Likewise. (find_case_label-index, find_case_label_range): Likewise. (switch_update, set_value_range_to_nonnegative): Remove. (set_value_range_to_truthvalue): Likewise. (symbolic_range_based_on_p, gimple_assign_nonzero_p): Likewise. (gimple_stmt_nonzero_p, compare_ranges): Likewise. (compare_range_with_value, vrp_valueize, vrp_valueize_1): Likewise. (find_case_label_ranges, test_for_singularity): Likewise. (range_fits_type_p, simplify_conversion_using_ranges): LIkewise. (x_vr_values): Move to its remaining use site. From-SVN: r254747
2017-11-10vr-values.h (VR_INITIALIZER): Move #define here.Jeff Law1-594/+6
* vr-values.h (VR_INITIALIZER): Move #define here. * gimple-ssa-evrp.c: New file with contents extracted from tree-vrp.c * Makefile.in (OBJS): Add tree-evrp.o * tree-vrp.h (assert_info): Move structure definition here. (set_value_range_to_varying): Prototype. (vrp_operand_equal_p, range_includes_zero_p): Likewise. (infer_value_range, register_edge_assert_for): Likewise. (stmt_interesting_for_vrp): Likewise. * tree-vrp.c: Move all methods for evrp class into tree-evrp.c. (set_value_range_to_varying): No longer static. (vrp_operand_equal_p, range_includes_zero_p): Likewise. (infer_value_range, register_edge_assert_for): Likewise. From-SVN: r254639
2017-11-09vr-values.h: New file with vr_values class.Jeff Law1-194/+258
* vr-values.h: New file with vr_values class. * tree-vrp.c: Include vr-values.h (vrp_value_range_pool, vrp_equiv_obstack, num_vr_values): Move static data objects into the vr_values class. (vr_value, values_propagated, vr_phi_edge_counts): Likewise. (get_value_range): Make it a member function within vr_values class. (set_defs_to_varying, update_value_range, add_equivalence): Likewise. (vrp_stmt_computes_nonzero_p, op_with_boolean_value_range_p): Likewise. (op_with_constant_singleton_value_range): Likewise. (extract_range_for_var_from_comparison_expr): Likewise. (extract_range_from_assert, extract_range_from_ssa_name): Likewise. (extract_range_from_binary_expr): Likewise. (extract_range_from_unary_expr): Likewise. (extract_range_from_cond_expr, extrat_range_from_comparison): Likewise. (check_for_binary_op_overflow, extract_range_basic): Likewise. (extract_range_from_assignment, adjust_range_with_scev): Likewise. (dump_all_value_ranges, get_vr_for_comparison): Likewise. (compare_name_with_value, compare_names): Likewise. (vrp_evaluate_conditional_warnv_with_ops_using_ranges): Likewise. (vrp_evaluate_conditional_warnv_with_ops): Likewise. Remove prototype. (vrp_evaluate_conditional, vrp_visit_cond_stmt): Likewise. (vrp_visit_switch_stmt, extract_range_from_stmt): Likewise. (extract_range_from_phi_node): Likewise. (simplify_truth_ops_using_ranges): Likewise. (simplify_div_or_mod_using_ranges): Likewise. (simplify_min_or_max_using_ranges, simplify_abs_using_ranges): Likewise. (simplify_bit_ops_using_ranges, simplify_cond_using_ranges_1): Likewise. (simplify_cond_using_ranges_2, simplify_switch_using_ranges): Likewise. (simplify_float_conversion_using_ranges): Likewise. (simplify_internal_call_using_ranges): Likewise. (two_valued_val_range_p, simplify_stmt_using_ranges): Likewise. (vrp_visit_assignment_or_call): Likewise. Smuggle class instance poitner via x_vr_values for calls into gimple folder. (vrp_initialize_lattice): Make this the vr_values ctor. (vrp_free_lattice): Make this the vr_values dtor. (set_vr_value): New function. (class vrp_prop): Add vr_values data member. Add various member functions as well as member functions that delegate to vr_values. (check_array_ref): Make a member function within vrp_prop class. (search_for_addr_array, vrp_initialize): Likewise. (vrp_finalize): Likewise. Revamp to avoid direct access to vr_value, values_propagated, etc. (check_array_bounds): Extract vrp_prop class instance pointer from walk info structure. Use it to call member functions. (check_all_array_refs): Make a member function within vrp_prop class. Smuggle class instance pointer via walk info structure. (x_vr_values): New local static. (vrp_valueize): Use x_vr_values to get class instance. (vr_valueize_1): Likewise. (class vrp_folder): Add vr_values data member. Add various member functions as well as member functions that delegate to vr_values. (fold_predicate_in): Make a mber fucntion within vrp_folder class. (simplify_stmt_for_jump_threading): Extract smuggled vr_values class instance from vr_values. Use it to call member functions. (vrp_dom_walker): Add vr_values data member. (vrp_dom_walker::after_dom_children): Smuggle vr_values class instance via x_vr_values. (identify_jump_threads): Accept vr_values as argument. Store it into the walker structure. (evrp_dom_walker): Add vr_values class data member. Add various delegators. (evrp_dom_walker::try_find_new_range): Use vr_values data member to access the memory allocator. (evrp_dom_walker::before_dom_children): Store vr_values class instance into the vrp_folder class. (evrp_dom_walker::push_value_range): Rework to avoid direct access to num_vr_values and vr_value. (evrp_dom_walker::pop_value_range): Likewise. (execute_early_vrp): Remove call to vrp_initialize_lattice. Use vr_values to get to dump_all_value_ranges member function. Remove call to vrp_free_lattice. Call vrp_initialize, vrp_finalize, and simplify_cond_using_ranges_2 via vrp_prop class instance. Pass vr_values class instance down to identify_jump_threads. Remove call to vrp_free_lattice. (debug_all_value_ranges): Remove. From-SVN: r254613
2017-11-09tree-vrp.c (vrp_prop): Move class to earlier point in the file.Jeff Law1-14/+14
* tree-vrp.c (vrp_prop): Move class to earlier point in the file. (vrp_folder): Likewise. From-SVN: r254612
2017-11-09tree-vrp.c (set_value_range): Do not reference vrp_equiv_obstack.Jeff Law1-3/+8
* tree-vrp.c (set_value_range): Do not reference vrp_equiv_obstack. Get it from the existing bitmap instead. (vrp_intersect_ranges_1): Likewise. From-SVN: r254611
2017-11-06Rework vrp_int_const_binop interfaceRichard Sandiford1-83/+60
...to avoid a warning about uninitialised wide_ints. 2017-11-06 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * tree-vrp.c (vrp_int_const_binop): Return true on success and return the value by pointer. (extract_range_from_multiplicative_op_1): Update accordingly. Return as soon as an operation fails. From-SVN: r254436
2017-11-03cfganal.c (single_pred_edge_ignoring_loop_edges): New function extracted ↵Jeff Law1-19/+5
from tree-ssa-dom.c. * cfganal.c (single_pred_edge_ignoring_loop_edges): New function extracted from tree-ssa-dom.c. * cfganal.h (single_pred_edge_ignoring_loop_edges): Prototype. * tree-ssa-dom.c (single_incoming_edge_ignoring_loop_edges): Remove. (record_equivalences_from_incoming_edge): Add additional argument to single_pred_edge_ignoring_loop_edges call. * tree-ssa-uncprop.c (single_incoming_edge_ignoring_loop_edges): Remove. (uncprop_dom_walker::before_dom_children): Add additional argument to single_pred_edge_ignoring_loop_edges call. * tree-ssa-sccvn.c (sccvn_dom_walker::before_dom_children): Use single_pred_edge_ignoring_loop_edges rather than open coding. * tree-vrp.c (evrp_dom_walker::before_dom_children): Similarly. From-SVN: r254383
2017-11-01tree-ssa-ccp.c (ccp_folder): New class derived from substitute_and_fold_engine.Jeff Law1-5/+25
* tree-ssa-ccp.c (ccp_folder): New class derived from substitute_and_fold_engine. (ccp_folder::get_value): New member function. (ccp_folder::fold_stmt): Renamed from ccp_fold_stmt. (ccp_fold_stmt): Remove prototype. (ccp_finalize): Call substitute_and_fold from the ccp_class. * tree-ssa-copy.c (copy_folder): New class derived from substitute_and_fold_engine. (copy_folder::get_value): Renamed from get_value. (fini_copy_prop): Call substitute_and_fold from copy_folder class. * tree-vrp.c (vrp_folder): New class derived from substitute_and_fold_engine. (vrp_folder::fold_stmt): Renamed from vrp_fold_stmt. (vrp_folder::get_value): New member function. (vrp_finalize): Call substitute_and_fold from vrp_folder class. (evrp_dom_walker::before_dom_children): Similarly for replace_uses_in. * tree-ssa-propagate.h (substitute_and_fold_engine): New class to provide a class interface to folder/substitute routines. (ssa_prop_fold_stmt_fn): Remove typedef. (ssa_prop_get_value_fn): Likewise. (subsitute_and_fold): Remove prototype. (replace_uses_in): Likewise. * tree-ssa-propagate.c (substitute_and_fold_engine::replace_uses_in): Renamed from replace_uses_in. Call the virtual member function (substitute_and_fold_engine::replace_phi_args_in): Similarly. (substitute_and_fold_dom_walker): Remove initialization of data member entries for calbacks. Add substitute_and_fold_engine member and initialize it. (substitute_and_fold_dom_walker::before_dom_children0: Use the member functions for get_value, replace_phi_args_in c replace_uses_in, and fold_stmt calls. (substitute_and_fold_engine::substitute_and_fold): Renamed from substitute_and_fold. Remove assert. Update ctor call. From-SVN: r254330
2017-11-01tree-ssa-propagate.h (ssa_prop_visit_stmt_fn): Remove typedef.Jeff Law1-5/+13
* tree-ssa-propagate.h (ssa_prop_visit_stmt_fn): Remove typedef. (ssa_prop_visit_phi_fn): Likewise. (class ssa_propagation_engine): New class to provide an interface into ssa_propagate. * tree-ssa-propagate.c (ssa_prop_visit_stmt): Remove file scoped variable. (ssa_prop_visit_phi): Likewise. (ssa_propagation_engine::simulate_stmt): Moved into class. Call visit_phi/visit_stmt from the class rather than via file scoped static variables. (ssa_propagation_engine::simulate_block): Moved into class. (ssa_propagation_engine::process_ssa_edge_worklist): Similarly. (ssa_propagation_engine::ssa_propagate): Similarly. No longer set file scoped statics for the visit_stmt/visit_phi callbacks. * tree-complex.c (complex_propagate): New class derived from ssa_propagation_engine. (complex_propagate::visit_stmt): Renamed from complex_visit_stmt. (complex_propagate::visit_phi): Renamed from complex_visit_phi. (tree_lower_complex): Call ssa_propagate via the complex_propagate class. * tree-ssa-ccp.c: (ccp_propagate): New class derived from ssa_propagation_engine. (ccp_propagate::visit_phi): Renamed from ccp_visit_phi_node. (ccp_propagate::visit_stmt): Renamed from ccp_visit_stmt. (do_ssa_ccp): Call ssa_propagate from the ccp_propagate class. * tree-ssa-copy.c (copy_prop): New class derived from ssa_propagation_engine. (copy_prop::visit_stmt): Renamed from copy_prop_visit_stmt. (copy_prop::visit_phi): Renamed from copy_prop_visit_phi_node. (execute_copy_prop): Call ssa_propagate from the copy_prop class. * tree-vrp.c (vrp_prop): New class derived from ssa_propagation_engine. (vrp_prop::visit_stmt): Renamed from vrp_visit_stmt. (vrp_prop::visit_phi): Renamed from vrp_visit_phi_node. (execute_vrp): Call ssa_propagate from the vrp_prop class. From-SVN: r254329
2017-10-27tree-vrp.c (check_all_array_refs): Do not use wi->info to smuggle gimple ↵Jeff Law1-7/+1
statement locations. * tree-vrp.c (check_all_array_refs): Do not use wi->info to smuggle gimple statement locations. (check_array_bounds): Corresponding changes. Get the statement's location directly from wi->stmt. From-SVN: r254154
2017-10-10Require wi::to_wide for treesRichard Sandiford1-95/+125
The wide_int routines allow things like: wi::add (t, 1) to add 1 to an INTEGER_CST T in its native precision. But we also have: wi::to_offset (t) // Treat T as an offset_int wi::to_widest (t) // Treat T as a widest_int Recently we also gained: wi::to_wide (t, prec) // Treat T as a wide_int in preccision PREC This patch therefore requires: wi::to_wide (t) when operating on INTEGER_CSTs in their native precision. This is just as efficient, and makes it clearer that a deliberate choice is being made to treat the tree as a wide_int in its native precision. This also removes the inconsistency that a) INTEGER_CSTs in their native precision can be used without an accessor but must use wi:: functions instead of C++ operators b) the other forms need an explicit accessor but the result can be used with C++ operators. It also helps with SVE, where there's the additional possibility that the tree could be a runtime value. 2017-10-10 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * wide-int.h (wide_int_ref_storage): Make host_dependent_precision a template parameter. (WIDE_INT_REF_FOR): Update accordingly. * tree.h (wi::int_traits <const_tree>): Delete. (wi::tree_to_widest_ref, wi::tree_to_offset_ref): New typedefs. (wi::to_widest, wi::to_offset): Use them. Expand commentary. (wi::tree_to_wide_ref): New typedef. (wi::to_wide): New function. * calls.c (get_size_range): Use wi::to_wide when operating on trees as wide_ints. * cgraph.c (cgraph_node::create_thunk): Likewise. * config/i386/i386.c (ix86_data_alignment): Likewise. (ix86_local_alignment): Likewise. * dbxout.c (stabstr_O): Likewise. * dwarf2out.c (add_scalar_info, gen_enumeration_type_die): Likewise. * expr.c (const_vector_from_tree): Likewise. * fold-const-call.c (host_size_t_cst_p, fold_const_call_1): Likewise. * fold-const.c (may_negate_without_overflow_p, negate_expr_p) (fold_negate_expr_1, int_const_binop_1, const_binop) (fold_convert_const_int_from_real, optimize_bit_field_compare) (all_ones_mask_p, sign_bit_p, unextend, extract_muldiv_1) (fold_div_compare, fold_single_bit_test, fold_plusminus_mult_expr) (pointer_may_wrap_p, expr_not_equal_to, fold_binary_loc) (fold_ternary_loc, multiple_of_p, fold_negate_const, fold_abs_const) (fold_not_const, round_up_loc): Likewise. * gimple-fold.c (gimple_fold_indirect_ref): Likewise. * gimple-ssa-warn-alloca.c (alloca_call_type_by_arg): Likewise. (alloca_call_type): Likewise. * gimple.c (preprocess_case_label_vec_for_gimple): Likewise. * godump.c (go_output_typedef): Likewise. * graphite-sese-to-poly.c (tree_int_to_gmp): Likewise. * internal-fn.c (get_min_precision): Likewise. * ipa-cp.c (ipcp_store_vr_results): Likewise. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::ipa_polymorphic_call_context): Likewise. * ipa-prop.c (ipa_print_node_jump_functions_for_edge): Likewise. (ipa_modify_call_arguments): Likewise. * match.pd: Likewise. * omp-low.c (scan_omp_1_op, lower_omp_ordered_clauses): Likewise. * print-tree.c (print_node_brief, print_node): Likewise. * stmt.c (expand_case): Likewise. * stor-layout.c (layout_type): Likewise. * tree-affine.c (tree_to_aff_combination): Likewise. * tree-cfg.c (group_case_labels_stmt): Likewise. * tree-data-ref.c (dr_analyze_indices): Likewise. (prune_runtime_alias_test_list): Likewise. * tree-dump.c (dequeue_and_dump): Likewise. * tree-inline.c (remap_gimple_op_r, copy_tree_body_r): Likewise. * tree-predcom.c (is_inv_store_elimination_chain): Likewise. * tree-pretty-print.c (dump_generic_node): Likewise. * tree-scalar-evolution.c (iv_can_overflow_p): Likewise. (simple_iv_with_niters): Likewise. * tree-ssa-address.c (addr_for_mem_ref): Likewise. * tree-ssa-ccp.c (ccp_finalize, evaluate_stmt): Likewise. * tree-ssa-loop-ivopts.c (constant_multiple_of): Likewise. * tree-ssa-loop-niter.c (split_to_var_and_offset) (refine_value_range_using_guard, number_of_iterations_ne_max) (number_of_iterations_lt_to_ne, number_of_iterations_lt) (get_cst_init_from_scev, record_nonwrapping_iv) (scev_var_range_cant_overflow): Likewise. * tree-ssa-phiopt.c (minmax_replacement): Likewise. * tree-ssa-pre.c (compute_avail): Likewise. * tree-ssa-sccvn.c (vn_reference_fold_indirect): Likewise. (vn_reference_maybe_forwprop_address, valueized_wider_op): Likewise. * tree-ssa-structalias.c (get_constraint_for_ptr_offset): Likewise. * tree-ssa-uninit.c (is_pred_expr_subset_of): Likewise. * tree-ssanames.c (set_nonzero_bits, get_nonzero_bits): Likewise. * tree-switch-conversion.c (collect_switch_conv_info, array_value_type) (dump_case_nodes, try_switch_expansion): Likewise. * tree-vect-loop-manip.c (vect_gen_vector_loop_niters): Likewise. (vect_do_peeling): Likewise. * tree-vect-patterns.c (vect_recog_bool_pattern): Likewise. * tree-vect-stmts.c (vectorizable_load): Likewise. * tree-vrp.c (compare_values_warnv, vrp_int_const_binop): Likewise. (zero_nonzero_bits_from_vr, ranges_from_anti_range): Likewise. (extract_range_from_binary_expr_1, adjust_range_with_scev): Likewise. (overflow_comparison_p_1, register_edge_assert_for_2): Likewise. (is_masked_range_test, find_switch_asserts, maybe_set_nonzero_bits) (vrp_evaluate_conditional_warnv_with_ops, intersect_ranges): Likewise. (range_fits_type_p, two_valued_val_range_p, vrp_finalize): Likewise. (evrp_dom_walker::before_dom_children): Likewise. * tree.c (cache_integer_cst, real_value_from_int_cst, integer_zerop) (integer_all_onesp, integer_pow2p, integer_nonzerop, tree_log2) (tree_floor_log2, tree_ctz, mem_ref_offset, tree_int_cst_sign_bit) (tree_int_cst_sgn, get_unwidened, int_fits_type_p): Likewise. (get_type_static_bounds, num_ending_zeros, drop_tree_overflow) (get_range_pos_neg): Likewise. * ubsan.c (ubsan_expand_ptr_ifn): Likewise. * config/darwin.c (darwin_mergeable_constant_section): Likewise. * config/aarch64/aarch64.c (aapcs_vfp_sub_candidate): Likewise. * config/arm/arm.c (aapcs_vfp_sub_candidate): Likewise. * config/avr/avr.c (avr_fold_builtin): Likewise. * config/bfin/bfin.c (bfin_local_alignment): Likewise. * config/msp430/msp430.c (msp430_attr): Likewise. * config/nds32/nds32.c (nds32_insert_attributes): Likewise. * config/powerpcspe/powerpcspe-c.c (altivec_resolve_overloaded_builtin): Likewise. * config/powerpcspe/powerpcspe.c (rs6000_aggregate_candidate) (rs6000_expand_ternop_builtin): Likewise. * config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): Likewise. * config/rs6000/rs6000.c (rs6000_aggregate_candidate): Likewise. (rs6000_expand_ternop_builtin): Likewise. * config/s390/s390.c (s390_handle_hotpatch_attribute): Likewise. gcc/ada/ * gcc-interface/decl.c (annotate_value): Use wi::to_wide when operating on trees as wide_ints. gcc/c/ * c-parser.c (c_parser_cilk_clause_vectorlength): Use wi::to_wide when operating on trees as wide_ints. * c-typeck.c (build_c_cast, c_finish_omp_clauses): Likewise. (c_tree_equal): Likewise. gcc/c-family/ * c-ada-spec.c (dump_generic_ada_node): Use wi::to_wide when operating on trees as wide_ints. * c-common.c (pointer_int_sum): Likewise. * c-pretty-print.c (pp_c_integer_constant): Likewise. * c-warn.c (match_case_to_enum_1): Likewise. (c_do_switch_warnings): Likewise. (maybe_warn_shift_overflow): Likewise. gcc/cp/ * cvt.c (ignore_overflows): Use wi::to_wide when operating on trees as wide_ints. * decl.c (check_array_designated_initializer): Likewise. * mangle.c (write_integer_cst): Likewise. * semantics.c (cp_finish_omp_clause_depend_sink): Likewise. gcc/fortran/ * target-memory.c (gfc_interpret_logical): Use wi::to_wide when operating on trees as wide_ints. * trans-const.c (gfc_conv_tree_to_mpz): Likewise. * trans-expr.c (gfc_conv_cst_int_power): Likewise. * trans-intrinsic.c (trans_this_image): Likewise. (gfc_conv_intrinsic_bound): Likewise. (conv_intrinsic_cobound): Likewise. gcc/lto/ * lto.c (compare_tree_sccs_1): Use wi::to_wide when operating on trees as wide_ints. gcc/objc/ * objc-act.c (objc_decl_method_attributes): Use wi::to_wide when operating on trees as wide_ints. From-SVN: r253595
2017-10-09Allow non-wi <op> wiRichard Sandiford1-8/+8
This patch uses global rather than member operators for wide-int.h, so that the first operand can be a non-wide-int type. The patch also removes the and_not and or_not member functions. It was already inconsistent to have member functions for these two operations (one of which was never used) and not other wi:: ones like udiv. After the operator change, we'd have the additional inconsistency that "non-wi & wi" would work but "non-wi.and_not (wi)" wouldn't. 2017-10-09 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * wide-int.h (WI_BINARY_OPERATOR_RESULT): New macro. (WI_BINARY_PREDICATE_RESULT): Likewise. (wi::binary_traits::operator_result): New type. (wi::binary_traits::predicate_result): Likewise. (generic_wide_int::operator~, unary generic_wide_int::operator-) (generic_wide_int::operator==, generic_wide_int::operator!=) (generic_wide_int::operator&, generic_wide_int::and_not) (generic_wide_int::operator|, generic_wide_int::or_not) (generic_wide_int::operator^, generic_wide_int::operator+ (binary generic_wide_int::operator-, generic_wide_int::operator*): Delete. (operator~, unary operator-, operator==, operator!=, operator&) (operator|, operator^, operator+, binary operator-, operator*): New functions. * expr.c (get_inner_reference): Use wi::bit_and_not. * fold-const.c (fold_binary_loc): Likewise. * ipa-prop.c (ipa_compute_jump_functions_for_edge): Likewise. * tree-ssa-ccp.c (get_value_from_alignment): Likewise. (bit_value_binop): Likewise. * tree-ssa-math-opts.c (find_bswap_or_nop_load): Likewise. * tree-vrp.c (zero_nonzero_bits_from_vr): Likewise. (extract_range_from_binary_expr_1): Likewise. (masked_increment): Likewise. (simplify_bit_ops_using_ranges): Likewise. From-SVN: r253539
2017-09-22range_int_cst_p handling in extract_range_from_binary_expr_1Richard Sandiford1-5/+9
extract_range_from_binary_expr_1 had: if (range_int_cst_p (&vr0) && range_int_cst_p (&vr1) && TYPE_OVERFLOW_WRAPS (expr_type)) ... ... extract_range_from_multiplicative_op_1 (vr, code, &vr0, &vr1); but extract_range_from_multiplicative_op_1 also requires range_int_cst_p. I think we should bail out if either range isn't a constant. This might only be theoretical with current sources, but it's needed once polynomial constants are added. 2017-09-22 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree-vrp.c (extract_range_from_multiplicative_op_1): Assert for VR_RANGE only; don't allow VR_ANTI_RANGE. (extract_range_from_binary_expr_1): Don't call extract_range_from_multiplicative_op_1 if !range_int_cst_p. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r253102
2017-09-21re PR tree-optimization/82276 (-O2: ICE: SSA corruption during RTL pass: ↵Richard Biener1-9/+6
expand; at tree-ssa-coalesce.c:1010) 2017-09-21 Richard Biener <rguenther@suse.de> PR tree-optimization/82276 PR tree-optimization/82244 * tree-vrp.c (build_assert_expr_for): Set SSA_NAME_OCCURS_IN_ABNORMAL_PHI if the variable we assert on has it set. (remove_range_assertions): Revert earlier change. * gcc.dg/torture/pr82276.c: New testcase. From-SVN: r253062
2017-09-21Add missing int_cst_rangeN checks to tree-vrp.cRichard Sandiford1-2/+4
The BIT_AND_EXPR handling in extract_range_from_binary_expr_1 was using value_range_constant_singleton without first checking whether the range was a constant. The earlier handling was correctly guarded: /* If either input range contains only non-negative values we can truncate the result range maximum to the respective maximum of the input range. */ if (int_cst_range0 && tree_int_cst_sgn (vr0.min) >= 0) wmax = wi::min (wmax, vr0.max, TYPE_SIGN (expr_type)); if (int_cst_range1 && tree_int_cst_sgn (vr1.min) >= 0) wmax = wi::min (wmax, vr1.max, TYPE_SIGN (expr_type)); so this patch uses the same guards again. Existing tests showed the need for this once polynomial constants are added. 2017-09-21 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree-vrp.c (extract_range_from_binary_expr_1): Check int_cst_rangeN before calling value_range_constant_singleton (&vrN). Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r253054
2017-09-19re PR tree-optimization/82244 (-O2: ICE: tree check: expected ssa_name, have ↵Richard Biener1-0/+8
integer_cst in replace_uses_by, at tree-cfg.c:1904) 2017-09-19 Richard Biener <rguenther@suse.de> PR tree-optimization/82244 * tree-vrp.c (remove_range_assertions): Do not propagate a constant to abnormals but replace the assert with a copy. * gcc.dg/torture/pr82244.c: New testcase. From-SVN: r252973
2017-08-30[62/77] Big machine_mode to scalar_int_mode replacementRichard Sandiford1-1/+1
This patch changes the types of various things from machine_mode to scalar_int_mode, in cases where (after previous patches) simply changing the type is enough on its own. The patch does nothing other than that. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * builtins.h (builtin_strncpy_read_str): Take a scalar_int_mode instead of a machine_mode. (builtin_memset_read_str): Likewise. * builtins.c (c_readstr): Likewise. (builtin_memcpy_read_str): Likewise. (builtin_strncpy_read_str): Likewise. (builtin_memset_read_str): Likewise. (builtin_memset_gen_str): Likewise. (expand_builtin_signbit): Use scalar_int_mode for local variables. * cfgexpand.c (convert_debug_memory_address): Take a scalar_int_mode instead of a machine_mode. * combine.c (simplify_if_then_else): Use scalar_int_mode for local variables. (make_extraction): Likewise. (try_widen_shift_mode): Take and return scalar_int_modes instead of machine_modes. * config/aarch64/aarch64.c (aarch64_libgcc_cmp_return_mode): Return a scalar_int_mode instead of a machine_mode. * config/avr/avr.c (avr_addr_space_address_mode): Likewise. (avr_addr_space_pointer_mode): Likewise. * config/cr16/cr16.c (cr16_unwind_word_mode): Likewise. * config/msp430/msp430.c (msp430_addr_space_pointer_mode): Likewise. (msp430_unwind_word_mode): Likewise. * config/spu/spu.c (spu_unwind_word_mode): Likewise. (spu_addr_space_pointer_mode): Likewise. (spu_addr_space_address_mode): Likewise. (spu_libgcc_cmp_return_mode): Likewise. (spu_libgcc_shift_count_mode): Likewise. * config/rl78/rl78.c (rl78_addr_space_address_mode): Likewise. (rl78_addr_space_pointer_mode): Likewise. (fl78_unwind_word_mode): Likewise. (rl78_valid_pointer_mode): Take a scalar_int_mode instead of a machine_mode. * config/alpha/alpha.c (vms_valid_pointer_mode): Likewise. * config/ia64/ia64.c (ia64_vms_valid_pointer_mode): Likewise. * config/mips/mips.c (mips_mode_rep_extended): Likewise. (mips_valid_pointer_mode): Likewise. * config/tilegx/tilegx.c (tilegx_mode_rep_extended): Likewise. * config/ft32/ft32.c (ft32_valid_pointer_mode): Likewise. (ft32_addr_space_pointer_mode): Return a scalar_int_mode instead of a machine_mode. (ft32_addr_space_address_mode): Likewise. * config/m32c/m32c.c (m32c_valid_pointer_mode): Take a scalar_int_mode instead of a machine_mode. (m32c_addr_space_pointer_mode): Return a scalar_int_mode instead of a machine_mode. (m32c_addr_space_address_mode): Likewise. * config/powerpcspe/powerpcspe.c (rs6000_abi_word_mode): Likewise. (rs6000_eh_return_filter_mode): Likewise. * config/rs6000/rs6000.c (rs6000_abi_word_mode): Likewise. (rs6000_eh_return_filter_mode): Likewise. * config/s390/s390.c (s390_libgcc_cmp_return_mode): Likewise. (s390_libgcc_shift_count_mode): Likewise. (s390_unwind_word_mode): Likewise. (s390_valid_pointer_mode): Take a scalar_int_mode rather than a machine_mode. * target.def (mode_rep_extended): Likewise. (valid_pointer_mode): Likewise. (addr_space.valid_pointer_mode): Likewise. (eh_return_filter_mode): Return a scalar_int_mode rather than a machine_mode. (libgcc_cmp_return_mode): Likewise. (libgcc_shift_count_mode): Likewise. (unwind_word_mode): Likewise. (addr_space.pointer_mode): Likewise. (addr_space.address_mode): Likewise. * doc/tm.texi: Regenerate. * dojump.c (prefer_and_bit_test): Take a scalar_int_mode rather than a machine_mode. (do_jump): Use scalar_int_mode for local variables. * dwarf2cfi.c (init_return_column_size): Take a scalar_int_mode rather than a machine_mode. * dwarf2out.c (convert_descriptor_to_mode): Likewise. (scompare_loc_descriptor_wide): Likewise. (scompare_loc_descriptor_narrow): Likewise. * emit-rtl.c (adjust_address_1): Use scalar_int_mode for local variables. * except.c (sjlj_emit_dispatch_table): Likewise. (expand_builtin_eh_copy_values): Likewise. * explow.c (convert_memory_address_addr_space_1): Likewise. Take a scalar_int_mode rather than a machine_mode. (convert_memory_address_addr_space): Take a scalar_int_mode rather than a machine_mode. (memory_address_addr_space): Use scalar_int_mode for local variables. * expmed.h (expand_mult_highpart_adjust): Take a scalar_int_mode rather than a machine_mode. * expmed.c (mask_rtx): Likewise. (init_expmed_one_conv): Likewise. (expand_mult_highpart_adjust): Likewise. (extract_high_half): Likewise. (expmed_mult_highpart_optab): Likewise. (expmed_mult_highpart): Likewise. (expand_smod_pow2): Likewise. (expand_sdiv_pow2): Likewise. (emit_store_flag_int): Likewise. (adjust_bit_field_mem_for_reg): Use scalar_int_mode for local variables. (extract_low_bits): Likewise. * expr.h (by_pieces_constfn): Take a scalar_int_mode rather than a machine_mode. * expr.c (pieces_addr::adjust): Likewise. (can_store_by_pieces): Likewise. (store_by_pieces): Likewise. (clear_by_pieces_1): Likewise. (expand_expr_addr_expr_1): Likewise. (expand_expr_addr_expr): Use scalar_int_mode for local variables. (expand_expr_real_1): Likewise. (try_casesi): Likewise. * final.c (shorten_branches): Likewise. * fold-const.c (fold_convert_const_int_from_fixed): Change the type of "mode" to machine_mode. * internal-fn.c (expand_arith_overflow_result_store): Take a scalar_int_mode rather than a machine_mode. (expand_mul_overflow): Use scalar_int_mode for local variables. * loop-doloop.c (doloop_modify): Likewise. (doloop_optimize): Likewise. * optabs.c (expand_subword_shift): Take a scalar_int_mode rather than a machine_mode. (expand_doubleword_shift_condmove): Likewise. (expand_doubleword_shift): Likewise. (expand_doubleword_clz): Likewise. (expand_doubleword_popcount): Likewise. (expand_doubleword_parity): Likewise. (expand_absneg_bit): Use scalar_int_mode for local variables. (prepare_float_lib_cmp): Likewise. * rtl.h (convert_memory_address_addr_space_1): Take a scalar_int_mode rather than a machine_mode. (convert_memory_address_addr_space): Likewise. (get_mode_bounds): Likewise. (get_address_mode): Return a scalar_int_mode rather than a machine_mode. * rtlanal.c (get_address_mode): Likewise. * stor-layout.c (get_mode_bounds): Take a scalar_int_mode rather than a machine_mode. * targhooks.c (default_mode_rep_extended): Likewise. (default_valid_pointer_mode): Likewise. (default_addr_space_valid_pointer_mode): Likewise. (default_eh_return_filter_mode): Return a scalar_int_mode rather than a machine_mode. (default_libgcc_cmp_return_mode): Likewise. (default_libgcc_shift_count_mode): Likewise. (default_unwind_word_mode): Likewise. (default_addr_space_pointer_mode): Likewise. (default_addr_space_address_mode): Likewise. * targhooks.h (default_eh_return_filter_mode): Likewise. (default_libgcc_cmp_return_mode): Likewise. (default_libgcc_shift_count_mode): Likewise. (default_unwind_word_mode): Likewise. (default_addr_space_pointer_mode): Likewise. (default_addr_space_address_mode): Likewise. (default_mode_rep_extended): Take a scalar_int_mode rather than a machine_mode. (default_valid_pointer_mode): Likewise. (default_addr_space_valid_pointer_mode): Likewise. * tree-ssa-address.c (addr_for_mem_ref): Use scalar_int_mode for local variables. * tree-ssa-loop-ivopts.c (get_shiftadd_cost): Take a scalar_int_mode rather than a machine_mode. * tree-switch-conversion.c (array_value_type): Use scalar_int_mode for local variables. * tree-vrp.c (simplify_float_conversion_using_ranges): Likewise. * var-tracking.c (use_narrower_mode): Take a scalar_int_mode rather than a machine_mode. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251513
2017-08-30[34/77] Add a SCALAR_INT_TYPE_MODE macroRichard Sandiford1-12/+11
This patch adds a SCALAR_INT_TYPE_MODE macro that asserts that the type has a scalar integer mode and returns it as a scalar_int_mode. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (SCALAR_INT_TYPE_MODE): New macro. * builtins.c (expand_builtin_signbit): Use it. * cfgexpand.c (expand_debug_expr): Likewise. * dojump.c (do_jump): Likewise. (do_compare_and_jump): Likewise. * dwarf2cfi.c (expand_builtin_init_dwarf_reg_sizes): Likewise. * expmed.c (make_tree): Likewise. * expr.c (expand_expr_real_2): Likewise. (expand_expr_real_1): Likewise. (try_casesi): Likewise. * fold-const-call.c (fold_const_call_ss): Likewise. * fold-const.c (unextend): Likewise. (extract_muldiv_1): Likewise. (fold_single_bit_test): Likewise. (native_encode_int): Likewise. (native_encode_string): Likewise. (native_interpret_int): Likewise. * gimple-fold.c (gimple_fold_builtin_memset): Likewise. * internal-fn.c (expand_addsub_overflow): Likewise. (expand_neg_overflow): Likewise. (expand_mul_overflow): Likewise. (expand_arith_overflow): Likewise. * match.pd: Likewise. * stor-layout.c (layout_type): Likewise. * tree-cfg.c (verify_gimple_assign_ternary): Likewise. * tree-ssa-math-opts.c (convert_mult_to_widen): Likewise. * tree-ssanames.c (get_range_info): Likewise. * tree-switch-conversion.c (array_value_type) Likewise. * tree-vect-patterns.c (vect_recog_rotate_pattern): Likewise. (vect_recog_divmod_pattern): Likewise. (vect_recog_mixed_size_cond_pattern): Likewise. * tree-vrp.c (extract_range_basic): Likewise. (simplify_float_conversion_using_ranges): Likewise. * tree.c (int_fits_type_p): Likewise. * ubsan.c (instrument_bool_enum_load): Likewise. * varasm.c (mergeable_string_section): Likewise. (narrowing_initializer_constant_valid_p): Likewise. (output_constant): Likewise. gcc/cp/ * cvt.c (cp_convert_to_pointer): Use SCALAR_INT_TYPE_MODE. gcc/fortran/ * target-memory.c (size_integer): Use SCALAR_INT_TYPE_MODE. (size_logical): Likewise. gcc/objc/ * objc-encoding.c (encode_type): Use SCALAR_INT_TYPE_MODE. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251486
2017-08-30[33/77] Add a NARROWEST_INT_MODE macroRichard Sandiford1-1/+1
This patch replaces uses of GET_CLASS_NARROWEST_MODE (MODE_INT) with a new NARROWEST_INT_MODE macro, which has type scalar_int_mode. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * machmode.h (NARROWEST_INT_MODE): New macro. * expr.c (alignment_for_piecewise_move): Use it instead of GET_CLASS_NARROWEST_MODE (MODE_INT). (push_block): Likewise. * stor-layout.c (bit_field_mode_iterator::bit_field_mode_iterator): Likewise. * tree-vrp.c (simplify_float_conversion_using_ranges): Likewise. gcc/ada/ * gcc-interface/decl.c (validate_size): Use NARROWEST_INT_MODE instead of GET_CLASS_NARROWEST_MODE (MODE_INT). Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251485
2017-08-30[9/77] Add SCALAR_FLOAT_TYPE_MODERichard Sandiford1-1/+2
This patch adds a macro that extracts the TYPE_MODE and forcibly converts it to a scalar_float_mode. The forcible conversion includes a gcc_checking_assert that the mode is a SCALAR_FLOAT_MODE_P. This becomes important as more static type checking is added by later patches. It has the additional benefit of bypassing the VECTOR_TYPE_P (...) ? vector_type_mode (...) : ... condition in TYPE_MODE; in release builds the new macro is a simple field access. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (SCALAR_FLOAT_TYPE_MODE): New macro. * builtins.c (expand_builtin_signbit): Use it instead of TYPE_MODE. * fold-const.c (fold_convert_const_real_from_fixed): Likewise. (native_encode_real): Likewise. (native_interpret_real): Likewise. * hsa-brig.c (emit_immediate_scalar_to_buffer): Likewise. * tree-vrp.c (simplify_float_conversion_using_ranges): Likewise. gcc/cp/ * mangle.c (write_real_cst): Use SCALAR_FLOAT_TYPE_MODE instead of TYPE_MODE. gcc/fortran/ * target-memory.c (size_float): Use SCALAR_FLOAT_TYPE_MODE instead of TYPE_MODE. gcc/objc/ * objc-encoding.c (encode_type): Use SCALAR_FLOAT_TYPE_MODE instead of TYPE_MODE. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251460
2017-08-30[6/77] Make GET_MODE_WIDER return an opt_modeRichard Sandiford1-6/+3
GET_MODE_WIDER previously returned VOIDmode if no wider mode existed. That would cause problems with stricter mode classes, since VOIDmode isn't for example a valid scalar integer or floating-point mode. This patch instead makes it return a new opt_mode<T> class, which holds either a T or nothing. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * coretypes.h (opt_mode): New class. * machmode.h (opt_mode): Likewise. (opt_mode::else_void): New function. (opt_mode::require): Likewise. (opt_mode::exists): Likewise. (GET_MODE_WIDER_MODE): Turn into a function and return an opt_mode. (GET_MODE_2XWIDER_MODE): Likewise. (mode_iterator::get_wider): Update accordingly. (mode_iterator::get_2xwider): Likewise. (mode_iterator::get_known_wider): Likewise, turning into a template. * combine.c (make_extraction): Update use of GET_MODE_WIDER_MODE, forcing a wider mode to exist. * config/cr16/cr16.h (LONG_REG_P): Likewise. * rtlanal.c (init_num_sign_bit_copies_in_rep): Likewise. * config/c6x/c6x.c (c6x_rtx_costs): Update use of GET_MODE_2XWIDER_MODE, forcing a wider mode to exist. * lower-subreg.c (init_lower_subreg): Likewise. * optabs-libfuncs.c (init_sync_libfuncs_1): Likewise, but not on the final iteration. * config/i386/i386.c (ix86_expand_set_or_movmem): Check whether a wider mode exists before asking for a move pattern. (get_mode_wider_vector): Update use of GET_MODE_WIDER_MODE, forcing a wider mode to exist. (expand_vselect_vconcat): Update use of GET_MODE_2XWIDER_MODE, returning false if no such mode exists. * config/ia64/ia64.c (expand_vselect_vconcat): Likewise. * config/mips/mips.c (mips_expand_vselect_vconcat): Likewise. * expmed.c (init_expmed_one_mode): Update use of GET_MODE_WIDER_MODE. Avoid checking for a MODE_INT if we already know the mode is not a SCALAR_INT_MODE_P. (extract_high_half): Update use of GET_MODE_WIDER_MODE, forcing a wider mode to exist. (expmed_mult_highpart_optab): Likewise. (expmed_mult_highpart): Likewise. * expr.c (expand_expr_real_2): Update use of GET_MODE_WIDER_MODE, using else_void. * lto-streamer-in.c (lto_input_mode_table): Likewise. * optabs-query.c (find_widening_optab_handler_and_mode): Likewise. * stor-layout.c (bit_field_mode_iterator::next_mode): Likewise. * internal-fn.c (expand_mul_overflow): Update use of GET_MODE_2XWIDER_MODE. * omp-low.c (omp_clause_aligned_alignment): Likewise. * tree-ssa-math-opts.c (convert_mult_to_widen): Update use of GET_MODE_WIDER_MODE. (convert_plusminus_to_widen): Likewise. * tree-switch-conversion.c (array_value_type): Likewise. * var-tracking.c (emit_note_insn_var_location): Likewise. * tree-vrp.c (simplify_float_conversion_using_ranges): Likewise. Return false inside rather than outside the loop if no wider mode exists * optabs.c (expand_binop): Update use of GET_MODE_WIDER_MODE and GET_MODE_2XWIDER_MODE (can_compare_p): Use else_void. * gdbhooks.py (OptMachineModePrinter): New class. (build_pretty_printer): Use it for opt_mode. gcc/ada/ * gcc-interface/decl.c (validate_size): Update use of GET_MODE_WIDER_MODE, forcing a wider mode to exist. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251457
2017-08-21Add a type_has_mode_precision_p helper functionRichard Sandiford1-1/+1
...to replace instances of: TYPE_PRECISION (t) == GET_MODE_PRECISION (TYPE_MODE (t)) These conditions would need to be rewritten with variable-sized modes anyway. 2017-08-21 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * tree.h (type_has_mode_precision_p): New function. * convert.c (convert_to_integer_1): Use it. * expr.c (expand_expr_real_2): Likewise. (expand_expr_real_1): Likewise. * fold-const.c (fold_single_bit_test_into_sign_test): Likewise. * match.pd: Likewise. * tree-ssa-forwprop.c (simplify_rotate): Likewise. * tree-ssa-math-opts.c (convert_mult_to_fma): Likewise. * tree-tailcall.c (process_assignment): Likewise. * tree-vect-loop.c (vectorizable_reduction): Likewise. * tree-vect-patterns.c (vect_recog_vector_vector_shift_pattern) (vect_recog_mult_pattern, vect_recog_divmod_pattern): Likewise. * tree-vect-stmts.c (vectorizable_conversion): Likewise. (vectorizable_assignment): Likewise. (vectorizable_shift): Likewise. (vectorizable_operation): Likewise. * tree-vrp.c (register_edge_assert_for_2): Likewise. From-SVN: r251231
2017-08-17tree-vrp.c (vrp_int_const_binop): Do not set *overflow_p to true when ↵Richard Biener1-2/+4
overflow is undefined and we saturated the... 2017-08-17 Richard Biener <rguenther@suse.de> * tree-vrp.c (vrp_int_const_binop): Do not set *overflow_p to true when overflow is undefined and we saturated the result. * gcc.dg/tree-ssa/vrp117.c: New testcase. From-SVN: r251141
2017-08-08trans.c: Include header files.Martin Liska1-0/+2
. 2017-08-08 Martin Liska <mliska@suse.cz> * gcc-interface/trans.c: Include header files. 2017-08-08 Martin Liska <mliska@suse.cz> * objc-gnu-runtime-abi-01.c: Include header files. * objc-next-runtime-abi-01.c: Likewise. * objc-next-runtime-abi-02.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * asan.c: Include header files. * attribs.c (build_decl_attribute_variant): New function moved from tree.[ch]. (build_type_attribute_qual_variant): Likewise. (cmp_attrib_identifiers): Likewise. (simple_cst_list_equal): Likewise. (omp_declare_simd_clauses_equal): Likewise. (attribute_value_equal): Likewise. (comp_type_attributes): Likewise. (build_type_attribute_variant): Likewise. (lookup_ident_attribute): Likewise. (remove_attribute): Likewise. (merge_attributes): Likewise. (merge_type_attributes): Likewise. (merge_decl_attributes): Likewise. (merge_dllimport_decl_attributes): Likewise. (handle_dll_attribute): Likewise. (attribute_list_equal): Likewise. (attribute_list_contained): Likewise. * attribs.h (lookup_attribute): New function moved from tree.[ch]. (lookup_attribute_by_prefix): Likewise. * bb-reorder.c: Include header files. * builtins.c: Likewise. * calls.c: Likewise. * cfgexpand.c: Likewise. * cgraph.c: Likewise. * cgraphunit.c: Likewise. * convert.c: Likewise. * dwarf2out.c: Likewise. * final.c: Likewise. * fold-const.c: Likewise. * function.c: Likewise. * gimple-expr.c: Likewise. * gimple-fold.c: Likewise. * gimple-pretty-print.c: Likewise. * gimple.c: Likewise. * gimplify.c: Likewise. * hsa-common.c: Likewise. * hsa-gen.c: Likewise. * internal-fn.c: Likewise. * ipa-chkp.c: Likewise. * ipa-cp.c: Likewise. * ipa-devirt.c: Likewise. * ipa-fnsummary.c: Likewise. * ipa-inline.c: Likewise. * ipa-visibility.c: Likewise. * ipa.c: Likewise. * lto-cgraph.c: Likewise. * omp-expand.c: Likewise. * omp-general.c: Likewise. * omp-low.c: Likewise. * omp-offload.c: Likewise. * omp-simd-clone.c: Likewise. * opts-global.c: Likewise. * passes.c: Likewise. * predict.c: Likewise. * sancov.c: Likewise. * sanopt.c: Likewise. * symtab.c: Likewise. * toplev.c: Likewise. * trans-mem.c: Likewise. * tree-chkp.c: Likewise. * tree-eh.c: Likewise. * tree-into-ssa.c: Likewise. * tree-object-size.c: Likewise. * tree-parloops.c: Likewise. * tree-profile.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa.c: Likewise. * tree-streamer-in.c: Likewise. * tree-vectorizer.c: Likewise. * tree-vrp.c: Likewise. * tsan.c: Likewise. * ubsan.c: Likewise. * varasm.c: Likewise. * varpool.c: Likewise. * tree.c: Remove functions moved to attribs.[ch]. * tree.h: Likewise. * config/aarch64/aarch64.c: Add attrs.h header file. * config/alpha/alpha.c: Likewise. * config/arc/arc.c: Likewise. * config/arm/arm.c: Likewise. * config/avr/avr.c: Likewise. * config/bfin/bfin.c: Likewise. * config/c6x/c6x.c: Likewise. * config/cr16/cr16.c: Likewise. * config/cris/cris.c: Likewise. * config/darwin.c: Likewise. * config/epiphany/epiphany.c: Likewise. * config/fr30/fr30.c: Likewise. * config/frv/frv.c: Likewise. * config/ft32/ft32.c: Likewise. * config/h8300/h8300.c: Likewise. * config/i386/winnt.c: Likewise. * config/ia64/ia64.c: Likewise. * config/iq2000/iq2000.c: Likewise. * config/lm32/lm32.c: Likewise. * config/m32c/m32c.c: Likewise. * config/m32r/m32r.c: Likewise. * config/m68k/m68k.c: Likewise. * config/mcore/mcore.c: Likewise. * config/microblaze/microblaze.c: Likewise. * config/mips/mips.c: Likewise. * config/mmix/mmix.c: Likewise. * config/mn10300/mn10300.c: Likewise. * config/moxie/moxie.c: Likewise. * config/msp430/msp430.c: Likewise. * config/nds32/nds32-isr.c: Likewise. * config/nds32/nds32.c: Likewise. * config/nios2/nios2.c: Likewise. * config/nvptx/nvptx.c: Likewise. * config/pa/pa.c: Likewise. * config/pdp11/pdp11.c: Likewise. * config/powerpcspe/powerpcspe.c: Likewise. * config/riscv/riscv.c: Likewise. * config/rl78/rl78.c: Likewise. * config/rx/rx.c: Likewise. * config/s390/s390.c: Likewise. * config/sh/sh.c: Likewise. * config/sol2.c: Likewise. * config/sparc/sparc.c: Likewise. * config/spu/spu.c: Likewise. * config/stormy16/stormy16.c: Likewise. * config/tilegx/tilegx.c: Likewise. * config/tilepro/tilepro.c: Likewise. * config/v850/v850.c: Likewise. * config/vax/vax.c: Likewise. * config/visium/visium.c: Likewise. * config/xtensa/xtensa.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * call.c: Include header files. * cp-gimplify.c: Likewise. * cp-ubsan.c: Likewise. * cvt.c: Likewise. * init.c: Likewise. * search.c: Likewise. * semantics.c: Likewise. * typeck.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * lto-lang.c: Include header files. * lto-symtab.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * c-convert.c: Include header files. * c-typeck.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * c-ada-spec.c: Include header files. * c-ubsan.c: Likewise. * c-warn.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * trans-types.c: Include header files. From-SVN: r250946
2017-08-01re PR tree-optimization/81297 (ICE in get_single_symbol)Richard Biener1-1/+2
2017-08-01 Richard Biener <rguenther@suse.de> PR tree-optimization/81297 * tree-vrp.c (get_single_symbol): Remove assert, instead drop TREE_OVERFLOW from INTEGER_CSTs. * gcc.dg/torture/pr81297.c: New testcase. From-SVN: r250758
2017-07-17tree-vrp.c (compare_assert_loc): Fix comparison function to return ↵Yury Gribov1-1/+1
predictable results. 2017-07-17 Yury Gribov <tetra2005@gmail.com> gcc/ * tree-vrp.c (compare_assert_loc): Fix comparison function to return predictable results. From-SVN: r250278
2017-07-04re PR debug/81278 (-fcompare-debug failure (length))Jakub Jelinek1-9/+45
PR debug/81278 * tree-vrp.c (compare_assert_loc): Turn into a function template with stable template parameter. Only test if a->e is NULL, !a->e == !b->e has been verified already. Use e == NULL or e != NULL instead of e or ! e tests. If stable is true, don't use iterative_hash_expr, on the other side allow a or b or both NULL and sort the NULLs last. (process_assert_insertions): Sort using compare_assert_loc<false> instead of compare_assert_loc, later sort using compare_assert_loc<true> before calling process_assert_insertions_for in a loop. Use break instead of continue once seen NULL pointer. From-SVN: r249975
2017-06-16re PR tree-optimization/81089 (ICE: tree check: expected ssa_name, have ↵Yury Gribov1-4/+3
integer_cst in register_edge_assert_for_2, at tree-vrp.c:5023) 2017-06-16 Yury Gribov <tetra2005@gmail.com> PR tree-optimization/81089 * tree-vrp.c (is_masked_range_test): Validate operands of subexpression. From-SVN: r249237
2017-06-13tree-vrp.c (is_masked_range_test): New function.Yury Gribov1-0/+94
2017-06-13 Yury Gribov <tetra2005@gmail.com> gcc/ * tree-vrp.c (is_masked_range_test): New function. (register_edge_assert_for): Determine ranges for some bit tests. From-SVN: r249150
2017-05-16Add default value for last argument of dump functions.Martin Liska1-37/+37
2017-05-16 Martin Liska <mliska@suse.cz> * parser.c (cp_lexer_print_token): Add default value for flags argument of print_gimple_stmt, print_gimple_expr, print_generic_stmt and print_generic_expr. 2017-05-16 Martin Liska <mliska@suse.cz> * cgraph.c (cgraph_edge::resolve_speculation): Add default value for flags argument of print_gimple_stmt, print_gimple_expr, print_generic_stmt and print_generic_expr. * cgraphclones.c (symbol_table::materialize_all_clones): Likewise. * coretypes.h: Likewise. * except.c (dump_eh_tree): Likewise. * gimple-fold.c (gimple_fold_stmt_to_constant_1): Likewise. * gimple-pretty-print.h: Likewise. * gimple-ssa-backprop.c (dump_usage_prefix): Likewise. (backprop::push_to_worklist): Likewise. (backprop::pop_from_worklist): Likewise. (backprop::process_use): Likewise. (backprop::intersect_uses): Likewise. (note_replacement): Likewise. * gimple-ssa-store-merging.c (pass_store_merging::terminate_all_aliasing_chains): Likewise. (imm_store_chain_info::coalesce_immediate_stores): Likewise. (pass_store_merging::execute): Likewise. * gimple-ssa-strength-reduction.c (dump_candidate): Likewise. (ssa_base_cand_dump_callback): Likewise. (dump_incr_vec): Likewise. (replace_refs): Likewise. (replace_mult_candidate): Likewise. (create_add_on_incoming_edge): Likewise. (create_phi_basis): Likewise. (insert_initializers): Likewise. (all_phi_incrs_profitable): Likewise. (introduce_cast_before_cand): Likewise. (replace_one_candidate): Likewise. * gimplify.c (gimplify_expr): Likewise. * graphite-isl-ast-to-gimple.c (is_valid_rename): Likewise. (set_rename): Likewise. (rename_uses): Likewise. (copy_loop_phi_nodes): Likewise. (add_close_phis_to_merge_points): Likewise. (copy_loop_close_phi_args): Likewise. (copy_cond_phi_args): Likewise. (graphite_copy_stmts_from_block): Likewise. (translate_pending_phi_nodes): Likewise. * graphite-poly.c (print_pdr): Likewise. (dump_gbb_cases): Likewise. (dump_gbb_conditions): Likewise. (print_scop_params): Likewise. * graphite-scop-detection.c (build_cross_bb_scalars_def): Likewise. (build_cross_bb_scalars_use): Likewise. (gather_bbs::before_dom_children): Likewise. * hsa-dump.c (dump_hsa_immed): Likewise. * ipa-cp.c (print_ipcp_constant_value): Likewise. (get_replacement_map): Likewise. * ipa-inline-analysis.c (dump_condition): Likewise. (estimate_function_body_sizes): Likewise. * ipa-polymorphic-call.c (check_stmt_for_type_change): Likewise. (ipa_polymorphic_call_context::get_dynamic_type): Likewise. * ipa-prop.c (ipa_dump_param): Likewise. (ipa_print_node_jump_functions_for_edge): Likewise. (ipa_modify_call_arguments): Likewise. (ipa_modify_expr): Likewise. (ipa_dump_param_adjustments): Likewise. (ipa_dump_agg_replacement_values): Likewise. (ipcp_modif_dom_walker::before_dom_children): Likewise. * ipa-pure-const.c (check_stmt): Likewise. (pass_nothrow::execute): Likewise. * ipa-split.c (execute_split_functions): Likewise. * omp-offload.c (dump_oacc_loop_part): Likewise. (dump_oacc_loop): Likewise. * trans-mem.c (tm_log_emit): Likewise. (tm_memopt_accumulate_memops): Likewise. (dump_tm_memopt_set): Likewise. (dump_tm_memopt_transform): Likewise. * tree-cfg.c (gimple_verify_flow_info): Likewise. (print_loop): Likewise. * tree-chkp-opt.c (chkp_print_addr): Likewise. (chkp_gather_checks_info): Likewise. (chkp_get_check_result): Likewise. (chkp_remove_check_if_pass): Likewise. (chkp_use_outer_bounds_if_possible): Likewise. (chkp_reduce_bounds_lifetime): Likewise. * tree-chkp.c (chkp_register_addr_bounds): Likewise. (chkp_mark_completed_bounds): Likewise. (chkp_register_incomplete_bounds): Likewise. (chkp_mark_invalid_bounds): Likewise. (chkp_maybe_copy_and_register_bounds): Likewise. (chkp_build_returned_bound): Likewise. (chkp_get_bound_for_parm): Likewise. (chkp_build_bndldx): Likewise. (chkp_get_bounds_by_definition): Likewise. (chkp_generate_extern_var_bounds): Likewise. (chkp_get_bounds_for_decl_addr): Likewise. * tree-chrec.c (chrec_apply): Likewise. * tree-data-ref.c (dump_data_reference): Likewise. (dump_subscript): Likewise. (dump_data_dependence_relation): Likewise. (analyze_overlapping_iterations): Likewise. * tree-inline.c (expand_call_inline): Likewise. (tree_function_versioning): Likewise. * tree-into-ssa.c (dump_defs_stack): Likewise. (dump_currdefs): Likewise. (dump_names_replaced_by): Likewise. (dump_update_ssa): Likewise. (update_ssa): Likewise. * tree-object-size.c (pass_object_sizes::execute): Likewise. * tree-parloops.c (build_new_reduction): Likewise. (try_create_reduction_list): Likewise. (ref_conflicts_with_region): Likewise. (oacc_entry_exit_ok_1): Likewise. (oacc_entry_exit_single_gang): Likewise. * tree-pretty-print.h: Likewise. * tree-scalar-evolution.c (set_scalar_evolution): Likewise. (get_scalar_evolution): Likewise. (add_to_evolution): Likewise. (get_loop_exit_condition): Likewise. (analyze_evolution_in_loop): Likewise. (analyze_initial_condition): Likewise. (analyze_scalar_evolution): Likewise. (instantiate_scev): Likewise. (number_of_latch_executions): Likewise. (gather_chrec_stats): Likewise. (final_value_replacement_loop): Likewise. (scev_const_prop): Likewise. * tree-sra.c (dump_access): Likewise. (disqualify_candidate): Likewise. (create_access): Likewise. (reject): Likewise. (maybe_add_sra_candidate): Likewise. (create_access_replacement): Likewise. (analyze_access_subtree): Likewise. (analyze_all_variable_accesses): Likewise. (sra_modify_assign): Likewise. (initialize_constant_pool_replacements): Likewise. (find_param_candidates): Likewise. (decide_one_param_reduction): Likewise. (replace_removed_params_ssa_names): Likewise. * tree-ssa-ccp.c (ccp_fold_stmt): Likewise. * tree-ssa-copy.c (dump_copy_of): Likewise. (copy_prop_visit_cond_stmt): Likewise. * tree-ssa-dce.c (mark_operand_necessary): Likewise. * tree-ssa-dom.c (pass_dominator::execute): Likewise. (record_equivalences_from_stmt): Likewise. * tree-ssa-dse.c (compute_trims): Likewise. (delete_dead_call): Likewise. (delete_dead_assignment): Likewise. * tree-ssa-forwprop.c (forward_propagate_into_gimple_cond): Likewise. (forward_propagate_into_cond): Likewise. (pass_forwprop::execute): Likewise. * tree-ssa-ifcombine.c (ifcombine_ifandif): Likewise. * tree-ssa-loop-im.c (invariantness_dom_walker::before_dom_children): Likewise. (move_computations_worker): Likewise. (execute_sm): Likewise. * tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Likewise. (remove_exits_and_undefined_stmts): Likewise. (remove_redundant_iv_tests): Likewise. * tree-ssa-loop-ivopts.c (dump_use): Likewise. (adjust_iv_update_pos): Likewise. * tree-ssa-math-opts.c (bswap_replace): Likewise. * tree-ssa-phiopt.c (factor_out_conditional_conversion): Likewise. (value_replacement): Likewise. * tree-ssa-phiprop.c (phiprop_insert_phi): Likewise. * tree-ssa-pre.c (print_pre_expr): Likewise. (get_representative_for): Likewise. (create_expression_by_pieces): Likewise. (insert_into_preds_of_block): Likewise. (eliminate_insert): Likewise. (eliminate_dom_walker::before_dom_children): Likewise. (eliminate): Likewise. (remove_dead_inserted_code): Likewise. * tree-ssa-propagate.c (substitute_and_fold): Likewise. * tree-ssa-reassoc.c (get_rank): Likewise. (eliminate_duplicate_pair): Likewise. (eliminate_plus_minus_pair): Likewise. (eliminate_not_pairs): Likewise. (undistribute_ops_list): Likewise. (eliminate_redundant_comparison): Likewise. (update_range_test): Likewise. (optimize_range_tests_var_bound): Likewise. (optimize_vec_cond_expr): Likewise. (rewrite_expr_tree): Likewise. (rewrite_expr_tree_parallel): Likewise. (linearize_expr): Likewise. (break_up_subtract): Likewise. (linearize_expr_tree): Likewise. (attempt_builtin_powi): Likewise. (attempt_builtin_copysign): Likewise. (transform_stmt_to_copy): Likewise. (transform_stmt_to_multiply): Likewise. (dump_ops_vector): Likewise. * tree-ssa-sccvn.c (vn_nary_build_or_lookup_1): Likewise. (print_scc): Likewise. (set_ssa_val_to): Likewise. (visit_reference_op_store): Likewise. (visit_use): Likewise. (sccvn_dom_walker::before_dom_children): Likewise. (run_scc_vn): Likewise. * tree-ssa-scopedtables.c (avail_exprs_stack::lookup_avail_expr): Likewise. (expr_hash_elt::print): Likewise. (const_and_copies::pop_to_marker): Likewise. (const_and_copies::record_const_or_copy_raw): Likewise. * tree-ssa-structalias.c (compute_dependence_clique): Likewise. * tree-ssa-uninit.c (collect_phi_def_edges): Likewise. (dump_predicates): Likewise. (find_uninit_use): Likewise. (warn_uninitialized_phi): Likewise. (pass_late_warn_uninitialized::execute): Likewise. * tree-ssa.c (verify_vssa): Likewise. (verify_ssa): Likewise. (maybe_optimize_var): Likewise. * tree-vrp.c (dump_value_range): Likewise. (dump_all_value_ranges): Likewise. (dump_asserts_for): Likewise. (register_edge_assert_for_2): Likewise. (vrp_visit_cond_stmt): Likewise. (vrp_visit_switch_stmt): Likewise. (vrp_visit_stmt): Likewise. (vrp_visit_phi_node): Likewise. (simplify_cond_using_ranges_1): Likewise. (fold_predicate_in): Likewise. (evrp_dom_walker::before_dom_children): Likewise. (evrp_dom_walker::push_value_range): Likewise. (evrp_dom_walker::pop_value_range): Likewise. (execute_early_vrp): Likewise. From-SVN: r248113
2017-05-12tree-vrp.c (vrp_dom_walker::before_dom_childern): Push unwinding markers.Jeff Law1-0/+2
* tree-vrp.c (vrp_dom_walker::before_dom_childern): Push unwinding markers. * g++.dg/tree-ssa/ssa-dom-thread-4.c: Update expected output. From-SVN: r247985
2017-05-09tree-vrp.c (vrp_val_is_max): Adjust comment.Richard Biener1-49/+22
2017-05-09 Richard Biener <rguenther@suse.de> * tree-vrp.c (vrp_val_is_max): Adjust comment. (vrp_val_is_min): Likewise. (set_value_range_to_value): Likewise. (set_value_range_to_nonnegative): Likewise. (gimple_assign_nonzero_p): Likewise. (gimple_stmt_nonzero_p): Likewise. (vrp_int_const_binop): Likewise. Remove unreachable case. (adjust_range_with_scev): Adjust comments. (compare_range_with_value): Likewise. (extract_range_from_phi_node): Likewise. (test_for_singularity): Likewise. From-SVN: r247783