gcc/gcc/loop.c

9436 lines
285 KiB
C
Raw Normal View History

1995-10-03 17:17:19 +01:00
/* Perform various loop optimizations, including strength reduction.
2000-02-26 14:55:09 +01:00
Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
1998, 1999, 2000 Free Software Foundation, Inc.
1992-02-01 09:24:22 +01:00
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
1995-06-15 13:52:21 +02:00
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
1992-02-01 09:24:22 +01:00
/* This is the loop optimization pass of the compiler.
It finds invariant computations within loops and moves them
to the beginning of the loop. Then it identifies basic and
1992-02-01 09:24:22 +01:00
general induction variables. Strength reduction is applied to the general
induction variables, and induction variable elimination is applied to
the basic induction variables.
It also finds cases where
a register is set within the loop by zero-extending a narrower value
and changes these to zero the entire register once before the loop
and merely copy the low part within the loop.
Most of the complexity is in heuristics to decide when it is worth
while to do these things. */
#include "config.h"
Major cutover to using system.h: * Makefile.in (alias.o, bitmap.o, c-aux-info.o, c-common.o, c-decl.o, c-iterate.o, c-lang.o, c-lex.o, c-pragma.o, c-typeck.o, caller-save.o, calls.o, collect2.o, combine.o, cse.o, dbxout.o, dwarf2out.o, dwarfout.o, emit-rtl.o, except.o, explow.o, expmed.o, expr.o, final.o, flow.o, function.o, getpwd.o, global.o, integrate.o, jump.o, local-alloc.o, loop.o, optabs.o, pexecute.o, prefix.o, print-rtl.o, print-tree.o, profile.o, real.o, recog.o, reg-stack.o, regclass.o, regmove.o, reload.o, reload1.o, reorg.o, rtl.o, rtlanal.o, sdbout.o, stmt.o, stor-layout.o, stupid.o, tlink.o, toplev.o, tree.o, unroll.o, varasm.o, xcoffout.o): Depend on system.h. * alias.c, bitmap.c, c-aux-info.c, c-common.c, c-decl.c, c-iterate.c, c-lang.c, c-lex.c, c-pragma.c, c-typeck.c, caller-save.c, calls.c, collect2.c, combine.c, cse.c, dbxout.c, dwarf2out.c, dwarfout.c, emit-rtl.c, except.c, explow.c, expmed.c, expr.c, final.c, flow.c, function.c, gcc.c, getpwd.c, global.c, integrate.c, jump.c, local-alloc.c, loop.c, optabs.c, pexecute.c, prefix.c, print-rtl.c, print-tree.c, profile.c, real.c, recog.c, reg-stack.c, regclass.c, regmove.c, reload.c, reload1.c, reorg.c, rtl.c, rtlanal.c, sched.c, sdbout.c, stmt.c, stor-layout.c, stupid.c, tlink.c, toplev.c, tree.c, unroll.c, varasm.c, xcoffout.c: Include system.h. Organize include ordering so that stdarg/varargs comes before other system headers. Remove spurious casts of functions assured of a prototype in system.h. From-SVN: r18726
1998-03-20 15:58:42 +01:00
#include "system.h"
1992-02-01 09:24:22 +01:00
#include "rtl.h"
#include "tm_p.h"
1992-02-01 09:24:22 +01:00
#include "obstack.h"
#include "function.h"
1992-02-01 09:24:22 +01:00
#include "expr.h"
#include "hard-reg-set.h"
#include "basic-block.h"
1992-02-01 09:24:22 +01:00
#include "insn-config.h"
#include "insn-flags.h"
#include "regs.h"
#include "recog.h"
#include "flags.h"
#include "real.h"
#include "loop.h"
#include "cselib.h"
1996-07-23 22:03:47 +02:00
#include "except.h"
#include "toplev.h"
1992-02-01 09:24:22 +01:00
/* Vector mapping INSN_UIDs to luids.
The luids are like uids but increase monotonically always.
1992-02-01 09:24:22 +01:00
We use them to see whether a jump comes from outside a given loop. */
int *uid_luid;
/* Indexed by INSN_UID, contains the ordinal giving the (innermost) loop
number the insn is contained in. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
struct loop **uid_loop;
1992-02-01 09:24:22 +01:00
/* 1 + largest uid of any insn. */
int max_uid_for_loop;
/* 1 + luid of last insn. */
static int max_luid;
/* Number of loops detected in current function. Used as index to the
next few tables. */
static int max_loop_num;
/* Bound on pseudo register number before loop optimization.
A pseudo has valid regscan info if its number is < max_reg_before_loop. */
* Rework fields used to describe positions of bitfields and modify sizes to be unsigned and use HOST_WIDE_INT. * alias.c (reg_known_value_size): Now unsigned. * c-typeck.c (build_unary_op, case ADDR_EXPR): Use byte_position. (really_start_incremental_init): Use bitsize_zero_node. (push_init_level, pop_init_level, output_init_element): Likewise. Use bitsize_unit_node and bitsize_one_node. (output_pending_init_elements, process_init_element): Likewise. * combine.c (combine_max_regno, reg_sign_bit_copies): Now unsigned. (make_extraction): Position and length HOST_WIDE_INT and unsigned HOST_WIDE_INT, respectively. (get_pos_from_mask): Passed in value is unsigned HOST_WIDE_INT. (num_sign_bit_copies): Returns unsigned. BITWIDTH now unsigned; rework arithmetic. Remove recursive call from arg to MAX. (combine_instructions, init_reg_last_arrays): NREGS now unsigned. (setup_incoming_promotions, can_combine_p, try_combine, simplify_set): REGNO now unsigned. (set_nonzero_bit_and_sign_copies): NUM now unsigned. (find_split_point, expand_compound_operation, make_extraction): LEN now unsigned HOST_WIDE_INT, POS now HOST_WIDE_INT. (make_field_assignment): Likewise. (combine_simplify_rtx): Add cast. (expand_compound_operation): MODEWIDTH now unsigned; rework arithmetic. (force_to_mode): WIDTH now unsigned; add cast. (if_then_else_cond): SIZE now unsigned. (nonzero_bits): MODE_WIDTH, RESULT_WIDTH, and WIDTH now unsigned. (extended_count): Now returns unsigned. (simplify_shift_const): COUNT unsigned; arg is now INPUT_COUNT. Add SIGNED_COUNT variable; MODE_WORDS and FIRST_COUNT now unsigned. (simplify_comparison): MODE_WIDTH now unsigned. (update_table_tick): REGNO and ENDREGNO now unsigned; new var R. (mark_used_regs_combine): Likewise; rework arithmetic. (record_value_for_reg): REGNO, ENDREGNO, and I now unsigned. (record_dead_and_set_regs, reg_dead_at_p, distribute_notes): Likewise. (record_promoted_value): REGNO now unsigned. (get_last_value_validate): REGNO, ENDREGNO, and J now unsigned. (get_last_value): REGNO now unsigned. (use_crosses_set_p): REGNO and ENDREGNO now unsigned. (reg_dead_regno, reg_dead_endregno): Now unsigned. (remove_death): Arg REGNO now unsigned. (move_deaths): REGNO, DEADREGNO, DEADEND, OUREND, and I now unsigned. (reg_bitfield_target_p): REGNO, REGNO, ENDREGNO, and ENDTREGNO now unsigned. * convert.c (convert_to_integer): INPREC and OUTPREC now unsigned. * cse.c (struct qty_table_elem): FIRST_REG and LAST_REG now unsigned. (struct cse_reg_info): REGNO now unsigned. (cached_regno): Now unsigned. (REGNO_QTY_VALID_P): Add cast. (make_new_qty, make_regs_eqv, delete_reg_eqiv): Regno args unsigned. (remove_invalid_regs): Likewise. (remove_invalid_subreg_refs): Likewise; arg WORD also unsigned as are variables END and I. (get_cse_reg_info, insert): Likewise. (mention_regs, invalidate_for_call): REGNO, ENDREGNO, and I unsigned. (canon_hash): Likewise. (insert_regs, lookup_for_remove): REGNO now unsigned. (invalidate): REGNO, ENDREGNO, TREGNO, and TENDREGNO now unsigned. New variable RN. * dbxout.c (dbxout_parms, dbxout_reg_parms): Don't check for REGNO < 0. * dwarf2out.c (dwarf2ou_frame_debug_expr): Remove cast. * emit-rtl.c (subreg_realpart_p): Add cast. (operand_subword): Arg I is now unsigned as is var PARTWORDS. (operand_subword_force): Arg I is now unsigned. * except.c (eh_regs): Variable I is now unsigned. * explow.c (hard_function_value): BYTES is unsigned HOST_WIDE_INT. * expmed.c (store_fixed_bit_field): Position is HOST_WIDE_INT; length is unsigned HOST_WIDE_INT; likewise for internal variables. (store_split_bit_field, extract_fixed_bit_field): Likewise. (extract_split_bit_field, store_bit_field, extract_bit_field): Likewise. * expr.c (store_constructor_fields, store_constructor, store_field): Positions are HOST_WIDE_INT and lengths are unsigned HOST_WIDE_INT. (expand_assignment, expand_expr, expand_expr_unaligned): Likewise. (do_jump): Likewise. (move_by_pieces, move_by_pieces_ninsns, clear_by_pieces): MAX_SIZE is now unsigned. (emit_group_load): BYTEPOS is HOST_WIDE_INT; BYTELEN is unsigned. (emit_group_store): Likewise. (emit_move_insn): I now unsigned. (store_constructor): Use host_integerp, tree_low_cst, and bitsize_unit_node. (get_inner_reference): Return bitpos and bitsize as HOST_WIDE_INT. Rework all calculations to use trees and new fields. * expr.h (promoted_input_arg): Regno now unsigned. (store_bit_field, extract_bit_field): Adjust types of pos and size. (mark_seen_cases): Arg is HOST_WIDE_INT. * flow.c (verify_wide_reg_1): REGNO now unsigned. * fold-const.c (decode_field_reference): Size and pos HOST_WIDE_INT; precisions and alignments are unsigned. (optimize_bit_field_compare, fold_truthop): Likewise. (int_const_binop): Adjust threshold for size_int_type_wide call. (fold_convert): Likewise. (size_int_type_wide): Make table larger and fix thinko that only had half of table used. (all_ones_mask_p, fold): Precisions are unsigned. * function.c (put_reg_info_stack): REGNO is unsigned. (instantiate_decl): Size is HOST_WIDE_INT. (instantiate_virtual_regs): I is unsigned. (assign_parms): REGNO, REGNOI, and REGNOR are unsigned. (promoted_input_arg): REGNO is unsigned. * function.h (struct function): x_max_parm_reg is now unsigned. * gcse.c (max_gcse_regno): Now unsigned. (struct null_pointer_info): min_reg and max_reg now unsigned. (lookup_set, next_set): REGNO arg now unsigned. (compute_hash_table): REGNO and I now unsigned. (handle_avail_expr): regnum_for_replacing now unsigned. (cprop_insn): REGNO now unsigned. (delete_null_pointer_checks_1): BLOCK_REG now pointer to unsigned. * ggc-common.c (ggc_mark_tree_children, case FIELD_DECL): New case. * global.c (set_preference): SRC_REGNO, DEST_REGNO, and I now unsigned. * hard-reg-set.h (reg_class_size): Now unsigned. * integrate.c (mark_stores): LAST_REG and I now unsigned; new UREGNO. * jump.c (mark_modified_reg): I now unsigned; add cast. (rtx_equal_for_thread_p): Add cast. * loop.c (max_reg_before_loop): Now unsigned. (struct_movable): REGNO now unsigned. (try_copy_prop): REGNO arg unsigned. (regs_match_p): XN and YN now unsigned. (consec_sets_invariant_p, maybe_eliminate_biv): REGNO now unsigned. (strength_reduce): Likewise; NREGS also unsigned. (first_increment_giv, last_increment_giv unsigned): Now unsigned. * loop.h (struct iv_class): REGNO now unsigned. (max_reg_before_loop, first_increment_giv, last_increment_giv): Now unsigned. * machmode.h (mode_size, mode_unit_size): Now unsigned. (mode_for_size, smallest_mode_for_size): Pass size as unsigned. * optabs.c (expand_binop): I and NWORDS now unsigned. (expand_unop): I now unsigned. * print-tree.c (print_node): Don't print DECL_FIELD_BITPOS, but do print DECL_FIELD_OFFSET and DECL_FIELD_BIT_OFFSET. * real.c (significand_size): Now returns unsigned. * real.h (significand_size): Likewise. * regclass.c (reg_class_size): Now unsigned. (choose_hard_reg_mode): Both operands now unsigned. (record_reg_classes): REGNO and NR now unsigned. (reg_scan): NREGS now unsigned. (reg_scan_update): old_max_regno now unsigned. (reg_scan_mark_refs): Arg MIN_REGNO and var REGNO now unsigned. * reload.c (find_valid_class): BEST_SIZE now unsigned. (find_dummy_reload): REGNO, NWORDS, and I now unsigned. (hard_reg_set_here_p): Args BEG_REGNO and END_REGNO now unsigned. Likewise for variable R. (refers_to_regno_for_reload_p): Args REGNO and END_REGNO now unsigned, as are variables INNER_REGNO and INNER_ENDREGNO; add new variable R. (find_equiv_reg): Add casts. (regno_clobbered_p): Arg REGNO now unsigned. * reload.h (struct reload): NREGS now unsigned. (refers_to_regno_for_reload_p): Regno args are unsigned. (regno_clobbered_p): Likewise. * reload1.c (reg_max_ref_width, spill_stack_slot_width): Now unsigned. (compute_use_by_pseudos): REGNO now unsigned. (find_reg): I and J now unsigned, new variable K, and change loop variables accordingly; THIS_NREGS now unsigned. (alter_reg): INHERENT_SIZE and TOTAL_SIZE now unsigned. (spill_hard_reg): REGNO arg now unsigned; add casts. (forget_old_reloads_1): REGNO, NR, and I now unsigned. (mark_reload_reg_in_use): Arg REGNO and vars NREGS and I now unsigned. (clear_reload_reg_in_use): Arg REGNO and vars NREGS, START_REGNO, END_REGNO, CONFLICT_START, and CONFLICT_END now unsigned. (reload_reg_free_p, reload_reg_reaches_end_p): Arg REGNO now unsigned. (choose_reload_regs): MAX_GROUP_SIZE now unsigned. (emit_reload_insns): REGNO now unsigned. (reload_cse_move2add): Add cast. (move2add_note_store): REGNO and I now unsigned; new variable ENDREGNO and rework loop. * resource.c (mark_referenced_resources, mark_set_resources): New variable R; REGNO and LAST_REGNO now unsigned. (mark_target_live_regs): J and REGNO now unsigned. * rtl.c (mode_size, mode_unit_size): Now unsigned. * rtl.h (union rtunion_def): New field rtuint. (XCUINT): New macro. (ADDRESSOF_REGNO, REGNO, SUBREG_WORD): New XCUINT. (operand_subword, operand_subword_force): Word number is unsigned. (choose_hard_reg_mode): Operands are unsigned. (refers_to-regno_p, dead_or_set_regno_p): Regno arg is unsigned. (find_regno_note, find_regno_fusage, replace_regs): Likewise. (regno_use_in, combine_instructions, remove_death): Likewise. (reg_scan, reg_scan_update): Likewise. (extended_count): Return is unsigned. * rtlanal.c (refers_to_regno_p): Args REGNO and ENDREGNO and vars I, INNER_REGNO, and INNER_ENDREGNO now unsigned; new variable X_REGNO. (reg_overlap_mentioned_p): REGNO and ENDREGNO now unsigned. (reg_set_last_first_regno, reg_set_last_last_regno): Now unsigned. (reg_reg_last_1): FIRS and LAST now unsigned. (dead_or_set_p): REGNO, LAST_REGNO, and I now unsigned. (dead_or_set_regno_p): Arg TEST_REGNO and vars REGNO and ENDREGNO now unsigned. (find_regno_note, regno_use_in): Arg REGNO now unsigned. (find_regno_fusage): Likewise; also var REGNOTE now unsigned. (find_reg_fusage): Variables REGNO, END_REGNO, and I now unsigned. (replace_regs): Arg NREGS now unsigned. * sdbout.c (sdbout_parms, sdbout_reg_parms): Don't check REGNO < 0. * simplify-rtx.c (simplify_unary_operation): WIDTH now unsigned. (simplify_binary_operation): Likewise. (cselib_invalidate_regno): Arg REGNO and variables ENDREGNO, I, and THIS_LAST now unsigned. (cselib_record_set): Add cast. * ssa.c (ssa_max_reg_num): Now unsigned. (rename_block): REGNO now unsigned. * stmt.c (expand_return): Bit positions unsigned HOST_WIDE_INT; sizes now unsigned. (all_cases_count): Just return -1 not -2. COUNT, MINVAL, and LASTVAL now HOST_WIDE_INT. Rework tests to use trees whenever possible. Use host_integerp and tree_low_cst. (mark_seen_cases): COUNT arg now HOST_WIDE_INT; Likewise variable NEXT_NODE_OFFSET; XLO now unsigned. (check_for_full_enumeration_handing): BYTES_NEEDED, I to HOST_WIDE_INT. * stor-layout.c (mode_for_size): SIZE arg now unsigned. (smallest_mode_for_size): Likewise. (layout_decl): Simplify handing of a specified DECL_SIZE_UNIT. KNOWN_ALIGN is now an alignment, so simplify code. Don't turn off DECL_BIT_FIELD if field is BLKmode, but not type. (start_record_layout): Renamed from new_record_layout_info. Update to new fields. (debug_rli, normalize_rli, rli_size_unit_so_far, rli_size_so_far): New functions. (place_union_field): Renamed from layout_union_field. Update to use new fields in rli. (place_field): Renamed from layout_field. Major rewrite to use new fields in rli; pass alignment to layout_decl. (finalize_record_size): Rework to use new fields in rli and handle union. (compute_record_mode): Rework to simplify and to use new DECL fields. (finalize_type_size): Make rounding more consistent. (finish_union_layout): Deleted. (layout_type, case VOID_TYPE): Don't set TYPE_SIZE_UNIT either. (layout_type, case RECORD_TYPE): Call new function names. (initialize_sizetypes): Set TYPE_IS_SIZETYPE. (set_sizetype): Set TYPE_IS_SIZETYPE earlier. (get_best_mode): UNIT is now unsigned; remove casts. * tree.c (bit_position): Compute from new fields. (byte_position, int_byte_position): New functions. (print_type_hash_statistics): Cast to remove warning. (build_range_type): Use host_integerp and tree_low_cst to try to hash. (build_index_type): Likewise; make subtype of sizetype. (build_index_2_type): Pass sizetype to build_range_type. (build_common_tree_nodes): Use size_int and bitsize_int to initialize nodes; add bitsize_{zero,one,unit}_node. * tree.h (DECL_FIELD_CONTEXT): Use FIELD_DECL_CHECK. (DECL_BIT_FIELD_TYPE, DECL_QUALIFIER, DECL_FCONTEXT): Likewise. (DECL_PACKED, DECL_BIT_FIELD): Likewise. (DECL_FIELD_BITPOS): Deleted. (DECL_FIELD_OFFSET, DECL_FIELD_BIT_OFFSET): New fields. (DECL_RESULT, DECL_SAVED_INSNS): Use FUNCTION_DECL_CHECK. (DECL_FRAME_SIZE, DECL_FUNCTION_CODE, DECL_NO_STATIC_CHAIN): Likewise. (DECL_INLINE, DECL_BUILT_IN_NONANSI, DECL_IS_MALLOC): Likewise. (DECL_BUILT_IN_CLASS, DECL_STATIC_CONSTRUCTOR): Likewise. (DECL_STATIC_DESTRUCTOR, DECL_NO_CHECK_MEMORY_USAGE): Likewise. (DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT, DECL_NO_LIMIT_STACK) Likewise. (DECL_ORIGINAL_TYPE, TYPE_DECL_SUPPRESS_DEBUG): Use TYPE_DECL_CHECK. (DECL_ARG_TYPE_AS_WRITEN, DECL_ARG_TYPE): Use PARM_DECL_CHECK. (DECL_INCOMING_RTL, DECL_TRANSPARENT_UNION): Likewise. (DECL_ALIGN): Adjust to new field in union. (DECL_OFFSET_ALIGN): New field. (DECL_ERROR_ISSUED, DECL_TOO_LATE): Use LABEL_DECL_CHECK. (DECL_IN_TEXT_SECTION): Use VAR_DECL_CHECK. (union tree_decl): Add struct for both aligns. (enum tree_index): Add TI_BITSIZE_{ZERO,ONE,UNIT}. (bitsize_zero_node, bitsize_one_node, bitsize_unit_node): Added. (struct record_layout_info): Rework fields to have offset alignment and byte and bit position. (start_record_layout, place_field): Renamed from old names. (rli_size_so_far, rli_size_unit_so_far, normalize_rli): New decls. (byte_position, int_byte_position): Likewise. (get_inner_reference): Change types of position and length. * unroll.c (unroll_loop): New variable R; use for some loops. MAX_LOCAL_REGNUM and MAXREGNUM now unsigned. (calculate_giv_inc): Arg REGNO now unsigned. (copy_loop_body): REGNO and SRC_REGNO now unsigned. * varasm.c (assemble_variable): Clean up handling of size using host_integerp and tree_low_cst. (decode_addr_const): Use byte, not bit, position. (output_constructor): bitpos and offsets are HOST_WIDE_INT; use tree_low_cst and int_bit_position. * objc/objc-act.c (build_ivar_list_initializer): Use byte_position. * ch/actions.c (check_missing_cases): BYTES_NEEDED is HOST_WIDE_INT. * ch/typeck.c (expand_constant_to_buffer): Use int_byte_position. (extract_constant_from_buffer): Likewise. * cp/class.c (build_vbase_pointer_fields): layout_field now place_field. (get_vfield_offset): Use byte_position. (set_rtti_entry): Set OFFSET to ssizetype zero. (get_binfo_offset_as_int): Deleted. (dfs_record_base_offsets): Use tree_low_cst. (dfs_search_base_offsets): Likewise. (layout_nonempty_base_or_field): Reflect changes in RLI format and call byte_position. (layout_empty_base): Convert offset to ssizetype. (build_base_field): use rli_size_unit_so_far. (dfs_propagate_binfo_offsets): Do computation in proper type. (layout_virtual_bases): Pass ssizetype to propagate_binfo_offsets. (layout_class_type): Reflect changes in RLI names and fields. (finish_struct_1): Set DECL_FIELD_OFFSET. * cp/dump.c (dequeue_and_dump): Call bit_position. * cp/expr.c (cplus_expand_constant): Use byte_position. * cp/rtti.c (expand_class_desc): Use bitsize_one_node. * cp/typeck.c (build_component_addr): Use byte_position and don't special case for zero offset. * f/com.c (ffecom_tree_canonize_ptr_): Use bitsize_zero_node. (ffecom_tree_canonize_ref_): Likewise. * java/class.c (make_field_value): Use byte_position. * java/expr.c (JAVA_ARRAY_LENGTH_OFFSET): Use byte_position. (java_array_data_offset): Likewise. * java/java-tree.h (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Add case to bzero call. From-SVN: r32742
2000-03-25 19:34:13 +01:00
unsigned int max_reg_before_loop;
1992-02-01 09:24:22 +01:00
/* The value to pass to the next call of reg_scan_update. */
static int loop_max_reg;
1992-02-01 09:24:22 +01:00
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
/* During the analysis of a loop, a chain of `struct movable's
is made to record all the movable insns found.
Then the entire chain can be scanned to decide which to move. */
struct movable
{
rtx insn; /* A movable insn */
1996-07-04 00:07:53 +02:00
rtx set_src; /* The expression this reg is set from. */
rtx set_dest; /* The destination of this SET. */
1992-02-01 09:24:22 +01:00
rtx dependencies; /* When INSN is libcall, this is an EXPR_LIST
1996-07-04 00:07:53 +02:00
of any registers used within the LIBCALL. */
int consec; /* Number of consecutive following insns
1992-02-01 09:24:22 +01:00
that must be moved with this one. */
* Rework fields used to describe positions of bitfields and modify sizes to be unsigned and use HOST_WIDE_INT. * alias.c (reg_known_value_size): Now unsigned. * c-typeck.c (build_unary_op, case ADDR_EXPR): Use byte_position. (really_start_incremental_init): Use bitsize_zero_node. (push_init_level, pop_init_level, output_init_element): Likewise. Use bitsize_unit_node and bitsize_one_node. (output_pending_init_elements, process_init_element): Likewise. * combine.c (combine_max_regno, reg_sign_bit_copies): Now unsigned. (make_extraction): Position and length HOST_WIDE_INT and unsigned HOST_WIDE_INT, respectively. (get_pos_from_mask): Passed in value is unsigned HOST_WIDE_INT. (num_sign_bit_copies): Returns unsigned. BITWIDTH now unsigned; rework arithmetic. Remove recursive call from arg to MAX. (combine_instructions, init_reg_last_arrays): NREGS now unsigned. (setup_incoming_promotions, can_combine_p, try_combine, simplify_set): REGNO now unsigned. (set_nonzero_bit_and_sign_copies): NUM now unsigned. (find_split_point, expand_compound_operation, make_extraction): LEN now unsigned HOST_WIDE_INT, POS now HOST_WIDE_INT. (make_field_assignment): Likewise. (combine_simplify_rtx): Add cast. (expand_compound_operation): MODEWIDTH now unsigned; rework arithmetic. (force_to_mode): WIDTH now unsigned; add cast. (if_then_else_cond): SIZE now unsigned. (nonzero_bits): MODE_WIDTH, RESULT_WIDTH, and WIDTH now unsigned. (extended_count): Now returns unsigned. (simplify_shift_const): COUNT unsigned; arg is now INPUT_COUNT. Add SIGNED_COUNT variable; MODE_WORDS and FIRST_COUNT now unsigned. (simplify_comparison): MODE_WIDTH now unsigned. (update_table_tick): REGNO and ENDREGNO now unsigned; new var R. (mark_used_regs_combine): Likewise; rework arithmetic. (record_value_for_reg): REGNO, ENDREGNO, and I now unsigned. (record_dead_and_set_regs, reg_dead_at_p, distribute_notes): Likewise. (record_promoted_value): REGNO now unsigned. (get_last_value_validate): REGNO, ENDREGNO, and J now unsigned. (get_last_value): REGNO now unsigned. (use_crosses_set_p): REGNO and ENDREGNO now unsigned. (reg_dead_regno, reg_dead_endregno): Now unsigned. (remove_death): Arg REGNO now unsigned. (move_deaths): REGNO, DEADREGNO, DEADEND, OUREND, and I now unsigned. (reg_bitfield_target_p): REGNO, REGNO, ENDREGNO, and ENDTREGNO now unsigned. * convert.c (convert_to_integer): INPREC and OUTPREC now unsigned. * cse.c (struct qty_table_elem): FIRST_REG and LAST_REG now unsigned. (struct cse_reg_info): REGNO now unsigned. (cached_regno): Now unsigned. (REGNO_QTY_VALID_P): Add cast. (make_new_qty, make_regs_eqv, delete_reg_eqiv): Regno args unsigned. (remove_invalid_regs): Likewise. (remove_invalid_subreg_refs): Likewise; arg WORD also unsigned as are variables END and I. (get_cse_reg_info, insert): Likewise. (mention_regs, invalidate_for_call): REGNO, ENDREGNO, and I unsigned. (canon_hash): Likewise. (insert_regs, lookup_for_remove): REGNO now unsigned. (invalidate): REGNO, ENDREGNO, TREGNO, and TENDREGNO now unsigned. New variable RN. * dbxout.c (dbxout_parms, dbxout_reg_parms): Don't check for REGNO < 0. * dwarf2out.c (dwarf2ou_frame_debug_expr): Remove cast. * emit-rtl.c (subreg_realpart_p): Add cast. (operand_subword): Arg I is now unsigned as is var PARTWORDS. (operand_subword_force): Arg I is now unsigned. * except.c (eh_regs): Variable I is now unsigned. * explow.c (hard_function_value): BYTES is unsigned HOST_WIDE_INT. * expmed.c (store_fixed_bit_field): Position is HOST_WIDE_INT; length is unsigned HOST_WIDE_INT; likewise for internal variables. (store_split_bit_field, extract_fixed_bit_field): Likewise. (extract_split_bit_field, store_bit_field, extract_bit_field): Likewise. * expr.c (store_constructor_fields, store_constructor, store_field): Positions are HOST_WIDE_INT and lengths are unsigned HOST_WIDE_INT. (expand_assignment, expand_expr, expand_expr_unaligned): Likewise. (do_jump): Likewise. (move_by_pieces, move_by_pieces_ninsns, clear_by_pieces): MAX_SIZE is now unsigned. (emit_group_load): BYTEPOS is HOST_WIDE_INT; BYTELEN is unsigned. (emit_group_store): Likewise. (emit_move_insn): I now unsigned. (store_constructor): Use host_integerp, tree_low_cst, and bitsize_unit_node. (get_inner_reference): Return bitpos and bitsize as HOST_WIDE_INT. Rework all calculations to use trees and new fields. * expr.h (promoted_input_arg): Regno now unsigned. (store_bit_field, extract_bit_field): Adjust types of pos and size. (mark_seen_cases): Arg is HOST_WIDE_INT. * flow.c (verify_wide_reg_1): REGNO now unsigned. * fold-const.c (decode_field_reference): Size and pos HOST_WIDE_INT; precisions and alignments are unsigned. (optimize_bit_field_compare, fold_truthop): Likewise. (int_const_binop): Adjust threshold for size_int_type_wide call. (fold_convert): Likewise. (size_int_type_wide): Make table larger and fix thinko that only had half of table used. (all_ones_mask_p, fold): Precisions are unsigned. * function.c (put_reg_info_stack): REGNO is unsigned. (instantiate_decl): Size is HOST_WIDE_INT. (instantiate_virtual_regs): I is unsigned. (assign_parms): REGNO, REGNOI, and REGNOR are unsigned. (promoted_input_arg): REGNO is unsigned. * function.h (struct function): x_max_parm_reg is now unsigned. * gcse.c (max_gcse_regno): Now unsigned. (struct null_pointer_info): min_reg and max_reg now unsigned. (lookup_set, next_set): REGNO arg now unsigned. (compute_hash_table): REGNO and I now unsigned. (handle_avail_expr): regnum_for_replacing now unsigned. (cprop_insn): REGNO now unsigned. (delete_null_pointer_checks_1): BLOCK_REG now pointer to unsigned. * ggc-common.c (ggc_mark_tree_children, case FIELD_DECL): New case. * global.c (set_preference): SRC_REGNO, DEST_REGNO, and I now unsigned. * hard-reg-set.h (reg_class_size): Now unsigned. * integrate.c (mark_stores): LAST_REG and I now unsigned; new UREGNO. * jump.c (mark_modified_reg): I now unsigned; add cast. (rtx_equal_for_thread_p): Add cast. * loop.c (max_reg_before_loop): Now unsigned. (struct_movable): REGNO now unsigned. (try_copy_prop): REGNO arg unsigned. (regs_match_p): XN and YN now unsigned. (consec_sets_invariant_p, maybe_eliminate_biv): REGNO now unsigned. (strength_reduce): Likewise; NREGS also unsigned. (first_increment_giv, last_increment_giv unsigned): Now unsigned. * loop.h (struct iv_class): REGNO now unsigned. (max_reg_before_loop, first_increment_giv, last_increment_giv): Now unsigned. * machmode.h (mode_size, mode_unit_size): Now unsigned. (mode_for_size, smallest_mode_for_size): Pass size as unsigned. * optabs.c (expand_binop): I and NWORDS now unsigned. (expand_unop): I now unsigned. * print-tree.c (print_node): Don't print DECL_FIELD_BITPOS, but do print DECL_FIELD_OFFSET and DECL_FIELD_BIT_OFFSET. * real.c (significand_size): Now returns unsigned. * real.h (significand_size): Likewise. * regclass.c (reg_class_size): Now unsigned. (choose_hard_reg_mode): Both operands now unsigned. (record_reg_classes): REGNO and NR now unsigned. (reg_scan): NREGS now unsigned. (reg_scan_update): old_max_regno now unsigned. (reg_scan_mark_refs): Arg MIN_REGNO and var REGNO now unsigned. * reload.c (find_valid_class): BEST_SIZE now unsigned. (find_dummy_reload): REGNO, NWORDS, and I now unsigned. (hard_reg_set_here_p): Args BEG_REGNO and END_REGNO now unsigned. Likewise for variable R. (refers_to_regno_for_reload_p): Args REGNO and END_REGNO now unsigned, as are variables INNER_REGNO and INNER_ENDREGNO; add new variable R. (find_equiv_reg): Add casts. (regno_clobbered_p): Arg REGNO now unsigned. * reload.h (struct reload): NREGS now unsigned. (refers_to_regno_for_reload_p): Regno args are unsigned. (regno_clobbered_p): Likewise. * reload1.c (reg_max_ref_width, spill_stack_slot_width): Now unsigned. (compute_use_by_pseudos): REGNO now unsigned. (find_reg): I and J now unsigned, new variable K, and change loop variables accordingly; THIS_NREGS now unsigned. (alter_reg): INHERENT_SIZE and TOTAL_SIZE now unsigned. (spill_hard_reg): REGNO arg now unsigned; add casts. (forget_old_reloads_1): REGNO, NR, and I now unsigned. (mark_reload_reg_in_use): Arg REGNO and vars NREGS and I now unsigned. (clear_reload_reg_in_use): Arg REGNO and vars NREGS, START_REGNO, END_REGNO, CONFLICT_START, and CONFLICT_END now unsigned. (reload_reg_free_p, reload_reg_reaches_end_p): Arg REGNO now unsigned. (choose_reload_regs): MAX_GROUP_SIZE now unsigned. (emit_reload_insns): REGNO now unsigned. (reload_cse_move2add): Add cast. (move2add_note_store): REGNO and I now unsigned; new variable ENDREGNO and rework loop. * resource.c (mark_referenced_resources, mark_set_resources): New variable R; REGNO and LAST_REGNO now unsigned. (mark_target_live_regs): J and REGNO now unsigned. * rtl.c (mode_size, mode_unit_size): Now unsigned. * rtl.h (union rtunion_def): New field rtuint. (XCUINT): New macro. (ADDRESSOF_REGNO, REGNO, SUBREG_WORD): New XCUINT. (operand_subword, operand_subword_force): Word number is unsigned. (choose_hard_reg_mode): Operands are unsigned. (refers_to-regno_p, dead_or_set_regno_p): Regno arg is unsigned. (find_regno_note, find_regno_fusage, replace_regs): Likewise. (regno_use_in, combine_instructions, remove_death): Likewise. (reg_scan, reg_scan_update): Likewise. (extended_count): Return is unsigned. * rtlanal.c (refers_to_regno_p): Args REGNO and ENDREGNO and vars I, INNER_REGNO, and INNER_ENDREGNO now unsigned; new variable X_REGNO. (reg_overlap_mentioned_p): REGNO and ENDREGNO now unsigned. (reg_set_last_first_regno, reg_set_last_last_regno): Now unsigned. (reg_reg_last_1): FIRS and LAST now unsigned. (dead_or_set_p): REGNO, LAST_REGNO, and I now unsigned. (dead_or_set_regno_p): Arg TEST_REGNO and vars REGNO and ENDREGNO now unsigned. (find_regno_note, regno_use_in): Arg REGNO now unsigned. (find_regno_fusage): Likewise; also var REGNOTE now unsigned. (find_reg_fusage): Variables REGNO, END_REGNO, and I now unsigned. (replace_regs): Arg NREGS now unsigned. * sdbout.c (sdbout_parms, sdbout_reg_parms): Don't check REGNO < 0. * simplify-rtx.c (simplify_unary_operation): WIDTH now unsigned. (simplify_binary_operation): Likewise. (cselib_invalidate_regno): Arg REGNO and variables ENDREGNO, I, and THIS_LAST now unsigned. (cselib_record_set): Add cast. * ssa.c (ssa_max_reg_num): Now unsigned. (rename_block): REGNO now unsigned. * stmt.c (expand_return): Bit positions unsigned HOST_WIDE_INT; sizes now unsigned. (all_cases_count): Just return -1 not -2. COUNT, MINVAL, and LASTVAL now HOST_WIDE_INT. Rework tests to use trees whenever possible. Use host_integerp and tree_low_cst. (mark_seen_cases): COUNT arg now HOST_WIDE_INT; Likewise variable NEXT_NODE_OFFSET; XLO now unsigned. (check_for_full_enumeration_handing): BYTES_NEEDED, I to HOST_WIDE_INT. * stor-layout.c (mode_for_size): SIZE arg now unsigned. (smallest_mode_for_size): Likewise. (layout_decl): Simplify handing of a specified DECL_SIZE_UNIT. KNOWN_ALIGN is now an alignment, so simplify code. Don't turn off DECL_BIT_FIELD if field is BLKmode, but not type. (start_record_layout): Renamed from new_record_layout_info. Update to new fields. (debug_rli, normalize_rli, rli_size_unit_so_far, rli_size_so_far): New functions. (place_union_field): Renamed from layout_union_field. Update to use new fields in rli. (place_field): Renamed from layout_field. Major rewrite to use new fields in rli; pass alignment to layout_decl. (finalize_record_size): Rework to use new fields in rli and handle union. (compute_record_mode): Rework to simplify and to use new DECL fields. (finalize_type_size): Make rounding more consistent. (finish_union_layout): Deleted. (layout_type, case VOID_TYPE): Don't set TYPE_SIZE_UNIT either. (layout_type, case RECORD_TYPE): Call new function names. (initialize_sizetypes): Set TYPE_IS_SIZETYPE. (set_sizetype): Set TYPE_IS_SIZETYPE earlier. (get_best_mode): UNIT is now unsigned; remove casts. * tree.c (bit_position): Compute from new fields. (byte_position, int_byte_position): New functions. (print_type_hash_statistics): Cast to remove warning. (build_range_type): Use host_integerp and tree_low_cst to try to hash. (build_index_type): Likewise; make subtype of sizetype. (build_index_2_type): Pass sizetype to build_range_type. (build_common_tree_nodes): Use size_int and bitsize_int to initialize nodes; add bitsize_{zero,one,unit}_node. * tree.h (DECL_FIELD_CONTEXT): Use FIELD_DECL_CHECK. (DECL_BIT_FIELD_TYPE, DECL_QUALIFIER, DECL_FCONTEXT): Likewise. (DECL_PACKED, DECL_BIT_FIELD): Likewise. (DECL_FIELD_BITPOS): Deleted. (DECL_FIELD_OFFSET, DECL_FIELD_BIT_OFFSET): New fields. (DECL_RESULT, DECL_SAVED_INSNS): Use FUNCTION_DECL_CHECK. (DECL_FRAME_SIZE, DECL_FUNCTION_CODE, DECL_NO_STATIC_CHAIN): Likewise. (DECL_INLINE, DECL_BUILT_IN_NONANSI, DECL_IS_MALLOC): Likewise. (DECL_BUILT_IN_CLASS, DECL_STATIC_CONSTRUCTOR): Likewise. (DECL_STATIC_DESTRUCTOR, DECL_NO_CHECK_MEMORY_USAGE): Likewise. (DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT, DECL_NO_LIMIT_STACK) Likewise. (DECL_ORIGINAL_TYPE, TYPE_DECL_SUPPRESS_DEBUG): Use TYPE_DECL_CHECK. (DECL_ARG_TYPE_AS_WRITEN, DECL_ARG_TYPE): Use PARM_DECL_CHECK. (DECL_INCOMING_RTL, DECL_TRANSPARENT_UNION): Likewise. (DECL_ALIGN): Adjust to new field in union. (DECL_OFFSET_ALIGN): New field. (DECL_ERROR_ISSUED, DECL_TOO_LATE): Use LABEL_DECL_CHECK. (DECL_IN_TEXT_SECTION): Use VAR_DECL_CHECK. (union tree_decl): Add struct for both aligns. (enum tree_index): Add TI_BITSIZE_{ZERO,ONE,UNIT}. (bitsize_zero_node, bitsize_one_node, bitsize_unit_node): Added. (struct record_layout_info): Rework fields to have offset alignment and byte and bit position. (start_record_layout, place_field): Renamed from old names. (rli_size_so_far, rli_size_unit_so_far, normalize_rli): New decls. (byte_position, int_byte_position): Likewise. (get_inner_reference): Change types of position and length. * unroll.c (unroll_loop): New variable R; use for some loops. MAX_LOCAL_REGNUM and MAXREGNUM now unsigned. (calculate_giv_inc): Arg REGNO now unsigned. (copy_loop_body): REGNO and SRC_REGNO now unsigned. * varasm.c (assemble_variable): Clean up handling of size using host_integerp and tree_low_cst. (decode_addr_const): Use byte, not bit, position. (output_constructor): bitpos and offsets are HOST_WIDE_INT; use tree_low_cst and int_bit_position. * objc/objc-act.c (build_ivar_list_initializer): Use byte_position. * ch/actions.c (check_missing_cases): BYTES_NEEDED is HOST_WIDE_INT. * ch/typeck.c (expand_constant_to_buffer): Use int_byte_position. (extract_constant_from_buffer): Likewise. * cp/class.c (build_vbase_pointer_fields): layout_field now place_field. (get_vfield_offset): Use byte_position. (set_rtti_entry): Set OFFSET to ssizetype zero. (get_binfo_offset_as_int): Deleted. (dfs_record_base_offsets): Use tree_low_cst. (dfs_search_base_offsets): Likewise. (layout_nonempty_base_or_field): Reflect changes in RLI format and call byte_position. (layout_empty_base): Convert offset to ssizetype. (build_base_field): use rli_size_unit_so_far. (dfs_propagate_binfo_offsets): Do computation in proper type. (layout_virtual_bases): Pass ssizetype to propagate_binfo_offsets. (layout_class_type): Reflect changes in RLI names and fields. (finish_struct_1): Set DECL_FIELD_OFFSET. * cp/dump.c (dequeue_and_dump): Call bit_position. * cp/expr.c (cplus_expand_constant): Use byte_position. * cp/rtti.c (expand_class_desc): Use bitsize_one_node. * cp/typeck.c (build_component_addr): Use byte_position and don't special case for zero offset. * f/com.c (ffecom_tree_canonize_ptr_): Use bitsize_zero_node. (ffecom_tree_canonize_ref_): Likewise. * java/class.c (make_field_value): Use byte_position. * java/expr.c (JAVA_ARRAY_LENGTH_OFFSET): Use byte_position. (java_array_data_offset): Likewise. * java/java-tree.h (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Add case to bzero call. From-SVN: r32742
2000-03-25 19:34:13 +01:00
unsigned int regno; /* The register it sets */
1992-02-01 09:24:22 +01:00
short lifetime; /* lifetime of that register;
may be adjusted when matching movables
that load the same value are found. */
short savings; /* Number of insns we can move for this reg,
including other movables that force this
or match this one. */
unsigned int cond : 1; /* 1 if only conditionally movable */
unsigned int force : 1; /* 1 means MUST move this insn */
unsigned int global : 1; /* 1 means reg is live outside this loop */
/* If PARTIAL is 1, GLOBAL means something different:
that the reg is live outside the range from where it is set
to the following label. */
unsigned int done : 1; /* 1 inhibits further processing of this */
1992-02-01 09:24:22 +01:00
unsigned int partial : 1; /* 1 means this reg is used for zero-extending.
In particular, moving it does not make it
invariant. */
unsigned int move_insn : 1; /* 1 means that we call emit_move_insn to
load SRC, rather than copying INSN. */
unsigned int move_insn_first:1;/* Same as above, if this is necessary for the
first insn of a consecutive sets group. */
1996-07-04 00:07:53 +02:00
unsigned int is_equiv : 1; /* 1 means a REG_EQUIV is present on INSN. */
1992-02-01 09:24:22 +01:00
enum machine_mode savemode; /* Nonzero means it is a mode for a low part
that we should avoid changing when clearing
the rest of the reg. */
struct movable *match; /* First entry for same value */
struct movable *forces; /* An insn that must be moved if this is */
struct movable *next;
};
struct movables
{
/* Head of movable chain. */
struct movable *head;
/* Last movable in chain. */
struct movable *last;
/* Number of movables in the loop. */
int num;
};
static struct movables the_movables;
1992-02-01 09:24:22 +01:00
FILE *loop_dump_stream;
/* Forward declarations. */
static void find_and_verify_loops PARAMS ((rtx, struct loops *));
static void mark_loop_jump PARAMS ((rtx, struct loop *));
static void prescan_loop PARAMS ((struct loop *));
static int reg_in_basic_block_p PARAMS ((rtx, rtx));
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
static int consec_sets_invariant_p PARAMS ((const struct loop *,
rtx, int, rtx));
static int labels_in_range_p PARAMS ((rtx, int));
static void count_one_set PARAMS ((struct loop_regs *, rtx, rtx,
varray_type, rtx *));
static void count_loop_regs_set PARAMS ((const struct loop*,
varray_type, varray_type,
int *, int));
static void note_addr_stored PARAMS ((rtx, rtx, void *));
static void note_set_pseudo_multiple_uses PARAMS ((rtx, rtx, void *));
static int loop_reg_used_before_p PARAMS ((const struct loop *, rtx, rtx));
static void scan_loop PARAMS ((struct loop*, int));
#if 0
static void replace_call_address PARAMS ((rtx, rtx, rtx));
#endif
static rtx skip_consec_insns PARAMS ((rtx, int));
static int libcall_benefit PARAMS ((rtx));
static void ignore_some_movables PARAMS ((struct movables *));
static void force_movables PARAMS ((struct movables *));
static void combine_movables PARAMS ((struct movables *, struct loop_regs *));
static int regs_match_p PARAMS ((rtx, rtx, struct movables *));
static int rtx_equal_for_loop_p PARAMS ((rtx, rtx, struct movables *,
struct loop_regs *));
static void add_label_notes PARAMS ((rtx, rtx));
static void move_movables PARAMS ((struct loop *loop, struct movables *,
int, int));
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
static int count_nonfixed_reads PARAMS ((const struct loop *, rtx));
static void strength_reduce PARAMS ((struct loop *, int, int));
static void find_single_use_in_loop PARAMS ((rtx, rtx, varray_type));
static int valid_initial_value_p PARAMS ((rtx, rtx, int, rtx));
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
static void find_mem_givs PARAMS ((const struct loop *, rtx, rtx, int, int));
static void record_biv PARAMS ((struct loop *, struct induction *,
rtx, rtx, rtx, rtx, rtx *,
int, int));
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
static void check_final_value PARAMS ((const struct loop *,
struct induction *));
static void record_giv PARAMS ((const struct loop *, struct induction *,
rtx, rtx, rtx, rtx, rtx, rtx, int,
enum g_types, int, int, rtx *));
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
static void update_giv_derive PARAMS ((const struct loop *, rtx));
static void check_ext_dependant_givs PARAMS ((struct iv_class *,
struct loop_info *));
static int basic_induction_var PARAMS ((const struct loop *, rtx,
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
enum machine_mode, rtx, rtx,
rtx *, rtx *, rtx **));
static rtx simplify_giv_expr PARAMS ((const struct loop *, rtx, rtx *, int *));
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
static int general_induction_var PARAMS ((const struct loop *loop, rtx, rtx *,
rtx *, rtx *, rtx *, int, int *,
enum machine_mode));
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
static int consec_sets_giv PARAMS ((const struct loop *, int, rtx,
rtx, rtx, rtx *, rtx *, rtx *, rtx *));
static int check_dbra_loop PARAMS ((struct loop *, int));
static rtx express_from_1 PARAMS ((rtx, rtx, rtx));
static rtx combine_givs_p PARAMS ((struct induction *, struct induction *));
2000-09-19 18:01:13 +02:00
static int cmp_combine_givs_stats PARAMS ((const PTR, const PTR));
static void combine_givs PARAMS ((struct loop_regs *, struct iv_class *));
static int product_cheap_p PARAMS ((rtx, rtx));
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
static int maybe_eliminate_biv PARAMS ((const struct loop *, struct iv_class *,
int, int, int));
static int maybe_eliminate_biv_1 PARAMS ((const struct loop *, rtx, rtx,
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
struct iv_class *, int, rtx));
static int last_use_this_basic_block PARAMS ((rtx, rtx));
static void record_initial PARAMS ((rtx, rtx, void *));
static void update_reg_last_use PARAMS ((rtx, rtx));
static rtx next_insn_in_loop PARAMS ((const struct loop *, rtx));
static void load_mems_and_recount_loop_regs_set PARAMS ((const struct loop*,
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
int *));
static void load_mems PARAMS ((const struct loop *));
static int insert_loop_mem PARAMS ((rtx *, void *));
static int replace_loop_mem PARAMS ((rtx *, void *));
static void replace_loop_mems PARAMS ((rtx, rtx, rtx));
static int replace_loop_reg PARAMS ((rtx *, void *));
static void replace_loop_regs PARAMS ((rtx insn, rtx, rtx));
static void note_reg_stored PARAMS ((rtx, rtx, void *));
* Rework fields used to describe positions of bitfields and modify sizes to be unsigned and use HOST_WIDE_INT. * alias.c (reg_known_value_size): Now unsigned. * c-typeck.c (build_unary_op, case ADDR_EXPR): Use byte_position. (really_start_incremental_init): Use bitsize_zero_node. (push_init_level, pop_init_level, output_init_element): Likewise. Use bitsize_unit_node and bitsize_one_node. (output_pending_init_elements, process_init_element): Likewise. * combine.c (combine_max_regno, reg_sign_bit_copies): Now unsigned. (make_extraction): Position and length HOST_WIDE_INT and unsigned HOST_WIDE_INT, respectively. (get_pos_from_mask): Passed in value is unsigned HOST_WIDE_INT. (num_sign_bit_copies): Returns unsigned. BITWIDTH now unsigned; rework arithmetic. Remove recursive call from arg to MAX. (combine_instructions, init_reg_last_arrays): NREGS now unsigned. (setup_incoming_promotions, can_combine_p, try_combine, simplify_set): REGNO now unsigned. (set_nonzero_bit_and_sign_copies): NUM now unsigned. (find_split_point, expand_compound_operation, make_extraction): LEN now unsigned HOST_WIDE_INT, POS now HOST_WIDE_INT. (make_field_assignment): Likewise. (combine_simplify_rtx): Add cast. (expand_compound_operation): MODEWIDTH now unsigned; rework arithmetic. (force_to_mode): WIDTH now unsigned; add cast. (if_then_else_cond): SIZE now unsigned. (nonzero_bits): MODE_WIDTH, RESULT_WIDTH, and WIDTH now unsigned. (extended_count): Now returns unsigned. (simplify_shift_const): COUNT unsigned; arg is now INPUT_COUNT. Add SIGNED_COUNT variable; MODE_WORDS and FIRST_COUNT now unsigned. (simplify_comparison): MODE_WIDTH now unsigned. (update_table_tick): REGNO and ENDREGNO now unsigned; new var R. (mark_used_regs_combine): Likewise; rework arithmetic. (record_value_for_reg): REGNO, ENDREGNO, and I now unsigned. (record_dead_and_set_regs, reg_dead_at_p, distribute_notes): Likewise. (record_promoted_value): REGNO now unsigned. (get_last_value_validate): REGNO, ENDREGNO, and J now unsigned. (get_last_value): REGNO now unsigned. (use_crosses_set_p): REGNO and ENDREGNO now unsigned. (reg_dead_regno, reg_dead_endregno): Now unsigned. (remove_death): Arg REGNO now unsigned. (move_deaths): REGNO, DEADREGNO, DEADEND, OUREND, and I now unsigned. (reg_bitfield_target_p): REGNO, REGNO, ENDREGNO, and ENDTREGNO now unsigned. * convert.c (convert_to_integer): INPREC and OUTPREC now unsigned. * cse.c (struct qty_table_elem): FIRST_REG and LAST_REG now unsigned. (struct cse_reg_info): REGNO now unsigned. (cached_regno): Now unsigned. (REGNO_QTY_VALID_P): Add cast. (make_new_qty, make_regs_eqv, delete_reg_eqiv): Regno args unsigned. (remove_invalid_regs): Likewise. (remove_invalid_subreg_refs): Likewise; arg WORD also unsigned as are variables END and I. (get_cse_reg_info, insert): Likewise. (mention_regs, invalidate_for_call): REGNO, ENDREGNO, and I unsigned. (canon_hash): Likewise. (insert_regs, lookup_for_remove): REGNO now unsigned. (invalidate): REGNO, ENDREGNO, TREGNO, and TENDREGNO now unsigned. New variable RN. * dbxout.c (dbxout_parms, dbxout_reg_parms): Don't check for REGNO < 0. * dwarf2out.c (dwarf2ou_frame_debug_expr): Remove cast. * emit-rtl.c (subreg_realpart_p): Add cast. (operand_subword): Arg I is now unsigned as is var PARTWORDS. (operand_subword_force): Arg I is now unsigned. * except.c (eh_regs): Variable I is now unsigned. * explow.c (hard_function_value): BYTES is unsigned HOST_WIDE_INT. * expmed.c (store_fixed_bit_field): Position is HOST_WIDE_INT; length is unsigned HOST_WIDE_INT; likewise for internal variables. (store_split_bit_field, extract_fixed_bit_field): Likewise. (extract_split_bit_field, store_bit_field, extract_bit_field): Likewise. * expr.c (store_constructor_fields, store_constructor, store_field): Positions are HOST_WIDE_INT and lengths are unsigned HOST_WIDE_INT. (expand_assignment, expand_expr, expand_expr_unaligned): Likewise. (do_jump): Likewise. (move_by_pieces, move_by_pieces_ninsns, clear_by_pieces): MAX_SIZE is now unsigned. (emit_group_load): BYTEPOS is HOST_WIDE_INT; BYTELEN is unsigned. (emit_group_store): Likewise. (emit_move_insn): I now unsigned. (store_constructor): Use host_integerp, tree_low_cst, and bitsize_unit_node. (get_inner_reference): Return bitpos and bitsize as HOST_WIDE_INT. Rework all calculations to use trees and new fields. * expr.h (promoted_input_arg): Regno now unsigned. (store_bit_field, extract_bit_field): Adjust types of pos and size. (mark_seen_cases): Arg is HOST_WIDE_INT. * flow.c (verify_wide_reg_1): REGNO now unsigned. * fold-const.c (decode_field_reference): Size and pos HOST_WIDE_INT; precisions and alignments are unsigned. (optimize_bit_field_compare, fold_truthop): Likewise. (int_const_binop): Adjust threshold for size_int_type_wide call. (fold_convert): Likewise. (size_int_type_wide): Make table larger and fix thinko that only had half of table used. (all_ones_mask_p, fold): Precisions are unsigned. * function.c (put_reg_info_stack): REGNO is unsigned. (instantiate_decl): Size is HOST_WIDE_INT. (instantiate_virtual_regs): I is unsigned. (assign_parms): REGNO, REGNOI, and REGNOR are unsigned. (promoted_input_arg): REGNO is unsigned. * function.h (struct function): x_max_parm_reg is now unsigned. * gcse.c (max_gcse_regno): Now unsigned. (struct null_pointer_info): min_reg and max_reg now unsigned. (lookup_set, next_set): REGNO arg now unsigned. (compute_hash_table): REGNO and I now unsigned. (handle_avail_expr): regnum_for_replacing now unsigned. (cprop_insn): REGNO now unsigned. (delete_null_pointer_checks_1): BLOCK_REG now pointer to unsigned. * ggc-common.c (ggc_mark_tree_children, case FIELD_DECL): New case. * global.c (set_preference): SRC_REGNO, DEST_REGNO, and I now unsigned. * hard-reg-set.h (reg_class_size): Now unsigned. * integrate.c (mark_stores): LAST_REG and I now unsigned; new UREGNO. * jump.c (mark_modified_reg): I now unsigned; add cast. (rtx_equal_for_thread_p): Add cast. * loop.c (max_reg_before_loop): Now unsigned. (struct_movable): REGNO now unsigned. (try_copy_prop): REGNO arg unsigned. (regs_match_p): XN and YN now unsigned. (consec_sets_invariant_p, maybe_eliminate_biv): REGNO now unsigned. (strength_reduce): Likewise; NREGS also unsigned. (first_increment_giv, last_increment_giv unsigned): Now unsigned. * loop.h (struct iv_class): REGNO now unsigned. (max_reg_before_loop, first_increment_giv, last_increment_giv): Now unsigned. * machmode.h (mode_size, mode_unit_size): Now unsigned. (mode_for_size, smallest_mode_for_size): Pass size as unsigned. * optabs.c (expand_binop): I and NWORDS now unsigned. (expand_unop): I now unsigned. * print-tree.c (print_node): Don't print DECL_FIELD_BITPOS, but do print DECL_FIELD_OFFSET and DECL_FIELD_BIT_OFFSET. * real.c (significand_size): Now returns unsigned. * real.h (significand_size): Likewise. * regclass.c (reg_class_size): Now unsigned. (choose_hard_reg_mode): Both operands now unsigned. (record_reg_classes): REGNO and NR now unsigned. (reg_scan): NREGS now unsigned. (reg_scan_update): old_max_regno now unsigned. (reg_scan_mark_refs): Arg MIN_REGNO and var REGNO now unsigned. * reload.c (find_valid_class): BEST_SIZE now unsigned. (find_dummy_reload): REGNO, NWORDS, and I now unsigned. (hard_reg_set_here_p): Args BEG_REGNO and END_REGNO now unsigned. Likewise for variable R. (refers_to_regno_for_reload_p): Args REGNO and END_REGNO now unsigned, as are variables INNER_REGNO and INNER_ENDREGNO; add new variable R. (find_equiv_reg): Add casts. (regno_clobbered_p): Arg REGNO now unsigned. * reload.h (struct reload): NREGS now unsigned. (refers_to_regno_for_reload_p): Regno args are unsigned. (regno_clobbered_p): Likewise. * reload1.c (reg_max_ref_width, spill_stack_slot_width): Now unsigned. (compute_use_by_pseudos): REGNO now unsigned. (find_reg): I and J now unsigned, new variable K, and change loop variables accordingly; THIS_NREGS now unsigned. (alter_reg): INHERENT_SIZE and TOTAL_SIZE now unsigned. (spill_hard_reg): REGNO arg now unsigned; add casts. (forget_old_reloads_1): REGNO, NR, and I now unsigned. (mark_reload_reg_in_use): Arg REGNO and vars NREGS and I now unsigned. (clear_reload_reg_in_use): Arg REGNO and vars NREGS, START_REGNO, END_REGNO, CONFLICT_START, and CONFLICT_END now unsigned. (reload_reg_free_p, reload_reg_reaches_end_p): Arg REGNO now unsigned. (choose_reload_regs): MAX_GROUP_SIZE now unsigned. (emit_reload_insns): REGNO now unsigned. (reload_cse_move2add): Add cast. (move2add_note_store): REGNO and I now unsigned; new variable ENDREGNO and rework loop. * resource.c (mark_referenced_resources, mark_set_resources): New variable R; REGNO and LAST_REGNO now unsigned. (mark_target_live_regs): J and REGNO now unsigned. * rtl.c (mode_size, mode_unit_size): Now unsigned. * rtl.h (union rtunion_def): New field rtuint. (XCUINT): New macro. (ADDRESSOF_REGNO, REGNO, SUBREG_WORD): New XCUINT. (operand_subword, operand_subword_force): Word number is unsigned. (choose_hard_reg_mode): Operands are unsigned. (refers_to-regno_p, dead_or_set_regno_p): Regno arg is unsigned. (find_regno_note, find_regno_fusage, replace_regs): Likewise. (regno_use_in, combine_instructions, remove_death): Likewise. (reg_scan, reg_scan_update): Likewise. (extended_count): Return is unsigned. * rtlanal.c (refers_to_regno_p): Args REGNO and ENDREGNO and vars I, INNER_REGNO, and INNER_ENDREGNO now unsigned; new variable X_REGNO. (reg_overlap_mentioned_p): REGNO and ENDREGNO now unsigned. (reg_set_last_first_regno, reg_set_last_last_regno): Now unsigned. (reg_reg_last_1): FIRS and LAST now unsigned. (dead_or_set_p): REGNO, LAST_REGNO, and I now unsigned. (dead_or_set_regno_p): Arg TEST_REGNO and vars REGNO and ENDREGNO now unsigned. (find_regno_note, regno_use_in): Arg REGNO now unsigned. (find_regno_fusage): Likewise; also var REGNOTE now unsigned. (find_reg_fusage): Variables REGNO, END_REGNO, and I now unsigned. (replace_regs): Arg NREGS now unsigned. * sdbout.c (sdbout_parms, sdbout_reg_parms): Don't check REGNO < 0. * simplify-rtx.c (simplify_unary_operation): WIDTH now unsigned. (simplify_binary_operation): Likewise. (cselib_invalidate_regno): Arg REGNO and variables ENDREGNO, I, and THIS_LAST now unsigned. (cselib_record_set): Add cast. * ssa.c (ssa_max_reg_num): Now unsigned. (rename_block): REGNO now unsigned. * stmt.c (expand_return): Bit positions unsigned HOST_WIDE_INT; sizes now unsigned. (all_cases_count): Just return -1 not -2. COUNT, MINVAL, and LASTVAL now HOST_WIDE_INT. Rework tests to use trees whenever possible. Use host_integerp and tree_low_cst. (mark_seen_cases): COUNT arg now HOST_WIDE_INT; Likewise variable NEXT_NODE_OFFSET; XLO now unsigned. (check_for_full_enumeration_handing): BYTES_NEEDED, I to HOST_WIDE_INT. * stor-layout.c (mode_for_size): SIZE arg now unsigned. (smallest_mode_for_size): Likewise. (layout_decl): Simplify handing of a specified DECL_SIZE_UNIT. KNOWN_ALIGN is now an alignment, so simplify code. Don't turn off DECL_BIT_FIELD if field is BLKmode, but not type. (start_record_layout): Renamed from new_record_layout_info. Update to new fields. (debug_rli, normalize_rli, rli_size_unit_so_far, rli_size_so_far): New functions. (place_union_field): Renamed from layout_union_field. Update to use new fields in rli. (place_field): Renamed from layout_field. Major rewrite to use new fields in rli; pass alignment to layout_decl. (finalize_record_size): Rework to use new fields in rli and handle union. (compute_record_mode): Rework to simplify and to use new DECL fields. (finalize_type_size): Make rounding more consistent. (finish_union_layout): Deleted. (layout_type, case VOID_TYPE): Don't set TYPE_SIZE_UNIT either. (layout_type, case RECORD_TYPE): Call new function names. (initialize_sizetypes): Set TYPE_IS_SIZETYPE. (set_sizetype): Set TYPE_IS_SIZETYPE earlier. (get_best_mode): UNIT is now unsigned; remove casts. * tree.c (bit_position): Compute from new fields. (byte_position, int_byte_position): New functions. (print_type_hash_statistics): Cast to remove warning. (build_range_type): Use host_integerp and tree_low_cst to try to hash. (build_index_type): Likewise; make subtype of sizetype. (build_index_2_type): Pass sizetype to build_range_type. (build_common_tree_nodes): Use size_int and bitsize_int to initialize nodes; add bitsize_{zero,one,unit}_node. * tree.h (DECL_FIELD_CONTEXT): Use FIELD_DECL_CHECK. (DECL_BIT_FIELD_TYPE, DECL_QUALIFIER, DECL_FCONTEXT): Likewise. (DECL_PACKED, DECL_BIT_FIELD): Likewise. (DECL_FIELD_BITPOS): Deleted. (DECL_FIELD_OFFSET, DECL_FIELD_BIT_OFFSET): New fields. (DECL_RESULT, DECL_SAVED_INSNS): Use FUNCTION_DECL_CHECK. (DECL_FRAME_SIZE, DECL_FUNCTION_CODE, DECL_NO_STATIC_CHAIN): Likewise. (DECL_INLINE, DECL_BUILT_IN_NONANSI, DECL_IS_MALLOC): Likewise. (DECL_BUILT_IN_CLASS, DECL_STATIC_CONSTRUCTOR): Likewise. (DECL_STATIC_DESTRUCTOR, DECL_NO_CHECK_MEMORY_USAGE): Likewise. (DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT, DECL_NO_LIMIT_STACK) Likewise. (DECL_ORIGINAL_TYPE, TYPE_DECL_SUPPRESS_DEBUG): Use TYPE_DECL_CHECK. (DECL_ARG_TYPE_AS_WRITEN, DECL_ARG_TYPE): Use PARM_DECL_CHECK. (DECL_INCOMING_RTL, DECL_TRANSPARENT_UNION): Likewise. (DECL_ALIGN): Adjust to new field in union. (DECL_OFFSET_ALIGN): New field. (DECL_ERROR_ISSUED, DECL_TOO_LATE): Use LABEL_DECL_CHECK. (DECL_IN_TEXT_SECTION): Use VAR_DECL_CHECK. (union tree_decl): Add struct for both aligns. (enum tree_index): Add TI_BITSIZE_{ZERO,ONE,UNIT}. (bitsize_zero_node, bitsize_one_node, bitsize_unit_node): Added. (struct record_layout_info): Rework fields to have offset alignment and byte and bit position. (start_record_layout, place_field): Renamed from old names. (rli_size_so_far, rli_size_unit_so_far, normalize_rli): New decls. (byte_position, int_byte_position): Likewise. (get_inner_reference): Change types of position and length. * unroll.c (unroll_loop): New variable R; use for some loops. MAX_LOCAL_REGNUM and MAXREGNUM now unsigned. (calculate_giv_inc): Arg REGNO now unsigned. (copy_loop_body): REGNO and SRC_REGNO now unsigned. * varasm.c (assemble_variable): Clean up handling of size using host_integerp and tree_low_cst. (decode_addr_const): Use byte, not bit, position. (output_constructor): bitpos and offsets are HOST_WIDE_INT; use tree_low_cst and int_bit_position. * objc/objc-act.c (build_ivar_list_initializer): Use byte_position. * ch/actions.c (check_missing_cases): BYTES_NEEDED is HOST_WIDE_INT. * ch/typeck.c (expand_constant_to_buffer): Use int_byte_position. (extract_constant_from_buffer): Likewise. * cp/class.c (build_vbase_pointer_fields): layout_field now place_field. (get_vfield_offset): Use byte_position. (set_rtti_entry): Set OFFSET to ssizetype zero. (get_binfo_offset_as_int): Deleted. (dfs_record_base_offsets): Use tree_low_cst. (dfs_search_base_offsets): Likewise. (layout_nonempty_base_or_field): Reflect changes in RLI format and call byte_position. (layout_empty_base): Convert offset to ssizetype. (build_base_field): use rli_size_unit_so_far. (dfs_propagate_binfo_offsets): Do computation in proper type. (layout_virtual_bases): Pass ssizetype to propagate_binfo_offsets. (layout_class_type): Reflect changes in RLI names and fields. (finish_struct_1): Set DECL_FIELD_OFFSET. * cp/dump.c (dequeue_and_dump): Call bit_position. * cp/expr.c (cplus_expand_constant): Use byte_position. * cp/rtti.c (expand_class_desc): Use bitsize_one_node. * cp/typeck.c (build_component_addr): Use byte_position and don't special case for zero offset. * f/com.c (ffecom_tree_canonize_ptr_): Use bitsize_zero_node. (ffecom_tree_canonize_ref_): Likewise. * java/class.c (make_field_value): Use byte_position. * java/expr.c (JAVA_ARRAY_LENGTH_OFFSET): Use byte_position. (java_array_data_offset): Likewise. * java/java-tree.h (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Add case to bzero call. From-SVN: r32742
2000-03-25 19:34:13 +01:00
static void try_copy_prop PARAMS ((const struct loop *, rtx, unsigned int));
static void try_swap_copy_prop PARAMS ((const struct loop *, rtx,
unsigned int));
static int replace_label PARAMS ((rtx *, void *));
static rtx check_insn_for_givs PARAMS((struct loop *, rtx, int, int));
static rtx check_insn_for_bivs PARAMS((struct loop *, rtx, int, int));
static int iv_add_mult_cost PARAMS ((rtx, rtx, rtx, rtx));
1998-08-19 14:30:47 +02:00
static void loop_dump_aux PARAMS ((const struct loop *, FILE *, int));
void debug_loop PARAMS ((const struct loop *));
typedef struct rtx_pair
{
1998-08-19 14:30:47 +02:00
rtx r1;
rtx r2;
} rtx_pair;
typedef struct loop_replace_args
{
rtx match;
rtx replacement;
rtx insn;
} loop_replace_args;
1998-08-19 14:30:47 +02:00
/* Nonzero iff INSN is between START and END, inclusive. */
#define INSN_IN_RANGE_P(INSN, START, END) \
(INSN_UID (INSN) < max_uid_for_loop \
&& INSN_LUID (INSN) >= INSN_LUID (START) \
&& INSN_LUID (INSN) <= INSN_LUID (END))
/* Indirect_jump_in_function is computed once per function. */
Makefile.in (OBJS): Add doloop.o. * Makefile.in (OBJS): Add doloop.o. * doloop.c: New file. * final.c (insn_current_reference_address): Return 0 before final. * flags.h (flag_branch_on_count_reg): Fix typos in commentary. * jump.c (any_uncondjump_p): Likewise. * loop.c (indirect_jump_in_function): Make static. (strength_reduce): Call doloop_optimize. (insert_bct, instrument_loop_bct): Remove. * loop.h (doloop_optimize): Prototype. * recog.c (split_all_insns): Split all INSN_P. * toplev.c (flag_branch_on_count_reg): Default on. * config/c4x/c4x.c (c4x_optimization_options): Don't set flag_branch_on_count_reg. * config/i386/i386.c (override_options): Likewise. * config/rs6000/rs6000.c (optimization_options): Likewise. * config/i386/i386.md (decrement_and_branch_on_count): Remove. (doloop_end): New. (dbra_ge): Remove, as well as all it's splitters. * config/rs6000/rs6000.md (decrement_and_branch_on_count): Remove. (doloop_end): New. * config/ia64/ia64-protos.h (ar_lc_reg_operand): Declare. (ia64_register_move_cost): Declare. * config/ia64/ia64.c (ar_lc_reg_operand): New. (struct ia64_frame_info): Add ar_size. (ia64_compute_frame_size): Set it. (save_restore_insns): Save and restore ar.lc. (ia64_register_move_cost): New, moved from header file. Handle application registers. (REG_AR_PFS, REG_AR_EC): Remove. Replace with AR_*_REGNUM numbers. (emit_insn_group_barriers): Special case doloop_end_internal. (ia64_epilogue_uses): Mark ar.lc live at end. * config/ia64/ia64.h (AR_CCV_REGNUM, AR_LC_REGNUM): New registers. (AR_EC_REGNUM, AR_PFS_REGNUM): New registers. (FIRST_PSEUDO_REGISTER): Make room. (AR_M_REGNO_P, AR_I_REGNO_P, AR_REGNO_P): New. (FIXED_REGISTERS, CALL_USED_REGISTERS): Update. (REG_ALLOC_ORDER): Update. (HARD_REGNO_MODE_OK): Update. (REGISTER_NAMES): Update. (enum reg_class): Add AR_M_REGS and AR_I_REGS. (REG_CLASS_NAMES, REG_CLASS_CONTENTS): Update. (REGNO_REG_CLASS): Update. (LEGITIMATE_ADDRESS_DISP): Displacement range is 9 bits, not 10. (REGISTER_MOVE_COST): Move out of line. (PREDICATE_CODES): Update. * config/ia64/ia64.md (movdi patterns): Handle ar register classes. (addsi3_plus1_alt, adddi3_plus1_alt): New. (shladd_elim splitter): Allow constants in the predicate. (doloop_end, doloop_end_internal): New. From-SVN: r35358
2000-07-31 01:58:03 +02:00
static int indirect_jump_in_function;
static int indirect_jump_in_function_p PARAMS ((rtx));
static int compute_luids PARAMS ((rtx, rtx, int));
static int biv_elimination_giv_has_0_offset PARAMS ((struct induction *,
struct induction *,
rtx));
1992-02-01 09:24:22 +01:00
/* Benefit penalty, if a giv is not replaceable, i.e. must emit an insn to
copy the value of the strength reduced giv to its original register. */
static int copy_cost;
/* Cost of using a register, to normalize the benefits of a giv. */
static int reg_address_cost;
1992-02-01 09:24:22 +01:00
void
init_loop ()
{
rtx reg = gen_rtx_REG (word_mode, LAST_VIRTUAL_REGISTER + 1);
1992-02-01 09:24:22 +01:00
reg_address_cost = address_cost (reg, SImode);
copy_cost = COSTS_N_INSNS (1);
1992-02-01 09:24:22 +01:00
}
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
/* Compute the mapping from uids to luids.
LUIDs are numbers assigned to insns, like uids,
except that luids increase monotonically through the code.
Start at insn START and stop just before END. Assign LUIDs
starting with PREV_LUID + 1. Return the last assigned LUID + 1. */
static int
compute_luids (start, end, prev_luid)
rtx start, end;
int prev_luid;
{
int i;
rtx insn;
for (insn = start, i = prev_luid; insn != end; insn = NEXT_INSN (insn))
{
if (INSN_UID (insn) >= max_uid_for_loop)
continue;
/* Don't assign luids to line-number NOTEs, so that the distance in
luids between two insns is not affected by -g. */
if (GET_CODE (insn) != NOTE
|| NOTE_LINE_NUMBER (insn) <= 0)
uid_luid[INSN_UID (insn)] = ++i;
else
/* Give a line number note the same luid as preceding insn. */
uid_luid[INSN_UID (insn)] = i;
}
return i + 1;
}
1992-02-01 09:24:22 +01:00
/* Entry point of this file. Perform loop optimization
on the current function. F is the first insn of the function
and DUMPFILE is a stream for output of a trace of actions taken
(or 0 if none should be output). */
void
loop_optimize (f, dumpfile, flags)
1992-02-01 09:24:22 +01:00
/* f is the first instruction of a chain of insns for one function */
rtx f;
FILE *dumpfile;
int flags;
1992-02-01 09:24:22 +01:00
{
register rtx insn;
register int i;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
struct loops loops_data;
struct loops *loops = &loops_data;
struct loop_info *loops_info;
static char *moved_once;
1992-02-01 09:24:22 +01:00
loop_dump_stream = dumpfile;
init_recog_no_volatile ();
max_reg_before_loop = max_reg_num ();
loop_max_reg = max_reg_before_loop;
1992-02-01 09:24:22 +01:00
regs_may_share = 0;
1996-07-04 00:07:53 +02:00
/* Count the number of loops. */
1992-02-01 09:24:22 +01:00
max_loop_num = 0;
for (insn = f; insn; insn = NEXT_INSN (insn))
{
if (GET_CODE (insn) == NOTE
&& NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG)
max_loop_num++;
}
/* Don't waste time if no loops. */
if (max_loop_num == 0)
return;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
loops->num = max_loop_num;
moved_once = (char *) xcalloc (max_reg_before_loop, sizeof (char));
1992-02-01 09:24:22 +01:00
/* Get size to use for tables indexed by uids.
Leave some space for labels allocated by find_and_verify_loops. */
max_uid_for_loop = get_max_uid () + 1 + max_loop_num * 32;
1992-02-01 09:24:22 +01:00
uid_luid = (int *) xcalloc (max_uid_for_loop, sizeof (int));
uid_loop = (struct loop **) xcalloc (max_uid_for_loop,
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
sizeof (struct loop *));
/* Allocate storage for array of loops. */
loops->array = (struct loop *)
xcalloc (loops->num, sizeof (struct loop));
1992-02-01 09:24:22 +01:00
/* Find and process each loop.
First, find them, and record them in order of their beginnings. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
find_and_verify_loops (f, loops);
1992-02-01 09:24:22 +01:00
/* Allocate and initialize auxiliary loop information. */
loops_info = xcalloc (loops->num, sizeof (struct loop_info));
for (i = 0; i < loops->num; i++)
loops->array[i].aux = loops_info + i;
1992-02-01 09:24:22 +01:00
/* Now find all register lifetimes. This must be done after
find_and_verify_loops, because it might reorder the insns in the
function. */
reg_scan (f, max_reg_before_loop, 1);
1992-02-01 09:24:22 +01:00
/* This must occur after reg_scan so that registers created by gcse
will have entries in the register tables.
We could have added a call to reg_scan after gcse_main in toplev.c,
but moving this call to init_alias_analysis is more efficient. */
init_alias_analysis ();
/* See if we went too far. Note that get_max_uid already returns
one more that the maximum uid of all insn. */
if (get_max_uid () > max_uid_for_loop)
abort ();
/* Now reset it to the actual size we need. See above. */
max_uid_for_loop = get_max_uid ();
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
/* find_and_verify_loops has already called compute_luids, but it
might have rearranged code afterwards, so we need to recompute
the luids now. */
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
max_luid = compute_luids (f, NULL_RTX, 0);
1992-02-01 09:24:22 +01:00
/* Don't leave gaps in uid_luid for insns that have been
deleted. It is possible that the first or last insn
using some register has been deleted by cross-jumping.
Make sure that uid_luid for that former insn's uid
points to the general area where that insn used to be. */
for (i = 0; i < max_uid_for_loop; i++)
{
uid_luid[0] = uid_luid[i];
if (uid_luid[0] != 0)
break;
}
for (i = 0; i < max_uid_for_loop; i++)
if (uid_luid[i] == 0)
uid_luid[i] = uid_luid[i - 1];
/* Determine if the function has indirect jump. On some systems
this prevents low overhead loop instructions from being used. */
indirect_jump_in_function = indirect_jump_in_function_p (f);
/* Now scan the loops, last ones first, since this means inner ones are done
before outer ones. */
for (i = max_loop_num - 1; i >= 0; i--)
{
struct loop *loop = &loops->array[i];
struct loop_regs *regs = LOOP_REGS (loop);
regs->moved_once = moved_once;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (! loop->invalid && loop->end)
scan_loop (loop, flags);
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
}
/* If there were lexical blocks inside the loop, they have been
replicated. We will now have more than one NOTE_INSN_BLOCK_BEG
and NOTE_INSN_BLOCK_END for each such block. We must duplicate
the BLOCKs as well. */
if (write_symbols != NO_DEBUG)
reorder_blocks ();
end_alias_analysis ();
/* Clean up. */
free (moved_once);
free (uid_luid);
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
free (uid_loop);
free (loops_info);
free (loops->array);
1992-02-01 09:24:22 +01:00
}
1998-08-19 14:30:47 +02:00
/* Returns the next insn, in execution order, after INSN. START and
END are the NOTE_INSN_LOOP_BEG and NOTE_INSN_LOOP_END for the loop,
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
respectively. LOOP->TOP, if non-NULL, is the top of the loop in the
1998-08-19 14:30:47 +02:00
insn-stream; it is used with loops that are entered near the
bottom. */
static rtx
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
next_insn_in_loop (loop, insn)
const struct loop *loop;
1998-08-19 14:30:47 +02:00
rtx insn;
{
insn = NEXT_INSN (insn);
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (insn == loop->end)
1998-08-19 14:30:47 +02:00
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (loop->top)
1998-08-19 14:30:47 +02:00
/* Go to the top of the loop, and continue there. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
insn = loop->top;
1998-08-19 14:30:47 +02:00
else
/* We're done. */
insn = NULL_RTX;
}
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (insn == loop->scan_start)
1998-08-19 14:30:47 +02:00
/* We're done. */
insn = NULL_RTX;
return insn;
}
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
/* Optimize one loop described by LOOP. */
1992-02-01 09:24:22 +01:00
/* ??? Could also move memory writes out of loops if the destination address
is invariant, the source is invariant, the memory write is not volatile,
and if we can prove that no read inside the loop can read this address
before the write occurs. If there is a read of this address after the
write, then we can also mark the memory read as invariant. */
static void
scan_loop (loop, flags)
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
struct loop *loop;
int flags;
1992-02-01 09:24:22 +01:00
{
struct loop_info *loop_info = LOOP_INFO (loop);
struct loop_regs *regs = LOOP_REGS (loop);
1992-02-01 09:24:22 +01:00
register int i;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
rtx loop_start = loop->start;
rtx loop_end = loop->end;
1998-08-19 14:30:47 +02:00
rtx p;
1992-02-01 09:24:22 +01:00
/* 1 if we are scanning insns that could be executed zero times. */
int maybe_never = 0;
/* 1 if we are scanning insns that might never be executed
due to a subroutine call which might exit before they are reached. */
int call_passed = 0;
/* Jump insn that enters the loop, or 0 if control drops in. */
rtx loop_entry_jump = 0;
/* Number of insns in the loop. */
int insn_count;
int tem;
rtx temp, update_start, update_end;
1992-02-01 09:24:22 +01:00
/* The SET from an insn, if it is the only SET in the insn. */
rtx set, set1;
/* Chain describing insns movable in current loop. */
struct movables *movables = &the_movables;
1992-02-01 09:24:22 +01:00
/* Ratio of extra register life span we can justify
for saving an instruction. More if loop doesn't call subroutines
since in that case saving an insn makes more difference
and more registers are available. */
int threshold;
/* Nonzero if we are scanning instructions in a sub-loop. */
int loop_depth = 0;
1998-08-19 14:30:47 +02:00
int nregs;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
loop->top = 0;
movables->head = 0;
movables->last = 0;
movables->num = 0;
1992-02-01 09:24:22 +01:00
/* Determine whether this loop starts with a jump down to a test at
the end. This will occur for a small number of loops with a test
that is too complex to duplicate in front of the loop.
We search for the first insn or label in the loop, skipping NOTEs.
However, we must be careful not to skip past a NOTE_INSN_LOOP_BEG
(because we might have a loop executed only once that contains a
loop which starts with a jump to its exit test) or a NOTE_INSN_LOOP_END
(in case we have a degenerate loop).
Note that if we mistakenly think that a loop is entered at the top
when, in fact, it is entered at the exit test, the only effect will be
slightly poorer optimization. Making the opposite error can generate
incorrect code. Since very few loops now start with a jump to the
1992-02-01 09:24:22 +01:00
exit test, the code here to detect that case is very conservative. */
for (p = NEXT_INSN (loop_start);
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
p != loop_end
alias.c (mark_constant_function): Use INSN_P. * alias.c (mark_constant_function): Use INSN_P. (init_alias_analysis): Likewise. * combine.c (combine_instructions): Use INSN_P. (can_combine_p): Likewise. (try_combine): Likewise. (distribute_notes): Likewise. (distribute_links): Likewise. * cse.c (cse_around_loop): Use INSN_P. (invalidate_skipped_block): Likewise. (cse_set_around_loop): Likewise. (cse_end_of_basic_block): Likewise. (delete_trivially_dead_insns): Likewise. * emit-rtl.c (unshare_all_rtl_again): Use INSN_P. (unshare_all_rtl_1): Likewise. (next_cc0_user): Likewise. (try_split make_insn_raw): Likewise. (remove_unnecessary_notes): Likewise. * final.c (shorten_branches): Use INSN_P. (leaf_renumber_regs): Likewise. (leaf_renumber_regs_insn): Likewise. * flow.c (find_label_refs): Use INSN_P. (verify_wide_reg): Likewise. (notice_stack_pointer_modification): Likewise. (count_or_remove_death_notes): Likewise. (verify_flow_info): Likewise. (clear_log_links): Likewise. * function.c (fixup_var_refs_insns): Use INSN_P. (compute_insns_for_mem): Likewise. * gcse.c (alloc_gcse_mem): Use INSN_P. (compute_sets): Likewise. (compute_hash_table): Likewise. (classic_gcse): Likewise. (cprop): Likewise. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks_1): Likewise. * global.c (expand_preferences): Use INSN_P. (build_insn_chain): Likewise. * graph.c (node_data): Use INSN_P. * haifa-sched.c (priority): Use INSN_P. (rm_line_notes): Likewise. (rm_other_notes): Likewise. (find_insn_reg_weight): Likewise. (init_target_units): Likewise. (schedule_block): Likewise. (compute_block_forward_dependences): Likewise. (debug_dependencies): Likewise. (set_priorities): Likewise. * integrate.c (function_cannot_inline_p): Use INSN_P. (save_parm_insns): Likewise. (copy_insn_list): Likewise. * jump.c (mark_all_labels): Use INSN_P. (never_reached_warning): Likewise. * lcm.c (optimize_mode_switching): Use INSN_P. * local-alloc.c (validate_equiv_mem): Use INSN_P. (memref_used_between_p): Likewise. (update_equiv_regs): Likewise. (block_alloc): Likewise. (no_conflict_p): Likewise. * loop.c (scan_loop): Use INSN_P. (find_and_verify_loops): Likewise. (count_loop_regs_set): Likewise. (loop_reg_used_before_p): Likewise. (strength_reduce): Likewise. (recombine_givs): Likewise. (check_dbra_loop): Likewise. (load_mems): Likewise. (try_copy_prop): Likewise. * print-rtl.c (print_rtx): Use INSN_P. * recog.c (find_single_use): Use INSN_P. * reg-stack.c (stack_regs_mentioned): Use INSN_P. (next_flags_user): Likewise. (swap_rtx_condition): Likewise. * regmove.c (mark_flags_life_zones): Use INSN_P. (optimize_reg_copy_1): Likewise. (optimize_reg_copy_2): Likewise. (optimize_reg_copy_3): Likewise. (reg_is_remote_constant_p): Likewise. (fixup_match_2): Likewise. (regmove_optimize): Likewise. (fixup_match_1): Likewise. * regrename.c (build_def_use): Use INSN_P. (replace_reg_in_block): Likewise. (consider_use): Likewise. * reload.c (find_equiv_reg): Use INSN_P. * reload1.c (reload): Use INSN_P. (maybe_fix_stack_asms): Likewise. (calculate_needs_all_insns): Likewise. (reload_as_needed): Likewise. (emit_output_reload_insns): Likewise. (delete_address_reloads_1): Likewise. (reload_cse_regs_1): Likewise. (reload_combine): Likewise. (reload_cse_move2add): Likewise. * reorg.c (redundant_insn): Use INSN_P. (dbr_schedule): Likewise. * resource.c (find_dead_or_set_registers): Use INSN_P. (mark_target_live_regs): Likewise. * rtlanal.c (reg_used_between_p): Use INSN_P. (reg_referenced_between_p): Likewise. (reg_set_between_p): Likewise. (reg_set_p): Likewise. (single_set): Likewise. (multiple_sets): Likewise. (find_last_value): Likewise. (reg_set_last): Likewise. (find_reg_note): Likewise. (find_regno_note): Likewise. * sibcall.c (sequence_uses_addressof): Use INSN_P. * simplify-rtx.c (cselib_process_insn): Use INSN_P. * ssa.c (find_evaluations): Use INSN_P. (rename_block): Likewise. (rename_equivalent_regs): Likewise. * unroll.c (loop_find_equiv_value): Use INSN_P. (set_dominates_use): Likewise. * varasm.c (mark_constant_pool): Use INSN_P. (mark_constants): Likewise. * config/alpha/alpha.c (alpha_does_function_need_gp): Use INSN_P. (alphaev4_next_group): Likewise. (alphaev5_next_group): Likewise. * config/c4x/c4x.c (c4x_process_after_reload): Use INSN_P. (c4x_rptb_rpts_p): Likewise. * config/mips/mips.c (mips16_optimize_gp): Use INSN_P. * config/rs6000/rs6000.c (uses_TOC): Use INSN_P. (rs6000_adjust_priority): Likewise. * config/sh/sh.c (sh_loop_align): Use INSN_P. (machine_dependent_reorg): Likewise. (split_branches): Likewise. * config/tahoe/tahoe.c (tahoe_cmp_check): Use INSN_P. From-SVN: r35494
2000-08-04 22:28:08 +02:00
&& GET_CODE (p) != CODE_LABEL && ! INSN_P (p)
1992-02-01 09:24:22 +01:00
&& (GET_CODE (p) != NOTE
|| (NOTE_LINE_NUMBER (p) != NOTE_INSN_LOOP_BEG
&& NOTE_LINE_NUMBER (p) != NOTE_INSN_LOOP_END));
p = NEXT_INSN (p))
;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
loop->scan_start = p;
1992-02-01 09:24:22 +01:00
/* Set up variables describing this loop. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
prescan_loop (loop);
threshold = (loop_info->has_call ? 1 : 2) * (1 + n_non_fixed_regs);
1992-02-01 09:24:22 +01:00
/* If loop has a jump before the first label,
the true entry is the target of that jump.
Start scan from there.
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
But record in LOOP->TOP the place where the end-test jumps
1992-02-01 09:24:22 +01:00
back to so we can scan that after the end of the loop. */
if (GET_CODE (p) == JUMP_INSN)
{
loop_entry_jump = p;
/* Loop entry must be unconditional jump (and not a RETURN) */
if (any_uncondjump_p (p)
1992-02-01 09:24:22 +01:00
&& JUMP_LABEL (p) != 0
/* Check to see whether the jump actually
jumps out of the loop (meaning it's no loop).
This case can happen for things like
do {..} while (0). If this label was generated previously
by loop, we can't tell anything about it and have to reject
the loop. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
&& INSN_IN_RANGE_P (JUMP_LABEL (p), loop_start, loop_end))
1992-02-01 09:24:22 +01:00
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
loop->top = next_label (loop->scan_start);
loop->scan_start = JUMP_LABEL (p);
1992-02-01 09:24:22 +01:00
}
}
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
/* If LOOP->SCAN_START was an insn created by loop, we don't know its luid
1992-02-01 09:24:22 +01:00
as required by loop_reg_used_before_p. So skip such loops. (This
test may never be true, but it's best to play it safe.)
1992-02-01 09:24:22 +01:00
Also, skip loops where we do not start scanning at a label. This
test also rejects loops starting with a JUMP_INSN that failed the
test above. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (INSN_UID (loop->scan_start) >= max_uid_for_loop
|| GET_CODE (loop->scan_start) != CODE_LABEL)
1992-02-01 09:24:22 +01:00
{
if (loop_dump_stream)
fprintf (loop_dump_stream, "\nLoop from %d to %d is phony.\n\n",
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
INSN_UID (loop_start), INSN_UID (loop_end));
1992-02-01 09:24:22 +01:00
return;
}
/* Count number of times each reg is set during this loop. Set
VARRAY_CHAR (regs->may_not_optimize, I) if it is not safe to move
out the setting of register I. Set VARRAY_RTX
(regs->single_usage, I). */
1998-08-19 14:30:47 +02:00
/* Allocate extra space for REGS that might be created by
load_mems. We allocate a little extra slop as well, in the hopes
that even after the moving of movables creates some new registers
we won't have to reallocate these arrays. However, we do grow
the arrays, if necessary, in load_mems_recount_loop_regs_set. */
nregs = max_reg_num () + loop_info->mems_idx + 16;
VARRAY_INT_INIT (regs->set_in_loop, nregs, "set_in_loop");
VARRAY_INT_INIT (regs->n_times_set, nregs, "n_times_set");
VARRAY_CHAR_INIT (regs->may_not_optimize, nregs, "may_not_optimize");
VARRAY_RTX_INIT (regs->single_usage, nregs, "single_usage");
1992-02-01 09:24:22 +01:00
regs->num = nregs;
count_loop_regs_set (loop, regs->may_not_optimize, regs->single_usage,
&insn_count, nregs);
1992-02-01 09:24:22 +01:00
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
{
VARRAY_CHAR (regs->may_not_optimize, i) = 1;
VARRAY_INT (regs->set_in_loop, i) = 1;
}
#ifdef AVOID_CCMODE_COPIES
/* Don't try to move insns which set CC registers if we should not
create CCmode register copies. */
for (i = max_reg_num () - 1; i >= FIRST_PSEUDO_REGISTER; i--)
if (GET_MODE_CLASS (GET_MODE (regno_reg_rtx[i])) == MODE_CC)
VARRAY_CHAR (regs->may_not_optimize, i) = 1;
#endif
bcopy ((char *) &regs->set_in_loop->data,
(char *) &regs->n_times_set->data, nregs * sizeof (int));
1992-02-01 09:24:22 +01:00
if (loop_dump_stream)
{
fprintf (loop_dump_stream, "\nLoop from %d to %d: %d real insns.\n",
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
INSN_UID (loop_start), INSN_UID (loop_end), insn_count);
if (loop->cont)
1992-02-01 09:24:22 +01:00
fprintf (loop_dump_stream, "Continue at insn %d.\n",
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
INSN_UID (loop->cont));
1992-02-01 09:24:22 +01:00
}
/* Scan through the loop finding insns that are safe to move.
Set regs->set_in_loop negative for the reg being set, so that
1992-02-01 09:24:22 +01:00
this reg will be considered invariant for subsequent insns.
We consider whether subsequent insns use the reg
in deciding whether it is worth actually moving.
MAYBE_NEVER is nonzero if we have passed a conditional jump insn
and therefore it is possible that the insns we are scanning
would never be executed. At such times, we must make sure
that it is safe to execute the insn once instead of zero times.
When MAYBE_NEVER is 0, all insns will be executed at least once
so that is not a problem. */
for (p = next_insn_in_loop (loop, loop->scan_start);
1998-08-19 14:30:47 +02:00
p != NULL_RTX;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
p = next_insn_in_loop (loop, p))
1992-02-01 09:24:22 +01:00
{
if (GET_CODE (p) == INSN
&& (set = single_set (p))
&& GET_CODE (SET_DEST (set)) == REG
&& ! VARRAY_CHAR (regs->may_not_optimize, REGNO (SET_DEST (set))))
1992-02-01 09:24:22 +01:00
{
int tem1 = 0;
int tem2 = 0;
int move_insn = 0;
rtx src = SET_SRC (set);
rtx dependencies = 0;
/* Figure out what to use as a source of this insn. If a REG_EQUIV
note is given or if a REG_EQUAL note with a constant operand is
specified, use it as the source and mark that we should move
this insn by calling emit_move_insn rather that duplicating the
insn.
Otherwise, only use the REG_EQUAL contents if a REG_RETVAL note
is present. */
temp = find_reg_note (p, REG_EQUIV, NULL_RTX);
1992-02-01 09:24:22 +01:00
if (temp)
src = XEXP (temp, 0), move_insn = 1;
else
1992-02-01 09:24:22 +01:00
{
temp = find_reg_note (p, REG_EQUAL, NULL_RTX);
1992-02-01 09:24:22 +01:00
if (temp && CONSTANT_P (XEXP (temp, 0)))
src = XEXP (temp, 0), move_insn = 1;
if (temp && find_reg_note (p, REG_RETVAL, NULL_RTX))
1992-02-01 09:24:22 +01:00
{
src = XEXP (temp, 0);
/* A libcall block can use regs that don't appear in
the equivalent expression. To move the libcall,
we must move those regs too. */
dependencies = libcall_other_reg (p, src);
}
}
/* Don't try to optimize a register that was made
by loop-optimization for an inner loop.
We don't know its life-span, so we can't compute the benefit. */
if (REGNO (SET_DEST (set)) >= max_reg_before_loop)
;
else if (/* The register is used in basic blocks other
than the one where it is set (meaning that
something after this point in the loop might
depend on its value before the set). */
! reg_in_basic_block_p (p, SET_DEST (set))
/* And the set is not guaranteed to be executed one
the loop starts, or the value before the set is
needed before the set occurs...
??? Note we have quadratic behaviour here, mitigated
by the fact that the previous test will often fail for
large loops. Rather than re-scanning the entire loop
each time for register usage, we should build tables
of the register usage and use them here instead. */
&& (maybe_never
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
|| loop_reg_used_before_p (loop, set, p)))
/* It is unsafe to move the set.
This code used to consider it OK to move a set of a variable
which was not created by the user and not used in an exit test.
That behavior is incorrect and was removed. */
1992-02-01 09:24:22 +01:00
;
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
else if ((tem = loop_invariant_p (loop, src))
1992-02-01 09:24:22 +01:00
&& (dependencies == 0
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
|| (tem2 = loop_invariant_p (loop, dependencies)) != 0)
&& (VARRAY_INT (regs->set_in_loop,
REGNO (SET_DEST (set))) == 1
1992-02-01 09:24:22 +01:00
|| (tem1
= consec_sets_invariant_p
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
(loop, SET_DEST (set),
VARRAY_INT (regs->set_in_loop,
REGNO (SET_DEST (set))),
p)))
1992-02-01 09:24:22 +01:00
/* If the insn can cause a trap (such as divide by zero),
can't move it unless it's guaranteed to be executed
once loop is entered. Even a function call might
prevent the trap insn from being reached
(since it might exit!) */
&& ! ((maybe_never || call_passed)
&& may_trap_p (src)))
{
register struct movable *m;
register int regno = REGNO (SET_DEST (set));
/* A potential lossage is where we have a case where two insns
can be combined as long as they are both in the loop, but
we move one of them outside the loop. For large loops,
this can lose. The most common case of this is the address
of a function being called.
1992-02-01 09:24:22 +01:00
Therefore, if this register is marked as being used exactly
once if we are in a loop with calls (a "large loop"), see if
we can replace the usage of this register with the source
of this SET. If we can, delete this insn.
1992-02-01 09:24:22 +01:00
Don't do this if P has a REG_RETVAL note or if we have
SMALL_REGISTER_CLASSES and SET_SRC is a hard register. */
if (loop_info->has_call
&& VARRAY_RTX (regs->single_usage, regno) != 0
&& VARRAY_RTX (regs->single_usage, regno) != const0_rtx
&& REGNO_FIRST_UID (regno) == INSN_UID (p)
&& (REGNO_LAST_UID (regno)
== INSN_UID (VARRAY_RTX (regs->single_usage, regno)))
&& VARRAY_INT (regs->set_in_loop, regno) == 1
1992-02-01 09:24:22 +01:00
&& ! side_effects_p (SET_SRC (set))
&& ! find_reg_note (p, REG_RETVAL, NULL_RTX)
&& (! SMALL_REGISTER_CLASSES
|| (! (GET_CODE (SET_SRC (set)) == REG
&& REGNO (SET_SRC (set)) < FIRST_PSEUDO_REGISTER)))
1992-02-01 09:24:22 +01:00
/* This test is not redundant; SET_SRC (set) might be
a call-clobbered register and the life of REGNO
might span a call. */
&& ! modified_between_p (SET_SRC (set), p,
VARRAY_RTX
(regs->single_usage, regno))
&& no_labels_between_p (p, VARRAY_RTX (regs->single_usage,
regno))
1992-02-01 09:24:22 +01:00
&& validate_replace_rtx (SET_DEST (set), SET_SRC (set),
VARRAY_RTX
(regs->single_usage, regno)))
1992-02-01 09:24:22 +01:00
{
/* Replace any usage in a REG_EQUAL note. Must copy the
new source, so that we don't get rtx sharing between the
SET_SOURCE and REG_NOTES of insn p. */
REG_NOTES (VARRAY_RTX (regs->single_usage, regno))
= replace_rtx (REG_NOTES (VARRAY_RTX
(regs->single_usage, regno)),
SET_DEST (set), copy_rtx (SET_SRC (set)));
1992-02-01 09:24:22 +01:00
PUT_CODE (p, NOTE);
NOTE_LINE_NUMBER (p) = NOTE_INSN_DELETED;
NOTE_SOURCE_FILE (p) = 0;
VARRAY_INT (regs->set_in_loop, regno) = 0;
1992-02-01 09:24:22 +01:00
continue;
}
m = (struct movable *) alloca (sizeof (struct movable));
m->next = 0;
m->insn = p;
m->set_src = src;
m->dependencies = dependencies;
m->set_dest = SET_DEST (set);
m->force = 0;
m->consec = VARRAY_INT (regs->set_in_loop,
REGNO (SET_DEST (set))) - 1;
1992-02-01 09:24:22 +01:00
m->done = 0;
m->forces = 0;
m->partial = 0;
m->move_insn = move_insn;
m->move_insn_first = 0;
m->is_equiv = (find_reg_note (p, REG_EQUIV, NULL_RTX) != 0);
1992-02-01 09:24:22 +01:00
m->savemode = VOIDmode;
m->regno = regno;
/* Set M->cond if either loop_invariant_p
or consec_sets_invariant_p returned 2
(only conditionally invariant). */
1992-02-01 09:24:22 +01:00
m->cond = ((tem | tem1 | tem2) > 1);
m->global = (uid_luid[REGNO_LAST_UID (regno)]
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
> INSN_LUID (loop_end)
|| uid_luid[REGNO_FIRST_UID (regno)] < INSN_LUID (loop_start));
1992-02-01 09:24:22 +01:00
m->match = 0;
m->lifetime = (uid_luid[REGNO_LAST_UID (regno)]
- uid_luid[REGNO_FIRST_UID (regno)]);
m->savings = VARRAY_INT (regs->n_times_set, regno);
if (find_reg_note (p, REG_RETVAL, NULL_RTX))
1992-02-01 09:24:22 +01:00
m->savings += libcall_benefit (p);
VARRAY_INT (regs->set_in_loop, regno) = move_insn ? -2 : -1;
1992-02-01 09:24:22 +01:00
/* Add M to the end of the chain MOVABLES. */
if (movables->head == 0)
movables->head = m;
1992-02-01 09:24:22 +01:00
else
movables->last->next = m;
movables->last = m;
1992-02-01 09:24:22 +01:00
if (m->consec > 0)
{
/* It is possible for the first instruction to have a
REG_EQUAL note but a non-invariant SET_SRC, so we must
remember the status of the first instruction in case
the last instruction doesn't have a REG_EQUAL note. */
m->move_insn_first = m->move_insn;
1992-02-01 09:24:22 +01:00
/* Skip this insn, not checking REG_LIBCALL notes. */
p = next_nonnote_insn (p);
1992-02-01 09:24:22 +01:00
/* Skip the consecutive insns, if there are any. */
p = skip_consec_insns (p, m->consec);
/* Back up to the last insn of the consecutive group. */
p = prev_nonnote_insn (p);
/* We must now reset m->move_insn, m->is_equiv, and possibly
m->set_src to correspond to the effects of all the
insns. */
temp = find_reg_note (p, REG_EQUIV, NULL_RTX);
1992-02-01 09:24:22 +01:00
if (temp)
m->set_src = XEXP (temp, 0), m->move_insn = 1;
else
{
temp = find_reg_note (p, REG_EQUAL, NULL_RTX);
1992-02-01 09:24:22 +01:00
if (temp && CONSTANT_P (XEXP (temp, 0)))
m->set_src = XEXP (temp, 0), m->move_insn = 1;
else
m->move_insn = 0;
}
m->is_equiv = (find_reg_note (p, REG_EQUIV, NULL_RTX) != 0);
1992-02-01 09:24:22 +01:00
}
}
/* If this register is always set within a STRICT_LOW_PART
or set to zero, then its high bytes are constant.
So clear them outside the loop and within the loop
just load the low bytes.
We must check that the machine has an instruction to do so.
Also, if the value loaded into the register
depends on the same register, this cannot be done. */
else if (SET_SRC (set) == const0_rtx
&& GET_CODE (NEXT_INSN (p)) == INSN
&& (set1 = single_set (NEXT_INSN (p)))
&& GET_CODE (set1) == SET
&& (GET_CODE (SET_DEST (set1)) == STRICT_LOW_PART)
&& (GET_CODE (XEXP (SET_DEST (set1), 0)) == SUBREG)
&& (SUBREG_REG (XEXP (SET_DEST (set1), 0))
== SET_DEST (set))
&& !reg_mentioned_p (SET_DEST (set), SET_SRC (set1)))
{
register int regno = REGNO (SET_DEST (set));
if (VARRAY_INT (regs->set_in_loop, regno) == 2)
1992-02-01 09:24:22 +01:00
{
register struct movable *m;
m = (struct movable *) alloca (sizeof (struct movable));
m->next = 0;
m->insn = p;
m->set_dest = SET_DEST (set);
m->dependencies = 0;
m->force = 0;
m->consec = 0;
m->done = 0;
m->forces = 0;
m->move_insn = 0;
m->move_insn_first = 0;
1992-02-01 09:24:22 +01:00
m->partial = 1;
/* If the insn may not be executed on some cycles,
we can't clear the whole reg; clear just high part.
Not even if the reg is used only within this loop.
Consider this:
while (1)
while (s != t) {
if (foo ()) x = *s;
use (x);
}
Clearing x before the inner loop could clobber a value
being saved from the last time around the outer loop.
However, if the reg is not used outside this loop
and all uses of the register are in the same
basic block as the store, there is no problem.
If this insn was made by loop, we don't know its
INSN_LUID and hence must make a conservative
1996-07-04 00:07:53 +02:00
assumption. */
1992-02-01 09:24:22 +01:00
m->global = (INSN_UID (p) >= max_uid_for_loop
|| (uid_luid[REGNO_LAST_UID (regno)]
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
> INSN_LUID (loop_end))
|| (uid_luid[REGNO_FIRST_UID (regno)]
1992-02-01 09:24:22 +01:00
< INSN_LUID (p))
|| (labels_in_range_p
(p, uid_luid[REGNO_FIRST_UID (regno)])));
1992-02-01 09:24:22 +01:00
if (maybe_never && m->global)
m->savemode = GET_MODE (SET_SRC (set1));
else
m->savemode = VOIDmode;
m->regno = regno;
m->cond = 0;
m->match = 0;
m->lifetime = (uid_luid[REGNO_LAST_UID (regno)]
- uid_luid[REGNO_FIRST_UID (regno)]);
1992-02-01 09:24:22 +01:00
m->savings = 1;
VARRAY_INT (regs->set_in_loop, regno) = -1;
1992-02-01 09:24:22 +01:00
/* Add M to the end of the chain MOVABLES. */
if (movables->head == 0)
movables->head = m;
1992-02-01 09:24:22 +01:00
else
movables->last->next = m;
movables->last = m;
1992-02-01 09:24:22 +01:00
}
}
}
/* Past a call insn, we get to insns which might not be executed
because the call might exit. This matters for insns that trap.
Constant and pure call insns always return, so they don't count. */
else if (GET_CODE (p) == CALL_INSN && ! CONST_CALL_P (p))
1992-02-01 09:24:22 +01:00
call_passed = 1;
/* Past a label or a jump, we get to insns for which we
can't count on whether or how many times they will be
executed during each iteration. Therefore, we can
only move out sets of trivial variables
(those not used after the loop). */
/* Similar code appears twice in strength_reduce. */
1992-02-01 09:24:22 +01:00
else if ((GET_CODE (p) == CODE_LABEL || GET_CODE (p) == JUMP_INSN)
/* If we enter the loop in the middle, and scan around to the
beginning, don't set maybe_never for that. This must be an
unconditional jump, otherwise the code at the top of the
loop might never be executed. Unconditional jumps are
followed a by barrier then loop end. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
&& ! (GET_CODE (p) == JUMP_INSN && JUMP_LABEL (p) == loop->top
&& NEXT_INSN (NEXT_INSN (p)) == loop_end
&& any_uncondjump_p (p)))
1992-02-01 09:24:22 +01:00
maybe_never = 1;
else if (GET_CODE (p) == NOTE)
{
/* At the virtual top of a converted loop, insns are again known to
be executed: logically, the loop begins here even though the exit
code has been duplicated. */
if (NOTE_LINE_NUMBER (p) == NOTE_INSN_LOOP_VTOP && loop_depth == 0)
maybe_never = call_passed = 0;
else if (NOTE_LINE_NUMBER (p) == NOTE_INSN_LOOP_BEG)
loop_depth++;
else if (NOTE_LINE_NUMBER (p) == NOTE_INSN_LOOP_END)
loop_depth--;
}
1992-02-01 09:24:22 +01:00
}
/* If one movable subsumes another, ignore that other. */
ignore_some_movables (movables);
/* For each movable insn, see if the reg that it loads
leads when it dies right into another conditionally movable insn.
If so, record that the second insn "forces" the first one,
since the second can be moved only if the first is. */
force_movables (movables);
/* See if there are multiple movable insns that load the same value.
If there are, make all but the first point at the first one
through the `match' field, and add the priorities of them
all together as the priority of the first. */
combine_movables (movables, regs);
1992-02-01 09:24:22 +01:00
/* Now consider each movable insn to decide whether it is worth moving.
Store 0 in regs->set_in_loop for each reg that is moved.
1992-02-01 09:24:22 +01:00
Generally this increases code size, so do not move moveables when
optimizing for code size. */
if (! optimize_size)
move_movables (loop, movables, threshold, insn_count);
1992-02-01 09:24:22 +01:00
/* Now candidates that still are negative are those not moved.
Change regs->set_in_loop to indicate that those are not actually
invariant. */
1992-02-01 09:24:22 +01:00
for (i = 0; i < nregs; i++)
if (VARRAY_INT (regs->set_in_loop, i) < 0)
VARRAY_INT (regs->set_in_loop, i) = VARRAY_INT (regs->n_times_set, i);
1992-02-01 09:24:22 +01:00
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
/* Now that we've moved some things out of the loop, we might be able to
hoist even more memory references. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
load_mems_and_recount_loop_regs_set (loop, &insn_count);
for (update_start = loop_start;
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
PREV_INSN (update_start)
&& GET_CODE (PREV_INSN (update_start)) != CODE_LABEL;
update_start = PREV_INSN (update_start))
;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
update_end = NEXT_INSN (loop_end);
reg_scan_update (update_start, update_end, loop_max_reg);
loop_max_reg = max_reg_num ();
1992-02-01 09:24:22 +01:00
if (flag_strength_reduce)
{
if (update_end && GET_CODE (update_end) == CODE_LABEL)
/* Ensure our label doesn't go away. */
LABEL_NUSES (update_end)++;
strength_reduce (loop, insn_count, flags);
reg_scan_update (update_start, update_end, loop_max_reg);
loop_max_reg = max_reg_num ();
if (update_end && GET_CODE (update_end) == CODE_LABEL
&& --LABEL_NUSES (update_end) == 0)
delete_insn (update_end);
}
VARRAY_FREE (regs->single_usage);
VARRAY_FREE (regs->set_in_loop);
VARRAY_FREE (regs->n_times_set);
VARRAY_FREE (regs->may_not_optimize);
1992-02-01 09:24:22 +01:00
}
/* Add elements to *OUTPUT to record all the pseudo-regs
mentioned in IN_THIS but not mentioned in NOT_IN_THIS. */
void
record_excess_regs (in_this, not_in_this, output)
rtx in_this, not_in_this;
rtx *output;
{
enum rtx_code code;
rtl.h (rtx_format): Constify a char*. * rtl.h (rtx_format): Constify a char*. * rtl.c (rtx_format): Likewise. (copy_rtx, copy_most_rtx, read_rtx): Likewise. (init_rtl): Use accessor macro, not `rtx_format'. * alias.c (rtx_equal_for_memref_p, find_symbolic_term): Constify a char*. * caller-save.c (mark_referenced_regs): Likewise. * combine.c (subst, make_compound_operation, known_cond, gen_rtx_combine, update_table_tick, get_last_value_validate, use_crosses_set_p, mark_used_regs_combine, move_deaths): Likewise. * cse.c (rtx_cost, mention_regs, canon_hash, exp_equiv_p, refers_to_p, canon_reg, fold_rtx, cse_process_notes, count_reg_usage): Likewise. * emit-rtl.c (gen_rtx, copy_rtx_if_shared, reset_used_flags): Likewise. * final.c (leaf_renumber_regs_insn): Likewise. * flow.c (mark_used_regs, find_use_as_address, dump_flow_info, dump_edge_info, count_reg_references): Likewise. * function.c (fixup_var_refs_1, walk_fixup_memory_subreg, fixup_stack_1, purge_addressof_1, instantiate_virtual_regs_1): Likewise. * gcse.c (oprs_unchanged_p, hash_expr_1, expr_equiv_p, oprs_not_set_p, expr_killed_p, compute_transp, find_used_regs, add_label_notes): Likewise. * genattrtab.c (attr_rtx, attr_copy_rtx, encode_units_mask, clear_struct_flag, count_sub_rtxs, count_alternatives, compares_alternatives_p, contained_in_p, walk_attr_value, write_expr_attr_cache): Likewise. * genconfig.c (walk_insn_part): Likewise. * genemit.c (max_operand_1, gen_exp): Likewise. * genextract.c (walk_rtx): Likewise. * genflags.c (num_operands): Likewise. * genoutput.c (scan_operands): Likewise. * genpeep.c (match_rtx): Likewise. * genrecog.c (add_to_sequence): Likewise. * haifa-sched.c (may_trap_exp, sched_analyze_2, attach_deaths): Likewise. * integrate.c (save_constants, copy_for_inline, copy_rtx_and_substitute, subst_constants, restore_constants): Likewise. * jump.c (mark_jump_label, invert_exp, redirect_exp, rtx_renumbered_equal_p, rtx_equal_for_thread_p): Likewise. * local-alloc.c (contains_replace_regs, memref_referenced_p): Likewise. * loop.c (record_excess_regs, rtx_equal_for_loop_p, add_label_notes, replace_call_address, count_nonfixed_reads, invariant_p, find_single_use_in_loop, find_mem_givs, find_life_end, maybe_eliminate_biv_1, update_reg_last_use): Likewise. * print-rtl.c (reg_names, print_rtx): Likewise. * recog.c (validate_replace_rtx_1, find_single_use_1): Likewise. * reg-stack.c (stack_regs_mentioned_p, record_label_references, record_reg_life_pat, swap_rtx_condition, goto_block_pat, print_blocks): Likewise. * regclass.c (fix_register, record_address_regs, reg_scan_mark_refs): Likewise. * regmove.c (stable_but_for_p): Likewise. * reload.c (loc_mentioned_in_p, operands_match_p, find_reloads_toplevsubst_reg_equivs, find_reloads_address_1, copy_replacements, refers_to_regno_for_reload_p, refers_to_mem_for_reload_p, find_inc_amount, regno_clobbered_p, reload_when_needed_name, reg_class_names, debug_reload_to_stream): Likewise. * reload1.c (eliminate_regs, scan_paradoxical_subregs, delete_address_reloads_1, count_occurrences, reload_cse_mem_conflict_p, reload_combine_note_use, add_auto_inc_notes): Likewise. * resource.c (mark_referenced_resources, mark_set_resources): Likewise. * rtlanal.c (rtx_unstable_p, rtx_varies_p, rtx_addr_varies_p, reg_mentioned_p, regs_set_between_p, modified_between_p, modified_in_p, refers_to_regno_p, reg_overlap_mentioned_p, rtx_equal_p, volatile_insn_p, volatile_refs_p, side_effects_p, may_trap_p, inequality_comparisons_p, replace_rtx, replace_regs, jmp_uses_reg_or_mem, for_each_rtx, regno_use_in): Likewise. * sched.c (sched_analyze_2, attach_deaths): Likewise. * stupid.c (stupid_mark_refs): Likewise. * unroll.c (remap_split_bivs): Likewise. * varasm.c (mark_constants): Likewise. * a29k/a29k.c (uses_local_reg_p): Likewise. * alpha/alpha.c (summarize_insn): Likewise. * arm/arm.c (symbol_mentioned_p, label_mentioned_p, eliminate_lr2ip): Likewise. * arm/thumb.c (symbol_mentioned_p, label_mentioned_p): Likewise. * i386/i386.c (symbolic_reference_mentioned_p, copy_all_rtx, reg_mentioned_in_mem): Likewise. * ns32k/ns32k.c (global_symbolic_reference_mentioned_p, symbolic_reference_mentioned_p): Likewise. * romp/romp.c (unsigned_comparisons_p, hash_rtx): Likewise. * sh/sh.c (regs_used, mark_use): Likewise. * vax/vax.c (vax_rtx_cost): Likewise. From-SVN: r28784
1999-08-21 01:05:25 +02:00
const char *fmt;
1992-02-01 09:24:22 +01:00
int i;
code = GET_CODE (in_this);
switch (code)
{
case PC:
case CC0:
case CONST_INT:
case CONST_DOUBLE:
case CONST:
case SYMBOL_REF:
case LABEL_REF:
return;
case REG:
if (REGNO (in_this) >= FIRST_PSEUDO_REGISTER
&& ! reg_mentioned_p (in_this, not_in_this))
*output = gen_rtx_EXPR_LIST (VOIDmode, in_this, *output);
1992-02-01 09:24:22 +01:00
return;
default:
break;
1992-02-01 09:24:22 +01:00
}
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
int j;
switch (fmt[i])
{
case 'E':
for (j = 0; j < XVECLEN (in_this, i); j++)
record_excess_regs (XVECEXP (in_this, i, j), not_in_this, output);
break;
case 'e':
record_excess_regs (XEXP (in_this, i), not_in_this, output);
break;
}
}
}
/* Check what regs are referred to in the libcall block ending with INSN,
aside from those mentioned in the equivalent value.
If there are none, return 0.
If there are one or more, return an EXPR_LIST containing all of them. */
rtx
1992-02-01 09:24:22 +01:00
libcall_other_reg (insn, equiv)
rtx insn, equiv;
{
rtx note = find_reg_note (insn, REG_RETVAL, NULL_RTX);
1992-02-01 09:24:22 +01:00
rtx p = XEXP (note, 0);
rtx output = 0;
/* First, find all the regs used in the libcall block
that are not mentioned as inputs to the result. */
while (p != insn)
{
if (GET_CODE (p) == INSN || GET_CODE (p) == JUMP_INSN
|| GET_CODE (p) == CALL_INSN)
record_excess_regs (PATTERN (p), equiv, &output);
p = NEXT_INSN (p);
}
return output;
}
/* Return 1 if all uses of REG
are between INSN and the end of the basic block. */
static int
1992-02-01 09:24:22 +01:00
reg_in_basic_block_p (insn, reg)
rtx insn, reg;
{
int regno = REGNO (reg);
rtx p;
if (REGNO_FIRST_UID (regno) != INSN_UID (insn))
1992-02-01 09:24:22 +01:00
return 0;
/* Search this basic block for the already recorded last use of the reg. */
for (p = insn; p; p = NEXT_INSN (p))
{
switch (GET_CODE (p))
{
case NOTE:
break;
case INSN:
case CALL_INSN:
/* Ordinary insn: if this is the last use, we win. */
if (REGNO_LAST_UID (regno) == INSN_UID (p))
1992-02-01 09:24:22 +01:00
return 1;
break;
case JUMP_INSN:
/* Jump insn: if this is the last use, we win. */
if (REGNO_LAST_UID (regno) == INSN_UID (p))
1992-02-01 09:24:22 +01:00
return 1;
/* Otherwise, it's the end of the basic block, so we lose. */
return 0;
case CODE_LABEL:
case BARRIER:
/* It's the end of the basic block, so we lose. */
return 0;
default:
break;
1992-02-01 09:24:22 +01:00
}
}
/* The "last use" that was recorded can't be found after the first
use. This can happen when the last use was deleted while
processing an inner loop, this inner loop was then completely
unrolled, and the outer loop is always exited after the inner loop,
so that everything after the first use becomes a single basic block. */
return 1;
1992-02-01 09:24:22 +01:00
}
/* Compute the benefit of eliminating the insns in the block whose
last insn is LAST. This may be a group of insns used to compute a
value directly or can contain a library call. */
static int
libcall_benefit (last)
rtx last;
{
rtx insn;
int benefit = 0;
for (insn = XEXP (find_reg_note (last, REG_RETVAL, NULL_RTX), 0);
1992-02-01 09:24:22 +01:00
insn != last; insn = NEXT_INSN (insn))
{
if (GET_CODE (insn) == CALL_INSN)
benefit += 10; /* Assume at least this many insns in a library
1996-07-04 00:07:53 +02:00
routine. */
1992-02-01 09:24:22 +01:00
else if (GET_CODE (insn) == INSN
&& GET_CODE (PATTERN (insn)) != USE
&& GET_CODE (PATTERN (insn)) != CLOBBER)
benefit++;
}
return benefit;
}
/* Skip COUNT insns from INSN, counting library calls as 1 insn. */
static rtx
skip_consec_insns (insn, count)
rtx insn;
int count;
{
for (; count > 0; count--)
{
rtx temp;
/* If first insn of libcall sequence, skip to end. */
/* Do this at start of loop, since INSN is guaranteed to
1992-02-01 09:24:22 +01:00
be an insn here. */
if (GET_CODE (insn) != NOTE
&& (temp = find_reg_note (insn, REG_LIBCALL, NULL_RTX)))
1992-02-01 09:24:22 +01:00
insn = XEXP (temp, 0);
do
insn = NEXT_INSN (insn);
1992-02-01 09:24:22 +01:00
while (GET_CODE (insn) == NOTE);
}
return insn;
}
/* Ignore any movable whose insn falls within a libcall
which is part of another movable.
We make use of the fact that the movable for the libcall value
was made later and so appears later on the chain. */
static void
ignore_some_movables (movables)
struct movables *movables;
1992-02-01 09:24:22 +01:00
{
register struct movable *m, *m1;
for (m = movables->head; m; m = m->next)
1992-02-01 09:24:22 +01:00
{
/* Is this a movable for the value of a libcall? */
rtx note = find_reg_note (m->insn, REG_RETVAL, NULL_RTX);
1992-02-01 09:24:22 +01:00
if (note)
{
rtx insn;
/* Check for earlier movables inside that range,
and mark them invalid. We cannot use LUIDs here because
insns created by loop.c for prior loops don't have LUIDs.
Rather than reject all such insns from movables, we just
explicitly check each insn in the libcall (since invariant
libcalls aren't that common). */
for (insn = XEXP (note, 0); insn != m->insn; insn = NEXT_INSN (insn))
for (m1 = movables->head; m1 != m; m1 = m1->next)
1992-02-01 09:24:22 +01:00
if (m1->insn == insn)
m1->done = 1;
}
}
}
1992-02-01 09:24:22 +01:00
/* For each movable insn, see if the reg that it loads
leads when it dies right into another conditionally movable insn.
If so, record that the second insn "forces" the first one,
since the second can be moved only if the first is. */
static void
force_movables (movables)
struct movables *movables;
1992-02-01 09:24:22 +01:00
{
register struct movable *m, *m1;
for (m1 = movables->head; m1; m1 = m1->next)
1992-02-01 09:24:22 +01:00
/* Omit this if moving just the (SET (REG) 0) of a zero-extend. */
if (!m1->partial && !m1->done)
{
int regno = m1->regno;
for (m = m1->next; m; m = m->next)
/* ??? Could this be a bug? What if CSE caused the
register of M1 to be used after this insn?
Since CSE does not update regno_last_uid,
this insn M->insn might not be where it dies.
But very likely this doesn't matter; what matters is
that M's reg is computed from M1's reg. */
if (INSN_UID (m->insn) == REGNO_LAST_UID (regno)
1992-02-01 09:24:22 +01:00
&& !m->done)
break;
if (m != 0 && m->set_src == m1->set_dest
/* If m->consec, m->set_src isn't valid. */
&& m->consec == 0)
m = 0;
/* Increase the priority of the moving the first insn
since it permits the second to be moved as well. */
if (m != 0)
{
m->forces = m1;
m1->lifetime += m->lifetime;
m1->savings += m->savings;
1992-02-01 09:24:22 +01:00
}
}
}
/* Find invariant expressions that are equal and can be combined into
one register. */
static void
combine_movables (movables, regs)
struct movables *movables;
struct loop_regs *regs;
1992-02-01 09:24:22 +01:00
{
register struct movable *m;
char *matched_regs = (char *) xmalloc (regs->num);
1992-02-01 09:24:22 +01:00
enum machine_mode mode;
/* Regs that are set more than once are not allowed to match
or be matched. I'm no longer sure why not. */
/* Perhaps testing m->consec_sets would be more appropriate here? */
for (m = movables->head; m; m = m->next)
if (m->match == 0 && VARRAY_INT (regs->n_times_set, m->regno) == 1
&& !m->partial)
1992-02-01 09:24:22 +01:00
{
register struct movable *m1;
int regno = m->regno;
alias.c [...] (init_alias_analysis, [...]): Use memset () instead of bzero (). * alias.c (init_alias_analysis), calls.c (expand_call, emit_library_call_value_1), combine.c (init_reg_last_arrays), cse.c (new_basic_block), dbxout.c (dbxout_type), diagnostic.c (init_output_buffer, set_diagnostic_context), dwarf2out.c (equate_decl_number_to_die, build_abbrev_table), emit-rtl.c (init_emit_once), fold-const.c (mul_double, div_and_round_double), function.c (assign_parms), gcse.c (compute_can_copy, alloc_gcse_mem, alloc_reg_set_mem, record_one_set, compute_hash_table, compute_set_hash_table, compute_expr_hash_table), genattrtab.c (optimize_attrs), global.c (global_alloc, global_conflicts), haifa-sched.c (compute_trg_info, clear_units, schedule_block), integrate.c (initialize_for_inline, expand_inline_function), jump.c (thread_jumps), local-alloc.c (local_alloc), loop.c (combine_movables, count_loop_regs_set, load_mems_and_recount_loop_regs_set), print-tree.c (debug_tree), regclass.c (init_reg_sets, init_reg_sets_1, regclass, record_reg_classes, allocate_reg_info), reload.c (get_secondary_mem, remove_address_replacements, find_reloads), reload1.c (reload, set_initial_label_offsets, finish_spills, reload_as_needed, choose_reload_regs_init, reload_cse_simplify_operands), reorg.c (dbr_schedule), sbitmap.c (sbitmap_zero), simplify-rtx.c (simplify_plus_minus), ssa.c (rename_registers), stmt.c (expand_end_case), unroll.c (unroll_loop), varray.c (varray_grow), objc/objc-act.c: Use memset () instead of bzero (). ch: * actions.c (check_missing_cases), typeck.c (build_chill_slice, build_chill_cast): Use memset () instead of bzero (). cp: * class.c (duplicate_tag_error, build_vtbl_initializer), decl.c (push_binding_level), error.c (cp_tree_printer), pt.c (process_partial_specialization, tsubst_template_arg_vector), search.c (lookup_member): Use memset () instead of bzero (). java: * expr.c (note_instructions), jcf-io.c (find_class), jcf-parse.c (init_outgoing_cpool), lex.c (java_init_lex): Use memset () instead of bzero (). From-SVN: r37303
2000-11-07 23:50:06 +01:00
memset (matched_regs, 0, regs->num);
1992-02-01 09:24:22 +01:00
matched_regs[regno] = 1;
/* We want later insns to match the first one. Don't make the first
one match any later ones. So start this loop at m->next. */
for (m1 = m->next; m1; m1 = m1->next)
if (m != m1 && m1->match == 0 && VARRAY_INT (regs->n_times_set,
m1->regno) == 1
1992-02-01 09:24:22 +01:00
/* A reg used outside the loop mustn't be eliminated. */
&& !m1->global
/* A reg used for zero-extending mustn't be eliminated. */
&& !m1->partial
&& (matched_regs[m1->regno]
||
(
/* Can combine regs with different modes loaded from the
same constant only if the modes are the same or
if both are integer modes with M wider or the same
width as M1. The check for integer is redundant, but
safe, since the only case of differing destination
modes with equal sources is when both sources are
VOIDmode, i.e., CONST_INT. */
(GET_MODE (m->set_dest) == GET_MODE (m1->set_dest)
|| (GET_MODE_CLASS (GET_MODE (m->set_dest)) == MODE_INT
&& GET_MODE_CLASS (GET_MODE (m1->set_dest)) == MODE_INT
&& (GET_MODE_BITSIZE (GET_MODE (m->set_dest))
>= GET_MODE_BITSIZE (GET_MODE (m1->set_dest)))))
/* See if the source of M1 says it matches M. */
&& ((GET_CODE (m1->set_src) == REG
&& matched_regs[REGNO (m1->set_src)])
|| rtx_equal_for_loop_p (m->set_src, m1->set_src,
movables, regs))))
1992-02-01 09:24:22 +01:00
&& ((m->dependencies == m1->dependencies)
|| rtx_equal_p (m->dependencies, m1->dependencies)))
{
m->lifetime += m1->lifetime;
m->savings += m1->savings;
m1->done = 1;
m1->match = m;
matched_regs[m1->regno] = 1;
}
}
/* Now combine the regs used for zero-extension.
This can be done for those not marked `global'
provided their lives don't overlap. */
for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
mode = GET_MODE_WIDER_MODE (mode))
{
register struct movable *m0 = 0;
/* Combine all the registers for extension from mode MODE.
Don't combine any that are used outside this loop. */
for (m = movables->head; m; m = m->next)
1992-02-01 09:24:22 +01:00
if (m->partial && ! m->global
&& mode == GET_MODE (SET_SRC (PATTERN (NEXT_INSN (m->insn)))))
{
register struct movable *m1;
int first = uid_luid[REGNO_FIRST_UID (m->regno)];
int last = uid_luid[REGNO_LAST_UID (m->regno)];
1992-02-01 09:24:22 +01:00
if (m0 == 0)
{
/* First one: don't check for overlap, just record it. */
m0 = m;
continue;
1992-02-01 09:24:22 +01:00
}
/* Make sure they extend to the same mode.
(Almost always true.) */
if (GET_MODE (m->set_dest) != GET_MODE (m0->set_dest))
continue;
1992-02-01 09:24:22 +01:00
/* We already have one: check for overlap with those
already combined together. */
for (m1 = movables->head; m1 != m; m1 = m1->next)
1992-02-01 09:24:22 +01:00
if (m1 == m0 || (m1->partial && m1->match == m0))
if (! (uid_luid[REGNO_FIRST_UID (m1->regno)] > last
|| uid_luid[REGNO_LAST_UID (m1->regno)] < first))
1992-02-01 09:24:22 +01:00
goto overlap;
/* No overlap: we can combine this with the others. */
m0->lifetime += m->lifetime;
m0->savings += m->savings;
m->done = 1;
m->match = m0;
overlap:
;
1992-02-01 09:24:22 +01:00
}
}
/* Clean up. */
free (matched_regs);
1992-02-01 09:24:22 +01:00
}
/* Return 1 if regs X and Y will become the same if moved. */
static int
regs_match_p (x, y, movables)
rtx x, y;
struct movables *movables;
1992-02-01 09:24:22 +01:00
{
* Rework fields used to describe positions of bitfields and modify sizes to be unsigned and use HOST_WIDE_INT. * alias.c (reg_known_value_size): Now unsigned. * c-typeck.c (build_unary_op, case ADDR_EXPR): Use byte_position. (really_start_incremental_init): Use bitsize_zero_node. (push_init_level, pop_init_level, output_init_element): Likewise. Use bitsize_unit_node and bitsize_one_node. (output_pending_init_elements, process_init_element): Likewise. * combine.c (combine_max_regno, reg_sign_bit_copies): Now unsigned. (make_extraction): Position and length HOST_WIDE_INT and unsigned HOST_WIDE_INT, respectively. (get_pos_from_mask): Passed in value is unsigned HOST_WIDE_INT. (num_sign_bit_copies): Returns unsigned. BITWIDTH now unsigned; rework arithmetic. Remove recursive call from arg to MAX. (combine_instructions, init_reg_last_arrays): NREGS now unsigned. (setup_incoming_promotions, can_combine_p, try_combine, simplify_set): REGNO now unsigned. (set_nonzero_bit_and_sign_copies): NUM now unsigned. (find_split_point, expand_compound_operation, make_extraction): LEN now unsigned HOST_WIDE_INT, POS now HOST_WIDE_INT. (make_field_assignment): Likewise. (combine_simplify_rtx): Add cast. (expand_compound_operation): MODEWIDTH now unsigned; rework arithmetic. (force_to_mode): WIDTH now unsigned; add cast. (if_then_else_cond): SIZE now unsigned. (nonzero_bits): MODE_WIDTH, RESULT_WIDTH, and WIDTH now unsigned. (extended_count): Now returns unsigned. (simplify_shift_const): COUNT unsigned; arg is now INPUT_COUNT. Add SIGNED_COUNT variable; MODE_WORDS and FIRST_COUNT now unsigned. (simplify_comparison): MODE_WIDTH now unsigned. (update_table_tick): REGNO and ENDREGNO now unsigned; new var R. (mark_used_regs_combine): Likewise; rework arithmetic. (record_value_for_reg): REGNO, ENDREGNO, and I now unsigned. (record_dead_and_set_regs, reg_dead_at_p, distribute_notes): Likewise. (record_promoted_value): REGNO now unsigned. (get_last_value_validate): REGNO, ENDREGNO, and J now unsigned. (get_last_value): REGNO now unsigned. (use_crosses_set_p): REGNO and ENDREGNO now unsigned. (reg_dead_regno, reg_dead_endregno): Now unsigned. (remove_death): Arg REGNO now unsigned. (move_deaths): REGNO, DEADREGNO, DEADEND, OUREND, and I now unsigned. (reg_bitfield_target_p): REGNO, REGNO, ENDREGNO, and ENDTREGNO now unsigned. * convert.c (convert_to_integer): INPREC and OUTPREC now unsigned. * cse.c (struct qty_table_elem): FIRST_REG and LAST_REG now unsigned. (struct cse_reg_info): REGNO now unsigned. (cached_regno): Now unsigned. (REGNO_QTY_VALID_P): Add cast. (make_new_qty, make_regs_eqv, delete_reg_eqiv): Regno args unsigned. (remove_invalid_regs): Likewise. (remove_invalid_subreg_refs): Likewise; arg WORD also unsigned as are variables END and I. (get_cse_reg_info, insert): Likewise. (mention_regs, invalidate_for_call): REGNO, ENDREGNO, and I unsigned. (canon_hash): Likewise. (insert_regs, lookup_for_remove): REGNO now unsigned. (invalidate): REGNO, ENDREGNO, TREGNO, and TENDREGNO now unsigned. New variable RN. * dbxout.c (dbxout_parms, dbxout_reg_parms): Don't check for REGNO < 0. * dwarf2out.c (dwarf2ou_frame_debug_expr): Remove cast. * emit-rtl.c (subreg_realpart_p): Add cast. (operand_subword): Arg I is now unsigned as is var PARTWORDS. (operand_subword_force): Arg I is now unsigned. * except.c (eh_regs): Variable I is now unsigned. * explow.c (hard_function_value): BYTES is unsigned HOST_WIDE_INT. * expmed.c (store_fixed_bit_field): Position is HOST_WIDE_INT; length is unsigned HOST_WIDE_INT; likewise for internal variables. (store_split_bit_field, extract_fixed_bit_field): Likewise. (extract_split_bit_field, store_bit_field, extract_bit_field): Likewise. * expr.c (store_constructor_fields, store_constructor, store_field): Positions are HOST_WIDE_INT and lengths are unsigned HOST_WIDE_INT. (expand_assignment, expand_expr, expand_expr_unaligned): Likewise. (do_jump): Likewise. (move_by_pieces, move_by_pieces_ninsns, clear_by_pieces): MAX_SIZE is now unsigned. (emit_group_load): BYTEPOS is HOST_WIDE_INT; BYTELEN is unsigned. (emit_group_store): Likewise. (emit_move_insn): I now unsigned. (store_constructor): Use host_integerp, tree_low_cst, and bitsize_unit_node. (get_inner_reference): Return bitpos and bitsize as HOST_WIDE_INT. Rework all calculations to use trees and new fields. * expr.h (promoted_input_arg): Regno now unsigned. (store_bit_field, extract_bit_field): Adjust types of pos and size. (mark_seen_cases): Arg is HOST_WIDE_INT. * flow.c (verify_wide_reg_1): REGNO now unsigned. * fold-const.c (decode_field_reference): Size and pos HOST_WIDE_INT; precisions and alignments are unsigned. (optimize_bit_field_compare, fold_truthop): Likewise. (int_const_binop): Adjust threshold for size_int_type_wide call. (fold_convert): Likewise. (size_int_type_wide): Make table larger and fix thinko that only had half of table used. (all_ones_mask_p, fold): Precisions are unsigned. * function.c (put_reg_info_stack): REGNO is unsigned. (instantiate_decl): Size is HOST_WIDE_INT. (instantiate_virtual_regs): I is unsigned. (assign_parms): REGNO, REGNOI, and REGNOR are unsigned. (promoted_input_arg): REGNO is unsigned. * function.h (struct function): x_max_parm_reg is now unsigned. * gcse.c (max_gcse_regno): Now unsigned. (struct null_pointer_info): min_reg and max_reg now unsigned. (lookup_set, next_set): REGNO arg now unsigned. (compute_hash_table): REGNO and I now unsigned. (handle_avail_expr): regnum_for_replacing now unsigned. (cprop_insn): REGNO now unsigned. (delete_null_pointer_checks_1): BLOCK_REG now pointer to unsigned. * ggc-common.c (ggc_mark_tree_children, case FIELD_DECL): New case. * global.c (set_preference): SRC_REGNO, DEST_REGNO, and I now unsigned. * hard-reg-set.h (reg_class_size): Now unsigned. * integrate.c (mark_stores): LAST_REG and I now unsigned; new UREGNO. * jump.c (mark_modified_reg): I now unsigned; add cast. (rtx_equal_for_thread_p): Add cast. * loop.c (max_reg_before_loop): Now unsigned. (struct_movable): REGNO now unsigned. (try_copy_prop): REGNO arg unsigned. (regs_match_p): XN and YN now unsigned. (consec_sets_invariant_p, maybe_eliminate_biv): REGNO now unsigned. (strength_reduce): Likewise; NREGS also unsigned. (first_increment_giv, last_increment_giv unsigned): Now unsigned. * loop.h (struct iv_class): REGNO now unsigned. (max_reg_before_loop, first_increment_giv, last_increment_giv): Now unsigned. * machmode.h (mode_size, mode_unit_size): Now unsigned. (mode_for_size, smallest_mode_for_size): Pass size as unsigned. * optabs.c (expand_binop): I and NWORDS now unsigned. (expand_unop): I now unsigned. * print-tree.c (print_node): Don't print DECL_FIELD_BITPOS, but do print DECL_FIELD_OFFSET and DECL_FIELD_BIT_OFFSET. * real.c (significand_size): Now returns unsigned. * real.h (significand_size): Likewise. * regclass.c (reg_class_size): Now unsigned. (choose_hard_reg_mode): Both operands now unsigned. (record_reg_classes): REGNO and NR now unsigned. (reg_scan): NREGS now unsigned. (reg_scan_update): old_max_regno now unsigned. (reg_scan_mark_refs): Arg MIN_REGNO and var REGNO now unsigned. * reload.c (find_valid_class): BEST_SIZE now unsigned. (find_dummy_reload): REGNO, NWORDS, and I now unsigned. (hard_reg_set_here_p): Args BEG_REGNO and END_REGNO now unsigned. Likewise for variable R. (refers_to_regno_for_reload_p): Args REGNO and END_REGNO now unsigned, as are variables INNER_REGNO and INNER_ENDREGNO; add new variable R. (find_equiv_reg): Add casts. (regno_clobbered_p): Arg REGNO now unsigned. * reload.h (struct reload): NREGS now unsigned. (refers_to_regno_for_reload_p): Regno args are unsigned. (regno_clobbered_p): Likewise. * reload1.c (reg_max_ref_width, spill_stack_slot_width): Now unsigned. (compute_use_by_pseudos): REGNO now unsigned. (find_reg): I and J now unsigned, new variable K, and change loop variables accordingly; THIS_NREGS now unsigned. (alter_reg): INHERENT_SIZE and TOTAL_SIZE now unsigned. (spill_hard_reg): REGNO arg now unsigned; add casts. (forget_old_reloads_1): REGNO, NR, and I now unsigned. (mark_reload_reg_in_use): Arg REGNO and vars NREGS and I now unsigned. (clear_reload_reg_in_use): Arg REGNO and vars NREGS, START_REGNO, END_REGNO, CONFLICT_START, and CONFLICT_END now unsigned. (reload_reg_free_p, reload_reg_reaches_end_p): Arg REGNO now unsigned. (choose_reload_regs): MAX_GROUP_SIZE now unsigned. (emit_reload_insns): REGNO now unsigned. (reload_cse_move2add): Add cast. (move2add_note_store): REGNO and I now unsigned; new variable ENDREGNO and rework loop. * resource.c (mark_referenced_resources, mark_set_resources): New variable R; REGNO and LAST_REGNO now unsigned. (mark_target_live_regs): J and REGNO now unsigned. * rtl.c (mode_size, mode_unit_size): Now unsigned. * rtl.h (union rtunion_def): New field rtuint. (XCUINT): New macro. (ADDRESSOF_REGNO, REGNO, SUBREG_WORD): New XCUINT. (operand_subword, operand_subword_force): Word number is unsigned. (choose_hard_reg_mode): Operands are unsigned. (refers_to-regno_p, dead_or_set_regno_p): Regno arg is unsigned. (find_regno_note, find_regno_fusage, replace_regs): Likewise. (regno_use_in, combine_instructions, remove_death): Likewise. (reg_scan, reg_scan_update): Likewise. (extended_count): Return is unsigned. * rtlanal.c (refers_to_regno_p): Args REGNO and ENDREGNO and vars I, INNER_REGNO, and INNER_ENDREGNO now unsigned; new variable X_REGNO. (reg_overlap_mentioned_p): REGNO and ENDREGNO now unsigned. (reg_set_last_first_regno, reg_set_last_last_regno): Now unsigned. (reg_reg_last_1): FIRS and LAST now unsigned. (dead_or_set_p): REGNO, LAST_REGNO, and I now unsigned. (dead_or_set_regno_p): Arg TEST_REGNO and vars REGNO and ENDREGNO now unsigned. (find_regno_note, regno_use_in): Arg REGNO now unsigned. (find_regno_fusage): Likewise; also var REGNOTE now unsigned. (find_reg_fusage): Variables REGNO, END_REGNO, and I now unsigned. (replace_regs): Arg NREGS now unsigned. * sdbout.c (sdbout_parms, sdbout_reg_parms): Don't check REGNO < 0. * simplify-rtx.c (simplify_unary_operation): WIDTH now unsigned. (simplify_binary_operation): Likewise. (cselib_invalidate_regno): Arg REGNO and variables ENDREGNO, I, and THIS_LAST now unsigned. (cselib_record_set): Add cast. * ssa.c (ssa_max_reg_num): Now unsigned. (rename_block): REGNO now unsigned. * stmt.c (expand_return): Bit positions unsigned HOST_WIDE_INT; sizes now unsigned. (all_cases_count): Just return -1 not -2. COUNT, MINVAL, and LASTVAL now HOST_WIDE_INT. Rework tests to use trees whenever possible. Use host_integerp and tree_low_cst. (mark_seen_cases): COUNT arg now HOST_WIDE_INT; Likewise variable NEXT_NODE_OFFSET; XLO now unsigned. (check_for_full_enumeration_handing): BYTES_NEEDED, I to HOST_WIDE_INT. * stor-layout.c (mode_for_size): SIZE arg now unsigned. (smallest_mode_for_size): Likewise. (layout_decl): Simplify handing of a specified DECL_SIZE_UNIT. KNOWN_ALIGN is now an alignment, so simplify code. Don't turn off DECL_BIT_FIELD if field is BLKmode, but not type. (start_record_layout): Renamed from new_record_layout_info. Update to new fields. (debug_rli, normalize_rli, rli_size_unit_so_far, rli_size_so_far): New functions. (place_union_field): Renamed from layout_union_field. Update to use new fields in rli. (place_field): Renamed from layout_field. Major rewrite to use new fields in rli; pass alignment to layout_decl. (finalize_record_size): Rework to use new fields in rli and handle union. (compute_record_mode): Rework to simplify and to use new DECL fields. (finalize_type_size): Make rounding more consistent. (finish_union_layout): Deleted. (layout_type, case VOID_TYPE): Don't set TYPE_SIZE_UNIT either. (layout_type, case RECORD_TYPE): Call new function names. (initialize_sizetypes): Set TYPE_IS_SIZETYPE. (set_sizetype): Set TYPE_IS_SIZETYPE earlier. (get_best_mode): UNIT is now unsigned; remove casts. * tree.c (bit_position): Compute from new fields. (byte_position, int_byte_position): New functions. (print_type_hash_statistics): Cast to remove warning. (build_range_type): Use host_integerp and tree_low_cst to try to hash. (build_index_type): Likewise; make subtype of sizetype. (build_index_2_type): Pass sizetype to build_range_type. (build_common_tree_nodes): Use size_int and bitsize_int to initialize nodes; add bitsize_{zero,one,unit}_node. * tree.h (DECL_FIELD_CONTEXT): Use FIELD_DECL_CHECK. (DECL_BIT_FIELD_TYPE, DECL_QUALIFIER, DECL_FCONTEXT): Likewise. (DECL_PACKED, DECL_BIT_FIELD): Likewise. (DECL_FIELD_BITPOS): Deleted. (DECL_FIELD_OFFSET, DECL_FIELD_BIT_OFFSET): New fields. (DECL_RESULT, DECL_SAVED_INSNS): Use FUNCTION_DECL_CHECK. (DECL_FRAME_SIZE, DECL_FUNCTION_CODE, DECL_NO_STATIC_CHAIN): Likewise. (DECL_INLINE, DECL_BUILT_IN_NONANSI, DECL_IS_MALLOC): Likewise. (DECL_BUILT_IN_CLASS, DECL_STATIC_CONSTRUCTOR): Likewise. (DECL_STATIC_DESTRUCTOR, DECL_NO_CHECK_MEMORY_USAGE): Likewise. (DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT, DECL_NO_LIMIT_STACK) Likewise. (DECL_ORIGINAL_TYPE, TYPE_DECL_SUPPRESS_DEBUG): Use TYPE_DECL_CHECK. (DECL_ARG_TYPE_AS_WRITEN, DECL_ARG_TYPE): Use PARM_DECL_CHECK. (DECL_INCOMING_RTL, DECL_TRANSPARENT_UNION): Likewise. (DECL_ALIGN): Adjust to new field in union. (DECL_OFFSET_ALIGN): New field. (DECL_ERROR_ISSUED, DECL_TOO_LATE): Use LABEL_DECL_CHECK. (DECL_IN_TEXT_SECTION): Use VAR_DECL_CHECK. (union tree_decl): Add struct for both aligns. (enum tree_index): Add TI_BITSIZE_{ZERO,ONE,UNIT}. (bitsize_zero_node, bitsize_one_node, bitsize_unit_node): Added. (struct record_layout_info): Rework fields to have offset alignment and byte and bit position. (start_record_layout, place_field): Renamed from old names. (rli_size_so_far, rli_size_unit_so_far, normalize_rli): New decls. (byte_position, int_byte_position): Likewise. (get_inner_reference): Change types of position and length. * unroll.c (unroll_loop): New variable R; use for some loops. MAX_LOCAL_REGNUM and MAXREGNUM now unsigned. (calculate_giv_inc): Arg REGNO now unsigned. (copy_loop_body): REGNO and SRC_REGNO now unsigned. * varasm.c (assemble_variable): Clean up handling of size using host_integerp and tree_low_cst. (decode_addr_const): Use byte, not bit, position. (output_constructor): bitpos and offsets are HOST_WIDE_INT; use tree_low_cst and int_bit_position. * objc/objc-act.c (build_ivar_list_initializer): Use byte_position. * ch/actions.c (check_missing_cases): BYTES_NEEDED is HOST_WIDE_INT. * ch/typeck.c (expand_constant_to_buffer): Use int_byte_position. (extract_constant_from_buffer): Likewise. * cp/class.c (build_vbase_pointer_fields): layout_field now place_field. (get_vfield_offset): Use byte_position. (set_rtti_entry): Set OFFSET to ssizetype zero. (get_binfo_offset_as_int): Deleted. (dfs_record_base_offsets): Use tree_low_cst. (dfs_search_base_offsets): Likewise. (layout_nonempty_base_or_field): Reflect changes in RLI format and call byte_position. (layout_empty_base): Convert offset to ssizetype. (build_base_field): use rli_size_unit_so_far. (dfs_propagate_binfo_offsets): Do computation in proper type. (layout_virtual_bases): Pass ssizetype to propagate_binfo_offsets. (layout_class_type): Reflect changes in RLI names and fields. (finish_struct_1): Set DECL_FIELD_OFFSET. * cp/dump.c (dequeue_and_dump): Call bit_position. * cp/expr.c (cplus_expand_constant): Use byte_position. * cp/rtti.c (expand_class_desc): Use bitsize_one_node. * cp/typeck.c (build_component_addr): Use byte_position and don't special case for zero offset. * f/com.c (ffecom_tree_canonize_ptr_): Use bitsize_zero_node. (ffecom_tree_canonize_ref_): Likewise. * java/class.c (make_field_value): Use byte_position. * java/expr.c (JAVA_ARRAY_LENGTH_OFFSET): Use byte_position. (java_array_data_offset): Likewise. * java/java-tree.h (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Add case to bzero call. From-SVN: r32742
2000-03-25 19:34:13 +01:00
unsigned int xn = REGNO (x);
unsigned int yn = REGNO (y);
1992-02-01 09:24:22 +01:00
struct movable *mx, *my;
for (mx = movables->head; mx; mx = mx->next)
1992-02-01 09:24:22 +01:00
if (mx->regno == xn)
break;
for (my = movables->head; my; my = my->next)
1992-02-01 09:24:22 +01:00
if (my->regno == yn)
break;
return (mx && my
&& ((mx->match == my->match && mx->match != 0)
|| mx->match == my
|| mx == my->match));
}
/* Return 1 if X and Y are identical-looking rtx's.
This is the Lisp function EQUAL for rtx arguments.
If two registers are matching movables or a movable register and an
equivalent constant, consider them equal. */
static int
rtx_equal_for_loop_p (x, y, movables, regs)
1992-02-01 09:24:22 +01:00
rtx x, y;
struct movables *movables;
struct loop_regs *regs;
1992-02-01 09:24:22 +01:00
{
register int i;
register int j;
register struct movable *m;
register enum rtx_code code;
rtl.h (rtx_format): Constify a char*. * rtl.h (rtx_format): Constify a char*. * rtl.c (rtx_format): Likewise. (copy_rtx, copy_most_rtx, read_rtx): Likewise. (init_rtl): Use accessor macro, not `rtx_format'. * alias.c (rtx_equal_for_memref_p, find_symbolic_term): Constify a char*. * caller-save.c (mark_referenced_regs): Likewise. * combine.c (subst, make_compound_operation, known_cond, gen_rtx_combine, update_table_tick, get_last_value_validate, use_crosses_set_p, mark_used_regs_combine, move_deaths): Likewise. * cse.c (rtx_cost, mention_regs, canon_hash, exp_equiv_p, refers_to_p, canon_reg, fold_rtx, cse_process_notes, count_reg_usage): Likewise. * emit-rtl.c (gen_rtx, copy_rtx_if_shared, reset_used_flags): Likewise. * final.c (leaf_renumber_regs_insn): Likewise. * flow.c (mark_used_regs, find_use_as_address, dump_flow_info, dump_edge_info, count_reg_references): Likewise. * function.c (fixup_var_refs_1, walk_fixup_memory_subreg, fixup_stack_1, purge_addressof_1, instantiate_virtual_regs_1): Likewise. * gcse.c (oprs_unchanged_p, hash_expr_1, expr_equiv_p, oprs_not_set_p, expr_killed_p, compute_transp, find_used_regs, add_label_notes): Likewise. * genattrtab.c (attr_rtx, attr_copy_rtx, encode_units_mask, clear_struct_flag, count_sub_rtxs, count_alternatives, compares_alternatives_p, contained_in_p, walk_attr_value, write_expr_attr_cache): Likewise. * genconfig.c (walk_insn_part): Likewise. * genemit.c (max_operand_1, gen_exp): Likewise. * genextract.c (walk_rtx): Likewise. * genflags.c (num_operands): Likewise. * genoutput.c (scan_operands): Likewise. * genpeep.c (match_rtx): Likewise. * genrecog.c (add_to_sequence): Likewise. * haifa-sched.c (may_trap_exp, sched_analyze_2, attach_deaths): Likewise. * integrate.c (save_constants, copy_for_inline, copy_rtx_and_substitute, subst_constants, restore_constants): Likewise. * jump.c (mark_jump_label, invert_exp, redirect_exp, rtx_renumbered_equal_p, rtx_equal_for_thread_p): Likewise. * local-alloc.c (contains_replace_regs, memref_referenced_p): Likewise. * loop.c (record_excess_regs, rtx_equal_for_loop_p, add_label_notes, replace_call_address, count_nonfixed_reads, invariant_p, find_single_use_in_loop, find_mem_givs, find_life_end, maybe_eliminate_biv_1, update_reg_last_use): Likewise. * print-rtl.c (reg_names, print_rtx): Likewise. * recog.c (validate_replace_rtx_1, find_single_use_1): Likewise. * reg-stack.c (stack_regs_mentioned_p, record_label_references, record_reg_life_pat, swap_rtx_condition, goto_block_pat, print_blocks): Likewise. * regclass.c (fix_register, record_address_regs, reg_scan_mark_refs): Likewise. * regmove.c (stable_but_for_p): Likewise. * reload.c (loc_mentioned_in_p, operands_match_p, find_reloads_toplevsubst_reg_equivs, find_reloads_address_1, copy_replacements, refers_to_regno_for_reload_p, refers_to_mem_for_reload_p, find_inc_amount, regno_clobbered_p, reload_when_needed_name, reg_class_names, debug_reload_to_stream): Likewise. * reload1.c (eliminate_regs, scan_paradoxical_subregs, delete_address_reloads_1, count_occurrences, reload_cse_mem_conflict_p, reload_combine_note_use, add_auto_inc_notes): Likewise. * resource.c (mark_referenced_resources, mark_set_resources): Likewise. * rtlanal.c (rtx_unstable_p, rtx_varies_p, rtx_addr_varies_p, reg_mentioned_p, regs_set_between_p, modified_between_p, modified_in_p, refers_to_regno_p, reg_overlap_mentioned_p, rtx_equal_p, volatile_insn_p, volatile_refs_p, side_effects_p, may_trap_p, inequality_comparisons_p, replace_rtx, replace_regs, jmp_uses_reg_or_mem, for_each_rtx, regno_use_in): Likewise. * sched.c (sched_analyze_2, attach_deaths): Likewise. * stupid.c (stupid_mark_refs): Likewise. * unroll.c (remap_split_bivs): Likewise. * varasm.c (mark_constants): Likewise. * a29k/a29k.c (uses_local_reg_p): Likewise. * alpha/alpha.c (summarize_insn): Likewise. * arm/arm.c (symbol_mentioned_p, label_mentioned_p, eliminate_lr2ip): Likewise. * arm/thumb.c (symbol_mentioned_p, label_mentioned_p): Likewise. * i386/i386.c (symbolic_reference_mentioned_p, copy_all_rtx, reg_mentioned_in_mem): Likewise. * ns32k/ns32k.c (global_symbolic_reference_mentioned_p, symbolic_reference_mentioned_p): Likewise. * romp/romp.c (unsigned_comparisons_p, hash_rtx): Likewise. * sh/sh.c (regs_used, mark_use): Likewise. * vax/vax.c (vax_rtx_cost): Likewise. From-SVN: r28784
1999-08-21 01:05:25 +02:00
register const char *fmt;
1992-02-01 09:24:22 +01:00
if (x == y)
return 1;
if (x == 0 || y == 0)
return 0;
code = GET_CODE (x);
/* If we have a register and a constant, they may sometimes be
equal. */
if (GET_CODE (x) == REG && VARRAY_INT (regs->set_in_loop, REGNO (x)) == -2
1992-02-01 09:24:22 +01:00
&& CONSTANT_P (y))
{
for (m = movables->head; m; m = m->next)
if (m->move_insn && m->regno == REGNO (x)
&& rtx_equal_p (m->set_src, y))
return 1;
}
else if (GET_CODE (y) == REG && VARRAY_INT (regs->set_in_loop,
REGNO (y)) == -2
1992-02-01 09:24:22 +01:00
&& CONSTANT_P (x))
{
for (m = movables->head; m; m = m->next)
if (m->move_insn && m->regno == REGNO (y)
&& rtx_equal_p (m->set_src, x))
return 1;
}
1992-02-01 09:24:22 +01:00
/* Otherwise, rtx's of different codes cannot be equal. */
if (code != GET_CODE (y))
return 0;
/* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.
(REG:SI x) and (REG:HI x) are NOT equivalent. */
if (GET_MODE (x) != GET_MODE (y))
return 0;
/* These three types of rtx's can be compared nonrecursively. */
if (code == REG)
return (REGNO (x) == REGNO (y) || regs_match_p (x, y, movables));
if (code == LABEL_REF)
return XEXP (x, 0) == XEXP (y, 0);
if (code == SYMBOL_REF)
return XSTR (x, 0) == XSTR (y, 0);
/* Compare the elements. If any pair of corresponding elements
fail to match, return 0 for the whole things. */
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
switch (fmt[i])
{
case 'w':
if (XWINT (x, i) != XWINT (y, i))
return 0;
break;
1992-02-01 09:24:22 +01:00
case 'i':
if (XINT (x, i) != XINT (y, i))
return 0;
break;
case 'E':
/* Two vectors must have the same length. */
if (XVECLEN (x, i) != XVECLEN (y, i))
return 0;
/* And the corresponding elements must match. */
for (j = 0; j < XVECLEN (x, i); j++)
if (rtx_equal_for_loop_p (XVECEXP (x, i, j), XVECEXP (y, i, j),
movables, regs) == 0)
1992-02-01 09:24:22 +01:00
return 0;
break;
case 'e':
if (rtx_equal_for_loop_p (XEXP (x, i), XEXP (y, i), movables, regs)
== 0)
1992-02-01 09:24:22 +01:00
return 0;
break;
case 's':
if (strcmp (XSTR (x, i), XSTR (y, i)))
return 0;
break;
case 'u':
/* These are just backpointers, so they don't matter. */
break;
case '0':
break;
/* It is believed that rtx's at this level will never
contain anything but integers and other rtx's,
except for within LABEL_REFs and SYMBOL_REFs. */
default:
abort ();
}
}
return 1;
}
/* If X contains any LABEL_REF's, add REG_LABEL notes for them to all
insns in INSNS which use the reference. */
static void
add_label_notes (x, insns)
rtx x;
rtx insns;
{
enum rtx_code code = GET_CODE (x);
int i, j;
rtl.h (rtx_format): Constify a char*. * rtl.h (rtx_format): Constify a char*. * rtl.c (rtx_format): Likewise. (copy_rtx, copy_most_rtx, read_rtx): Likewise. (init_rtl): Use accessor macro, not `rtx_format'. * alias.c (rtx_equal_for_memref_p, find_symbolic_term): Constify a char*. * caller-save.c (mark_referenced_regs): Likewise. * combine.c (subst, make_compound_operation, known_cond, gen_rtx_combine, update_table_tick, get_last_value_validate, use_crosses_set_p, mark_used_regs_combine, move_deaths): Likewise. * cse.c (rtx_cost, mention_regs, canon_hash, exp_equiv_p, refers_to_p, canon_reg, fold_rtx, cse_process_notes, count_reg_usage): Likewise. * emit-rtl.c (gen_rtx, copy_rtx_if_shared, reset_used_flags): Likewise. * final.c (leaf_renumber_regs_insn): Likewise. * flow.c (mark_used_regs, find_use_as_address, dump_flow_info, dump_edge_info, count_reg_references): Likewise. * function.c (fixup_var_refs_1, walk_fixup_memory_subreg, fixup_stack_1, purge_addressof_1, instantiate_virtual_regs_1): Likewise. * gcse.c (oprs_unchanged_p, hash_expr_1, expr_equiv_p, oprs_not_set_p, expr_killed_p, compute_transp, find_used_regs, add_label_notes): Likewise. * genattrtab.c (attr_rtx, attr_copy_rtx, encode_units_mask, clear_struct_flag, count_sub_rtxs, count_alternatives, compares_alternatives_p, contained_in_p, walk_attr_value, write_expr_attr_cache): Likewise. * genconfig.c (walk_insn_part): Likewise. * genemit.c (max_operand_1, gen_exp): Likewise. * genextract.c (walk_rtx): Likewise. * genflags.c (num_operands): Likewise. * genoutput.c (scan_operands): Likewise. * genpeep.c (match_rtx): Likewise. * genrecog.c (add_to_sequence): Likewise. * haifa-sched.c (may_trap_exp, sched_analyze_2, attach_deaths): Likewise. * integrate.c (save_constants, copy_for_inline, copy_rtx_and_substitute, subst_constants, restore_constants): Likewise. * jump.c (mark_jump_label, invert_exp, redirect_exp, rtx_renumbered_equal_p, rtx_equal_for_thread_p): Likewise. * local-alloc.c (contains_replace_regs, memref_referenced_p): Likewise. * loop.c (record_excess_regs, rtx_equal_for_loop_p, add_label_notes, replace_call_address, count_nonfixed_reads, invariant_p, find_single_use_in_loop, find_mem_givs, find_life_end, maybe_eliminate_biv_1, update_reg_last_use): Likewise. * print-rtl.c (reg_names, print_rtx): Likewise. * recog.c (validate_replace_rtx_1, find_single_use_1): Likewise. * reg-stack.c (stack_regs_mentioned_p, record_label_references, record_reg_life_pat, swap_rtx_condition, goto_block_pat, print_blocks): Likewise. * regclass.c (fix_register, record_address_regs, reg_scan_mark_refs): Likewise. * regmove.c (stable_but_for_p): Likewise. * reload.c (loc_mentioned_in_p, operands_match_p, find_reloads_toplevsubst_reg_equivs, find_reloads_address_1, copy_replacements, refers_to_regno_for_reload_p, refers_to_mem_for_reload_p, find_inc_amount, regno_clobbered_p, reload_when_needed_name, reg_class_names, debug_reload_to_stream): Likewise. * reload1.c (eliminate_regs, scan_paradoxical_subregs, delete_address_reloads_1, count_occurrences, reload_cse_mem_conflict_p, reload_combine_note_use, add_auto_inc_notes): Likewise. * resource.c (mark_referenced_resources, mark_set_resources): Likewise. * rtlanal.c (rtx_unstable_p, rtx_varies_p, rtx_addr_varies_p, reg_mentioned_p, regs_set_between_p, modified_between_p, modified_in_p, refers_to_regno_p, reg_overlap_mentioned_p, rtx_equal_p, volatile_insn_p, volatile_refs_p, side_effects_p, may_trap_p, inequality_comparisons_p, replace_rtx, replace_regs, jmp_uses_reg_or_mem, for_each_rtx, regno_use_in): Likewise. * sched.c (sched_analyze_2, attach_deaths): Likewise. * stupid.c (stupid_mark_refs): Likewise. * unroll.c (remap_split_bivs): Likewise. * varasm.c (mark_constants): Likewise. * a29k/a29k.c (uses_local_reg_p): Likewise. * alpha/alpha.c (summarize_insn): Likewise. * arm/arm.c (symbol_mentioned_p, label_mentioned_p, eliminate_lr2ip): Likewise. * arm/thumb.c (symbol_mentioned_p, label_mentioned_p): Likewise. * i386/i386.c (symbolic_reference_mentioned_p, copy_all_rtx, reg_mentioned_in_mem): Likewise. * ns32k/ns32k.c (global_symbolic_reference_mentioned_p, symbolic_reference_mentioned_p): Likewise. * romp/romp.c (unsigned_comparisons_p, hash_rtx): Likewise. * sh/sh.c (regs_used, mark_use): Likewise. * vax/vax.c (vax_rtx_cost): Likewise. From-SVN: r28784
1999-08-21 01:05:25 +02:00
const char *fmt;
rtx insn;
if (code == LABEL_REF && !LABEL_REF_NONLOCAL_P (x))
{
/* This code used to ignore labels that referred to dispatch tables to
avoid flow generating (slighly) worse code.
We no longer ignore such label references (see LABEL_REF handling in
mark_jump_label for additional information). */
for (insn = insns; insn; insn = NEXT_INSN (insn))
if (reg_mentioned_p (XEXP (x, 0), insn))
REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_LABEL, XEXP (x, 0),
REG_NOTES (insn));
}
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
if (fmt[i] == 'e')
add_label_notes (XEXP (x, i), insns);
else if (fmt[i] == 'E')
for (j = XVECLEN (x, i) - 1; j >= 0; j--)
add_label_notes (XVECEXP (x, i, j), insns);
}
}
1992-02-01 09:24:22 +01:00
/* Scan MOVABLES, and move the insns that deserve to be moved.
If two matching movables are combined, replace one reg with the
other throughout. */
static void
move_movables (loop, movables, threshold, insn_count)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
struct loop *loop;
struct movables *movables;
1992-02-01 09:24:22 +01:00
int threshold;
int insn_count;
{
struct loop_regs *regs = LOOP_REGS (loop);
int nregs = regs->num;
1992-02-01 09:24:22 +01:00
rtx new_start = 0;
register struct movable *m;
register rtx p;
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
rtx loop_start = loop->start;
rtx loop_end = loop->end;
1992-02-01 09:24:22 +01:00
/* Map of pseudo-register replacements to handle combining
when we move several insns that load the same value
into different pseudo-registers. */
rtx *reg_map = (rtx *) xcalloc (nregs, sizeof (rtx));
char *already_moved = (char *) xcalloc (nregs, sizeof (char));
1992-02-01 09:24:22 +01:00
movables->num = 0;
1992-02-01 09:24:22 +01:00
for (m = movables->head; m; m = m->next)
1992-02-01 09:24:22 +01:00
{
/* Describe this movable insn. */
if (loop_dump_stream)
{
fprintf (loop_dump_stream, "Insn %d: regno %d (life %d), ",
INSN_UID (m->insn), m->regno, m->lifetime);
if (m->consec > 0)
fprintf (loop_dump_stream, "consec %d, ", m->consec);
if (m->cond)
fprintf (loop_dump_stream, "cond ");
if (m->force)
fprintf (loop_dump_stream, "force ");
if (m->global)
fprintf (loop_dump_stream, "global ");
if (m->done)
fprintf (loop_dump_stream, "done ");
if (m->move_insn)
fprintf (loop_dump_stream, "move-insn ");
if (m->match)
fprintf (loop_dump_stream, "matches %d ",
INSN_UID (m->match->insn));
if (m->forces)
fprintf (loop_dump_stream, "forces %d ",
INSN_UID (m->forces->insn));
}
/* Count movables. Value used in heuristics in strength_reduce. */
movables->num++;
1992-02-01 09:24:22 +01:00
/* Ignore the insn if it's already done (it matched something else).
Otherwise, see if it is now safe to move. */
if (!m->done
&& (! m->cond
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
|| (1 == loop_invariant_p (loop, m->set_src)
1992-02-01 09:24:22 +01:00
&& (m->dependencies == 0
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
|| 1 == loop_invariant_p (loop, m->dependencies))
1992-02-01 09:24:22 +01:00
&& (m->consec == 0
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
|| 1 == consec_sets_invariant_p (loop, m->set_dest,
1992-02-01 09:24:22 +01:00
m->consec + 1,
m->insn))))
&& (! m->forces || m->forces->done))
{
register int regno;
register rtx p;
int savings = m->savings;
/* We have an insn that is safe to move.
Compute its desirability. */
p = m->insn;
regno = m->regno;
if (loop_dump_stream)
fprintf (loop_dump_stream, "savings %d ", savings);
if (regs->moved_once[regno] && loop_dump_stream)
fprintf (loop_dump_stream, "halved since already moved ");
1992-02-01 09:24:22 +01:00
/* An insn MUST be moved if we already moved something else
which is safe only if this one is moved too: that is,
if already_moved[REGNO] is nonzero. */
/* An insn is desirable to move if the new lifetime of the
register is no more than THRESHOLD times the old lifetime.
If it's not desirable, it means the loop is so big
that moving won't speed things up much,
and it is liable to make register usage worse. */
/* It is also desirable to move if it can be moved at no
extra cost because something else was already moved. */
if (already_moved[regno]
|| flag_move_all_movables
|| (threshold * savings * m->lifetime) >=
(regs->moved_once[regno] ? insn_count * 2 : insn_count)
1992-02-01 09:24:22 +01:00
|| (m->forces && m->forces->done
&& VARRAY_INT (regs->n_times_set, m->forces->regno) == 1))
1992-02-01 09:24:22 +01:00
{
int count;
register struct movable *m1;
Warning fixes: * calls.c (emit_call_1): Mark parameter `stack_size' with ATTRIBUTE_UNUSED. (expand_call): Initialize variable `insn'. (emit_library_call): Likewise for variable `high_to_save'. (emit_library_call_value): Likewise. (store_one_arg): Likewise for variables `lower_bound' and `upper_bound'. * combine.c (try_combine): Likewise for variables `i2_code_number' and `other_code_number'. (find_split_point): Likewise for variables `pos', `unsignedp' and `inner'. (simplify_if_then_else): Likewise for variables `op' and `c1'. (simplify_and_const_int): Remove unused variable `width'. (merge_outer_ops): Likewise. * cse.c (simplify_binary_operation): Cast an INTVAL() to `unsigned HOST_WIDE_INT' when comparing against one. (simplify_relational_operation): Likewise. (cse_insn): Initialize variables `src_eqv_volatile', `src_eqv_in_memory', `src_eqv_in_struct', `src_eqv_hash' and `sets'. * final.c (init_final): Constify parameter `filename'. (final_start_function): Mark parameter `optimize' with ATTRIBUTE_UNUSED. (profile_function): Likewise for parameters `first' and `optimize'. (output_source_line): Likewise for parameter `file'. * integrate.c (subst_constants): Cast a value to `size_t' when comparing against one. (mark_stores): Initialize variable `mode'. Cast a value to `size_t' when comparing against one. * integrate.h (MAYBE_EXTEND_CONST_EQUIV_VARRAY): Likewise. * loop.c (move_movables): Initialize variable `first'. (strength_reduce): Likewise for variable `increment'. (check_dbra_loop): Likewise for variable `comparison_val'. Cast a value to `size_t' when comparing against one. (load_mems): Initialize variable `end_label'. * output.h (init_final): Constify parameter. * reload.c (decompose): Initialize variable `base'. * reload1.c (reload): Likewise for variable `is_scalar'. (spill_hard_reg): Mark parameter `dumpfile' with ATTRIBUTE_UNUSED. (choose_reload_regs): Initialize variable `mode'. (emit_reload_insns): Likewise for variable `store_insn'. (reload_cse_noop_set_p): Mark parameter `insn' with ATTRIBUTE_UNUSED. (reload_combine): Initialize variable `set'. * unroll.c (unroll_loop): Likewise for variable `local_label'. (copy_loop_body): Cast a value to `size_t' when comparing against one. * varasm.c (assemble_variable): Initialize variable `size_tree'. (const_hash): Add an `else abort()' in an if-else-if-else sequence. (remove_from_pending_weak_list): Mark parameter `name' with ATTRIBUTE_UNUSED. From-SVN: r28860
1999-08-25 15:37:46 +02:00
rtx first = NULL_RTX;
1992-02-01 09:24:22 +01:00
/* Now move the insns that set the reg. */
if (m->partial && m->match)
{
rtx newpat, i1;
rtx r1, r2;
/* Find the end of this chain of matching regs.
Thus, we load each reg in the chain from that one reg.
And that reg is loaded with 0 directly,
since it has ->match == 0. */
for (m1 = m; m1->match; m1 = m1->match);
newpat = gen_move_insn (SET_DEST (PATTERN (m->insn)),
SET_DEST (PATTERN (m1->insn)));
i1 = emit_insn_before (newpat, loop_start);
/* Mark the moved, invariant reg as being allowed to
share a hard reg with the other matching invariant. */
REG_NOTES (i1) = REG_NOTES (m->insn);
r1 = SET_DEST (PATTERN (m->insn));
r2 = SET_DEST (PATTERN (m1->insn));
regs_may_share
= gen_rtx_EXPR_LIST (VOIDmode, r1,
gen_rtx_EXPR_LIST (VOIDmode, r2,
regs_may_share));
1992-02-01 09:24:22 +01:00
delete_insn (m->insn);
if (new_start == 0)
new_start = i1;
if (loop_dump_stream)
fprintf (loop_dump_stream, " moved to %d", INSN_UID (i1));
}
/* If we are to re-generate the item being moved with a
new move insn, first delete what we have and then emit
the move insn before the loop. */
else if (m->move_insn)
{
rtx i1, temp;
for (count = m->consec; count >= 0; count--)
{
/* If this is the first insn of a library call sequence,
skip to the end. */
if (GET_CODE (p) != NOTE
&& (temp = find_reg_note (p, REG_LIBCALL, NULL_RTX)))
1992-02-01 09:24:22 +01:00
p = XEXP (temp, 0);
/* If this is the last insn of a libcall sequence, then
delete every insn in the sequence except the last.
The last insn is handled in the normal manner. */
if (GET_CODE (p) != NOTE
&& (temp = find_reg_note (p, REG_RETVAL, NULL_RTX)))
1992-02-01 09:24:22 +01:00
{
temp = XEXP (temp, 0);
while (temp != p)
temp = delete_insn (temp);
}
temp = p;
1992-02-01 09:24:22 +01:00
p = delete_insn (p);
/* simplify_giv_expr expects that it can walk the insns
at m->insn forwards and see this old sequence we are
tossing here. delete_insn does preserve the next
pointers, but when we skip over a NOTE we must fix
it up. Otherwise that code walks into the non-deleted
insn stream. */
while (p && GET_CODE (p) == NOTE)
p = NEXT_INSN (temp) = NEXT_INSN (p);
1992-02-01 09:24:22 +01:00
}
start_sequence ();
emit_move_insn (m->set_dest, m->set_src);
temp = get_insns ();
1992-02-01 09:24:22 +01:00
end_sequence ();
add_label_notes (m->set_src, temp);
i1 = emit_insns_before (temp, loop_start);
if (! find_reg_note (i1, REG_EQUAL, NULL_RTX))
1992-02-01 09:24:22 +01:00
REG_NOTES (i1)
= gen_rtx_EXPR_LIST (m->is_equiv ? REG_EQUIV : REG_EQUAL,
m->set_src, REG_NOTES (i1));
1992-02-01 09:24:22 +01:00
if (loop_dump_stream)
fprintf (loop_dump_stream, " moved to %d", INSN_UID (i1));
/* The more regs we move, the less we like moving them. */
threshold -= 3;
}
else
{
for (count = m->consec; count >= 0; count--)
{
rtx i1, temp;
1996-07-04 00:07:53 +02:00
/* If first insn of libcall sequence, skip to end. */
/* Do this at start of loop, since p is guaranteed to
1992-02-01 09:24:22 +01:00
be an insn here. */
if (GET_CODE (p) != NOTE
&& (temp = find_reg_note (p, REG_LIBCALL, NULL_RTX)))
1992-02-01 09:24:22 +01:00
p = XEXP (temp, 0);
/* If last insn of libcall sequence, move all
insns except the last before the loop. The last
insn is handled in the normal manner. */
if (GET_CODE (p) != NOTE
&& (temp = find_reg_note (p, REG_RETVAL, NULL_RTX)))
1992-02-01 09:24:22 +01:00
{
rtx fn_address = 0;
rtx fn_reg = 0;
rtx fn_address_insn = 0;
first = 0;
for (temp = XEXP (temp, 0); temp != p;
temp = NEXT_INSN (temp))
{
rtx body;
rtx n;
rtx next;
if (GET_CODE (temp) == NOTE)
continue;
body = PATTERN (temp);
/* Find the next insn after TEMP,
not counting USE or NOTE insns. */
for (next = NEXT_INSN (temp); next != p;
next = NEXT_INSN (next))
if (! (GET_CODE (next) == INSN
&& GET_CODE (PATTERN (next)) == USE)
&& GET_CODE (next) != NOTE)
break;
1992-02-01 09:24:22 +01:00
/* If that is the call, this may be the insn
that loads the function address.
Extract the function address from the insn
that loads it into a register.
If this insn was cse'd, we get incorrect code.
So emit a new move insn that copies the
function address into the register that the
call insn will use. flow.c will delete any
redundant stores that we have created. */
if (GET_CODE (next) == CALL_INSN
&& GET_CODE (body) == SET
&& GET_CODE (SET_DEST (body)) == REG
&& (n = find_reg_note (temp, REG_EQUAL,
NULL_RTX)))
1992-02-01 09:24:22 +01:00
{
fn_reg = SET_SRC (body);
if (GET_CODE (fn_reg) != REG)
fn_reg = SET_DEST (body);
fn_address = XEXP (n, 0);
fn_address_insn = temp;
}
/* We have the call insn.
If it uses the register we suspect it might,
load it with the correct address directly. */
if (GET_CODE (temp) == CALL_INSN
&& fn_address != 0
1992-07-29 23:24:29 +02:00
&& reg_referenced_p (fn_reg, body))
1992-02-01 09:24:22 +01:00
emit_insn_after (gen_move_insn (fn_reg,
fn_address),
fn_address_insn);
if (GET_CODE (temp) == CALL_INSN)
{
i1 = emit_call_insn_before (body, loop_start);
/* Because the USAGE information potentially
contains objects other than hard registers
we need to copy it. */
if (CALL_INSN_FUNCTION_USAGE (temp))
CALL_INSN_FUNCTION_USAGE (i1)
= copy_rtx (CALL_INSN_FUNCTION_USAGE (temp));
}
1992-02-01 09:24:22 +01:00
else
i1 = emit_insn_before (body, loop_start);
if (first == 0)
first = i1;
if (temp == fn_address_insn)
fn_address_insn = i1;
REG_NOTES (i1) = REG_NOTES (temp);
delete_insn (temp);
}
if (new_start == 0)
new_start = first;
1992-02-01 09:24:22 +01:00
}
if (m->savemode != VOIDmode)
{
/* P sets REG to zero; but we should clear only
the bits that are not covered by the mode
m->savemode. */
rtx reg = m->set_dest;
rtx sequence;
rtx tem;
1992-02-01 09:24:22 +01:00
start_sequence ();
tem = expand_binop
(GET_MODE (reg), and_optab, reg,
GEN_INT ((((HOST_WIDE_INT) 1
<< GET_MODE_BITSIZE (m->savemode)))
1992-02-01 09:24:22 +01:00
- 1),
reg, 1, OPTAB_LIB_WIDEN);
if (tem == 0)
abort ();
if (tem != reg)
emit_move_insn (reg, tem);
sequence = gen_sequence ();
end_sequence ();
i1 = emit_insn_before (sequence, loop_start);
}
else if (GET_CODE (p) == CALL_INSN)
{
i1 = emit_call_insn_before (PATTERN (p), loop_start);
/* Because the USAGE information potentially
contains objects other than hard registers
we need to copy it. */
if (CALL_INSN_FUNCTION_USAGE (p))
CALL_INSN_FUNCTION_USAGE (i1)
= copy_rtx (CALL_INSN_FUNCTION_USAGE (p));
}
else if (count == m->consec && m->move_insn_first)
{
/* The SET_SRC might not be invariant, so we must
use the REG_EQUAL note. */
start_sequence ();
emit_move_insn (m->set_dest, m->set_src);
temp = get_insns ();
end_sequence ();
add_label_notes (m->set_src, temp);
i1 = emit_insns_before (temp, loop_start);
if (! find_reg_note (i1, REG_EQUAL, NULL_RTX))
REG_NOTES (i1)
= gen_rtx_EXPR_LIST ((m->is_equiv ? REG_EQUIV
: REG_EQUAL),
m->set_src, REG_NOTES (i1));
}
1992-02-01 09:24:22 +01:00
else
i1 = emit_insn_before (PATTERN (p), loop_start);
if (REG_NOTES (i1) == 0)
{
REG_NOTES (i1) = REG_NOTES (p);
1992-02-01 09:24:22 +01:00
/* If there is a REG_EQUAL note present whose value
is not loop invariant, then delete it, since it
may cause problems with later optimization passes.
It is possible for cse to create such notes
like this as a result of record_jump_cond. */
if ((temp = find_reg_note (i1, REG_EQUAL, NULL_RTX))
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
&& ! loop_invariant_p (loop, XEXP (temp, 0)))
remove_note (i1, temp);
}
1992-02-01 09:24:22 +01:00
if (new_start == 0)
new_start = i1;
if (loop_dump_stream)
fprintf (loop_dump_stream, " moved to %d",
INSN_UID (i1));
/* If library call, now fix the REG_NOTES that contain
insn pointers, namely REG_LIBCALL on FIRST
and REG_RETVAL on I1. */
Fix warious warnings: * c-aux-info.c: Include string.h/strings.h. * pa.c: Include stdlib.h. (pa_combine_instructions): Prototype the function. (pa_can_combine_p, forward_branch_p, shadd_constant_p): Likewise. (reloc_needed): Add default case for enumeration switch. (remove_useless_addtr_insns): Remove unused variable `all'. (hppa_expand_prologue): Add explicit braces to avoid ambiguous `else'. (output_function_epilogue): Remove unused variable `i'. (output_millicode_call): Remove unused variable `link'. (shadd_constant_p, forward_branch_p): Make the function static. (following_call): Explicitly declare to return int. (pa_reorg): Declare as void. (pa_combine_instructions): Declare as static void. Add parentheses around && within ||. * pa.h: Add prototypes for pa_reorg, symbolic_operand, following_call, function_label_operand, lhs_lshift_cint_operand and zdepi_cint_p. * pa.md: Add parentheses around && within ||. * cppalloc.c: Include stdlib.h. * cpperror.c (cpp_print_containing_files): Remove unused variable `i'. Fix format specifier in fprintf. * cse.c (cse_around_loop): Add explicit braces to avoid ambiguous `else'. (delete_dead_from_cse): Wrap variable `tem' in macro HAVE_cc0. * expr.c (expand_expr): Add parentheses around && within ||. * final.c (app_enable): Replace fprintf with fputs where there are no format specifiers and no trailing argument after the string. Eg, when printing ASM_APP_ON/ASM_APP_OFF. (app_disable): Likewise. (final_end_function): Likewise. (final_scan_insn): Likewise. Remove unused variable `set'. (profile_function): Wrap empty if-statement body in {} brackets. * function.c: Include stdlib.h. (pad_below): Wrap prototype and definition in ARGS_GROW_DOWNWARD. (reposition_prologue_and_epilogue_notes): Add parentheses around assignment used as truth value. * integrate.c (expand_inline_function): Wrap variable `cc0_insn' in macro HAVE_cc0. * jump.c (jump_optimize): Wrap variable `q' in macro HAVE_cc0. Remove unused variable `prev1'. * libgcc2.c (__bb_exit_trace_func): Add parentheses around && within ||. Fix format specifier in fprintf. (__bb_init_prg): Add parentheses around assignment used as truth value. * local-alloc.c: Include stdlib.h. (requires_inout): Add parentheses around assignment used as truth value. * loop.c (analyze_loop_iterations): Wrap prototype and definition in macro HAVE_decrement_and_branch_on_count. (insert_bct, instrument_loop_bct): Likewise. (move_movables): Add parentheses around assignment used as truth value. (consec_sets_invariant_p): Likewise. (maybe_eliminate_biv_1): Wrap variable `new' in macro HAVE_cc0. * objc/objc-act.c: Include stdlib.h. (lookup_method_in_protocol_list): Wrap empty else-statement body in braces. (lookup_protocol_in_reflist): Likewise. (objc_add_static_instance): Remove unused variables `decl_expr' and `decl_spec'. (get_objc_string_decl): Remove unused variable `decl'. (generate_static_references): Remove unused variables `idecl' and `instance'. (check_protocols): Wrap empty else-statement body in braces. * protoize.c: Include stdlib.h. (substr): Add parentheses around assignment used as truth value. (abspath): Likewise. (shortpath): Likewise. * regmove.c (fixup_match_1): Add parentheses around assignment used as truth value. * reload.c (push_secondary_reload): Remove unused variable `i'. (find_reloads): Add parentheses around assignment used as truth value. * reload1.c: Include stdlib.h. * rtl.h: Correct typo in prototype of offsettable_memref_p. * stmt.c (add_case_node): Add parentheses around assignment used as truth value. (case_tree2list): Likewise. * tree.c (valid_machine_attribute): Wrap variable `decl_attr_list' in macro VALID_MACHINE_DECL_ATTRIBUTE. Wrap variable `type_attr_list' in macro VALID_MACHINE_TYPE_ATTRIBUTE. (merge_attributes): Add explicit braces to avoid ambiguous `else'. * unroll.c (copy_loop_body): Wrap variable `cc0_insn' in macro HAVE_cc0. * varasm.c: Include stdlib.h. From-SVN: r18290
1998-02-28 08:06:53 +01:00
if ((temp = find_reg_note (i1, REG_RETVAL, NULL_RTX)))
1992-02-01 09:24:22 +01:00
{
XEXP (temp, 0) = first;
temp = find_reg_note (first, REG_LIBCALL, NULL_RTX);
1992-02-01 09:24:22 +01:00
XEXP (temp, 0) = i1;
}
temp = p;
1992-02-01 09:24:22 +01:00
delete_insn (p);
p = NEXT_INSN (p);
/* simplify_giv_expr expects that it can walk the insns
at m->insn forwards and see this old sequence we are
tossing here. delete_insn does preserve the next
pointers, but when we skip over a NOTE we must fix
it up. Otherwise that code walks into the non-deleted
insn stream. */
while (p && GET_CODE (p) == NOTE)
p = NEXT_INSN (temp) = NEXT_INSN (p);
1992-02-01 09:24:22 +01:00
}
/* The more regs we move, the less we like moving them. */
threshold -= 3;
}
/* Any other movable that loads the same register
MUST be moved. */
already_moved[regno] = 1;
/* This reg has been moved out of one loop. */
regs->moved_once[regno] = 1;
1992-02-01 09:24:22 +01:00
/* The reg set here is now invariant. */
if (! m->partial)
VARRAY_INT (regs->set_in_loop, regno) = 0;
1992-02-01 09:24:22 +01:00
m->done = 1;
/* Change the length-of-life info for the register
to say it lives at least the full length of this loop.
This will help guide optimizations in outer loops. */
if (uid_luid[REGNO_FIRST_UID (regno)] > INSN_LUID (loop_start))
1992-02-01 09:24:22 +01:00
/* This is the old insn before all the moved insns.
We can't use the moved insn because it is out of range
in uid_luid. Only the old insns have luids. */
REGNO_FIRST_UID (regno) = INSN_UID (loop_start);
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (uid_luid[REGNO_LAST_UID (regno)] < INSN_LUID (loop_end))
REGNO_LAST_UID (regno) = INSN_UID (loop_end);
1992-02-01 09:24:22 +01:00
/* Combine with this moved insn any other matching movables. */
if (! m->partial)
for (m1 = movables->head; m1; m1 = m1->next)
1992-02-01 09:24:22 +01:00
if (m1->match == m)
{
rtx temp;
/* Schedule the reg loaded by M1
for replacement so that shares the reg of M.
If the modes differ (only possible in restricted
circumstances, make a SUBREG.
Note this assumes that the target dependent files
treat REG and SUBREG equally, including within
GO_IF_LEGITIMATE_ADDRESS and in all the
predicates since we never verify that replacing the
original register with a SUBREG results in a
recognizable insn. */
1992-02-01 09:24:22 +01:00
if (GET_MODE (m->set_dest) == GET_MODE (m1->set_dest))
reg_map[m1->regno] = m->set_dest;
else
reg_map[m1->regno]
= gen_lowpart_common (GET_MODE (m1->set_dest),
m->set_dest);
1992-02-01 09:24:22 +01:00
/* Get rid of the matching insn
and prevent further processing of it. */
m1->done = 1;
/* if library call, delete all insn except last, which
is deleted below */
Fix warious warnings: * c-aux-info.c: Include string.h/strings.h. * pa.c: Include stdlib.h. (pa_combine_instructions): Prototype the function. (pa_can_combine_p, forward_branch_p, shadd_constant_p): Likewise. (reloc_needed): Add default case for enumeration switch. (remove_useless_addtr_insns): Remove unused variable `all'. (hppa_expand_prologue): Add explicit braces to avoid ambiguous `else'. (output_function_epilogue): Remove unused variable `i'. (output_millicode_call): Remove unused variable `link'. (shadd_constant_p, forward_branch_p): Make the function static. (following_call): Explicitly declare to return int. (pa_reorg): Declare as void. (pa_combine_instructions): Declare as static void. Add parentheses around && within ||. * pa.h: Add prototypes for pa_reorg, symbolic_operand, following_call, function_label_operand, lhs_lshift_cint_operand and zdepi_cint_p. * pa.md: Add parentheses around && within ||. * cppalloc.c: Include stdlib.h. * cpperror.c (cpp_print_containing_files): Remove unused variable `i'. Fix format specifier in fprintf. * cse.c (cse_around_loop): Add explicit braces to avoid ambiguous `else'. (delete_dead_from_cse): Wrap variable `tem' in macro HAVE_cc0. * expr.c (expand_expr): Add parentheses around && within ||. * final.c (app_enable): Replace fprintf with fputs where there are no format specifiers and no trailing argument after the string. Eg, when printing ASM_APP_ON/ASM_APP_OFF. (app_disable): Likewise. (final_end_function): Likewise. (final_scan_insn): Likewise. Remove unused variable `set'. (profile_function): Wrap empty if-statement body in {} brackets. * function.c: Include stdlib.h. (pad_below): Wrap prototype and definition in ARGS_GROW_DOWNWARD. (reposition_prologue_and_epilogue_notes): Add parentheses around assignment used as truth value. * integrate.c (expand_inline_function): Wrap variable `cc0_insn' in macro HAVE_cc0. * jump.c (jump_optimize): Wrap variable `q' in macro HAVE_cc0. Remove unused variable `prev1'. * libgcc2.c (__bb_exit_trace_func): Add parentheses around && within ||. Fix format specifier in fprintf. (__bb_init_prg): Add parentheses around assignment used as truth value. * local-alloc.c: Include stdlib.h. (requires_inout): Add parentheses around assignment used as truth value. * loop.c (analyze_loop_iterations): Wrap prototype and definition in macro HAVE_decrement_and_branch_on_count. (insert_bct, instrument_loop_bct): Likewise. (move_movables): Add parentheses around assignment used as truth value. (consec_sets_invariant_p): Likewise. (maybe_eliminate_biv_1): Wrap variable `new' in macro HAVE_cc0. * objc/objc-act.c: Include stdlib.h. (lookup_method_in_protocol_list): Wrap empty else-statement body in braces. (lookup_protocol_in_reflist): Likewise. (objc_add_static_instance): Remove unused variables `decl_expr' and `decl_spec'. (get_objc_string_decl): Remove unused variable `decl'. (generate_static_references): Remove unused variables `idecl' and `instance'. (check_protocols): Wrap empty else-statement body in braces. * protoize.c: Include stdlib.h. (substr): Add parentheses around assignment used as truth value. (abspath): Likewise. (shortpath): Likewise. * regmove.c (fixup_match_1): Add parentheses around assignment used as truth value. * reload.c (push_secondary_reload): Remove unused variable `i'. (find_reloads): Add parentheses around assignment used as truth value. * reload1.c: Include stdlib.h. * rtl.h: Correct typo in prototype of offsettable_memref_p. * stmt.c (add_case_node): Add parentheses around assignment used as truth value. (case_tree2list): Likewise. * tree.c (valid_machine_attribute): Wrap variable `decl_attr_list' in macro VALID_MACHINE_DECL_ATTRIBUTE. Wrap variable `type_attr_list' in macro VALID_MACHINE_TYPE_ATTRIBUTE. (merge_attributes): Add explicit braces to avoid ambiguous `else'. * unroll.c (copy_loop_body): Wrap variable `cc0_insn' in macro HAVE_cc0. * varasm.c: Include stdlib.h. From-SVN: r18290
1998-02-28 08:06:53 +01:00
if ((temp = find_reg_note (m1->insn, REG_RETVAL,
NULL_RTX)))
1992-02-01 09:24:22 +01:00
{
for (temp = XEXP (temp, 0); temp != m1->insn;
temp = NEXT_INSN (temp))
delete_insn (temp);
}
delete_insn (m1->insn);
/* Any other movable that loads the same register
MUST be moved. */
already_moved[m1->regno] = 1;
/* The reg merged here is now invariant,
if the reg it matches is invariant. */
if (! m->partial)
VARRAY_INT (regs->set_in_loop, m1->regno) = 0;
1992-02-01 09:24:22 +01:00
}
}
else if (loop_dump_stream)
fprintf (loop_dump_stream, "not desirable");
}
else if (loop_dump_stream && !m->match)
fprintf (loop_dump_stream, "not safe");
if (loop_dump_stream)
fprintf (loop_dump_stream, "\n");
}
if (new_start == 0)
new_start = loop_start;
/* Go through all the instructions in the loop, making
all the register substitutions scheduled in REG_MAP. */
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
for (p = new_start; p != loop_end; p = NEXT_INSN (p))
1992-02-01 09:24:22 +01:00
if (GET_CODE (p) == INSN || GET_CODE (p) == JUMP_INSN
|| GET_CODE (p) == CALL_INSN)
{
replace_regs (PATTERN (p), reg_map, nregs, 0);
replace_regs (REG_NOTES (p), reg_map, nregs, 0);
INSN_CODE (p) = -1;
1992-02-01 09:24:22 +01:00
}
/* Clean up. */
free (reg_map);
free (already_moved);
1992-02-01 09:24:22 +01:00
}
#if 0
/* Scan X and replace the address of any MEM in it with ADDR.
REG is the address that MEM should have before the replacement. */
static void
replace_call_address (x, reg, addr)
rtx x, reg, addr;
{
register enum rtx_code code;
register int i;
rtl.h (rtx_format): Constify a char*. * rtl.h (rtx_format): Constify a char*. * rtl.c (rtx_format): Likewise. (copy_rtx, copy_most_rtx, read_rtx): Likewise. (init_rtl): Use accessor macro, not `rtx_format'. * alias.c (rtx_equal_for_memref_p, find_symbolic_term): Constify a char*. * caller-save.c (mark_referenced_regs): Likewise. * combine.c (subst, make_compound_operation, known_cond, gen_rtx_combine, update_table_tick, get_last_value_validate, use_crosses_set_p, mark_used_regs_combine, move_deaths): Likewise. * cse.c (rtx_cost, mention_regs, canon_hash, exp_equiv_p, refers_to_p, canon_reg, fold_rtx, cse_process_notes, count_reg_usage): Likewise. * emit-rtl.c (gen_rtx, copy_rtx_if_shared, reset_used_flags): Likewise. * final.c (leaf_renumber_regs_insn): Likewise. * flow.c (mark_used_regs, find_use_as_address, dump_flow_info, dump_edge_info, count_reg_references): Likewise. * function.c (fixup_var_refs_1, walk_fixup_memory_subreg, fixup_stack_1, purge_addressof_1, instantiate_virtual_regs_1): Likewise. * gcse.c (oprs_unchanged_p, hash_expr_1, expr_equiv_p, oprs_not_set_p, expr_killed_p, compute_transp, find_used_regs, add_label_notes): Likewise. * genattrtab.c (attr_rtx, attr_copy_rtx, encode_units_mask, clear_struct_flag, count_sub_rtxs, count_alternatives, compares_alternatives_p, contained_in_p, walk_attr_value, write_expr_attr_cache): Likewise. * genconfig.c (walk_insn_part): Likewise. * genemit.c (max_operand_1, gen_exp): Likewise. * genextract.c (walk_rtx): Likewise. * genflags.c (num_operands): Likewise. * genoutput.c (scan_operands): Likewise. * genpeep.c (match_rtx): Likewise. * genrecog.c (add_to_sequence): Likewise. * haifa-sched.c (may_trap_exp, sched_analyze_2, attach_deaths): Likewise. * integrate.c (save_constants, copy_for_inline, copy_rtx_and_substitute, subst_constants, restore_constants): Likewise. * jump.c (mark_jump_label, invert_exp, redirect_exp, rtx_renumbered_equal_p, rtx_equal_for_thread_p): Likewise. * local-alloc.c (contains_replace_regs, memref_referenced_p): Likewise. * loop.c (record_excess_regs, rtx_equal_for_loop_p, add_label_notes, replace_call_address, count_nonfixed_reads, invariant_p, find_single_use_in_loop, find_mem_givs, find_life_end, maybe_eliminate_biv_1, update_reg_last_use): Likewise. * print-rtl.c (reg_names, print_rtx): Likewise. * recog.c (validate_replace_rtx_1, find_single_use_1): Likewise. * reg-stack.c (stack_regs_mentioned_p, record_label_references, record_reg_life_pat, swap_rtx_condition, goto_block_pat, print_blocks): Likewise. * regclass.c (fix_register, record_address_regs, reg_scan_mark_refs): Likewise. * regmove.c (stable_but_for_p): Likewise. * reload.c (loc_mentioned_in_p, operands_match_p, find_reloads_toplevsubst_reg_equivs, find_reloads_address_1, copy_replacements, refers_to_regno_for_reload_p, refers_to_mem_for_reload_p, find_inc_amount, regno_clobbered_p, reload_when_needed_name, reg_class_names, debug_reload_to_stream): Likewise. * reload1.c (eliminate_regs, scan_paradoxical_subregs, delete_address_reloads_1, count_occurrences, reload_cse_mem_conflict_p, reload_combine_note_use, add_auto_inc_notes): Likewise. * resource.c (mark_referenced_resources, mark_set_resources): Likewise. * rtlanal.c (rtx_unstable_p, rtx_varies_p, rtx_addr_varies_p, reg_mentioned_p, regs_set_between_p, modified_between_p, modified_in_p, refers_to_regno_p, reg_overlap_mentioned_p, rtx_equal_p, volatile_insn_p, volatile_refs_p, side_effects_p, may_trap_p, inequality_comparisons_p, replace_rtx, replace_regs, jmp_uses_reg_or_mem, for_each_rtx, regno_use_in): Likewise. * sched.c (sched_analyze_2, attach_deaths): Likewise. * stupid.c (stupid_mark_refs): Likewise. * unroll.c (remap_split_bivs): Likewise. * varasm.c (mark_constants): Likewise. * a29k/a29k.c (uses_local_reg_p): Likewise. * alpha/alpha.c (summarize_insn): Likewise. * arm/arm.c (symbol_mentioned_p, label_mentioned_p, eliminate_lr2ip): Likewise. * arm/thumb.c (symbol_mentioned_p, label_mentioned_p): Likewise. * i386/i386.c (symbolic_reference_mentioned_p, copy_all_rtx, reg_mentioned_in_mem): Likewise. * ns32k/ns32k.c (global_symbolic_reference_mentioned_p, symbolic_reference_mentioned_p): Likewise. * romp/romp.c (unsigned_comparisons_p, hash_rtx): Likewise. * sh/sh.c (regs_used, mark_use): Likewise. * vax/vax.c (vax_rtx_cost): Likewise. From-SVN: r28784
1999-08-21 01:05:25 +02:00
register const char *fmt;
1992-02-01 09:24:22 +01:00
if (x == 0)
return;
code = GET_CODE (x);
switch (code)
{
case PC:
case CC0:
case CONST_INT:
case CONST_DOUBLE:
case CONST:
case SYMBOL_REF:
case LABEL_REF:
case REG:
return;
case SET:
/* Short cut for very common case. */
replace_call_address (XEXP (x, 1), reg, addr);
return;
case CALL:
/* Short cut for very common case. */
replace_call_address (XEXP (x, 0), reg, addr);
return;
case MEM:
/* If this MEM uses a reg other than the one we expected,
something is wrong. */
if (XEXP (x, 0) != reg)
abort ();
XEXP (x, 0) = addr;
return;
default:
break;
1992-02-01 09:24:22 +01:00
}
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
if (fmt[i] == 'e')
replace_call_address (XEXP (x, i), reg, addr);
else if (fmt[i] == 'E')
1992-02-01 09:24:22 +01:00
{
register int j;
for (j = 0; j < XVECLEN (x, i); j++)
replace_call_address (XVECEXP (x, i, j), reg, addr);
}
}
}
#endif
/* Return the number of memory refs to addresses that vary
in the rtx X. */
static int
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
count_nonfixed_reads (loop, x)
const struct loop *loop;
1992-02-01 09:24:22 +01:00
rtx x;
{
register enum rtx_code code;
register int i;
rtl.h (rtx_format): Constify a char*. * rtl.h (rtx_format): Constify a char*. * rtl.c (rtx_format): Likewise. (copy_rtx, copy_most_rtx, read_rtx): Likewise. (init_rtl): Use accessor macro, not `rtx_format'. * alias.c (rtx_equal_for_memref_p, find_symbolic_term): Constify a char*. * caller-save.c (mark_referenced_regs): Likewise. * combine.c (subst, make_compound_operation, known_cond, gen_rtx_combine, update_table_tick, get_last_value_validate, use_crosses_set_p, mark_used_regs_combine, move_deaths): Likewise. * cse.c (rtx_cost, mention_regs, canon_hash, exp_equiv_p, refers_to_p, canon_reg, fold_rtx, cse_process_notes, count_reg_usage): Likewise. * emit-rtl.c (gen_rtx, copy_rtx_if_shared, reset_used_flags): Likewise. * final.c (leaf_renumber_regs_insn): Likewise. * flow.c (mark_used_regs, find_use_as_address, dump_flow_info, dump_edge_info, count_reg_references): Likewise. * function.c (fixup_var_refs_1, walk_fixup_memory_subreg, fixup_stack_1, purge_addressof_1, instantiate_virtual_regs_1): Likewise. * gcse.c (oprs_unchanged_p, hash_expr_1, expr_equiv_p, oprs_not_set_p, expr_killed_p, compute_transp, find_used_regs, add_label_notes): Likewise. * genattrtab.c (attr_rtx, attr_copy_rtx, encode_units_mask, clear_struct_flag, count_sub_rtxs, count_alternatives, compares_alternatives_p, contained_in_p, walk_attr_value, write_expr_attr_cache): Likewise. * genconfig.c (walk_insn_part): Likewise. * genemit.c (max_operand_1, gen_exp): Likewise. * genextract.c (walk_rtx): Likewise. * genflags.c (num_operands): Likewise. * genoutput.c (scan_operands): Likewise. * genpeep.c (match_rtx): Likewise. * genrecog.c (add_to_sequence): Likewise. * haifa-sched.c (may_trap_exp, sched_analyze_2, attach_deaths): Likewise. * integrate.c (save_constants, copy_for_inline, copy_rtx_and_substitute, subst_constants, restore_constants): Likewise. * jump.c (mark_jump_label, invert_exp, redirect_exp, rtx_renumbered_equal_p, rtx_equal_for_thread_p): Likewise. * local-alloc.c (contains_replace_regs, memref_referenced_p): Likewise. * loop.c (record_excess_regs, rtx_equal_for_loop_p, add_label_notes, replace_call_address, count_nonfixed_reads, invariant_p, find_single_use_in_loop, find_mem_givs, find_life_end, maybe_eliminate_biv_1, update_reg_last_use): Likewise. * print-rtl.c (reg_names, print_rtx): Likewise. * recog.c (validate_replace_rtx_1, find_single_use_1): Likewise. * reg-stack.c (stack_regs_mentioned_p, record_label_references, record_reg_life_pat, swap_rtx_condition, goto_block_pat, print_blocks): Likewise. * regclass.c (fix_register, record_address_regs, reg_scan_mark_refs): Likewise. * regmove.c (stable_but_for_p): Likewise. * reload.c (loc_mentioned_in_p, operands_match_p, find_reloads_toplevsubst_reg_equivs, find_reloads_address_1, copy_replacements, refers_to_regno_for_reload_p, refers_to_mem_for_reload_p, find_inc_amount, regno_clobbered_p, reload_when_needed_name, reg_class_names, debug_reload_to_stream): Likewise. * reload1.c (eliminate_regs, scan_paradoxical_subregs, delete_address_reloads_1, count_occurrences, reload_cse_mem_conflict_p, reload_combine_note_use, add_auto_inc_notes): Likewise. * resource.c (mark_referenced_resources, mark_set_resources): Likewise. * rtlanal.c (rtx_unstable_p, rtx_varies_p, rtx_addr_varies_p, reg_mentioned_p, regs_set_between_p, modified_between_p, modified_in_p, refers_to_regno_p, reg_overlap_mentioned_p, rtx_equal_p, volatile_insn_p, volatile_refs_p, side_effects_p, may_trap_p, inequality_comparisons_p, replace_rtx, replace_regs, jmp_uses_reg_or_mem, for_each_rtx, regno_use_in): Likewise. * sched.c (sched_analyze_2, attach_deaths): Likewise. * stupid.c (stupid_mark_refs): Likewise. * unroll.c (remap_split_bivs): Likewise. * varasm.c (mark_constants): Likewise. * a29k/a29k.c (uses_local_reg_p): Likewise. * alpha/alpha.c (summarize_insn): Likewise. * arm/arm.c (symbol_mentioned_p, label_mentioned_p, eliminate_lr2ip): Likewise. * arm/thumb.c (symbol_mentioned_p, label_mentioned_p): Likewise. * i386/i386.c (symbolic_reference_mentioned_p, copy_all_rtx, reg_mentioned_in_mem): Likewise. * ns32k/ns32k.c (global_symbolic_reference_mentioned_p, symbolic_reference_mentioned_p): Likewise. * romp/romp.c (unsigned_comparisons_p, hash_rtx): Likewise. * sh/sh.c (regs_used, mark_use): Likewise. * vax/vax.c (vax_rtx_cost): Likewise. From-SVN: r28784
1999-08-21 01:05:25 +02:00
register const char *fmt;
1992-02-01 09:24:22 +01:00
int value;
if (x == 0)
return 0;
code = GET_CODE (x);
switch (code)
{
case PC:
case CC0:
case CONST_INT:
case CONST_DOUBLE:
case CONST:
case SYMBOL_REF:
case LABEL_REF:
case REG:
return 0;
case MEM:
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
return ((loop_invariant_p (loop, XEXP (x, 0)) != 1)
+ count_nonfixed_reads (loop, XEXP (x, 0)));
default:
break;
1992-02-01 09:24:22 +01:00
}
value = 0;
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
if (fmt[i] == 'e')
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
value += count_nonfixed_reads (loop, XEXP (x, i));
if (fmt[i] == 'E')
1992-02-01 09:24:22 +01:00
{
register int j;
for (j = 0; j < XVECLEN (x, i); j++)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
value += count_nonfixed_reads (loop, XVECEXP (x, i, j));
1992-02-01 09:24:22 +01:00
}
}
return value;
}
/* Scan a loop setting the elements `cont', `vtop', `loops_enclosed',
`has_call', `has_volatile', `has_tablejump',
`unknown_address_altered', `unknown_constant_address_altered', and
`num_mem_sets' in LOOP. Also, fill in the array `mems' and the
list `store_mems' in LOOP. */
1992-02-01 09:24:22 +01:00
static void
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
prescan_loop (loop)
struct loop *loop;
1992-02-01 09:24:22 +01:00
{
register int level = 1;
1998-08-19 14:30:47 +02:00
rtx insn;
struct loop_info *loop_info = LOOP_INFO (loop);
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
rtx start = loop->start;
rtx end = loop->end;
1998-08-19 14:30:47 +02:00
/* The label after END. Jumping here is just like falling off the
end of the loop. We use next_nonnote_insn instead of next_label
as a hedge against the (pathological) case where some actual insn
might end up between the two. */
rtx exit_target = next_nonnote_insn (end);
loop_info->has_indirect_jump = indirect_jump_in_function;
loop_info->has_call = 0;
loop_info->has_volatile = 0;
loop_info->has_tablejump = 0;
loop_info->has_multiple_exit_targets = 0;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
loop->level = 1;
1992-02-01 09:24:22 +01:00
loop_info->unknown_address_altered = 0;
loop_info->unknown_constant_address_altered = 0;
loop_info->store_mems = NULL_RTX;
loop_info->first_loop_store_insn = NULL_RTX;
loop_info->mems_idx = 0;
loop_info->num_mem_sets = 0;
1992-02-01 09:24:22 +01:00
for (insn = NEXT_INSN (start); insn != NEXT_INSN (end);
insn = NEXT_INSN (insn))
{
if (GET_CODE (insn) == NOTE)
{
if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG)
{
++level;
/* Count number of loops contained in this one. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
loop->level++;
1992-02-01 09:24:22 +01:00
}
else if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_END)
{
--level;
}
}
else if (GET_CODE (insn) == CALL_INSN)
{
* Integrate alias analysis changes from jfc@mit.edu * Makefile.in (OBJS): Add alias.o (alias.o): Add dependencies. * alias.c: New file. * sched.c: Remove alias analysis code. It lives in alias.c now. (reg_last_uses_size): Declare. (sched_analyze_2): Add new arguments to true_dependence. (sched_analyze_insn): Use reg_last_uses_size instead of max_reg. (schedule_block): Initialize reg_last_uses_size. (schedule_insns): Always call init_alias_analysis. * calls.c (expand_call): Note calls to malloc, calloc, and realloc; mark return value from such functions as a pointer and keep track of them for alias analysis. If a return value from a function is a pointer, mark it as such. * combine.c (distribute_notes): Handle REG_NOALIAS. * cse.c (struct write_data): Delete. No longer needed. (invalidate): Don't call set_nonvarying_address_components anymore. Use true_dependence to decide if an entry should be removed from the hash table. (invalidate_memory): Remove WRITES argument, simplify appropriately. Fix all callers. (note_mem_written): Similarly for WRITE_PTR argument. (invalidate_from_clobbers): Similarly for W argument. (invalidate_for_call): Remove memory elements from the hash table. (refers_to_mem_p, cse_rtx_addr_varies_p): Deleted. (cse_rtx_varies_p): New function. Derived from old cse_rtx_addr_varies_p. (cse_insn): Remove WRITES_MEMORY and INIT variables and all references. Don't call note_mem_written anymore. Stack pushes invalidate the stack pointer if PUSH_ROUNDING is defined. No longer need to call cse_rtx_addr_varies_p to decide if a MEM should be invalidated. (skipped_writes_memory): Remove variable. (invalidate_skipped_set): Simplify and wewrite to use invalidate_memory. (invalidate_skipped_block): Simplify for new alias analysis code. (cse_set_around_loop): Likewise. (cse_main): Call init_alias_analysis. * flags.h (flag_alias_check, flag_argument_noalias): Declare. * toplev.c (flag_alias_check, flag_argument_noalias): Define. (f_options): Add new alias checking arguments. (main): Set flag_alias_check when optimizing. * local_alloc (validate_equiv_mem_from_store): Add new arguments to true_dependence. (memref_referenced_p): Likewise. * loop.c (NUM_STORES): Increase to 30. (prescan_loop): Only non-constant calls set unknown_address_altered. (invariant_p): Add new arguments to true_dependence. (record_giv): Initialize unrolled and shared fields. (emit_iv_add_mult): Call record_base_value as needed. * loop.h (struct induction): Add unrolled and shared fields. * unroll.c (unroll_loop): Call record_base_value as needed. (copy_loop_body): Likewise. (final_biv_value): Likewise. (final_giv_value): Likewise. (find_splittable_regs): Likewise. Only create one new pseudo if we have multiple address GIVs that were combined with the same dst_reg GIV. Note when a new register is created due to unrolling. * rtl.c (reg_note_name): Add REG_NOALIAS. * rtl.h (enum reg_note): Similarly. (rtx_varies_p, may_trap_p, side_effects_p): Declare. (volatile_refs_p, volatile_insn_p, remove_note): Likewise. (note_stores, refers_to_regno_p, reg_overlap_mentioned_p): Likewise. (true_dependence, read_dependence, anti_dependence): Likewise. (output_dependence, init_alias_analysis, end_alias_analysis): Likewise. (mark_user_reg, mark_reg_pointer): Likewise. jfc's alias analysis code. From-SVN: r14768
1997-08-11 22:07:24 +02:00
if (! CONST_CALL_P (insn))
loop_info->unknown_address_altered = 1;
loop_info->has_call = 1;
1992-02-01 09:24:22 +01:00
}
1998-08-19 14:30:47 +02:00
else if (GET_CODE (insn) == INSN || GET_CODE (insn) == JUMP_INSN)
1992-02-01 09:24:22 +01:00
{
1998-08-19 14:30:47 +02:00
rtx label1 = NULL_RTX;
rtx label2 = NULL_RTX;
if (volatile_refs_p (PATTERN (insn)))
loop_info->has_volatile = 1;
if (GET_CODE (insn) == JUMP_INSN
&& (GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC
|| GET_CODE (PATTERN (insn)) == ADDR_VEC))
loop_info->has_tablejump = 1;
note_stores (PATTERN (insn), note_addr_stored, loop_info);
if (! loop_info->first_loop_store_insn && loop_info->store_mems)
loop_info->first_loop_store_insn = insn;
1998-08-19 14:30:47 +02:00
if (! loop_info->has_multiple_exit_targets
1998-08-19 14:30:47 +02:00
&& GET_CODE (insn) == JUMP_INSN
&& GET_CODE (PATTERN (insn)) == SET
&& SET_DEST (PATTERN (insn)) == pc_rtx)
{
1998-08-19 14:30:47 +02:00
if (GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE)
{
label1 = XEXP (SET_SRC (PATTERN (insn)), 1);
label2 = XEXP (SET_SRC (PATTERN (insn)), 2);
}
else
{
label1 = SET_SRC (PATTERN (insn));
}
do
{
if (label1 && label1 != pc_rtx)
{
if (GET_CODE (label1) != LABEL_REF)
{
/* Something tricky. */
loop_info->has_multiple_exit_targets = 1;
break;
}
else if (XEXP (label1, 0) != exit_target
&& LABEL_OUTSIDE_LOOP_P (label1))
{
/* A jump outside the current loop. */
loop_info->has_multiple_exit_targets = 1;
break;
}
}
label1 = label2;
label2 = NULL_RTX;
}
while (label1);
}
1992-02-01 09:24:22 +01:00
}
1998-08-19 14:30:47 +02:00
else if (GET_CODE (insn) == RETURN)
loop_info->has_multiple_exit_targets = 1;
1992-02-01 09:24:22 +01:00
}
1998-08-19 14:30:47 +02:00
/* Now, rescan the loop, setting up the LOOP_MEMS array. */
if (/* An exception thrown by a called function might land us
1998-08-19 14:30:47 +02:00
anywhere. */
! loop_info->has_call
1998-08-19 14:30:47 +02:00
/* We don't want loads for MEMs moved to a location before the
one at which their stack memory becomes allocated. (Note
that this is not a problem for malloc, etc., since those
require actual function calls. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
&& ! current_function_calls_alloca
1998-08-19 14:30:47 +02:00
/* There are ways to leave the loop other than falling off the
end. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
&& ! loop_info->has_multiple_exit_targets)
1998-08-19 14:30:47 +02:00
for (insn = NEXT_INSN (start); insn != NEXT_INSN (end);
insn = NEXT_INSN (insn))
for_each_rtx (&insn, insert_loop_mem, loop_info);
/* BLKmode MEMs are added to LOOP_STORE_MEM as necessary so
that loop_invariant_p and load_mems can use true_dependence
to determine what is really clobbered. */
if (loop_info->unknown_address_altered)
{
rtx mem = gen_rtx_MEM (BLKmode, const0_rtx);
loop_info->store_mems
= gen_rtx_EXPR_LIST (VOIDmode, mem, loop_info->store_mems);
}
if (loop_info->unknown_constant_address_altered)
{
rtx mem = gen_rtx_MEM (BLKmode, const0_rtx);
RTX_UNCHANGING_P (mem) = 1;
loop_info->store_mems
= gen_rtx_EXPR_LIST (VOIDmode, mem, loop_info->store_mems);
}
1992-02-01 09:24:22 +01:00
}
/* Scan the function looking for loops. Record the start and end of each loop.
Also mark as invalid loops any loops that contain a setjmp or are branched
to from outside the loop. */
static void
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
find_and_verify_loops (f, loops)
1992-02-01 09:24:22 +01:00
rtx f;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
struct loops *loops;
1992-02-01 09:24:22 +01:00
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
rtx insn;
rtx label;
int num_loops;
struct loop *current_loop;
struct loop *next_loop;
struct loop *loop;
num_loops = loops->num;
1992-02-01 09:24:22 +01:00
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
compute_luids (f, NULL_RTX, 0);
1992-02-01 09:24:22 +01:00
/* If there are jumps to undefined labels,
treat them as jumps out of any/all loops.
This also avoids writing past end of tables when there are no loops. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
uid_loop[0] = NULL;
1992-02-01 09:24:22 +01:00
/* Find boundaries of loops, mark which loops are contained within
loops, and invalidate loops that have setjmp. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
num_loops = 0;
current_loop = NULL;
1992-02-01 09:24:22 +01:00
for (insn = f; insn; insn = NEXT_INSN (insn))
{
if (GET_CODE (insn) == NOTE)
switch (NOTE_LINE_NUMBER (insn))
{
case NOTE_INSN_LOOP_BEG:
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
next_loop = loops->array + num_loops;
next_loop->num = num_loops;
num_loops++;
next_loop->start = insn;
next_loop->outer = current_loop;
1992-02-01 09:24:22 +01:00
current_loop = next_loop;
break;
case NOTE_INSN_SETJMP:
/* In this case, we must invalidate our current loop and any
enclosing loop. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (loop = current_loop; loop; loop = loop->outer)
1992-02-01 09:24:22 +01:00
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
loop->invalid = 1;
1992-02-01 09:24:22 +01:00
if (loop_dump_stream)
fprintf (loop_dump_stream,
"\nLoop at %d ignored due to setjmp.\n",
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
INSN_UID (loop->start));
1992-02-01 09:24:22 +01:00
}
break;
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
case NOTE_INSN_LOOP_CONT:
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
current_loop->cont = insn;
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
break;
case NOTE_INSN_LOOP_VTOP:
current_loop->vtop = insn;
break;
1992-02-01 09:24:22 +01:00
case NOTE_INSN_LOOP_END:
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (! current_loop)
1992-02-01 09:24:22 +01:00
abort ();
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
current_loop->end = insn;
current_loop = current_loop->outer;
1992-02-01 09:24:22 +01:00
break;
default:
break;
1992-02-01 09:24:22 +01:00
}
/* Note that this will mark the NOTE_INSN_LOOP_END note as being in the
enclosing loop, but this doesn't matter. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
uid_loop[INSN_UID (insn)] = current_loop;
1992-02-01 09:24:22 +01:00
}
/* Any loop containing a label used in an initializer must be invalidated,
because it can be jumped into from anywhere. */
for (label = forced_labels; label; label = XEXP (label, 1))
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (loop = uid_loop[INSN_UID (XEXP (label, 0))];
loop; loop = loop->outer)
loop->invalid = 1;
}
1996-07-23 22:03:47 +02:00
/* Any loop containing a label used for an exception handler must be
invalidated, because it can be jumped into from anywhere. */
for (label = exception_handler_labels; label; label = XEXP (label, 1))
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (loop = uid_loop[INSN_UID (XEXP (label, 0))];
loop; loop = loop->outer)
loop->invalid = 1;
1996-07-23 22:03:47 +02:00
}
/* Now scan all insn's in the function. If any JUMP_INSN branches into a
loop that it is not contained within, that loop is marked invalid.
If any INSN or CALL_INSN uses a label's address, then the loop containing
that label is marked invalid, because it could be jumped into from
anywhere.
1992-02-01 09:24:22 +01:00
Also look for blocks of code ending in an unconditional branch that
exits the loop. If such a block is surrounded by a conditional
1992-02-01 09:24:22 +01:00
branch around the block, move the block elsewhere (see below) and
invert the jump to point to the code block. This may eliminate a
label in our loop and will simplify processing by both us and a
possible second cse pass. */
for (insn = f; insn; insn = NEXT_INSN (insn))
alias.c (mark_constant_function): Use INSN_P. * alias.c (mark_constant_function): Use INSN_P. (init_alias_analysis): Likewise. * combine.c (combine_instructions): Use INSN_P. (can_combine_p): Likewise. (try_combine): Likewise. (distribute_notes): Likewise. (distribute_links): Likewise. * cse.c (cse_around_loop): Use INSN_P. (invalidate_skipped_block): Likewise. (cse_set_around_loop): Likewise. (cse_end_of_basic_block): Likewise. (delete_trivially_dead_insns): Likewise. * emit-rtl.c (unshare_all_rtl_again): Use INSN_P. (unshare_all_rtl_1): Likewise. (next_cc0_user): Likewise. (try_split make_insn_raw): Likewise. (remove_unnecessary_notes): Likewise. * final.c (shorten_branches): Use INSN_P. (leaf_renumber_regs): Likewise. (leaf_renumber_regs_insn): Likewise. * flow.c (find_label_refs): Use INSN_P. (verify_wide_reg): Likewise. (notice_stack_pointer_modification): Likewise. (count_or_remove_death_notes): Likewise. (verify_flow_info): Likewise. (clear_log_links): Likewise. * function.c (fixup_var_refs_insns): Use INSN_P. (compute_insns_for_mem): Likewise. * gcse.c (alloc_gcse_mem): Use INSN_P. (compute_sets): Likewise. (compute_hash_table): Likewise. (classic_gcse): Likewise. (cprop): Likewise. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks_1): Likewise. * global.c (expand_preferences): Use INSN_P. (build_insn_chain): Likewise. * graph.c (node_data): Use INSN_P. * haifa-sched.c (priority): Use INSN_P. (rm_line_notes): Likewise. (rm_other_notes): Likewise. (find_insn_reg_weight): Likewise. (init_target_units): Likewise. (schedule_block): Likewise. (compute_block_forward_dependences): Likewise. (debug_dependencies): Likewise. (set_priorities): Likewise. * integrate.c (function_cannot_inline_p): Use INSN_P. (save_parm_insns): Likewise. (copy_insn_list): Likewise. * jump.c (mark_all_labels): Use INSN_P. (never_reached_warning): Likewise. * lcm.c (optimize_mode_switching): Use INSN_P. * local-alloc.c (validate_equiv_mem): Use INSN_P. (memref_used_between_p): Likewise. (update_equiv_regs): Likewise. (block_alloc): Likewise. (no_conflict_p): Likewise. * loop.c (scan_loop): Use INSN_P. (find_and_verify_loops): Likewise. (count_loop_regs_set): Likewise. (loop_reg_used_before_p): Likewise. (strength_reduce): Likewise. (recombine_givs): Likewise. (check_dbra_loop): Likewise. (load_mems): Likewise. (try_copy_prop): Likewise. * print-rtl.c (print_rtx): Use INSN_P. * recog.c (find_single_use): Use INSN_P. * reg-stack.c (stack_regs_mentioned): Use INSN_P. (next_flags_user): Likewise. (swap_rtx_condition): Likewise. * regmove.c (mark_flags_life_zones): Use INSN_P. (optimize_reg_copy_1): Likewise. (optimize_reg_copy_2): Likewise. (optimize_reg_copy_3): Likewise. (reg_is_remote_constant_p): Likewise. (fixup_match_2): Likewise. (regmove_optimize): Likewise. (fixup_match_1): Likewise. * regrename.c (build_def_use): Use INSN_P. (replace_reg_in_block): Likewise. (consider_use): Likewise. * reload.c (find_equiv_reg): Use INSN_P. * reload1.c (reload): Use INSN_P. (maybe_fix_stack_asms): Likewise. (calculate_needs_all_insns): Likewise. (reload_as_needed): Likewise. (emit_output_reload_insns): Likewise. (delete_address_reloads_1): Likewise. (reload_cse_regs_1): Likewise. (reload_combine): Likewise. (reload_cse_move2add): Likewise. * reorg.c (redundant_insn): Use INSN_P. (dbr_schedule): Likewise. * resource.c (find_dead_or_set_registers): Use INSN_P. (mark_target_live_regs): Likewise. * rtlanal.c (reg_used_between_p): Use INSN_P. (reg_referenced_between_p): Likewise. (reg_set_between_p): Likewise. (reg_set_p): Likewise. (single_set): Likewise. (multiple_sets): Likewise. (find_last_value): Likewise. (reg_set_last): Likewise. (find_reg_note): Likewise. (find_regno_note): Likewise. * sibcall.c (sequence_uses_addressof): Use INSN_P. * simplify-rtx.c (cselib_process_insn): Use INSN_P. * ssa.c (find_evaluations): Use INSN_P. (rename_block): Likewise. (rename_equivalent_regs): Likewise. * unroll.c (loop_find_equiv_value): Use INSN_P. (set_dominates_use): Likewise. * varasm.c (mark_constant_pool): Use INSN_P. (mark_constants): Likewise. * config/alpha/alpha.c (alpha_does_function_need_gp): Use INSN_P. (alphaev4_next_group): Likewise. (alphaev5_next_group): Likewise. * config/c4x/c4x.c (c4x_process_after_reload): Use INSN_P. (c4x_rptb_rpts_p): Likewise. * config/mips/mips.c (mips16_optimize_gp): Use INSN_P. * config/rs6000/rs6000.c (uses_TOC): Use INSN_P. (rs6000_adjust_priority): Likewise. * config/sh/sh.c (sh_loop_align): Use INSN_P. (machine_dependent_reorg): Likewise. (split_branches): Likewise. * config/tahoe/tahoe.c (tahoe_cmp_check): Use INSN_P. From-SVN: r35494
2000-08-04 22:28:08 +02:00
if (INSN_P (insn))
1992-02-01 09:24:22 +01:00
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
struct loop *this_loop = uid_loop[INSN_UID (insn)];
1992-02-01 09:24:22 +01:00
if (GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN)
{
rtx note = find_reg_note (insn, REG_LABEL, NULL_RTX);
if (note)
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (loop = uid_loop[INSN_UID (XEXP (note, 0))];
loop; loop = loop->outer)
loop->invalid = 1;
}
}
if (GET_CODE (insn) != JUMP_INSN)
continue;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
mark_loop_jump (PATTERN (insn), this_loop);
1992-02-01 09:24:22 +01:00
/* See if this is an unconditional branch outside the loop. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (this_loop
1992-02-01 09:24:22 +01:00
&& (GET_CODE (PATTERN (insn)) == RETURN
|| (any_uncondjump_p (insn)
&& onlyjump_p (insn)
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
&& (uid_loop[INSN_UID (JUMP_LABEL (insn))]
!= this_loop)))
&& get_max_uid () < max_uid_for_loop)
1992-02-01 09:24:22 +01:00
{
rtx p;
rtx our_next = next_real_insn (insn);
rtx last_insn_to_move = NEXT_INSN (insn);
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
struct loop *dest_loop;
struct loop *outer_loop = NULL;
1992-02-01 09:24:22 +01:00
/* Go backwards until we reach the start of the loop, a label,
or a JUMP_INSN. */
for (p = PREV_INSN (insn);
GET_CODE (p) != CODE_LABEL
&& ! (GET_CODE (p) == NOTE
&& NOTE_LINE_NUMBER (p) == NOTE_INSN_LOOP_BEG)
&& GET_CODE (p) != JUMP_INSN;
p = PREV_INSN (p))
;
/* Check for the case where we have a jump to an inner nested
loop, and do not perform the optimization in that case. */
if (JUMP_LABEL (insn))
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
dest_loop = uid_loop[INSN_UID (JUMP_LABEL (insn))];
if (dest_loop)
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (outer_loop = dest_loop; outer_loop;
outer_loop = outer_loop->outer)
if (outer_loop == this_loop)
break;
}
}
/* Make sure that the target of P is within the current loop. */
if (GET_CODE (p) == JUMP_INSN && JUMP_LABEL (p)
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
&& uid_loop[INSN_UID (JUMP_LABEL (p))] != this_loop)
outer_loop = this_loop;
1992-02-01 09:24:22 +01:00
/* If we stopped on a JUMP_INSN to the next insn after INSN,
we have a block of code to try to move.
We look backward and then forward from the target of INSN
to find a BARRIER at the same loop depth as the target.
If we find such a BARRIER, we make a new label for the start
of the block, invert the jump in P and point it to that label,
and move the block of code to the spot we found. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (! outer_loop
&& GET_CODE (p) == JUMP_INSN
&& JUMP_LABEL (p) != 0
/* Just ignore jumps to labels that were never emitted.
These always indicate compilation errors. */
&& INSN_UID (JUMP_LABEL (p)) != 0
&& any_condjump_p (p) && onlyjump_p (p)
&& next_real_insn (JUMP_LABEL (p)) == our_next
/* If it's not safe to move the sequence, then we
mustn't try. */
&& insns_safe_to_move_p (p, NEXT_INSN (insn),
&last_insn_to_move))
1992-02-01 09:24:22 +01:00
{
rtx target
= JUMP_LABEL (insn) ? JUMP_LABEL (insn) : get_last_insn ();
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
struct loop *target_loop = uid_loop[INSN_UID (target)];
rtx loc, loc2;
1992-02-01 09:24:22 +01:00
for (loc = target; loc; loc = PREV_INSN (loc))
if (GET_CODE (loc) == BARRIER
/* Don't move things inside a tablejump. */
&& ((loc2 = next_nonnote_insn (loc)) == 0
|| GET_CODE (loc2) != CODE_LABEL
|| (loc2 = next_nonnote_insn (loc2)) == 0
|| GET_CODE (loc2) != JUMP_INSN
|| (GET_CODE (PATTERN (loc2)) != ADDR_VEC
&& GET_CODE (PATTERN (loc2)) != ADDR_DIFF_VEC))
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
&& uid_loop[INSN_UID (loc)] == target_loop)
1992-02-01 09:24:22 +01:00
break;
if (loc == 0)
for (loc = target; loc; loc = NEXT_INSN (loc))
if (GET_CODE (loc) == BARRIER
/* Don't move things inside a tablejump. */
&& ((loc2 = next_nonnote_insn (loc)) == 0
|| GET_CODE (loc2) != CODE_LABEL
|| (loc2 = next_nonnote_insn (loc2)) == 0
|| GET_CODE (loc2) != JUMP_INSN
|| (GET_CODE (PATTERN (loc2)) != ADDR_VEC
&& GET_CODE (PATTERN (loc2)) != ADDR_DIFF_VEC))
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
&& uid_loop[INSN_UID (loc)] == target_loop)
1992-02-01 09:24:22 +01:00
break;
if (loc)
{
rtx cond_label = JUMP_LABEL (p);
rtx new_label = get_label_after (p);
/* Ensure our label doesn't go away. */
LABEL_NUSES (cond_label)++;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
/* Verify that uid_loop is large enough and that
1996-07-04 00:07:53 +02:00
we can invert P. */
if (invert_jump (p, new_label, 1))
{
rtx q, r;
/* If no suitable BARRIER was found, create a suitable
one before TARGET. Since TARGET is a fall through
path, we'll need to insert an jump around our block
and a add a BARRIER before TARGET.
This creates an extra unconditional jump outside
the loop. However, the benefits of removing rarely
executed instructions from inside the loop usually
outweighs the cost of the extra unconditional jump
outside the loop. */
if (loc == 0)
{
rtx temp;
temp = gen_jump (JUMP_LABEL (insn));
temp = emit_jump_insn_before (temp, target);
JUMP_LABEL (temp) = JUMP_LABEL (insn);
LABEL_NUSES (JUMP_LABEL (insn))++;
loc = emit_barrier_before (target);
}
/* Include the BARRIER after INSN and copy the
block after LOC. */
new_label = squeeze_notes (new_label,
last_insn_to_move);
reorder_insns (new_label, last_insn_to_move, loc);
/* All those insns are now in TARGET_LOOP. */
for (q = new_label;
q != NEXT_INSN (last_insn_to_move);
q = NEXT_INSN (q))
uid_loop[INSN_UID (q)] = target_loop;
/* The label jumped to by INSN is no longer a loop
exit. Unless INSN does not have a label (e.g.,
it is a RETURN insn), search loop->exit_labels
to find its label_ref, and remove it. Also turn
off LABEL_OUTSIDE_LOOP_P bit. */
if (JUMP_LABEL (insn))
{
for (q = 0, r = this_loop->exit_labels;
r;
q = r, r = LABEL_NEXTREF (r))
if (XEXP (r, 0) == JUMP_LABEL (insn))
{
LABEL_OUTSIDE_LOOP_P (r) = 0;
if (q)
LABEL_NEXTREF (q) = LABEL_NEXTREF (r);
else
this_loop->exit_labels = LABEL_NEXTREF (r);
break;
}
for (loop = this_loop; loop && loop != target_loop;
loop = loop->outer)
loop->exit_count--;
/* If we didn't find it, then something is
wrong. */
if (! r)
abort ();
}
/* P is now a jump outside the loop, so it must be put
in loop->exit_labels, and marked as such.
The easiest way to do this is to just call
mark_loop_jump again for P. */
mark_loop_jump (PATTERN (p), this_loop);
/* If INSN now jumps to the insn after it,
delete INSN. */
if (JUMP_LABEL (insn) != 0
&& (next_real_insn (JUMP_LABEL (insn))
== next_real_insn (insn)))
delete_insn (insn);
}
1992-02-01 09:24:22 +01:00
/* Continue the loop after where the conditional
branch used to jump, since the only branch insn
in the block (if it still remains) is an inter-loop
branch and hence needs no processing. */
insn = NEXT_INSN (cond_label);
if (--LABEL_NUSES (cond_label) == 0)
delete_insn (cond_label);
/* This loop will be continued with NEXT_INSN (insn). */
insn = PREV_INSN (insn);
1992-02-01 09:24:22 +01:00
}
}
}
}
}
/* If any label in X jumps to a loop different from LOOP_NUM and any of the
loops it is contained in, mark the target loop invalid.
For speed, we assume that X is part of a pattern of a JUMP_INSN. */
static void
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
mark_loop_jump (x, loop)
1992-02-01 09:24:22 +01:00
rtx x;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
struct loop *loop;
1992-02-01 09:24:22 +01:00
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
struct loop *dest_loop;
struct loop *outer_loop;
1992-02-01 09:24:22 +01:00
int i;
switch (GET_CODE (x))
{
case PC:
case USE:
case CLOBBER:
case REG:
case MEM:
case CONST_INT:
case CONST_DOUBLE:
case RETURN:
return;
case CONST:
/* There could be a label reference in here. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
mark_loop_jump (XEXP (x, 0), loop);
1992-02-01 09:24:22 +01:00
return;
case PLUS:
case MINUS:
case MULT:
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
mark_loop_jump (XEXP (x, 0), loop);
mark_loop_jump (XEXP (x, 1), loop);
1992-02-01 09:24:22 +01:00
return;
case LO_SUM:
/* This may refer to a LABEL_REF or SYMBOL_REF. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
mark_loop_jump (XEXP (x, 1), loop);
return;
1992-02-01 09:24:22 +01:00
case SIGN_EXTEND:
case ZERO_EXTEND:
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
mark_loop_jump (XEXP (x, 0), loop);
1992-02-01 09:24:22 +01:00
return;
case LABEL_REF:
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
dest_loop = uid_loop[INSN_UID (XEXP (x, 0))];
1992-02-01 09:24:22 +01:00
/* Link together all labels that branch outside the loop. This
is used by final_[bg]iv_value and the loop unrolling code. Also
mark this LABEL_REF so we know that this branch should predict
false. */
/* A check to make sure the label is not in an inner nested loop,
since this does not count as a loop exit. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (dest_loop)
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (outer_loop = dest_loop; outer_loop;
outer_loop = outer_loop->outer)
if (outer_loop == loop)
break;
}
else
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
outer_loop = NULL;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (loop && ! outer_loop)
1992-02-01 09:24:22 +01:00
{
LABEL_OUTSIDE_LOOP_P (x) = 1;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
LABEL_NEXTREF (x) = loop->exit_labels;
loop->exit_labels = x;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (outer_loop = loop;
outer_loop && outer_loop != dest_loop;
outer_loop = outer_loop->outer)
outer_loop->exit_count++;
1992-02-01 09:24:22 +01:00
}
/* If this is inside a loop, but not in the current loop or one enclosed
by it, it invalidates at least one loop. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (! dest_loop)
1992-02-01 09:24:22 +01:00
return;
/* We must invalidate every nested loop containing the target of this
label, except those that also contain the jump insn. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (; dest_loop; dest_loop = dest_loop->outer)
1992-02-01 09:24:22 +01:00
{
/* Stop when we reach a loop that also contains the jump insn. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (outer_loop = loop; outer_loop; outer_loop = outer_loop->outer)
1992-02-01 09:24:22 +01:00
if (dest_loop == outer_loop)
return;
/* If we get here, we know we need to invalidate a loop. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (loop_dump_stream && ! dest_loop->invalid)
1992-02-01 09:24:22 +01:00
fprintf (loop_dump_stream,
"\nLoop at %d ignored due to multiple entry points.\n",
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
INSN_UID (dest_loop->start));
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
dest_loop->invalid = 1;
1992-02-01 09:24:22 +01:00
}
return;
case SET:
/* If this is not setting pc, ignore. */
if (SET_DEST (x) == pc_rtx)
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
mark_loop_jump (SET_SRC (x), loop);
1992-02-01 09:24:22 +01:00
return;
case IF_THEN_ELSE:
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
mark_loop_jump (XEXP (x, 1), loop);
mark_loop_jump (XEXP (x, 2), loop);
1992-02-01 09:24:22 +01:00
return;
case PARALLEL:
case ADDR_VEC:
for (i = 0; i < XVECLEN (x, 0); i++)
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
mark_loop_jump (XVECEXP (x, 0, i), loop);
1992-02-01 09:24:22 +01:00
return;
case ADDR_DIFF_VEC:
for (i = 0; i < XVECLEN (x, 1); i++)
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
mark_loop_jump (XVECEXP (x, 1, i), loop);
1992-02-01 09:24:22 +01:00
return;
default:
/* Strictly speaking this is not a jump into the loop, only a possible
jump out of the loop. However, we have no way to link the destination
of this jump onto the list of exit labels. To be safe we mark this
loop and any containing loops as invalid. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (loop)
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (outer_loop = loop; outer_loop; outer_loop = outer_loop->outer)
{
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (loop_dump_stream && ! outer_loop->invalid)
fprintf (loop_dump_stream,
"\nLoop at %d ignored due to unknown exit jump.\n",
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
INSN_UID (outer_loop->start));
outer_loop->invalid = 1;
}
}
return;
1992-02-01 09:24:22 +01:00
}
}
/* Return nonzero if there is a label in the range from
insn INSN to and including the insn whose luid is END
INSN must have an assigned luid (i.e., it must not have
been previously created by loop.c). */
static int
labels_in_range_p (insn, end)
rtx insn;
int end;
{
while (insn && INSN_LUID (insn) <= end)
{
if (GET_CODE (insn) == CODE_LABEL)
return 1;
insn = NEXT_INSN (insn);
}
return 0;
}
/* Record that a memory reference X is being set. */
static void
rtl.h (note_stores): Add additional paramter. * rtl.h (note_stores): Add additional paramter. * rtlanal.c (reg_set_p_1): Take additional paramter. (reg_set_last_1): Likewise. (reg_set_p): Adjust call to note_stores. (reg_set_last): Likewise. (note_stores): Pass data parameter to worker function. * alias.c (record_set): Take additional parameter. (init_alias_analysis): Pass it. * caller-save.c (mark_set_regs): Take additional parameter. (save_call_clobbered_regs): Pass NULL to note_stores. * combine.c (set_nonzero_bits_and_sign_copies): Take additional parameter. (record_dead_and_set_regs_1): Likewise. (reg_dead_at_p_1): Likewise. (combine_instructions): Adjust calls to note_stores. (try_combine): Likewise. (record_dead_insn): Remove. (record_dead_and_set_regs): Adjust calls to note_stores. (reg_dead_at_p): Likewise. * cse.c (invalidate_skipped_set): Take additional parameter. (cse_check_loop_start): Likewise. (cse_check_loop_start_value): Remove. (cse_set_around_loop): Adjust calls to note_stores. * flow.c (notice_stack_pointer_modification): Take additional parameter. Remove duplicate declaration. (record_volatile_insns): Adjust calls to note_stores. * gcse.c (record_set_info): Take additional parameter. (record_last_set_info): Likewise. (invalidate_nonnull_info): Likewise. (record_set_insn): Remove. (compute_sets): Adjust calls to note_stores. (last_set_insn): Remove. (compute_hash_table): Adjust calls to note_stores. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks): Likewise. * global.c (mark_reg_store): Take additional parameter. (mark_reg_clobber): Likewise. (reg_becomes_live): Likewise. (global_conflicts): Adjust calls to note_stores. (build_insn_chain): Likewise. * integrate.c (note_modified_parmregs): Take additional parameter. (mark_stores): Likewise. Make it static. (save_for_inline_nocopy): Adjust calls to note_stores. (try_constants): Likewise. * integrate.h (mark_stores): Remove declaration. * jump.c (mark_modified_reg): Take additional parameter. (thread_jumps): Adjust calls to note_stores. * local-alloc.c (validate_equiv_mem_from_store): Take additional parameter. (no_equiv): Likewise. (reg_is_set): Likewise. (validate_equiv_mem): Adjust calls to note_stores. (update_equiv_regs): Likewise. (block_alloc): Likewise. * loop.c (note_set_pseudo_multiple_uses_retval): Remove. (note_addr_stored): Take additional parameter. (note_set_pseudo_multiple_uses): Likewise. (record_initial): Likewise. (prescan_loop): Adjust calls to note_stores. (strength_reduce): Likewise. (check_dbra_loop): Likewise. * regmove.c (flags_set_1): Take additional paramter. (mark_flags_life_zones): Adjust calls to note_stores. * reload1.c (mark_not_eliminable): Take additional parameter. (forget_old_reloads_1): Likewise. (reload_cse_invalidate_rtx): Likewise. (reload_cse_check_clobber): Likewise. (reload_combine_note_store): Likewise. (move2add_note_store): Likewise. (reload): Adjust calls to note_stores. (reload_as_needed): Likewise. (emit_reload_insns): Likewise. (reload_cse_regs_1): Likewise. (reload_cse_record_set): Adjust calls to reload_cse_invalidate_rtx. (reload_combine): Adjust calls to note_stores. * resource.c (update_live_status): Take additional paramter. (mark_target_live_regs): Adjust calls to note_stores. * stupid.c (find_clobbered_regs): Take additional parameter. (stupid_life_analysis): Adjust calls to note_stores. From-SVN: r30221
1999-10-27 21:27:41 +02:00
note_addr_stored (x, y, data)
1992-02-01 09:24:22 +01:00
rtx x;
rtx y ATTRIBUTE_UNUSED;
rtl.h (note_stores): Add additional paramter. * rtl.h (note_stores): Add additional paramter. * rtlanal.c (reg_set_p_1): Take additional paramter. (reg_set_last_1): Likewise. (reg_set_p): Adjust call to note_stores. (reg_set_last): Likewise. (note_stores): Pass data parameter to worker function. * alias.c (record_set): Take additional parameter. (init_alias_analysis): Pass it. * caller-save.c (mark_set_regs): Take additional parameter. (save_call_clobbered_regs): Pass NULL to note_stores. * combine.c (set_nonzero_bits_and_sign_copies): Take additional parameter. (record_dead_and_set_regs_1): Likewise. (reg_dead_at_p_1): Likewise. (combine_instructions): Adjust calls to note_stores. (try_combine): Likewise. (record_dead_insn): Remove. (record_dead_and_set_regs): Adjust calls to note_stores. (reg_dead_at_p): Likewise. * cse.c (invalidate_skipped_set): Take additional parameter. (cse_check_loop_start): Likewise. (cse_check_loop_start_value): Remove. (cse_set_around_loop): Adjust calls to note_stores. * flow.c (notice_stack_pointer_modification): Take additional parameter. Remove duplicate declaration. (record_volatile_insns): Adjust calls to note_stores. * gcse.c (record_set_info): Take additional parameter. (record_last_set_info): Likewise. (invalidate_nonnull_info): Likewise. (record_set_insn): Remove. (compute_sets): Adjust calls to note_stores. (last_set_insn): Remove. (compute_hash_table): Adjust calls to note_stores. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks): Likewise. * global.c (mark_reg_store): Take additional parameter. (mark_reg_clobber): Likewise. (reg_becomes_live): Likewise. (global_conflicts): Adjust calls to note_stores. (build_insn_chain): Likewise. * integrate.c (note_modified_parmregs): Take additional parameter. (mark_stores): Likewise. Make it static. (save_for_inline_nocopy): Adjust calls to note_stores. (try_constants): Likewise. * integrate.h (mark_stores): Remove declaration. * jump.c (mark_modified_reg): Take additional parameter. (thread_jumps): Adjust calls to note_stores. * local-alloc.c (validate_equiv_mem_from_store): Take additional parameter. (no_equiv): Likewise. (reg_is_set): Likewise. (validate_equiv_mem): Adjust calls to note_stores. (update_equiv_regs): Likewise. (block_alloc): Likewise. * loop.c (note_set_pseudo_multiple_uses_retval): Remove. (note_addr_stored): Take additional parameter. (note_set_pseudo_multiple_uses): Likewise. (record_initial): Likewise. (prescan_loop): Adjust calls to note_stores. (strength_reduce): Likewise. (check_dbra_loop): Likewise. * regmove.c (flags_set_1): Take additional paramter. (mark_flags_life_zones): Adjust calls to note_stores. * reload1.c (mark_not_eliminable): Take additional parameter. (forget_old_reloads_1): Likewise. (reload_cse_invalidate_rtx): Likewise. (reload_cse_check_clobber): Likewise. (reload_combine_note_store): Likewise. (move2add_note_store): Likewise. (reload): Adjust calls to note_stores. (reload_as_needed): Likewise. (emit_reload_insns): Likewise. (reload_cse_regs_1): Likewise. (reload_cse_record_set): Adjust calls to reload_cse_invalidate_rtx. (reload_combine): Adjust calls to note_stores. * resource.c (update_live_status): Take additional paramter. (mark_target_live_regs): Adjust calls to note_stores. * stupid.c (find_clobbered_regs): Take additional parameter. (stupid_life_analysis): Adjust calls to note_stores. From-SVN: r30221
1999-10-27 21:27:41 +02:00
void *data ATTRIBUTE_UNUSED;
1992-02-01 09:24:22 +01:00
{
struct loop_info *loop_info = data;
1992-02-01 09:24:22 +01:00
if (x == 0 || GET_CODE (x) != MEM)
return;
/* Count number of memory writes.
This affects heuristics in strength_reduce. */
loop_info->num_mem_sets++;
/* BLKmode MEM means all memory is clobbered. */
if (GET_MODE (x) == BLKmode)
[multiple changes] Fri Oct 29 15:25:07 1999 Arnaud Charlet <charlet@ACT-Europe.FR> * gcov.c (DIR_SEPARATOR): Provide default. (output_data): Add test for MS-DOS format absolute filename. (fancy_abort): Correct program name. (open_files): Open all files in binary mode. * libgcc2.c (__bb_exit_func): Likewise. * profile.c (init_branch_prob): Specify binary when opening files. * flags.h (flag_unwind_tables): New decl. * toplev.c (flag_unwind_table): New definition. (f_options): Add -funwind-tables. (decode_g_option): Clarify warning when unknown -g option is given. (rest_of_compilation): If inside an inlined external function, pretend we are just being declared. * dwarf2out.c (dwarf2out_do_frame): Check -funwind_tables. (dwarf2out_frame_finish): Likewise. Fri Oct 29 06:32:44 1999 Geoffrey Keating <geoffk@cygnus.com> * flow.c (propagate_block): When the last reference to a label before an ADDR_VEC is deleted because the reference is a dead store, delete the ADDR_VEC. Fri Oct 29 07:44:26 1999 Vasco Pedro <vp@di.fct.unl.pt> * fold-const.c (merge_ranges): In not in0, but in1, handle upper bounds equal like subset case. Thu Oct 28 19:22:24 1999 Douglas Rupp <rupp@gnat.com> * dbxout.c (dbxout_parms): Generate a second stabs line for parameters passed in a register but moved to the stack. Thu Oct 28 19:12:57 1999 Sam Tardieu <tardieu@act-europe.fr> * gcc.c (pass_exit_codes, greatest_status): New variables. (struct option_map): Add entry for "--pass-exit-codes". (execute): Update greatest_status if error. (display_help): Add documentation for -pass-exit-codes. (process_command): Handle -pass-exit-codes. (main): Look at pass_exit_codes and greatest_status on call to exit. Thu Oct 28 18:06:50 1999 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> * reload.c (find_reloads): Refine test for no input reload case to not includes reloads emitted after insn. * function.c (find_temp_slots_from_address): Handle sum involving a register that points to a temp slot. (update_temp_slot_address): Make recursive call if both old and new are PLUS with a common operand. * calls.c (expand_call): Mark temp slot for result as having address taken. * rtlanal.c (reg_referenced_p, case IF_THEN_ELSE): New case. * gcc.c (process_command): Add standard_exec_prefix with "GCC" component as well as "BINUTILS". * integrate.h (copy_rtx_and_substitute): New arg, FOR_LHS. * integrate.c (copy_rtx_and_substitute): Likewise. (expand_inline_function, integrate_parm_decls, integrate_decl_tree): All callers changed. * unroll.c (inital_reg_note_copy, copy_loop_body): Likewise. * dbxout.c (dbxout_type, case INTEGER_TYPE_NODE): If can use gdb extensions, write size of type; also be more consistent in using references when this is a subtype. * pa.md (extv, extzv, insv): Use define_expand to reject constant that is out of range. * loop.c (unknown_constant_address_altered): New variable. (prescan_loop): Initialize it. (note_addr_stored): Set it for RTX_UNCHANGING_P MEM. (invariant_p, case MEM): Remove handling for volatile and readony; check new variable if readonly. (check_dbra_loop): Chdeck unknown_constant_address_altered. * cse.c (canon_hash, case MEM): Do not record if BLKmode. (addr_affects_sp_p): Removed from note_mem_written and only define #ifdef AUTO_INC_DEC. * alpha.c (input_operand, case ADDRESSOF): Treat as REG. * regclass.c (record_reg_classes): Properly handle register move directions. * varasm.c (initializer_constant_valid_p, case MINUS_EXPR): Don't think valid if both operands are invalid. (struct constant_descriptor): New field RTL. (mark_const_hash_entry): Mark it. (record_constant{,_rtx}): Initialize it. (output_constant_def): Allocate RTL in permanent obstack and save in table. ({record,compare}_constant_1): Modes must match for CONSTRUCTOR of ARRAY_TYPE. * c-common.h (initializer_constant_valid_p): Delete decl from here. * output.h (initializer_constant_valid_p): Move decl to here. * c-common.c (initializer_constant_valid_p): Delete function from here. * varasm.c (initializer_constant_valid_p): Move function to here. * tree.h (STRIP_SIGN_NOPS): New macro. * fold-const.c (optimize_minmax_comparison): New function. (invert_truthvalue, case WITH_RECORD_EXPR): New case. (fold): Use STRIP_SIGN_NOPS instead of STRIP_TYPE_NOPS. (fold, case EQ_EXPR): Call optimize_minmax_comparison and add cases with ABS_EXPR, NEGATE_EXPR, PLUS_EXPR, MINUS_EXPR, and widening conversions. (fold, case LE_EXPR): Rework changing unsigned to signed comparisons to look at size of mode, not precision of type; also add missing cases. (optimize_bit_field_compare, decode_field_reference): Don't try to optimize COMPONENT_REF of a PLACEHOLDER_EXPR. * dwarf2out.c (ctype.h): Include. (dwarf2out_set_demangle_name_func): New function. (size_of_line_info): Deleted. (output_line_info): Compute size of line info table from difference of labels. (base_type_die, add_name_attribute): Call demangle function, if any. (field_byte_offset): Use bits per word for variable length fields. (gen_array_type_die): Add array name. (gen_subprogram_die): Ignore DECL_INLINE if -fno-inline. (dwarf2out_add_library_unit_info): New function. * explow.c (set_stack_check_libfunc): New function. (stack_check_libfunc): New static variable. (probe_stack_range): Allow front-end to set up a libfunc to call. * combine.c (simplify_comparison): When making comparison in wider mode, check for having commuted an AND and a SUBREG. (contains_muldiv): New function. (try_combine): Call it when dividing a PARALLEL. (simplify_rtx, case TRUNCATE): Don't remove for umulsi3_highpart. (simplify_comparison, case ASHIFTRT): Recognize sign-extension of a PLUS. (record_value_for_reg): If TEM is a binary operation with two CLOBBERs, use one of the CLOBBERs instead. (if_then_else_cond): If comparing against zero, just return thing being compared. * optabs.c (expand_abs): If machine has MAX, ABS (x) is MAX (x, -x). Don't generate shifts and subtract if have conditional arithmetic. * rtl.h (delete_barrier): New declaration. * jump.c (jump_optimize): Set up to handle conditional call. In conditional arithmetic case, handle CALL_INSN followed by a BARRIER. (delete_barrier): New function. * rtl.c (read_rtx): Call fatal if bad RTL code; check for bad mode. * recog.c (nonmemory_operand): Accept ADDRESSOF. * tree.c (build_type_attribute_variant): Push to obstack of ttype around type_hash_canon call. * expr.c (placeholder_list): Move decl to file scope. (expand_expr): Don't force access to volatile just because its address is taken. If ignoring reference operations, just expand the operands. (expand_expr, case COMPONENT_REF): Propagate EXPAND_CONST_ADDRESS to recursive call when expanding inner. Refine test for using bitfield operations vs pointer punning. (expand_expr, case CONVERT_EXPR): If converting to BLKmode UNION_TYPE from BLKmode, just return inner object. Use proper mode in store_field call. Properly set sizes of object to store and total size in store_field call for convert to union. (expand_expr, case ARRAY_REF): If OP0 is in a register, put it in memory (like for ADDR_EXPR). Also, don't put constant in register if we'll want it in memory. (readonly_fields_p): New function. (expand_expr, case INDIRECT_REF): Call it if LHS. (expand_assignment): Handle a RESULT_DECL where DECL_RTL is a PARALLEL. (do_jump, case WITH_RECORD_EXPR): New case. (get_inner_reference): Always go inside a CONVERT_EXPR and NOP_EXPR if both modes are the same. (store_field): Use bitfield operations if size of bitsize is not same as size of RHS's type. Check for bitpos not a multiple of alignment in BLKmode case. Do block move in largest possible alignment. (store_constructor): Set BITSIZE to -1 for variable size and properly in case of array of BLKmode. (expand_expr_unaligned): New function. (do_compare_and_jump): Call it. * mips/iris5.h (SWITCHES_NEED_SPACES): New macro. * collect2.c (main): Only allow -ofoo if SWITCHES_NEED_SPACES does not include 'o'. * function.c (instantiate_virtual_regs_1, case SET): Handle case where both SET_DEST and SET_SRC reference a virtual register. (gen_mem_addressof): Copy RTX_UNCHANGING_P from new REG to old REG. * integrate.c (expand_inline_function): Handle case of setting virtual stack vars register (from built in setjmp); when parameter lives in memory, expand virtual_{stack_vars,incoming_args}_rtx early. (subst_constant): Add new parm, MEMONLY. (expand_inline_function, integrate_parm_decls): Pass new parm. (integrate_decl_tree): Likewise. (copy_rtx_and_substitute, case MEM): Do copy RTX_UNCHANGING_P. (try_constants): Call subst_constants twice, with MEMONLY 0 and 1. (copy_rtx_and_substitute, case SET): Add explicit calls to copy_rtx_and_substitute for both sides. * stmt.c (expand_asm_operands): Don't use TREE_STRING_LENGTH for constraints. (pushcase{,_range}): Convert to NOMINAL_TYPE after checking for within INDEX_TYPE, instead of before. (fixup_gotos): Use f->target_rtl, not the next insn, since latter may be from a later fixup. (expand_value_return): Correctly convert VAL when promoting function return; support RETURN_REG being a PARALLEL. (expand_return): When checking for result in regs and having cleanup, consider PARALLEL in DECL_RTL as being in regs. From-SVN: r30299
1999-11-01 02:11:22 +01:00
{
if (RTX_UNCHANGING_P (x))
loop_info->unknown_constant_address_altered = 1;
[multiple changes] Fri Oct 29 15:25:07 1999 Arnaud Charlet <charlet@ACT-Europe.FR> * gcov.c (DIR_SEPARATOR): Provide default. (output_data): Add test for MS-DOS format absolute filename. (fancy_abort): Correct program name. (open_files): Open all files in binary mode. * libgcc2.c (__bb_exit_func): Likewise. * profile.c (init_branch_prob): Specify binary when opening files. * flags.h (flag_unwind_tables): New decl. * toplev.c (flag_unwind_table): New definition. (f_options): Add -funwind-tables. (decode_g_option): Clarify warning when unknown -g option is given. (rest_of_compilation): If inside an inlined external function, pretend we are just being declared. * dwarf2out.c (dwarf2out_do_frame): Check -funwind_tables. (dwarf2out_frame_finish): Likewise. Fri Oct 29 06:32:44 1999 Geoffrey Keating <geoffk@cygnus.com> * flow.c (propagate_block): When the last reference to a label before an ADDR_VEC is deleted because the reference is a dead store, delete the ADDR_VEC. Fri Oct 29 07:44:26 1999 Vasco Pedro <vp@di.fct.unl.pt> * fold-const.c (merge_ranges): In not in0, but in1, handle upper bounds equal like subset case. Thu Oct 28 19:22:24 1999 Douglas Rupp <rupp@gnat.com> * dbxout.c (dbxout_parms): Generate a second stabs line for parameters passed in a register but moved to the stack. Thu Oct 28 19:12:57 1999 Sam Tardieu <tardieu@act-europe.fr> * gcc.c (pass_exit_codes, greatest_status): New variables. (struct option_map): Add entry for "--pass-exit-codes". (execute): Update greatest_status if error. (display_help): Add documentation for -pass-exit-codes. (process_command): Handle -pass-exit-codes. (main): Look at pass_exit_codes and greatest_status on call to exit. Thu Oct 28 18:06:50 1999 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> * reload.c (find_reloads): Refine test for no input reload case to not includes reloads emitted after insn. * function.c (find_temp_slots_from_address): Handle sum involving a register that points to a temp slot. (update_temp_slot_address): Make recursive call if both old and new are PLUS with a common operand. * calls.c (expand_call): Mark temp slot for result as having address taken. * rtlanal.c (reg_referenced_p, case IF_THEN_ELSE): New case. * gcc.c (process_command): Add standard_exec_prefix with "GCC" component as well as "BINUTILS". * integrate.h (copy_rtx_and_substitute): New arg, FOR_LHS. * integrate.c (copy_rtx_and_substitute): Likewise. (expand_inline_function, integrate_parm_decls, integrate_decl_tree): All callers changed. * unroll.c (inital_reg_note_copy, copy_loop_body): Likewise. * dbxout.c (dbxout_type, case INTEGER_TYPE_NODE): If can use gdb extensions, write size of type; also be more consistent in using references when this is a subtype. * pa.md (extv, extzv, insv): Use define_expand to reject constant that is out of range. * loop.c (unknown_constant_address_altered): New variable. (prescan_loop): Initialize it. (note_addr_stored): Set it for RTX_UNCHANGING_P MEM. (invariant_p, case MEM): Remove handling for volatile and readony; check new variable if readonly. (check_dbra_loop): Chdeck unknown_constant_address_altered. * cse.c (canon_hash, case MEM): Do not record if BLKmode. (addr_affects_sp_p): Removed from note_mem_written and only define #ifdef AUTO_INC_DEC. * alpha.c (input_operand, case ADDRESSOF): Treat as REG. * regclass.c (record_reg_classes): Properly handle register move directions. * varasm.c (initializer_constant_valid_p, case MINUS_EXPR): Don't think valid if both operands are invalid. (struct constant_descriptor): New field RTL. (mark_const_hash_entry): Mark it. (record_constant{,_rtx}): Initialize it. (output_constant_def): Allocate RTL in permanent obstack and save in table. ({record,compare}_constant_1): Modes must match for CONSTRUCTOR of ARRAY_TYPE. * c-common.h (initializer_constant_valid_p): Delete decl from here. * output.h (initializer_constant_valid_p): Move decl to here. * c-common.c (initializer_constant_valid_p): Delete function from here. * varasm.c (initializer_constant_valid_p): Move function to here. * tree.h (STRIP_SIGN_NOPS): New macro. * fold-const.c (optimize_minmax_comparison): New function. (invert_truthvalue, case WITH_RECORD_EXPR): New case. (fold): Use STRIP_SIGN_NOPS instead of STRIP_TYPE_NOPS. (fold, case EQ_EXPR): Call optimize_minmax_comparison and add cases with ABS_EXPR, NEGATE_EXPR, PLUS_EXPR, MINUS_EXPR, and widening conversions. (fold, case LE_EXPR): Rework changing unsigned to signed comparisons to look at size of mode, not precision of type; also add missing cases. (optimize_bit_field_compare, decode_field_reference): Don't try to optimize COMPONENT_REF of a PLACEHOLDER_EXPR. * dwarf2out.c (ctype.h): Include. (dwarf2out_set_demangle_name_func): New function. (size_of_line_info): Deleted. (output_line_info): Compute size of line info table from difference of labels. (base_type_die, add_name_attribute): Call demangle function, if any. (field_byte_offset): Use bits per word for variable length fields. (gen_array_type_die): Add array name. (gen_subprogram_die): Ignore DECL_INLINE if -fno-inline. (dwarf2out_add_library_unit_info): New function. * explow.c (set_stack_check_libfunc): New function. (stack_check_libfunc): New static variable. (probe_stack_range): Allow front-end to set up a libfunc to call. * combine.c (simplify_comparison): When making comparison in wider mode, check for having commuted an AND and a SUBREG. (contains_muldiv): New function. (try_combine): Call it when dividing a PARALLEL. (simplify_rtx, case TRUNCATE): Don't remove for umulsi3_highpart. (simplify_comparison, case ASHIFTRT): Recognize sign-extension of a PLUS. (record_value_for_reg): If TEM is a binary operation with two CLOBBERs, use one of the CLOBBERs instead. (if_then_else_cond): If comparing against zero, just return thing being compared. * optabs.c (expand_abs): If machine has MAX, ABS (x) is MAX (x, -x). Don't generate shifts and subtract if have conditional arithmetic. * rtl.h (delete_barrier): New declaration. * jump.c (jump_optimize): Set up to handle conditional call. In conditional arithmetic case, handle CALL_INSN followed by a BARRIER. (delete_barrier): New function. * rtl.c (read_rtx): Call fatal if bad RTL code; check for bad mode. * recog.c (nonmemory_operand): Accept ADDRESSOF. * tree.c (build_type_attribute_variant): Push to obstack of ttype around type_hash_canon call. * expr.c (placeholder_list): Move decl to file scope. (expand_expr): Don't force access to volatile just because its address is taken. If ignoring reference operations, just expand the operands. (expand_expr, case COMPONENT_REF): Propagate EXPAND_CONST_ADDRESS to recursive call when expanding inner. Refine test for using bitfield operations vs pointer punning. (expand_expr, case CONVERT_EXPR): If converting to BLKmode UNION_TYPE from BLKmode, just return inner object. Use proper mode in store_field call. Properly set sizes of object to store and total size in store_field call for convert to union. (expand_expr, case ARRAY_REF): If OP0 is in a register, put it in memory (like for ADDR_EXPR). Also, don't put constant in register if we'll want it in memory. (readonly_fields_p): New function. (expand_expr, case INDIRECT_REF): Call it if LHS. (expand_assignment): Handle a RESULT_DECL where DECL_RTL is a PARALLEL. (do_jump, case WITH_RECORD_EXPR): New case. (get_inner_reference): Always go inside a CONVERT_EXPR and NOP_EXPR if both modes are the same. (store_field): Use bitfield operations if size of bitsize is not same as size of RHS's type. Check for bitpos not a multiple of alignment in BLKmode case. Do block move in largest possible alignment. (store_constructor): Set BITSIZE to -1 for variable size and properly in case of array of BLKmode. (expand_expr_unaligned): New function. (do_compare_and_jump): Call it. * mips/iris5.h (SWITCHES_NEED_SPACES): New macro. * collect2.c (main): Only allow -ofoo if SWITCHES_NEED_SPACES does not include 'o'. * function.c (instantiate_virtual_regs_1, case SET): Handle case where both SET_DEST and SET_SRC reference a virtual register. (gen_mem_addressof): Copy RTX_UNCHANGING_P from new REG to old REG. * integrate.c (expand_inline_function): Handle case of setting virtual stack vars register (from built in setjmp); when parameter lives in memory, expand virtual_{stack_vars,incoming_args}_rtx early. (subst_constant): Add new parm, MEMONLY. (expand_inline_function, integrate_parm_decls): Pass new parm. (integrate_decl_tree): Likewise. (copy_rtx_and_substitute, case MEM): Do copy RTX_UNCHANGING_P. (try_constants): Call subst_constants twice, with MEMONLY 0 and 1. (copy_rtx_and_substitute, case SET): Add explicit calls to copy_rtx_and_substitute for both sides. * stmt.c (expand_asm_operands): Don't use TREE_STRING_LENGTH for constraints. (pushcase{,_range}): Convert to NOMINAL_TYPE after checking for within INDEX_TYPE, instead of before. (fixup_gotos): Use f->target_rtl, not the next insn, since latter may be from a later fixup. (expand_value_return): Correctly convert VAL when promoting function return; support RETURN_REG being a PARALLEL. (expand_return): When checking for result in regs and having cleanup, consider PARALLEL in DECL_RTL as being in regs. From-SVN: r30299
1999-11-01 02:11:22 +01:00
else
loop_info->unknown_address_altered = 1;
[multiple changes] Fri Oct 29 15:25:07 1999 Arnaud Charlet <charlet@ACT-Europe.FR> * gcov.c (DIR_SEPARATOR): Provide default. (output_data): Add test for MS-DOS format absolute filename. (fancy_abort): Correct program name. (open_files): Open all files in binary mode. * libgcc2.c (__bb_exit_func): Likewise. * profile.c (init_branch_prob): Specify binary when opening files. * flags.h (flag_unwind_tables): New decl. * toplev.c (flag_unwind_table): New definition. (f_options): Add -funwind-tables. (decode_g_option): Clarify warning when unknown -g option is given. (rest_of_compilation): If inside an inlined external function, pretend we are just being declared. * dwarf2out.c (dwarf2out_do_frame): Check -funwind_tables. (dwarf2out_frame_finish): Likewise. Fri Oct 29 06:32:44 1999 Geoffrey Keating <geoffk@cygnus.com> * flow.c (propagate_block): When the last reference to a label before an ADDR_VEC is deleted because the reference is a dead store, delete the ADDR_VEC. Fri Oct 29 07:44:26 1999 Vasco Pedro <vp@di.fct.unl.pt> * fold-const.c (merge_ranges): In not in0, but in1, handle upper bounds equal like subset case. Thu Oct 28 19:22:24 1999 Douglas Rupp <rupp@gnat.com> * dbxout.c (dbxout_parms): Generate a second stabs line for parameters passed in a register but moved to the stack. Thu Oct 28 19:12:57 1999 Sam Tardieu <tardieu@act-europe.fr> * gcc.c (pass_exit_codes, greatest_status): New variables. (struct option_map): Add entry for "--pass-exit-codes". (execute): Update greatest_status if error. (display_help): Add documentation for -pass-exit-codes. (process_command): Handle -pass-exit-codes. (main): Look at pass_exit_codes and greatest_status on call to exit. Thu Oct 28 18:06:50 1999 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> * reload.c (find_reloads): Refine test for no input reload case to not includes reloads emitted after insn. * function.c (find_temp_slots_from_address): Handle sum involving a register that points to a temp slot. (update_temp_slot_address): Make recursive call if both old and new are PLUS with a common operand. * calls.c (expand_call): Mark temp slot for result as having address taken. * rtlanal.c (reg_referenced_p, case IF_THEN_ELSE): New case. * gcc.c (process_command): Add standard_exec_prefix with "GCC" component as well as "BINUTILS". * integrate.h (copy_rtx_and_substitute): New arg, FOR_LHS. * integrate.c (copy_rtx_and_substitute): Likewise. (expand_inline_function, integrate_parm_decls, integrate_decl_tree): All callers changed. * unroll.c (inital_reg_note_copy, copy_loop_body): Likewise. * dbxout.c (dbxout_type, case INTEGER_TYPE_NODE): If can use gdb extensions, write size of type; also be more consistent in using references when this is a subtype. * pa.md (extv, extzv, insv): Use define_expand to reject constant that is out of range. * loop.c (unknown_constant_address_altered): New variable. (prescan_loop): Initialize it. (note_addr_stored): Set it for RTX_UNCHANGING_P MEM. (invariant_p, case MEM): Remove handling for volatile and readony; check new variable if readonly. (check_dbra_loop): Chdeck unknown_constant_address_altered. * cse.c (canon_hash, case MEM): Do not record if BLKmode. (addr_affects_sp_p): Removed from note_mem_written and only define #ifdef AUTO_INC_DEC. * alpha.c (input_operand, case ADDRESSOF): Treat as REG. * regclass.c (record_reg_classes): Properly handle register move directions. * varasm.c (initializer_constant_valid_p, case MINUS_EXPR): Don't think valid if both operands are invalid. (struct constant_descriptor): New field RTL. (mark_const_hash_entry): Mark it. (record_constant{,_rtx}): Initialize it. (output_constant_def): Allocate RTL in permanent obstack and save in table. ({record,compare}_constant_1): Modes must match for CONSTRUCTOR of ARRAY_TYPE. * c-common.h (initializer_constant_valid_p): Delete decl from here. * output.h (initializer_constant_valid_p): Move decl to here. * c-common.c (initializer_constant_valid_p): Delete function from here. * varasm.c (initializer_constant_valid_p): Move function to here. * tree.h (STRIP_SIGN_NOPS): New macro. * fold-const.c (optimize_minmax_comparison): New function. (invert_truthvalue, case WITH_RECORD_EXPR): New case. (fold): Use STRIP_SIGN_NOPS instead of STRIP_TYPE_NOPS. (fold, case EQ_EXPR): Call optimize_minmax_comparison and add cases with ABS_EXPR, NEGATE_EXPR, PLUS_EXPR, MINUS_EXPR, and widening conversions. (fold, case LE_EXPR): Rework changing unsigned to signed comparisons to look at size of mode, not precision of type; also add missing cases. (optimize_bit_field_compare, decode_field_reference): Don't try to optimize COMPONENT_REF of a PLACEHOLDER_EXPR. * dwarf2out.c (ctype.h): Include. (dwarf2out_set_demangle_name_func): New function. (size_of_line_info): Deleted. (output_line_info): Compute size of line info table from difference of labels. (base_type_die, add_name_attribute): Call demangle function, if any. (field_byte_offset): Use bits per word for variable length fields. (gen_array_type_die): Add array name. (gen_subprogram_die): Ignore DECL_INLINE if -fno-inline. (dwarf2out_add_library_unit_info): New function. * explow.c (set_stack_check_libfunc): New function. (stack_check_libfunc): New static variable. (probe_stack_range): Allow front-end to set up a libfunc to call. * combine.c (simplify_comparison): When making comparison in wider mode, check for having commuted an AND and a SUBREG. (contains_muldiv): New function. (try_combine): Call it when dividing a PARALLEL. (simplify_rtx, case TRUNCATE): Don't remove for umulsi3_highpart. (simplify_comparison, case ASHIFTRT): Recognize sign-extension of a PLUS. (record_value_for_reg): If TEM is a binary operation with two CLOBBERs, use one of the CLOBBERs instead. (if_then_else_cond): If comparing against zero, just return thing being compared. * optabs.c (expand_abs): If machine has MAX, ABS (x) is MAX (x, -x). Don't generate shifts and subtract if have conditional arithmetic. * rtl.h (delete_barrier): New declaration. * jump.c (jump_optimize): Set up to handle conditional call. In conditional arithmetic case, handle CALL_INSN followed by a BARRIER. (delete_barrier): New function. * rtl.c (read_rtx): Call fatal if bad RTL code; check for bad mode. * recog.c (nonmemory_operand): Accept ADDRESSOF. * tree.c (build_type_attribute_variant): Push to obstack of ttype around type_hash_canon call. * expr.c (placeholder_list): Move decl to file scope. (expand_expr): Don't force access to volatile just because its address is taken. If ignoring reference operations, just expand the operands. (expand_expr, case COMPONENT_REF): Propagate EXPAND_CONST_ADDRESS to recursive call when expanding inner. Refine test for using bitfield operations vs pointer punning. (expand_expr, case CONVERT_EXPR): If converting to BLKmode UNION_TYPE from BLKmode, just return inner object. Use proper mode in store_field call. Properly set sizes of object to store and total size in store_field call for convert to union. (expand_expr, case ARRAY_REF): If OP0 is in a register, put it in memory (like for ADDR_EXPR). Also, don't put constant in register if we'll want it in memory. (readonly_fields_p): New function. (expand_expr, case INDIRECT_REF): Call it if LHS. (expand_assignment): Handle a RESULT_DECL where DECL_RTL is a PARALLEL. (do_jump, case WITH_RECORD_EXPR): New case. (get_inner_reference): Always go inside a CONVERT_EXPR and NOP_EXPR if both modes are the same. (store_field): Use bitfield operations if size of bitsize is not same as size of RHS's type. Check for bitpos not a multiple of alignment in BLKmode case. Do block move in largest possible alignment. (store_constructor): Set BITSIZE to -1 for variable size and properly in case of array of BLKmode. (expand_expr_unaligned): New function. (do_compare_and_jump): Call it. * mips/iris5.h (SWITCHES_NEED_SPACES): New macro. * collect2.c (main): Only allow -ofoo if SWITCHES_NEED_SPACES does not include 'o'. * function.c (instantiate_virtual_regs_1, case SET): Handle case where both SET_DEST and SET_SRC reference a virtual register. (gen_mem_addressof): Copy RTX_UNCHANGING_P from new REG to old REG. * integrate.c (expand_inline_function): Handle case of setting virtual stack vars register (from built in setjmp); when parameter lives in memory, expand virtual_{stack_vars,incoming_args}_rtx early. (subst_constant): Add new parm, MEMONLY. (expand_inline_function, integrate_parm_decls): Pass new parm. (integrate_decl_tree): Likewise. (copy_rtx_and_substitute, case MEM): Do copy RTX_UNCHANGING_P. (try_constants): Call subst_constants twice, with MEMONLY 0 and 1. (copy_rtx_and_substitute, case SET): Add explicit calls to copy_rtx_and_substitute for both sides. * stmt.c (expand_asm_operands): Don't use TREE_STRING_LENGTH for constraints. (pushcase{,_range}): Convert to NOMINAL_TYPE after checking for within INDEX_TYPE, instead of before. (fixup_gotos): Use f->target_rtl, not the next insn, since latter may be from a later fixup. (expand_value_return): Correctly convert VAL when promoting function return; support RETURN_REG being a PARALLEL. (expand_return): When checking for result in regs and having cleanup, consider PARALLEL in DECL_RTL as being in regs. From-SVN: r30299
1999-11-01 02:11:22 +01:00
return;
}
loop_info->store_mems = gen_rtx_EXPR_LIST (VOIDmode, x,
loop_info->store_mems);
1992-02-01 09:24:22 +01:00
}
/* X is a value modified by an INSN that references a biv inside a loop
exit test (ie, X is somehow related to the value of the biv). If X
is a pseudo that is used more than once, then the biv is (effectively)
used more than once. DATA is a pointer to a loop_regs structure. */
static void
rtl.h (note_stores): Add additional paramter. * rtl.h (note_stores): Add additional paramter. * rtlanal.c (reg_set_p_1): Take additional paramter. (reg_set_last_1): Likewise. (reg_set_p): Adjust call to note_stores. (reg_set_last): Likewise. (note_stores): Pass data parameter to worker function. * alias.c (record_set): Take additional parameter. (init_alias_analysis): Pass it. * caller-save.c (mark_set_regs): Take additional parameter. (save_call_clobbered_regs): Pass NULL to note_stores. * combine.c (set_nonzero_bits_and_sign_copies): Take additional parameter. (record_dead_and_set_regs_1): Likewise. (reg_dead_at_p_1): Likewise. (combine_instructions): Adjust calls to note_stores. (try_combine): Likewise. (record_dead_insn): Remove. (record_dead_and_set_regs): Adjust calls to note_stores. (reg_dead_at_p): Likewise. * cse.c (invalidate_skipped_set): Take additional parameter. (cse_check_loop_start): Likewise. (cse_check_loop_start_value): Remove. (cse_set_around_loop): Adjust calls to note_stores. * flow.c (notice_stack_pointer_modification): Take additional parameter. Remove duplicate declaration. (record_volatile_insns): Adjust calls to note_stores. * gcse.c (record_set_info): Take additional parameter. (record_last_set_info): Likewise. (invalidate_nonnull_info): Likewise. (record_set_insn): Remove. (compute_sets): Adjust calls to note_stores. (last_set_insn): Remove. (compute_hash_table): Adjust calls to note_stores. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks): Likewise. * global.c (mark_reg_store): Take additional parameter. (mark_reg_clobber): Likewise. (reg_becomes_live): Likewise. (global_conflicts): Adjust calls to note_stores. (build_insn_chain): Likewise. * integrate.c (note_modified_parmregs): Take additional parameter. (mark_stores): Likewise. Make it static. (save_for_inline_nocopy): Adjust calls to note_stores. (try_constants): Likewise. * integrate.h (mark_stores): Remove declaration. * jump.c (mark_modified_reg): Take additional parameter. (thread_jumps): Adjust calls to note_stores. * local-alloc.c (validate_equiv_mem_from_store): Take additional parameter. (no_equiv): Likewise. (reg_is_set): Likewise. (validate_equiv_mem): Adjust calls to note_stores. (update_equiv_regs): Likewise. (block_alloc): Likewise. * loop.c (note_set_pseudo_multiple_uses_retval): Remove. (note_addr_stored): Take additional parameter. (note_set_pseudo_multiple_uses): Likewise. (record_initial): Likewise. (prescan_loop): Adjust calls to note_stores. (strength_reduce): Likewise. (check_dbra_loop): Likewise. * regmove.c (flags_set_1): Take additional paramter. (mark_flags_life_zones): Adjust calls to note_stores. * reload1.c (mark_not_eliminable): Take additional parameter. (forget_old_reloads_1): Likewise. (reload_cse_invalidate_rtx): Likewise. (reload_cse_check_clobber): Likewise. (reload_combine_note_store): Likewise. (move2add_note_store): Likewise. (reload): Adjust calls to note_stores. (reload_as_needed): Likewise. (emit_reload_insns): Likewise. (reload_cse_regs_1): Likewise. (reload_cse_record_set): Adjust calls to reload_cse_invalidate_rtx. (reload_combine): Adjust calls to note_stores. * resource.c (update_live_status): Take additional paramter. (mark_target_live_regs): Adjust calls to note_stores. * stupid.c (find_clobbered_regs): Take additional parameter. (stupid_life_analysis): Adjust calls to note_stores. From-SVN: r30221
1999-10-27 21:27:41 +02:00
note_set_pseudo_multiple_uses (x, y, data)
rtx x;
rtx y ATTRIBUTE_UNUSED;
rtl.h (note_stores): Add additional paramter. * rtl.h (note_stores): Add additional paramter. * rtlanal.c (reg_set_p_1): Take additional paramter. (reg_set_last_1): Likewise. (reg_set_p): Adjust call to note_stores. (reg_set_last): Likewise. (note_stores): Pass data parameter to worker function. * alias.c (record_set): Take additional parameter. (init_alias_analysis): Pass it. * caller-save.c (mark_set_regs): Take additional parameter. (save_call_clobbered_regs): Pass NULL to note_stores. * combine.c (set_nonzero_bits_and_sign_copies): Take additional parameter. (record_dead_and_set_regs_1): Likewise. (reg_dead_at_p_1): Likewise. (combine_instructions): Adjust calls to note_stores. (try_combine): Likewise. (record_dead_insn): Remove. (record_dead_and_set_regs): Adjust calls to note_stores. (reg_dead_at_p): Likewise. * cse.c (invalidate_skipped_set): Take additional parameter. (cse_check_loop_start): Likewise. (cse_check_loop_start_value): Remove. (cse_set_around_loop): Adjust calls to note_stores. * flow.c (notice_stack_pointer_modification): Take additional parameter. Remove duplicate declaration. (record_volatile_insns): Adjust calls to note_stores. * gcse.c (record_set_info): Take additional parameter. (record_last_set_info): Likewise. (invalidate_nonnull_info): Likewise. (record_set_insn): Remove. (compute_sets): Adjust calls to note_stores. (last_set_insn): Remove. (compute_hash_table): Adjust calls to note_stores. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks): Likewise. * global.c (mark_reg_store): Take additional parameter. (mark_reg_clobber): Likewise. (reg_becomes_live): Likewise. (global_conflicts): Adjust calls to note_stores. (build_insn_chain): Likewise. * integrate.c (note_modified_parmregs): Take additional parameter. (mark_stores): Likewise. Make it static. (save_for_inline_nocopy): Adjust calls to note_stores. (try_constants): Likewise. * integrate.h (mark_stores): Remove declaration. * jump.c (mark_modified_reg): Take additional parameter. (thread_jumps): Adjust calls to note_stores. * local-alloc.c (validate_equiv_mem_from_store): Take additional parameter. (no_equiv): Likewise. (reg_is_set): Likewise. (validate_equiv_mem): Adjust calls to note_stores. (update_equiv_regs): Likewise. (block_alloc): Likewise. * loop.c (note_set_pseudo_multiple_uses_retval): Remove. (note_addr_stored): Take additional parameter. (note_set_pseudo_multiple_uses): Likewise. (record_initial): Likewise. (prescan_loop): Adjust calls to note_stores. (strength_reduce): Likewise. (check_dbra_loop): Likewise. * regmove.c (flags_set_1): Take additional paramter. (mark_flags_life_zones): Adjust calls to note_stores. * reload1.c (mark_not_eliminable): Take additional parameter. (forget_old_reloads_1): Likewise. (reload_cse_invalidate_rtx): Likewise. (reload_cse_check_clobber): Likewise. (reload_combine_note_store): Likewise. (move2add_note_store): Likewise. (reload): Adjust calls to note_stores. (reload_as_needed): Likewise. (emit_reload_insns): Likewise. (reload_cse_regs_1): Likewise. (reload_cse_record_set): Adjust calls to reload_cse_invalidate_rtx. (reload_combine): Adjust calls to note_stores. * resource.c (update_live_status): Take additional paramter. (mark_target_live_regs): Adjust calls to note_stores. * stupid.c (find_clobbered_regs): Take additional parameter. (stupid_life_analysis): Adjust calls to note_stores. From-SVN: r30221
1999-10-27 21:27:41 +02:00
void *data;
{
struct loop_regs *regs = (struct loop_regs *) data;
if (x == 0)
return;
while (GET_CODE (x) == STRICT_LOW_PART
|| GET_CODE (x) == SIGN_EXTRACT
|| GET_CODE (x) == ZERO_EXTRACT
|| GET_CODE (x) == SUBREG)
x = XEXP (x, 0);
if (GET_CODE (x) != REG || REGNO (x) < FIRST_PSEUDO_REGISTER)
return;
/* If we do not have usage information, or if we know the register
is used more than once, note that fact for check_dbra_loop. */
if (REGNO (x) >= max_reg_before_loop
|| ! VARRAY_RTX (regs->single_usage, REGNO (x))
|| VARRAY_RTX (regs->single_usage, REGNO (x)) == const0_rtx)
regs->multiple_uses = 1;
}
1992-02-01 09:24:22 +01:00
/* Return nonzero if the rtx X is invariant over the current loop.
The value is 2 if we refer to something only conditionally invariant.
A memory ref is invariant if it is not volatile and does not conflict
with anything stored in `loop_info->store_mems'. */
1992-02-01 09:24:22 +01:00
int
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
loop_invariant_p (loop, x)
const struct loop *loop;
1992-02-01 09:24:22 +01:00
register rtx x;
{
struct loop_info *loop_info = LOOP_INFO (loop);
struct loop_regs *regs = LOOP_REGS (loop);
1992-02-01 09:24:22 +01:00
register int i;
register enum rtx_code code;
rtl.h (rtx_format): Constify a char*. * rtl.h (rtx_format): Constify a char*. * rtl.c (rtx_format): Likewise. (copy_rtx, copy_most_rtx, read_rtx): Likewise. (init_rtl): Use accessor macro, not `rtx_format'. * alias.c (rtx_equal_for_memref_p, find_symbolic_term): Constify a char*. * caller-save.c (mark_referenced_regs): Likewise. * combine.c (subst, make_compound_operation, known_cond, gen_rtx_combine, update_table_tick, get_last_value_validate, use_crosses_set_p, mark_used_regs_combine, move_deaths): Likewise. * cse.c (rtx_cost, mention_regs, canon_hash, exp_equiv_p, refers_to_p, canon_reg, fold_rtx, cse_process_notes, count_reg_usage): Likewise. * emit-rtl.c (gen_rtx, copy_rtx_if_shared, reset_used_flags): Likewise. * final.c (leaf_renumber_regs_insn): Likewise. * flow.c (mark_used_regs, find_use_as_address, dump_flow_info, dump_edge_info, count_reg_references): Likewise. * function.c (fixup_var_refs_1, walk_fixup_memory_subreg, fixup_stack_1, purge_addressof_1, instantiate_virtual_regs_1): Likewise. * gcse.c (oprs_unchanged_p, hash_expr_1, expr_equiv_p, oprs_not_set_p, expr_killed_p, compute_transp, find_used_regs, add_label_notes): Likewise. * genattrtab.c (attr_rtx, attr_copy_rtx, encode_units_mask, clear_struct_flag, count_sub_rtxs, count_alternatives, compares_alternatives_p, contained_in_p, walk_attr_value, write_expr_attr_cache): Likewise. * genconfig.c (walk_insn_part): Likewise. * genemit.c (max_operand_1, gen_exp): Likewise. * genextract.c (walk_rtx): Likewise. * genflags.c (num_operands): Likewise. * genoutput.c (scan_operands): Likewise. * genpeep.c (match_rtx): Likewise. * genrecog.c (add_to_sequence): Likewise. * haifa-sched.c (may_trap_exp, sched_analyze_2, attach_deaths): Likewise. * integrate.c (save_constants, copy_for_inline, copy_rtx_and_substitute, subst_constants, restore_constants): Likewise. * jump.c (mark_jump_label, invert_exp, redirect_exp, rtx_renumbered_equal_p, rtx_equal_for_thread_p): Likewise. * local-alloc.c (contains_replace_regs, memref_referenced_p): Likewise. * loop.c (record_excess_regs, rtx_equal_for_loop_p, add_label_notes, replace_call_address, count_nonfixed_reads, invariant_p, find_single_use_in_loop, find_mem_givs, find_life_end, maybe_eliminate_biv_1, update_reg_last_use): Likewise. * print-rtl.c (reg_names, print_rtx): Likewise. * recog.c (validate_replace_rtx_1, find_single_use_1): Likewise. * reg-stack.c (stack_regs_mentioned_p, record_label_references, record_reg_life_pat, swap_rtx_condition, goto_block_pat, print_blocks): Likewise. * regclass.c (fix_register, record_address_regs, reg_scan_mark_refs): Likewise. * regmove.c (stable_but_for_p): Likewise. * reload.c (loc_mentioned_in_p, operands_match_p, find_reloads_toplevsubst_reg_equivs, find_reloads_address_1, copy_replacements, refers_to_regno_for_reload_p, refers_to_mem_for_reload_p, find_inc_amount, regno_clobbered_p, reload_when_needed_name, reg_class_names, debug_reload_to_stream): Likewise. * reload1.c (eliminate_regs, scan_paradoxical_subregs, delete_address_reloads_1, count_occurrences, reload_cse_mem_conflict_p, reload_combine_note_use, add_auto_inc_notes): Likewise. * resource.c (mark_referenced_resources, mark_set_resources): Likewise. * rtlanal.c (rtx_unstable_p, rtx_varies_p, rtx_addr_varies_p, reg_mentioned_p, regs_set_between_p, modified_between_p, modified_in_p, refers_to_regno_p, reg_overlap_mentioned_p, rtx_equal_p, volatile_insn_p, volatile_refs_p, side_effects_p, may_trap_p, inequality_comparisons_p, replace_rtx, replace_regs, jmp_uses_reg_or_mem, for_each_rtx, regno_use_in): Likewise. * sched.c (sched_analyze_2, attach_deaths): Likewise. * stupid.c (stupid_mark_refs): Likewise. * unroll.c (remap_split_bivs): Likewise. * varasm.c (mark_constants): Likewise. * a29k/a29k.c (uses_local_reg_p): Likewise. * alpha/alpha.c (summarize_insn): Likewise. * arm/arm.c (symbol_mentioned_p, label_mentioned_p, eliminate_lr2ip): Likewise. * arm/thumb.c (symbol_mentioned_p, label_mentioned_p): Likewise. * i386/i386.c (symbolic_reference_mentioned_p, copy_all_rtx, reg_mentioned_in_mem): Likewise. * ns32k/ns32k.c (global_symbolic_reference_mentioned_p, symbolic_reference_mentioned_p): Likewise. * romp/romp.c (unsigned_comparisons_p, hash_rtx): Likewise. * sh/sh.c (regs_used, mark_use): Likewise. * vax/vax.c (vax_rtx_cost): Likewise. From-SVN: r28784
1999-08-21 01:05:25 +02:00
register const char *fmt;
1992-02-01 09:24:22 +01:00
int conditional = 0;
rtx mem_list_entry;
1992-02-01 09:24:22 +01:00
if (x == 0)
return 1;
code = GET_CODE (x);
switch (code)
{
case CONST_INT:
case CONST_DOUBLE:
case SYMBOL_REF:
case CONST:
return 1;
case LABEL_REF:
/* A LABEL_REF is normally invariant, however, if we are unrolling
loops, and this label is inside the loop, then it isn't invariant.
This is because each unrolled copy of the loop body will have
a copy of this label. If this was invariant, then an insn loading
the address of this label into a register might get moved outside
the loop, and then each loop body would end up using the same label.
We don't know the loop bounds here though, so just fail for all
labels. */
if (flag_unroll_loops)
1992-02-01 09:24:22 +01:00
return 0;
else
return 1;
case PC:
case CC0:
case UNSPEC_VOLATILE:
return 0;
case REG:
/* We used to check RTX_UNCHANGING_P (x) here, but that is invalid
since the reg might be set by initialization within the loop. */
if ((x == frame_pointer_rtx || x == hard_frame_pointer_rtx
|| x == arg_pointer_rtx)
&& ! current_function_has_nonlocal_goto)
1992-02-01 09:24:22 +01:00
return 1;
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (LOOP_INFO (loop)->has_call
1992-02-01 09:24:22 +01:00
&& REGNO (x) < FIRST_PSEUDO_REGISTER && call_used_regs[REGNO (x)])
return 0;
if (VARRAY_INT (regs->set_in_loop, REGNO (x)) < 0)
1992-02-01 09:24:22 +01:00
return 2;
return VARRAY_INT (regs->set_in_loop, REGNO (x)) == 0;
1992-02-01 09:24:22 +01:00
case MEM:
/* Volatile memory references must be rejected. Do this before
checking for read-only items, so that volatile read-only items
will be rejected also. */
if (MEM_VOLATILE_P (x))
return 0;
1992-02-01 09:24:22 +01:00
/* See if there is any dependence between a store and this load. */
mem_list_entry = loop_info->store_mems;
while (mem_list_entry)
{
if (true_dependence (XEXP (mem_list_entry, 0), VOIDmode,
x, rtx_varies_p))
return 0;
[multiple changes] Fri Oct 29 15:25:07 1999 Arnaud Charlet <charlet@ACT-Europe.FR> * gcov.c (DIR_SEPARATOR): Provide default. (output_data): Add test for MS-DOS format absolute filename. (fancy_abort): Correct program name. (open_files): Open all files in binary mode. * libgcc2.c (__bb_exit_func): Likewise. * profile.c (init_branch_prob): Specify binary when opening files. * flags.h (flag_unwind_tables): New decl. * toplev.c (flag_unwind_table): New definition. (f_options): Add -funwind-tables. (decode_g_option): Clarify warning when unknown -g option is given. (rest_of_compilation): If inside an inlined external function, pretend we are just being declared. * dwarf2out.c (dwarf2out_do_frame): Check -funwind_tables. (dwarf2out_frame_finish): Likewise. Fri Oct 29 06:32:44 1999 Geoffrey Keating <geoffk@cygnus.com> * flow.c (propagate_block): When the last reference to a label before an ADDR_VEC is deleted because the reference is a dead store, delete the ADDR_VEC. Fri Oct 29 07:44:26 1999 Vasco Pedro <vp@di.fct.unl.pt> * fold-const.c (merge_ranges): In not in0, but in1, handle upper bounds equal like subset case. Thu Oct 28 19:22:24 1999 Douglas Rupp <rupp@gnat.com> * dbxout.c (dbxout_parms): Generate a second stabs line for parameters passed in a register but moved to the stack. Thu Oct 28 19:12:57 1999 Sam Tardieu <tardieu@act-europe.fr> * gcc.c (pass_exit_codes, greatest_status): New variables. (struct option_map): Add entry for "--pass-exit-codes". (execute): Update greatest_status if error. (display_help): Add documentation for -pass-exit-codes. (process_command): Handle -pass-exit-codes. (main): Look at pass_exit_codes and greatest_status on call to exit. Thu Oct 28 18:06:50 1999 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> * reload.c (find_reloads): Refine test for no input reload case to not includes reloads emitted after insn. * function.c (find_temp_slots_from_address): Handle sum involving a register that points to a temp slot. (update_temp_slot_address): Make recursive call if both old and new are PLUS with a common operand. * calls.c (expand_call): Mark temp slot for result as having address taken. * rtlanal.c (reg_referenced_p, case IF_THEN_ELSE): New case. * gcc.c (process_command): Add standard_exec_prefix with "GCC" component as well as "BINUTILS". * integrate.h (copy_rtx_and_substitute): New arg, FOR_LHS. * integrate.c (copy_rtx_and_substitute): Likewise. (expand_inline_function, integrate_parm_decls, integrate_decl_tree): All callers changed. * unroll.c (inital_reg_note_copy, copy_loop_body): Likewise. * dbxout.c (dbxout_type, case INTEGER_TYPE_NODE): If can use gdb extensions, write size of type; also be more consistent in using references when this is a subtype. * pa.md (extv, extzv, insv): Use define_expand to reject constant that is out of range. * loop.c (unknown_constant_address_altered): New variable. (prescan_loop): Initialize it. (note_addr_stored): Set it for RTX_UNCHANGING_P MEM. (invariant_p, case MEM): Remove handling for volatile and readony; check new variable if readonly. (check_dbra_loop): Chdeck unknown_constant_address_altered. * cse.c (canon_hash, case MEM): Do not record if BLKmode. (addr_affects_sp_p): Removed from note_mem_written and only define #ifdef AUTO_INC_DEC. * alpha.c (input_operand, case ADDRESSOF): Treat as REG. * regclass.c (record_reg_classes): Properly handle register move directions. * varasm.c (initializer_constant_valid_p, case MINUS_EXPR): Don't think valid if both operands are invalid. (struct constant_descriptor): New field RTL. (mark_const_hash_entry): Mark it. (record_constant{,_rtx}): Initialize it. (output_constant_def): Allocate RTL in permanent obstack and save in table. ({record,compare}_constant_1): Modes must match for CONSTRUCTOR of ARRAY_TYPE. * c-common.h (initializer_constant_valid_p): Delete decl from here. * output.h (initializer_constant_valid_p): Move decl to here. * c-common.c (initializer_constant_valid_p): Delete function from here. * varasm.c (initializer_constant_valid_p): Move function to here. * tree.h (STRIP_SIGN_NOPS): New macro. * fold-const.c (optimize_minmax_comparison): New function. (invert_truthvalue, case WITH_RECORD_EXPR): New case. (fold): Use STRIP_SIGN_NOPS instead of STRIP_TYPE_NOPS. (fold, case EQ_EXPR): Call optimize_minmax_comparison and add cases with ABS_EXPR, NEGATE_EXPR, PLUS_EXPR, MINUS_EXPR, and widening conversions. (fold, case LE_EXPR): Rework changing unsigned to signed comparisons to look at size of mode, not precision of type; also add missing cases. (optimize_bit_field_compare, decode_field_reference): Don't try to optimize COMPONENT_REF of a PLACEHOLDER_EXPR. * dwarf2out.c (ctype.h): Include. (dwarf2out_set_demangle_name_func): New function. (size_of_line_info): Deleted. (output_line_info): Compute size of line info table from difference of labels. (base_type_die, add_name_attribute): Call demangle function, if any. (field_byte_offset): Use bits per word for variable length fields. (gen_array_type_die): Add array name. (gen_subprogram_die): Ignore DECL_INLINE if -fno-inline. (dwarf2out_add_library_unit_info): New function. * explow.c (set_stack_check_libfunc): New function. (stack_check_libfunc): New static variable. (probe_stack_range): Allow front-end to set up a libfunc to call. * combine.c (simplify_comparison): When making comparison in wider mode, check for having commuted an AND and a SUBREG. (contains_muldiv): New function. (try_combine): Call it when dividing a PARALLEL. (simplify_rtx, case TRUNCATE): Don't remove for umulsi3_highpart. (simplify_comparison, case ASHIFTRT): Recognize sign-extension of a PLUS. (record_value_for_reg): If TEM is a binary operation with two CLOBBERs, use one of the CLOBBERs instead. (if_then_else_cond): If comparing against zero, just return thing being compared. * optabs.c (expand_abs): If machine has MAX, ABS (x) is MAX (x, -x). Don't generate shifts and subtract if have conditional arithmetic. * rtl.h (delete_barrier): New declaration. * jump.c (jump_optimize): Set up to handle conditional call. In conditional arithmetic case, handle CALL_INSN followed by a BARRIER. (delete_barrier): New function. * rtl.c (read_rtx): Call fatal if bad RTL code; check for bad mode. * recog.c (nonmemory_operand): Accept ADDRESSOF. * tree.c (build_type_attribute_variant): Push to obstack of ttype around type_hash_canon call. * expr.c (placeholder_list): Move decl to file scope. (expand_expr): Don't force access to volatile just because its address is taken. If ignoring reference operations, just expand the operands. (expand_expr, case COMPONENT_REF): Propagate EXPAND_CONST_ADDRESS to recursive call when expanding inner. Refine test for using bitfield operations vs pointer punning. (expand_expr, case CONVERT_EXPR): If converting to BLKmode UNION_TYPE from BLKmode, just return inner object. Use proper mode in store_field call. Properly set sizes of object to store and total size in store_field call for convert to union. (expand_expr, case ARRAY_REF): If OP0 is in a register, put it in memory (like for ADDR_EXPR). Also, don't put constant in register if we'll want it in memory. (readonly_fields_p): New function. (expand_expr, case INDIRECT_REF): Call it if LHS. (expand_assignment): Handle a RESULT_DECL where DECL_RTL is a PARALLEL. (do_jump, case WITH_RECORD_EXPR): New case. (get_inner_reference): Always go inside a CONVERT_EXPR and NOP_EXPR if both modes are the same. (store_field): Use bitfield operations if size of bitsize is not same as size of RHS's type. Check for bitpos not a multiple of alignment in BLKmode case. Do block move in largest possible alignment. (store_constructor): Set BITSIZE to -1 for variable size and properly in case of array of BLKmode. (expand_expr_unaligned): New function. (do_compare_and_jump): Call it. * mips/iris5.h (SWITCHES_NEED_SPACES): New macro. * collect2.c (main): Only allow -ofoo if SWITCHES_NEED_SPACES does not include 'o'. * function.c (instantiate_virtual_regs_1, case SET): Handle case where both SET_DEST and SET_SRC reference a virtual register. (gen_mem_addressof): Copy RTX_UNCHANGING_P from new REG to old REG. * integrate.c (expand_inline_function): Handle case of setting virtual stack vars register (from built in setjmp); when parameter lives in memory, expand virtual_{stack_vars,incoming_args}_rtx early. (subst_constant): Add new parm, MEMONLY. (expand_inline_function, integrate_parm_decls): Pass new parm. (integrate_decl_tree): Likewise. (copy_rtx_and_substitute, case MEM): Do copy RTX_UNCHANGING_P. (try_constants): Call subst_constants twice, with MEMONLY 0 and 1. (copy_rtx_and_substitute, case SET): Add explicit calls to copy_rtx_and_substitute for both sides. * stmt.c (expand_asm_operands): Don't use TREE_STRING_LENGTH for constraints. (pushcase{,_range}): Convert to NOMINAL_TYPE after checking for within INDEX_TYPE, instead of before. (fixup_gotos): Use f->target_rtl, not the next insn, since latter may be from a later fixup. (expand_value_return): Correctly convert VAL when promoting function return; support RETURN_REG being a PARALLEL. (expand_return): When checking for result in regs and having cleanup, consider PARALLEL in DECL_RTL as being in regs. From-SVN: r30299
1999-11-01 02:11:22 +01:00
mem_list_entry = XEXP (mem_list_entry, 1);
}
1992-02-01 09:24:22 +01:00
/* It's not invalidated by a store in memory
but we must still verify the address is invariant. */
break;
case ASM_OPERANDS:
/* Don't mess with insns declared volatile. */
if (MEM_VOLATILE_P (x))
return 0;
break;
default:
break;
1992-02-01 09:24:22 +01:00
}
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
if (fmt[i] == 'e')
{
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
int tem = loop_invariant_p (loop, XEXP (x, i));
1992-02-01 09:24:22 +01:00
if (tem == 0)
return 0;
if (tem == 2)
conditional = 1;
}
else if (fmt[i] == 'E')
{
register int j;
for (j = 0; j < XVECLEN (x, i); j++)
{
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
int tem = loop_invariant_p (loop, XVECEXP (x, i, j));
1992-02-01 09:24:22 +01:00
if (tem == 0)
return 0;
if (tem == 2)
conditional = 1;
}
}
}
return 1 + conditional;
}
/* Return nonzero if all the insns in the loop that set REG
are INSN and the immediately following insns,
and if each of those insns sets REG in an invariant way
(not counting uses of REG in them).
The value is 2 if some of these insns are only conditionally invariant.
We assume that INSN itself is the first set of REG
and that its source is invariant. */
static int
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
consec_sets_invariant_p (loop, reg, n_sets, insn)
const struct loop *loop;
1992-02-01 09:24:22 +01:00
int n_sets;
rtx reg, insn;
{
struct loop_regs *regs = LOOP_REGS (loop);
* Rework fields used to describe positions of bitfields and modify sizes to be unsigned and use HOST_WIDE_INT. * alias.c (reg_known_value_size): Now unsigned. * c-typeck.c (build_unary_op, case ADDR_EXPR): Use byte_position. (really_start_incremental_init): Use bitsize_zero_node. (push_init_level, pop_init_level, output_init_element): Likewise. Use bitsize_unit_node and bitsize_one_node. (output_pending_init_elements, process_init_element): Likewise. * combine.c (combine_max_regno, reg_sign_bit_copies): Now unsigned. (make_extraction): Position and length HOST_WIDE_INT and unsigned HOST_WIDE_INT, respectively. (get_pos_from_mask): Passed in value is unsigned HOST_WIDE_INT. (num_sign_bit_copies): Returns unsigned. BITWIDTH now unsigned; rework arithmetic. Remove recursive call from arg to MAX. (combine_instructions, init_reg_last_arrays): NREGS now unsigned. (setup_incoming_promotions, can_combine_p, try_combine, simplify_set): REGNO now unsigned. (set_nonzero_bit_and_sign_copies): NUM now unsigned. (find_split_point, expand_compound_operation, make_extraction): LEN now unsigned HOST_WIDE_INT, POS now HOST_WIDE_INT. (make_field_assignment): Likewise. (combine_simplify_rtx): Add cast. (expand_compound_operation): MODEWIDTH now unsigned; rework arithmetic. (force_to_mode): WIDTH now unsigned; add cast. (if_then_else_cond): SIZE now unsigned. (nonzero_bits): MODE_WIDTH, RESULT_WIDTH, and WIDTH now unsigned. (extended_count): Now returns unsigned. (simplify_shift_const): COUNT unsigned; arg is now INPUT_COUNT. Add SIGNED_COUNT variable; MODE_WORDS and FIRST_COUNT now unsigned. (simplify_comparison): MODE_WIDTH now unsigned. (update_table_tick): REGNO and ENDREGNO now unsigned; new var R. (mark_used_regs_combine): Likewise; rework arithmetic. (record_value_for_reg): REGNO, ENDREGNO, and I now unsigned. (record_dead_and_set_regs, reg_dead_at_p, distribute_notes): Likewise. (record_promoted_value): REGNO now unsigned. (get_last_value_validate): REGNO, ENDREGNO, and J now unsigned. (get_last_value): REGNO now unsigned. (use_crosses_set_p): REGNO and ENDREGNO now unsigned. (reg_dead_regno, reg_dead_endregno): Now unsigned. (remove_death): Arg REGNO now unsigned. (move_deaths): REGNO, DEADREGNO, DEADEND, OUREND, and I now unsigned. (reg_bitfield_target_p): REGNO, REGNO, ENDREGNO, and ENDTREGNO now unsigned. * convert.c (convert_to_integer): INPREC and OUTPREC now unsigned. * cse.c (struct qty_table_elem): FIRST_REG and LAST_REG now unsigned. (struct cse_reg_info): REGNO now unsigned. (cached_regno): Now unsigned. (REGNO_QTY_VALID_P): Add cast. (make_new_qty, make_regs_eqv, delete_reg_eqiv): Regno args unsigned. (remove_invalid_regs): Likewise. (remove_invalid_subreg_refs): Likewise; arg WORD also unsigned as are variables END and I. (get_cse_reg_info, insert): Likewise. (mention_regs, invalidate_for_call): REGNO, ENDREGNO, and I unsigned. (canon_hash): Likewise. (insert_regs, lookup_for_remove): REGNO now unsigned. (invalidate): REGNO, ENDREGNO, TREGNO, and TENDREGNO now unsigned. New variable RN. * dbxout.c (dbxout_parms, dbxout_reg_parms): Don't check for REGNO < 0. * dwarf2out.c (dwarf2ou_frame_debug_expr): Remove cast. * emit-rtl.c (subreg_realpart_p): Add cast. (operand_subword): Arg I is now unsigned as is var PARTWORDS. (operand_subword_force): Arg I is now unsigned. * except.c (eh_regs): Variable I is now unsigned. * explow.c (hard_function_value): BYTES is unsigned HOST_WIDE_INT. * expmed.c (store_fixed_bit_field): Position is HOST_WIDE_INT; length is unsigned HOST_WIDE_INT; likewise for internal variables. (store_split_bit_field, extract_fixed_bit_field): Likewise. (extract_split_bit_field, store_bit_field, extract_bit_field): Likewise. * expr.c (store_constructor_fields, store_constructor, store_field): Positions are HOST_WIDE_INT and lengths are unsigned HOST_WIDE_INT. (expand_assignment, expand_expr, expand_expr_unaligned): Likewise. (do_jump): Likewise. (move_by_pieces, move_by_pieces_ninsns, clear_by_pieces): MAX_SIZE is now unsigned. (emit_group_load): BYTEPOS is HOST_WIDE_INT; BYTELEN is unsigned. (emit_group_store): Likewise. (emit_move_insn): I now unsigned. (store_constructor): Use host_integerp, tree_low_cst, and bitsize_unit_node. (get_inner_reference): Return bitpos and bitsize as HOST_WIDE_INT. Rework all calculations to use trees and new fields. * expr.h (promoted_input_arg): Regno now unsigned. (store_bit_field, extract_bit_field): Adjust types of pos and size. (mark_seen_cases): Arg is HOST_WIDE_INT. * flow.c (verify_wide_reg_1): REGNO now unsigned. * fold-const.c (decode_field_reference): Size and pos HOST_WIDE_INT; precisions and alignments are unsigned. (optimize_bit_field_compare, fold_truthop): Likewise. (int_const_binop): Adjust threshold for size_int_type_wide call. (fold_convert): Likewise. (size_int_type_wide): Make table larger and fix thinko that only had half of table used. (all_ones_mask_p, fold): Precisions are unsigned. * function.c (put_reg_info_stack): REGNO is unsigned. (instantiate_decl): Size is HOST_WIDE_INT. (instantiate_virtual_regs): I is unsigned. (assign_parms): REGNO, REGNOI, and REGNOR are unsigned. (promoted_input_arg): REGNO is unsigned. * function.h (struct function): x_max_parm_reg is now unsigned. * gcse.c (max_gcse_regno): Now unsigned. (struct null_pointer_info): min_reg and max_reg now unsigned. (lookup_set, next_set): REGNO arg now unsigned. (compute_hash_table): REGNO and I now unsigned. (handle_avail_expr): regnum_for_replacing now unsigned. (cprop_insn): REGNO now unsigned. (delete_null_pointer_checks_1): BLOCK_REG now pointer to unsigned. * ggc-common.c (ggc_mark_tree_children, case FIELD_DECL): New case. * global.c (set_preference): SRC_REGNO, DEST_REGNO, and I now unsigned. * hard-reg-set.h (reg_class_size): Now unsigned. * integrate.c (mark_stores): LAST_REG and I now unsigned; new UREGNO. * jump.c (mark_modified_reg): I now unsigned; add cast. (rtx_equal_for_thread_p): Add cast. * loop.c (max_reg_before_loop): Now unsigned. (struct_movable): REGNO now unsigned. (try_copy_prop): REGNO arg unsigned. (regs_match_p): XN and YN now unsigned. (consec_sets_invariant_p, maybe_eliminate_biv): REGNO now unsigned. (strength_reduce): Likewise; NREGS also unsigned. (first_increment_giv, last_increment_giv unsigned): Now unsigned. * loop.h (struct iv_class): REGNO now unsigned. (max_reg_before_loop, first_increment_giv, last_increment_giv): Now unsigned. * machmode.h (mode_size, mode_unit_size): Now unsigned. (mode_for_size, smallest_mode_for_size): Pass size as unsigned. * optabs.c (expand_binop): I and NWORDS now unsigned. (expand_unop): I now unsigned. * print-tree.c (print_node): Don't print DECL_FIELD_BITPOS, but do print DECL_FIELD_OFFSET and DECL_FIELD_BIT_OFFSET. * real.c (significand_size): Now returns unsigned. * real.h (significand_size): Likewise. * regclass.c (reg_class_size): Now unsigned. (choose_hard_reg_mode): Both operands now unsigned. (record_reg_classes): REGNO and NR now unsigned. (reg_scan): NREGS now unsigned. (reg_scan_update): old_max_regno now unsigned. (reg_scan_mark_refs): Arg MIN_REGNO and var REGNO now unsigned. * reload.c (find_valid_class): BEST_SIZE now unsigned. (find_dummy_reload): REGNO, NWORDS, and I now unsigned. (hard_reg_set_here_p): Args BEG_REGNO and END_REGNO now unsigned. Likewise for variable R. (refers_to_regno_for_reload_p): Args REGNO and END_REGNO now unsigned, as are variables INNER_REGNO and INNER_ENDREGNO; add new variable R. (find_equiv_reg): Add casts. (regno_clobbered_p): Arg REGNO now unsigned. * reload.h (struct reload): NREGS now unsigned. (refers_to_regno_for_reload_p): Regno args are unsigned. (regno_clobbered_p): Likewise. * reload1.c (reg_max_ref_width, spill_stack_slot_width): Now unsigned. (compute_use_by_pseudos): REGNO now unsigned. (find_reg): I and J now unsigned, new variable K, and change loop variables accordingly; THIS_NREGS now unsigned. (alter_reg): INHERENT_SIZE and TOTAL_SIZE now unsigned. (spill_hard_reg): REGNO arg now unsigned; add casts. (forget_old_reloads_1): REGNO, NR, and I now unsigned. (mark_reload_reg_in_use): Arg REGNO and vars NREGS and I now unsigned. (clear_reload_reg_in_use): Arg REGNO and vars NREGS, START_REGNO, END_REGNO, CONFLICT_START, and CONFLICT_END now unsigned. (reload_reg_free_p, reload_reg_reaches_end_p): Arg REGNO now unsigned. (choose_reload_regs): MAX_GROUP_SIZE now unsigned. (emit_reload_insns): REGNO now unsigned. (reload_cse_move2add): Add cast. (move2add_note_store): REGNO and I now unsigned; new variable ENDREGNO and rework loop. * resource.c (mark_referenced_resources, mark_set_resources): New variable R; REGNO and LAST_REGNO now unsigned. (mark_target_live_regs): J and REGNO now unsigned. * rtl.c (mode_size, mode_unit_size): Now unsigned. * rtl.h (union rtunion_def): New field rtuint. (XCUINT): New macro. (ADDRESSOF_REGNO, REGNO, SUBREG_WORD): New XCUINT. (operand_subword, operand_subword_force): Word number is unsigned. (choose_hard_reg_mode): Operands are unsigned. (refers_to-regno_p, dead_or_set_regno_p): Regno arg is unsigned. (find_regno_note, find_regno_fusage, replace_regs): Likewise. (regno_use_in, combine_instructions, remove_death): Likewise. (reg_scan, reg_scan_update): Likewise. (extended_count): Return is unsigned. * rtlanal.c (refers_to_regno_p): Args REGNO and ENDREGNO and vars I, INNER_REGNO, and INNER_ENDREGNO now unsigned; new variable X_REGNO. (reg_overlap_mentioned_p): REGNO and ENDREGNO now unsigned. (reg_set_last_first_regno, reg_set_last_last_regno): Now unsigned. (reg_reg_last_1): FIRS and LAST now unsigned. (dead_or_set_p): REGNO, LAST_REGNO, and I now unsigned. (dead_or_set_regno_p): Arg TEST_REGNO and vars REGNO and ENDREGNO now unsigned. (find_regno_note, regno_use_in): Arg REGNO now unsigned. (find_regno_fusage): Likewise; also var REGNOTE now unsigned. (find_reg_fusage): Variables REGNO, END_REGNO, and I now unsigned. (replace_regs): Arg NREGS now unsigned. * sdbout.c (sdbout_parms, sdbout_reg_parms): Don't check REGNO < 0. * simplify-rtx.c (simplify_unary_operation): WIDTH now unsigned. (simplify_binary_operation): Likewise. (cselib_invalidate_regno): Arg REGNO and variables ENDREGNO, I, and THIS_LAST now unsigned. (cselib_record_set): Add cast. * ssa.c (ssa_max_reg_num): Now unsigned. (rename_block): REGNO now unsigned. * stmt.c (expand_return): Bit positions unsigned HOST_WIDE_INT; sizes now unsigned. (all_cases_count): Just return -1 not -2. COUNT, MINVAL, and LASTVAL now HOST_WIDE_INT. Rework tests to use trees whenever possible. Use host_integerp and tree_low_cst. (mark_seen_cases): COUNT arg now HOST_WIDE_INT; Likewise variable NEXT_NODE_OFFSET; XLO now unsigned. (check_for_full_enumeration_handing): BYTES_NEEDED, I to HOST_WIDE_INT. * stor-layout.c (mode_for_size): SIZE arg now unsigned. (smallest_mode_for_size): Likewise. (layout_decl): Simplify handing of a specified DECL_SIZE_UNIT. KNOWN_ALIGN is now an alignment, so simplify code. Don't turn off DECL_BIT_FIELD if field is BLKmode, but not type. (start_record_layout): Renamed from new_record_layout_info. Update to new fields. (debug_rli, normalize_rli, rli_size_unit_so_far, rli_size_so_far): New functions. (place_union_field): Renamed from layout_union_field. Update to use new fields in rli. (place_field): Renamed from layout_field. Major rewrite to use new fields in rli; pass alignment to layout_decl. (finalize_record_size): Rework to use new fields in rli and handle union. (compute_record_mode): Rework to simplify and to use new DECL fields. (finalize_type_size): Make rounding more consistent. (finish_union_layout): Deleted. (layout_type, case VOID_TYPE): Don't set TYPE_SIZE_UNIT either. (layout_type, case RECORD_TYPE): Call new function names. (initialize_sizetypes): Set TYPE_IS_SIZETYPE. (set_sizetype): Set TYPE_IS_SIZETYPE earlier. (get_best_mode): UNIT is now unsigned; remove casts. * tree.c (bit_position): Compute from new fields. (byte_position, int_byte_position): New functions. (print_type_hash_statistics): Cast to remove warning. (build_range_type): Use host_integerp and tree_low_cst to try to hash. (build_index_type): Likewise; make subtype of sizetype. (build_index_2_type): Pass sizetype to build_range_type. (build_common_tree_nodes): Use size_int and bitsize_int to initialize nodes; add bitsize_{zero,one,unit}_node. * tree.h (DECL_FIELD_CONTEXT): Use FIELD_DECL_CHECK. (DECL_BIT_FIELD_TYPE, DECL_QUALIFIER, DECL_FCONTEXT): Likewise. (DECL_PACKED, DECL_BIT_FIELD): Likewise. (DECL_FIELD_BITPOS): Deleted. (DECL_FIELD_OFFSET, DECL_FIELD_BIT_OFFSET): New fields. (DECL_RESULT, DECL_SAVED_INSNS): Use FUNCTION_DECL_CHECK. (DECL_FRAME_SIZE, DECL_FUNCTION_CODE, DECL_NO_STATIC_CHAIN): Likewise. (DECL_INLINE, DECL_BUILT_IN_NONANSI, DECL_IS_MALLOC): Likewise. (DECL_BUILT_IN_CLASS, DECL_STATIC_CONSTRUCTOR): Likewise. (DECL_STATIC_DESTRUCTOR, DECL_NO_CHECK_MEMORY_USAGE): Likewise. (DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT, DECL_NO_LIMIT_STACK) Likewise. (DECL_ORIGINAL_TYPE, TYPE_DECL_SUPPRESS_DEBUG): Use TYPE_DECL_CHECK. (DECL_ARG_TYPE_AS_WRITEN, DECL_ARG_TYPE): Use PARM_DECL_CHECK. (DECL_INCOMING_RTL, DECL_TRANSPARENT_UNION): Likewise. (DECL_ALIGN): Adjust to new field in union. (DECL_OFFSET_ALIGN): New field. (DECL_ERROR_ISSUED, DECL_TOO_LATE): Use LABEL_DECL_CHECK. (DECL_IN_TEXT_SECTION): Use VAR_DECL_CHECK. (union tree_decl): Add struct for both aligns. (enum tree_index): Add TI_BITSIZE_{ZERO,ONE,UNIT}. (bitsize_zero_node, bitsize_one_node, bitsize_unit_node): Added. (struct record_layout_info): Rework fields to have offset alignment and byte and bit position. (start_record_layout, place_field): Renamed from old names. (rli_size_so_far, rli_size_unit_so_far, normalize_rli): New decls. (byte_position, int_byte_position): Likewise. (get_inner_reference): Change types of position and length. * unroll.c (unroll_loop): New variable R; use for some loops. MAX_LOCAL_REGNUM and MAXREGNUM now unsigned. (calculate_giv_inc): Arg REGNO now unsigned. (copy_loop_body): REGNO and SRC_REGNO now unsigned. * varasm.c (assemble_variable): Clean up handling of size using host_integerp and tree_low_cst. (decode_addr_const): Use byte, not bit, position. (output_constructor): bitpos and offsets are HOST_WIDE_INT; use tree_low_cst and int_bit_position. * objc/objc-act.c (build_ivar_list_initializer): Use byte_position. * ch/actions.c (check_missing_cases): BYTES_NEEDED is HOST_WIDE_INT. * ch/typeck.c (expand_constant_to_buffer): Use int_byte_position. (extract_constant_from_buffer): Likewise. * cp/class.c (build_vbase_pointer_fields): layout_field now place_field. (get_vfield_offset): Use byte_position. (set_rtti_entry): Set OFFSET to ssizetype zero. (get_binfo_offset_as_int): Deleted. (dfs_record_base_offsets): Use tree_low_cst. (dfs_search_base_offsets): Likewise. (layout_nonempty_base_or_field): Reflect changes in RLI format and call byte_position. (layout_empty_base): Convert offset to ssizetype. (build_base_field): use rli_size_unit_so_far. (dfs_propagate_binfo_offsets): Do computation in proper type. (layout_virtual_bases): Pass ssizetype to propagate_binfo_offsets. (layout_class_type): Reflect changes in RLI names and fields. (finish_struct_1): Set DECL_FIELD_OFFSET. * cp/dump.c (dequeue_and_dump): Call bit_position. * cp/expr.c (cplus_expand_constant): Use byte_position. * cp/rtti.c (expand_class_desc): Use bitsize_one_node. * cp/typeck.c (build_component_addr): Use byte_position and don't special case for zero offset. * f/com.c (ffecom_tree_canonize_ptr_): Use bitsize_zero_node. (ffecom_tree_canonize_ref_): Likewise. * java/class.c (make_field_value): Use byte_position. * java/expr.c (JAVA_ARRAY_LENGTH_OFFSET): Use byte_position. (java_array_data_offset): Likewise. * java/java-tree.h (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Add case to bzero call. From-SVN: r32742
2000-03-25 19:34:13 +01:00
rtx p = insn;
unsigned int regno = REGNO (reg);
1992-02-01 09:24:22 +01:00
rtx temp;
/* Number of sets we have to insist on finding after INSN. */
int count = n_sets - 1;
int old = VARRAY_INT (regs->set_in_loop, regno);
1992-02-01 09:24:22 +01:00
int value = 0;
int this;
/* If N_SETS hit the limit, we can't rely on its value. */
if (n_sets == 127)
return 0;
VARRAY_INT (regs->set_in_loop, regno) = 0;
1992-02-01 09:24:22 +01:00
while (count > 0)
{
register enum rtx_code code;
rtx set;
p = NEXT_INSN (p);
code = GET_CODE (p);
1998-05-06 23:09:07 +02:00
/* If library call, skip to end of it. */
if (code == INSN && (temp = find_reg_note (p, REG_LIBCALL, NULL_RTX)))
1992-02-01 09:24:22 +01:00
p = XEXP (temp, 0);
this = 0;
if (code == INSN
&& (set = single_set (p))
&& GET_CODE (SET_DEST (set)) == REG
&& REGNO (SET_DEST (set)) == regno)
{
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
this = loop_invariant_p (loop, SET_SRC (set));
1992-02-01 09:24:22 +01:00
if (this != 0)
value |= this;
Fix warious warnings: * c-aux-info.c: Include string.h/strings.h. * pa.c: Include stdlib.h. (pa_combine_instructions): Prototype the function. (pa_can_combine_p, forward_branch_p, shadd_constant_p): Likewise. (reloc_needed): Add default case for enumeration switch. (remove_useless_addtr_insns): Remove unused variable `all'. (hppa_expand_prologue): Add explicit braces to avoid ambiguous `else'. (output_function_epilogue): Remove unused variable `i'. (output_millicode_call): Remove unused variable `link'. (shadd_constant_p, forward_branch_p): Make the function static. (following_call): Explicitly declare to return int. (pa_reorg): Declare as void. (pa_combine_instructions): Declare as static void. Add parentheses around && within ||. * pa.h: Add prototypes for pa_reorg, symbolic_operand, following_call, function_label_operand, lhs_lshift_cint_operand and zdepi_cint_p. * pa.md: Add parentheses around && within ||. * cppalloc.c: Include stdlib.h. * cpperror.c (cpp_print_containing_files): Remove unused variable `i'. Fix format specifier in fprintf. * cse.c (cse_around_loop): Add explicit braces to avoid ambiguous `else'. (delete_dead_from_cse): Wrap variable `tem' in macro HAVE_cc0. * expr.c (expand_expr): Add parentheses around && within ||. * final.c (app_enable): Replace fprintf with fputs where there are no format specifiers and no trailing argument after the string. Eg, when printing ASM_APP_ON/ASM_APP_OFF. (app_disable): Likewise. (final_end_function): Likewise. (final_scan_insn): Likewise. Remove unused variable `set'. (profile_function): Wrap empty if-statement body in {} brackets. * function.c: Include stdlib.h. (pad_below): Wrap prototype and definition in ARGS_GROW_DOWNWARD. (reposition_prologue_and_epilogue_notes): Add parentheses around assignment used as truth value. * integrate.c (expand_inline_function): Wrap variable `cc0_insn' in macro HAVE_cc0. * jump.c (jump_optimize): Wrap variable `q' in macro HAVE_cc0. Remove unused variable `prev1'. * libgcc2.c (__bb_exit_trace_func): Add parentheses around && within ||. Fix format specifier in fprintf. (__bb_init_prg): Add parentheses around assignment used as truth value. * local-alloc.c: Include stdlib.h. (requires_inout): Add parentheses around assignment used as truth value. * loop.c (analyze_loop_iterations): Wrap prototype and definition in macro HAVE_decrement_and_branch_on_count. (insert_bct, instrument_loop_bct): Likewise. (move_movables): Add parentheses around assignment used as truth value. (consec_sets_invariant_p): Likewise. (maybe_eliminate_biv_1): Wrap variable `new' in macro HAVE_cc0. * objc/objc-act.c: Include stdlib.h. (lookup_method_in_protocol_list): Wrap empty else-statement body in braces. (lookup_protocol_in_reflist): Likewise. (objc_add_static_instance): Remove unused variables `decl_expr' and `decl_spec'. (get_objc_string_decl): Remove unused variable `decl'. (generate_static_references): Remove unused variables `idecl' and `instance'. (check_protocols): Wrap empty else-statement body in braces. * protoize.c: Include stdlib.h. (substr): Add parentheses around assignment used as truth value. (abspath): Likewise. (shortpath): Likewise. * regmove.c (fixup_match_1): Add parentheses around assignment used as truth value. * reload.c (push_secondary_reload): Remove unused variable `i'. (find_reloads): Add parentheses around assignment used as truth value. * reload1.c: Include stdlib.h. * rtl.h: Correct typo in prototype of offsettable_memref_p. * stmt.c (add_case_node): Add parentheses around assignment used as truth value. (case_tree2list): Likewise. * tree.c (valid_machine_attribute): Wrap variable `decl_attr_list' in macro VALID_MACHINE_DECL_ATTRIBUTE. Wrap variable `type_attr_list' in macro VALID_MACHINE_TYPE_ATTRIBUTE. (merge_attributes): Add explicit braces to avoid ambiguous `else'. * unroll.c (copy_loop_body): Wrap variable `cc0_insn' in macro HAVE_cc0. * varasm.c: Include stdlib.h. From-SVN: r18290
1998-02-28 08:06:53 +01:00
else if ((temp = find_reg_note (p, REG_EQUAL, NULL_RTX)))
1992-02-01 09:24:22 +01:00
{
/* If this is a libcall, then any invariant REG_EQUAL note is OK.
If this is an ordinary insn, then only CONSTANT_P REG_EQUAL
notes are OK. */
this = (CONSTANT_P (XEXP (temp, 0))
|| (find_reg_note (p, REG_RETVAL, NULL_RTX)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
&& loop_invariant_p (loop, XEXP (temp, 0))));
1992-02-01 09:24:22 +01:00
if (this != 0)
value |= this;
}
}
if (this != 0)
count--;
else if (code != NOTE)
{
VARRAY_INT (regs->set_in_loop, regno) = old;
1992-02-01 09:24:22 +01:00
return 0;
}
}
VARRAY_INT (regs->set_in_loop, regno) = old;
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
/* If loop_invariant_p ever returned 2, we return 2. */
1992-02-01 09:24:22 +01:00
return 1 + (value & 2);
}
#if 0
/* I don't think this condition is sufficient to allow INSN
to be moved, so we no longer test it. */
/* Return 1 if all insns in the basic block of INSN and following INSN
that set REG are invariant according to TABLE. */
static int
all_sets_invariant_p (reg, insn, table)
rtx reg, insn;
short *table;
{
register rtx p = insn;
register int regno = REGNO (reg);
while (1)
{
register enum rtx_code code;
p = NEXT_INSN (p);
code = GET_CODE (p);
if (code == CODE_LABEL || code == JUMP_INSN)
return 1;
if (code == INSN && GET_CODE (PATTERN (p)) == SET
&& GET_CODE (SET_DEST (PATTERN (p))) == REG
&& REGNO (SET_DEST (PATTERN (p))) == regno)
{
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (! loop_invariant_p (loop, SET_SRC (PATTERN (p)), table))
1992-02-01 09:24:22 +01:00
return 0;
}
}
}
#endif /* 0 */
/* Look at all uses (not sets) of registers in X. For each, if it is
the single use, set USAGE[REGNO] to INSN; if there was a previous use in
a different insn, set USAGE[REGNO] to const0_rtx. */
static void
find_single_use_in_loop (insn, x, usage)
rtx insn;
rtx x;
varray_type usage;
1992-02-01 09:24:22 +01:00
{
enum rtx_code code = GET_CODE (x);
rtl.h (rtx_format): Constify a char*. * rtl.h (rtx_format): Constify a char*. * rtl.c (rtx_format): Likewise. (copy_rtx, copy_most_rtx, read_rtx): Likewise. (init_rtl): Use accessor macro, not `rtx_format'. * alias.c (rtx_equal_for_memref_p, find_symbolic_term): Constify a char*. * caller-save.c (mark_referenced_regs): Likewise. * combine.c (subst, make_compound_operation, known_cond, gen_rtx_combine, update_table_tick, get_last_value_validate, use_crosses_set_p, mark_used_regs_combine, move_deaths): Likewise. * cse.c (rtx_cost, mention_regs, canon_hash, exp_equiv_p, refers_to_p, canon_reg, fold_rtx, cse_process_notes, count_reg_usage): Likewise. * emit-rtl.c (gen_rtx, copy_rtx_if_shared, reset_used_flags): Likewise. * final.c (leaf_renumber_regs_insn): Likewise. * flow.c (mark_used_regs, find_use_as_address, dump_flow_info, dump_edge_info, count_reg_references): Likewise. * function.c (fixup_var_refs_1, walk_fixup_memory_subreg, fixup_stack_1, purge_addressof_1, instantiate_virtual_regs_1): Likewise. * gcse.c (oprs_unchanged_p, hash_expr_1, expr_equiv_p, oprs_not_set_p, expr_killed_p, compute_transp, find_used_regs, add_label_notes): Likewise. * genattrtab.c (attr_rtx, attr_copy_rtx, encode_units_mask, clear_struct_flag, count_sub_rtxs, count_alternatives, compares_alternatives_p, contained_in_p, walk_attr_value, write_expr_attr_cache): Likewise. * genconfig.c (walk_insn_part): Likewise. * genemit.c (max_operand_1, gen_exp): Likewise. * genextract.c (walk_rtx): Likewise. * genflags.c (num_operands): Likewise. * genoutput.c (scan_operands): Likewise. * genpeep.c (match_rtx): Likewise. * genrecog.c (add_to_sequence): Likewise. * haifa-sched.c (may_trap_exp, sched_analyze_2, attach_deaths): Likewise. * integrate.c (save_constants, copy_for_inline, copy_rtx_and_substitute, subst_constants, restore_constants): Likewise. * jump.c (mark_jump_label, invert_exp, redirect_exp, rtx_renumbered_equal_p, rtx_equal_for_thread_p): Likewise. * local-alloc.c (contains_replace_regs, memref_referenced_p): Likewise. * loop.c (record_excess_regs, rtx_equal_for_loop_p, add_label_notes, replace_call_address, count_nonfixed_reads, invariant_p, find_single_use_in_loop, find_mem_givs, find_life_end, maybe_eliminate_biv_1, update_reg_last_use): Likewise. * print-rtl.c (reg_names, print_rtx): Likewise. * recog.c (validate_replace_rtx_1, find_single_use_1): Likewise. * reg-stack.c (stack_regs_mentioned_p, record_label_references, record_reg_life_pat, swap_rtx_condition, goto_block_pat, print_blocks): Likewise. * regclass.c (fix_register, record_address_regs, reg_scan_mark_refs): Likewise. * regmove.c (stable_but_for_p): Likewise. * reload.c (loc_mentioned_in_p, operands_match_p, find_reloads_toplevsubst_reg_equivs, find_reloads_address_1, copy_replacements, refers_to_regno_for_reload_p, refers_to_mem_for_reload_p, find_inc_amount, regno_clobbered_p, reload_when_needed_name, reg_class_names, debug_reload_to_stream): Likewise. * reload1.c (eliminate_regs, scan_paradoxical_subregs, delete_address_reloads_1, count_occurrences, reload_cse_mem_conflict_p, reload_combine_note_use, add_auto_inc_notes): Likewise. * resource.c (mark_referenced_resources, mark_set_resources): Likewise. * rtlanal.c (rtx_unstable_p, rtx_varies_p, rtx_addr_varies_p, reg_mentioned_p, regs_set_between_p, modified_between_p, modified_in_p, refers_to_regno_p, reg_overlap_mentioned_p, rtx_equal_p, volatile_insn_p, volatile_refs_p, side_effects_p, may_trap_p, inequality_comparisons_p, replace_rtx, replace_regs, jmp_uses_reg_or_mem, for_each_rtx, regno_use_in): Likewise. * sched.c (sched_analyze_2, attach_deaths): Likewise. * stupid.c (stupid_mark_refs): Likewise. * unroll.c (remap_split_bivs): Likewise. * varasm.c (mark_constants): Likewise. * a29k/a29k.c (uses_local_reg_p): Likewise. * alpha/alpha.c (summarize_insn): Likewise. * arm/arm.c (symbol_mentioned_p, label_mentioned_p, eliminate_lr2ip): Likewise. * arm/thumb.c (symbol_mentioned_p, label_mentioned_p): Likewise. * i386/i386.c (symbolic_reference_mentioned_p, copy_all_rtx, reg_mentioned_in_mem): Likewise. * ns32k/ns32k.c (global_symbolic_reference_mentioned_p, symbolic_reference_mentioned_p): Likewise. * romp/romp.c (unsigned_comparisons_p, hash_rtx): Likewise. * sh/sh.c (regs_used, mark_use): Likewise. * vax/vax.c (vax_rtx_cost): Likewise. From-SVN: r28784
1999-08-21 01:05:25 +02:00
const char *fmt = GET_RTX_FORMAT (code);
1992-02-01 09:24:22 +01:00
int i, j;
if (code == REG)
VARRAY_RTX (usage, REGNO (x))
= (VARRAY_RTX (usage, REGNO (x)) != 0
&& VARRAY_RTX (usage, REGNO (x)) != insn)
1992-02-01 09:24:22 +01:00
? const0_rtx : insn;
else if (code == SET)
{
/* Don't count SET_DEST if it is a REG; otherwise count things
in SET_DEST because if a register is partially modified, it won't
show up as a potential movable so we don't care how USAGE is set
1992-02-01 09:24:22 +01:00
for it. */
if (GET_CODE (SET_DEST (x)) != REG)
find_single_use_in_loop (insn, SET_DEST (x), usage);
find_single_use_in_loop (insn, SET_SRC (x), usage);
}
else
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
if (fmt[i] == 'e' && XEXP (x, i) != 0)
find_single_use_in_loop (insn, XEXP (x, i), usage);
else if (fmt[i] == 'E')
for (j = XVECLEN (x, i) - 1; j >= 0; j--)
find_single_use_in_loop (insn, XVECEXP (x, i, j), usage);
}
}
/* Count and record any set in X which is contained in INSN. Update
MAY_NOT_MOVE and LAST_SET for any register set in X. */
static void
count_one_set (regs, insn, x, may_not_move, last_set)
struct loop_regs *regs;
rtx insn, x;
varray_type may_not_move;
rtx *last_set;
{
if (GET_CODE (x) == CLOBBER && GET_CODE (XEXP (x, 0)) == REG)
/* Don't move a reg that has an explicit clobber.
It's not worth the pain to try to do it correctly. */
VARRAY_CHAR (may_not_move, REGNO (XEXP (x, 0))) = 1;
if (GET_CODE (x) == SET || GET_CODE (x) == CLOBBER)
{
rtx dest = SET_DEST (x);
while (GET_CODE (dest) == SUBREG
|| GET_CODE (dest) == ZERO_EXTRACT
|| GET_CODE (dest) == SIGN_EXTRACT
|| GET_CODE (dest) == STRICT_LOW_PART)
dest = XEXP (dest, 0);
if (GET_CODE (dest) == REG)
{
register int regno = REGNO (dest);
/* If this is the first setting of this reg
in current basic block, and it was set before,
it must be set in two basic blocks, so it cannot
be moved out of the loop. */
if (VARRAY_INT (regs->set_in_loop, regno) > 0
&& last_set[regno] == 0)
VARRAY_CHAR (may_not_move, regno) = 1;
/* If this is not first setting in current basic block,
see if reg was used in between previous one and this.
If so, neither one can be moved. */
if (last_set[regno] != 0
&& reg_used_between_p (dest, last_set[regno], insn))
VARRAY_CHAR (may_not_move, regno) = 1;
if (VARRAY_INT (regs->set_in_loop, regno) < 127)
++VARRAY_INT (regs->set_in_loop, regno);
last_set[regno] = insn;
}
}
}
/* Increment REGS->SET_IN_LOOP at the index of each register
1992-02-01 09:24:22 +01:00
that is modified by an insn between FROM and TO.
If the value of an element of REGS->SET_IN_LOOP becomes 127 or more,
1992-02-01 09:24:22 +01:00
stop incrementing it, to avoid overflow.
Store in SINGLE_USAGE[I] the single insn in which register I is
used, if it is only used once. Otherwise, it is set to 0 (for no
uses) or const0_rtx for more than one use. This parameter may be zero,
in which case this processing is not done.
Store in *COUNT_PTR the number of actual instruction
in the loop. We use this to decide what is worth moving out. */
/* last_set[n] is nonzero iff reg n has been set in the current basic block.
In that case, it is the insn that last set reg n. */
static void
count_loop_regs_set (loop, may_not_move, single_usage, count_ptr, nregs)
const struct loop *loop;
varray_type may_not_move;
varray_type single_usage;
1992-02-01 09:24:22 +01:00
int *count_ptr;
int nregs;
{
struct loop_regs *regs = LOOP_REGS (loop);
register rtx *last_set = (rtx *) xcalloc (nregs, sizeof (rtx));
1992-02-01 09:24:22 +01:00
register rtx insn;
register int count = 0;
for (insn = loop->top ? loop->top : loop->start; insn != loop->end;
insn = NEXT_INSN (insn))
1992-02-01 09:24:22 +01:00
{
alias.c (mark_constant_function): Use INSN_P. * alias.c (mark_constant_function): Use INSN_P. (init_alias_analysis): Likewise. * combine.c (combine_instructions): Use INSN_P. (can_combine_p): Likewise. (try_combine): Likewise. (distribute_notes): Likewise. (distribute_links): Likewise. * cse.c (cse_around_loop): Use INSN_P. (invalidate_skipped_block): Likewise. (cse_set_around_loop): Likewise. (cse_end_of_basic_block): Likewise. (delete_trivially_dead_insns): Likewise. * emit-rtl.c (unshare_all_rtl_again): Use INSN_P. (unshare_all_rtl_1): Likewise. (next_cc0_user): Likewise. (try_split make_insn_raw): Likewise. (remove_unnecessary_notes): Likewise. * final.c (shorten_branches): Use INSN_P. (leaf_renumber_regs): Likewise. (leaf_renumber_regs_insn): Likewise. * flow.c (find_label_refs): Use INSN_P. (verify_wide_reg): Likewise. (notice_stack_pointer_modification): Likewise. (count_or_remove_death_notes): Likewise. (verify_flow_info): Likewise. (clear_log_links): Likewise. * function.c (fixup_var_refs_insns): Use INSN_P. (compute_insns_for_mem): Likewise. * gcse.c (alloc_gcse_mem): Use INSN_P. (compute_sets): Likewise. (compute_hash_table): Likewise. (classic_gcse): Likewise. (cprop): Likewise. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks_1): Likewise. * global.c (expand_preferences): Use INSN_P. (build_insn_chain): Likewise. * graph.c (node_data): Use INSN_P. * haifa-sched.c (priority): Use INSN_P. (rm_line_notes): Likewise. (rm_other_notes): Likewise. (find_insn_reg_weight): Likewise. (init_target_units): Likewise. (schedule_block): Likewise. (compute_block_forward_dependences): Likewise. (debug_dependencies): Likewise. (set_priorities): Likewise. * integrate.c (function_cannot_inline_p): Use INSN_P. (save_parm_insns): Likewise. (copy_insn_list): Likewise. * jump.c (mark_all_labels): Use INSN_P. (never_reached_warning): Likewise. * lcm.c (optimize_mode_switching): Use INSN_P. * local-alloc.c (validate_equiv_mem): Use INSN_P. (memref_used_between_p): Likewise. (update_equiv_regs): Likewise. (block_alloc): Likewise. (no_conflict_p): Likewise. * loop.c (scan_loop): Use INSN_P. (find_and_verify_loops): Likewise. (count_loop_regs_set): Likewise. (loop_reg_used_before_p): Likewise. (strength_reduce): Likewise. (recombine_givs): Likewise. (check_dbra_loop): Likewise. (load_mems): Likewise. (try_copy_prop): Likewise. * print-rtl.c (print_rtx): Use INSN_P. * recog.c (find_single_use): Use INSN_P. * reg-stack.c (stack_regs_mentioned): Use INSN_P. (next_flags_user): Likewise. (swap_rtx_condition): Likewise. * regmove.c (mark_flags_life_zones): Use INSN_P. (optimize_reg_copy_1): Likewise. (optimize_reg_copy_2): Likewise. (optimize_reg_copy_3): Likewise. (reg_is_remote_constant_p): Likewise. (fixup_match_2): Likewise. (regmove_optimize): Likewise. (fixup_match_1): Likewise. * regrename.c (build_def_use): Use INSN_P. (replace_reg_in_block): Likewise. (consider_use): Likewise. * reload.c (find_equiv_reg): Use INSN_P. * reload1.c (reload): Use INSN_P. (maybe_fix_stack_asms): Likewise. (calculate_needs_all_insns): Likewise. (reload_as_needed): Likewise. (emit_output_reload_insns): Likewise. (delete_address_reloads_1): Likewise. (reload_cse_regs_1): Likewise. (reload_combine): Likewise. (reload_cse_move2add): Likewise. * reorg.c (redundant_insn): Use INSN_P. (dbr_schedule): Likewise. * resource.c (find_dead_or_set_registers): Use INSN_P. (mark_target_live_regs): Likewise. * rtlanal.c (reg_used_between_p): Use INSN_P. (reg_referenced_between_p): Likewise. (reg_set_between_p): Likewise. (reg_set_p): Likewise. (single_set): Likewise. (multiple_sets): Likewise. (find_last_value): Likewise. (reg_set_last): Likewise. (find_reg_note): Likewise. (find_regno_note): Likewise. * sibcall.c (sequence_uses_addressof): Use INSN_P. * simplify-rtx.c (cselib_process_insn): Use INSN_P. * ssa.c (find_evaluations): Use INSN_P. (rename_block): Likewise. (rename_equivalent_regs): Likewise. * unroll.c (loop_find_equiv_value): Use INSN_P. (set_dominates_use): Likewise. * varasm.c (mark_constant_pool): Use INSN_P. (mark_constants): Likewise. * config/alpha/alpha.c (alpha_does_function_need_gp): Use INSN_P. (alphaev4_next_group): Likewise. (alphaev5_next_group): Likewise. * config/c4x/c4x.c (c4x_process_after_reload): Use INSN_P. (c4x_rptb_rpts_p): Likewise. * config/mips/mips.c (mips16_optimize_gp): Use INSN_P. * config/rs6000/rs6000.c (uses_TOC): Use INSN_P. (rs6000_adjust_priority): Likewise. * config/sh/sh.c (sh_loop_align): Use INSN_P. (machine_dependent_reorg): Likewise. (split_branches): Likewise. * config/tahoe/tahoe.c (tahoe_cmp_check): Use INSN_P. From-SVN: r35494
2000-08-04 22:28:08 +02:00
if (INSN_P (insn))
1992-02-01 09:24:22 +01:00
{
++count;
/* Record registers that have exactly one use. */
find_single_use_in_loop (insn, PATTERN (insn), single_usage);
1992-02-01 09:24:22 +01:00
/* Include uses in REG_EQUAL notes. */
if (REG_NOTES (insn))
find_single_use_in_loop (insn, REG_NOTES (insn), single_usage);
1992-02-01 09:24:22 +01:00
if (GET_CODE (PATTERN (insn)) == SET
|| GET_CODE (PATTERN (insn)) == CLOBBER)
count_one_set (regs, insn, PATTERN (insn), may_not_move, last_set);
1992-02-01 09:24:22 +01:00
else if (GET_CODE (PATTERN (insn)) == PARALLEL)
{
register int i;
for (i = XVECLEN (PATTERN (insn), 0) - 1; i >= 0; i--)
count_one_set (regs, insn, XVECEXP (PATTERN (insn), 0, i),
may_not_move, last_set);
1992-02-01 09:24:22 +01:00
}
}
1992-02-01 09:24:22 +01:00
if (GET_CODE (insn) == CODE_LABEL || GET_CODE (insn) == JUMP_INSN)
alias.c [...] (init_alias_analysis, [...]): Use memset () instead of bzero (). * alias.c (init_alias_analysis), calls.c (expand_call, emit_library_call_value_1), combine.c (init_reg_last_arrays), cse.c (new_basic_block), dbxout.c (dbxout_type), diagnostic.c (init_output_buffer, set_diagnostic_context), dwarf2out.c (equate_decl_number_to_die, build_abbrev_table), emit-rtl.c (init_emit_once), fold-const.c (mul_double, div_and_round_double), function.c (assign_parms), gcse.c (compute_can_copy, alloc_gcse_mem, alloc_reg_set_mem, record_one_set, compute_hash_table, compute_set_hash_table, compute_expr_hash_table), genattrtab.c (optimize_attrs), global.c (global_alloc, global_conflicts), haifa-sched.c (compute_trg_info, clear_units, schedule_block), integrate.c (initialize_for_inline, expand_inline_function), jump.c (thread_jumps), local-alloc.c (local_alloc), loop.c (combine_movables, count_loop_regs_set, load_mems_and_recount_loop_regs_set), print-tree.c (debug_tree), regclass.c (init_reg_sets, init_reg_sets_1, regclass, record_reg_classes, allocate_reg_info), reload.c (get_secondary_mem, remove_address_replacements, find_reloads), reload1.c (reload, set_initial_label_offsets, finish_spills, reload_as_needed, choose_reload_regs_init, reload_cse_simplify_operands), reorg.c (dbr_schedule), sbitmap.c (sbitmap_zero), simplify-rtx.c (simplify_plus_minus), ssa.c (rename_registers), stmt.c (expand_end_case), unroll.c (unroll_loop), varray.c (varray_grow), objc/objc-act.c: Use memset () instead of bzero (). ch: * actions.c (check_missing_cases), typeck.c (build_chill_slice, build_chill_cast): Use memset () instead of bzero (). cp: * class.c (duplicate_tag_error, build_vtbl_initializer), decl.c (push_binding_level), error.c (cp_tree_printer), pt.c (process_partial_specialization, tsubst_template_arg_vector), search.c (lookup_member): Use memset () instead of bzero (). java: * expr.c (note_instructions), jcf-io.c (find_class), jcf-parse.c (init_outgoing_cpool), lex.c (java_init_lex): Use memset () instead of bzero (). From-SVN: r37303
2000-11-07 23:50:06 +01:00
memset ((char *) last_set, 0, nregs * sizeof (rtx));
1992-02-01 09:24:22 +01:00
}
*count_ptr = count;
/* Clean up. */
free (last_set);
1992-02-01 09:24:22 +01:00
}
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
/* Given a loop that is bounded by LOOP->START and LOOP->END and that
is entered at LOOP->SCAN_START, return 1 if the register set in SET
contained in insn INSN is used by any insn that precedes INSN in
cyclic order starting from the loop entry point.
1992-02-01 09:24:22 +01:00
We don't want to use INSN_LUID here because if we restrict INSN to those
that have a valid INSN_LUID, it means we cannot move an invariant out
from an inner loop past two loops. */
static int
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
loop_reg_used_before_p (loop, set, insn)
const struct loop *loop;
rtx set, insn;
1992-02-01 09:24:22 +01:00
{
rtx reg = SET_DEST (set);
rtx p;
/* Scan forward checking for register usage. If we hit INSN, we
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
are done. Otherwise, if we hit LOOP->END, wrap around to LOOP->START. */
for (p = loop->scan_start; p != insn; p = NEXT_INSN (p))
1992-02-01 09:24:22 +01:00
{
alias.c (mark_constant_function): Use INSN_P. * alias.c (mark_constant_function): Use INSN_P. (init_alias_analysis): Likewise. * combine.c (combine_instructions): Use INSN_P. (can_combine_p): Likewise. (try_combine): Likewise. (distribute_notes): Likewise. (distribute_links): Likewise. * cse.c (cse_around_loop): Use INSN_P. (invalidate_skipped_block): Likewise. (cse_set_around_loop): Likewise. (cse_end_of_basic_block): Likewise. (delete_trivially_dead_insns): Likewise. * emit-rtl.c (unshare_all_rtl_again): Use INSN_P. (unshare_all_rtl_1): Likewise. (next_cc0_user): Likewise. (try_split make_insn_raw): Likewise. (remove_unnecessary_notes): Likewise. * final.c (shorten_branches): Use INSN_P. (leaf_renumber_regs): Likewise. (leaf_renumber_regs_insn): Likewise. * flow.c (find_label_refs): Use INSN_P. (verify_wide_reg): Likewise. (notice_stack_pointer_modification): Likewise. (count_or_remove_death_notes): Likewise. (verify_flow_info): Likewise. (clear_log_links): Likewise. * function.c (fixup_var_refs_insns): Use INSN_P. (compute_insns_for_mem): Likewise. * gcse.c (alloc_gcse_mem): Use INSN_P. (compute_sets): Likewise. (compute_hash_table): Likewise. (classic_gcse): Likewise. (cprop): Likewise. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks_1): Likewise. * global.c (expand_preferences): Use INSN_P. (build_insn_chain): Likewise. * graph.c (node_data): Use INSN_P. * haifa-sched.c (priority): Use INSN_P. (rm_line_notes): Likewise. (rm_other_notes): Likewise. (find_insn_reg_weight): Likewise. (init_target_units): Likewise. (schedule_block): Likewise. (compute_block_forward_dependences): Likewise. (debug_dependencies): Likewise. (set_priorities): Likewise. * integrate.c (function_cannot_inline_p): Use INSN_P. (save_parm_insns): Likewise. (copy_insn_list): Likewise. * jump.c (mark_all_labels): Use INSN_P. (never_reached_warning): Likewise. * lcm.c (optimize_mode_switching): Use INSN_P. * local-alloc.c (validate_equiv_mem): Use INSN_P. (memref_used_between_p): Likewise. (update_equiv_regs): Likewise. (block_alloc): Likewise. (no_conflict_p): Likewise. * loop.c (scan_loop): Use INSN_P. (find_and_verify_loops): Likewise. (count_loop_regs_set): Likewise. (loop_reg_used_before_p): Likewise. (strength_reduce): Likewise. (recombine_givs): Likewise. (check_dbra_loop): Likewise. (load_mems): Likewise. (try_copy_prop): Likewise. * print-rtl.c (print_rtx): Use INSN_P. * recog.c (find_single_use): Use INSN_P. * reg-stack.c (stack_regs_mentioned): Use INSN_P. (next_flags_user): Likewise. (swap_rtx_condition): Likewise. * regmove.c (mark_flags_life_zones): Use INSN_P. (optimize_reg_copy_1): Likewise. (optimize_reg_copy_2): Likewise. (optimize_reg_copy_3): Likewise. (reg_is_remote_constant_p): Likewise. (fixup_match_2): Likewise. (regmove_optimize): Likewise. (fixup_match_1): Likewise. * regrename.c (build_def_use): Use INSN_P. (replace_reg_in_block): Likewise. (consider_use): Likewise. * reload.c (find_equiv_reg): Use INSN_P. * reload1.c (reload): Use INSN_P. (maybe_fix_stack_asms): Likewise. (calculate_needs_all_insns): Likewise. (reload_as_needed): Likewise. (emit_output_reload_insns): Likewise. (delete_address_reloads_1): Likewise. (reload_cse_regs_1): Likewise. (reload_combine): Likewise. (reload_cse_move2add): Likewise. * reorg.c (redundant_insn): Use INSN_P. (dbr_schedule): Likewise. * resource.c (find_dead_or_set_registers): Use INSN_P. (mark_target_live_regs): Likewise. * rtlanal.c (reg_used_between_p): Use INSN_P. (reg_referenced_between_p): Likewise. (reg_set_between_p): Likewise. (reg_set_p): Likewise. (single_set): Likewise. (multiple_sets): Likewise. (find_last_value): Likewise. (reg_set_last): Likewise. (find_reg_note): Likewise. (find_regno_note): Likewise. * sibcall.c (sequence_uses_addressof): Use INSN_P. * simplify-rtx.c (cselib_process_insn): Use INSN_P. * ssa.c (find_evaluations): Use INSN_P. (rename_block): Likewise. (rename_equivalent_regs): Likewise. * unroll.c (loop_find_equiv_value): Use INSN_P. (set_dominates_use): Likewise. * varasm.c (mark_constant_pool): Use INSN_P. (mark_constants): Likewise. * config/alpha/alpha.c (alpha_does_function_need_gp): Use INSN_P. (alphaev4_next_group): Likewise. (alphaev5_next_group): Likewise. * config/c4x/c4x.c (c4x_process_after_reload): Use INSN_P. (c4x_rptb_rpts_p): Likewise. * config/mips/mips.c (mips16_optimize_gp): Use INSN_P. * config/rs6000/rs6000.c (uses_TOC): Use INSN_P. (rs6000_adjust_priority): Likewise. * config/sh/sh.c (sh_loop_align): Use INSN_P. (machine_dependent_reorg): Likewise. (split_branches): Likewise. * config/tahoe/tahoe.c (tahoe_cmp_check): Use INSN_P. From-SVN: r35494
2000-08-04 22:28:08 +02:00
if (INSN_P (p) && reg_overlap_mentioned_p (reg, PATTERN (p)))
1992-02-01 09:24:22 +01:00
return 1;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (p == loop->end)
p = loop->start;
1992-02-01 09:24:22 +01:00
}
return 0;
}
/* A "basic induction variable" or biv is a pseudo reg that is set
(within this loop) only by incrementing or decrementing it. */
/* A "general induction variable" or giv is a pseudo reg whose
value is a linear function of a biv. */
/* Bivs are recognized by `basic_induction_var';
Givs by `general_induction_var'. */
1992-02-01 09:24:22 +01:00
/* Communication with routines called via `note_stores'. */
static rtx note_insn;
/* Dummy register to have non-zero DEST_REG for DEST_ADDR type givs. */
static rtx addr_placeholder;
/* ??? Unfinished optimizations, and possible future optimizations,
for the strength reduction code. */
/* ??? The interaction of biv elimination, and recognition of 'constant'
1996-07-04 00:07:53 +02:00
bivs, may cause problems. */
1992-02-01 09:24:22 +01:00
/* ??? Add heuristics so that DEST_ADDR strength reduction does not cause
performance problems.
Perhaps don't eliminate things that can be combined with an addressing
mode. Find all givs that have the same biv, mult_val, and add_val;
then for each giv, check to see if its only use dies in a following
memory address. If so, generate a new memory address and check to see
if it is valid. If it is valid, then store the modified memory address,
otherwise, mark the giv as not done so that it will get its own iv. */
/* ??? Could try to optimize branches when it is known that a biv is always
positive. */
/* ??? When replace a biv in a compare insn, we should replace with closest
giv so that an optimized branch can still be recognized by the combiner,
e.g. the VAX acb insn. */
/* ??? Many of the checks involving uid_luid could be simplified if regscan
was rerun in loop_optimize whenever a register was added or moved.
Also, some of the optimizations could be a little less conservative. */
/* Scan the loop body and call FNCALL for each insn. In the addition to the
LOOP and INSN parameters pass MAYBE_MULTIPLE and NOT_EVERY_ITERATION to the
callback.
NOT_EVERY_ITERATION if current insn is not executed at least once for every
loop iteration except for the last one.
MAYBE_MULTIPLE is 1 if current insn may be executed more than once for every
loop iteration.
*/
void
for_each_insn_in_loop (loop, fncall)
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
struct loop *loop;
loop_insn_callback fncall;
1992-02-01 09:24:22 +01:00
{
/* This is 1 if current insn is not executed at least once for every loop
iteration. */
int not_every_iteration = 0;
int maybe_multiple = 0;
int past_loop_latch = 0;
int loop_depth = 0;
rtx p;
1992-02-01 09:24:22 +01:00
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
/* If loop_scan_start points to the loop exit test, we have to be wary of
subversive use of gotos inside expression statements. */
if (prev_nonnote_insn (loop->scan_start) != prev_nonnote_insn (loop->start))
maybe_multiple = back_branch_in_range_p (loop, loop->scan_start);
1992-02-01 09:24:22 +01:00
/* Scan through loop to find all possible bivs. */
for (p = next_insn_in_loop (loop, loop->scan_start);
1998-08-19 14:30:47 +02:00
p != NULL_RTX;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
p = next_insn_in_loop (loop, p))
1992-02-01 09:24:22 +01:00
{
p = fncall (loop, p, not_every_iteration, maybe_multiple);
1992-02-01 09:24:22 +01:00
/* Past CODE_LABEL, we get to insns that may be executed multiple
times. The only way we can be sure that they can't is if every
jump insn between here and the end of the loop either
returns, exits the loop, is a jump to a location that is still
behind the label, or is a jump to the loop start. */
if (GET_CODE (p) == CODE_LABEL)
{
rtx insn = p;
maybe_multiple = 0;
while (1)
{
insn = NEXT_INSN (insn);
if (insn == loop->scan_start)
break;
if (insn == loop->end)
{
if (loop->top != 0)
insn = loop->top;
else
break;
if (insn == loop->scan_start)
break;
}
if (GET_CODE (insn) == JUMP_INSN
&& GET_CODE (PATTERN (insn)) != RETURN
&& (!any_condjump_p (insn)
|| (JUMP_LABEL (insn) != 0
&& JUMP_LABEL (insn) != loop->scan_start
&& !loop_insn_first_p (p, JUMP_LABEL (insn)))))
{
maybe_multiple = 1;
break;
}
}
}
/* Past a jump, we get to insns for which we can't count
on whether they will be executed during each iteration. */
/* This code appears twice in strength_reduce. There is also similar
code in scan_loop. */
if (GET_CODE (p) == JUMP_INSN
/* If we enter the loop in the middle, and scan around to the
beginning, don't set not_every_iteration for that.
This can be any kind of jump, since we want to know if insns
will be executed if the loop is executed. */
&& !(JUMP_LABEL (p) == loop->top
&& ((NEXT_INSN (NEXT_INSN (p)) == loop->end
&& any_uncondjump_p (p))
|| (NEXT_INSN (p) == loop->end && any_condjump_p (p)))))
{
rtx label = 0;
/* If this is a jump outside the loop, then it also doesn't
matter. Check to see if the target of this branch is on the
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
loop->exits_labels list. */
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
for (label = loop->exit_labels; label; label = LABEL_NEXTREF (label))
if (XEXP (label, 0) == JUMP_LABEL (p))
break;
if (!label)
not_every_iteration = 1;
}
1992-02-01 09:24:22 +01:00
else if (GET_CODE (p) == NOTE)
{
/* At the virtual top of a converted loop, insns are again known to
be executed each iteration: logically, the loop begins here
even though the exit code has been duplicated.
Insns are also again known to be executed each iteration at
the LOOP_CONT note. */
if ((NOTE_LINE_NUMBER (p) == NOTE_INSN_LOOP_VTOP
|| NOTE_LINE_NUMBER (p) == NOTE_INSN_LOOP_CONT)
&& loop_depth == 0)
not_every_iteration = 0;
else if (NOTE_LINE_NUMBER (p) == NOTE_INSN_LOOP_BEG)
loop_depth++;
else if (NOTE_LINE_NUMBER (p) == NOTE_INSN_LOOP_END)
loop_depth--;
}
1992-02-01 09:24:22 +01:00
/* Note if we pass a loop latch. If we do, then we can not clear
NOT_EVERY_ITERATION below when we pass the last CODE_LABEL in
a loop since a jump before the last CODE_LABEL may have started
a new loop iteration.
Note that LOOP_TOP is only set for rotated loops and we need
this check for all loops, so compare against the CODE_LABEL
which immediately follows LOOP_START. */
if (GET_CODE (p) == JUMP_INSN
&& JUMP_LABEL (p) == NEXT_INSN (loop->start))
past_loop_latch = 1;
1992-02-01 09:24:22 +01:00
/* Unlike in the code motion pass where MAYBE_NEVER indicates that
an insn may never be executed, NOT_EVERY_ITERATION indicates whether
or not an insn is known to be executed each iteration of the
loop, whether or not any iterations are known to occur.
1992-02-01 09:24:22 +01:00
Therefore, if we have just passed a label and have no more labels
between here and the test insn of the loop, and we have not passed
a jump to the top of the loop, then we know these insns will be
executed each iteration. */
1992-02-01 09:24:22 +01:00
if (not_every_iteration
&& !past_loop_latch
&& GET_CODE (p) == CODE_LABEL
&& no_labels_between_p (p, loop->end)
&& loop_insn_first_p (p, loop->cont))
1992-02-01 09:24:22 +01:00
not_every_iteration = 0;
}
}
/* Perform strength reduction and induction variable elimination.
Pseudo registers created during this function will be beyond the
last valid index in several tables including regs->n_times_set and
regno_last_uid. This does not cause a problem here, because the
added registers cannot be givs outside of their loop, and hence
will never be reconsidered. But scan_loop must check regnos to
make sure they are in bounds. */
static void
strength_reduce (loop, insn_count, flags)
struct loop *loop;
int insn_count;
int flags;
{
struct loop_info *loop_info = LOOP_INFO (loop);
struct loop_regs *regs = LOOP_REGS (loop);
struct loop_ivs *ivs = LOOP_IVS (loop);
rtx p;
/* Temporary list pointers for traversing ivs->loop_iv_list. */
struct iv_class *bl, **backbl;
/* Ratio of extra register life span we can justify
for saving an instruction. More if loop doesn't call subroutines
since in that case saving an insn makes more difference
and more registers are available. */
/* ??? could set this to last value of threshold in move_movables */
int threshold = (loop_info->has_call ? 1 : 2) * (3 + n_non_fixed_regs);
/* Map of pseudo-register replacements. */
rtx *reg_map = NULL;
int reg_map_size;
int call_seen;
rtx test;
rtx end_insert_before;
int unrolled_insn_copies = 0;
rtx loop_start = loop->start;
rtx loop_end = loop->end;
rtx test_reg = gen_rtx_REG (word_mode, LAST_VIRTUAL_REGISTER + 1);
VARRAY_INT_INIT (ivs->reg_iv_type, max_reg_before_loop, "reg_iv_type");
VARRAY_GENERIC_PTR_INIT (ivs->reg_iv_info, max_reg_before_loop, "reg_iv_info");
ivs->reg_biv_class = (struct iv_class **)
xcalloc (max_reg_before_loop, sizeof (struct iv_class *));
ivs->loop_iv_list = 0;
addr_placeholder = gen_reg_rtx (Pmode);
/* Save insn immediately after the loop_end. Insns inserted after loop_end
must be put before this insn, so that they will appear in the right
order (i.e. loop order).
If loop_end is the end of the current function, then emit a
NOTE_INSN_DELETED after loop_end and set end_insert_before to the
dummy note insn. */
if (NEXT_INSN (loop_end) != 0)
end_insert_before = NEXT_INSN (loop_end);
else
end_insert_before = emit_note_after (NOTE_INSN_DELETED, loop_end);
for_each_insn_in_loop (loop, check_insn_for_bivs);
1992-02-01 09:24:22 +01:00
/* Scan ivs->loop_iv_list to remove all regs that proved not to be bivs.
Make a sanity check against regs->n_times_set. */
for (backbl = &ivs->loop_iv_list, bl = *backbl; bl; bl = bl->next)
1992-02-01 09:24:22 +01:00
{
if (REG_IV_TYPE (ivs, bl->regno) != BASIC_INDUCT
1992-02-01 09:24:22 +01:00
/* Above happens if register modified by subreg, etc. */
/* Make sure it is not recognized as a basic induction var: */
|| VARRAY_INT (regs->n_times_set, bl->regno) != bl->biv_count
1992-02-01 09:24:22 +01:00
/* If never incremented, it is invariant that we decided not to
move. So leave it alone. */
|| ! bl->incremented)
{
if (loop_dump_stream)
fprintf (loop_dump_stream, "Reg %d: biv discarded, %s\n",
bl->regno,
(REG_IV_TYPE (ivs, bl->regno) != BASIC_INDUCT
1992-02-01 09:24:22 +01:00
? "not induction variable"
: (! bl->incremented ? "never incremented"
: "count error")));
REG_IV_TYPE (ivs, bl->regno) = NOT_BASIC_INDUCT;
1992-02-01 09:24:22 +01:00
*backbl = bl->next;
}
else
{
backbl = &bl->next;
if (loop_dump_stream)
fprintf (loop_dump_stream, "Reg %d: biv verified\n", bl->regno);
}
}
/* Exit if there are no bivs. */
if (! ivs->loop_iv_list)
1992-02-01 09:24:22 +01:00
{
/* Can still unroll the loop anyways, but indicate that there is no
strength reduction info available. */
if (flags & LOOP_UNROLL)
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
unroll_loop (loop, insn_count, end_insert_before, 0);
1992-02-01 09:24:22 +01:00
goto egress;
1992-02-01 09:24:22 +01:00
}
/* Find initial value for each biv by searching backwards from loop_start,
halting at first label. Also record any test condition. */
call_seen = 0;
for (p = loop_start; p && GET_CODE (p) != CODE_LABEL; p = PREV_INSN (p))
{
note_insn = p;
if (GET_CODE (p) == CALL_INSN)
call_seen = 1;
if (INSN_P (p))
note_stores (PATTERN (p), record_initial, ivs);
1992-02-01 09:24:22 +01:00
/* Record any test of a biv that branches around the loop if no store
between it and the start of loop. We only care about tests with
constants and registers and only certain of those. */
if (GET_CODE (p) == JUMP_INSN
&& JUMP_LABEL (p) != 0
&& next_real_insn (JUMP_LABEL (p)) == next_real_insn (loop_end)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
&& (test = get_condition_for_loop (loop, p)) != 0
1992-02-01 09:24:22 +01:00
&& GET_CODE (XEXP (test, 0)) == REG
&& REGNO (XEXP (test, 0)) < max_reg_before_loop
&& (bl = ivs->reg_biv_class[REGNO (XEXP (test, 0))]) != 0
1992-02-01 09:24:22 +01:00
&& valid_initial_value_p (XEXP (test, 1), p, call_seen, loop_start)
&& bl->init_insn == 0)
{
/* If an NE test, we have an initial value! */
if (GET_CODE (test) == NE)
{
bl->init_insn = p;
bl->init_set = gen_rtx_SET (VOIDmode,
XEXP (test, 0), XEXP (test, 1));
1992-02-01 09:24:22 +01:00
}
else
bl->initial_test = test;
}
}
/* Look at the each biv and see if we can say anything better about its
initial value from any initializing insns set up above. (This is done
in two passes to avoid missing SETs in a PARALLEL.) */
for (backbl = &ivs->loop_iv_list; (bl = *backbl); backbl = &bl->next)
1992-02-01 09:24:22 +01:00
{
rtx src;
1997-12-07 01:31:01 +01:00
rtx note;
1992-02-01 09:24:22 +01:00
if (! bl->init_insn)
continue;
1997-12-07 01:31:01 +01:00
/* IF INIT_INSN has a REG_EQUAL or REG_EQUIV note and the value
is a constant, use the value of that. */
if (((note = find_reg_note (bl->init_insn, REG_EQUAL, 0)) != NULL
&& CONSTANT_P (XEXP (note, 0)))
|| ((note = find_reg_note (bl->init_insn, REG_EQUIV, 0)) != NULL
&& CONSTANT_P (XEXP (note, 0))))
src = XEXP (note, 0);
else
src = SET_SRC (bl->init_set);
1992-02-01 09:24:22 +01:00
if (loop_dump_stream)
fprintf (loop_dump_stream,
"Biv %d initialized at insn %d: initial value ",
bl->regno, INSN_UID (bl->init_insn));
if ((GET_MODE (src) == GET_MODE (regno_reg_rtx[bl->regno])
|| GET_MODE (src) == VOIDmode)
&& valid_initial_value_p (src, bl->init_insn, call_seen, loop_start))
1992-02-01 09:24:22 +01:00
{
bl->initial_value = src;
if (loop_dump_stream)
{
if (GET_CODE (src) == CONST_INT)
{
fprintf (loop_dump_stream, HOST_WIDE_INT_PRINT_DEC, INTVAL (src));
fputc ('\n', loop_dump_stream);
}
1992-02-01 09:24:22 +01:00
else
{
print_rtl (loop_dump_stream, src);
fprintf (loop_dump_stream, "\n");
}
}
}
2000-09-19 18:01:13 +02:00
/* If we can't make it a giv,
let biv keep initial value of "itself". */
else if (loop_dump_stream)
fprintf (loop_dump_stream, "is complex\n");
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
}
1992-02-01 09:24:22 +01:00
/* Search the loop for general induction variables. */
for_each_insn_in_loop (loop, check_insn_for_givs);
1992-02-01 09:24:22 +01:00
/* Try to calculate and save the number of loop iterations. This is
set to zero if the actual number can not be calculated. This must
be called after all giv's have been identified, since otherwise it may
fail if the iteration variable is a giv. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
loop_iterations (loop);
1992-02-01 09:24:22 +01:00
/* Now for each giv for which we still don't know whether or not it is
replaceable, check to see if it is replaceable because its final value
can be calculated. This must be done after loop_iterations is called,
so that final_giv_value will work correctly. */
for (bl = ivs->loop_iv_list; bl; bl = bl->next)
1992-02-01 09:24:22 +01:00
{
struct induction *v;
for (v = bl->giv; v; v = v->next_iv)
if (! v->replaceable && ! v->not_replaceable)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
check_final_value (loop, v);
1992-02-01 09:24:22 +01:00
}
/* Try to prove that the loop counter variable (if any) is always
nonnegative; if so, record that fact with a REG_NONNEG note
so that "decrement and branch until zero" insn can be used. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
check_dbra_loop (loop, insn_count);
1992-02-01 09:24:22 +01:00
/* Create reg_map to hold substitutions for replaceable giv regs.
Some givs might have been made from biv increments, so look at
ivs->reg_iv_type for a suitable size. */
reg_map_size = ivs->reg_iv_type->num_elements;
reg_map = (rtx *) xcalloc (reg_map_size, sizeof (rtx));
1992-02-01 09:24:22 +01:00
/* Examine each iv class for feasibility of strength reduction/induction
variable elimination. */
for (bl = ivs->loop_iv_list; bl; bl = bl->next)
1992-02-01 09:24:22 +01:00
{
struct induction *v;
int benefit;
int all_reduced;
rtx final_value = 0;
/* Test whether it will be possible to eliminate this biv
provided all givs are reduced. This is possible if either
the reg is not used outside the loop, or we can compute
what its final value will be.
For architectures with a decrement_and_branch_until_zero insn,
don't do this if we put a REG_NONNEG note on the endtest for
this biv. */
/* Compare against bl->init_insn rather than loop_start.
We aren't concerned with any uses of the biv between
init_insn and loop_start since these won't be affected
by the value of the biv elsewhere in the function, so
long as init_insn doesn't use the biv itself.
March 14, 1989 -- self@bayes.arc.nasa.gov */
if ((uid_luid[REGNO_LAST_UID (bl->regno)] < INSN_LUID (loop_end)
1992-02-01 09:24:22 +01:00
&& bl->init_insn
&& INSN_UID (bl->init_insn) < max_uid_for_loop
&& uid_luid[REGNO_FIRST_UID (bl->regno)] >= INSN_LUID (bl->init_insn)
1992-02-01 09:24:22 +01:00
#ifdef HAVE_decrement_and_branch_until_zero
&& ! bl->nonneg
#endif
&& ! reg_mentioned_p (bl->biv->dest_reg, SET_SRC (bl->init_set)))
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
|| ((final_value = final_biv_value (loop, bl))
1992-02-01 09:24:22 +01:00
#ifdef HAVE_decrement_and_branch_until_zero
&& ! bl->nonneg
#endif
))
bl->eliminable = maybe_eliminate_biv (loop, bl, 0, threshold,
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
insn_count);
1992-02-01 09:24:22 +01:00
else
{
if (loop_dump_stream)
{
fprintf (loop_dump_stream,
"Cannot eliminate biv %d.\n",
bl->regno);
fprintf (loop_dump_stream,
"First use: insn %d, last use: insn %d.\n",
REGNO_FIRST_UID (bl->regno),
REGNO_LAST_UID (bl->regno));
1992-02-01 09:24:22 +01:00
}
}
/* Check each extension dependant giv in this class to see if its
root biv is safe from wrapping in the interior mode. */
check_ext_dependant_givs (bl, loop_info);
1992-02-01 09:24:22 +01:00
/* Combine all giv's for this iv_class. */
combine_givs (regs, bl);
1992-02-01 09:24:22 +01:00
/* This will be true at the end, if all givs which depend on this
biv have been strength reduced.
We can't (currently) eliminate the biv unless this is so. */
all_reduced = 1;
/* Check each giv in this class to see if we will benefit by reducing
it. Skip giv's combined with others. */
for (v = bl->giv; v; v = v->next_iv)
{
struct induction *tv;
int add_cost;
1992-02-01 09:24:22 +01:00
if (v->ignore || v->same)
continue;
benefit = v->benefit;
PUT_MODE (test_reg, v->mode);
add_cost = iv_add_mult_cost (bl->biv->add_val, v->mult_val,
test_reg, test_reg);
1992-02-01 09:24:22 +01:00
/* Reduce benefit if not replaceable, since we will insert
a move-insn to replace the insn that calculates this giv.
Don't do this unless the giv is a user variable, since it
will often be marked non-replaceable because of the duplication
of the exit code outside the loop. In such a case, the copies
we insert are dead and will be deleted. So they don't have
a cost. Similar situations exist. */
/* ??? The new final_[bg]iv_value code does a much better job
of finding replaceable giv's, and hence this code may no longer
be necessary. */
if (! v->replaceable && ! bl->eliminable
&& REG_USERVAR_P (v->dest_reg))
benefit -= copy_cost;
/* Decrease the benefit to count the add-insns that we will
insert to increment the reduced reg for the giv.
??? This can overestimate the run-time cost of the additional
insns, e.g. if there are multiple basic blocks that increment
the biv, but only one of these blocks is executed during each
iteration. There is no good way to detect cases like this with
the current structure of the loop optimizer.
This code is more accurate for determining code size than
run-time benefits. */
1992-02-01 09:24:22 +01:00
benefit -= add_cost * bl->biv_count;
/* Decide whether to strength-reduce this giv or to leave the code
unchanged (recompute it from the biv each time it is used).
This decision can be made independently for each giv. */
#ifdef AUTO_INC_DEC
/* Attempt to guess whether autoincrement will handle some of the
new add insns; if so, increase BENEFIT (undo the subtraction of
add_cost that was done above). */
if (v->giv_type == DEST_ADDR
/* Increasing the benefit is risky, since this is only a guess.
Avoid increasing register pressure in cases where there would
be no other benefit from reducing this giv. */
&& benefit > 0
&& GET_CODE (v->mult_val) == CONST_INT)
{
if (HAVE_POST_INCREMENT
&& INTVAL (v->mult_val) == GET_MODE_SIZE (v->mem_mode))
benefit += add_cost * bl->biv_count;
else if (HAVE_PRE_INCREMENT
&& INTVAL (v->mult_val) == GET_MODE_SIZE (v->mem_mode))
benefit += add_cost * bl->biv_count;
else if (HAVE_POST_DECREMENT
&& -INTVAL (v->mult_val) == GET_MODE_SIZE (v->mem_mode))
benefit += add_cost * bl->biv_count;
else if (HAVE_PRE_DECREMENT
&& -INTVAL (v->mult_val) == GET_MODE_SIZE (v->mem_mode))
benefit += add_cost * bl->biv_count;
}
#endif
1992-02-01 09:24:22 +01:00
/* If an insn is not to be strength reduced, then set its ignore
flag, and clear all_reduced. */
/* A giv that depends on a reversed biv must be reduced if it is
used after the loop exit, otherwise, it would have the wrong
value after the loop exit. To make it simple, just reduce all
of such giv's whether or not we know they are used after the loop
exit. */
if ( ! flag_reduce_all_givs && v->lifetime * threshold * benefit < insn_count
&& ! bl->reversed )
1992-02-01 09:24:22 +01:00
{
if (loop_dump_stream)
fprintf (loop_dump_stream,
"giv of insn %d not worth while, %d vs %d.\n",
INSN_UID (v->insn),
v->lifetime * threshold * benefit, insn_count);
v->ignore = 1;
all_reduced = 0;
}
else
{
/* Check that we can increment the reduced giv without a
multiply insn. If not, reject it. */
for (tv = bl->biv; tv; tv = tv->next_iv)
if (tv->mult_val == const1_rtx
&& ! product_cheap_p (tv->add_val, v->mult_val))
{
if (loop_dump_stream)
fprintf (loop_dump_stream,
"giv of insn %d: would need a multiply.\n",
INSN_UID (v->insn));
v->ignore = 1;
all_reduced = 0;
break;
}
}
}
/* Check for givs whose first use is their definition and whose
last use is the definition of another giv. If so, it is likely
dead and should not be used to derive another giv nor to
eliminate a biv. */
for (v = bl->giv; v; v = v->next_iv)
{
if (v->ignore
|| (v->same && v->same->ignore))
continue;
2000-09-19 18:01:13 +02:00
if (v->giv_type == DEST_REG
&& REGNO_FIRST_UID (REGNO (v->dest_reg)) == INSN_UID (v->insn))
{
struct induction *v1;
for (v1 = bl->giv; v1; v1 = v1->next_iv)
if (REGNO_LAST_UID (REGNO (v->dest_reg)) == INSN_UID (v1->insn))
v->maybe_dead = 1;
}
}
1992-02-01 09:24:22 +01:00
/* Reduce each giv that we decided to reduce. */
for (v = bl->giv; v; v = v->next_iv)
{
struct induction *tv;
if (! v->ignore && v->same == 0)
{
int auto_inc_opt = 0;
/* If the code for derived givs immediately below has already
allocated a new_reg, we must keep it. */
if (! v->new_reg)
v->new_reg = gen_reg_rtx (v->mode);
1992-02-01 09:24:22 +01:00
#ifdef AUTO_INC_DEC
/* If the target has auto-increment addressing modes, and
this is an address giv, then try to put the increment
immediately after its use, so that flow can create an
auto-increment addressing mode. */
if (v->giv_type == DEST_ADDR && bl->biv_count == 1
&& bl->biv->always_executed && ! bl->biv->maybe_multiple
/* We don't handle reversed biv's because bl->biv->insn
does not have a valid INSN_LUID. */
&& ! bl->reversed
&& v->always_executed && ! v->maybe_multiple
&& INSN_UID (v->insn) < max_uid_for_loop)
{
/* If other giv's have been combined with this one, then
this will work only if all uses of the other giv's occur
before this giv's insn. This is difficult to check.
We simplify this by looking for the common case where
there is one DEST_REG giv, and this giv's insn is the
last use of the dest_reg of that DEST_REG giv. If the
1998-05-06 23:09:07 +02:00
increment occurs after the address giv, then we can
perform the optimization. (Otherwise, the increment
would have to go before other_giv, and we would not be
able to combine it with the address giv to get an
auto-inc address.) */
if (v->combined_with)
{
struct induction *other_giv = 0;
for (tv = bl->giv; tv; tv = tv->next_iv)
if (tv->same == v)
{
if (other_giv)
break;
else
other_giv = tv;
}
if (! tv && other_giv
&& REGNO (other_giv->dest_reg) < max_reg_before_loop
&& (REGNO_LAST_UID (REGNO (other_giv->dest_reg))
== INSN_UID (v->insn))
&& INSN_LUID (v->insn) < INSN_LUID (bl->biv->insn))
auto_inc_opt = 1;
}
1998-05-06 23:09:07 +02:00
/* Check for case where increment is before the address
giv. Do this test in "loop order". */
else if ((INSN_LUID (v->insn) > INSN_LUID (bl->biv->insn)
2000-09-19 18:01:13 +02:00
&& (INSN_LUID (v->insn) < INSN_LUID (loop->scan_start)
|| (INSN_LUID (bl->biv->insn)
2000-09-19 18:01:13 +02:00
> INSN_LUID (loop->scan_start))))
|| (INSN_LUID (v->insn) < INSN_LUID (loop->scan_start)
&& (INSN_LUID (loop->scan_start)
< INSN_LUID (bl->biv->insn))))
auto_inc_opt = -1;
else
auto_inc_opt = 1;
#ifdef HAVE_cc0
{
rtx prev;
/* We can't put an insn immediately after one setting
cc0, or immediately before one using cc0. */
if ((auto_inc_opt == 1 && sets_cc0_p (PATTERN (v->insn)))
|| (auto_inc_opt == -1
&& (prev = prev_nonnote_insn (v->insn)) != 0
alias.c (mark_constant_function): Use INSN_P. * alias.c (mark_constant_function): Use INSN_P. (init_alias_analysis): Likewise. * combine.c (combine_instructions): Use INSN_P. (can_combine_p): Likewise. (try_combine): Likewise. (distribute_notes): Likewise. (distribute_links): Likewise. * cse.c (cse_around_loop): Use INSN_P. (invalidate_skipped_block): Likewise. (cse_set_around_loop): Likewise. (cse_end_of_basic_block): Likewise. (delete_trivially_dead_insns): Likewise. * emit-rtl.c (unshare_all_rtl_again): Use INSN_P. (unshare_all_rtl_1): Likewise. (next_cc0_user): Likewise. (try_split make_insn_raw): Likewise. (remove_unnecessary_notes): Likewise. * final.c (shorten_branches): Use INSN_P. (leaf_renumber_regs): Likewise. (leaf_renumber_regs_insn): Likewise. * flow.c (find_label_refs): Use INSN_P. (verify_wide_reg): Likewise. (notice_stack_pointer_modification): Likewise. (count_or_remove_death_notes): Likewise. (verify_flow_info): Likewise. (clear_log_links): Likewise. * function.c (fixup_var_refs_insns): Use INSN_P. (compute_insns_for_mem): Likewise. * gcse.c (alloc_gcse_mem): Use INSN_P. (compute_sets): Likewise. (compute_hash_table): Likewise. (classic_gcse): Likewise. (cprop): Likewise. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks_1): Likewise. * global.c (expand_preferences): Use INSN_P. (build_insn_chain): Likewise. * graph.c (node_data): Use INSN_P. * haifa-sched.c (priority): Use INSN_P. (rm_line_notes): Likewise. (rm_other_notes): Likewise. (find_insn_reg_weight): Likewise. (init_target_units): Likewise. (schedule_block): Likewise. (compute_block_forward_dependences): Likewise. (debug_dependencies): Likewise. (set_priorities): Likewise. * integrate.c (function_cannot_inline_p): Use INSN_P. (save_parm_insns): Likewise. (copy_insn_list): Likewise. * jump.c (mark_all_labels): Use INSN_P. (never_reached_warning): Likewise. * lcm.c (optimize_mode_switching): Use INSN_P. * local-alloc.c (validate_equiv_mem): Use INSN_P. (memref_used_between_p): Likewise. (update_equiv_regs): Likewise. (block_alloc): Likewise. (no_conflict_p): Likewise. * loop.c (scan_loop): Use INSN_P. (find_and_verify_loops): Likewise. (count_loop_regs_set): Likewise. (loop_reg_used_before_p): Likewise. (strength_reduce): Likewise. (recombine_givs): Likewise. (check_dbra_loop): Likewise. (load_mems): Likewise. (try_copy_prop): Likewise. * print-rtl.c (print_rtx): Use INSN_P. * recog.c (find_single_use): Use INSN_P. * reg-stack.c (stack_regs_mentioned): Use INSN_P. (next_flags_user): Likewise. (swap_rtx_condition): Likewise. * regmove.c (mark_flags_life_zones): Use INSN_P. (optimize_reg_copy_1): Likewise. (optimize_reg_copy_2): Likewise. (optimize_reg_copy_3): Likewise. (reg_is_remote_constant_p): Likewise. (fixup_match_2): Likewise. (regmove_optimize): Likewise. (fixup_match_1): Likewise. * regrename.c (build_def_use): Use INSN_P. (replace_reg_in_block): Likewise. (consider_use): Likewise. * reload.c (find_equiv_reg): Use INSN_P. * reload1.c (reload): Use INSN_P. (maybe_fix_stack_asms): Likewise. (calculate_needs_all_insns): Likewise. (reload_as_needed): Likewise. (emit_output_reload_insns): Likewise. (delete_address_reloads_1): Likewise. (reload_cse_regs_1): Likewise. (reload_combine): Likewise. (reload_cse_move2add): Likewise. * reorg.c (redundant_insn): Use INSN_P. (dbr_schedule): Likewise. * resource.c (find_dead_or_set_registers): Use INSN_P. (mark_target_live_regs): Likewise. * rtlanal.c (reg_used_between_p): Use INSN_P. (reg_referenced_between_p): Likewise. (reg_set_between_p): Likewise. (reg_set_p): Likewise. (single_set): Likewise. (multiple_sets): Likewise. (find_last_value): Likewise. (reg_set_last): Likewise. (find_reg_note): Likewise. (find_regno_note): Likewise. * sibcall.c (sequence_uses_addressof): Use INSN_P. * simplify-rtx.c (cselib_process_insn): Use INSN_P. * ssa.c (find_evaluations): Use INSN_P. (rename_block): Likewise. (rename_equivalent_regs): Likewise. * unroll.c (loop_find_equiv_value): Use INSN_P. (set_dominates_use): Likewise. * varasm.c (mark_constant_pool): Use INSN_P. (mark_constants): Likewise. * config/alpha/alpha.c (alpha_does_function_need_gp): Use INSN_P. (alphaev4_next_group): Likewise. (alphaev5_next_group): Likewise. * config/c4x/c4x.c (c4x_process_after_reload): Use INSN_P. (c4x_rptb_rpts_p): Likewise. * config/mips/mips.c (mips16_optimize_gp): Use INSN_P. * config/rs6000/rs6000.c (uses_TOC): Use INSN_P. (rs6000_adjust_priority): Likewise. * config/sh/sh.c (sh_loop_align): Use INSN_P. (machine_dependent_reorg): Likewise. (split_branches): Likewise. * config/tahoe/tahoe.c (tahoe_cmp_check): Use INSN_P. From-SVN: r35494
2000-08-04 22:28:08 +02:00
&& INSN_P (prev)
&& sets_cc0_p (PATTERN (prev))))
auto_inc_opt = 0;
}
#endif
if (auto_inc_opt)
v->auto_inc_opt = 1;
}
#endif
/* For each place where the biv is incremented, add an insn
to increment the new, reduced reg for the giv. */
1992-02-01 09:24:22 +01:00
for (tv = bl->biv; tv; tv = tv->next_iv)
{
rtx insert_before;
if (! auto_inc_opt)
insert_before = tv->insn;
else if (auto_inc_opt == 1)
insert_before = NEXT_INSN (v->insn);
else
insert_before = v->insn;
1992-02-01 09:24:22 +01:00
if (tv->mult_val == const1_rtx)
emit_iv_add_mult (tv->add_val, v->mult_val,
v->new_reg, v->new_reg, insert_before);
1992-02-01 09:24:22 +01:00
else /* tv->mult_val == const0_rtx */
/* A multiply is acceptable here
since this is presumed to be seldom executed. */
emit_iv_add_mult (tv->add_val, v->mult_val,
v->add_val, v->new_reg, insert_before);
1992-02-01 09:24:22 +01:00
}
/* Add code at loop start to initialize giv's reduced reg. */
emit_iv_add_mult (extend_value_for_giv (v, bl->initial_value),
v->mult_val, v->add_val, v->new_reg,
loop_start);
1992-02-01 09:24:22 +01:00
}
}
/* Rescan all givs. If a giv is the same as a giv not reduced, mark it
as not reduced.
1992-02-01 09:24:22 +01:00
For each giv register that can be reduced now: if replaceable,
substitute reduced reg wherever the old giv occurs;
else add new move insn "giv_reg = reduced_reg". */
1992-02-01 09:24:22 +01:00
for (v = bl->giv; v; v = v->next_iv)
{
if (v->same && v->same->ignore)
v->ignore = 1;
if (v->ignore)
continue;
/* Update expression if this was combined, in case other giv was
replaced. */
if (v->same)
v->new_reg = replace_rtx (v->new_reg,
v->same->dest_reg, v->same->new_reg);
/* See if this register is known to be a pointer to something. If
so, see if we can find the alignment. First see if there is a
destination register that is a pointer. If so, this shares the
alignment too. Next see if we can deduce anything from the
computational information. If not, and this is a DEST_ADDR
giv, at least we know that it's a pointer, though we don't know
the alignment. */
if (GET_CODE (v->new_reg) == REG
&& v->giv_type == DEST_REG
function.h (emit_status): Delete member regno_pointer_flag and rename regno_pointer_flag_length to... * function.h (emit_status): Delete member regno_pointer_flag and rename regno_pointer_flag_length to regno_pointer_align_length. Delete define for REGNO_POINTER_FLAG. * integrate.h (inline_remap): Delete member regno_pointer_flag. Add member x_regno_reg_rtx. * rtl.h (rtx_def): Use frame_related bit to indicate register is a pointer in REG expressions. Define REG_POINTER macro. * alias.c (find_base_value, find_base_term): Use REG_POINTER instead of REGNO_POINTER_FLAG. * combine.c (nonzero_bits, num_sign_bit_copies): Likewise. * emit-rtl.c (gen_reg_rtx): Use regno_pointer_align_length instead of regno_pointer_flag_length. Remove code which refers to regno_pointer_flag. (mark_reg_pointer): Use REG_POINTER. (free_emit_status): Remove code which refers to regno_pointer_flag. (init_emit, mark_emit_status): Likewise. * flow.c (dump_flow_info): Likewise. * function.c (preserve_temp_slots): Likewise. * integrate.c (expand_inline_function, copy_rtx_and_substitute): Use x_regno_reg_rtx instead of regno_pointer_flag for function pointer determination in map. * loop.c (strength_reduce, maybe_eliminate_biv_1): Use REG_POINTER. * predict.c (estimate_probability): Likewise. * regclass.c (record_address_regs, reg_scan_mark_refs): Likewise. * unroll.c (unroll_loop): Use x_regno_reg_rtx instead of regno_pointer_flag for function pointer determination in map. * convex.h (RTX_COSTS): Don't test regno_pointer_flag and use REG_POINTER. * pa.c (hppa_legitimize_address, emit_move_sequence, basereg_operand): Use REG_POINTER. (restore_unscaled_index_insn_codes): Revise comment. From-SVN: r37863
2000-11-30 07:31:19 +01:00
&& REG_POINTER (v->dest_reg))
mark_reg_pointer (v->new_reg,
REGNO_POINTER_ALIGN (REGNO (v->dest_reg)));
else if (GET_CODE (v->new_reg) == REG
function.h (emit_status): Delete member regno_pointer_flag and rename regno_pointer_flag_length to... * function.h (emit_status): Delete member regno_pointer_flag and rename regno_pointer_flag_length to regno_pointer_align_length. Delete define for REGNO_POINTER_FLAG. * integrate.h (inline_remap): Delete member regno_pointer_flag. Add member x_regno_reg_rtx. * rtl.h (rtx_def): Use frame_related bit to indicate register is a pointer in REG expressions. Define REG_POINTER macro. * alias.c (find_base_value, find_base_term): Use REG_POINTER instead of REGNO_POINTER_FLAG. * combine.c (nonzero_bits, num_sign_bit_copies): Likewise. * emit-rtl.c (gen_reg_rtx): Use regno_pointer_align_length instead of regno_pointer_flag_length. Remove code which refers to regno_pointer_flag. (mark_reg_pointer): Use REG_POINTER. (free_emit_status): Remove code which refers to regno_pointer_flag. (init_emit, mark_emit_status): Likewise. * flow.c (dump_flow_info): Likewise. * function.c (preserve_temp_slots): Likewise. * integrate.c (expand_inline_function, copy_rtx_and_substitute): Use x_regno_reg_rtx instead of regno_pointer_flag for function pointer determination in map. * loop.c (strength_reduce, maybe_eliminate_biv_1): Use REG_POINTER. * predict.c (estimate_probability): Likewise. * regclass.c (record_address_regs, reg_scan_mark_refs): Likewise. * unroll.c (unroll_loop): Use x_regno_reg_rtx instead of regno_pointer_flag for function pointer determination in map. * convex.h (RTX_COSTS): Don't test regno_pointer_flag and use REG_POINTER. * pa.c (hppa_legitimize_address, emit_move_sequence, basereg_operand): Use REG_POINTER. (restore_unscaled_index_insn_codes): Revise comment. From-SVN: r37863
2000-11-30 07:31:19 +01:00
&& REG_POINTER (v->src_reg))
{
unsigned int align = REGNO_POINTER_ALIGN (REGNO (v->src_reg));
if (align == 0
|| GET_CODE (v->add_val) != CONST_INT
|| INTVAL (v->add_val) % (align / BITS_PER_UNIT) != 0)
align = 0;
mark_reg_pointer (v->new_reg, align);
}
else if (GET_CODE (v->new_reg) == REG
&& GET_CODE (v->add_val) == REG
function.h (emit_status): Delete member regno_pointer_flag and rename regno_pointer_flag_length to... * function.h (emit_status): Delete member regno_pointer_flag and rename regno_pointer_flag_length to regno_pointer_align_length. Delete define for REGNO_POINTER_FLAG. * integrate.h (inline_remap): Delete member regno_pointer_flag. Add member x_regno_reg_rtx. * rtl.h (rtx_def): Use frame_related bit to indicate register is a pointer in REG expressions. Define REG_POINTER macro. * alias.c (find_base_value, find_base_term): Use REG_POINTER instead of REGNO_POINTER_FLAG. * combine.c (nonzero_bits, num_sign_bit_copies): Likewise. * emit-rtl.c (gen_reg_rtx): Use regno_pointer_align_length instead of regno_pointer_flag_length. Remove code which refers to regno_pointer_flag. (mark_reg_pointer): Use REG_POINTER. (free_emit_status): Remove code which refers to regno_pointer_flag. (init_emit, mark_emit_status): Likewise. * flow.c (dump_flow_info): Likewise. * function.c (preserve_temp_slots): Likewise. * integrate.c (expand_inline_function, copy_rtx_and_substitute): Use x_regno_reg_rtx instead of regno_pointer_flag for function pointer determination in map. * loop.c (strength_reduce, maybe_eliminate_biv_1): Use REG_POINTER. * predict.c (estimate_probability): Likewise. * regclass.c (record_address_regs, reg_scan_mark_refs): Likewise. * unroll.c (unroll_loop): Use x_regno_reg_rtx instead of regno_pointer_flag for function pointer determination in map. * convex.h (RTX_COSTS): Don't test regno_pointer_flag and use REG_POINTER. * pa.c (hppa_legitimize_address, emit_move_sequence, basereg_operand): Use REG_POINTER. (restore_unscaled_index_insn_codes): Revise comment. From-SVN: r37863
2000-11-30 07:31:19 +01:00
&& REG_POINTER (v->add_val))
{
unsigned int align = REGNO_POINTER_ALIGN (REGNO (v->add_val));
if (align == 0 || GET_CODE (v->mult_val) != CONST_INT
|| INTVAL (v->mult_val) % (align / BITS_PER_UNIT) != 0)
align = 0;
mark_reg_pointer (v->new_reg, align);
}
else if (GET_CODE (v->new_reg) == REG && v->giv_type == DEST_ADDR)
mark_reg_pointer (v->new_reg, 0);
1992-02-01 09:24:22 +01:00
if (v->giv_type == DEST_ADDR)
/* Store reduced reg as the address in the memref where we found
this giv. */
validate_change (v->insn, v->location, v->new_reg, 0);
1992-02-01 09:24:22 +01:00
else if (v->replaceable)
{
reg_map[REGNO (v->dest_reg)] = v->new_reg;
#if 0
/* I can no longer duplicate the original problem. Perhaps
this is unnecessary now? */
/* Replaceable; it isn't strictly necessary to delete the old
insn and emit a new one, because v->dest_reg is now dead.
However, especially when unrolling loops, the special
handling for (set REG0 REG1) in the second cse pass may
make v->dest_reg live again. To avoid this problem, emit
an insn to set the original giv reg from the reduced giv.
We can not delete the original insn, since it may be part
of a LIBCALL, and the code in flow that eliminates dead
libcalls will fail if it is deleted. */
emit_insn_after (gen_move_insn (v->dest_reg, v->new_reg),
v->insn);
#endif
}
else
{
/* Not replaceable; emit an insn to set the original giv reg from
the reduced giv, same as above. */
emit_insn_after (gen_move_insn (v->dest_reg, v->new_reg),
v->insn);
}
/* When a loop is reversed, givs which depend on the reversed
biv, and which are live outside the loop, must be set to their
correct final value. This insn is only needed if the giv is
not replaceable. The correct final value is the same as the
value that the giv starts the reversed loop with. */
if (bl->reversed && ! v->replaceable)
emit_iv_add_mult (extend_value_for_giv (v, bl->initial_value),
v->mult_val, v->add_val, v->dest_reg,
end_insert_before);
1992-02-01 09:24:22 +01:00
else if (v->final_value)
{
rtx insert_before;
/* If the loop has multiple exits, emit the insn before the
loop to ensure that it will always be executed no matter
how the loop exits. Otherwise, emit the insn after the loop,
since this is slightly more efficient. */
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (loop->exit_count)
1992-02-01 09:24:22 +01:00
insert_before = loop_start;
else
insert_before = end_insert_before;
emit_insn_before (gen_move_insn (v->dest_reg, v->final_value),
insert_before);
#if 0
/* If the insn to set the final value of the giv was emitted
before the loop, then we must delete the insn inside the loop
that sets it. If this is a LIBCALL, then we must delete
every insn in the libcall. Note, however, that
final_giv_value will only succeed when there are multiple
exits if the giv is dead at each exit, hence it does not
matter that the original insn remains because it is dead
anyways. */
/* Delete the insn inside the loop that sets the giv since
the giv is now set before (or after) the loop. */
delete_insn (v->insn);
#endif
}
if (loop_dump_stream)
{
fprintf (loop_dump_stream, "giv at %d reduced to ",
INSN_UID (v->insn));
print_rtl (loop_dump_stream, v->new_reg);
fprintf (loop_dump_stream, "\n");
}
}
/* All the givs based on the biv bl have been reduced if they
merit it. */
/* For each giv not marked as maybe dead that has been combined with a
second giv, clear any "maybe dead" mark on that second giv.
v->new_reg will either be or refer to the register of the giv it
combined with.
Doing this clearing avoids problems in biv elimination where a
giv's new_reg is a complex value that can't be put in the insn but
the giv combined with (with a reg as new_reg) is marked maybe_dead.
Since the register will be used in either case, we'd prefer it be
used from the simpler giv. */
for (v = bl->giv; v; v = v->next_iv)
if (! v->maybe_dead && v->same)
v->same->maybe_dead = 0;
/* Try to eliminate the biv, if it is a candidate.
This won't work if ! all_reduced,
since the givs we planned to use might not have been reduced.
We have to be careful that we didn't initially think we could eliminate
1992-02-01 09:24:22 +01:00
this biv because of a giv that we now think may be dead and shouldn't
be used as a biv replacement.
1992-02-01 09:24:22 +01:00
Also, there is the possibility that we may have a giv that looks
like it can be used to eliminate a biv, but the resulting insn
isn't valid. This can happen, for example, on the 88k, where a
1992-02-01 09:24:22 +01:00
JUMP_INSN can compare a register only with zero. Attempts to
replace it with a compare with a constant will fail.
1992-02-01 09:24:22 +01:00
Note that in cases where this call fails, we may have replaced some
of the occurrences of the biv with a giv, but no harm was done in
doing so in the rare cases where it can occur. */
if (all_reduced == 1 && bl->eliminable
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
&& maybe_eliminate_biv (loop, bl, 1, threshold, insn_count))
1992-02-01 09:24:22 +01:00
{
/* ?? If we created a new test to bypass the loop entirely,
or otherwise drop straight in, based on this test, then
we might want to rewrite it also. This way some later
pass has more hope of removing the initialization of this
1996-07-04 00:07:53 +02:00
biv entirely. */
1992-02-01 09:24:22 +01:00
/* If final_value != 0, then the biv may be used after loop end
and we must emit an insn to set it just in case.
Reversed bivs already have an insn after the loop setting their
value, so we don't need another one. We can't calculate the
1996-07-04 00:07:53 +02:00
proper final value for such a biv here anyways. */
1992-02-01 09:24:22 +01:00
if (final_value != 0 && ! bl->reversed)
{
rtx insert_before;
/* If the loop has multiple exits, emit the insn before the
loop to ensure that it will always be executed no matter
how the loop exits. Otherwise, emit the insn after the
loop, since this is slightly more efficient. */
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (loop->exit_count)
1992-02-01 09:24:22 +01:00
insert_before = loop_start;
else
insert_before = end_insert_before;
emit_insn_before (gen_move_insn (bl->biv->dest_reg, final_value),
end_insert_before);
}
#if 0
/* Delete all of the instructions inside the loop which set
the biv, as they are all dead. If is safe to delete them,
because an insn setting a biv will never be part of a libcall. */
/* However, deleting them will invalidate the regno_last_uid info,
so keeping them around is more convenient. Final_biv_value
will only succeed when there are multiple exits if the biv
is dead at each exit, hence it does not matter that the original
insn remains, because it is dead anyways. */
for (v = bl->biv; v; v = v->next_iv)
delete_insn (v->insn);
#endif
if (loop_dump_stream)
fprintf (loop_dump_stream, "Reg %d: biv eliminated\n",
bl->regno);
}
}
/* Go through all the instructions in the loop, making all the
register substitutions scheduled in REG_MAP. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (p = loop_start; p != loop_end; p = NEXT_INSN (p))
1992-02-01 09:24:22 +01:00
if (GET_CODE (p) == INSN || GET_CODE (p) == JUMP_INSN
|| GET_CODE (p) == CALL_INSN)
1992-02-01 09:24:22 +01:00
{
replace_regs (PATTERN (p), reg_map, reg_map_size, 0);
replace_regs (REG_NOTES (p), reg_map, reg_map_size, 0);
INSN_CODE (p) = -1;
1992-02-01 09:24:22 +01:00
}
if (loop_info->n_iterations > 0)
{
/* When we completely unroll a loop we will likely not need the increment
of the loop BIV and we will not need the conditional branch at the
end of the loop. */
unrolled_insn_copies = insn_count - 2;
#ifdef HAVE_cc0
/* When we completely unroll a loop on a HAVE_cc0 machine we will not
need the comparison before the conditional branch at the end of the
loop. */
unrolled_insn_copies -= 1;
#endif
/* We'll need one copy for each loop iteration. */
unrolled_insn_copies *= loop_info->n_iterations;
/* A little slop to account for the ability to remove initialization
code, better CSE, and other secondary benefits of completely
unrolling some loops. */
unrolled_insn_copies -= 1;
/* Clamp the value. */
if (unrolled_insn_copies < 0)
unrolled_insn_copies = 0;
}
1992-02-01 09:24:22 +01:00
/* Unroll loops from within strength reduction so that we can use the
induction variable information that strength_reduce has already
collected. Always unroll loops that would be as small or smaller
unrolled than when rolled. */
if ((flags & LOOP_UNROLL)
|| (loop_info->n_iterations > 0
&& unrolled_insn_copies <= insn_count))
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
unroll_loop (loop, insn_count, end_insert_before, 1);
1992-02-01 09:24:22 +01:00
Makefile.in (OBJS): Add doloop.o. * Makefile.in (OBJS): Add doloop.o. * doloop.c: New file. * final.c (insn_current_reference_address): Return 0 before final. * flags.h (flag_branch_on_count_reg): Fix typos in commentary. * jump.c (any_uncondjump_p): Likewise. * loop.c (indirect_jump_in_function): Make static. (strength_reduce): Call doloop_optimize. (insert_bct, instrument_loop_bct): Remove. * loop.h (doloop_optimize): Prototype. * recog.c (split_all_insns): Split all INSN_P. * toplev.c (flag_branch_on_count_reg): Default on. * config/c4x/c4x.c (c4x_optimization_options): Don't set flag_branch_on_count_reg. * config/i386/i386.c (override_options): Likewise. * config/rs6000/rs6000.c (optimization_options): Likewise. * config/i386/i386.md (decrement_and_branch_on_count): Remove. (doloop_end): New. (dbra_ge): Remove, as well as all it's splitters. * config/rs6000/rs6000.md (decrement_and_branch_on_count): Remove. (doloop_end): New. * config/ia64/ia64-protos.h (ar_lc_reg_operand): Declare. (ia64_register_move_cost): Declare. * config/ia64/ia64.c (ar_lc_reg_operand): New. (struct ia64_frame_info): Add ar_size. (ia64_compute_frame_size): Set it. (save_restore_insns): Save and restore ar.lc. (ia64_register_move_cost): New, moved from header file. Handle application registers. (REG_AR_PFS, REG_AR_EC): Remove. Replace with AR_*_REGNUM numbers. (emit_insn_group_barriers): Special case doloop_end_internal. (ia64_epilogue_uses): Mark ar.lc live at end. * config/ia64/ia64.h (AR_CCV_REGNUM, AR_LC_REGNUM): New registers. (AR_EC_REGNUM, AR_PFS_REGNUM): New registers. (FIRST_PSEUDO_REGISTER): Make room. (AR_M_REGNO_P, AR_I_REGNO_P, AR_REGNO_P): New. (FIXED_REGISTERS, CALL_USED_REGISTERS): Update. (REG_ALLOC_ORDER): Update. (HARD_REGNO_MODE_OK): Update. (REGISTER_NAMES): Update. (enum reg_class): Add AR_M_REGS and AR_I_REGS. (REG_CLASS_NAMES, REG_CLASS_CONTENTS): Update. (REGNO_REG_CLASS): Update. (LEGITIMATE_ADDRESS_DISP): Displacement range is 9 bits, not 10. (REGISTER_MOVE_COST): Move out of line. (PREDICATE_CODES): Update. * config/ia64/ia64.md (movdi patterns): Handle ar register classes. (addsi3_plus1_alt, adddi3_plus1_alt): New. (shladd_elim splitter): Allow constants in the predicate. (doloop_end, doloop_end_internal): New. From-SVN: r35358
2000-07-31 01:58:03 +02:00
#ifdef HAVE_doloop_end
if (HAVE_doloop_end && (flags & LOOP_BCT) && flag_branch_on_count_reg)
doloop_optimize (loop);
#endif /* HAVE_doloop_end */
1992-02-01 09:24:22 +01:00
if (loop_dump_stream)
fprintf (loop_dump_stream, "\n");
egress:
VARRAY_FREE (ivs->reg_iv_type);
VARRAY_FREE (ivs->reg_iv_info);
free (ivs->reg_biv_class);
Remove obstacks. * Makefile.in (ggc-callbacks.o): Remove target. (flow.o): Depend on GGC_H. * alias.c (init_alias_analysis): Remove ggc_p conditionals. (end_alias_analysis): Likewise. * basic-block.h (init_flow): New function. (allocate_reg_life_data): Declare. * bb-reorder.c (function_obstack): Replace with ... (flow_obstack): ... new variable. (fixup_reorder_chain): Use it. * c-decl.c (ggc_p): Remove. (caller-save.c): Don't call oballoc/obfree. * combine.c (struct undobuf): Remove storage. (try_combine): Don't call oballoc. (undo_all): Don't call obfree. * cse.c (insert): Use xmalloc, not oballoc. (cse_main): Adjust accordingly. * dwarf2out.c (save_rtx): Remove obstack code. (dwarf2out_init): Remove ggc_p conditionals. * emit-rtl.c (rtl_obstack): Remove. (gen_rtx_CONST_INT): Remove ggc_p conditionals. (make_insn_raw): Likewise. (emit_insn_before): Likewise. (emit_insn_after): Likewise. (emit_insn): Likewise. (gen_sequence): Likewise. (copy_insn_1): Remove handling of `b' RTL components. (init_emit_once): Remove ggc_p conditionals. * except.c (create_rethrow_ref): Don't fool with obstacks. (add_partial_entry): Likewise. (call_get_eh_context): Likewise. (begin_protect_partials): Likewise. (protect_with_terminate): Likewise. * explow.c (plus_constant_wide): Likewise. * expr.c (init_expr_once): Likewise. (emit_block_move): Likewise. (clear_storage): Likewise. (expand_expr): Likewise. * flow.c (function_obstack): Remove. (flow_obstack): New variable. (flow_firstobj): Likewise. (create_base_block): Use the flow_obstack. (split_block): Likewise. (split_edge): Likewise. (calculate_global_regs_live): Likewise. (allocate_bb_life_data): Make it static. Likewiwse. (init_flow): New function. (size_int_type_wide): Remove ggc_p conditionals. * function.c (push_function_context_to): Don't call save_tree_status. (pop_function_context_from): Or restore_tree_status. (assign_stack_local_1): Don't call push_obstacks. (find_fixup_replacement): Use xmalloc. (fixup_var_refs_insns): Free the storage. (insns_for_mem_walk): Don't mess with obstacks. (instantiate_decls): Likewise. (trampoline_address): Likewise. (expand_function_end): Likewise. * function.h (sturct function): Remove obstack-related variables. (save_tree_status): Don't declare. (restore_tree_status): Likewise. * gcse.c (compute_can_copy): Don't call oballoc/obfree. * genattrtab.c (operate_exp): Remove ggc_p conditionals. (simplify_cond): Likewise. (simplify_test_exp): Don't mess with obstacks. (optimize_attrs): Likewise. * gengenrtl.c (gendef): Don't include ggc_p conditionals. * ggc-callbacks.c (ggc_p): Remove. * ggc-none.c (ggc_p): Remove. * ggc.h (ggc_p): Don't declare. * integrate.c (save_for_inline): Don't mess with obstacks. (integrate_decl_tree): Likewise. (output_inline_function): Likewise. * lists.c (init_EXPR_INSN_LIST_cache): Likewise. * loop.c (temp_obstack): Remove. (rtl_obstack): Likewise. (init_loop): Don't mess with obstacks. (reg_address_cost): Free BIVs and GIVs. (check_insns_for_bivs): Use xmalloc, not oballoc. (find_mem_givs): Likewise. (record_biv): Likewise. (general_induction_var): Likewise. (product_cheap_p): Likewse. * optabs.c (init_one_libfunc): Remove ggc_p conditional. * print-tree.c (debug_tree): Don't use oballoc/obfree. (print_node): Likewise. * profile.c (output_func_start_profiler): Remove call to temporary_allocation. * reload1.c (eliminate_regs_in_insn): Don't mess with obstacks. * resource.c (mark_target_live_regs): Use xmalloc. (free_resource_info): Free the memory. * rtl.c (rtl_obstack): Remove. (rtvec_alloc): Don't mess with obstacks. (rtx_alloc): Likewise. (rtx_free): Remove. (copy_rtx): Don't handle `b' cases. (read_rtx): Use a local rtl_obstack. * rtl.h (oballoc): Remove. (obfree): Likewise. (pop_obstacks): Likewise. (push_obstacks): Likewise. (allocate_bb_life_data): Likewise. (allocate_reg_life_data): Likewise. (rtx_free): Likewise. * sdbout.c (sdbout_queue_anonymous_type): Use tree_cons, not saveable_tree_cons. * simplify-rtx.c (cselib_init): Don't mess with obstacks. * stmt.c (mark_block_nesting): Mark the label_chain. (epxand_label): Use ggc_alloc, not oballoc. (clear_last_expr): Don't mess with obstacks. (expand_decl_cleanup): Likewise. (expand_dcc_cleanup): Likewise. (expand_dhc_cleanup): Likewise. (expand_anon_union_decl): Likewise. (add_case_node): Use xmalloc, not oballoc. (free_case_nodes): New function. (expand_end_case): Call it. * stor-layout.c (layout_type): Don't mess with obstacks. (layout_type): Likewise. * toplev.c (wrapup_global_declarations): Likewise. (compile_file): Remove ggc_p conditionals. (rest_of_compilation): Call init_flow. Remove ggc_p conditionals. (decode_f_option): Remove ggc_p conditionals. * tree.c (function_maybepermanent_obstack): Remove. (maybepermanent_obstack): Likewise. (function_obstack): Likewise. (tmeporary_obstack): Likewise. (momentary_obstack): Likewise. (temp_decl_obstack): Likewise. (saveable_obstack): Likewise. (rtl_obstack): Likewise. (current_obstack): Likewise. (expression_obstack): Likewise. (struct obstack_stack): Likewise. (obstack_stack): Likewise. (obstack_stack_obstack): Likewise. (maybepermanent_firstobj): Likewise. (temporary_firstobj): Likewise. (momentary_firstobj): Likewise. (temp_decl_firstobj): Likewise. (momentary_function_firstobj): Likewise. (all_types_permanent): Likewise. (struct momentary_level): Likewise. (momentary_stack): Likewise. (init_obstacks): Remove initialization of removed obstacks. (save_tree_status): Remove. (restore_tree_status): Likewise. (temporary_allocation): Liekwise. (end_temporary_allocation): Liekwise. (resume_temporary_allocation): Likewise. (saveable_allocation): Likewise. (push_obstacks): Likewise. (push_obstacks_nochange): Likewise. (pop_obstacks): Likewise. (allocation_temporary_p): Likewise. (permanent_allocation): Likewise. (preserve_data): Likewise. (preserve_initializer): Likewise. (rtl_in_current_obstack): Likewise. (rtl_in_saveable_obstack): Likewise. (oballoc): Likewise. (obfree): Likewise. (savealloc): Likewise. (expralloc): Likewise. (print_obstack_name): Likewise. (debug_obstack): Likewise. (object_permanent_p): Likewise. (push_momentary): Likewise. (perserve_momentary): Likewise. (clear_momentary): Likewise. (pop_momentary): Likewise. (pop_momentary_nofree): Likewise. (suspend_momentary): Likewise. (resume_momentary): Likewise. (make_node): Don't set TREE_PERMANENT. (copy_node): Remove ggc_p conditionals. Don't set TYPE_OBSTACK. Don't set TREE_PERMANENT. (get_identifier): Remove ggc_p conditionals. (build_string): Likewise. (make_tree_vec): Likewise. (build_decl_list): Remove. (build_expr_list): Likewise. (tree_cons): Remove ggc_p conditionals. (decl_tree_cons): Remove. (expr_tree_cons): Likewise. (perm_tree_cons): Likewise. (temp_tree_cons): Likewise. (saveable_tree_cons): Likewise. (build1): Remove ggc_p conditionals. (build_parse_node): Likewise. (build_type_attribute_variant): Don't mess with obstacks. (build_type_copy): Likewise. (type_hash_canon): Likewise. (build_pointer_type): Likewise. (build_reference_type): Likewise. (build_index_type): Likewise. (build_range_type): Likewise. (dump_tree_statistics): Don't print obstack information. * tree.h (struct tree_common): Remove permanent_flag. (TREE_PERMANENT): Remove. (TREE_SET_PERMANENT): Likewise. (TYPE_OBSTACK): Likewise. (struct tree_type): Remove obstack. (oballoc): Remove. (savealloc): Likewise. (build_decl_list): Likewise. (build_expr_list): Likewise. (perm_tree_cons): Likewise. (temp_tree_cons): Likewise. (saveable_tree_cons): Likewise. (decl_tree_cons): Likewise. (expr_tree_cons): Likewise. (suspend_momentary): Likewise. (allocation_temporary_p): Likewise. (resume_momentary): Likewise. (push_obstacks_nochange): Likewise. (permanent_allocation): Likewise. (push_momentary): Likewise. (clear_momentary): Likewise. (pop_momentary): Likewise. (end_temporary_allocation): Likewise. (pop_obstacks): Likewise. (push_obstacks): Likewise. (pop_momentary_nofree): LIkewise. (preserve_momentary): Likewise. (saveable_allocation): Likewise. (temporary_allocation): Likewise. (resume_temporary_allocation): Likewise. (perserve_initializer): Likewise. (debug_obstack): Likewise. (rtl_in_current_obstack): Likewise. (rtl_in_saveable_obstack): Likewise. (obfree): Likewise. * varasm.c (current_obstack): Remove. (saveable_obstack): Remove. (rtl_obstack): Remove. (immed_double_const): Don't mess with obstacks. (immed_real_cons): Likewise. (output_constant_def): Likewise. (init_varasm_status): Use xcalloc. (mark_pool_constant): Mark the pool constant itself. (free_varasm_status): Free memory. (decode_rtx_const): Call bzero directly, rather than expanding it inline. (record_rtx_const): Don't mess with obstacks. (force_const_mem): Likewise. * config/arm/arm.c (arm_encode_call_attribute): Remove ggc_p conditionals. (aof_pic_entry): Likewise. * config/ia64/ia64.c (ia64_encode_section_info): Likewise. * config/m32r/m32r.c (m32r_encode_section_info): Likewise. * config/pa/pa.c (saveable_obstack): Remove. (rtl_obstack): Likewise. (current_obstack): Likewise. (output_call): Don't mess with obstacks. (hppa_encode_label): Remove ggc_p conditionals. * config/romp/romp.c (get_symref): Don't mess with obstacks. * config/rs6000/rs6000.c (output_toc): Remove ggc_p conditional. (rs6000_encode_section_info): Likewise. * config/sh/sh.c (get_fpscr_rtx): Likewise. From-SVN: r36856
2000-10-13 08:26:46 +02:00
{
struct iv_class *iv = ivs->loop_iv_list;
while (iv) {
struct iv_class *next = iv->next;
struct induction *induction;
struct induction *next_induction;
for (induction = iv->biv; induction; induction = next_induction)
{
next_induction = induction->next_iv;
free (induction);
}
for (induction = iv->giv; induction; induction = next_induction)
{
next_induction = induction->next_iv;
free (induction);
}
free (iv);
iv = next;
}
}
if (reg_map)
free (reg_map);
1992-02-01 09:24:22 +01:00
}
/*Record all basic induction variables calculated in the insn. */
static rtx
check_insn_for_bivs (loop, p, not_every_iteration, maybe_multiple)
struct loop *loop;
rtx p;
int not_every_iteration;
int maybe_multiple;
{
struct loop_ivs *ivs = LOOP_IVS (loop);
rtx set;
rtx dest_reg;
rtx inc_val;
rtx mult_val;
rtx *location;
if (GET_CODE (p) == INSN
&& (set = single_set (p))
&& GET_CODE (SET_DEST (set)) == REG)
{
dest_reg = SET_DEST (set);
if (REGNO (dest_reg) < max_reg_before_loop
&& REGNO (dest_reg) >= FIRST_PSEUDO_REGISTER
&& REG_IV_TYPE (ivs, REGNO (dest_reg)) != NOT_BASIC_INDUCT)
{
if (basic_induction_var (loop, SET_SRC (set),
GET_MODE (SET_SRC (set)),
dest_reg, p, &inc_val, &mult_val,
&location))
{
/* It is a possible basic induction variable.
Create and initialize an induction structure for it. */
struct induction *v
Remove obstacks. * Makefile.in (ggc-callbacks.o): Remove target. (flow.o): Depend on GGC_H. * alias.c (init_alias_analysis): Remove ggc_p conditionals. (end_alias_analysis): Likewise. * basic-block.h (init_flow): New function. (allocate_reg_life_data): Declare. * bb-reorder.c (function_obstack): Replace with ... (flow_obstack): ... new variable. (fixup_reorder_chain): Use it. * c-decl.c (ggc_p): Remove. (caller-save.c): Don't call oballoc/obfree. * combine.c (struct undobuf): Remove storage. (try_combine): Don't call oballoc. (undo_all): Don't call obfree. * cse.c (insert): Use xmalloc, not oballoc. (cse_main): Adjust accordingly. * dwarf2out.c (save_rtx): Remove obstack code. (dwarf2out_init): Remove ggc_p conditionals. * emit-rtl.c (rtl_obstack): Remove. (gen_rtx_CONST_INT): Remove ggc_p conditionals. (make_insn_raw): Likewise. (emit_insn_before): Likewise. (emit_insn_after): Likewise. (emit_insn): Likewise. (gen_sequence): Likewise. (copy_insn_1): Remove handling of `b' RTL components. (init_emit_once): Remove ggc_p conditionals. * except.c (create_rethrow_ref): Don't fool with obstacks. (add_partial_entry): Likewise. (call_get_eh_context): Likewise. (begin_protect_partials): Likewise. (protect_with_terminate): Likewise. * explow.c (plus_constant_wide): Likewise. * expr.c (init_expr_once): Likewise. (emit_block_move): Likewise. (clear_storage): Likewise. (expand_expr): Likewise. * flow.c (function_obstack): Remove. (flow_obstack): New variable. (flow_firstobj): Likewise. (create_base_block): Use the flow_obstack. (split_block): Likewise. (split_edge): Likewise. (calculate_global_regs_live): Likewise. (allocate_bb_life_data): Make it static. Likewiwse. (init_flow): New function. (size_int_type_wide): Remove ggc_p conditionals. * function.c (push_function_context_to): Don't call save_tree_status. (pop_function_context_from): Or restore_tree_status. (assign_stack_local_1): Don't call push_obstacks. (find_fixup_replacement): Use xmalloc. (fixup_var_refs_insns): Free the storage. (insns_for_mem_walk): Don't mess with obstacks. (instantiate_decls): Likewise. (trampoline_address): Likewise. (expand_function_end): Likewise. * function.h (sturct function): Remove obstack-related variables. (save_tree_status): Don't declare. (restore_tree_status): Likewise. * gcse.c (compute_can_copy): Don't call oballoc/obfree. * genattrtab.c (operate_exp): Remove ggc_p conditionals. (simplify_cond): Likewise. (simplify_test_exp): Don't mess with obstacks. (optimize_attrs): Likewise. * gengenrtl.c (gendef): Don't include ggc_p conditionals. * ggc-callbacks.c (ggc_p): Remove. * ggc-none.c (ggc_p): Remove. * ggc.h (ggc_p): Don't declare. * integrate.c (save_for_inline): Don't mess with obstacks. (integrate_decl_tree): Likewise. (output_inline_function): Likewise. * lists.c (init_EXPR_INSN_LIST_cache): Likewise. * loop.c (temp_obstack): Remove. (rtl_obstack): Likewise. (init_loop): Don't mess with obstacks. (reg_address_cost): Free BIVs and GIVs. (check_insns_for_bivs): Use xmalloc, not oballoc. (find_mem_givs): Likewise. (record_biv): Likewise. (general_induction_var): Likewise. (product_cheap_p): Likewse. * optabs.c (init_one_libfunc): Remove ggc_p conditional. * print-tree.c (debug_tree): Don't use oballoc/obfree. (print_node): Likewise. * profile.c (output_func_start_profiler): Remove call to temporary_allocation. * reload1.c (eliminate_regs_in_insn): Don't mess with obstacks. * resource.c (mark_target_live_regs): Use xmalloc. (free_resource_info): Free the memory. * rtl.c (rtl_obstack): Remove. (rtvec_alloc): Don't mess with obstacks. (rtx_alloc): Likewise. (rtx_free): Remove. (copy_rtx): Don't handle `b' cases. (read_rtx): Use a local rtl_obstack. * rtl.h (oballoc): Remove. (obfree): Likewise. (pop_obstacks): Likewise. (push_obstacks): Likewise. (allocate_bb_life_data): Likewise. (allocate_reg_life_data): Likewise. (rtx_free): Likewise. * sdbout.c (sdbout_queue_anonymous_type): Use tree_cons, not saveable_tree_cons. * simplify-rtx.c (cselib_init): Don't mess with obstacks. * stmt.c (mark_block_nesting): Mark the label_chain. (epxand_label): Use ggc_alloc, not oballoc. (clear_last_expr): Don't mess with obstacks. (expand_decl_cleanup): Likewise. (expand_dcc_cleanup): Likewise. (expand_dhc_cleanup): Likewise. (expand_anon_union_decl): Likewise. (add_case_node): Use xmalloc, not oballoc. (free_case_nodes): New function. (expand_end_case): Call it. * stor-layout.c (layout_type): Don't mess with obstacks. (layout_type): Likewise. * toplev.c (wrapup_global_declarations): Likewise. (compile_file): Remove ggc_p conditionals. (rest_of_compilation): Call init_flow. Remove ggc_p conditionals. (decode_f_option): Remove ggc_p conditionals. * tree.c (function_maybepermanent_obstack): Remove. (maybepermanent_obstack): Likewise. (function_obstack): Likewise. (tmeporary_obstack): Likewise. (momentary_obstack): Likewise. (temp_decl_obstack): Likewise. (saveable_obstack): Likewise. (rtl_obstack): Likewise. (current_obstack): Likewise. (expression_obstack): Likewise. (struct obstack_stack): Likewise. (obstack_stack): Likewise. (obstack_stack_obstack): Likewise. (maybepermanent_firstobj): Likewise. (temporary_firstobj): Likewise. (momentary_firstobj): Likewise. (temp_decl_firstobj): Likewise. (momentary_function_firstobj): Likewise. (all_types_permanent): Likewise. (struct momentary_level): Likewise. (momentary_stack): Likewise. (init_obstacks): Remove initialization of removed obstacks. (save_tree_status): Remove. (restore_tree_status): Likewise. (temporary_allocation): Liekwise. (end_temporary_allocation): Liekwise. (resume_temporary_allocation): Likewise. (saveable_allocation): Likewise. (push_obstacks): Likewise. (push_obstacks_nochange): Likewise. (pop_obstacks): Likewise. (allocation_temporary_p): Likewise. (permanent_allocation): Likewise. (preserve_data): Likewise. (preserve_initializer): Likewise. (rtl_in_current_obstack): Likewise. (rtl_in_saveable_obstack): Likewise. (oballoc): Likewise. (obfree): Likewise. (savealloc): Likewise. (expralloc): Likewise. (print_obstack_name): Likewise. (debug_obstack): Likewise. (object_permanent_p): Likewise. (push_momentary): Likewise. (perserve_momentary): Likewise. (clear_momentary): Likewise. (pop_momentary): Likewise. (pop_momentary_nofree): Likewise. (suspend_momentary): Likewise. (resume_momentary): Likewise. (make_node): Don't set TREE_PERMANENT. (copy_node): Remove ggc_p conditionals. Don't set TYPE_OBSTACK. Don't set TREE_PERMANENT. (get_identifier): Remove ggc_p conditionals. (build_string): Likewise. (make_tree_vec): Likewise. (build_decl_list): Remove. (build_expr_list): Likewise. (tree_cons): Remove ggc_p conditionals. (decl_tree_cons): Remove. (expr_tree_cons): Likewise. (perm_tree_cons): Likewise. (temp_tree_cons): Likewise. (saveable_tree_cons): Likewise. (build1): Remove ggc_p conditionals. (build_parse_node): Likewise. (build_type_attribute_variant): Don't mess with obstacks. (build_type_copy): Likewise. (type_hash_canon): Likewise. (build_pointer_type): Likewise. (build_reference_type): Likewise. (build_index_type): Likewise. (build_range_type): Likewise. (dump_tree_statistics): Don't print obstack information. * tree.h (struct tree_common): Remove permanent_flag. (TREE_PERMANENT): Remove. (TREE_SET_PERMANENT): Likewise. (TYPE_OBSTACK): Likewise. (struct tree_type): Remove obstack. (oballoc): Remove. (savealloc): Likewise. (build_decl_list): Likewise. (build_expr_list): Likewise. (perm_tree_cons): Likewise. (temp_tree_cons): Likewise. (saveable_tree_cons): Likewise. (decl_tree_cons): Likewise. (expr_tree_cons): Likewise. (suspend_momentary): Likewise. (allocation_temporary_p): Likewise. (resume_momentary): Likewise. (push_obstacks_nochange): Likewise. (permanent_allocation): Likewise. (push_momentary): Likewise. (clear_momentary): Likewise. (pop_momentary): Likewise. (end_temporary_allocation): Likewise. (pop_obstacks): Likewise. (push_obstacks): Likewise. (pop_momentary_nofree): LIkewise. (preserve_momentary): Likewise. (saveable_allocation): Likewise. (temporary_allocation): Likewise. (resume_temporary_allocation): Likewise. (perserve_initializer): Likewise. (debug_obstack): Likewise. (rtl_in_current_obstack): Likewise. (rtl_in_saveable_obstack): Likewise. (obfree): Likewise. * varasm.c (current_obstack): Remove. (saveable_obstack): Remove. (rtl_obstack): Remove. (immed_double_const): Don't mess with obstacks. (immed_real_cons): Likewise. (output_constant_def): Likewise. (init_varasm_status): Use xcalloc. (mark_pool_constant): Mark the pool constant itself. (free_varasm_status): Free memory. (decode_rtx_const): Call bzero directly, rather than expanding it inline. (record_rtx_const): Don't mess with obstacks. (force_const_mem): Likewise. * config/arm/arm.c (arm_encode_call_attribute): Remove ggc_p conditionals. (aof_pic_entry): Likewise. * config/ia64/ia64.c (ia64_encode_section_info): Likewise. * config/m32r/m32r.c (m32r_encode_section_info): Likewise. * config/pa/pa.c (saveable_obstack): Remove. (rtl_obstack): Likewise. (current_obstack): Likewise. (output_call): Don't mess with obstacks. (hppa_encode_label): Remove ggc_p conditionals. * config/romp/romp.c (get_symref): Don't mess with obstacks. * config/rs6000/rs6000.c (output_toc): Remove ggc_p conditional. (rs6000_encode_section_info): Likewise. * config/sh/sh.c (get_fpscr_rtx): Likewise. From-SVN: r36856
2000-10-13 08:26:46 +02:00
= (struct induction *) xmalloc (sizeof (struct induction));
record_biv (loop, v, p, dest_reg, inc_val, mult_val, location,
not_every_iteration, maybe_multiple);
REG_IV_TYPE (ivs, REGNO (dest_reg)) = BASIC_INDUCT;
}
else if (REGNO (dest_reg) < max_reg_before_loop)
REG_IV_TYPE (ivs, REGNO (dest_reg)) = NOT_BASIC_INDUCT;
}
}
return p;
}
/* Record all givs calculated in the insn.
A register is a giv if: it is only set once, it is a function of a
biv and a constant (or invariant), and it is not a biv. */
static rtx
check_insn_for_givs (loop, p, not_every_iteration, maybe_multiple)
struct loop *loop;
rtx p;
int not_every_iteration;
int maybe_multiple;
{
struct loop_regs *regs = LOOP_REGS (loop);
rtx set;
/* Look for a general induction variable in a register. */
if (GET_CODE (p) == INSN
&& (set = single_set (p))
&& GET_CODE (SET_DEST (set)) == REG
&& ! VARRAY_CHAR (regs->may_not_optimize, REGNO (SET_DEST (set))))
{
rtx src_reg;
rtx dest_reg;
rtx add_val;
rtx mult_val;
rtx ext_val;
int benefit;
rtx regnote = 0;
rtx last_consec_insn;
dest_reg = SET_DEST (set);
if (REGNO (dest_reg) < FIRST_PSEUDO_REGISTER)
return p;
if (/* SET_SRC is a giv. */
(general_induction_var (loop, SET_SRC (set), &src_reg, &add_val,
&mult_val, &ext_val, 0, &benefit, VOIDmode)
/* Equivalent expression is a giv. */
|| ((regnote = find_reg_note (p, REG_EQUAL, NULL_RTX))
&& general_induction_var (loop, XEXP (regnote, 0), &src_reg,
&add_val, &mult_val, &ext_val, 0,
&benefit, VOIDmode)))
/* Don't try to handle any regs made by loop optimization.
We have nothing on them in regno_first_uid, etc. */
&& REGNO (dest_reg) < max_reg_before_loop
/* Don't recognize a BASIC_INDUCT_VAR here. */
&& dest_reg != src_reg
/* This must be the only place where the register is set. */
&& (VARRAY_INT (regs->n_times_set, REGNO (dest_reg)) == 1
/* or all sets must be consecutive and make a giv. */
|| (benefit = consec_sets_giv (loop, benefit, p,
src_reg, dest_reg,
&add_val, &mult_val, &ext_val,
&last_consec_insn))))
{
struct induction *v
Remove obstacks. * Makefile.in (ggc-callbacks.o): Remove target. (flow.o): Depend on GGC_H. * alias.c (init_alias_analysis): Remove ggc_p conditionals. (end_alias_analysis): Likewise. * basic-block.h (init_flow): New function. (allocate_reg_life_data): Declare. * bb-reorder.c (function_obstack): Replace with ... (flow_obstack): ... new variable. (fixup_reorder_chain): Use it. * c-decl.c (ggc_p): Remove. (caller-save.c): Don't call oballoc/obfree. * combine.c (struct undobuf): Remove storage. (try_combine): Don't call oballoc. (undo_all): Don't call obfree. * cse.c (insert): Use xmalloc, not oballoc. (cse_main): Adjust accordingly. * dwarf2out.c (save_rtx): Remove obstack code. (dwarf2out_init): Remove ggc_p conditionals. * emit-rtl.c (rtl_obstack): Remove. (gen_rtx_CONST_INT): Remove ggc_p conditionals. (make_insn_raw): Likewise. (emit_insn_before): Likewise. (emit_insn_after): Likewise. (emit_insn): Likewise. (gen_sequence): Likewise. (copy_insn_1): Remove handling of `b' RTL components. (init_emit_once): Remove ggc_p conditionals. * except.c (create_rethrow_ref): Don't fool with obstacks. (add_partial_entry): Likewise. (call_get_eh_context): Likewise. (begin_protect_partials): Likewise. (protect_with_terminate): Likewise. * explow.c (plus_constant_wide): Likewise. * expr.c (init_expr_once): Likewise. (emit_block_move): Likewise. (clear_storage): Likewise. (expand_expr): Likewise. * flow.c (function_obstack): Remove. (flow_obstack): New variable. (flow_firstobj): Likewise. (create_base_block): Use the flow_obstack. (split_block): Likewise. (split_edge): Likewise. (calculate_global_regs_live): Likewise. (allocate_bb_life_data): Make it static. Likewiwse. (init_flow): New function. (size_int_type_wide): Remove ggc_p conditionals. * function.c (push_function_context_to): Don't call save_tree_status. (pop_function_context_from): Or restore_tree_status. (assign_stack_local_1): Don't call push_obstacks. (find_fixup_replacement): Use xmalloc. (fixup_var_refs_insns): Free the storage. (insns_for_mem_walk): Don't mess with obstacks. (instantiate_decls): Likewise. (trampoline_address): Likewise. (expand_function_end): Likewise. * function.h (sturct function): Remove obstack-related variables. (save_tree_status): Don't declare. (restore_tree_status): Likewise. * gcse.c (compute_can_copy): Don't call oballoc/obfree. * genattrtab.c (operate_exp): Remove ggc_p conditionals. (simplify_cond): Likewise. (simplify_test_exp): Don't mess with obstacks. (optimize_attrs): Likewise. * gengenrtl.c (gendef): Don't include ggc_p conditionals. * ggc-callbacks.c (ggc_p): Remove. * ggc-none.c (ggc_p): Remove. * ggc.h (ggc_p): Don't declare. * integrate.c (save_for_inline): Don't mess with obstacks. (integrate_decl_tree): Likewise. (output_inline_function): Likewise. * lists.c (init_EXPR_INSN_LIST_cache): Likewise. * loop.c (temp_obstack): Remove. (rtl_obstack): Likewise. (init_loop): Don't mess with obstacks. (reg_address_cost): Free BIVs and GIVs. (check_insns_for_bivs): Use xmalloc, not oballoc. (find_mem_givs): Likewise. (record_biv): Likewise. (general_induction_var): Likewise. (product_cheap_p): Likewse. * optabs.c (init_one_libfunc): Remove ggc_p conditional. * print-tree.c (debug_tree): Don't use oballoc/obfree. (print_node): Likewise. * profile.c (output_func_start_profiler): Remove call to temporary_allocation. * reload1.c (eliminate_regs_in_insn): Don't mess with obstacks. * resource.c (mark_target_live_regs): Use xmalloc. (free_resource_info): Free the memory. * rtl.c (rtl_obstack): Remove. (rtvec_alloc): Don't mess with obstacks. (rtx_alloc): Likewise. (rtx_free): Remove. (copy_rtx): Don't handle `b' cases. (read_rtx): Use a local rtl_obstack. * rtl.h (oballoc): Remove. (obfree): Likewise. (pop_obstacks): Likewise. (push_obstacks): Likewise. (allocate_bb_life_data): Likewise. (allocate_reg_life_data): Likewise. (rtx_free): Likewise. * sdbout.c (sdbout_queue_anonymous_type): Use tree_cons, not saveable_tree_cons. * simplify-rtx.c (cselib_init): Don't mess with obstacks. * stmt.c (mark_block_nesting): Mark the label_chain. (epxand_label): Use ggc_alloc, not oballoc. (clear_last_expr): Don't mess with obstacks. (expand_decl_cleanup): Likewise. (expand_dcc_cleanup): Likewise. (expand_dhc_cleanup): Likewise. (expand_anon_union_decl): Likewise. (add_case_node): Use xmalloc, not oballoc. (free_case_nodes): New function. (expand_end_case): Call it. * stor-layout.c (layout_type): Don't mess with obstacks. (layout_type): Likewise. * toplev.c (wrapup_global_declarations): Likewise. (compile_file): Remove ggc_p conditionals. (rest_of_compilation): Call init_flow. Remove ggc_p conditionals. (decode_f_option): Remove ggc_p conditionals. * tree.c (function_maybepermanent_obstack): Remove. (maybepermanent_obstack): Likewise. (function_obstack): Likewise. (tmeporary_obstack): Likewise. (momentary_obstack): Likewise. (temp_decl_obstack): Likewise. (saveable_obstack): Likewise. (rtl_obstack): Likewise. (current_obstack): Likewise. (expression_obstack): Likewise. (struct obstack_stack): Likewise. (obstack_stack): Likewise. (obstack_stack_obstack): Likewise. (maybepermanent_firstobj): Likewise. (temporary_firstobj): Likewise. (momentary_firstobj): Likewise. (temp_decl_firstobj): Likewise. (momentary_function_firstobj): Likewise. (all_types_permanent): Likewise. (struct momentary_level): Likewise. (momentary_stack): Likewise. (init_obstacks): Remove initialization of removed obstacks. (save_tree_status): Remove. (restore_tree_status): Likewise. (temporary_allocation): Liekwise. (end_temporary_allocation): Liekwise. (resume_temporary_allocation): Likewise. (saveable_allocation): Likewise. (push_obstacks): Likewise. (push_obstacks_nochange): Likewise. (pop_obstacks): Likewise. (allocation_temporary_p): Likewise. (permanent_allocation): Likewise. (preserve_data): Likewise. (preserve_initializer): Likewise. (rtl_in_current_obstack): Likewise. (rtl_in_saveable_obstack): Likewise. (oballoc): Likewise. (obfree): Likewise. (savealloc): Likewise. (expralloc): Likewise. (print_obstack_name): Likewise. (debug_obstack): Likewise. (object_permanent_p): Likewise. (push_momentary): Likewise. (perserve_momentary): Likewise. (clear_momentary): Likewise. (pop_momentary): Likewise. (pop_momentary_nofree): Likewise. (suspend_momentary): Likewise. (resume_momentary): Likewise. (make_node): Don't set TREE_PERMANENT. (copy_node): Remove ggc_p conditionals. Don't set TYPE_OBSTACK. Don't set TREE_PERMANENT. (get_identifier): Remove ggc_p conditionals. (build_string): Likewise. (make_tree_vec): Likewise. (build_decl_list): Remove. (build_expr_list): Likewise. (tree_cons): Remove ggc_p conditionals. (decl_tree_cons): Remove. (expr_tree_cons): Likewise. (perm_tree_cons): Likewise. (temp_tree_cons): Likewise. (saveable_tree_cons): Likewise. (build1): Remove ggc_p conditionals. (build_parse_node): Likewise. (build_type_attribute_variant): Don't mess with obstacks. (build_type_copy): Likewise. (type_hash_canon): Likewise. (build_pointer_type): Likewise. (build_reference_type): Likewise. (build_index_type): Likewise. (build_range_type): Likewise. (dump_tree_statistics): Don't print obstack information. * tree.h (struct tree_common): Remove permanent_flag. (TREE_PERMANENT): Remove. (TREE_SET_PERMANENT): Likewise. (TYPE_OBSTACK): Likewise. (struct tree_type): Remove obstack. (oballoc): Remove. (savealloc): Likewise. (build_decl_list): Likewise. (build_expr_list): Likewise. (perm_tree_cons): Likewise. (temp_tree_cons): Likewise. (saveable_tree_cons): Likewise. (decl_tree_cons): Likewise. (expr_tree_cons): Likewise. (suspend_momentary): Likewise. (allocation_temporary_p): Likewise. (resume_momentary): Likewise. (push_obstacks_nochange): Likewise. (permanent_allocation): Likewise. (push_momentary): Likewise. (clear_momentary): Likewise. (pop_momentary): Likewise. (end_temporary_allocation): Likewise. (pop_obstacks): Likewise. (push_obstacks): Likewise. (pop_momentary_nofree): LIkewise. (preserve_momentary): Likewise. (saveable_allocation): Likewise. (temporary_allocation): Likewise. (resume_temporary_allocation): Likewise. (perserve_initializer): Likewise. (debug_obstack): Likewise. (rtl_in_current_obstack): Likewise. (rtl_in_saveable_obstack): Likewise. (obfree): Likewise. * varasm.c (current_obstack): Remove. (saveable_obstack): Remove. (rtl_obstack): Remove. (immed_double_const): Don't mess with obstacks. (immed_real_cons): Likewise. (output_constant_def): Likewise. (init_varasm_status): Use xcalloc. (mark_pool_constant): Mark the pool constant itself. (free_varasm_status): Free memory. (decode_rtx_const): Call bzero directly, rather than expanding it inline. (record_rtx_const): Don't mess with obstacks. (force_const_mem): Likewise. * config/arm/arm.c (arm_encode_call_attribute): Remove ggc_p conditionals. (aof_pic_entry): Likewise. * config/ia64/ia64.c (ia64_encode_section_info): Likewise. * config/m32r/m32r.c (m32r_encode_section_info): Likewise. * config/pa/pa.c (saveable_obstack): Remove. (rtl_obstack): Likewise. (current_obstack): Likewise. (output_call): Don't mess with obstacks. (hppa_encode_label): Remove ggc_p conditionals. * config/romp/romp.c (get_symref): Don't mess with obstacks. * config/rs6000/rs6000.c (output_toc): Remove ggc_p conditional. (rs6000_encode_section_info): Likewise. * config/sh/sh.c (get_fpscr_rtx): Likewise. From-SVN: r36856
2000-10-13 08:26:46 +02:00
= (struct induction *) xmalloc (sizeof (struct induction));
/* If this is a library call, increase benefit. */
if (find_reg_note (p, REG_RETVAL, NULL_RTX))
benefit += libcall_benefit (p);
/* Skip the consecutive insns, if there are any. */
if (VARRAY_INT (regs->n_times_set, REGNO (dest_reg)) != 1)
p = last_consec_insn;
record_giv (loop, v, p, src_reg, dest_reg, mult_val, add_val,
ext_val, benefit, DEST_REG, not_every_iteration,
maybe_multiple, NULL_PTR);
}
}
#ifndef DONT_REDUCE_ADDR
/* Look for givs which are memory addresses. */
/* This resulted in worse code on a VAX 8600. I wonder if it
still does. */
if (GET_CODE (p) == INSN)
find_mem_givs (loop, PATTERN (p), p, not_every_iteration,
maybe_multiple);
#endif
/* Update the status of whether giv can derive other givs. This can
change when we pass a label or an insn that updates a biv. */
if (GET_CODE (p) == INSN || GET_CODE (p) == JUMP_INSN
|| GET_CODE (p) == CODE_LABEL)
update_giv_derive (loop, p);
return p;
}
1992-02-01 09:24:22 +01:00
/* Return 1 if X is a valid source for an initial value (or as value being
compared against in an initial test).
X must be either a register or constant and must not be clobbered between
the current insn and the start of the loop.
INSN is the insn containing X. */
static int
valid_initial_value_p (x, insn, call_seen, loop_start)
rtx x;
rtx insn;
int call_seen;
rtx loop_start;
{
if (CONSTANT_P (x))
return 1;
/* Only consider pseudos we know about initialized in insns whose luids
1992-02-01 09:24:22 +01:00
we know. */
if (GET_CODE (x) != REG
|| REGNO (x) >= max_reg_before_loop)
return 0;
/* Don't use call-clobbered registers across a call which clobbers it. On
some machines, don't use any hard registers at all. */
if (REGNO (x) < FIRST_PSEUDO_REGISTER
&& (SMALL_REGISTER_CLASSES
|| (call_used_regs[REGNO (x)] && call_seen)))
1992-02-01 09:24:22 +01:00
return 0;
/* Don't use registers that have been clobbered before the start of the
loop. */
if (reg_set_between_p (x, insn, loop_start))
return 0;
return 1;
}
/* Scan X for memory refs and check each memory address
as a possible giv. INSN is the insn whose pattern X comes from.
NOT_EVERY_ITERATION is 1 if the insn might not be executed during
every loop iteration. MAYBE_MULTIPLE is 1 if the insn might be executed
more thanonce in each loop iteration. */
1992-02-01 09:24:22 +01:00
static void
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
find_mem_givs (loop, x, insn, not_every_iteration, maybe_multiple)
const struct loop *loop;
1992-02-01 09:24:22 +01:00
rtx x;
rtx insn;
int not_every_iteration, maybe_multiple;
1992-02-01 09:24:22 +01:00
{
register int i, j;
register enum rtx_code code;
rtl.h (rtx_format): Constify a char*. * rtl.h (rtx_format): Constify a char*. * rtl.c (rtx_format): Likewise. (copy_rtx, copy_most_rtx, read_rtx): Likewise. (init_rtl): Use accessor macro, not `rtx_format'. * alias.c (rtx_equal_for_memref_p, find_symbolic_term): Constify a char*. * caller-save.c (mark_referenced_regs): Likewise. * combine.c (subst, make_compound_operation, known_cond, gen_rtx_combine, update_table_tick, get_last_value_validate, use_crosses_set_p, mark_used_regs_combine, move_deaths): Likewise. * cse.c (rtx_cost, mention_regs, canon_hash, exp_equiv_p, refers_to_p, canon_reg, fold_rtx, cse_process_notes, count_reg_usage): Likewise. * emit-rtl.c (gen_rtx, copy_rtx_if_shared, reset_used_flags): Likewise. * final.c (leaf_renumber_regs_insn): Likewise. * flow.c (mark_used_regs, find_use_as_address, dump_flow_info, dump_edge_info, count_reg_references): Likewise. * function.c (fixup_var_refs_1, walk_fixup_memory_subreg, fixup_stack_1, purge_addressof_1, instantiate_virtual_regs_1): Likewise. * gcse.c (oprs_unchanged_p, hash_expr_1, expr_equiv_p, oprs_not_set_p, expr_killed_p, compute_transp, find_used_regs, add_label_notes): Likewise. * genattrtab.c (attr_rtx, attr_copy_rtx, encode_units_mask, clear_struct_flag, count_sub_rtxs, count_alternatives, compares_alternatives_p, contained_in_p, walk_attr_value, write_expr_attr_cache): Likewise. * genconfig.c (walk_insn_part): Likewise. * genemit.c (max_operand_1, gen_exp): Likewise. * genextract.c (walk_rtx): Likewise. * genflags.c (num_operands): Likewise. * genoutput.c (scan_operands): Likewise. * genpeep.c (match_rtx): Likewise. * genrecog.c (add_to_sequence): Likewise. * haifa-sched.c (may_trap_exp, sched_analyze_2, attach_deaths): Likewise. * integrate.c (save_constants, copy_for_inline, copy_rtx_and_substitute, subst_constants, restore_constants): Likewise. * jump.c (mark_jump_label, invert_exp, redirect_exp, rtx_renumbered_equal_p, rtx_equal_for_thread_p): Likewise. * local-alloc.c (contains_replace_regs, memref_referenced_p): Likewise. * loop.c (record_excess_regs, rtx_equal_for_loop_p, add_label_notes, replace_call_address, count_nonfixed_reads, invariant_p, find_single_use_in_loop, find_mem_givs, find_life_end, maybe_eliminate_biv_1, update_reg_last_use): Likewise. * print-rtl.c (reg_names, print_rtx): Likewise. * recog.c (validate_replace_rtx_1, find_single_use_1): Likewise. * reg-stack.c (stack_regs_mentioned_p, record_label_references, record_reg_life_pat, swap_rtx_condition, goto_block_pat, print_blocks): Likewise. * regclass.c (fix_register, record_address_regs, reg_scan_mark_refs): Likewise. * regmove.c (stable_but_for_p): Likewise. * reload.c (loc_mentioned_in_p, operands_match_p, find_reloads_toplevsubst_reg_equivs, find_reloads_address_1, copy_replacements, refers_to_regno_for_reload_p, refers_to_mem_for_reload_p, find_inc_amount, regno_clobbered_p, reload_when_needed_name, reg_class_names, debug_reload_to_stream): Likewise. * reload1.c (eliminate_regs, scan_paradoxical_subregs, delete_address_reloads_1, count_occurrences, reload_cse_mem_conflict_p, reload_combine_note_use, add_auto_inc_notes): Likewise. * resource.c (mark_referenced_resources, mark_set_resources): Likewise. * rtlanal.c (rtx_unstable_p, rtx_varies_p, rtx_addr_varies_p, reg_mentioned_p, regs_set_between_p, modified_between_p, modified_in_p, refers_to_regno_p, reg_overlap_mentioned_p, rtx_equal_p, volatile_insn_p, volatile_refs_p, side_effects_p, may_trap_p, inequality_comparisons_p, replace_rtx, replace_regs, jmp_uses_reg_or_mem, for_each_rtx, regno_use_in): Likewise. * sched.c (sched_analyze_2, attach_deaths): Likewise. * stupid.c (stupid_mark_refs): Likewise. * unroll.c (remap_split_bivs): Likewise. * varasm.c (mark_constants): Likewise. * a29k/a29k.c (uses_local_reg_p): Likewise. * alpha/alpha.c (summarize_insn): Likewise. * arm/arm.c (symbol_mentioned_p, label_mentioned_p, eliminate_lr2ip): Likewise. * arm/thumb.c (symbol_mentioned_p, label_mentioned_p): Likewise. * i386/i386.c (symbolic_reference_mentioned_p, copy_all_rtx, reg_mentioned_in_mem): Likewise. * ns32k/ns32k.c (global_symbolic_reference_mentioned_p, symbolic_reference_mentioned_p): Likewise. * romp/romp.c (unsigned_comparisons_p, hash_rtx): Likewise. * sh/sh.c (regs_used, mark_use): Likewise. * vax/vax.c (vax_rtx_cost): Likewise. From-SVN: r28784
1999-08-21 01:05:25 +02:00
register const char *fmt;
1992-02-01 09:24:22 +01:00
if (x == 0)
return;
code = GET_CODE (x);
switch (code)
{
case REG:
case CONST_INT:
case CONST:
case CONST_DOUBLE:
case SYMBOL_REF:
case LABEL_REF:
case PC:
case CC0:
case ADDR_VEC:
case ADDR_DIFF_VEC:
case USE:
case CLOBBER:
return;
case MEM:
{
rtx src_reg;
rtx add_val;
rtx mult_val;
rtx ext_val;
1992-02-01 09:24:22 +01:00
int benefit;
/* This code used to disable creating GIVs with mult_val == 1 and
add_val == 0. However, this leads to lost optimizations when
it comes time to combine a set of related DEST_ADDR GIVs, since
this one would not be seen. */
1992-02-01 09:24:22 +01:00
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (general_induction_var (loop, XEXP (x, 0), &src_reg, &add_val,
&mult_val, &ext_val, 1, &benefit,
GET_MODE (x)))
1992-02-01 09:24:22 +01:00
{
/* Found one; record it. */
struct induction *v
Remove obstacks. * Makefile.in (ggc-callbacks.o): Remove target. (flow.o): Depend on GGC_H. * alias.c (init_alias_analysis): Remove ggc_p conditionals. (end_alias_analysis): Likewise. * basic-block.h (init_flow): New function. (allocate_reg_life_data): Declare. * bb-reorder.c (function_obstack): Replace with ... (flow_obstack): ... new variable. (fixup_reorder_chain): Use it. * c-decl.c (ggc_p): Remove. (caller-save.c): Don't call oballoc/obfree. * combine.c (struct undobuf): Remove storage. (try_combine): Don't call oballoc. (undo_all): Don't call obfree. * cse.c (insert): Use xmalloc, not oballoc. (cse_main): Adjust accordingly. * dwarf2out.c (save_rtx): Remove obstack code. (dwarf2out_init): Remove ggc_p conditionals. * emit-rtl.c (rtl_obstack): Remove. (gen_rtx_CONST_INT): Remove ggc_p conditionals. (make_insn_raw): Likewise. (emit_insn_before): Likewise. (emit_insn_after): Likewise. (emit_insn): Likewise. (gen_sequence): Likewise. (copy_insn_1): Remove handling of `b' RTL components. (init_emit_once): Remove ggc_p conditionals. * except.c (create_rethrow_ref): Don't fool with obstacks. (add_partial_entry): Likewise. (call_get_eh_context): Likewise. (begin_protect_partials): Likewise. (protect_with_terminate): Likewise. * explow.c (plus_constant_wide): Likewise. * expr.c (init_expr_once): Likewise. (emit_block_move): Likewise. (clear_storage): Likewise. (expand_expr): Likewise. * flow.c (function_obstack): Remove. (flow_obstack): New variable. (flow_firstobj): Likewise. (create_base_block): Use the flow_obstack. (split_block): Likewise. (split_edge): Likewise. (calculate_global_regs_live): Likewise. (allocate_bb_life_data): Make it static. Likewiwse. (init_flow): New function. (size_int_type_wide): Remove ggc_p conditionals. * function.c (push_function_context_to): Don't call save_tree_status. (pop_function_context_from): Or restore_tree_status. (assign_stack_local_1): Don't call push_obstacks. (find_fixup_replacement): Use xmalloc. (fixup_var_refs_insns): Free the storage. (insns_for_mem_walk): Don't mess with obstacks. (instantiate_decls): Likewise. (trampoline_address): Likewise. (expand_function_end): Likewise. * function.h (sturct function): Remove obstack-related variables. (save_tree_status): Don't declare. (restore_tree_status): Likewise. * gcse.c (compute_can_copy): Don't call oballoc/obfree. * genattrtab.c (operate_exp): Remove ggc_p conditionals. (simplify_cond): Likewise. (simplify_test_exp): Don't mess with obstacks. (optimize_attrs): Likewise. * gengenrtl.c (gendef): Don't include ggc_p conditionals. * ggc-callbacks.c (ggc_p): Remove. * ggc-none.c (ggc_p): Remove. * ggc.h (ggc_p): Don't declare. * integrate.c (save_for_inline): Don't mess with obstacks. (integrate_decl_tree): Likewise. (output_inline_function): Likewise. * lists.c (init_EXPR_INSN_LIST_cache): Likewise. * loop.c (temp_obstack): Remove. (rtl_obstack): Likewise. (init_loop): Don't mess with obstacks. (reg_address_cost): Free BIVs and GIVs. (check_insns_for_bivs): Use xmalloc, not oballoc. (find_mem_givs): Likewise. (record_biv): Likewise. (general_induction_var): Likewise. (product_cheap_p): Likewse. * optabs.c (init_one_libfunc): Remove ggc_p conditional. * print-tree.c (debug_tree): Don't use oballoc/obfree. (print_node): Likewise. * profile.c (output_func_start_profiler): Remove call to temporary_allocation. * reload1.c (eliminate_regs_in_insn): Don't mess with obstacks. * resource.c (mark_target_live_regs): Use xmalloc. (free_resource_info): Free the memory. * rtl.c (rtl_obstack): Remove. (rtvec_alloc): Don't mess with obstacks. (rtx_alloc): Likewise. (rtx_free): Remove. (copy_rtx): Don't handle `b' cases. (read_rtx): Use a local rtl_obstack. * rtl.h (oballoc): Remove. (obfree): Likewise. (pop_obstacks): Likewise. (push_obstacks): Likewise. (allocate_bb_life_data): Likewise. (allocate_reg_life_data): Likewise. (rtx_free): Likewise. * sdbout.c (sdbout_queue_anonymous_type): Use tree_cons, not saveable_tree_cons. * simplify-rtx.c (cselib_init): Don't mess with obstacks. * stmt.c (mark_block_nesting): Mark the label_chain. (epxand_label): Use ggc_alloc, not oballoc. (clear_last_expr): Don't mess with obstacks. (expand_decl_cleanup): Likewise. (expand_dcc_cleanup): Likewise. (expand_dhc_cleanup): Likewise. (expand_anon_union_decl): Likewise. (add_case_node): Use xmalloc, not oballoc. (free_case_nodes): New function. (expand_end_case): Call it. * stor-layout.c (layout_type): Don't mess with obstacks. (layout_type): Likewise. * toplev.c (wrapup_global_declarations): Likewise. (compile_file): Remove ggc_p conditionals. (rest_of_compilation): Call init_flow. Remove ggc_p conditionals. (decode_f_option): Remove ggc_p conditionals. * tree.c (function_maybepermanent_obstack): Remove. (maybepermanent_obstack): Likewise. (function_obstack): Likewise. (tmeporary_obstack): Likewise. (momentary_obstack): Likewise. (temp_decl_obstack): Likewise. (saveable_obstack): Likewise. (rtl_obstack): Likewise. (current_obstack): Likewise. (expression_obstack): Likewise. (struct obstack_stack): Likewise. (obstack_stack): Likewise. (obstack_stack_obstack): Likewise. (maybepermanent_firstobj): Likewise. (temporary_firstobj): Likewise. (momentary_firstobj): Likewise. (temp_decl_firstobj): Likewise. (momentary_function_firstobj): Likewise. (all_types_permanent): Likewise. (struct momentary_level): Likewise. (momentary_stack): Likewise. (init_obstacks): Remove initialization of removed obstacks. (save_tree_status): Remove. (restore_tree_status): Likewise. (temporary_allocation): Liekwise. (end_temporary_allocation): Liekwise. (resume_temporary_allocation): Likewise. (saveable_allocation): Likewise. (push_obstacks): Likewise. (push_obstacks_nochange): Likewise. (pop_obstacks): Likewise. (allocation_temporary_p): Likewise. (permanent_allocation): Likewise. (preserve_data): Likewise. (preserve_initializer): Likewise. (rtl_in_current_obstack): Likewise. (rtl_in_saveable_obstack): Likewise. (oballoc): Likewise. (obfree): Likewise. (savealloc): Likewise. (expralloc): Likewise. (print_obstack_name): Likewise. (debug_obstack): Likewise. (object_permanent_p): Likewise. (push_momentary): Likewise. (perserve_momentary): Likewise. (clear_momentary): Likewise. (pop_momentary): Likewise. (pop_momentary_nofree): Likewise. (suspend_momentary): Likewise. (resume_momentary): Likewise. (make_node): Don't set TREE_PERMANENT. (copy_node): Remove ggc_p conditionals. Don't set TYPE_OBSTACK. Don't set TREE_PERMANENT. (get_identifier): Remove ggc_p conditionals. (build_string): Likewise. (make_tree_vec): Likewise. (build_decl_list): Remove. (build_expr_list): Likewise. (tree_cons): Remove ggc_p conditionals. (decl_tree_cons): Remove. (expr_tree_cons): Likewise. (perm_tree_cons): Likewise. (temp_tree_cons): Likewise. (saveable_tree_cons): Likewise. (build1): Remove ggc_p conditionals. (build_parse_node): Likewise. (build_type_attribute_variant): Don't mess with obstacks. (build_type_copy): Likewise. (type_hash_canon): Likewise. (build_pointer_type): Likewise. (build_reference_type): Likewise. (build_index_type): Likewise. (build_range_type): Likewise. (dump_tree_statistics): Don't print obstack information. * tree.h (struct tree_common): Remove permanent_flag. (TREE_PERMANENT): Remove. (TREE_SET_PERMANENT): Likewise. (TYPE_OBSTACK): Likewise. (struct tree_type): Remove obstack. (oballoc): Remove. (savealloc): Likewise. (build_decl_list): Likewise. (build_expr_list): Likewise. (perm_tree_cons): Likewise. (temp_tree_cons): Likewise. (saveable_tree_cons): Likewise. (decl_tree_cons): Likewise. (expr_tree_cons): Likewise. (suspend_momentary): Likewise. (allocation_temporary_p): Likewise. (resume_momentary): Likewise. (push_obstacks_nochange): Likewise. (permanent_allocation): Likewise. (push_momentary): Likewise. (clear_momentary): Likewise. (pop_momentary): Likewise. (end_temporary_allocation): Likewise. (pop_obstacks): Likewise. (push_obstacks): Likewise. (pop_momentary_nofree): LIkewise. (preserve_momentary): Likewise. (saveable_allocation): Likewise. (temporary_allocation): Likewise. (resume_temporary_allocation): Likewise. (perserve_initializer): Likewise. (debug_obstack): Likewise. (rtl_in_current_obstack): Likewise. (rtl_in_saveable_obstack): Likewise. (obfree): Likewise. * varasm.c (current_obstack): Remove. (saveable_obstack): Remove. (rtl_obstack): Remove. (immed_double_const): Don't mess with obstacks. (immed_real_cons): Likewise. (output_constant_def): Likewise. (init_varasm_status): Use xcalloc. (mark_pool_constant): Mark the pool constant itself. (free_varasm_status): Free memory. (decode_rtx_const): Call bzero directly, rather than expanding it inline. (record_rtx_const): Don't mess with obstacks. (force_const_mem): Likewise. * config/arm/arm.c (arm_encode_call_attribute): Remove ggc_p conditionals. (aof_pic_entry): Likewise. * config/ia64/ia64.c (ia64_encode_section_info): Likewise. * config/m32r/m32r.c (m32r_encode_section_info): Likewise. * config/pa/pa.c (saveable_obstack): Remove. (rtl_obstack): Likewise. (current_obstack): Likewise. (output_call): Don't mess with obstacks. (hppa_encode_label): Remove ggc_p conditionals. * config/romp/romp.c (get_symref): Don't mess with obstacks. * config/rs6000/rs6000.c (output_toc): Remove ggc_p conditional. (rs6000_encode_section_info): Likewise. * config/sh/sh.c (get_fpscr_rtx): Likewise. From-SVN: r36856
2000-10-13 08:26:46 +02:00
= (struct induction *) xmalloc (sizeof (struct induction));
1992-02-01 09:24:22 +01:00
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
record_giv (loop, v, insn, src_reg, addr_placeholder, mult_val,
add_val, ext_val, benefit, DEST_ADDR,
not_every_iteration, maybe_multiple, &XEXP (x, 0));
1992-02-01 09:24:22 +01:00
v->mem_mode = GET_MODE (x);
}
}
return;
default:
break;
1992-02-01 09:24:22 +01:00
}
/* Recursively scan the subexpressions for other mem refs. */
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
if (fmt[i] == 'e')
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
find_mem_givs (loop, XEXP (x, i), insn, not_every_iteration,
maybe_multiple);
1992-02-01 09:24:22 +01:00
else if (fmt[i] == 'E')
for (j = 0; j < XVECLEN (x, i); j++)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
find_mem_givs (loop, XVECEXP (x, i, j), insn, not_every_iteration,
maybe_multiple);
1992-02-01 09:24:22 +01:00
}
/* Fill in the data about one biv update.
V is the `struct induction' in which we record the biv. (It is
allocated by the caller, with alloca.)
INSN is the insn that sets it.
DEST_REG is the biv's reg.
MULT_VAL is const1_rtx if the biv is being incremented here, in which case
INC_VAL is the increment. Otherwise, MULT_VAL is const0_rtx and the biv is
being set to INC_VAL.
NOT_EVERY_ITERATION is nonzero if this biv update is not know to be
executed every iteration; MAYBE_MULTIPLE is nonzero if this biv update
can be executed more than once per iteration. If MAYBE_MULTIPLE
and NOT_EVERY_ITERATION are both zero, we know that the biv update is
executed exactly once per iteration. */
1992-02-01 09:24:22 +01:00
static void
record_biv (loop, v, insn, dest_reg, inc_val, mult_val, location,
not_every_iteration, maybe_multiple)
struct loop *loop;
1992-02-01 09:24:22 +01:00
struct induction *v;
rtx insn;
rtx dest_reg;
rtx inc_val;
rtx mult_val;
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
rtx *location;
1992-02-01 09:24:22 +01:00
int not_every_iteration;
int maybe_multiple;
1992-02-01 09:24:22 +01:00
{
struct loop_ivs *ivs = LOOP_IVS (loop);
1992-02-01 09:24:22 +01:00
struct iv_class *bl;
v->insn = insn;
v->src_reg = dest_reg;
v->dest_reg = dest_reg;
v->mult_val = mult_val;
v->add_val = inc_val;
v->ext_dependant = NULL_RTX;
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
v->location = location;
1992-02-01 09:24:22 +01:00
v->mode = GET_MODE (dest_reg);
v->always_computable = ! not_every_iteration;
v->always_executed = ! not_every_iteration;
v->maybe_multiple = maybe_multiple;
1992-02-01 09:24:22 +01:00
/* Add this to the reg's iv_class, creating a class
if this is the first incrementation of the reg. */
bl = ivs->reg_biv_class[REGNO (dest_reg)];
1992-02-01 09:24:22 +01:00
if (bl == 0)
{
/* Create and initialize new iv_class. */
Remove obstacks. * Makefile.in (ggc-callbacks.o): Remove target. (flow.o): Depend on GGC_H. * alias.c (init_alias_analysis): Remove ggc_p conditionals. (end_alias_analysis): Likewise. * basic-block.h (init_flow): New function. (allocate_reg_life_data): Declare. * bb-reorder.c (function_obstack): Replace with ... (flow_obstack): ... new variable. (fixup_reorder_chain): Use it. * c-decl.c (ggc_p): Remove. (caller-save.c): Don't call oballoc/obfree. * combine.c (struct undobuf): Remove storage. (try_combine): Don't call oballoc. (undo_all): Don't call obfree. * cse.c (insert): Use xmalloc, not oballoc. (cse_main): Adjust accordingly. * dwarf2out.c (save_rtx): Remove obstack code. (dwarf2out_init): Remove ggc_p conditionals. * emit-rtl.c (rtl_obstack): Remove. (gen_rtx_CONST_INT): Remove ggc_p conditionals. (make_insn_raw): Likewise. (emit_insn_before): Likewise. (emit_insn_after): Likewise. (emit_insn): Likewise. (gen_sequence): Likewise. (copy_insn_1): Remove handling of `b' RTL components. (init_emit_once): Remove ggc_p conditionals. * except.c (create_rethrow_ref): Don't fool with obstacks. (add_partial_entry): Likewise. (call_get_eh_context): Likewise. (begin_protect_partials): Likewise. (protect_with_terminate): Likewise. * explow.c (plus_constant_wide): Likewise. * expr.c (init_expr_once): Likewise. (emit_block_move): Likewise. (clear_storage): Likewise. (expand_expr): Likewise. * flow.c (function_obstack): Remove. (flow_obstack): New variable. (flow_firstobj): Likewise. (create_base_block): Use the flow_obstack. (split_block): Likewise. (split_edge): Likewise. (calculate_global_regs_live): Likewise. (allocate_bb_life_data): Make it static. Likewiwse. (init_flow): New function. (size_int_type_wide): Remove ggc_p conditionals. * function.c (push_function_context_to): Don't call save_tree_status. (pop_function_context_from): Or restore_tree_status. (assign_stack_local_1): Don't call push_obstacks. (find_fixup_replacement): Use xmalloc. (fixup_var_refs_insns): Free the storage. (insns_for_mem_walk): Don't mess with obstacks. (instantiate_decls): Likewise. (trampoline_address): Likewise. (expand_function_end): Likewise. * function.h (sturct function): Remove obstack-related variables. (save_tree_status): Don't declare. (restore_tree_status): Likewise. * gcse.c (compute_can_copy): Don't call oballoc/obfree. * genattrtab.c (operate_exp): Remove ggc_p conditionals. (simplify_cond): Likewise. (simplify_test_exp): Don't mess with obstacks. (optimize_attrs): Likewise. * gengenrtl.c (gendef): Don't include ggc_p conditionals. * ggc-callbacks.c (ggc_p): Remove. * ggc-none.c (ggc_p): Remove. * ggc.h (ggc_p): Don't declare. * integrate.c (save_for_inline): Don't mess with obstacks. (integrate_decl_tree): Likewise. (output_inline_function): Likewise. * lists.c (init_EXPR_INSN_LIST_cache): Likewise. * loop.c (temp_obstack): Remove. (rtl_obstack): Likewise. (init_loop): Don't mess with obstacks. (reg_address_cost): Free BIVs and GIVs. (check_insns_for_bivs): Use xmalloc, not oballoc. (find_mem_givs): Likewise. (record_biv): Likewise. (general_induction_var): Likewise. (product_cheap_p): Likewse. * optabs.c (init_one_libfunc): Remove ggc_p conditional. * print-tree.c (debug_tree): Don't use oballoc/obfree. (print_node): Likewise. * profile.c (output_func_start_profiler): Remove call to temporary_allocation. * reload1.c (eliminate_regs_in_insn): Don't mess with obstacks. * resource.c (mark_target_live_regs): Use xmalloc. (free_resource_info): Free the memory. * rtl.c (rtl_obstack): Remove. (rtvec_alloc): Don't mess with obstacks. (rtx_alloc): Likewise. (rtx_free): Remove. (copy_rtx): Don't handle `b' cases. (read_rtx): Use a local rtl_obstack. * rtl.h (oballoc): Remove. (obfree): Likewise. (pop_obstacks): Likewise. (push_obstacks): Likewise. (allocate_bb_life_data): Likewise. (allocate_reg_life_data): Likewise. (rtx_free): Likewise. * sdbout.c (sdbout_queue_anonymous_type): Use tree_cons, not saveable_tree_cons. * simplify-rtx.c (cselib_init): Don't mess with obstacks. * stmt.c (mark_block_nesting): Mark the label_chain. (epxand_label): Use ggc_alloc, not oballoc. (clear_last_expr): Don't mess with obstacks. (expand_decl_cleanup): Likewise. (expand_dcc_cleanup): Likewise. (expand_dhc_cleanup): Likewise. (expand_anon_union_decl): Likewise. (add_case_node): Use xmalloc, not oballoc. (free_case_nodes): New function. (expand_end_case): Call it. * stor-layout.c (layout_type): Don't mess with obstacks. (layout_type): Likewise. * toplev.c (wrapup_global_declarations): Likewise. (compile_file): Remove ggc_p conditionals. (rest_of_compilation): Call init_flow. Remove ggc_p conditionals. (decode_f_option): Remove ggc_p conditionals. * tree.c (function_maybepermanent_obstack): Remove. (maybepermanent_obstack): Likewise. (function_obstack): Likewise. (tmeporary_obstack): Likewise. (momentary_obstack): Likewise. (temp_decl_obstack): Likewise. (saveable_obstack): Likewise. (rtl_obstack): Likewise. (current_obstack): Likewise. (expression_obstack): Likewise. (struct obstack_stack): Likewise. (obstack_stack): Likewise. (obstack_stack_obstack): Likewise. (maybepermanent_firstobj): Likewise. (temporary_firstobj): Likewise. (momentary_firstobj): Likewise. (temp_decl_firstobj): Likewise. (momentary_function_firstobj): Likewise. (all_types_permanent): Likewise. (struct momentary_level): Likewise. (momentary_stack): Likewise. (init_obstacks): Remove initialization of removed obstacks. (save_tree_status): Remove. (restore_tree_status): Likewise. (temporary_allocation): Liekwise. (end_temporary_allocation): Liekwise. (resume_temporary_allocation): Likewise. (saveable_allocation): Likewise. (push_obstacks): Likewise. (push_obstacks_nochange): Likewise. (pop_obstacks): Likewise. (allocation_temporary_p): Likewise. (permanent_allocation): Likewise. (preserve_data): Likewise. (preserve_initializer): Likewise. (rtl_in_current_obstack): Likewise. (rtl_in_saveable_obstack): Likewise. (oballoc): Likewise. (obfree): Likewise. (savealloc): Likewise. (expralloc): Likewise. (print_obstack_name): Likewise. (debug_obstack): Likewise. (object_permanent_p): Likewise. (push_momentary): Likewise. (perserve_momentary): Likewise. (clear_momentary): Likewise. (pop_momentary): Likewise. (pop_momentary_nofree): Likewise. (suspend_momentary): Likewise. (resume_momentary): Likewise. (make_node): Don't set TREE_PERMANENT. (copy_node): Remove ggc_p conditionals. Don't set TYPE_OBSTACK. Don't set TREE_PERMANENT. (get_identifier): Remove ggc_p conditionals. (build_string): Likewise. (make_tree_vec): Likewise. (build_decl_list): Remove. (build_expr_list): Likewise. (tree_cons): Remove ggc_p conditionals. (decl_tree_cons): Remove. (expr_tree_cons): Likewise. (perm_tree_cons): Likewise. (temp_tree_cons): Likewise. (saveable_tree_cons): Likewise. (build1): Remove ggc_p conditionals. (build_parse_node): Likewise. (build_type_attribute_variant): Don't mess with obstacks. (build_type_copy): Likewise. (type_hash_canon): Likewise. (build_pointer_type): Likewise. (build_reference_type): Likewise. (build_index_type): Likewise. (build_range_type): Likewise. (dump_tree_statistics): Don't print obstack information. * tree.h (struct tree_common): Remove permanent_flag. (TREE_PERMANENT): Remove. (TREE_SET_PERMANENT): Likewise. (TYPE_OBSTACK): Likewise. (struct tree_type): Remove obstack. (oballoc): Remove. (savealloc): Likewise. (build_decl_list): Likewise. (build_expr_list): Likewise. (perm_tree_cons): Likewise. (temp_tree_cons): Likewise. (saveable_tree_cons): Likewise. (decl_tree_cons): Likewise. (expr_tree_cons): Likewise. (suspend_momentary): Likewise. (allocation_temporary_p): Likewise. (resume_momentary): Likewise. (push_obstacks_nochange): Likewise. (permanent_allocation): Likewise. (push_momentary): Likewise. (clear_momentary): Likewise. (pop_momentary): Likewise. (end_temporary_allocation): Likewise. (pop_obstacks): Likewise. (push_obstacks): Likewise. (pop_momentary_nofree): LIkewise. (preserve_momentary): Likewise. (saveable_allocation): Likewise. (temporary_allocation): Likewise. (resume_temporary_allocation): Likewise. (perserve_initializer): Likewise. (debug_obstack): Likewise. (rtl_in_current_obstack): Likewise. (rtl_in_saveable_obstack): Likewise. (obfree): Likewise. * varasm.c (current_obstack): Remove. (saveable_obstack): Remove. (rtl_obstack): Remove. (immed_double_const): Don't mess with obstacks. (immed_real_cons): Likewise. (output_constant_def): Likewise. (init_varasm_status): Use xcalloc. (mark_pool_constant): Mark the pool constant itself. (free_varasm_status): Free memory. (decode_rtx_const): Call bzero directly, rather than expanding it inline. (record_rtx_const): Don't mess with obstacks. (force_const_mem): Likewise. * config/arm/arm.c (arm_encode_call_attribute): Remove ggc_p conditionals. (aof_pic_entry): Likewise. * config/ia64/ia64.c (ia64_encode_section_info): Likewise. * config/m32r/m32r.c (m32r_encode_section_info): Likewise. * config/pa/pa.c (saveable_obstack): Remove. (rtl_obstack): Likewise. (current_obstack): Likewise. (output_call): Don't mess with obstacks. (hppa_encode_label): Remove ggc_p conditionals. * config/romp/romp.c (get_symref): Don't mess with obstacks. * config/rs6000/rs6000.c (output_toc): Remove ggc_p conditional. (rs6000_encode_section_info): Likewise. * config/sh/sh.c (get_fpscr_rtx): Likewise. From-SVN: r36856
2000-10-13 08:26:46 +02:00
bl = (struct iv_class *) xmalloc (sizeof (struct iv_class));
1992-02-01 09:24:22 +01:00
bl->regno = REGNO (dest_reg);
bl->biv = 0;
bl->giv = 0;
bl->biv_count = 0;
bl->giv_count = 0;
/* Set initial value to the reg itself. */
bl->initial_value = dest_reg;
/* We haven't seen the initializing insn yet */
1992-02-01 09:24:22 +01:00
bl->init_insn = 0;
bl->init_set = 0;
bl->initial_test = 0;
bl->incremented = 0;
bl->eliminable = 0;
bl->nonneg = 0;
bl->reversed = 0;
bl->total_benefit = 0;
1992-02-01 09:24:22 +01:00
/* Add this class to ivs->loop_iv_list. */
bl->next = ivs->loop_iv_list;
ivs->loop_iv_list = bl;
1992-02-01 09:24:22 +01:00
/* Put it in the array of biv register classes. */
ivs->reg_biv_class[REGNO (dest_reg)] = bl;
1992-02-01 09:24:22 +01:00
}
/* Update IV_CLASS entry for this biv. */
v->next_iv = bl->biv;
bl->biv = v;
bl->biv_count++;
if (mult_val == const1_rtx)
bl->incremented = 1;
if (loop_dump_stream)
{
fprintf (loop_dump_stream,
"Insn %d: possible biv, reg %d,",
INSN_UID (insn), REGNO (dest_reg));
if (GET_CODE (inc_val) == CONST_INT)
{
fprintf (loop_dump_stream, " const =");
fprintf (loop_dump_stream, HOST_WIDE_INT_PRINT_DEC, INTVAL (inc_val));
fputc ('\n', loop_dump_stream);
}
1992-02-01 09:24:22 +01:00
else
{
fprintf (loop_dump_stream, " const = ");
print_rtl (loop_dump_stream, inc_val);
fprintf (loop_dump_stream, "\n");
}
}
}
/* Fill in the data about one giv.
V is the `struct induction' in which we record the giv. (It is
allocated by the caller, with alloca.)
INSN is the insn that sets it.
BENEFIT estimates the savings from deleting this insn.
TYPE is DEST_REG or DEST_ADDR; it says whether the giv is computed
into a register or is used as a memory address.
SRC_REG is the biv reg which the giv is computed from.
DEST_REG is the giv's reg (if the giv is stored in a reg).
MULT_VAL and ADD_VAL are the coefficients used to compute the giv.
LOCATION points to the place where this giv's value appears in INSN. */
static void
record_giv (loop, v, insn, src_reg, dest_reg, mult_val, add_val, ext_val,
benefit, type, not_every_iteration, maybe_multiple, location)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
const struct loop *loop;
1992-02-01 09:24:22 +01:00
struct induction *v;
rtx insn;
rtx src_reg;
rtx dest_reg;
rtx mult_val, add_val, ext_val;
1992-02-01 09:24:22 +01:00
int benefit;
enum g_types type;
int not_every_iteration, maybe_multiple;
1992-02-01 09:24:22 +01:00
rtx *location;
{
struct loop_ivs *ivs = LOOP_IVS (loop);
1992-02-01 09:24:22 +01:00
struct induction *b;
struct iv_class *bl;
rtx set = single_set (insn);
rtx temp;
/* Attempt to prove constantness of the values. */
temp = simplify_rtx (add_val);
if (temp)
add_val = temp;
1992-02-01 09:24:22 +01:00
v->insn = insn;
v->src_reg = src_reg;
v->giv_type = type;
v->dest_reg = dest_reg;
v->mult_val = mult_val;
v->add_val = add_val;
v->ext_dependant = ext_val;
1992-02-01 09:24:22 +01:00
v->benefit = benefit;
v->location = location;
v->cant_derive = 0;
v->combined_with = 0;
v->maybe_multiple = maybe_multiple;
1992-02-01 09:24:22 +01:00
v->maybe_dead = 0;
v->derive_adjustment = 0;
v->same = 0;
v->ignore = 0;
v->new_reg = 0;
v->final_value = 0;
v->same_insn = 0;
v->auto_inc_opt = 0;
* Integrate alias analysis changes from jfc@mit.edu * Makefile.in (OBJS): Add alias.o (alias.o): Add dependencies. * alias.c: New file. * sched.c: Remove alias analysis code. It lives in alias.c now. (reg_last_uses_size): Declare. (sched_analyze_2): Add new arguments to true_dependence. (sched_analyze_insn): Use reg_last_uses_size instead of max_reg. (schedule_block): Initialize reg_last_uses_size. (schedule_insns): Always call init_alias_analysis. * calls.c (expand_call): Note calls to malloc, calloc, and realloc; mark return value from such functions as a pointer and keep track of them for alias analysis. If a return value from a function is a pointer, mark it as such. * combine.c (distribute_notes): Handle REG_NOALIAS. * cse.c (struct write_data): Delete. No longer needed. (invalidate): Don't call set_nonvarying_address_components anymore. Use true_dependence to decide if an entry should be removed from the hash table. (invalidate_memory): Remove WRITES argument, simplify appropriately. Fix all callers. (note_mem_written): Similarly for WRITE_PTR argument. (invalidate_from_clobbers): Similarly for W argument. (invalidate_for_call): Remove memory elements from the hash table. (refers_to_mem_p, cse_rtx_addr_varies_p): Deleted. (cse_rtx_varies_p): New function. Derived from old cse_rtx_addr_varies_p. (cse_insn): Remove WRITES_MEMORY and INIT variables and all references. Don't call note_mem_written anymore. Stack pushes invalidate the stack pointer if PUSH_ROUNDING is defined. No longer need to call cse_rtx_addr_varies_p to decide if a MEM should be invalidated. (skipped_writes_memory): Remove variable. (invalidate_skipped_set): Simplify and wewrite to use invalidate_memory. (invalidate_skipped_block): Simplify for new alias analysis code. (cse_set_around_loop): Likewise. (cse_main): Call init_alias_analysis. * flags.h (flag_alias_check, flag_argument_noalias): Declare. * toplev.c (flag_alias_check, flag_argument_noalias): Define. (f_options): Add new alias checking arguments. (main): Set flag_alias_check when optimizing. * local_alloc (validate_equiv_mem_from_store): Add new arguments to true_dependence. (memref_referenced_p): Likewise. * loop.c (NUM_STORES): Increase to 30. (prescan_loop): Only non-constant calls set unknown_address_altered. (invariant_p): Add new arguments to true_dependence. (record_giv): Initialize unrolled and shared fields. (emit_iv_add_mult): Call record_base_value as needed. * loop.h (struct induction): Add unrolled and shared fields. * unroll.c (unroll_loop): Call record_base_value as needed. (copy_loop_body): Likewise. (final_biv_value): Likewise. (final_giv_value): Likewise. (find_splittable_regs): Likewise. Only create one new pseudo if we have multiple address GIVs that were combined with the same dst_reg GIV. Note when a new register is created due to unrolling. * rtl.c (reg_note_name): Add REG_NOALIAS. * rtl.h (enum reg_note): Similarly. (rtx_varies_p, may_trap_p, side_effects_p): Declare. (volatile_refs_p, volatile_insn_p, remove_note): Likewise. (note_stores, refers_to_regno_p, reg_overlap_mentioned_p): Likewise. (true_dependence, read_dependence, anti_dependence): Likewise. (output_dependence, init_alias_analysis, end_alias_analysis): Likewise. (mark_user_reg, mark_reg_pointer): Likewise. jfc's alias analysis code. From-SVN: r14768
1997-08-11 22:07:24 +02:00
v->unrolled = 0;
v->shared = 0;
1992-02-01 09:24:22 +01:00
/* The v->always_computable field is used in update_giv_derive, to
determine whether a giv can be used to derive another giv. For a
DEST_REG giv, INSN computes a new value for the giv, so its value
isn't computable if INSN insn't executed every iteration.
However, for a DEST_ADDR giv, INSN merely uses the value of the giv;
it does not compute a new value. Hence the value is always computable
regardless of whether INSN is executed each iteration. */
1992-02-01 09:24:22 +01:00
if (type == DEST_ADDR)
v->always_computable = 1;
else
v->always_computable = ! not_every_iteration;
v->always_executed = ! not_every_iteration;
1992-02-01 09:24:22 +01:00
if (type == DEST_ADDR)
{
v->mode = GET_MODE (*location);
v->lifetime = 1;
}
else /* type == DEST_REG */
{
v->mode = GET_MODE (SET_DEST (set));
v->lifetime = (uid_luid[REGNO_LAST_UID (REGNO (dest_reg))]
- uid_luid[REGNO_FIRST_UID (REGNO (dest_reg))]);
1992-02-01 09:24:22 +01:00
/* If the lifetime is zero, it means that this register is
really a dead store. So mark this as a giv that can be
1996-07-04 00:07:53 +02:00
ignored. This will not prevent the biv from being eliminated. */
1992-02-01 09:24:22 +01:00
if (v->lifetime == 0)
v->ignore = 1;
REG_IV_TYPE (ivs, REGNO (dest_reg)) = GENERAL_INDUCT;
REG_IV_INFO (ivs, REGNO (dest_reg)) = v;
1992-02-01 09:24:22 +01:00
}
/* Add the giv to the class of givs computed from one biv. */
bl = ivs->reg_biv_class[REGNO (src_reg)];
1992-02-01 09:24:22 +01:00
if (bl)
{
v->next_iv = bl->giv;
bl->giv = v;
/* Don't count DEST_ADDR. This is supposed to count the number of
insns that calculate givs. */
if (type == DEST_REG)
bl->giv_count++;
bl->total_benefit += benefit;
}
else
/* Fatal error, biv missing for this giv? */
abort ();
if (type == DEST_ADDR)
v->replaceable = 1;
else
{
/* The giv can be replaced outright by the reduced register only if all
of the following conditions are true:
- the insn that sets the giv is always executed on any iteration
on which the giv is used at all
(there are two ways to deduce this:
either the insn is executed on every iteration,
or all uses follow that insn in the same basic block),
- the giv is not used outside the loop
- no assignments to the biv occur during the giv's lifetime. */
if (REGNO_FIRST_UID (REGNO (dest_reg)) == INSN_UID (insn)
1992-02-01 09:24:22 +01:00
/* Previous line always fails if INSN was moved by loop opt. */
&& uid_luid[REGNO_LAST_UID (REGNO (dest_reg))]
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
< INSN_LUID (loop->end)
1992-02-01 09:24:22 +01:00
&& (! not_every_iteration
|| last_use_this_basic_block (dest_reg, insn)))
{
1992-02-01 09:24:22 +01:00
/* Now check that there are no assignments to the biv within the
giv's lifetime. This requires two separate checks. */
/* Check each biv update, and fail if any are between the first
and last use of the giv.
1992-02-01 09:24:22 +01:00
If this loop contains an inner loop that was unrolled, then
the insn modifying the biv may have been emitted by the loop
unrolling code, and hence does not have a valid luid. Just
mark the biv as not replaceable in this case. It is not very
useful as a biv, because it is used in two different loops.
It is very unlikely that we would be able to optimize the giv
using this biv anyways. */
v->replaceable = 1;
for (b = bl->biv; b; b = b->next_iv)
{
if (INSN_UID (b->insn) >= max_uid_for_loop
|| ((uid_luid[INSN_UID (b->insn)]
>= uid_luid[REGNO_FIRST_UID (REGNO (dest_reg))])
1992-02-01 09:24:22 +01:00
&& (uid_luid[INSN_UID (b->insn)]
<= uid_luid[REGNO_LAST_UID (REGNO (dest_reg))])))
1992-02-01 09:24:22 +01:00
{
v->replaceable = 0;
v->not_replaceable = 1;
break;
}
1992-02-01 09:24:22 +01:00
}
/* If there are any backwards branches that go from after the
biv update to before it, then this giv is not replaceable. */
1992-02-01 09:24:22 +01:00
if (v->replaceable)
for (b = bl->biv; b; b = b->next_iv)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (back_branch_in_range_p (loop, b->insn))
{
v->replaceable = 0;
v->not_replaceable = 1;
break;
}
1992-02-01 09:24:22 +01:00
}
else
{
/* May still be replaceable, we don't have enough info here to
decide. */
v->replaceable = 0;
v->not_replaceable = 0;
}
}
/* Record whether the add_val contains a const_int, for later use by
combine_givs. */
{
rtx tem = add_val;
v->no_const_addval = 1;
if (tem == const0_rtx)
;
else if (CONSTANT_P (add_val))
v->no_const_addval = 0;
if (GET_CODE (tem) == PLUS)
{
while (1)
{
if (GET_CODE (XEXP (tem, 0)) == PLUS)
tem = XEXP (tem, 0);
else if (GET_CODE (XEXP (tem, 1)) == PLUS)
tem = XEXP (tem, 1);
else
break;
}
if (CONSTANT_P (XEXP (tem, 1)))
v->no_const_addval = 0;
}
}
1992-02-01 09:24:22 +01:00
if (loop_dump_stream)
{
if (type == DEST_REG)
fprintf (loop_dump_stream, "Insn %d: giv reg %d",
INSN_UID (insn), REGNO (dest_reg));
else
fprintf (loop_dump_stream, "Insn %d: dest address",
INSN_UID (insn));
fprintf (loop_dump_stream, " src reg %d benefit %d",
REGNO (src_reg), v->benefit);
fprintf (loop_dump_stream, " lifetime %d",
v->lifetime);
1992-02-01 09:24:22 +01:00
if (v->replaceable)
fprintf (loop_dump_stream, " replaceable");
if (v->no_const_addval)
fprintf (loop_dump_stream, " ncav");
if (v->ext_dependant)
{
switch (GET_CODE (v->ext_dependant))
{
case SIGN_EXTEND:
fprintf (loop_dump_stream, " ext se");
break;
case ZERO_EXTEND:
fprintf (loop_dump_stream, " ext ze");
break;
case TRUNCATE:
fprintf (loop_dump_stream, " ext tr");
break;
default:
abort ();
}
}
1992-02-01 09:24:22 +01:00
if (GET_CODE (mult_val) == CONST_INT)
{
fprintf (loop_dump_stream, " mult ");
fprintf (loop_dump_stream, HOST_WIDE_INT_PRINT_DEC, INTVAL (mult_val));
}
1992-02-01 09:24:22 +01:00
else
{
fprintf (loop_dump_stream, " mult ");
print_rtl (loop_dump_stream, mult_val);
}
if (GET_CODE (add_val) == CONST_INT)
{
fprintf (loop_dump_stream, " add ");
fprintf (loop_dump_stream, HOST_WIDE_INT_PRINT_DEC, INTVAL (add_val));
}
1992-02-01 09:24:22 +01:00
else
{
fprintf (loop_dump_stream, " add ");
print_rtl (loop_dump_stream, add_val);
}
}
if (loop_dump_stream)
fprintf (loop_dump_stream, "\n");
}
/* All this does is determine whether a giv can be made replaceable because
its final value can be calculated. This code can not be part of record_giv
above, because final_giv_value requires that the number of loop iterations
be known, and that can not be accurately calculated until after all givs
have been identified. */
static void
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
check_final_value (loop, v)
const struct loop *loop;
1992-02-01 09:24:22 +01:00
struct induction *v;
{
struct loop_ivs *ivs = LOOP_IVS (loop);
1992-02-01 09:24:22 +01:00
struct iv_class *bl;
rtx final_value = 0;
bl = ivs->reg_biv_class[REGNO (v->src_reg)];
1992-02-01 09:24:22 +01:00
/* DEST_ADDR givs will never reach here, because they are always marked
replaceable above in record_giv. */
/* The giv can be replaced outright by the reduced register only if all
of the following conditions are true:
- the insn that sets the giv is always executed on any iteration
on which the giv is used at all
(there are two ways to deduce this:
either the insn is executed on every iteration,
or all uses follow that insn in the same basic block),
- its final value can be calculated (this condition is different
than the one above in record_giv)
- it's not used before the it's set
1992-02-01 09:24:22 +01:00
- no assignments to the biv occur during the giv's lifetime. */
#if 0
/* This is only called now when replaceable is known to be false. */
/* Clear replaceable, so that it won't confuse final_giv_value. */
v->replaceable = 0;
#endif
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if ((final_value = final_giv_value (loop, v))
1992-02-01 09:24:22 +01:00
&& (v->always_computable || last_use_this_basic_block (v->dest_reg, v->insn)))
{
int biv_increment_seen = 0, before_giv_insn = 0;
1992-02-01 09:24:22 +01:00
rtx p = v->insn;
rtx last_giv_use;
v->replaceable = 1;
/* When trying to determine whether or not a biv increment occurs
during the lifetime of the giv, we can ignore uses of the variable
outside the loop because final_value is true. Hence we can not
use regno_last_uid and regno_first_uid as above in record_giv. */
/* Search the loop to determine whether any assignments to the
biv occur during the giv's lifetime. Start with the insn
that sets the giv, and search around the loop until we come
back to that insn again.
Also fail if there is a jump within the giv's lifetime that jumps
to somewhere outside the lifetime but still within the loop. This
catches spaghetti code where the execution order is not linear, and
hence the above test fails. Here we assume that the giv lifetime
does not extend from one iteration of the loop to the next, so as
to make the test easier. Since the lifetime isn't known yet,
this requires two loops. See also record_giv above. */
last_giv_use = v->insn;
while (1)
{
p = NEXT_INSN (p);
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (p == loop->end)
{
before_giv_insn = 1;
p = NEXT_INSN (loop->start);
}
1992-02-01 09:24:22 +01:00
if (p == v->insn)
break;
if (GET_CODE (p) == INSN || GET_CODE (p) == JUMP_INSN
|| GET_CODE (p) == CALL_INSN)
{
/* It is possible for the BIV increment to use the GIV if we
have a cycle. Thus we must be sure to check each insn for
both BIV and GIV uses, and we must check for BIV uses
first. */
if (! biv_increment_seen
&& reg_set_p (v->src_reg, PATTERN (p)))
biv_increment_seen = 1;
if (reg_mentioned_p (v->dest_reg, PATTERN (p)))
1992-02-01 09:24:22 +01:00
{
if (biv_increment_seen || before_giv_insn)
1992-02-01 09:24:22 +01:00
{
v->replaceable = 0;
v->not_replaceable = 1;
break;
}
last_giv_use = p;
1992-02-01 09:24:22 +01:00
}
}
}
1992-02-01 09:24:22 +01:00
/* Now that the lifetime of the giv is known, check for branches
from within the lifetime to outside the lifetime if it is still
replaceable. */
if (v->replaceable)
{
p = v->insn;
while (1)
{
p = NEXT_INSN (p);
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (p == loop->end)
p = NEXT_INSN (loop->start);
1992-02-01 09:24:22 +01:00
if (p == last_giv_use)
break;
if (GET_CODE (p) == JUMP_INSN && JUMP_LABEL (p)
&& LABEL_NAME (JUMP_LABEL (p))
&& ((loop_insn_first_p (JUMP_LABEL (p), v->insn)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
&& loop_insn_first_p (loop->start, JUMP_LABEL (p)))
|| (loop_insn_first_p (last_giv_use, JUMP_LABEL (p))
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
&& loop_insn_first_p (JUMP_LABEL (p), loop->end))))
1992-02-01 09:24:22 +01:00
{
v->replaceable = 0;
v->not_replaceable = 1;
if (loop_dump_stream)
fprintf (loop_dump_stream,
"Found branch outside giv lifetime.\n");
break;
}
}
}
/* If it is replaceable, then save the final value. */
if (v->replaceable)
v->final_value = final_value;
}
if (loop_dump_stream && v->replaceable)
fprintf (loop_dump_stream, "Insn %d: giv reg %d final_value replaceable\n",
INSN_UID (v->insn), REGNO (v->dest_reg));
}
/* Update the status of whether a giv can derive other givs.
We need to do something special if there is or may be an update to the biv
between the time the giv is defined and the time it is used to derive
another giv.
In addition, a giv that is only conditionally set is not allowed to
derive another giv once a label has been passed.
The cases we look at are when a label or an update to a biv is passed. */
static void
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
update_giv_derive (loop, p)
const struct loop *loop;
1992-02-01 09:24:22 +01:00
rtx p;
{
struct loop_ivs *ivs = LOOP_IVS (loop);
1992-02-01 09:24:22 +01:00
struct iv_class *bl;
struct induction *biv, *giv;
rtx tem;
int dummy;
/* Search all IV classes, then all bivs, and finally all givs.
There are three cases we are concerned with. First we have the situation
1992-02-01 09:24:22 +01:00
of a giv that is only updated conditionally. In that case, it may not
derive any givs after a label is passed.
The second case is when a biv update occurs, or may occur, after the
definition of a giv. For certain biv updates (see below) that are
known to occur between the giv definition and use, we can adjust the
giv definition. For others, or when the biv update is conditional,
we must prevent the giv from deriving any other givs. There are two
sub-cases within this case.
If this is a label, we are concerned with any biv update that is done
conditionally, since it may be done after the giv is defined followed by
a branch here (actually, we need to pass both a jump and a label, but
this extra tracking doesn't seem worth it).
If this is a jump, we are concerned about any biv update that may be
executed multiple times. We are actually only concerned about
backward jumps, but it is probably not worth performing the test
on the jump again here.
If this is a biv update, we must adjust the giv status to show that a
1992-02-01 09:24:22 +01:00
subsequent biv update was performed. If this adjustment cannot be done,
the giv cannot derive further givs. */
for (bl = ivs->loop_iv_list; bl; bl = bl->next)
1992-02-01 09:24:22 +01:00
for (biv = bl->biv; biv; biv = biv->next_iv)
if (GET_CODE (p) == CODE_LABEL || GET_CODE (p) == JUMP_INSN
|| biv->insn == p)
1992-02-01 09:24:22 +01:00
{
for (giv = bl->giv; giv; giv = giv->next_iv)
{
/* If cant_derive is already true, there is no point in
checking all of these conditions again. */
if (giv->cant_derive)
continue;
/* If this giv is conditionally set and we have passed a label,
it cannot derive anything. */
if (GET_CODE (p) == CODE_LABEL && ! giv->always_computable)
giv->cant_derive = 1;
/* Skip givs that have mult_val == 0, since
they are really invariants. Also skip those that are
replaceable, since we know their lifetime doesn't contain
any biv update. */
else if (giv->mult_val == const0_rtx || giv->replaceable)
continue;
/* The only way we can allow this giv to derive another
is if this is a biv increment and we can form the product
of biv->add_val and giv->mult_val. In this case, we will
be able to compute a compensation. */
else if (biv->insn == p)
{
rtx ext_val_dummy;
tem = 0;
if (biv->mult_val == const1_rtx)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
tem = simplify_giv_expr (loop,
gen_rtx_MULT (giv->mode,
biv->add_val,
giv->mult_val),
&ext_val_dummy, &dummy);
if (tem && giv->derive_adjustment)
tem = simplify_giv_expr
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
(loop,
gen_rtx_PLUS (giv->mode, tem, giv->derive_adjustment),
&ext_val_dummy, &dummy);
if (tem)
1992-02-01 09:24:22 +01:00
giv->derive_adjustment = tem;
else
giv->cant_derive = 1;
}
else if ((GET_CODE (p) == CODE_LABEL && ! biv->always_computable)
|| (GET_CODE (p) == JUMP_INSN && biv->maybe_multiple))
1992-02-01 09:24:22 +01:00
giv->cant_derive = 1;
}
}
}
/* Check whether an insn is an increment legitimate for a basic induction var.
X is the source of insn P, or a part of it.
MODE is the mode in which X should be interpreted.
1992-02-01 09:24:22 +01:00
DEST_REG is the putative biv, also the destination of the insn.
We accept patterns of these forms:
REG = REG + INVARIANT (includes REG = REG - CONSTANT)
1992-02-01 09:24:22 +01:00
REG = INVARIANT + REG
If X is suitable, we return 1, set *MULT_VAL to CONST1_RTX,
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
store the additive term into *INC_VAL, and store the place where
we found the additive term into *LOCATION.
1992-02-01 09:24:22 +01:00
If X is an assignment of an invariant into DEST_REG, we set
*MULT_VAL to CONST0_RTX, and store the invariant into *INC_VAL.
We also want to detect a BIV when it corresponds to a variable
whose mode was promoted via PROMOTED_MODE. In that case, an increment
of the variable may be a PLUS that adds a SUBREG of that variable to
an invariant and then sign- or zero-extends the result of the PLUS
into the variable.
Most GIVs in such cases will be in the promoted mode, since that is the
probably the natural computation mode (and almost certainly the mode
used for addresses) on the machine. So we view the pseudo-reg containing
the variable as the BIV, as if it were simply incremented.
Note that treating the entire pseudo as a BIV will result in making
simple increments to any GIVs based on it. However, if the variable
overflows in its declared mode but not its promoted mode, the result will
be incorrect. This is acceptable if the variable is signed, since
overflows in such cases are undefined, but not if it is unsigned, since
those overflows are defined. So we only check for SIGN_EXTEND and
not ZERO_EXTEND.
If we cannot find a biv, we return 0. */
1992-02-01 09:24:22 +01:00
static int
basic_induction_var (loop, x, mode, dest_reg, p, inc_val, mult_val, location)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
const struct loop *loop;
1992-02-01 09:24:22 +01:00
register rtx x;
enum machine_mode mode;
1992-02-01 09:24:22 +01:00
rtx dest_reg;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
rtx p;
1992-02-01 09:24:22 +01:00
rtx *inc_val;
rtx *mult_val;
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
rtx **location;
1992-02-01 09:24:22 +01:00
{
register enum rtx_code code;
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
rtx *argp, arg;
rtx insn, set = 0;
1992-02-01 09:24:22 +01:00
code = GET_CODE (x);
*location = NULL;
1992-02-01 09:24:22 +01:00
switch (code)
{
case PLUS:
if (rtx_equal_p (XEXP (x, 0), dest_reg)
|| (GET_CODE (XEXP (x, 0)) == SUBREG
&& SUBREG_PROMOTED_VAR_P (XEXP (x, 0))
&& SUBREG_REG (XEXP (x, 0)) == dest_reg))
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
{
argp = &XEXP (x, 1);
}
else if (rtx_equal_p (XEXP (x, 1), dest_reg)
|| (GET_CODE (XEXP (x, 1)) == SUBREG
&& SUBREG_PROMOTED_VAR_P (XEXP (x, 1))
&& SUBREG_REG (XEXP (x, 1)) == dest_reg))
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
{
argp = &XEXP (x, 0);
}
1992-02-01 09:24:22 +01:00
else
return 0;
1992-02-01 09:24:22 +01:00
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
arg = *argp;
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (loop_invariant_p (loop, arg) != 1)
1992-02-01 09:24:22 +01:00
return 0;
*inc_val = convert_modes (GET_MODE (dest_reg), GET_MODE (x), arg, 0);
1992-02-01 09:24:22 +01:00
*mult_val = const1_rtx;
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
*location = argp;
1992-02-01 09:24:22 +01:00
return 1;
case SUBREG:
/* If this is a SUBREG for a promoted variable, check the inner
value. */
if (SUBREG_PROMOTED_VAR_P (x))
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
return basic_induction_var (loop, SUBREG_REG (x),
GET_MODE (SUBREG_REG (x)),
dest_reg, p, inc_val, mult_val, location);
return 0;
1992-02-01 09:24:22 +01:00
case REG:
/* If this register is assigned in a previous insn, look at its
source, but don't go outside the loop or past a label. */
/* If this sets a register to itself, we would repeat any previous
biv increment if we applied this strategy blindly. */
if (rtx_equal_p (dest_reg, x))
return 0;
insn = p;
while (1)
{
rtx dest;
do
{
insn = PREV_INSN (insn);
}
while (insn && GET_CODE (insn) == NOTE
&& NOTE_LINE_NUMBER (insn) != NOTE_INSN_LOOP_BEG);
if (!insn)
break;
set = single_set (insn);
if (set == 0)
break;
dest = SET_DEST (set);
if (dest == x
|| (GET_CODE (dest) == SUBREG
&& (GET_MODE_SIZE (GET_MODE (dest)) <= UNITS_PER_WORD)
&& (GET_MODE_CLASS (GET_MODE (dest)) == MODE_INT)
&& SUBREG_REG (dest) == x))
return basic_induction_var (loop, SET_SRC (set),
(GET_MODE (SET_SRC (set)) == VOIDmode
? GET_MODE (x)
: GET_MODE (SET_SRC (set))),
dest_reg, insn,
inc_val, mult_val, location);
while (GET_CODE (dest) == SIGN_EXTRACT
|| GET_CODE (dest) == ZERO_EXTRACT
|| GET_CODE (dest) == SUBREG
|| GET_CODE (dest) == STRICT_LOW_PART)
dest = XEXP (dest, 0);
if (dest == x)
break;
}
/* Fall through. */
1992-02-01 09:24:22 +01:00
/* Can accept constant setting of biv only when inside inner most loop.
Otherwise, a biv of an inner loop may be incorrectly recognized
as a biv of the outer loop,
causing code to be moved INTO the inner loop. */
case MEM:
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (loop_invariant_p (loop, x) != 1)
1992-02-01 09:24:22 +01:00
return 0;
case CONST_INT:
case SYMBOL_REF:
case CONST:
/* convert_modes aborts if we try to convert to or from CCmode, so just
exclude that case. It is very unlikely that a condition code value
would be a useful iterator anyways. */
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (loop->level == 1
&& GET_MODE_CLASS (mode) != MODE_CC
&& GET_MODE_CLASS (GET_MODE (dest_reg)) != MODE_CC)
{
/* Possible bug here? Perhaps we don't know the mode of X. */
*inc_val = convert_modes (GET_MODE (dest_reg), mode, x, 0);
*mult_val = const0_rtx;
return 1;
}
1992-02-01 09:24:22 +01:00
else
return 0;
1992-02-01 09:24:22 +01:00
case SIGN_EXTEND:
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
return basic_induction_var (loop, XEXP (x, 0), GET_MODE (XEXP (x, 0)),
dest_reg, p, inc_val, mult_val, location);
case ASHIFTRT:
/* Similar, since this can be a sign extension. */
for (insn = PREV_INSN (p);
(insn && GET_CODE (insn) == NOTE
&& NOTE_LINE_NUMBER (insn) != NOTE_INSN_LOOP_BEG);
insn = PREV_INSN (insn))
;
if (insn)
set = single_set (insn);
if (! rtx_equal_p (dest_reg, XEXP (x, 0))
&& set && SET_DEST (set) == XEXP (x, 0)
&& GET_CODE (XEXP (x, 1)) == CONST_INT
&& INTVAL (XEXP (x, 1)) >= 0
&& GET_CODE (SET_SRC (set)) == ASHIFT
&& XEXP (x, 1) == XEXP (SET_SRC (set), 1))
return basic_induction_var (loop, XEXP (SET_SRC (set), 0),
GET_MODE (XEXP (x, 0)),
dest_reg, insn, inc_val, mult_val,
location);
return 0;
1992-02-01 09:24:22 +01:00
default:
return 0;
}
}
/* A general induction variable (giv) is any quantity that is a linear
function of a basic induction variable,
i.e. giv = biv * mult_val + add_val.
The coefficients can be any loop invariant quantity.
A giv need not be computed directly from the biv;
it can be computed by way of other givs. */
/* Determine whether X computes a giv.
If it does, return a nonzero value
which is the benefit from eliminating the computation of X;
set *SRC_REG to the register of the biv that it is computed from;
set *ADD_VAL and *MULT_VAL to the coefficients,
such that the value of X is biv * mult + add; */
static int
general_induction_var (loop, x, src_reg, add_val, mult_val, ext_val,
is_addr, pbenefit, addr_mode)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
const struct loop *loop;
1992-02-01 09:24:22 +01:00
rtx x;
rtx *src_reg;
rtx *add_val;
rtx *mult_val;
rtx *ext_val;
int is_addr;
int *pbenefit;
enum machine_mode addr_mode;
1992-02-01 09:24:22 +01:00
{
struct loop_ivs *ivs = LOOP_IVS (loop);
1992-02-01 09:24:22 +01:00
rtx orig_x = x;
/* If this is an invariant, forget it, it isn't a giv. */
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (loop_invariant_p (loop, x) == 1)
1992-02-01 09:24:22 +01:00
return 0;
*pbenefit = 0;
*ext_val = NULL_RTX;
x = simplify_giv_expr (loop, x, ext_val, pbenefit);
1992-02-01 09:24:22 +01:00
if (x == 0)
Remove obstacks. * Makefile.in (ggc-callbacks.o): Remove target. (flow.o): Depend on GGC_H. * alias.c (init_alias_analysis): Remove ggc_p conditionals. (end_alias_analysis): Likewise. * basic-block.h (init_flow): New function. (allocate_reg_life_data): Declare. * bb-reorder.c (function_obstack): Replace with ... (flow_obstack): ... new variable. (fixup_reorder_chain): Use it. * c-decl.c (ggc_p): Remove. (caller-save.c): Don't call oballoc/obfree. * combine.c (struct undobuf): Remove storage. (try_combine): Don't call oballoc. (undo_all): Don't call obfree. * cse.c (insert): Use xmalloc, not oballoc. (cse_main): Adjust accordingly. * dwarf2out.c (save_rtx): Remove obstack code. (dwarf2out_init): Remove ggc_p conditionals. * emit-rtl.c (rtl_obstack): Remove. (gen_rtx_CONST_INT): Remove ggc_p conditionals. (make_insn_raw): Likewise. (emit_insn_before): Likewise. (emit_insn_after): Likewise. (emit_insn): Likewise. (gen_sequence): Likewise. (copy_insn_1): Remove handling of `b' RTL components. (init_emit_once): Remove ggc_p conditionals. * except.c (create_rethrow_ref): Don't fool with obstacks. (add_partial_entry): Likewise. (call_get_eh_context): Likewise. (begin_protect_partials): Likewise. (protect_with_terminate): Likewise. * explow.c (plus_constant_wide): Likewise. * expr.c (init_expr_once): Likewise. (emit_block_move): Likewise. (clear_storage): Likewise. (expand_expr): Likewise. * flow.c (function_obstack): Remove. (flow_obstack): New variable. (flow_firstobj): Likewise. (create_base_block): Use the flow_obstack. (split_block): Likewise. (split_edge): Likewise. (calculate_global_regs_live): Likewise. (allocate_bb_life_data): Make it static. Likewiwse. (init_flow): New function. (size_int_type_wide): Remove ggc_p conditionals. * function.c (push_function_context_to): Don't call save_tree_status. (pop_function_context_from): Or restore_tree_status. (assign_stack_local_1): Don't call push_obstacks. (find_fixup_replacement): Use xmalloc. (fixup_var_refs_insns): Free the storage. (insns_for_mem_walk): Don't mess with obstacks. (instantiate_decls): Likewise. (trampoline_address): Likewise. (expand_function_end): Likewise. * function.h (sturct function): Remove obstack-related variables. (save_tree_status): Don't declare. (restore_tree_status): Likewise. * gcse.c (compute_can_copy): Don't call oballoc/obfree. * genattrtab.c (operate_exp): Remove ggc_p conditionals. (simplify_cond): Likewise. (simplify_test_exp): Don't mess with obstacks. (optimize_attrs): Likewise. * gengenrtl.c (gendef): Don't include ggc_p conditionals. * ggc-callbacks.c (ggc_p): Remove. * ggc-none.c (ggc_p): Remove. * ggc.h (ggc_p): Don't declare. * integrate.c (save_for_inline): Don't mess with obstacks. (integrate_decl_tree): Likewise. (output_inline_function): Likewise. * lists.c (init_EXPR_INSN_LIST_cache): Likewise. * loop.c (temp_obstack): Remove. (rtl_obstack): Likewise. (init_loop): Don't mess with obstacks. (reg_address_cost): Free BIVs and GIVs. (check_insns_for_bivs): Use xmalloc, not oballoc. (find_mem_givs): Likewise. (record_biv): Likewise. (general_induction_var): Likewise. (product_cheap_p): Likewse. * optabs.c (init_one_libfunc): Remove ggc_p conditional. * print-tree.c (debug_tree): Don't use oballoc/obfree. (print_node): Likewise. * profile.c (output_func_start_profiler): Remove call to temporary_allocation. * reload1.c (eliminate_regs_in_insn): Don't mess with obstacks. * resource.c (mark_target_live_regs): Use xmalloc. (free_resource_info): Free the memory. * rtl.c (rtl_obstack): Remove. (rtvec_alloc): Don't mess with obstacks. (rtx_alloc): Likewise. (rtx_free): Remove. (copy_rtx): Don't handle `b' cases. (read_rtx): Use a local rtl_obstack. * rtl.h (oballoc): Remove. (obfree): Likewise. (pop_obstacks): Likewise. (push_obstacks): Likewise. (allocate_bb_life_data): Likewise. (allocate_reg_life_data): Likewise. (rtx_free): Likewise. * sdbout.c (sdbout_queue_anonymous_type): Use tree_cons, not saveable_tree_cons. * simplify-rtx.c (cselib_init): Don't mess with obstacks. * stmt.c (mark_block_nesting): Mark the label_chain. (epxand_label): Use ggc_alloc, not oballoc. (clear_last_expr): Don't mess with obstacks. (expand_decl_cleanup): Likewise. (expand_dcc_cleanup): Likewise. (expand_dhc_cleanup): Likewise. (expand_anon_union_decl): Likewise. (add_case_node): Use xmalloc, not oballoc. (free_case_nodes): New function. (expand_end_case): Call it. * stor-layout.c (layout_type): Don't mess with obstacks. (layout_type): Likewise. * toplev.c (wrapup_global_declarations): Likewise. (compile_file): Remove ggc_p conditionals. (rest_of_compilation): Call init_flow. Remove ggc_p conditionals. (decode_f_option): Remove ggc_p conditionals. * tree.c (function_maybepermanent_obstack): Remove. (maybepermanent_obstack): Likewise. (function_obstack): Likewise. (tmeporary_obstack): Likewise. (momentary_obstack): Likewise. (temp_decl_obstack): Likewise. (saveable_obstack): Likewise. (rtl_obstack): Likewise. (current_obstack): Likewise. (expression_obstack): Likewise. (struct obstack_stack): Likewise. (obstack_stack): Likewise. (obstack_stack_obstack): Likewise. (maybepermanent_firstobj): Likewise. (temporary_firstobj): Likewise. (momentary_firstobj): Likewise. (temp_decl_firstobj): Likewise. (momentary_function_firstobj): Likewise. (all_types_permanent): Likewise. (struct momentary_level): Likewise. (momentary_stack): Likewise. (init_obstacks): Remove initialization of removed obstacks. (save_tree_status): Remove. (restore_tree_status): Likewise. (temporary_allocation): Liekwise. (end_temporary_allocation): Liekwise. (resume_temporary_allocation): Likewise. (saveable_allocation): Likewise. (push_obstacks): Likewise. (push_obstacks_nochange): Likewise. (pop_obstacks): Likewise. (allocation_temporary_p): Likewise. (permanent_allocation): Likewise. (preserve_data): Likewise. (preserve_initializer): Likewise. (rtl_in_current_obstack): Likewise. (rtl_in_saveable_obstack): Likewise. (oballoc): Likewise. (obfree): Likewise. (savealloc): Likewise. (expralloc): Likewise. (print_obstack_name): Likewise. (debug_obstack): Likewise. (object_permanent_p): Likewise. (push_momentary): Likewise. (perserve_momentary): Likewise. (clear_momentary): Likewise. (pop_momentary): Likewise. (pop_momentary_nofree): Likewise. (suspend_momentary): Likewise. (resume_momentary): Likewise. (make_node): Don't set TREE_PERMANENT. (copy_node): Remove ggc_p conditionals. Don't set TYPE_OBSTACK. Don't set TREE_PERMANENT. (get_identifier): Remove ggc_p conditionals. (build_string): Likewise. (make_tree_vec): Likewise. (build_decl_list): Remove. (build_expr_list): Likewise. (tree_cons): Remove ggc_p conditionals. (decl_tree_cons): Remove. (expr_tree_cons): Likewise. (perm_tree_cons): Likewise. (temp_tree_cons): Likewise. (saveable_tree_cons): Likewise. (build1): Remove ggc_p conditionals. (build_parse_node): Likewise. (build_type_attribute_variant): Don't mess with obstacks. (build_type_copy): Likewise. (type_hash_canon): Likewise. (build_pointer_type): Likewise. (build_reference_type): Likewise. (build_index_type): Likewise. (build_range_type): Likewise. (dump_tree_statistics): Don't print obstack information. * tree.h (struct tree_common): Remove permanent_flag. (TREE_PERMANENT): Remove. (TREE_SET_PERMANENT): Likewise. (TYPE_OBSTACK): Likewise. (struct tree_type): Remove obstack. (oballoc): Remove. (savealloc): Likewise. (build_decl_list): Likewise. (build_expr_list): Likewise. (perm_tree_cons): Likewise. (temp_tree_cons): Likewise. (saveable_tree_cons): Likewise. (decl_tree_cons): Likewise. (expr_tree_cons): Likewise. (suspend_momentary): Likewise. (allocation_temporary_p): Likewise. (resume_momentary): Likewise. (push_obstacks_nochange): Likewise. (permanent_allocation): Likewise. (push_momentary): Likewise. (clear_momentary): Likewise. (pop_momentary): Likewise. (end_temporary_allocation): Likewise. (pop_obstacks): Likewise. (push_obstacks): Likewise. (pop_momentary_nofree): LIkewise. (preserve_momentary): Likewise. (saveable_allocation): Likewise. (temporary_allocation): Likewise. (resume_temporary_allocation): Likewise. (perserve_initializer): Likewise. (debug_obstack): Likewise. (rtl_in_current_obstack): Likewise. (rtl_in_saveable_obstack): Likewise. (obfree): Likewise. * varasm.c (current_obstack): Remove. (saveable_obstack): Remove. (rtl_obstack): Remove. (immed_double_const): Don't mess with obstacks. (immed_real_cons): Likewise. (output_constant_def): Likewise. (init_varasm_status): Use xcalloc. (mark_pool_constant): Mark the pool constant itself. (free_varasm_status): Free memory. (decode_rtx_const): Call bzero directly, rather than expanding it inline. (record_rtx_const): Don't mess with obstacks. (force_const_mem): Likewise. * config/arm/arm.c (arm_encode_call_attribute): Remove ggc_p conditionals. (aof_pic_entry): Likewise. * config/ia64/ia64.c (ia64_encode_section_info): Likewise. * config/m32r/m32r.c (m32r_encode_section_info): Likewise. * config/pa/pa.c (saveable_obstack): Remove. (rtl_obstack): Likewise. (current_obstack): Likewise. (output_call): Don't mess with obstacks. (hppa_encode_label): Remove ggc_p conditionals. * config/romp/romp.c (get_symref): Don't mess with obstacks. * config/rs6000/rs6000.c (output_toc): Remove ggc_p conditional. (rs6000_encode_section_info): Likewise. * config/sh/sh.c (get_fpscr_rtx): Likewise. From-SVN: r36856
2000-10-13 08:26:46 +02:00
return 0;
1992-02-01 09:24:22 +01:00
switch (GET_CODE (x))
{
case USE:
case CONST_INT:
/* Since this is now an invariant and wasn't before, it must be a giv
with MULT_VAL == 0. It doesn't matter which BIV we associate this
with. */
*src_reg = ivs->loop_iv_list->biv->dest_reg;
1992-02-01 09:24:22 +01:00
*mult_val = const0_rtx;
*add_val = x;
break;
case REG:
/* This is equivalent to a BIV. */
*src_reg = x;
*mult_val = const1_rtx;
*add_val = const0_rtx;
break;
case PLUS:
/* Either (plus (biv) (invar)) or
(plus (mult (biv) (invar_1)) (invar_2)). */
if (GET_CODE (XEXP (x, 0)) == MULT)
{
*src_reg = XEXP (XEXP (x, 0), 0);
*mult_val = XEXP (XEXP (x, 0), 1);
}
else
{
*src_reg = XEXP (x, 0);
*mult_val = const1_rtx;
}
*add_val = XEXP (x, 1);
break;
case MULT:
/* ADD_VAL is zero. */
*src_reg = XEXP (x, 0);
*mult_val = XEXP (x, 1);
*add_val = const0_rtx;
break;
default:
abort ();
}
/* Remove any enclosing USE from ADD_VAL and MULT_VAL (there will be
unless they are CONST_INT). */
if (GET_CODE (*add_val) == USE)
*add_val = XEXP (*add_val, 0);
if (GET_CODE (*mult_val) == USE)
*mult_val = XEXP (*mult_val, 0);
if (is_addr)
*pbenefit += address_cost (orig_x, addr_mode) - reg_address_cost;
else
*pbenefit += rtx_cost (orig_x, SET);
1992-02-01 09:24:22 +01:00
/* Always return true if this is a giv so it will be detected as such,
even if the benefit is zero or negative. This allows elimination
of bivs that might otherwise not be eliminated. */
return 1;
1992-02-01 09:24:22 +01:00
}
/* Given an expression, X, try to form it as a linear function of a biv.
We will canonicalize it to be of the form
(plus (mult (BIV) (invar_1))
(invar_2))
with possible degeneracies.
1992-02-01 09:24:22 +01:00
The invariant expressions must each be of a form that can be used as a
machine operand. We surround then with a USE rtx (a hack, but localized
and certainly unambiguous!) if not a CONST_INT for simplicity in this
routine; it is the caller's responsibility to strip them.
If no such canonicalization is possible (i.e., two biv's are used or an
expression that is neither invariant nor a biv or giv), this routine
returns 0.
For a non-zero return, the result will have a code of CONST_INT, USE,
REG (for a BIV), PLUS, or MULT. No other codes will occur.
1992-02-01 09:24:22 +01:00
*BENEFIT will be incremented by the benefit of any sub-giv encountered. */
static rtx sge_plus PARAMS ((enum machine_mode, rtx, rtx));
static rtx sge_plus_constant PARAMS ((rtx, rtx));
1992-02-01 09:24:22 +01:00
static rtx
simplify_giv_expr (loop, x, ext_val, benefit)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
const struct loop *loop;
1992-02-01 09:24:22 +01:00
rtx x;
rtx *ext_val;
1992-02-01 09:24:22 +01:00
int *benefit;
{
struct loop_ivs *ivs = LOOP_IVS (loop);
struct loop_regs *regs = LOOP_REGS (loop);
1992-02-01 09:24:22 +01:00
enum machine_mode mode = GET_MODE (x);
rtx arg0, arg1;
rtx tem;
/* If this is not an integer mode, or if we cannot do arithmetic in this
mode, this can't be a giv. */
if (mode != VOIDmode
&& (GET_MODE_CLASS (mode) != MODE_INT
|| GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT))
return NULL_RTX;
1992-02-01 09:24:22 +01:00
switch (GET_CODE (x))
{
case PLUS:
arg0 = simplify_giv_expr (loop, XEXP (x, 0), ext_val, benefit);
arg1 = simplify_giv_expr (loop, XEXP (x, 1), ext_val, benefit);
1992-02-01 09:24:22 +01:00
if (arg0 == 0 || arg1 == 0)
return NULL_RTX;
1992-02-01 09:24:22 +01:00
/* Put constant last, CONST_INT last if both constant. */
if ((GET_CODE (arg0) == USE
|| GET_CODE (arg0) == CONST_INT)
&& ! ((GET_CODE (arg0) == USE
&& GET_CODE (arg1) == USE)
|| GET_CODE (arg1) == CONST_INT))
1992-02-01 09:24:22 +01:00
tem = arg0, arg0 = arg1, arg1 = tem;
/* Handle addition of zero, then addition of an invariant. */
if (arg1 == const0_rtx)
return arg0;
else if (GET_CODE (arg1) == CONST_INT || GET_CODE (arg1) == USE)
switch (GET_CODE (arg0))
{
case CONST_INT:
case USE:
/* Adding two invariants must result in an invariant, so enclose
addition operation inside a USE and return it. */
1992-02-01 09:24:22 +01:00
if (GET_CODE (arg0) == USE)
arg0 = XEXP (arg0, 0);
if (GET_CODE (arg1) == USE)
arg1 = XEXP (arg1, 0);
if (GET_CODE (arg0) == CONST_INT)
tem = arg0, arg0 = arg1, arg1 = tem;
if (GET_CODE (arg1) == CONST_INT)
tem = sge_plus_constant (arg0, arg1);
else
tem = sge_plus (mode, arg0, arg1);
1992-02-01 09:24:22 +01:00
if (GET_CODE (tem) != CONST_INT)
tem = gen_rtx_USE (mode, tem);
1992-02-01 09:24:22 +01:00
return tem;
case REG:
case MULT:
/* biv + invar or mult + invar. Return sum. */
return gen_rtx_PLUS (mode, arg0, arg1);
1992-02-01 09:24:22 +01:00
case PLUS:
/* (a + invar_1) + invar_2. Associate. */
return
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
simplify_giv_expr (loop,
gen_rtx_PLUS (mode,
XEXP (arg0, 0),
gen_rtx_PLUS (mode,
XEXP (arg0, 1),
arg1)),
ext_val, benefit);
1992-02-01 09:24:22 +01:00
default:
abort ();
}
/* Each argument must be either REG, PLUS, or MULT. Convert REG to
MULT to reduce cases. */
if (GET_CODE (arg0) == REG)
arg0 = gen_rtx_MULT (mode, arg0, const1_rtx);
1992-02-01 09:24:22 +01:00
if (GET_CODE (arg1) == REG)
arg1 = gen_rtx_MULT (mode, arg1, const1_rtx);
1992-02-01 09:24:22 +01:00
/* Now have PLUS + PLUS, PLUS + MULT, MULT + PLUS, or MULT + MULT.
Put a MULT first, leaving PLUS + PLUS, MULT + PLUS, or MULT + MULT.
Recurse to associate the second PLUS. */
if (GET_CODE (arg1) == MULT)
tem = arg0, arg0 = arg1, arg1 = tem;
if (GET_CODE (arg1) == PLUS)
return
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
simplify_giv_expr (loop,
gen_rtx_PLUS (mode,
gen_rtx_PLUS (mode, arg0,
XEXP (arg1, 0)),
XEXP (arg1, 1)),
ext_val, benefit);
1992-02-01 09:24:22 +01:00
/* Now must have MULT + MULT. Distribute if same biv, else not giv. */
if (GET_CODE (arg0) != MULT || GET_CODE (arg1) != MULT)
return NULL_RTX;
1992-02-01 09:24:22 +01:00
if (!rtx_equal_p (arg0, arg1))
return NULL_RTX;
1992-02-01 09:24:22 +01:00
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
return simplify_giv_expr (loop,
gen_rtx_MULT (mode,
XEXP (arg0, 0),
gen_rtx_PLUS (mode,
XEXP (arg0, 1),
XEXP (arg1, 1))),
ext_val, benefit);
1992-02-01 09:24:22 +01:00
case MINUS:
1996-07-04 00:07:53 +02:00
/* Handle "a - b" as "a + b * (-1)". */
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
return simplify_giv_expr (loop,
gen_rtx_PLUS (mode,
XEXP (x, 0),
gen_rtx_MULT (mode,
XEXP (x, 1),
constm1_rtx)),
ext_val, benefit);
1992-02-01 09:24:22 +01:00
case MULT:
arg0 = simplify_giv_expr (loop, XEXP (x, 0), ext_val, benefit);
arg1 = simplify_giv_expr (loop, XEXP (x, 1), ext_val, benefit);
1992-02-01 09:24:22 +01:00
if (arg0 == 0 || arg1 == 0)
return NULL_RTX;
1992-02-01 09:24:22 +01:00
/* Put constant last, CONST_INT last if both constant. */
if ((GET_CODE (arg0) == USE || GET_CODE (arg0) == CONST_INT)
&& GET_CODE (arg1) != CONST_INT)
tem = arg0, arg0 = arg1, arg1 = tem;
/* If second argument is not now constant, not giv. */
if (GET_CODE (arg1) != USE && GET_CODE (arg1) != CONST_INT)
return NULL_RTX;
1992-02-01 09:24:22 +01:00
/* Handle multiply by 0 or 1. */
if (arg1 == const0_rtx)
return const0_rtx;
else if (arg1 == const1_rtx)
return arg0;
switch (GET_CODE (arg0))
{
case REG:
/* biv * invar. Done. */
return gen_rtx_MULT (mode, arg0, arg1);
1992-02-01 09:24:22 +01:00
case CONST_INT:
/* Product of two constants. */
return GEN_INT (INTVAL (arg0) * INTVAL (arg1));
1992-02-01 09:24:22 +01:00
case USE:
/* invar * invar is a giv, but attempt to simplify it somehow. */
if (GET_CODE (arg1) != CONST_INT)
return NULL_RTX;
arg0 = XEXP (arg0, 0);
if (GET_CODE (arg0) == MULT)
{
/* (invar_0 * invar_1) * invar_2. Associate. */
return simplify_giv_expr (loop,
gen_rtx_MULT (mode,
XEXP (arg0, 0),
gen_rtx_MULT (mode,
XEXP (arg0,
1),
arg1)),
ext_val, benefit);
}
/* Porpagate the MULT expressions to the intermost nodes. */
else if (GET_CODE (arg0) == PLUS)
{
/* (invar_0 + invar_1) * invar_2. Distribute. */
return simplify_giv_expr (loop,
gen_rtx_PLUS (mode,
gen_rtx_MULT (mode,
XEXP (arg0,
0),
arg1),
gen_rtx_MULT (mode,
XEXP (arg0,
1),
arg1)),
ext_val, benefit);
}
return gen_rtx_USE (mode, gen_rtx_MULT (mode, arg0, arg1));
1992-02-01 09:24:22 +01:00
case MULT:
/* (a * invar_1) * invar_2. Associate. */
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
return simplify_giv_expr (loop,
gen_rtx_MULT (mode,
XEXP (arg0, 0),
gen_rtx_MULT (mode,
XEXP (arg0, 1),
arg1)),
ext_val, benefit);
1992-02-01 09:24:22 +01:00
case PLUS:
/* (a + invar_1) * invar_2. Distribute. */
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
return simplify_giv_expr (loop,
gen_rtx_PLUS (mode,
gen_rtx_MULT (mode,
XEXP (arg0, 0),
arg1),
gen_rtx_MULT (mode,
XEXP (arg0, 1),
arg1)),
ext_val, benefit);
1992-02-01 09:24:22 +01:00
default:
abort ();
}
case ASHIFT:
/* Shift by constant is multiply by power of two. */
if (GET_CODE (XEXP (x, 1)) != CONST_INT)
return 0;
return
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
simplify_giv_expr (loop,
gen_rtx_MULT (mode,
XEXP (x, 0),
GEN_INT ((HOST_WIDE_INT) 1
<< INTVAL (XEXP (x, 1)))),
ext_val, benefit);
1992-02-01 09:24:22 +01:00
case NEG:
/* "-a" is "a * (-1)" */
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
return simplify_giv_expr (loop,
gen_rtx_MULT (mode, XEXP (x, 0), constm1_rtx),
ext_val, benefit);
1992-02-01 09:24:22 +01:00
case NOT:
/* "~a" is "-a - 1". Silly, but easy. */
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
return simplify_giv_expr (loop,
gen_rtx_MINUS (mode,
gen_rtx_NEG (mode, XEXP (x, 0)),
const1_rtx),
ext_val, benefit);
1992-02-01 09:24:22 +01:00
case USE:
/* Already in proper form for invariant. */
return x;
case SIGN_EXTEND:
case ZERO_EXTEND:
case TRUNCATE:
/* Conditionally recognize extensions of simple IVs. After we've
computed loop traversal counts and verified the range of the
source IV, we'll reevaluate this as a GIV. */
if (*ext_val == NULL_RTX)
{
arg0 = simplify_giv_expr (loop, XEXP (x, 0), ext_val, benefit);
if (arg0 && *ext_val == NULL_RTX && GET_CODE (arg0) == REG)
{
*ext_val = gen_rtx_fmt_e (GET_CODE (x), mode, arg0);
return arg0;
}
}
goto do_default;
case REG:
1992-02-01 09:24:22 +01:00
/* If this is a new register, we can't deal with it. */
if (REGNO (x) >= max_reg_before_loop)
return 0;
/* Check for biv or giv. */
switch (REG_IV_TYPE (ivs, REGNO (x)))
1992-02-01 09:24:22 +01:00
{
case BASIC_INDUCT:
return x;
case GENERAL_INDUCT:
{
struct induction *v = REG_IV_INFO (ivs, REGNO (x));
1992-02-01 09:24:22 +01:00
/* Form expression from giv and add benefit. Ensure this giv
can derive another and subtract any needed adjustment if so. */
/* Increasing the benefit here is risky. The only case in which it
is arguably correct is if this is the only use of V. In other
cases, this will artificially inflate the benefit of the current
giv, and lead to suboptimal code. Thus, it is disabled, since
potentially not reducing an only marginally beneficial giv is
less harmful than reducing many givs that are not really
beneficial. */
{
rtx single_use = VARRAY_RTX (regs->single_usage, REGNO (x));
if (single_use && single_use != const0_rtx)
*benefit += v->benefit;
}
1992-02-01 09:24:22 +01:00
if (v->cant_derive)
return 0;
tem = gen_rtx_PLUS (mode, gen_rtx_MULT (mode,
v->src_reg, v->mult_val),
v->add_val);
1992-02-01 09:24:22 +01:00
if (v->derive_adjustment)
tem = gen_rtx_MINUS (mode, tem, v->derive_adjustment);
arg0 = simplify_giv_expr (loop, tem, ext_val, benefit);
if (*ext_val)
{
if (!v->ext_dependant)
return arg0;
}
else
{
*ext_val = v->ext_dependant;
return arg0;
}
return 0;
1992-02-01 09:24:22 +01:00
}
default:
do_default:
/* If it isn't an induction variable, and it is invariant, we
may be able to simplify things further by looking through
the bits we just moved outside the loop. */
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (loop_invariant_p (loop, x) == 1)
{
struct movable *m;
for (m = the_movables.head; m; m = m->next)
if (rtx_equal_p (x, m->set_dest))
{
/* Ok, we found a match. Substitute and simplify. */
/* If we match another movable, we must use that, as
this one is going away. */
if (m->match)
return simplify_giv_expr (loop, m->match->set_dest,
ext_val, benefit);
/* If consec is non-zero, this is a member of a group of
instructions that were moved together. We handle this
case only to the point of seeking to the last insn and
looking for a REG_EQUAL. Fail if we don't find one. */
if (m->consec != 0)
{
int i = m->consec;
tem = m->insn;
do
{
tem = NEXT_INSN (tem);
}
while (--i > 0);
tem = find_reg_note (tem, REG_EQUAL, NULL_RTX);
if (tem)
tem = XEXP (tem, 0);
}
else
{
tem = single_set (m->insn);
if (tem)
tem = SET_SRC (tem);
}
if (tem)
{
/* What we are most interested in is pointer
arithmetic on invariants -- only take
patterns we may be able to do something with. */
if (GET_CODE (tem) == PLUS
|| GET_CODE (tem) == MULT
|| GET_CODE (tem) == ASHIFT
|| GET_CODE (tem) == CONST_INT
|| GET_CODE (tem) == SYMBOL_REF)
{
tem = simplify_giv_expr (loop, tem, ext_val,
benefit);
if (tem)
return tem;
}
else if (GET_CODE (tem) == CONST
&& GET_CODE (XEXP (tem, 0)) == PLUS
&& GET_CODE (XEXP (XEXP (tem, 0), 0)) == SYMBOL_REF
&& GET_CODE (XEXP (XEXP (tem, 0), 1)) == CONST_INT)
{
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
tem = simplify_giv_expr (loop, XEXP (tem, 0),
ext_val, benefit);
if (tem)
return tem;
}
}
break;
}
}
break;
1992-02-01 09:24:22 +01:00
}
/* Fall through to general case. */
default:
/* If invariant, return as USE (unless CONST_INT).
Otherwise, not giv. */
if (GET_CODE (x) == USE)
x = XEXP (x, 0);
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (loop_invariant_p (loop, x) == 1)
1992-02-01 09:24:22 +01:00
{
if (GET_CODE (x) == CONST_INT)
return x;
if (GET_CODE (x) == CONST
&& GET_CODE (XEXP (x, 0)) == PLUS
&& GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF
&& GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT)
x = XEXP (x, 0);
return gen_rtx_USE (mode, x);
1992-02-01 09:24:22 +01:00
}
else
return 0;
}
}
/* This routine folds invariants such that there is only ever one
CONST_INT in the summation. It is only used by simplify_giv_expr. */
static rtx
sge_plus_constant (x, c)
rtx x, c;
{
if (GET_CODE (x) == CONST_INT)
return GEN_INT (INTVAL (x) + INTVAL (c));
else if (GET_CODE (x) != PLUS)
return gen_rtx_PLUS (GET_MODE (x), x, c);
else if (GET_CODE (XEXP (x, 1)) == CONST_INT)
{
return gen_rtx_PLUS (GET_MODE (x), XEXP (x, 0),
GEN_INT (INTVAL (XEXP (x, 1)) + INTVAL (c)));
}
else if (GET_CODE (XEXP (x, 0)) == PLUS
|| GET_CODE (XEXP (x, 1)) != PLUS)
{
return gen_rtx_PLUS (GET_MODE (x),
sge_plus_constant (XEXP (x, 0), c), XEXP (x, 1));
}
else
{
return gen_rtx_PLUS (GET_MODE (x),
sge_plus_constant (XEXP (x, 1), c), XEXP (x, 0));
}
}
static rtx
sge_plus (mode, x, y)
enum machine_mode mode;
rtx x, y;
{
while (GET_CODE (y) == PLUS)
{
rtx a = XEXP (y, 0);
if (GET_CODE (a) == CONST_INT)
x = sge_plus_constant (x, a);
else
x = gen_rtx_PLUS (mode, x, a);
y = XEXP (y, 1);
}
if (GET_CODE (y) == CONST_INT)
x = sge_plus_constant (x, y);
else
x = gen_rtx_PLUS (mode, x, y);
return x;
}
1992-02-01 09:24:22 +01:00
/* Help detect a giv that is calculated by several consecutive insns;
for example,
giv = biv * M
giv = giv + A
The caller has already identified the first insn P as having a giv as dest;
we check that all other insns that set the same register follow
immediately after P, that they alter nothing else,
and that the result of the last is still a giv.
The value is 0 if the reg set in P is not really a giv.
Otherwise, the value is the amount gained by eliminating
all the consecutive insns that compute the value.
FIRST_BENEFIT is the amount gained by eliminating the first insn, P.
SRC_REG is the reg of the biv; DEST_REG is the reg of the giv.
The coefficients of the ultimate giv value are stored in
*MULT_VAL and *ADD_VAL. */
static int
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
consec_sets_giv (loop, first_benefit, p, src_reg, dest_reg,
add_val, mult_val, ext_val, last_consec_insn)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
const struct loop *loop;
1992-02-01 09:24:22 +01:00
int first_benefit;
rtx p;
rtx src_reg;
rtx dest_reg;
rtx *add_val;
rtx *mult_val;
rtx *ext_val;
rtx *last_consec_insn;
1992-02-01 09:24:22 +01:00
{
struct loop_ivs *ivs = LOOP_IVS (loop);
struct loop_regs *regs = LOOP_REGS (loop);
1992-02-01 09:24:22 +01:00
int count;
enum rtx_code code;
int benefit;
rtx temp;
rtx set;
/* Indicate that this is a giv so that we can update the value produced in
each insn of the multi-insn sequence.
1992-02-01 09:24:22 +01:00
This induction structure will be used only by the call to
general_induction_var below, so we can allocate it on our stack.
If this is a giv, our caller will replace the induct var entry with
a new induction structure. */
struct induction *v;
if (REG_IV_TYPE (ivs, REGNO (dest_reg)) != UNKNOWN_INDUCT)
return 0;
v = (struct induction *) alloca (sizeof (struct induction));
1992-02-01 09:24:22 +01:00
v->src_reg = src_reg;
v->mult_val = *mult_val;
v->add_val = *add_val;
v->benefit = first_benefit;
v->cant_derive = 0;
v->derive_adjustment = 0;
v->ext_dependant = NULL_RTX;
1992-02-01 09:24:22 +01:00
REG_IV_TYPE (ivs, REGNO (dest_reg)) = GENERAL_INDUCT;
REG_IV_INFO (ivs, REGNO (dest_reg)) = v;
1992-02-01 09:24:22 +01:00
count = VARRAY_INT (regs->n_times_set, REGNO (dest_reg)) - 1;
1992-02-01 09:24:22 +01:00
while (count > 0)
{
p = NEXT_INSN (p);
code = GET_CODE (p);
/* If libcall, skip to end of call sequence. */
if (code == INSN && (temp = find_reg_note (p, REG_LIBCALL, NULL_RTX)))
1992-02-01 09:24:22 +01:00
p = XEXP (temp, 0);
if (code == INSN
&& (set = single_set (p))
&& GET_CODE (SET_DEST (set)) == REG
&& SET_DEST (set) == dest_reg
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
&& (general_induction_var (loop, SET_SRC (set), &src_reg,
add_val, mult_val, ext_val, 0,
&benefit, VOIDmode)
1992-02-01 09:24:22 +01:00
/* Giv created by equivalent expression. */
|| ((temp = find_reg_note (p, REG_EQUAL, NULL_RTX))
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
&& general_induction_var (loop, XEXP (temp, 0), &src_reg,
add_val, mult_val, ext_val, 0,
&benefit, VOIDmode)))
1992-02-01 09:24:22 +01:00
&& src_reg == v->src_reg)
{
if (find_reg_note (p, REG_RETVAL, NULL_RTX))
1992-02-01 09:24:22 +01:00
benefit += libcall_benefit (p);
count--;
v->mult_val = *mult_val;
v->add_val = *add_val;
v->benefit += benefit;
1992-02-01 09:24:22 +01:00
}
else if (code != NOTE)
{
/* Allow insns that set something other than this giv to a
constant. Such insns are needed on machines which cannot
include long constants and should not disqualify a giv. */
if (code == INSN
&& (set = single_set (p))
&& SET_DEST (set) != dest_reg
&& CONSTANT_P (SET_SRC (set)))
continue;
REG_IV_TYPE (ivs, REGNO (dest_reg)) = UNKNOWN_INDUCT;
1992-02-01 09:24:22 +01:00
return 0;
}
}
REG_IV_TYPE (ivs, REGNO (dest_reg)) = UNKNOWN_INDUCT;
*last_consec_insn = p;
1992-02-01 09:24:22 +01:00
return v->benefit;
}
/* Return an rtx, if any, that expresses giv G2 as a function of the register
represented by G1. If no such expression can be found, or it is clear that
it cannot possibly be a valid address, 0 is returned.
1992-02-01 09:24:22 +01:00
To perform the computation, we note that
G1 = x * v + a and
G2 = y * v + b
1992-02-01 09:24:22 +01:00
where `v' is the biv.
So G2 = (y/b) * G1 + (b - a*y/x).
Note that MULT = y/x.
Update: A and B are now allowed to be additive expressions such that
B contains all variables in A. That is, computing B-A will not require
subtracting variables. */
static rtx
express_from_1 (a, b, mult)
rtx a, b, mult;
{
/* If MULT is zero, then A*MULT is zero, and our expression is B. */
if (mult == const0_rtx)
return b;
/* If MULT is not 1, we cannot handle A with non-constants, since we
would then be required to subtract multiples of the registers in A.
This is theoretically possible, and may even apply to some Fortran
constructs, but it is a lot of work and we do not attempt it here. */
if (mult != const1_rtx && GET_CODE (a) != CONST_INT)
return NULL_RTX;
/* In general these structures are sorted top to bottom (down the PLUS
chain), but not left to right across the PLUS. If B is a higher
order giv than A, we can strip one level and recurse. If A is higher
order, we'll eventually bail out, but won't know that until the end.
If they are the same, we'll strip one level around this loop. */
while (GET_CODE (a) == PLUS && GET_CODE (b) == PLUS)
{
rtx ra, rb, oa, ob, tmp;
ra = XEXP (a, 0), oa = XEXP (a, 1);
if (GET_CODE (ra) == PLUS)
tmp = ra, ra = oa, oa = tmp;
rb = XEXP (b, 0), ob = XEXP (b, 1);
if (GET_CODE (rb) == PLUS)
tmp = rb, rb = ob, ob = tmp;
if (rtx_equal_p (ra, rb))
/* We matched: remove one reg completely. */
a = oa, b = ob;
else if (GET_CODE (ob) != PLUS && rtx_equal_p (ra, ob))
/* An alternate match. */
a = oa, b = rb;
else if (GET_CODE (oa) != PLUS && rtx_equal_p (oa, rb))
/* An alternate match. */
a = ra, b = ob;
else
{
/* Indicates an extra register in B. Strip one level from B and
recurse, hoping B was the higher order expression. */
ob = express_from_1 (a, ob, mult);
if (ob == NULL_RTX)
return NULL_RTX;
return gen_rtx_PLUS (GET_MODE (b), rb, ob);
}
}
/* Here we are at the last level of A, go through the cases hoping to
get rid of everything but a constant. */
if (GET_CODE (a) == PLUS)
{
rtx ra, oa;
ra = XEXP (a, 0), oa = XEXP (a, 1);
if (rtx_equal_p (oa, b))
oa = ra;
else if (!rtx_equal_p (ra, b))
return NULL_RTX;
if (GET_CODE (oa) != CONST_INT)
return NULL_RTX;
return GEN_INT (-INTVAL (oa) * INTVAL (mult));
}
else if (GET_CODE (a) == CONST_INT)
{
return plus_constant (b, -INTVAL (a) * INTVAL (mult));
}
else if (CONSTANT_P (a))
{
return simplify_gen_binary (MINUS, GET_MODE (b) != VOIDmode ? GET_MODE (b) : GET_MODE (a), const0_rtx, a);
}
else if (GET_CODE (b) == PLUS)
{
if (rtx_equal_p (a, XEXP (b, 0)))
return XEXP (b, 1);
else if (rtx_equal_p (a, XEXP (b, 1)))
return XEXP (b, 0);
else
return NULL_RTX;
}
else if (rtx_equal_p (a, b))
return const0_rtx;
return NULL_RTX;
}
1992-02-01 09:24:22 +01:00
rtx
1992-02-01 09:24:22 +01:00
express_from (g1, g2)
struct induction *g1, *g2;
{
rtx mult, add;
/* The value that G1 will be multiplied by must be a constant integer. Also,
the only chance we have of getting a valid address is if b*c/a (see above
for notation) is also an integer. */
if (GET_CODE (g1->mult_val) == CONST_INT
&& GET_CODE (g2->mult_val) == CONST_INT)
{
if (g1->mult_val == const0_rtx
|| INTVAL (g2->mult_val) % INTVAL (g1->mult_val) != 0)
return NULL_RTX;
mult = GEN_INT (INTVAL (g2->mult_val) / INTVAL (g1->mult_val));
}
else if (rtx_equal_p (g1->mult_val, g2->mult_val))
mult = const1_rtx;
else
{
/* ??? Find out if the one is a multiple of the other? */
return NULL_RTX;
}
1992-02-01 09:24:22 +01:00
add = express_from_1 (g1->add_val, g2->add_val, mult);
if (add == NULL_RTX)
{
/* Failed. If we've got a multiplication factor between G1 and G2,
scale G1's addend and try again. */
if (INTVAL (mult) > 1)
{
rtx g1_add_val = g1->add_val;
if (GET_CODE (g1_add_val) == MULT
&& GET_CODE (XEXP (g1_add_val, 1)) == CONST_INT)
{
HOST_WIDE_INT m;
m = INTVAL (mult) * INTVAL (XEXP (g1_add_val, 1));
g1_add_val = gen_rtx_MULT (GET_MODE (g1_add_val),
XEXP (g1_add_val, 0), GEN_INT (m));
}
else
{
g1_add_val = gen_rtx_MULT (GET_MODE (g1_add_val), g1_add_val,
mult);
}
add = express_from_1 (g1_add_val, g2->add_val, const1_rtx);
}
}
if (add == NULL_RTX)
return NULL_RTX;
1992-02-01 09:24:22 +01:00
/* Form simplified final result. */
if (mult == const0_rtx)
return add;
else if (mult == const1_rtx)
mult = g1->dest_reg;
else
mult = gen_rtx_MULT (g2->mode, g1->dest_reg, mult);
1992-02-01 09:24:22 +01:00
if (add == const0_rtx)
return mult;
else
{
if (GET_CODE (add) == PLUS
&& CONSTANT_P (XEXP (add, 1)))
{
rtx tem = XEXP (add, 1);
mult = gen_rtx_PLUS (g2->mode, mult, XEXP (add, 0));
add = tem;
}
return gen_rtx_PLUS (g2->mode, mult, add);
}
1992-02-01 09:24:22 +01:00
}
/* Return an rtx, if any, that expresses giv G2 as a function of the register
represented by G1. This indicates that G2 should be combined with G1 and
that G2 can use (either directly or via an address expression) a register
used to represent G1. */
1992-02-01 09:24:22 +01:00
static rtx
1992-02-01 09:24:22 +01:00
combine_givs_p (g1, g2)
struct induction *g1, *g2;
{
rtx comb, ret;
/* With the introduction of ext dependant givs, we must care for modes.
G2 must not use a wider mode than G1. */
if (GET_MODE_SIZE (g1->mode) < GET_MODE_SIZE (g2->mode))
return NULL_RTX;
ret = comb = express_from (g1, g2);
if (comb == NULL_RTX)
return NULL_RTX;
if (g1->mode != g2->mode)
ret = gen_lowpart (g2->mode, comb);
1992-02-01 09:24:22 +01:00
/* If these givs are identical, they can be combined. We use the results
of express_from because the addends are not in a canonical form, so
rtx_equal_p is a weaker test. */
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
/* But don't combine a DEST_REG giv with a DEST_ADDR giv; we want the
combination to be the other way round. */
if (comb == g1->dest_reg
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
&& (g1->giv_type == DEST_REG || g2->giv_type == DEST_ADDR))
1992-02-01 09:24:22 +01:00
{
return ret;
1992-02-01 09:24:22 +01:00
}
/* If G2 can be expressed as a function of G1 and that function is valid
as an address and no more expensive than using a register for G2,
the expression of G2 in terms of G1 can be used. */
if (ret != NULL_RTX
&& g2->giv_type == DEST_ADDR
&& memory_address_p (g2->mem_mode, ret)
/* ??? Looses, especially with -fforce-addr, where *g2->location
will always be a register, and so anything more complicated
gets discarded. */
#if 0
#ifdef ADDRESS_COST
&& ADDRESS_COST (tem) <= ADDRESS_COST (*g2->location)
#else
&& rtx_cost (tem, MEM) <= rtx_cost (*g2->location, MEM)
#endif
#endif
)
1992-02-01 09:24:22 +01:00
{
return ret;
1992-02-01 09:24:22 +01:00
}
return NULL_RTX;
1992-02-01 09:24:22 +01:00
}
/* Check each extension dependant giv in this class to see if its
root biv is safe from wrapping in the interior mode, which would
make the giv illegal. */
static void
check_ext_dependant_givs (bl, loop_info)
struct iv_class *bl;
struct loop_info *loop_info;
{
int ze_ok = 0, se_ok = 0, info_ok = 0;
enum machine_mode biv_mode = GET_MODE (bl->biv->src_reg);
HOST_WIDE_INT start_val;
unsigned HOST_WIDE_INT u_end_val, u_start_val;
rtx incr = pc_rtx;
struct induction *v;
/* Make sure the iteration data is available. We must have
constants in order to be certain of no overflow. */
/* ??? An unknown iteration count with an increment of +-1
combined with friendly exit tests of against an invariant
value is also ameanable to optimization. Not implemented. */
if (loop_info->n_iterations > 0
&& bl->initial_value
&& GET_CODE (bl->initial_value) == CONST_INT
&& (incr = biv_total_increment (bl))
&& GET_CODE (incr) == CONST_INT
/* Make sure the host can represent the arithmetic. */
&& HOST_BITS_PER_WIDE_INT >= GET_MODE_BITSIZE (biv_mode))
{
unsigned HOST_WIDE_INT abs_incr, total_incr;
HOST_WIDE_INT s_end_val;
int neg_incr;
info_ok = 1;
start_val = INTVAL (bl->initial_value);
u_start_val = start_val;
neg_incr = 0, abs_incr = INTVAL (incr);
if (INTVAL (incr) < 0)
neg_incr = 1, abs_incr = -abs_incr;
total_incr = abs_incr * loop_info->n_iterations;
/* Check for host arithmatic overflow. */
if (total_incr / loop_info->n_iterations == abs_incr)
{
unsigned HOST_WIDE_INT u_max;
HOST_WIDE_INT s_max;
u_end_val = start_val + (neg_incr ? -total_incr : total_incr);
s_end_val = u_end_val;
u_max = GET_MODE_MASK (biv_mode);
s_max = u_max >> 1;
/* Check zero extension of biv ok. */
if (start_val >= 0
/* Check for host arithmatic overflow. */
&& (neg_incr
? u_end_val < u_start_val
: u_end_val > u_start_val)
/* Check for target arithmetic overflow. */
&& (neg_incr
? 1 /* taken care of with host overflow */
: u_end_val <= u_max))
{
ze_ok = 1;
}
/* Check sign extension of biv ok. */
/* ??? While it is true that overflow with signed and pointer
arithmetic is undefined, I fear too many programmers don't
keep this fact in mind -- myself included on occasion.
So leave alone with the signed overflow optimizations. */
if (start_val >= -s_max - 1
/* Check for host arithmatic overflow. */
&& (neg_incr
? s_end_val < start_val
: s_end_val > start_val)
/* Check for target arithmetic overflow. */
&& (neg_incr
? s_end_val >= -s_max - 1
: s_end_val <= s_max))
{
se_ok = 1;
}
}
}
/* Invalidate givs that fail the tests. */
for (v = bl->giv; v; v = v->next_iv)
if (v->ext_dependant)
{
enum rtx_code code = GET_CODE (v->ext_dependant);
int ok = 0;
switch (code)
{
case SIGN_EXTEND:
ok = se_ok;
break;
case ZERO_EXTEND:
ok = ze_ok;
break;
case TRUNCATE:
/* We don't know whether this value is being used as either
signed or unsigned, so to safely truncate we must satisfy
both. The initial check here verifies the BIV itself;
once that is successful we may check its range wrt the
derived GIV. */
if (se_ok && ze_ok)
{
enum machine_mode outer_mode = GET_MODE (v->ext_dependant);
unsigned HOST_WIDE_INT max = GET_MODE_MASK (outer_mode) >> 1;
/* We know from the above that both endpoints are nonnegative,
and that there is no wrapping. Verify that both endpoints
are within the (signed) range of the outer mode. */
if (u_start_val <= max && u_end_val <= max)
ok = 1;
}
break;
default:
abort ();
}
if (ok)
{
if (loop_dump_stream)
{
fprintf (loop_dump_stream,
"Verified ext dependant giv at %d of reg %d\n",
INSN_UID (v->insn), bl->regno);
}
}
else
{
if (loop_dump_stream)
{
const char *why;
if (info_ok)
why = "biv iteration values overflowed";
else
{
if (incr == pc_rtx)
incr = biv_total_increment (bl);
if (incr == const1_rtx)
why = "biv iteration info incomplete; incr by 1";
else
why = "biv iteration info incomplete";
}
fprintf (loop_dump_stream,
"Failed ext dependant giv at %d, %s\n",
INSN_UID (v->insn), why);
}
v->ignore = 1;
}
}
}
/* Generate a version of VALUE in a mode appropriate for initializing V. */
rtx
extend_value_for_giv (v, value)
struct induction *v;
rtx value;
{
rtx ext_dep = v->ext_dependant;
if (! ext_dep)
return value;
/* Recall that check_ext_dependant_givs verified that the known bounds
of a biv did not overflow or wrap with respect to the extension for
the giv. Therefore, constants need no additional adjustment. */
if (CONSTANT_P (value) && GET_MODE (value) == VOIDmode)
return value;
/* Otherwise, we must adjust the value to compensate for the
differing modes of the biv and the giv. */
return gen_rtx_fmt_e (GET_CODE (ext_dep), GET_MODE (ext_dep), value);
}
struct combine_givs_stats
{
int giv_number;
int total_benefit;
};
static int
cmp_combine_givs_stats (xp, yp)
const PTR xp;
const PTR yp;
{
const struct combine_givs_stats * const x =
(const struct combine_givs_stats *) xp;
const struct combine_givs_stats * const y =
(const struct combine_givs_stats *) yp;
int d;
d = y->total_benefit - x->total_benefit;
/* Stabilize the sort. */
if (!d)
d = x->giv_number - y->giv_number;
return d;
}
1992-02-01 09:24:22 +01:00
/* Check all pairs of givs for iv_class BL and see if any can be combined with
any other. If so, point SAME to the giv combined with and set NEW_REG to
be an expression (in terms of the other giv's DEST_REG) equivalent to the
giv. Also, update BENEFIT and related fields for cost/benefit analysis. */
static void
combine_givs (regs, bl)
struct loop_regs *regs;
1992-02-01 09:24:22 +01:00
struct iv_class *bl;
{
/* Additional benefit to add for being combined multiple times. */
const int extra_benefit = 3;
varasm.c (output_constant_pool): Bring back 'done' label inside an appropriate #ifdef. * varasm.c (output_constant_pool): Bring back 'done' label inside an appropriate #ifdef. * bitmap.c (bitmap_element_allocate): Wrap variable 'i' in an appropriate #ifdef. (bitmap_copy, bitmap_operation): Likewise. * combine.c (combinable_i3pat): Similarly for 'src'. * function.c (fixup_var_refs_1): Similarly for 'outerdest'. (locate_and_pad_parm): Similarly for 'reg_parm_stack_space'. * regclass.c (copy_cost): Similarly for 'secondary_class'. * reload.c (make_memloc): Simliarly for 'i'. (find_reloads_address_1): Similarly for 'link'. * reload1.c (reload): Similarly for 'previous_frame_pointer_needed'. (emit_reload_insns): Similarly for 'second_reloadreg'. * unroll.c (iteration_info): Similarly for 'v'. * caller-save.c (insert_save_restore): Remove unused variable 'i'. * calls.c (expand_call): Similarly for 'i'. (emit_library_call, emit_library_call_value): Similarly for 'mode'. * fold-const.c (strip_compund_expr): Similarly for 'type'. * function.c (fixup_var_refs_1): Similarly for 'width'. (fixup_memory_subreg): Similarly for 'saved'. (locate_and_pad_parm): Similarly for 'boundary_in_bytes.' (setjmp_protect): Similarly for 'sub'. (thread_prologue_and_epilogue_insns): Similarly for 'insn'. * loop.c (record_giv): Similarly for 'p'. (combine_givs): Similarly for 'temp_iv'. (indirect_jump_in_function_p): Similarly for 'is_indirect_jump'. * recog.c (validate_replace_rtx_1): Similarly for 'width'. * tree.c (get_set_constructor_bytes): Similarly for 'vals'. * unroll.c (unroll_loop): Similarly for 'copy'. (iteration_info): Similarly for 'b'. * varasm.c (assemble_string): Similarly for 'i'. * i386.h (LEGITIMIZE_ADDRESS): Similarly for 'orig_x'. From-SVN: r17973
1998-02-14 02:13:58 +01:00
struct induction *g1, *g2, **giv_array;
int i, j, k, giv_count;
struct combine_givs_stats *stats;
rtx *can_combine;
1992-02-01 09:24:22 +01:00
/* Count givs, because bl->giv_count is incorrect here. */
giv_count = 0;
1992-02-01 09:24:22 +01:00
for (g1 = bl->giv; g1; g1 = g1->next_iv)
if (!g1->ignore)
giv_count++;
giv_array
= (struct induction **) alloca (giv_count * sizeof (struct induction *));
i = 0;
for (g1 = bl->giv; g1; g1 = g1->next_iv)
if (!g1->ignore)
giv_array[i++] = g1;
stats = (struct combine_givs_stats *) xcalloc (giv_count, sizeof (*stats));
can_combine = (rtx *) xcalloc (giv_count, giv_count * sizeof (rtx));
for (i = 0; i < giv_count; i++)
{
int this_benefit;
rtx single_use;
g1 = giv_array[i];
stats[i].giv_number = i;
/* If a DEST_REG GIV is used only once, do not allow it to combine
with anything, for in doing so we will gain nothing that cannot
be had by simply letting the GIV with which we would have combined
to be reduced on its own. The losage shows up in particular with
DEST_ADDR targets on hosts with reg+reg addressing, though it can
be seen elsewhere as well. */
if (g1->giv_type == DEST_REG
&& (single_use = VARRAY_RTX (regs->single_usage,
REGNO (g1->dest_reg)))
&& single_use != const0_rtx)
continue;
this_benefit = g1->benefit;
/* Add an additional weight for zero addends. */
if (g1->no_const_addval)
this_benefit += 1;
for (j = 0; j < giv_count; j++)
{
rtx this_combine;
g2 = giv_array[j];
if (g1 != g2
&& (this_combine = combine_givs_p (g1, g2)) != NULL_RTX)
{
can_combine[i * giv_count + j] = this_combine;
this_benefit += g2->benefit + extra_benefit;
}
}
stats[i].total_benefit = this_benefit;
}
/* Iterate, combining until we can't. */
restart:
qsort (stats, giv_count, sizeof (*stats), cmp_combine_givs_stats);
if (loop_dump_stream)
{
fprintf (loop_dump_stream, "Sorted combine statistics:\n");
for (k = 0; k < giv_count; k++)
{
g1 = giv_array[stats[k].giv_number];
if (!g1->combined_with && !g1->same)
fprintf (loop_dump_stream, " {%d, %d}",
INSN_UID (giv_array[stats[k].giv_number]->insn),
stats[k].total_benefit);
}
putc ('\n', loop_dump_stream);
}
for (k = 0; k < giv_count; k++)
{
int g1_add_benefit = 0;
i = stats[k].giv_number;
g1 = giv_array[i];
/* If it has already been combined, skip. */
if (g1->combined_with || g1->same)
continue;
for (j = 0; j < giv_count; j++)
{
g2 = giv_array[j];
if (g1 != g2 && can_combine[i * giv_count + j]
/* If it has already been combined, skip. */
&& ! g2->same && ! g2->combined_with)
{
int l;
g2->new_reg = can_combine[i * giv_count + j];
g2->same = g1;
rtl.h (insn_first_p): Declare. * rtl.h (insn_first_p): Declare. * rtlanal.c (insn_first_p): New function. * loop.h (varray.h): Include. (struct induction): Change combined_with to unsigned. New members derived, ix and last_use. (reg_iv_type, reg_iv_info): Now varray_type. All references changed. (REG_IV_TYPE, REG_IV_INFO): Define. (first_increment_giv, last_increment_giv): Declare. * loop.c (loop_number_loop_cont): New static variable. (loop_number_cont_dominator): Likewise. (reg_iv_type, reg_iv_info): Now varray_type. (first_increment_giv, last_increment_giv): New variables. (compute_luids, verify_dominator, find_life_end): New functions. (cmp_recombine_givs_stats, recombine_givs): Likewise. (loop_optimize): Allocate loop_number_loop_cont and loop_number_cont_dominator. Use compute_luids. (find_and_verify_loops): Initialize loop_number_loop_cont and loop_number_cont_dominator. (strength_reduce): Try to find bivs that can be expressed as givs of another biv, and to convert biv increments into givs. Call recombine_givs. Handle derived givs. (record_biv): New argument location. All callers changed. (record_giv): Initialize derived and last_use fields. (basic_induction_var): New argument location. All callers changed. (combine_givs): Don't combine a DEST_REG giv with a DEST_ADDR giv. Increment combined_with instead of setting to 1. * unroll.c (derived_regs): New static variable. (unroll_loop): Initialize it. Allocate local_regno according to max_reg_num. (copy_loop_body): Cope with derived givs. (find_splittable_givs): Check for Givs made from biv increments. Set derived_regs for givs. * Makefile.in (stmt.o, loop.o, unroll.o): Depend on loop.h . From-SVN: r24889
1999-01-27 16:45:50 +01:00
g1->combined_with++;
g1->lifetime += g2->lifetime;
g1_add_benefit += g2->benefit;
/* ??? The new final_[bg]iv_value code does a much better job
of finding replaceable giv's, and hence this code may no
longer be necessary. */
if (! g2->replaceable && REG_USERVAR_P (g2->dest_reg))
g1_add_benefit -= copy_cost;
/* To help optimize the next set of combinations, remove
this giv from the benefits of other potential mates. */
for (l = 0; l < giv_count; ++l)
{
int m = stats[l].giv_number;
if (can_combine[m * giv_count + j])
stats[l].total_benefit -= g2->benefit + extra_benefit;
}
if (loop_dump_stream)
fprintf (loop_dump_stream,
"giv at %d combined with giv at %d; new benefit %d + %d, lifetime %d\n",
INSN_UID (g2->insn), INSN_UID (g1->insn),
g1->benefit, g1_add_benefit, g1->lifetime);
}
}
/* To help optimize the next set of combinations, remove
this giv from the benefits of other potential mates. */
if (g1->combined_with)
{
for (j = 0; j < giv_count; ++j)
{
int m = stats[j].giv_number;
if (can_combine[m * giv_count + i])
stats[j].total_benefit -= g1->benefit + extra_benefit;
}
g1->benefit += g1_add_benefit;
/* We've finished with this giv, and everything it touched.
Restart the combination so that proper weights for the
rest of the givs are properly taken into account. */
/* ??? Ideally we would compact the arrays at this point, so
as to not cover old ground. But sanely compacting
can_combine is tricky. */
goto restart;
}
}
/* Clean up. */
free (stats);
free (can_combine);
1992-02-01 09:24:22 +01:00
}
/* EMIT code before INSERT_BEFORE to set REG = B * M + A. */
void
emit_iv_add_mult (b, m, a, reg, insert_before)
rtx b; /* initial value of basic induction variable */
rtx m; /* multiplicative constant */
rtx a; /* additive constant */
rtx reg; /* destination register */
rtx insert_before;
{
rtx seq;
rtx result;
/* Prevent unexpected sharing of these rtx. */
a = copy_rtx (a);
b = copy_rtx (b);
1996-07-04 00:07:53 +02:00
/* Increase the lifetime of any invariants moved further in code. */
1992-02-01 09:24:22 +01:00
update_reg_last_use (a, insert_before);
update_reg_last_use (b, insert_before);
update_reg_last_use (m, insert_before);
start_sequence ();
result = expand_mult_add (b, reg, m, a, GET_MODE (reg), 1);
1992-02-01 09:24:22 +01:00
if (reg != result)
emit_move_insn (reg, result);
seq = gen_sequence ();
end_sequence ();
emit_insn_before (seq, insert_before);
* Integrate alias analysis changes from jfc@mit.edu * Makefile.in (OBJS): Add alias.o (alias.o): Add dependencies. * alias.c: New file. * sched.c: Remove alias analysis code. It lives in alias.c now. (reg_last_uses_size): Declare. (sched_analyze_2): Add new arguments to true_dependence. (sched_analyze_insn): Use reg_last_uses_size instead of max_reg. (schedule_block): Initialize reg_last_uses_size. (schedule_insns): Always call init_alias_analysis. * calls.c (expand_call): Note calls to malloc, calloc, and realloc; mark return value from such functions as a pointer and keep track of them for alias analysis. If a return value from a function is a pointer, mark it as such. * combine.c (distribute_notes): Handle REG_NOALIAS. * cse.c (struct write_data): Delete. No longer needed. (invalidate): Don't call set_nonvarying_address_components anymore. Use true_dependence to decide if an entry should be removed from the hash table. (invalidate_memory): Remove WRITES argument, simplify appropriately. Fix all callers. (note_mem_written): Similarly for WRITE_PTR argument. (invalidate_from_clobbers): Similarly for W argument. (invalidate_for_call): Remove memory elements from the hash table. (refers_to_mem_p, cse_rtx_addr_varies_p): Deleted. (cse_rtx_varies_p): New function. Derived from old cse_rtx_addr_varies_p. (cse_insn): Remove WRITES_MEMORY and INIT variables and all references. Don't call note_mem_written anymore. Stack pushes invalidate the stack pointer if PUSH_ROUNDING is defined. No longer need to call cse_rtx_addr_varies_p to decide if a MEM should be invalidated. (skipped_writes_memory): Remove variable. (invalidate_skipped_set): Simplify and wewrite to use invalidate_memory. (invalidate_skipped_block): Simplify for new alias analysis code. (cse_set_around_loop): Likewise. (cse_main): Call init_alias_analysis. * flags.h (flag_alias_check, flag_argument_noalias): Declare. * toplev.c (flag_alias_check, flag_argument_noalias): Define. (f_options): Add new alias checking arguments. (main): Set flag_alias_check when optimizing. * local_alloc (validate_equiv_mem_from_store): Add new arguments to true_dependence. (memref_referenced_p): Likewise. * loop.c (NUM_STORES): Increase to 30. (prescan_loop): Only non-constant calls set unknown_address_altered. (invariant_p): Add new arguments to true_dependence. (record_giv): Initialize unrolled and shared fields. (emit_iv_add_mult): Call record_base_value as needed. * loop.h (struct induction): Add unrolled and shared fields. * unroll.c (unroll_loop): Call record_base_value as needed. (copy_loop_body): Likewise. (final_biv_value): Likewise. (final_giv_value): Likewise. (find_splittable_regs): Likewise. Only create one new pseudo if we have multiple address GIVs that were combined with the same dst_reg GIV. Note when a new register is created due to unrolling. * rtl.c (reg_note_name): Add REG_NOALIAS. * rtl.h (enum reg_note): Similarly. (rtx_varies_p, may_trap_p, side_effects_p): Declare. (volatile_refs_p, volatile_insn_p, remove_note): Likewise. (note_stores, refers_to_regno_p, reg_overlap_mentioned_p): Likewise. (true_dependence, read_dependence, anti_dependence): Likewise. (output_dependence, init_alias_analysis, end_alias_analysis): Likewise. (mark_user_reg, mark_reg_pointer): Likewise. jfc's alias analysis code. From-SVN: r14768
1997-08-11 22:07:24 +02:00
/* It is entirely possible that the expansion created lots of new
registers. Iterate over the sequence we just created and
record them all. */
if (GET_CODE (seq) == SEQUENCE)
{
int i;
for (i = 0; i < XVECLEN (seq, 0); ++i)
{
rtx set = single_set (XVECEXP (seq, 0, i));
if (set && GET_CODE (SET_DEST (set)) == REG)
record_base_value (REGNO (SET_DEST (set)), SET_SRC (set), 0);
}
}
else if (GET_CODE (seq) == SET
&& GET_CODE (SET_DEST (seq)) == REG)
record_base_value (REGNO (SET_DEST (seq)), SET_SRC (seq), 0);
1992-02-01 09:24:22 +01:00
}
/* Similar to emit_iv_add_mult, but compute cost rather than emitting
insns. */
static int
iv_add_mult_cost (b, m, a, reg)
rtx b; /* initial value of basic induction variable */
rtx m; /* multiplicative constant */
rtx a; /* additive constant */
rtx reg; /* destination register */
{
int cost = 0;
rtx last, result;
start_sequence ();
result = expand_mult_add (b, reg, m, a, GET_MODE (reg), 0);
if (reg != result)
emit_move_insn (reg, result);
last = get_last_insn ();
while (last)
{
rtx t = single_set (last);
if (t)
cost += rtx_cost (SET_SRC (t), SET);
last = PREV_INSN (last);
}
end_sequence ();
return cost;
}
1992-02-01 09:24:22 +01:00
/* Test whether A * B can be computed without
an actual multiply insn. Value is 1 if so. */
static int
product_cheap_p (a, b)
rtx a;
rtx b;
{
int i;
rtx tmp;
int win = 1;
1996-07-04 00:07:53 +02:00
/* If only one is constant, make it B. */
1992-02-01 09:24:22 +01:00
if (GET_CODE (a) == CONST_INT)
tmp = a, a = b, b = tmp;
/* If first constant, both constant, so don't need multiply. */
if (GET_CODE (a) == CONST_INT)
return 1;
/* If second not constant, neither is constant, so would need multiply. */
if (GET_CODE (b) != CONST_INT)
return 0;
/* One operand is constant, so might not need multiply insn. Generate the
code for the multiply and see if a call or multiply, or long sequence
of insns is generated. */
start_sequence ();
expand_mult (GET_MODE (a), a, b, NULL_RTX, 1);
1992-02-01 09:24:22 +01:00
tmp = gen_sequence ();
end_sequence ();
if (GET_CODE (tmp) == SEQUENCE)
{
if (XVEC (tmp, 0) == 0)
win = 1;
else if (XVECLEN (tmp, 0) > 3)
win = 0;
else
for (i = 0; i < XVECLEN (tmp, 0); i++)
{
rtx insn = XVECEXP (tmp, 0, i);
if (GET_CODE (insn) != INSN
|| (GET_CODE (PATTERN (insn)) == SET
&& GET_CODE (SET_SRC (PATTERN (insn))) == MULT)
|| (GET_CODE (PATTERN (insn)) == PARALLEL
&& GET_CODE (XVECEXP (PATTERN (insn), 0, 0)) == SET
&& GET_CODE (SET_SRC (XVECEXP (PATTERN (insn), 0, 0))) == MULT))
{
win = 0;
break;
}
}
}
else if (GET_CODE (tmp) == SET
&& GET_CODE (SET_SRC (tmp)) == MULT)
win = 0;
else if (GET_CODE (tmp) == PARALLEL
&& GET_CODE (XVECEXP (tmp, 0, 0)) == SET
&& GET_CODE (SET_SRC (XVECEXP (tmp, 0, 0))) == MULT)
win = 0;
return win;
}
/* Check to see if loop can be terminated by a "decrement and branch until
zero" instruction. If so, add a REG_NONNEG note to the branch insn if so.
Also try reversing an increment loop to a decrement loop
to see if the optimization can be performed.
Value is nonzero if optimization was performed. */
/* This is useful even if the architecture doesn't have such an insn,
because it might change a loops which increments from 0 to n to a loop
which decrements from n to 0. A loop that decrements to zero is usually
faster than one that increments from zero. */
/* ??? This could be rewritten to use some of the loop unrolling procedures,
such as approx_final_value, biv_total_increment, loop_iterations, and
final_[bg]iv_value. */
static int
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
check_dbra_loop (loop, insn_count)
struct loop *loop;
1992-02-01 09:24:22 +01:00
int insn_count;
{
struct loop_info *loop_info = LOOP_INFO (loop);
struct loop_regs *regs = LOOP_REGS (loop);
struct loop_ivs *ivs = LOOP_IVS (loop);
1992-02-01 09:24:22 +01:00
struct iv_class *bl;
rtx reg;
rtx jump_label;
rtx final_value;
rtx start_value;
rtx new_add_val;
rtx comparison;
rtx before_comparison;
rtx p;
rtx jump;
rtx first_compare;
int compare_and_branch;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
rtx loop_start = loop->start;
rtx loop_end = loop->end;
1992-02-01 09:24:22 +01:00
/* If last insn is a conditional branch, and the insn before tests a
register value, try to optimize it. Otherwise, we can't do anything. */
jump = PREV_INSN (loop_end);
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
comparison = get_condition_for_loop (loop, jump);
1992-02-01 09:24:22 +01:00
if (comparison == 0)
return 0;
if (!onlyjump_p (jump))
return 0;
1992-02-01 09:24:22 +01:00
/* Try to compute whether the compare/branch at the loop end is one or
two instructions. */
get_condition (jump, &first_compare);
if (first_compare == jump)
compare_and_branch = 1;
else if (first_compare == prev_nonnote_insn (jump))
compare_and_branch = 2;
else
return 0;
{
/* If more than one condition is present to control the loop, then
2000-07-18 02:31:30 +02:00
do not proceed, as this function does not know how to rewrite
loop tests with more than one condition.
Look backwards from the first insn in the last comparison
sequence and see if we've got another comparison sequence. */
rtx jump1;
if ((jump1 = prev_nonnote_insn (first_compare)) != loop->cont)
if (GET_CODE (jump1) == JUMP_INSN)
return 0;
}
1992-02-01 09:24:22 +01:00
/* Check all of the bivs to see if the compare uses one of them.
Skip biv's set more than once because we can't guarantee that
it will be zero on the last iteration. Also skip if the biv is
used between its update and the test insn. */
for (bl = ivs->loop_iv_list; bl; bl = bl->next)
1992-02-01 09:24:22 +01:00
{
if (bl->biv_count == 1
&& ! bl->biv->maybe_multiple
1992-02-01 09:24:22 +01:00
&& bl->biv->dest_reg == XEXP (comparison, 0)
&& ! reg_used_between_p (regno_reg_rtx[bl->regno], bl->biv->insn,
first_compare))
1992-02-01 09:24:22 +01:00
break;
}
if (! bl)
return 0;
/* Look for the case where the basic induction variable is always
nonnegative, and equals zero on the last iteration.
In this case, add a reg_note REG_NONNEG, which allows the
m68k DBRA instruction to be used. */
if (((GET_CODE (comparison) == GT
&& GET_CODE (XEXP (comparison, 1)) == CONST_INT
&& INTVAL (XEXP (comparison, 1)) == -1)
|| (GET_CODE (comparison) == NE && XEXP (comparison, 1) == const0_rtx))
&& GET_CODE (bl->biv->add_val) == CONST_INT
&& INTVAL (bl->biv->add_val) < 0)
{
/* Initial value must be greater than 0,
init_val % -dec_value == 0 to ensure that it equals zero on
the last iteration */
if (GET_CODE (bl->initial_value) == CONST_INT
&& INTVAL (bl->initial_value) > 0
&& (INTVAL (bl->initial_value)
% (-INTVAL (bl->biv->add_val))) == 0)
1992-02-01 09:24:22 +01:00
{
/* register always nonnegative, add REG_NOTE to branch */
if (! find_reg_note (jump, REG_NONNEG, NULL_RTX))
REG_NOTES (jump)
= gen_rtx_EXPR_LIST (REG_NONNEG, bl->biv->dest_reg,
REG_NOTES (jump));
1992-02-01 09:24:22 +01:00
bl->nonneg = 1;
return 1;
}
/* If the decrement is 1 and the value was tested as >= 0 before
the loop, then we can safely optimize. */
for (p = loop_start; p; p = PREV_INSN (p))
{
if (GET_CODE (p) == CODE_LABEL)
break;
if (GET_CODE (p) != JUMP_INSN)
continue;
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
before_comparison = get_condition_for_loop (loop, p);
1992-02-01 09:24:22 +01:00
if (before_comparison
&& XEXP (before_comparison, 0) == bl->biv->dest_reg
&& GET_CODE (before_comparison) == LT
&& XEXP (before_comparison, 1) == const0_rtx
&& ! reg_set_between_p (bl->biv->dest_reg, p, loop_start)
&& INTVAL (bl->biv->add_val) == -1)
{
if (! find_reg_note (jump, REG_NONNEG, NULL_RTX))
REG_NOTES (jump)
= gen_rtx_EXPR_LIST (REG_NONNEG, bl->biv->dest_reg,
REG_NOTES (jump));
1992-02-01 09:24:22 +01:00
bl->nonneg = 1;
return 1;
}
}
}
rtl.h (RTL_CHECK1, RTL_CHECK2): New macros which type- and bounds- check RTL accesses if --enable-checking. 1999-08-31 12:20 -0700 Zack Weinberg <zack@bitmover.com> * rtl.h (RTL_CHECK1, RTL_CHECK2): New macros which type- and bounds- check RTL accesses if --enable-checking. (RTVEC_ELT): Bounds check if --enable-checking. (XWINT, XINT, XSTR, XEXP, XVEC, XMODE, XBITMAP, XTREE, XBBDEF): Use RTL_CHECK1/RTL_CHECK2 as appropriate. (XVECEXP, XVECLEN): Define in terms of XVEC, RTVEC_ELT, and GET_NUM_ELEM. (X0WINT, X0INT, X0STR, X0EXP, X0VEC, X0MODE, X0BITMAP, X0TREE, X0BBDEF, X0ADVFLAGS): New macros for accessing '0' slots of RTXes. (ADDR_DIFF_VEC_FLAGS): Use X0ADVFLAGS. (NOTE_SOURCE_FILE): Use X0STR. (NOTE_BLOCK_NUMBER, NOTE_EH_HANDLER, LABEL_NUSES, MEM_ALIAS_SET): Use X0INT. (NOTE_RANGE_INFO, NOTE_LIVE_INFO, NOTE_BASIC_BLOCK, JUMP_LABEL, LABEL_REFS, LABEL_NEXTREF, CONTAINING_INSN): Use X0EXP. * real.h (CONST_DOUBLE_CHAIN): Use X0EXP. * rtl.c (copy_rtx, copy_most_rtx): Copy '0' slots with X0WINT. (rtl_check_failed_bounds, rtl_check_failed_type1, rtl_check_failed_type2, rtvec_check_failed_bounds): New functions. (fancy_abort): Fix comment. * cse.c (canon_hash): Read CONST_DOUBLE data slots with XWINT. (cse_insn): Decrement LABEL_NUSES for jump target before deleting jump insn. * emit-rtl.c (gen_rtx_CONST_DOUBLE): Use X0EXP for slot 1. * final.c (alter_subreg): Compute regno before changing x to REG; set REGNO(x) after changing it. * flow.c (count_basic_blocks): Use XWINT to inspect EH_REGION notes containing CONST_INTs. (delete_eh_regions): Use NOTE_EH_HANDLER. * function.c (put_reg_into_stack): Make reg a MEM before initializing it. (fixup_var_refs_insns): Save REG_NOTES (insn) in case we delete insn. (gen_mem_addressof): Make reg a MEM before initializing it. * integrate.c (copy_rtx_and_substitute): Copy '0' slots with X0WINT. * local-alloc.c (update_equiv_regs): Zap REG_NOTES before deleting an insn, not after. (block_alloc): Only look at PATTERN(insn) if we have to, and only if it's format class 'i'. * loop.c (check_dbra_loop): Check bl->biv->add_val is a CONST_INT before using its INTVAL. * print-rtl.c (print_rtx): Use X0STR. * regmove.c (fixup_match_1): Don't look at PATTERN of non-class-'i' insn chain elements. * reload.c (loc_mentioned_in_p): Take address of in->fld[1].rtx directly. * reload1.c (reload): Change reg to a MEM before initializing it. * varasm.c (mark_constant_pool): Skip CONST_DOUBLES, which have no names. * config/i386/i386.md (decrement_and_branch_if_zero): Fix typo. From-SVN: r29008
1999-08-31 21:39:10 +02:00
else if (GET_CODE (bl->biv->add_val) == CONST_INT
&& INTVAL (bl->biv->add_val) > 0)
1992-02-01 09:24:22 +01:00
{
/* Try to change inc to dec, so can apply above optimization. */
/* Can do this if:
all registers modified are induction variables or invariant,
all memory references have non-overlapping addresses
(obviously true if only one write)
allow 2 insns for the compare/jump at the end of the loop. */
/* Also, we must avoid any instructions which use both the reversed
biv and another biv. Such instructions will fail if the loop is
reversed. We meet this condition by requiring that either
no_use_except_counting is true, or else that there is only
one biv. */
1992-02-01 09:24:22 +01:00
int num_nonfixed_reads = 0;
/* 1 if the iteration var is used only to count iterations. */
int no_use_except_counting = 0;
/* 1 if the loop has no memory store, or it has a single memory store
which is reversible. */
int reversible_mem_store = 1;
1992-02-01 09:24:22 +01:00
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (bl->giv_count == 0 && ! loop->exit_count)
1992-02-01 09:24:22 +01:00
{
rtx bivreg = regno_reg_rtx[bl->regno];
/* If there are no givs for this biv, and the only exit is the
1998-05-06 23:09:07 +02:00
fall through at the end of the loop, then
1992-02-01 09:24:22 +01:00
see if perhaps there are no uses except to count. */
no_use_except_counting = 1;
for (p = loop_start; p != loop_end; p = NEXT_INSN (p))
alias.c (mark_constant_function): Use INSN_P. * alias.c (mark_constant_function): Use INSN_P. (init_alias_analysis): Likewise. * combine.c (combine_instructions): Use INSN_P. (can_combine_p): Likewise. (try_combine): Likewise. (distribute_notes): Likewise. (distribute_links): Likewise. * cse.c (cse_around_loop): Use INSN_P. (invalidate_skipped_block): Likewise. (cse_set_around_loop): Likewise. (cse_end_of_basic_block): Likewise. (delete_trivially_dead_insns): Likewise. * emit-rtl.c (unshare_all_rtl_again): Use INSN_P. (unshare_all_rtl_1): Likewise. (next_cc0_user): Likewise. (try_split make_insn_raw): Likewise. (remove_unnecessary_notes): Likewise. * final.c (shorten_branches): Use INSN_P. (leaf_renumber_regs): Likewise. (leaf_renumber_regs_insn): Likewise. * flow.c (find_label_refs): Use INSN_P. (verify_wide_reg): Likewise. (notice_stack_pointer_modification): Likewise. (count_or_remove_death_notes): Likewise. (verify_flow_info): Likewise. (clear_log_links): Likewise. * function.c (fixup_var_refs_insns): Use INSN_P. (compute_insns_for_mem): Likewise. * gcse.c (alloc_gcse_mem): Use INSN_P. (compute_sets): Likewise. (compute_hash_table): Likewise. (classic_gcse): Likewise. (cprop): Likewise. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks_1): Likewise. * global.c (expand_preferences): Use INSN_P. (build_insn_chain): Likewise. * graph.c (node_data): Use INSN_P. * haifa-sched.c (priority): Use INSN_P. (rm_line_notes): Likewise. (rm_other_notes): Likewise. (find_insn_reg_weight): Likewise. (init_target_units): Likewise. (schedule_block): Likewise. (compute_block_forward_dependences): Likewise. (debug_dependencies): Likewise. (set_priorities): Likewise. * integrate.c (function_cannot_inline_p): Use INSN_P. (save_parm_insns): Likewise. (copy_insn_list): Likewise. * jump.c (mark_all_labels): Use INSN_P. (never_reached_warning): Likewise. * lcm.c (optimize_mode_switching): Use INSN_P. * local-alloc.c (validate_equiv_mem): Use INSN_P. (memref_used_between_p): Likewise. (update_equiv_regs): Likewise. (block_alloc): Likewise. (no_conflict_p): Likewise. * loop.c (scan_loop): Use INSN_P. (find_and_verify_loops): Likewise. (count_loop_regs_set): Likewise. (loop_reg_used_before_p): Likewise. (strength_reduce): Likewise. (recombine_givs): Likewise. (check_dbra_loop): Likewise. (load_mems): Likewise. (try_copy_prop): Likewise. * print-rtl.c (print_rtx): Use INSN_P. * recog.c (find_single_use): Use INSN_P. * reg-stack.c (stack_regs_mentioned): Use INSN_P. (next_flags_user): Likewise. (swap_rtx_condition): Likewise. * regmove.c (mark_flags_life_zones): Use INSN_P. (optimize_reg_copy_1): Likewise. (optimize_reg_copy_2): Likewise. (optimize_reg_copy_3): Likewise. (reg_is_remote_constant_p): Likewise. (fixup_match_2): Likewise. (regmove_optimize): Likewise. (fixup_match_1): Likewise. * regrename.c (build_def_use): Use INSN_P. (replace_reg_in_block): Likewise. (consider_use): Likewise. * reload.c (find_equiv_reg): Use INSN_P. * reload1.c (reload): Use INSN_P. (maybe_fix_stack_asms): Likewise. (calculate_needs_all_insns): Likewise. (reload_as_needed): Likewise. (emit_output_reload_insns): Likewise. (delete_address_reloads_1): Likewise. (reload_cse_regs_1): Likewise. (reload_combine): Likewise. (reload_cse_move2add): Likewise. * reorg.c (redundant_insn): Use INSN_P. (dbr_schedule): Likewise. * resource.c (find_dead_or_set_registers): Use INSN_P. (mark_target_live_regs): Likewise. * rtlanal.c (reg_used_between_p): Use INSN_P. (reg_referenced_between_p): Likewise. (reg_set_between_p): Likewise. (reg_set_p): Likewise. (single_set): Likewise. (multiple_sets): Likewise. (find_last_value): Likewise. (reg_set_last): Likewise. (find_reg_note): Likewise. (find_regno_note): Likewise. * sibcall.c (sequence_uses_addressof): Use INSN_P. * simplify-rtx.c (cselib_process_insn): Use INSN_P. * ssa.c (find_evaluations): Use INSN_P. (rename_block): Likewise. (rename_equivalent_regs): Likewise. * unroll.c (loop_find_equiv_value): Use INSN_P. (set_dominates_use): Likewise. * varasm.c (mark_constant_pool): Use INSN_P. (mark_constants): Likewise. * config/alpha/alpha.c (alpha_does_function_need_gp): Use INSN_P. (alphaev4_next_group): Likewise. (alphaev5_next_group): Likewise. * config/c4x/c4x.c (c4x_process_after_reload): Use INSN_P. (c4x_rptb_rpts_p): Likewise. * config/mips/mips.c (mips16_optimize_gp): Use INSN_P. * config/rs6000/rs6000.c (uses_TOC): Use INSN_P. (rs6000_adjust_priority): Likewise. * config/sh/sh.c (sh_loop_align): Use INSN_P. (machine_dependent_reorg): Likewise. (split_branches): Likewise. * config/tahoe/tahoe.c (tahoe_cmp_check): Use INSN_P. From-SVN: r35494
2000-08-04 22:28:08 +02:00
if (INSN_P (p))
1992-02-01 09:24:22 +01:00
{
rtx set = single_set (p);
if (set && GET_CODE (SET_DEST (set)) == REG
&& REGNO (SET_DEST (set)) == bl->regno)
/* An insn that sets the biv is okay. */
;
else if ((p == prev_nonnote_insn (prev_nonnote_insn (loop_end))
|| p == prev_nonnote_insn (loop_end))
&& reg_mentioned_p (bivreg, PATTERN (p)))
{
/* If either of these insns uses the biv and sets a pseudo
that has more than one usage, then the biv has uses
other than counting since it's used to derive a value
that is used more than one time. */
rtl.h (note_stores): Add additional paramter. * rtl.h (note_stores): Add additional paramter. * rtlanal.c (reg_set_p_1): Take additional paramter. (reg_set_last_1): Likewise. (reg_set_p): Adjust call to note_stores. (reg_set_last): Likewise. (note_stores): Pass data parameter to worker function. * alias.c (record_set): Take additional parameter. (init_alias_analysis): Pass it. * caller-save.c (mark_set_regs): Take additional parameter. (save_call_clobbered_regs): Pass NULL to note_stores. * combine.c (set_nonzero_bits_and_sign_copies): Take additional parameter. (record_dead_and_set_regs_1): Likewise. (reg_dead_at_p_1): Likewise. (combine_instructions): Adjust calls to note_stores. (try_combine): Likewise. (record_dead_insn): Remove. (record_dead_and_set_regs): Adjust calls to note_stores. (reg_dead_at_p): Likewise. * cse.c (invalidate_skipped_set): Take additional parameter. (cse_check_loop_start): Likewise. (cse_check_loop_start_value): Remove. (cse_set_around_loop): Adjust calls to note_stores. * flow.c (notice_stack_pointer_modification): Take additional parameter. Remove duplicate declaration. (record_volatile_insns): Adjust calls to note_stores. * gcse.c (record_set_info): Take additional parameter. (record_last_set_info): Likewise. (invalidate_nonnull_info): Likewise. (record_set_insn): Remove. (compute_sets): Adjust calls to note_stores. (last_set_insn): Remove. (compute_hash_table): Adjust calls to note_stores. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks): Likewise. * global.c (mark_reg_store): Take additional parameter. (mark_reg_clobber): Likewise. (reg_becomes_live): Likewise. (global_conflicts): Adjust calls to note_stores. (build_insn_chain): Likewise. * integrate.c (note_modified_parmregs): Take additional parameter. (mark_stores): Likewise. Make it static. (save_for_inline_nocopy): Adjust calls to note_stores. (try_constants): Likewise. * integrate.h (mark_stores): Remove declaration. * jump.c (mark_modified_reg): Take additional parameter. (thread_jumps): Adjust calls to note_stores. * local-alloc.c (validate_equiv_mem_from_store): Take additional parameter. (no_equiv): Likewise. (reg_is_set): Likewise. (validate_equiv_mem): Adjust calls to note_stores. (update_equiv_regs): Likewise. (block_alloc): Likewise. * loop.c (note_set_pseudo_multiple_uses_retval): Remove. (note_addr_stored): Take additional parameter. (note_set_pseudo_multiple_uses): Likewise. (record_initial): Likewise. (prescan_loop): Adjust calls to note_stores. (strength_reduce): Likewise. (check_dbra_loop): Likewise. * regmove.c (flags_set_1): Take additional paramter. (mark_flags_life_zones): Adjust calls to note_stores. * reload1.c (mark_not_eliminable): Take additional parameter. (forget_old_reloads_1): Likewise. (reload_cse_invalidate_rtx): Likewise. (reload_cse_check_clobber): Likewise. (reload_combine_note_store): Likewise. (move2add_note_store): Likewise. (reload): Adjust calls to note_stores. (reload_as_needed): Likewise. (emit_reload_insns): Likewise. (reload_cse_regs_1): Likewise. (reload_cse_record_set): Adjust calls to reload_cse_invalidate_rtx. (reload_combine): Adjust calls to note_stores. * resource.c (update_live_status): Take additional paramter. (mark_target_live_regs): Adjust calls to note_stores. * stupid.c (find_clobbered_regs): Take additional parameter. (stupid_life_analysis): Adjust calls to note_stores. From-SVN: r30221
1999-10-27 21:27:41 +02:00
note_stores (PATTERN (p), note_set_pseudo_multiple_uses,
regs);
if (regs->multiple_uses)
{
no_use_except_counting = 0;
break;
}
}
1992-02-01 09:24:22 +01:00
else if (reg_mentioned_p (bivreg, PATTERN (p)))
{
no_use_except_counting = 0;
break;
}
}
}
if (no_use_except_counting)
/* No need to worry about MEMs. */
;
else if (loop_info->num_mem_sets <= 1)
{
for (p = loop_start; p != loop_end; p = NEXT_INSN (p))
alias.c (mark_constant_function): Use INSN_P. * alias.c (mark_constant_function): Use INSN_P. (init_alias_analysis): Likewise. * combine.c (combine_instructions): Use INSN_P. (can_combine_p): Likewise. (try_combine): Likewise. (distribute_notes): Likewise. (distribute_links): Likewise. * cse.c (cse_around_loop): Use INSN_P. (invalidate_skipped_block): Likewise. (cse_set_around_loop): Likewise. (cse_end_of_basic_block): Likewise. (delete_trivially_dead_insns): Likewise. * emit-rtl.c (unshare_all_rtl_again): Use INSN_P. (unshare_all_rtl_1): Likewise. (next_cc0_user): Likewise. (try_split make_insn_raw): Likewise. (remove_unnecessary_notes): Likewise. * final.c (shorten_branches): Use INSN_P. (leaf_renumber_regs): Likewise. (leaf_renumber_regs_insn): Likewise. * flow.c (find_label_refs): Use INSN_P. (verify_wide_reg): Likewise. (notice_stack_pointer_modification): Likewise. (count_or_remove_death_notes): Likewise. (verify_flow_info): Likewise. (clear_log_links): Likewise. * function.c (fixup_var_refs_insns): Use INSN_P. (compute_insns_for_mem): Likewise. * gcse.c (alloc_gcse_mem): Use INSN_P. (compute_sets): Likewise. (compute_hash_table): Likewise. (classic_gcse): Likewise. (cprop): Likewise. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks_1): Likewise. * global.c (expand_preferences): Use INSN_P. (build_insn_chain): Likewise. * graph.c (node_data): Use INSN_P. * haifa-sched.c (priority): Use INSN_P. (rm_line_notes): Likewise. (rm_other_notes): Likewise. (find_insn_reg_weight): Likewise. (init_target_units): Likewise. (schedule_block): Likewise. (compute_block_forward_dependences): Likewise. (debug_dependencies): Likewise. (set_priorities): Likewise. * integrate.c (function_cannot_inline_p): Use INSN_P. (save_parm_insns): Likewise. (copy_insn_list): Likewise. * jump.c (mark_all_labels): Use INSN_P. (never_reached_warning): Likewise. * lcm.c (optimize_mode_switching): Use INSN_P. * local-alloc.c (validate_equiv_mem): Use INSN_P. (memref_used_between_p): Likewise. (update_equiv_regs): Likewise. (block_alloc): Likewise. (no_conflict_p): Likewise. * loop.c (scan_loop): Use INSN_P. (find_and_verify_loops): Likewise. (count_loop_regs_set): Likewise. (loop_reg_used_before_p): Likewise. (strength_reduce): Likewise. (recombine_givs): Likewise. (check_dbra_loop): Likewise. (load_mems): Likewise. (try_copy_prop): Likewise. * print-rtl.c (print_rtx): Use INSN_P. * recog.c (find_single_use): Use INSN_P. * reg-stack.c (stack_regs_mentioned): Use INSN_P. (next_flags_user): Likewise. (swap_rtx_condition): Likewise. * regmove.c (mark_flags_life_zones): Use INSN_P. (optimize_reg_copy_1): Likewise. (optimize_reg_copy_2): Likewise. (optimize_reg_copy_3): Likewise. (reg_is_remote_constant_p): Likewise. (fixup_match_2): Likewise. (regmove_optimize): Likewise. (fixup_match_1): Likewise. * regrename.c (build_def_use): Use INSN_P. (replace_reg_in_block): Likewise. (consider_use): Likewise. * reload.c (find_equiv_reg): Use INSN_P. * reload1.c (reload): Use INSN_P. (maybe_fix_stack_asms): Likewise. (calculate_needs_all_insns): Likewise. (reload_as_needed): Likewise. (emit_output_reload_insns): Likewise. (delete_address_reloads_1): Likewise. (reload_cse_regs_1): Likewise. (reload_combine): Likewise. (reload_cse_move2add): Likewise. * reorg.c (redundant_insn): Use INSN_P. (dbr_schedule): Likewise. * resource.c (find_dead_or_set_registers): Use INSN_P. (mark_target_live_regs): Likewise. * rtlanal.c (reg_used_between_p): Use INSN_P. (reg_referenced_between_p): Likewise. (reg_set_between_p): Likewise. (reg_set_p): Likewise. (single_set): Likewise. (multiple_sets): Likewise. (find_last_value): Likewise. (reg_set_last): Likewise. (find_reg_note): Likewise. (find_regno_note): Likewise. * sibcall.c (sequence_uses_addressof): Use INSN_P. * simplify-rtx.c (cselib_process_insn): Use INSN_P. * ssa.c (find_evaluations): Use INSN_P. (rename_block): Likewise. (rename_equivalent_regs): Likewise. * unroll.c (loop_find_equiv_value): Use INSN_P. (set_dominates_use): Likewise. * varasm.c (mark_constant_pool): Use INSN_P. (mark_constants): Likewise. * config/alpha/alpha.c (alpha_does_function_need_gp): Use INSN_P. (alphaev4_next_group): Likewise. (alphaev5_next_group): Likewise. * config/c4x/c4x.c (c4x_process_after_reload): Use INSN_P. (c4x_rptb_rpts_p): Likewise. * config/mips/mips.c (mips16_optimize_gp): Use INSN_P. * config/rs6000/rs6000.c (uses_TOC): Use INSN_P. (rs6000_adjust_priority): Likewise. * config/sh/sh.c (sh_loop_align): Use INSN_P. (machine_dependent_reorg): Likewise. (split_branches): Likewise. * config/tahoe/tahoe.c (tahoe_cmp_check): Use INSN_P. From-SVN: r35494
2000-08-04 22:28:08 +02:00
if (INSN_P (p))
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
num_nonfixed_reads += count_nonfixed_reads (loop, PATTERN (p));
/* If the loop has a single store, and the destination address is
invariant, then we can't reverse the loop, because this address
might then have the wrong value at loop exit.
This would work if the source was invariant also, however, in that
case, the insn should have been moved out of the loop. */
if (loop_info->num_mem_sets == 1)
{
struct induction *v;
reversible_mem_store
= (! loop_info->unknown_address_altered
&& ! loop_info->unknown_constant_address_altered
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
&& ! loop_invariant_p (loop,
XEXP (XEXP (loop_info->store_mems, 0),
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
0)));
/* If the store depends on a register that is set after the
store, it depends on the initial value, and is thus not
reversible. */
for (v = bl->giv; reversible_mem_store && v; v = v->next_iv)
{
if (v->giv_type == DEST_REG
&& reg_mentioned_p (v->dest_reg,
PATTERN (loop_info->first_loop_store_insn))
&& loop_insn_first_p (loop_info->first_loop_store_insn,
v->insn))
reversible_mem_store = 0;
}
}
}
else
return 0;
1992-02-01 09:24:22 +01:00
/* This code only acts for innermost loops. Also it simplifies
the memory address check by only reversing loops with
zero or one memory access.
Two memory accesses could involve parts of the same array,
and that can't be reversed.
If the biv is used only for counting, than we don't need to worry
about all these things. */
if ((num_nonfixed_reads <= 1
&& ! loop_info->has_call
&& ! loop_info->has_volatile
&& reversible_mem_store
&& (bl->giv_count + bl->biv_count + loop_info->num_mem_sets
+ the_movables.num + compare_and_branch == insn_count)
&& (bl == ivs->loop_iv_list && bl->next == 0))
|| no_use_except_counting)
1992-02-01 09:24:22 +01:00
{
rtx tem;
/* Loop can be reversed. */
if (loop_dump_stream)
fprintf (loop_dump_stream, "Can reverse loop\n");
/* Now check other conditions:
1997-12-07 01:31:01 +01:00
The increment must be a constant, as must the initial value,
and the comparison code must be LT.
1992-02-01 09:24:22 +01:00
This test can probably be improved since +/- 1 in the constant
can be obtained by changing LT to LE and vice versa; this is
confusing. */
if (comparison
/* for constants, LE gets turned into LT */
&& (GET_CODE (comparison) == LT
|| (GET_CODE (comparison) == LE
&& no_use_except_counting)))
1992-02-01 09:24:22 +01:00
{
HOST_WIDE_INT add_val, add_adjust, comparison_val = 0;
rtx initial_value, comparison_value;
int nonneg = 0;
enum rtx_code cmp_code;
int comparison_const_width;
unsigned HOST_WIDE_INT comparison_sign_mask;
add_val = INTVAL (bl->biv->add_val);
comparison_value = XEXP (comparison, 1);
if (GET_MODE (comparison_value) == VOIDmode)
comparison_const_width
= GET_MODE_BITSIZE (GET_MODE (XEXP (comparison, 0)));
else
comparison_const_width
= GET_MODE_BITSIZE (GET_MODE (comparison_value));
if (comparison_const_width > HOST_BITS_PER_WIDE_INT)
comparison_const_width = HOST_BITS_PER_WIDE_INT;
comparison_sign_mask
= (unsigned HOST_WIDE_INT) 1 << (comparison_const_width - 1);
/* If the comparison value is not a loop invariant, then we
can not reverse this loop.
??? If the insns which initialize the comparison value as
a whole compute an invariant result, then we could move
them out of the loop and proceed with loop reversal. */
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (! loop_invariant_p (loop, comparison_value))
return 0;
if (GET_CODE (comparison_value) == CONST_INT)
comparison_val = INTVAL (comparison_value);
initial_value = bl->initial_value;
/* Normalize the initial value if it is an integer and
has no other use except as a counter. This will allow
a few more loops to be reversed. */
if (no_use_except_counting
&& GET_CODE (comparison_value) == CONST_INT
&& GET_CODE (initial_value) == CONST_INT)
{
comparison_val = comparison_val - INTVAL (bl->initial_value);
/* The code below requires comparison_val to be a multiple
of add_val in order to do the loop reversal, so
round up comparison_val to a multiple of add_val.
Since comparison_value is constant, we know that the
current comparison code is LT. */
comparison_val = comparison_val + add_val - 1;
comparison_val
-= (unsigned HOST_WIDE_INT) comparison_val % add_val;
/* We postpone overflow checks for COMPARISON_VAL here;
even if there is an overflow, we might still be able to
reverse the loop, if converting the loop exit test to
NE is possible. */
initial_value = const0_rtx;
}
/* First check if we can do a vanilla loop reversal. */
if (initial_value == const0_rtx
/* If we have a decrement_and_branch_on_count,
prefer the NE test, since this will allow that
instruction to be generated. Note that we must
use a vanilla loop reversal if the biv is used to
calculate a giv or has a non-counting use. */
#if ! defined (HAVE_decrement_and_branch_until_zero) \
&& defined (HAVE_decrement_and_branch_on_count)
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
&& (! (add_val == 1 && loop->vtop
&& (bl->biv_count == 0
|| no_use_except_counting)))
#endif
&& GET_CODE (comparison_value) == CONST_INT
/* Now do postponed overflow checks on COMPARISON_VAL. */
&& ! (((comparison_val - add_val) ^ INTVAL (comparison_value))
& comparison_sign_mask))
{
/* Register will always be nonnegative, with value
0 on last iteration */
add_adjust = add_val;
nonneg = 1;
cmp_code = GE;
}
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
else if (add_val == 1 && loop->vtop
&& (bl->biv_count == 0
|| no_use_except_counting))
{
add_adjust = 0;
cmp_code = NE;
}
else
return 0;
if (GET_CODE (comparison) == LE)
add_adjust -= add_val;
/* If the initial value is not zero, or if the comparison
value is not an exact multiple of the increment, then we
can not reverse this loop. */
if (initial_value == const0_rtx
&& GET_CODE (comparison_value) == CONST_INT)
{
if (((unsigned HOST_WIDE_INT) comparison_val % add_val) != 0)
return 0;
}
else
{
if (! no_use_except_counting || add_val != 1)
return 0;
}
final_value = comparison_value;
/* Reset these in case we normalized the initial value
and comparison value above. */
if (GET_CODE (comparison_value) == CONST_INT
&& GET_CODE (initial_value) == CONST_INT)
{
comparison_value = GEN_INT (comparison_val);
final_value
= GEN_INT (comparison_val + INTVAL (bl->initial_value));
}
bl->initial_value = initial_value;
1992-02-01 09:24:22 +01:00
/* Save some info needed to produce the new insns. */
reg = bl->biv->dest_reg;
jump_label = XEXP (SET_SRC (PATTERN (PREV_INSN (loop_end))), 1);
if (jump_label == pc_rtx)
jump_label = XEXP (SET_SRC (PATTERN (PREV_INSN (loop_end))), 2);
new_add_val = GEN_INT (-INTVAL (bl->biv->add_val));
1992-02-01 09:24:22 +01:00
/* Set start_value; if this is not a CONST_INT, we need
to generate a SUB.
Initialize biv to start_value before loop start.
1992-02-01 09:24:22 +01:00
The old initializing insn will be deleted as a
dead store by flow.c. */
if (initial_value == const0_rtx
&& GET_CODE (comparison_value) == CONST_INT)
{
start_value = GEN_INT (comparison_val - add_adjust);
emit_insn_before (gen_move_insn (reg, start_value),
loop_start);
}
else if (GET_CODE (initial_value) == CONST_INT)
{
rtx offset = GEN_INT (-INTVAL (initial_value) - add_adjust);
enum machine_mode mode = GET_MODE (reg);
enum insn_code icode
= add_optab->handlers[(int) mode].insn_code;
if (! (*insn_data[icode].operand[0].predicate) (reg, mode)
|| ! ((*insn_data[icode].operand[1].predicate)
(comparison_value, mode))
|| ! ((*insn_data[icode].operand[2].predicate)
(offset, mode)))
return 0;
start_value
= gen_rtx_PLUS (mode, comparison_value, offset);
emit_insn_before ((GEN_FCN (icode)
(reg, comparison_value, offset)),
loop_start);
if (GET_CODE (comparison) == LE)
final_value = gen_rtx_PLUS (mode, comparison_value,
GEN_INT (add_val));
}
else if (! add_adjust)
{
enum machine_mode mode = GET_MODE (reg);
enum insn_code icode
= sub_optab->handlers[(int) mode].insn_code;
if (! (*insn_data[icode].operand[0].predicate) (reg, mode)
|| ! ((*insn_data[icode].operand[1].predicate)
(comparison_value, mode))
|| ! ((*insn_data[icode].operand[2].predicate)
(initial_value, mode)))
return 0;
start_value
= gen_rtx_MINUS (mode, comparison_value, initial_value);
emit_insn_before ((GEN_FCN (icode)
(reg, comparison_value, initial_value)),
loop_start);
}
else
/* We could handle the other cases too, but it'll be
better to have a testcase first. */
return 0;
1992-02-01 09:24:22 +01:00
/* We may not have a single insn which can increment a reg, so
create a sequence to hold all the insns from expand_inc. */
start_sequence ();
expand_inc (reg, new_add_val);
tem = gen_sequence ();
end_sequence ();
p = emit_insn_before (tem, bl->biv->insn);
1992-02-01 09:24:22 +01:00
delete_insn (bl->biv->insn);
1992-02-01 09:24:22 +01:00
/* Update biv info to reflect its new status. */
bl->biv->insn = p;
bl->initial_value = start_value;
bl->biv->add_val = new_add_val;
/* Update loop info. */
loop_info->initial_value = reg;
loop_info->initial_equiv_value = reg;
loop_info->final_value = const0_rtx;
loop_info->final_equiv_value = const0_rtx;
loop_info->comparison_value = const0_rtx;
loop_info->comparison_code = cmp_code;
loop_info->increment = new_add_val;
1992-02-01 09:24:22 +01:00
/* Inc LABEL_NUSES so that delete_insn will
not delete the label. */
LABEL_NUSES (XEXP (jump_label, 0))++;
1992-02-01 09:24:22 +01:00
/* Emit an insn after the end of the loop to set the biv's
proper exit value if it is used anywhere outside the loop. */
if ((REGNO_LAST_UID (bl->regno) != INSN_UID (first_compare))
1992-02-01 09:24:22 +01:00
|| ! bl->init_insn
|| REGNO_FIRST_UID (bl->regno) != INSN_UID (bl->init_insn))
1992-02-01 09:24:22 +01:00
emit_insn_after (gen_move_insn (reg, final_value),
loop_end);
/* Delete compare/branch at end of loop. */
delete_insn (PREV_INSN (loop_end));
if (compare_and_branch == 2)
delete_insn (first_compare);
1992-02-01 09:24:22 +01:00
/* Add new compare/branch insn at end of loop. */
start_sequence ();
emit_cmp_and_jump_insns (reg, const0_rtx, cmp_code, NULL_RTX,
GET_MODE (reg), 0, 0,
XEXP (jump_label, 0));
1992-02-01 09:24:22 +01:00
tem = gen_sequence ();
end_sequence ();
emit_jump_insn_before (tem, loop_end);
for (tem = PREV_INSN (loop_end);
tem && GET_CODE (tem) != JUMP_INSN;
tem = PREV_INSN (tem))
;
if (tem)
JUMP_LABEL (tem) = XEXP (jump_label, 0);
if (nonneg)
1992-02-01 09:24:22 +01:00
{
if (tem)
{
/* Increment of LABEL_NUSES done above. */
/* Register is now always nonnegative,
so add REG_NONNEG note to the branch. */
REG_NOTES (tem) = gen_rtx_EXPR_LIST (REG_NONNEG, reg,
REG_NOTES (tem));
}
bl->nonneg = 1;
1992-02-01 09:24:22 +01:00
}
/* No insn may reference both the reversed and another biv or it
will fail (see comment near the top of the loop reversal
code).
Earlier on, we have verified that the biv has no use except
counting, or it is the only biv in this function.
However, the code that computes no_use_except_counting does
not verify reg notes. It's possible to have an insn that
references another biv, and has a REG_EQUAL note with an
expression based on the reversed biv. To avoid this case,
remove all REG_EQUAL notes based on the reversed biv
here. */
for (p = loop_start; p != loop_end; p = NEXT_INSN (p))
alias.c (mark_constant_function): Use INSN_P. * alias.c (mark_constant_function): Use INSN_P. (init_alias_analysis): Likewise. * combine.c (combine_instructions): Use INSN_P. (can_combine_p): Likewise. (try_combine): Likewise. (distribute_notes): Likewise. (distribute_links): Likewise. * cse.c (cse_around_loop): Use INSN_P. (invalidate_skipped_block): Likewise. (cse_set_around_loop): Likewise. (cse_end_of_basic_block): Likewise. (delete_trivially_dead_insns): Likewise. * emit-rtl.c (unshare_all_rtl_again): Use INSN_P. (unshare_all_rtl_1): Likewise. (next_cc0_user): Likewise. (try_split make_insn_raw): Likewise. (remove_unnecessary_notes): Likewise. * final.c (shorten_branches): Use INSN_P. (leaf_renumber_regs): Likewise. (leaf_renumber_regs_insn): Likewise. * flow.c (find_label_refs): Use INSN_P. (verify_wide_reg): Likewise. (notice_stack_pointer_modification): Likewise. (count_or_remove_death_notes): Likewise. (verify_flow_info): Likewise. (clear_log_links): Likewise. * function.c (fixup_var_refs_insns): Use INSN_P. (compute_insns_for_mem): Likewise. * gcse.c (alloc_gcse_mem): Use INSN_P. (compute_sets): Likewise. (compute_hash_table): Likewise. (classic_gcse): Likewise. (cprop): Likewise. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks_1): Likewise. * global.c (expand_preferences): Use INSN_P. (build_insn_chain): Likewise. * graph.c (node_data): Use INSN_P. * haifa-sched.c (priority): Use INSN_P. (rm_line_notes): Likewise. (rm_other_notes): Likewise. (find_insn_reg_weight): Likewise. (init_target_units): Likewise. (schedule_block): Likewise. (compute_block_forward_dependences): Likewise. (debug_dependencies): Likewise. (set_priorities): Likewise. * integrate.c (function_cannot_inline_p): Use INSN_P. (save_parm_insns): Likewise. (copy_insn_list): Likewise. * jump.c (mark_all_labels): Use INSN_P. (never_reached_warning): Likewise. * lcm.c (optimize_mode_switching): Use INSN_P. * local-alloc.c (validate_equiv_mem): Use INSN_P. (memref_used_between_p): Likewise. (update_equiv_regs): Likewise. (block_alloc): Likewise. (no_conflict_p): Likewise. * loop.c (scan_loop): Use INSN_P. (find_and_verify_loops): Likewise. (count_loop_regs_set): Likewise. (loop_reg_used_before_p): Likewise. (strength_reduce): Likewise. (recombine_givs): Likewise. (check_dbra_loop): Likewise. (load_mems): Likewise. (try_copy_prop): Likewise. * print-rtl.c (print_rtx): Use INSN_P. * recog.c (find_single_use): Use INSN_P. * reg-stack.c (stack_regs_mentioned): Use INSN_P. (next_flags_user): Likewise. (swap_rtx_condition): Likewise. * regmove.c (mark_flags_life_zones): Use INSN_P. (optimize_reg_copy_1): Likewise. (optimize_reg_copy_2): Likewise. (optimize_reg_copy_3): Likewise. (reg_is_remote_constant_p): Likewise. (fixup_match_2): Likewise. (regmove_optimize): Likewise. (fixup_match_1): Likewise. * regrename.c (build_def_use): Use INSN_P. (replace_reg_in_block): Likewise. (consider_use): Likewise. * reload.c (find_equiv_reg): Use INSN_P. * reload1.c (reload): Use INSN_P. (maybe_fix_stack_asms): Likewise. (calculate_needs_all_insns): Likewise. (reload_as_needed): Likewise. (emit_output_reload_insns): Likewise. (delete_address_reloads_1): Likewise. (reload_cse_regs_1): Likewise. (reload_combine): Likewise. (reload_cse_move2add): Likewise. * reorg.c (redundant_insn): Use INSN_P. (dbr_schedule): Likewise. * resource.c (find_dead_or_set_registers): Use INSN_P. (mark_target_live_regs): Likewise. * rtlanal.c (reg_used_between_p): Use INSN_P. (reg_referenced_between_p): Likewise. (reg_set_between_p): Likewise. (reg_set_p): Likewise. (single_set): Likewise. (multiple_sets): Likewise. (find_last_value): Likewise. (reg_set_last): Likewise. (find_reg_note): Likewise. (find_regno_note): Likewise. * sibcall.c (sequence_uses_addressof): Use INSN_P. * simplify-rtx.c (cselib_process_insn): Use INSN_P. * ssa.c (find_evaluations): Use INSN_P. (rename_block): Likewise. (rename_equivalent_regs): Likewise. * unroll.c (loop_find_equiv_value): Use INSN_P. (set_dominates_use): Likewise. * varasm.c (mark_constant_pool): Use INSN_P. (mark_constants): Likewise. * config/alpha/alpha.c (alpha_does_function_need_gp): Use INSN_P. (alphaev4_next_group): Likewise. (alphaev5_next_group): Likewise. * config/c4x/c4x.c (c4x_process_after_reload): Use INSN_P. (c4x_rptb_rpts_p): Likewise. * config/mips/mips.c (mips16_optimize_gp): Use INSN_P. * config/rs6000/rs6000.c (uses_TOC): Use INSN_P. (rs6000_adjust_priority): Likewise. * config/sh/sh.c (sh_loop_align): Use INSN_P. (machine_dependent_reorg): Likewise. (split_branches): Likewise. * config/tahoe/tahoe.c (tahoe_cmp_check): Use INSN_P. From-SVN: r35494
2000-08-04 22:28:08 +02:00
if (INSN_P (p))
{
rtx *pnote;
rtx set = single_set (p);
/* If this is a set of a GIV based on the reversed biv, any
REG_EQUAL notes should still be correct. */
if (! set
|| GET_CODE (SET_DEST (set)) != REG
|| (size_t) REGNO (SET_DEST (set)) >= ivs->reg_iv_type->num_elements
|| REG_IV_TYPE (ivs, REGNO (SET_DEST (set))) != GENERAL_INDUCT
|| REG_IV_INFO (ivs, REGNO (SET_DEST (set)))->src_reg != bl->biv->src_reg)
for (pnote = &REG_NOTES (p); *pnote;)
{
if (REG_NOTE_KIND (*pnote) == REG_EQUAL
&& reg_mentioned_p (regno_reg_rtx[bl->regno],
XEXP (*pnote, 0)))
*pnote = XEXP (*pnote, 1);
else
pnote = &XEXP (*pnote, 1);
}
}
1992-02-01 09:24:22 +01:00
/* Mark that this biv has been reversed. Each giv which depends
on this biv, and which is also live past the end of the loop
will have to be fixed up. */
bl->reversed = 1;
if (loop_dump_stream)
{
fprintf (loop_dump_stream, "Reversed loop");
if (bl->nonneg)
fprintf (loop_dump_stream, " and added reg_nonneg\n");
else
fprintf (loop_dump_stream, "\n");
}
1992-02-01 09:24:22 +01:00
return 1;
}
}
}
return 0;
}
/* Verify whether the biv BL appears to be eliminable,
based on the insns in the loop that refer to it.
If ELIMINATE_P is non-zero, actually do the elimination.
THRESHOLD and INSN_COUNT are from loop_optimize and are used to
determine whether invariant insns should be placed inside or at the
start of the loop. */
static int
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
maybe_eliminate_biv (loop, bl, eliminate_p, threshold, insn_count)
const struct loop *loop;
1992-02-01 09:24:22 +01:00
struct iv_class *bl;
int eliminate_p;
int threshold, insn_count;
{
struct loop_ivs *ivs = LOOP_IVS (loop);
1992-02-01 09:24:22 +01:00
rtx reg = bl->biv->dest_reg;
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
rtx loop_start = loop->start;
rtx loop_end = loop->end;
rtx p;
1992-02-01 09:24:22 +01:00
/* Scan all insns in the loop, stopping if we find one that uses the
biv in a way that we cannot eliminate. */
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (p = loop_start; p != loop_end; p = NEXT_INSN (p))
1992-02-01 09:24:22 +01:00
{
enum rtx_code code = GET_CODE (p);
rtx where = threshold >= insn_count ? loop_start : p;
/* If this is a libcall that sets a giv, skip ahead to its end. */
if (GET_RTX_CLASS (code) == 'i')
{
rtx note = find_reg_note (p, REG_LIBCALL, NULL_RTX);
if (note)
{
rtx last = XEXP (note, 0);
rtx set = single_set (last);
if (set && GET_CODE (SET_DEST (set)) == REG)
{
* Rework fields used to describe positions of bitfields and modify sizes to be unsigned and use HOST_WIDE_INT. * alias.c (reg_known_value_size): Now unsigned. * c-typeck.c (build_unary_op, case ADDR_EXPR): Use byte_position. (really_start_incremental_init): Use bitsize_zero_node. (push_init_level, pop_init_level, output_init_element): Likewise. Use bitsize_unit_node and bitsize_one_node. (output_pending_init_elements, process_init_element): Likewise. * combine.c (combine_max_regno, reg_sign_bit_copies): Now unsigned. (make_extraction): Position and length HOST_WIDE_INT and unsigned HOST_WIDE_INT, respectively. (get_pos_from_mask): Passed in value is unsigned HOST_WIDE_INT. (num_sign_bit_copies): Returns unsigned. BITWIDTH now unsigned; rework arithmetic. Remove recursive call from arg to MAX. (combine_instructions, init_reg_last_arrays): NREGS now unsigned. (setup_incoming_promotions, can_combine_p, try_combine, simplify_set): REGNO now unsigned. (set_nonzero_bit_and_sign_copies): NUM now unsigned. (find_split_point, expand_compound_operation, make_extraction): LEN now unsigned HOST_WIDE_INT, POS now HOST_WIDE_INT. (make_field_assignment): Likewise. (combine_simplify_rtx): Add cast. (expand_compound_operation): MODEWIDTH now unsigned; rework arithmetic. (force_to_mode): WIDTH now unsigned; add cast. (if_then_else_cond): SIZE now unsigned. (nonzero_bits): MODE_WIDTH, RESULT_WIDTH, and WIDTH now unsigned. (extended_count): Now returns unsigned. (simplify_shift_const): COUNT unsigned; arg is now INPUT_COUNT. Add SIGNED_COUNT variable; MODE_WORDS and FIRST_COUNT now unsigned. (simplify_comparison): MODE_WIDTH now unsigned. (update_table_tick): REGNO and ENDREGNO now unsigned; new var R. (mark_used_regs_combine): Likewise; rework arithmetic. (record_value_for_reg): REGNO, ENDREGNO, and I now unsigned. (record_dead_and_set_regs, reg_dead_at_p, distribute_notes): Likewise. (record_promoted_value): REGNO now unsigned. (get_last_value_validate): REGNO, ENDREGNO, and J now unsigned. (get_last_value): REGNO now unsigned. (use_crosses_set_p): REGNO and ENDREGNO now unsigned. (reg_dead_regno, reg_dead_endregno): Now unsigned. (remove_death): Arg REGNO now unsigned. (move_deaths): REGNO, DEADREGNO, DEADEND, OUREND, and I now unsigned. (reg_bitfield_target_p): REGNO, REGNO, ENDREGNO, and ENDTREGNO now unsigned. * convert.c (convert_to_integer): INPREC and OUTPREC now unsigned. * cse.c (struct qty_table_elem): FIRST_REG and LAST_REG now unsigned. (struct cse_reg_info): REGNO now unsigned. (cached_regno): Now unsigned. (REGNO_QTY_VALID_P): Add cast. (make_new_qty, make_regs_eqv, delete_reg_eqiv): Regno args unsigned. (remove_invalid_regs): Likewise. (remove_invalid_subreg_refs): Likewise; arg WORD also unsigned as are variables END and I. (get_cse_reg_info, insert): Likewise. (mention_regs, invalidate_for_call): REGNO, ENDREGNO, and I unsigned. (canon_hash): Likewise. (insert_regs, lookup_for_remove): REGNO now unsigned. (invalidate): REGNO, ENDREGNO, TREGNO, and TENDREGNO now unsigned. New variable RN. * dbxout.c (dbxout_parms, dbxout_reg_parms): Don't check for REGNO < 0. * dwarf2out.c (dwarf2ou_frame_debug_expr): Remove cast. * emit-rtl.c (subreg_realpart_p): Add cast. (operand_subword): Arg I is now unsigned as is var PARTWORDS. (operand_subword_force): Arg I is now unsigned. * except.c (eh_regs): Variable I is now unsigned. * explow.c (hard_function_value): BYTES is unsigned HOST_WIDE_INT. * expmed.c (store_fixed_bit_field): Position is HOST_WIDE_INT; length is unsigned HOST_WIDE_INT; likewise for internal variables. (store_split_bit_field, extract_fixed_bit_field): Likewise. (extract_split_bit_field, store_bit_field, extract_bit_field): Likewise. * expr.c (store_constructor_fields, store_constructor, store_field): Positions are HOST_WIDE_INT and lengths are unsigned HOST_WIDE_INT. (expand_assignment, expand_expr, expand_expr_unaligned): Likewise. (do_jump): Likewise. (move_by_pieces, move_by_pieces_ninsns, clear_by_pieces): MAX_SIZE is now unsigned. (emit_group_load): BYTEPOS is HOST_WIDE_INT; BYTELEN is unsigned. (emit_group_store): Likewise. (emit_move_insn): I now unsigned. (store_constructor): Use host_integerp, tree_low_cst, and bitsize_unit_node. (get_inner_reference): Return bitpos and bitsize as HOST_WIDE_INT. Rework all calculations to use trees and new fields. * expr.h (promoted_input_arg): Regno now unsigned. (store_bit_field, extract_bit_field): Adjust types of pos and size. (mark_seen_cases): Arg is HOST_WIDE_INT. * flow.c (verify_wide_reg_1): REGNO now unsigned. * fold-const.c (decode_field_reference): Size and pos HOST_WIDE_INT; precisions and alignments are unsigned. (optimize_bit_field_compare, fold_truthop): Likewise. (int_const_binop): Adjust threshold for size_int_type_wide call. (fold_convert): Likewise. (size_int_type_wide): Make table larger and fix thinko that only had half of table used. (all_ones_mask_p, fold): Precisions are unsigned. * function.c (put_reg_info_stack): REGNO is unsigned. (instantiate_decl): Size is HOST_WIDE_INT. (instantiate_virtual_regs): I is unsigned. (assign_parms): REGNO, REGNOI, and REGNOR are unsigned. (promoted_input_arg): REGNO is unsigned. * function.h (struct function): x_max_parm_reg is now unsigned. * gcse.c (max_gcse_regno): Now unsigned. (struct null_pointer_info): min_reg and max_reg now unsigned. (lookup_set, next_set): REGNO arg now unsigned. (compute_hash_table): REGNO and I now unsigned. (handle_avail_expr): regnum_for_replacing now unsigned. (cprop_insn): REGNO now unsigned. (delete_null_pointer_checks_1): BLOCK_REG now pointer to unsigned. * ggc-common.c (ggc_mark_tree_children, case FIELD_DECL): New case. * global.c (set_preference): SRC_REGNO, DEST_REGNO, and I now unsigned. * hard-reg-set.h (reg_class_size): Now unsigned. * integrate.c (mark_stores): LAST_REG and I now unsigned; new UREGNO. * jump.c (mark_modified_reg): I now unsigned; add cast. (rtx_equal_for_thread_p): Add cast. * loop.c (max_reg_before_loop): Now unsigned. (struct_movable): REGNO now unsigned. (try_copy_prop): REGNO arg unsigned. (regs_match_p): XN and YN now unsigned. (consec_sets_invariant_p, maybe_eliminate_biv): REGNO now unsigned. (strength_reduce): Likewise; NREGS also unsigned. (first_increment_giv, last_increment_giv unsigned): Now unsigned. * loop.h (struct iv_class): REGNO now unsigned. (max_reg_before_loop, first_increment_giv, last_increment_giv): Now unsigned. * machmode.h (mode_size, mode_unit_size): Now unsigned. (mode_for_size, smallest_mode_for_size): Pass size as unsigned. * optabs.c (expand_binop): I and NWORDS now unsigned. (expand_unop): I now unsigned. * print-tree.c (print_node): Don't print DECL_FIELD_BITPOS, but do print DECL_FIELD_OFFSET and DECL_FIELD_BIT_OFFSET. * real.c (significand_size): Now returns unsigned. * real.h (significand_size): Likewise. * regclass.c (reg_class_size): Now unsigned. (choose_hard_reg_mode): Both operands now unsigned. (record_reg_classes): REGNO and NR now unsigned. (reg_scan): NREGS now unsigned. (reg_scan_update): old_max_regno now unsigned. (reg_scan_mark_refs): Arg MIN_REGNO and var REGNO now unsigned. * reload.c (find_valid_class): BEST_SIZE now unsigned. (find_dummy_reload): REGNO, NWORDS, and I now unsigned. (hard_reg_set_here_p): Args BEG_REGNO and END_REGNO now unsigned. Likewise for variable R. (refers_to_regno_for_reload_p): Args REGNO and END_REGNO now unsigned, as are variables INNER_REGNO and INNER_ENDREGNO; add new variable R. (find_equiv_reg): Add casts. (regno_clobbered_p): Arg REGNO now unsigned. * reload.h (struct reload): NREGS now unsigned. (refers_to_regno_for_reload_p): Regno args are unsigned. (regno_clobbered_p): Likewise. * reload1.c (reg_max_ref_width, spill_stack_slot_width): Now unsigned. (compute_use_by_pseudos): REGNO now unsigned. (find_reg): I and J now unsigned, new variable K, and change loop variables accordingly; THIS_NREGS now unsigned. (alter_reg): INHERENT_SIZE and TOTAL_SIZE now unsigned. (spill_hard_reg): REGNO arg now unsigned; add casts. (forget_old_reloads_1): REGNO, NR, and I now unsigned. (mark_reload_reg_in_use): Arg REGNO and vars NREGS and I now unsigned. (clear_reload_reg_in_use): Arg REGNO and vars NREGS, START_REGNO, END_REGNO, CONFLICT_START, and CONFLICT_END now unsigned. (reload_reg_free_p, reload_reg_reaches_end_p): Arg REGNO now unsigned. (choose_reload_regs): MAX_GROUP_SIZE now unsigned. (emit_reload_insns): REGNO now unsigned. (reload_cse_move2add): Add cast. (move2add_note_store): REGNO and I now unsigned; new variable ENDREGNO and rework loop. * resource.c (mark_referenced_resources, mark_set_resources): New variable R; REGNO and LAST_REGNO now unsigned. (mark_target_live_regs): J and REGNO now unsigned. * rtl.c (mode_size, mode_unit_size): Now unsigned. * rtl.h (union rtunion_def): New field rtuint. (XCUINT): New macro. (ADDRESSOF_REGNO, REGNO, SUBREG_WORD): New XCUINT. (operand_subword, operand_subword_force): Word number is unsigned. (choose_hard_reg_mode): Operands are unsigned. (refers_to-regno_p, dead_or_set_regno_p): Regno arg is unsigned. (find_regno_note, find_regno_fusage, replace_regs): Likewise. (regno_use_in, combine_instructions, remove_death): Likewise. (reg_scan, reg_scan_update): Likewise. (extended_count): Return is unsigned. * rtlanal.c (refers_to_regno_p): Args REGNO and ENDREGNO and vars I, INNER_REGNO, and INNER_ENDREGNO now unsigned; new variable X_REGNO. (reg_overlap_mentioned_p): REGNO and ENDREGNO now unsigned. (reg_set_last_first_regno, reg_set_last_last_regno): Now unsigned. (reg_reg_last_1): FIRS and LAST now unsigned. (dead_or_set_p): REGNO, LAST_REGNO, and I now unsigned. (dead_or_set_regno_p): Arg TEST_REGNO and vars REGNO and ENDREGNO now unsigned. (find_regno_note, regno_use_in): Arg REGNO now unsigned. (find_regno_fusage): Likewise; also var REGNOTE now unsigned. (find_reg_fusage): Variables REGNO, END_REGNO, and I now unsigned. (replace_regs): Arg NREGS now unsigned. * sdbout.c (sdbout_parms, sdbout_reg_parms): Don't check REGNO < 0. * simplify-rtx.c (simplify_unary_operation): WIDTH now unsigned. (simplify_binary_operation): Likewise. (cselib_invalidate_regno): Arg REGNO and variables ENDREGNO, I, and THIS_LAST now unsigned. (cselib_record_set): Add cast. * ssa.c (ssa_max_reg_num): Now unsigned. (rename_block): REGNO now unsigned. * stmt.c (expand_return): Bit positions unsigned HOST_WIDE_INT; sizes now unsigned. (all_cases_count): Just return -1 not -2. COUNT, MINVAL, and LASTVAL now HOST_WIDE_INT. Rework tests to use trees whenever possible. Use host_integerp and tree_low_cst. (mark_seen_cases): COUNT arg now HOST_WIDE_INT; Likewise variable NEXT_NODE_OFFSET; XLO now unsigned. (check_for_full_enumeration_handing): BYTES_NEEDED, I to HOST_WIDE_INT. * stor-layout.c (mode_for_size): SIZE arg now unsigned. (smallest_mode_for_size): Likewise. (layout_decl): Simplify handing of a specified DECL_SIZE_UNIT. KNOWN_ALIGN is now an alignment, so simplify code. Don't turn off DECL_BIT_FIELD if field is BLKmode, but not type. (start_record_layout): Renamed from new_record_layout_info. Update to new fields. (debug_rli, normalize_rli, rli_size_unit_so_far, rli_size_so_far): New functions. (place_union_field): Renamed from layout_union_field. Update to use new fields in rli. (place_field): Renamed from layout_field. Major rewrite to use new fields in rli; pass alignment to layout_decl. (finalize_record_size): Rework to use new fields in rli and handle union. (compute_record_mode): Rework to simplify and to use new DECL fields. (finalize_type_size): Make rounding more consistent. (finish_union_layout): Deleted. (layout_type, case VOID_TYPE): Don't set TYPE_SIZE_UNIT either. (layout_type, case RECORD_TYPE): Call new function names. (initialize_sizetypes): Set TYPE_IS_SIZETYPE. (set_sizetype): Set TYPE_IS_SIZETYPE earlier. (get_best_mode): UNIT is now unsigned; remove casts. * tree.c (bit_position): Compute from new fields. (byte_position, int_byte_position): New functions. (print_type_hash_statistics): Cast to remove warning. (build_range_type): Use host_integerp and tree_low_cst to try to hash. (build_index_type): Likewise; make subtype of sizetype. (build_index_2_type): Pass sizetype to build_range_type. (build_common_tree_nodes): Use size_int and bitsize_int to initialize nodes; add bitsize_{zero,one,unit}_node. * tree.h (DECL_FIELD_CONTEXT): Use FIELD_DECL_CHECK. (DECL_BIT_FIELD_TYPE, DECL_QUALIFIER, DECL_FCONTEXT): Likewise. (DECL_PACKED, DECL_BIT_FIELD): Likewise. (DECL_FIELD_BITPOS): Deleted. (DECL_FIELD_OFFSET, DECL_FIELD_BIT_OFFSET): New fields. (DECL_RESULT, DECL_SAVED_INSNS): Use FUNCTION_DECL_CHECK. (DECL_FRAME_SIZE, DECL_FUNCTION_CODE, DECL_NO_STATIC_CHAIN): Likewise. (DECL_INLINE, DECL_BUILT_IN_NONANSI, DECL_IS_MALLOC): Likewise. (DECL_BUILT_IN_CLASS, DECL_STATIC_CONSTRUCTOR): Likewise. (DECL_STATIC_DESTRUCTOR, DECL_NO_CHECK_MEMORY_USAGE): Likewise. (DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT, DECL_NO_LIMIT_STACK) Likewise. (DECL_ORIGINAL_TYPE, TYPE_DECL_SUPPRESS_DEBUG): Use TYPE_DECL_CHECK. (DECL_ARG_TYPE_AS_WRITEN, DECL_ARG_TYPE): Use PARM_DECL_CHECK. (DECL_INCOMING_RTL, DECL_TRANSPARENT_UNION): Likewise. (DECL_ALIGN): Adjust to new field in union. (DECL_OFFSET_ALIGN): New field. (DECL_ERROR_ISSUED, DECL_TOO_LATE): Use LABEL_DECL_CHECK. (DECL_IN_TEXT_SECTION): Use VAR_DECL_CHECK. (union tree_decl): Add struct for both aligns. (enum tree_index): Add TI_BITSIZE_{ZERO,ONE,UNIT}. (bitsize_zero_node, bitsize_one_node, bitsize_unit_node): Added. (struct record_layout_info): Rework fields to have offset alignment and byte and bit position. (start_record_layout, place_field): Renamed from old names. (rli_size_so_far, rli_size_unit_so_far, normalize_rli): New decls. (byte_position, int_byte_position): Likewise. (get_inner_reference): Change types of position and length. * unroll.c (unroll_loop): New variable R; use for some loops. MAX_LOCAL_REGNUM and MAXREGNUM now unsigned. (calculate_giv_inc): Arg REGNO now unsigned. (copy_loop_body): REGNO and SRC_REGNO now unsigned. * varasm.c (assemble_variable): Clean up handling of size using host_integerp and tree_low_cst. (decode_addr_const): Use byte, not bit, position. (output_constructor): bitpos and offsets are HOST_WIDE_INT; use tree_low_cst and int_bit_position. * objc/objc-act.c (build_ivar_list_initializer): Use byte_position. * ch/actions.c (check_missing_cases): BYTES_NEEDED is HOST_WIDE_INT. * ch/typeck.c (expand_constant_to_buffer): Use int_byte_position. (extract_constant_from_buffer): Likewise. * cp/class.c (build_vbase_pointer_fields): layout_field now place_field. (get_vfield_offset): Use byte_position. (set_rtti_entry): Set OFFSET to ssizetype zero. (get_binfo_offset_as_int): Deleted. (dfs_record_base_offsets): Use tree_low_cst. (dfs_search_base_offsets): Likewise. (layout_nonempty_base_or_field): Reflect changes in RLI format and call byte_position. (layout_empty_base): Convert offset to ssizetype. (build_base_field): use rli_size_unit_so_far. (dfs_propagate_binfo_offsets): Do computation in proper type. (layout_virtual_bases): Pass ssizetype to propagate_binfo_offsets. (layout_class_type): Reflect changes in RLI names and fields. (finish_struct_1): Set DECL_FIELD_OFFSET. * cp/dump.c (dequeue_and_dump): Call bit_position. * cp/expr.c (cplus_expand_constant): Use byte_position. * cp/rtti.c (expand_class_desc): Use bitsize_one_node. * cp/typeck.c (build_component_addr): Use byte_position and don't special case for zero offset. * f/com.c (ffecom_tree_canonize_ptr_): Use bitsize_zero_node. (ffecom_tree_canonize_ref_): Likewise. * java/class.c (make_field_value): Use byte_position. * java/expr.c (JAVA_ARRAY_LENGTH_OFFSET): Use byte_position. (java_array_data_offset): Likewise. * java/java-tree.h (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Add case to bzero call. From-SVN: r32742
2000-03-25 19:34:13 +01:00
unsigned int regno = REGNO (SET_DEST (set));
if (regno < max_reg_before_loop
&& REG_IV_TYPE (ivs, regno) == GENERAL_INDUCT
&& REG_IV_INFO (ivs, regno)->src_reg == bl->biv->src_reg)
p = last;
}
}
}
1992-02-01 09:24:22 +01:00
if ((code == INSN || code == JUMP_INSN || code == CALL_INSN)
&& reg_mentioned_p (reg, PATTERN (p))
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
&& ! maybe_eliminate_biv_1 (loop, PATTERN (p), p, bl,
eliminate_p, where))
1992-02-01 09:24:22 +01:00
{
if (loop_dump_stream)
fprintf (loop_dump_stream,
"Cannot eliminate biv %d: biv used in insn %d.\n",
bl->regno, INSN_UID (p));
break;
}
}
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
if (p == loop_end)
1992-02-01 09:24:22 +01:00
{
if (loop_dump_stream)
fprintf (loop_dump_stream, "biv %d %s eliminated.\n",
bl->regno, eliminate_p ? "was" : "can be");
return 1;
}
return 0;
}
/* INSN and REFERENCE are instructions in the same insn chain.
Return non-zero if INSN is first. */
int
loop_insn_first_p (insn, reference)
rtx insn, reference;
{
rtx p, q;
for (p = insn, q = reference;;)
{
/* Start with test for not first so that INSN == REFERENCE yields not
first. */
if (q == insn || ! p)
return 0;
if (p == reference || ! q)
return 1;
/* Either of P or Q might be a NOTE. Notes have the same LUID as the
previous insn, hence the <= comparison below does not work if
P is a note. */
if (INSN_UID (p) < max_uid_for_loop
&& INSN_UID (q) < max_uid_for_loop
&& GET_CODE (p) != NOTE)
return INSN_LUID (p) <= INSN_LUID (q);
if (INSN_UID (p) >= max_uid_for_loop
|| GET_CODE (p) == NOTE)
p = NEXT_INSN (p);
if (INSN_UID (q) >= max_uid_for_loop)
q = NEXT_INSN (q);
}
}
/* We are trying to eliminate BIV in INSN using GIV. Return non-zero if
the offset that we have to take into account due to auto-increment /
div derivation is zero. */
static int
biv_elimination_giv_has_0_offset (biv, giv, insn)
struct induction *biv, *giv;
rtx insn;
{
/* If the giv V had the auto-inc address optimization applied
to it, and INSN occurs between the giv insn and the biv
insn, then we'd have to adjust the value used here.
This is rare, so we don't bother to make this possible. */
if (giv->auto_inc_opt
&& ((loop_insn_first_p (giv->insn, insn)
&& loop_insn_first_p (insn, biv->insn))
|| (loop_insn_first_p (biv->insn, insn)
&& loop_insn_first_p (insn, giv->insn))))
return 0;
return 1;
}
1992-02-01 09:24:22 +01:00
/* If BL appears in X (part of the pattern of INSN), see if we can
eliminate its use. If so, return 1. If not, return 0.
If BIV does not appear in X, return 1.
If ELIMINATE_P is non-zero, actually do the elimination. WHERE indicates
where extra insns should be added. Depending on how many items have been
moved out of the loop, it will either be before INSN or at the start of
the loop. */
static int
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
maybe_eliminate_biv_1 (loop, x, insn, bl, eliminate_p, where)
const struct loop *loop;
1992-02-01 09:24:22 +01:00
rtx x, insn;
struct iv_class *bl;
int eliminate_p;
rtx where;
{
enum rtx_code code = GET_CODE (x);
rtx reg = bl->biv->dest_reg;
enum machine_mode mode = GET_MODE (reg);
struct induction *v;
Fix warious warnings: * c-aux-info.c: Include string.h/strings.h. * pa.c: Include stdlib.h. (pa_combine_instructions): Prototype the function. (pa_can_combine_p, forward_branch_p, shadd_constant_p): Likewise. (reloc_needed): Add default case for enumeration switch. (remove_useless_addtr_insns): Remove unused variable `all'. (hppa_expand_prologue): Add explicit braces to avoid ambiguous `else'. (output_function_epilogue): Remove unused variable `i'. (output_millicode_call): Remove unused variable `link'. (shadd_constant_p, forward_branch_p): Make the function static. (following_call): Explicitly declare to return int. (pa_reorg): Declare as void. (pa_combine_instructions): Declare as static void. Add parentheses around && within ||. * pa.h: Add prototypes for pa_reorg, symbolic_operand, following_call, function_label_operand, lhs_lshift_cint_operand and zdepi_cint_p. * pa.md: Add parentheses around && within ||. * cppalloc.c: Include stdlib.h. * cpperror.c (cpp_print_containing_files): Remove unused variable `i'. Fix format specifier in fprintf. * cse.c (cse_around_loop): Add explicit braces to avoid ambiguous `else'. (delete_dead_from_cse): Wrap variable `tem' in macro HAVE_cc0. * expr.c (expand_expr): Add parentheses around && within ||. * final.c (app_enable): Replace fprintf with fputs where there are no format specifiers and no trailing argument after the string. Eg, when printing ASM_APP_ON/ASM_APP_OFF. (app_disable): Likewise. (final_end_function): Likewise. (final_scan_insn): Likewise. Remove unused variable `set'. (profile_function): Wrap empty if-statement body in {} brackets. * function.c: Include stdlib.h. (pad_below): Wrap prototype and definition in ARGS_GROW_DOWNWARD. (reposition_prologue_and_epilogue_notes): Add parentheses around assignment used as truth value. * integrate.c (expand_inline_function): Wrap variable `cc0_insn' in macro HAVE_cc0. * jump.c (jump_optimize): Wrap variable `q' in macro HAVE_cc0. Remove unused variable `prev1'. * libgcc2.c (__bb_exit_trace_func): Add parentheses around && within ||. Fix format specifier in fprintf. (__bb_init_prg): Add parentheses around assignment used as truth value. * local-alloc.c: Include stdlib.h. (requires_inout): Add parentheses around assignment used as truth value. * loop.c (analyze_loop_iterations): Wrap prototype and definition in macro HAVE_decrement_and_branch_on_count. (insert_bct, instrument_loop_bct): Likewise. (move_movables): Add parentheses around assignment used as truth value. (consec_sets_invariant_p): Likewise. (maybe_eliminate_biv_1): Wrap variable `new' in macro HAVE_cc0. * objc/objc-act.c: Include stdlib.h. (lookup_method_in_protocol_list): Wrap empty else-statement body in braces. (lookup_protocol_in_reflist): Likewise. (objc_add_static_instance): Remove unused variables `decl_expr' and `decl_spec'. (get_objc_string_decl): Remove unused variable `decl'. (generate_static_references): Remove unused variables `idecl' and `instance'. (check_protocols): Wrap empty else-statement body in braces. * protoize.c: Include stdlib.h. (substr): Add parentheses around assignment used as truth value. (abspath): Likewise. (shortpath): Likewise. * regmove.c (fixup_match_1): Add parentheses around assignment used as truth value. * reload.c (push_secondary_reload): Remove unused variable `i'. (find_reloads): Add parentheses around assignment used as truth value. * reload1.c: Include stdlib.h. * rtl.h: Correct typo in prototype of offsettable_memref_p. * stmt.c (add_case_node): Add parentheses around assignment used as truth value. (case_tree2list): Likewise. * tree.c (valid_machine_attribute): Wrap variable `decl_attr_list' in macro VALID_MACHINE_DECL_ATTRIBUTE. Wrap variable `type_attr_list' in macro VALID_MACHINE_TYPE_ATTRIBUTE. (merge_attributes): Add explicit braces to avoid ambiguous `else'. * unroll.c (copy_loop_body): Wrap variable `cc0_insn' in macro HAVE_cc0. * varasm.c: Include stdlib.h. From-SVN: r18290
1998-02-28 08:06:53 +01:00
rtx arg, tem;
#ifdef HAVE_cc0
rtx new;
#endif
1992-02-01 09:24:22 +01:00
int arg_operand;
rtl.h (rtx_format): Constify a char*. * rtl.h (rtx_format): Constify a char*. * rtl.c (rtx_format): Likewise. (copy_rtx, copy_most_rtx, read_rtx): Likewise. (init_rtl): Use accessor macro, not `rtx_format'. * alias.c (rtx_equal_for_memref_p, find_symbolic_term): Constify a char*. * caller-save.c (mark_referenced_regs): Likewise. * combine.c (subst, make_compound_operation, known_cond, gen_rtx_combine, update_table_tick, get_last_value_validate, use_crosses_set_p, mark_used_regs_combine, move_deaths): Likewise. * cse.c (rtx_cost, mention_regs, canon_hash, exp_equiv_p, refers_to_p, canon_reg, fold_rtx, cse_process_notes, count_reg_usage): Likewise. * emit-rtl.c (gen_rtx, copy_rtx_if_shared, reset_used_flags): Likewise. * final.c (leaf_renumber_regs_insn): Likewise. * flow.c (mark_used_regs, find_use_as_address, dump_flow_info, dump_edge_info, count_reg_references): Likewise. * function.c (fixup_var_refs_1, walk_fixup_memory_subreg, fixup_stack_1, purge_addressof_1, instantiate_virtual_regs_1): Likewise. * gcse.c (oprs_unchanged_p, hash_expr_1, expr_equiv_p, oprs_not_set_p, expr_killed_p, compute_transp, find_used_regs, add_label_notes): Likewise. * genattrtab.c (attr_rtx, attr_copy_rtx, encode_units_mask, clear_struct_flag, count_sub_rtxs, count_alternatives, compares_alternatives_p, contained_in_p, walk_attr_value, write_expr_attr_cache): Likewise. * genconfig.c (walk_insn_part): Likewise. * genemit.c (max_operand_1, gen_exp): Likewise. * genextract.c (walk_rtx): Likewise. * genflags.c (num_operands): Likewise. * genoutput.c (scan_operands): Likewise. * genpeep.c (match_rtx): Likewise. * genrecog.c (add_to_sequence): Likewise. * haifa-sched.c (may_trap_exp, sched_analyze_2, attach_deaths): Likewise. * integrate.c (save_constants, copy_for_inline, copy_rtx_and_substitute, subst_constants, restore_constants): Likewise. * jump.c (mark_jump_label, invert_exp, redirect_exp, rtx_renumbered_equal_p, rtx_equal_for_thread_p): Likewise. * local-alloc.c (contains_replace_regs, memref_referenced_p): Likewise. * loop.c (record_excess_regs, rtx_equal_for_loop_p, add_label_notes, replace_call_address, count_nonfixed_reads, invariant_p, find_single_use_in_loop, find_mem_givs, find_life_end, maybe_eliminate_biv_1, update_reg_last_use): Likewise. * print-rtl.c (reg_names, print_rtx): Likewise. * recog.c (validate_replace_rtx_1, find_single_use_1): Likewise. * reg-stack.c (stack_regs_mentioned_p, record_label_references, record_reg_life_pat, swap_rtx_condition, goto_block_pat, print_blocks): Likewise. * regclass.c (fix_register, record_address_regs, reg_scan_mark_refs): Likewise. * regmove.c (stable_but_for_p): Likewise. * reload.c (loc_mentioned_in_p, operands_match_p, find_reloads_toplevsubst_reg_equivs, find_reloads_address_1, copy_replacements, refers_to_regno_for_reload_p, refers_to_mem_for_reload_p, find_inc_amount, regno_clobbered_p, reload_when_needed_name, reg_class_names, debug_reload_to_stream): Likewise. * reload1.c (eliminate_regs, scan_paradoxical_subregs, delete_address_reloads_1, count_occurrences, reload_cse_mem_conflict_p, reload_combine_note_use, add_auto_inc_notes): Likewise. * resource.c (mark_referenced_resources, mark_set_resources): Likewise. * rtlanal.c (rtx_unstable_p, rtx_varies_p, rtx_addr_varies_p, reg_mentioned_p, regs_set_between_p, modified_between_p, modified_in_p, refers_to_regno_p, reg_overlap_mentioned_p, rtx_equal_p, volatile_insn_p, volatile_refs_p, side_effects_p, may_trap_p, inequality_comparisons_p, replace_rtx, replace_regs, jmp_uses_reg_or_mem, for_each_rtx, regno_use_in): Likewise. * sched.c (sched_analyze_2, attach_deaths): Likewise. * stupid.c (stupid_mark_refs): Likewise. * unroll.c (remap_split_bivs): Likewise. * varasm.c (mark_constants): Likewise. * a29k/a29k.c (uses_local_reg_p): Likewise. * alpha/alpha.c (summarize_insn): Likewise. * arm/arm.c (symbol_mentioned_p, label_mentioned_p, eliminate_lr2ip): Likewise. * arm/thumb.c (symbol_mentioned_p, label_mentioned_p): Likewise. * i386/i386.c (symbolic_reference_mentioned_p, copy_all_rtx, reg_mentioned_in_mem): Likewise. * ns32k/ns32k.c (global_symbolic_reference_mentioned_p, symbolic_reference_mentioned_p): Likewise. * romp/romp.c (unsigned_comparisons_p, hash_rtx): Likewise. * sh/sh.c (regs_used, mark_use): Likewise. * vax/vax.c (vax_rtx_cost): Likewise. From-SVN: r28784
1999-08-21 01:05:25 +02:00
const char *fmt;
1992-02-01 09:24:22 +01:00
int i, j;
switch (code)
{
case REG:
/* If we haven't already been able to do something with this BIV,
we can't eliminate it. */
if (x == reg)
return 0;
return 1;
case SET:
/* If this sets the BIV, it is not a problem. */
if (SET_DEST (x) == reg)
return 1;
/* If this is an insn that defines a giv, it is also ok because
it will go away when the giv is reduced. */
for (v = bl->giv; v; v = v->next_iv)
if (v->giv_type == DEST_REG && SET_DEST (x) == v->dest_reg)
return 1;
#ifdef HAVE_cc0
if (SET_DEST (x) == cc0_rtx && SET_SRC (x) == reg)
{
/* Can replace with any giv that was reduced and
that has (MULT_VAL != 0) and (ADD_VAL == 0).
Require a constant for MULT_VAL, so we know it's nonzero.
??? We disable this optimization to avoid potential
overflows. */
1992-02-01 09:24:22 +01:00
for (v = bl->giv; v; v = v->next_iv)
if (GET_CODE (v->mult_val) == CONST_INT && v->mult_val != const0_rtx
1992-02-01 09:24:22 +01:00
&& v->add_val == const0_rtx
&& ! v->ignore && ! v->maybe_dead && v->always_computable
&& v->mode == mode
&& 0)
1992-02-01 09:24:22 +01:00
{
if (! biv_elimination_giv_has_0_offset (bl->biv, v, insn))
continue;
1992-02-01 09:24:22 +01:00
if (! eliminate_p)
return 1;
/* If the giv has the opposite direction of change,
then reverse the comparison. */
if (INTVAL (v->mult_val) < 0)
new = gen_rtx_COMPARE (GET_MODE (v->new_reg),
const0_rtx, v->new_reg);
1992-02-01 09:24:22 +01:00
else
new = v->new_reg;
/* We can probably test that giv's reduced reg. */
if (validate_change (insn, &SET_SRC (x), new, 0))
return 1;
}
/* Look for a giv with (MULT_VAL != 0) and (ADD_VAL != 0);
replace test insn with a compare insn (cmp REDUCED_GIV ADD_VAL).
Require a constant for MULT_VAL, so we know it's nonzero.
??? Do this only if ADD_VAL is a pointer to avoid a potential
overflow problem. */
1992-02-01 09:24:22 +01:00
for (v = bl->giv; v; v = v->next_iv)
if (GET_CODE (v->mult_val) == CONST_INT
&& v->mult_val != const0_rtx
&& ! v->ignore && ! v->maybe_dead && v->always_computable
&& v->mode == mode
&& (GET_CODE (v->add_val) == SYMBOL_REF
|| GET_CODE (v->add_val) == LABEL_REF
|| GET_CODE (v->add_val) == CONST
|| (GET_CODE (v->add_val) == REG
function.h (emit_status): Delete member regno_pointer_flag and rename regno_pointer_flag_length to... * function.h (emit_status): Delete member regno_pointer_flag and rename regno_pointer_flag_length to regno_pointer_align_length. Delete define for REGNO_POINTER_FLAG. * integrate.h (inline_remap): Delete member regno_pointer_flag. Add member x_regno_reg_rtx. * rtl.h (rtx_def): Use frame_related bit to indicate register is a pointer in REG expressions. Define REG_POINTER macro. * alias.c (find_base_value, find_base_term): Use REG_POINTER instead of REGNO_POINTER_FLAG. * combine.c (nonzero_bits, num_sign_bit_copies): Likewise. * emit-rtl.c (gen_reg_rtx): Use regno_pointer_align_length instead of regno_pointer_flag_length. Remove code which refers to regno_pointer_flag. (mark_reg_pointer): Use REG_POINTER. (free_emit_status): Remove code which refers to regno_pointer_flag. (init_emit, mark_emit_status): Likewise. * flow.c (dump_flow_info): Likewise. * function.c (preserve_temp_slots): Likewise. * integrate.c (expand_inline_function, copy_rtx_and_substitute): Use x_regno_reg_rtx instead of regno_pointer_flag for function pointer determination in map. * loop.c (strength_reduce, maybe_eliminate_biv_1): Use REG_POINTER. * predict.c (estimate_probability): Likewise. * regclass.c (record_address_regs, reg_scan_mark_refs): Likewise. * unroll.c (unroll_loop): Use x_regno_reg_rtx instead of regno_pointer_flag for function pointer determination in map. * convex.h (RTX_COSTS): Don't test regno_pointer_flag and use REG_POINTER. * pa.c (hppa_legitimize_address, emit_move_sequence, basereg_operand): Use REG_POINTER. (restore_unscaled_index_insn_codes): Revise comment. From-SVN: r37863
2000-11-30 07:31:19 +01:00
&& REG_POINTER (v->add_val))))
1992-02-01 09:24:22 +01:00
{
if (! biv_elimination_giv_has_0_offset (bl->biv, v, insn))
continue;
1992-02-01 09:24:22 +01:00
if (! eliminate_p)
return 1;
/* If the giv has the opposite direction of change,
then reverse the comparison. */
if (INTVAL (v->mult_val) < 0)
new = gen_rtx_COMPARE (VOIDmode, copy_rtx (v->add_val),
v->new_reg);
1992-02-01 09:24:22 +01:00
else
new = gen_rtx_COMPARE (VOIDmode, v->new_reg,
copy_rtx (v->add_val));
1992-02-01 09:24:22 +01:00
/* Replace biv with the giv's reduced register. */
update_reg_last_use (v->add_val, insn);
if (validate_change (insn, &SET_SRC (PATTERN (insn)), new, 0))
return 1;
/* Insn doesn't support that constant or invariant. Copy it
into a register (it will be a loop invariant.) */
tem = gen_reg_rtx (GET_MODE (v->new_reg));
emit_insn_before (gen_move_insn (tem, copy_rtx (v->add_val)),
where);
/* Substitute the new register for its invariant value in
the compare expression. */
XEXP (new, (INTVAL (v->mult_val) < 0) ? 0 : 1) = tem;
if (validate_change (insn, &SET_SRC (PATTERN (insn)), new, 0))
1992-02-01 09:24:22 +01:00
return 1;
}
}
#endif
break;
case COMPARE:
case EQ: case NE:
case GT: case GE: case GTU: case GEU:
case LT: case LE: case LTU: case LEU:
/* See if either argument is the biv. */
if (XEXP (x, 0) == reg)
arg = XEXP (x, 1), arg_operand = 1;
else if (XEXP (x, 1) == reg)
arg = XEXP (x, 0), arg_operand = 0;
else
break;
if (CONSTANT_P (arg))
{
/* First try to replace with any giv that has constant positive
mult_val and constant add_val. We might be able to support
negative mult_val, but it seems complex to do it in general. */
for (v = bl->giv; v; v = v->next_iv)
if (GET_CODE (v->mult_val) == CONST_INT
&& INTVAL (v->mult_val) > 0
&& (GET_CODE (v->add_val) == SYMBOL_REF
|| GET_CODE (v->add_val) == LABEL_REF
|| GET_CODE (v->add_val) == CONST
|| (GET_CODE (v->add_val) == REG
function.h (emit_status): Delete member regno_pointer_flag and rename regno_pointer_flag_length to... * function.h (emit_status): Delete member regno_pointer_flag and rename regno_pointer_flag_length to regno_pointer_align_length. Delete define for REGNO_POINTER_FLAG. * integrate.h (inline_remap): Delete member regno_pointer_flag. Add member x_regno_reg_rtx. * rtl.h (rtx_def): Use frame_related bit to indicate register is a pointer in REG expressions. Define REG_POINTER macro. * alias.c (find_base_value, find_base_term): Use REG_POINTER instead of REGNO_POINTER_FLAG. * combine.c (nonzero_bits, num_sign_bit_copies): Likewise. * emit-rtl.c (gen_reg_rtx): Use regno_pointer_align_length instead of regno_pointer_flag_length. Remove code which refers to regno_pointer_flag. (mark_reg_pointer): Use REG_POINTER. (free_emit_status): Remove code which refers to regno_pointer_flag. (init_emit, mark_emit_status): Likewise. * flow.c (dump_flow_info): Likewise. * function.c (preserve_temp_slots): Likewise. * integrate.c (expand_inline_function, copy_rtx_and_substitute): Use x_regno_reg_rtx instead of regno_pointer_flag for function pointer determination in map. * loop.c (strength_reduce, maybe_eliminate_biv_1): Use REG_POINTER. * predict.c (estimate_probability): Likewise. * regclass.c (record_address_regs, reg_scan_mark_refs): Likewise. * unroll.c (unroll_loop): Use x_regno_reg_rtx instead of regno_pointer_flag for function pointer determination in map. * convex.h (RTX_COSTS): Don't test regno_pointer_flag and use REG_POINTER. * pa.c (hppa_legitimize_address, emit_move_sequence, basereg_operand): Use REG_POINTER. (restore_unscaled_index_insn_codes): Revise comment. From-SVN: r37863
2000-11-30 07:31:19 +01:00
&& REG_POINTER (v->add_val)))
&& ! v->ignore && ! v->maybe_dead && v->always_computable
1992-02-01 09:24:22 +01:00
&& v->mode == mode)
{
if (! biv_elimination_giv_has_0_offset (bl->biv, v, insn))
continue;
1992-02-01 09:24:22 +01:00
if (! eliminate_p)
return 1;
/* Replace biv with the giv's reduced reg. */
validate_change (insn, &XEXP (x, 1 - arg_operand), v->new_reg, 1);
1992-02-01 09:24:22 +01:00
/* If all constants are actually constant integers and
the derived constant can be directly placed in the COMPARE,
do so. */
if (GET_CODE (arg) == CONST_INT
&& GET_CODE (v->mult_val) == CONST_INT
&& GET_CODE (v->add_val) == CONST_INT)
{
validate_change (insn, &XEXP (x, arg_operand),
GEN_INT (INTVAL (arg)
* INTVAL (v->mult_val)
+ INTVAL (v->add_val)), 1);
}
else
{
/* Otherwise, load it into a register. */
tem = gen_reg_rtx (mode);
emit_iv_add_mult (arg, v->mult_val, v->add_val, tem, where);
validate_change (insn, &XEXP (x, arg_operand), tem, 1);
}
if (apply_change_group ())
1992-02-01 09:24:22 +01:00
return 1;
}
1992-02-01 09:24:22 +01:00
/* Look for giv with positive constant mult_val and nonconst add_val.
Insert insns to calculate new compare value.
??? Turn this off due to possible overflow. */
1992-02-01 09:24:22 +01:00
for (v = bl->giv; v; v = v->next_iv)
if (GET_CODE (v->mult_val) == CONST_INT
&& INTVAL (v->mult_val) > 0
&& ! v->ignore && ! v->maybe_dead && v->always_computable
&& v->mode == mode
&& 0)
1992-02-01 09:24:22 +01:00
{
rtx tem;
if (! biv_elimination_giv_has_0_offset (bl->biv, v, insn))
continue;
1992-02-01 09:24:22 +01:00
if (! eliminate_p)
return 1;
tem = gen_reg_rtx (mode);
/* Replace biv with giv's reduced register. */
validate_change (insn, &XEXP (x, 1 - arg_operand),
v->new_reg, 1);
/* Compute value to compare against. */
emit_iv_add_mult (arg, v->mult_val, v->add_val, tem, where);
/* Use it in this insn. */
validate_change (insn, &XEXP (x, arg_operand), tem, 1);
if (apply_change_group ())
return 1;
}
}
else if (GET_CODE (arg) == REG || GET_CODE (arg) == MEM)
{
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (loop_invariant_p (loop, arg) == 1)
1992-02-01 09:24:22 +01:00
{
/* Look for giv with constant positive mult_val and nonconst
add_val. Insert insns to compute new compare value.
??? Turn this off due to possible overflow. */
1992-02-01 09:24:22 +01:00
for (v = bl->giv; v; v = v->next_iv)
if (GET_CODE (v->mult_val) == CONST_INT && INTVAL (v->mult_val) > 0
&& ! v->ignore && ! v->maybe_dead && v->always_computable
&& v->mode == mode
&& 0)
1992-02-01 09:24:22 +01:00
{
rtx tem;
if (! biv_elimination_giv_has_0_offset (bl->biv, v, insn))
continue;
1992-02-01 09:24:22 +01:00
if (! eliminate_p)
return 1;
tem = gen_reg_rtx (mode);
/* Replace biv with giv's reduced register. */
validate_change (insn, &XEXP (x, 1 - arg_operand),
v->new_reg, 1);
/* Compute value to compare against. */
emit_iv_add_mult (arg, v->mult_val, v->add_val,
tem, where);
validate_change (insn, &XEXP (x, arg_operand), tem, 1);
if (apply_change_group ())
return 1;
}
}
/* This code has problems. Basically, you can't know when
seeing if we will eliminate BL, whether a particular giv
of ARG will be reduced. If it isn't going to be reduced,
we can't eliminate BL. We can try forcing it to be reduced,
but that can generate poor code.
The problem is that the benefit of reducing TV, below should
be increased if BL can actually be eliminated, but this means
we might have to do a topological sort of the order in which
we try to process biv. It doesn't seem worthwhile to do
this sort of thing now. */
#if 0
/* Otherwise the reg compared with had better be a biv. */
if (GET_CODE (arg) != REG
|| REG_IV_TYPE (ivs, REGNO (arg)) != BASIC_INDUCT)
1992-02-01 09:24:22 +01:00
return 0;
/* Look for a pair of givs, one for each biv,
with identical coefficients. */
for (v = bl->giv; v; v = v->next_iv)
{
struct induction *tv;
if (v->ignore || v->maybe_dead || v->mode != mode)
continue;
for (tv = ivs->reg_biv_class[REGNO (arg)]->giv; tv; tv = tv->next_iv)
1992-02-01 09:24:22 +01:00
if (! tv->ignore && ! tv->maybe_dead
&& rtx_equal_p (tv->mult_val, v->mult_val)
&& rtx_equal_p (tv->add_val, v->add_val)
&& tv->mode == mode)
{
if (! biv_elimination_giv_has_0_offset (bl->biv, v, insn))
continue;
1992-02-01 09:24:22 +01:00
if (! eliminate_p)
return 1;
/* Replace biv with its giv's reduced reg. */
XEXP (x, 1 - arg_operand) = v->new_reg;
1992-02-01 09:24:22 +01:00
/* Replace other operand with the other giv's
reduced reg. */
XEXP (x, arg_operand) = tv->new_reg;
return 1;
}
}
#endif
}
/* If we get here, the biv can't be eliminated. */
return 0;
case MEM:
/* If this address is a DEST_ADDR giv, it doesn't matter if the
biv is used in it, since it will be replaced. */
for (v = bl->giv; v; v = v->next_iv)
if (v->giv_type == DEST_ADDR && v->location == &XEXP (x, 0))
return 1;
break;
default:
break;
1992-02-01 09:24:22 +01:00
}
/* See if any subexpression fails elimination. */
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
switch (fmt[i])
{
case 'e':
if (! maybe_eliminate_biv_1 (loop, XEXP (x, i), insn, bl,
1992-02-01 09:24:22 +01:00
eliminate_p, where))
return 0;
break;
case 'E':
for (j = XVECLEN (x, i) - 1; j >= 0; j--)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
if (! maybe_eliminate_biv_1 (loop, XVECEXP (x, i, j), insn, bl,
1992-02-01 09:24:22 +01:00
eliminate_p, where))
return 0;
break;
}
}
return 1;
}
1992-02-01 09:24:22 +01:00
/* Return nonzero if the last use of REG
is in an insn following INSN in the same basic block. */
static int
last_use_this_basic_block (reg, insn)
rtx reg;
rtx insn;
{
rtx n;
for (n = insn;
n && GET_CODE (n) != CODE_LABEL && GET_CODE (n) != JUMP_INSN;
n = NEXT_INSN (n))
{
if (REGNO_LAST_UID (REGNO (reg)) == INSN_UID (n))
1992-02-01 09:24:22 +01:00
return 1;
}
return 0;
}
/* Called via `note_stores' to record the initial value of a biv. Here we
just record the location of the set and process it later. */
static void
rtl.h (note_stores): Add additional paramter. * rtl.h (note_stores): Add additional paramter. * rtlanal.c (reg_set_p_1): Take additional paramter. (reg_set_last_1): Likewise. (reg_set_p): Adjust call to note_stores. (reg_set_last): Likewise. (note_stores): Pass data parameter to worker function. * alias.c (record_set): Take additional parameter. (init_alias_analysis): Pass it. * caller-save.c (mark_set_regs): Take additional parameter. (save_call_clobbered_regs): Pass NULL to note_stores. * combine.c (set_nonzero_bits_and_sign_copies): Take additional parameter. (record_dead_and_set_regs_1): Likewise. (reg_dead_at_p_1): Likewise. (combine_instructions): Adjust calls to note_stores. (try_combine): Likewise. (record_dead_insn): Remove. (record_dead_and_set_regs): Adjust calls to note_stores. (reg_dead_at_p): Likewise. * cse.c (invalidate_skipped_set): Take additional parameter. (cse_check_loop_start): Likewise. (cse_check_loop_start_value): Remove. (cse_set_around_loop): Adjust calls to note_stores. * flow.c (notice_stack_pointer_modification): Take additional parameter. Remove duplicate declaration. (record_volatile_insns): Adjust calls to note_stores. * gcse.c (record_set_info): Take additional parameter. (record_last_set_info): Likewise. (invalidate_nonnull_info): Likewise. (record_set_insn): Remove. (compute_sets): Adjust calls to note_stores. (last_set_insn): Remove. (compute_hash_table): Adjust calls to note_stores. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks): Likewise. * global.c (mark_reg_store): Take additional parameter. (mark_reg_clobber): Likewise. (reg_becomes_live): Likewise. (global_conflicts): Adjust calls to note_stores. (build_insn_chain): Likewise. * integrate.c (note_modified_parmregs): Take additional parameter. (mark_stores): Likewise. Make it static. (save_for_inline_nocopy): Adjust calls to note_stores. (try_constants): Likewise. * integrate.h (mark_stores): Remove declaration. * jump.c (mark_modified_reg): Take additional parameter. (thread_jumps): Adjust calls to note_stores. * local-alloc.c (validate_equiv_mem_from_store): Take additional parameter. (no_equiv): Likewise. (reg_is_set): Likewise. (validate_equiv_mem): Adjust calls to note_stores. (update_equiv_regs): Likewise. (block_alloc): Likewise. * loop.c (note_set_pseudo_multiple_uses_retval): Remove. (note_addr_stored): Take additional parameter. (note_set_pseudo_multiple_uses): Likewise. (record_initial): Likewise. (prescan_loop): Adjust calls to note_stores. (strength_reduce): Likewise. (check_dbra_loop): Likewise. * regmove.c (flags_set_1): Take additional paramter. (mark_flags_life_zones): Adjust calls to note_stores. * reload1.c (mark_not_eliminable): Take additional parameter. (forget_old_reloads_1): Likewise. (reload_cse_invalidate_rtx): Likewise. (reload_cse_check_clobber): Likewise. (reload_combine_note_store): Likewise. (move2add_note_store): Likewise. (reload): Adjust calls to note_stores. (reload_as_needed): Likewise. (emit_reload_insns): Likewise. (reload_cse_regs_1): Likewise. (reload_cse_record_set): Adjust calls to reload_cse_invalidate_rtx. (reload_combine): Adjust calls to note_stores. * resource.c (update_live_status): Take additional paramter. (mark_target_live_regs): Adjust calls to note_stores. * stupid.c (find_clobbered_regs): Take additional parameter. (stupid_life_analysis): Adjust calls to note_stores. From-SVN: r30221
1999-10-27 21:27:41 +02:00
record_initial (dest, set, data)
1992-02-01 09:24:22 +01:00
rtx dest;
rtx set;
rtl.h (note_stores): Add additional paramter. * rtl.h (note_stores): Add additional paramter. * rtlanal.c (reg_set_p_1): Take additional paramter. (reg_set_last_1): Likewise. (reg_set_p): Adjust call to note_stores. (reg_set_last): Likewise. (note_stores): Pass data parameter to worker function. * alias.c (record_set): Take additional parameter. (init_alias_analysis): Pass it. * caller-save.c (mark_set_regs): Take additional parameter. (save_call_clobbered_regs): Pass NULL to note_stores. * combine.c (set_nonzero_bits_and_sign_copies): Take additional parameter. (record_dead_and_set_regs_1): Likewise. (reg_dead_at_p_1): Likewise. (combine_instructions): Adjust calls to note_stores. (try_combine): Likewise. (record_dead_insn): Remove. (record_dead_and_set_regs): Adjust calls to note_stores. (reg_dead_at_p): Likewise. * cse.c (invalidate_skipped_set): Take additional parameter. (cse_check_loop_start): Likewise. (cse_check_loop_start_value): Remove. (cse_set_around_loop): Adjust calls to note_stores. * flow.c (notice_stack_pointer_modification): Take additional parameter. Remove duplicate declaration. (record_volatile_insns): Adjust calls to note_stores. * gcse.c (record_set_info): Take additional parameter. (record_last_set_info): Likewise. (invalidate_nonnull_info): Likewise. (record_set_insn): Remove. (compute_sets): Adjust calls to note_stores. (last_set_insn): Remove. (compute_hash_table): Adjust calls to note_stores. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks): Likewise. * global.c (mark_reg_store): Take additional parameter. (mark_reg_clobber): Likewise. (reg_becomes_live): Likewise. (global_conflicts): Adjust calls to note_stores. (build_insn_chain): Likewise. * integrate.c (note_modified_parmregs): Take additional parameter. (mark_stores): Likewise. Make it static. (save_for_inline_nocopy): Adjust calls to note_stores. (try_constants): Likewise. * integrate.h (mark_stores): Remove declaration. * jump.c (mark_modified_reg): Take additional parameter. (thread_jumps): Adjust calls to note_stores. * local-alloc.c (validate_equiv_mem_from_store): Take additional parameter. (no_equiv): Likewise. (reg_is_set): Likewise. (validate_equiv_mem): Adjust calls to note_stores. (update_equiv_regs): Likewise. (block_alloc): Likewise. * loop.c (note_set_pseudo_multiple_uses_retval): Remove. (note_addr_stored): Take additional parameter. (note_set_pseudo_multiple_uses): Likewise. (record_initial): Likewise. (prescan_loop): Adjust calls to note_stores. (strength_reduce): Likewise. (check_dbra_loop): Likewise. * regmove.c (flags_set_1): Take additional paramter. (mark_flags_life_zones): Adjust calls to note_stores. * reload1.c (mark_not_eliminable): Take additional parameter. (forget_old_reloads_1): Likewise. (reload_cse_invalidate_rtx): Likewise. (reload_cse_check_clobber): Likewise. (reload_combine_note_store): Likewise. (move2add_note_store): Likewise. (reload): Adjust calls to note_stores. (reload_as_needed): Likewise. (emit_reload_insns): Likewise. (reload_cse_regs_1): Likewise. (reload_cse_record_set): Adjust calls to reload_cse_invalidate_rtx. (reload_combine): Adjust calls to note_stores. * resource.c (update_live_status): Take additional paramter. (mark_target_live_regs): Adjust calls to note_stores. * stupid.c (find_clobbered_regs): Take additional parameter. (stupid_life_analysis): Adjust calls to note_stores. From-SVN: r30221
1999-10-27 21:27:41 +02:00
void *data ATTRIBUTE_UNUSED;
1992-02-01 09:24:22 +01:00
{
struct loop_ivs *ivs = (struct loop_ivs *) data;
1992-02-01 09:24:22 +01:00
struct iv_class *bl;
if (GET_CODE (dest) != REG
|| REGNO (dest) >= max_reg_before_loop
|| REG_IV_TYPE (ivs, REGNO (dest)) != BASIC_INDUCT)
1992-02-01 09:24:22 +01:00
return;
bl = ivs->reg_biv_class[REGNO (dest)];
1992-02-01 09:24:22 +01:00
/* If this is the first set found, record it. */
if (bl->init_insn == 0)
{
bl->init_insn = note_insn;
bl->init_set = set;
}
}
/* If any of the registers in X are "old" and currently have a last use earlier
than INSN, update them to have a last use of INSN. Their actual last use
will be the previous insn but it will not have a valid uid_luid so we can't
use it. */
static void
update_reg_last_use (x, insn)
rtx x;
rtx insn;
{
/* Check for the case where INSN does not have a valid luid. In this case,
there is no need to modify the regno_last_uid, as this can only happen
when code is inserted after the loop_end to set a pseudo's final value,
and hence this insn will never be the last use of x. */
if (GET_CODE (x) == REG && REGNO (x) < max_reg_before_loop
&& INSN_UID (insn) < max_uid_for_loop
&& uid_luid[REGNO_LAST_UID (REGNO (x))] < uid_luid[INSN_UID (insn)])
REGNO_LAST_UID (REGNO (x)) = INSN_UID (insn);
1992-02-01 09:24:22 +01:00
else
{
register int i, j;
rtl.h (rtx_format): Constify a char*. * rtl.h (rtx_format): Constify a char*. * rtl.c (rtx_format): Likewise. (copy_rtx, copy_most_rtx, read_rtx): Likewise. (init_rtl): Use accessor macro, not `rtx_format'. * alias.c (rtx_equal_for_memref_p, find_symbolic_term): Constify a char*. * caller-save.c (mark_referenced_regs): Likewise. * combine.c (subst, make_compound_operation, known_cond, gen_rtx_combine, update_table_tick, get_last_value_validate, use_crosses_set_p, mark_used_regs_combine, move_deaths): Likewise. * cse.c (rtx_cost, mention_regs, canon_hash, exp_equiv_p, refers_to_p, canon_reg, fold_rtx, cse_process_notes, count_reg_usage): Likewise. * emit-rtl.c (gen_rtx, copy_rtx_if_shared, reset_used_flags): Likewise. * final.c (leaf_renumber_regs_insn): Likewise. * flow.c (mark_used_regs, find_use_as_address, dump_flow_info, dump_edge_info, count_reg_references): Likewise. * function.c (fixup_var_refs_1, walk_fixup_memory_subreg, fixup_stack_1, purge_addressof_1, instantiate_virtual_regs_1): Likewise. * gcse.c (oprs_unchanged_p, hash_expr_1, expr_equiv_p, oprs_not_set_p, expr_killed_p, compute_transp, find_used_regs, add_label_notes): Likewise. * genattrtab.c (attr_rtx, attr_copy_rtx, encode_units_mask, clear_struct_flag, count_sub_rtxs, count_alternatives, compares_alternatives_p, contained_in_p, walk_attr_value, write_expr_attr_cache): Likewise. * genconfig.c (walk_insn_part): Likewise. * genemit.c (max_operand_1, gen_exp): Likewise. * genextract.c (walk_rtx): Likewise. * genflags.c (num_operands): Likewise. * genoutput.c (scan_operands): Likewise. * genpeep.c (match_rtx): Likewise. * genrecog.c (add_to_sequence): Likewise. * haifa-sched.c (may_trap_exp, sched_analyze_2, attach_deaths): Likewise. * integrate.c (save_constants, copy_for_inline, copy_rtx_and_substitute, subst_constants, restore_constants): Likewise. * jump.c (mark_jump_label, invert_exp, redirect_exp, rtx_renumbered_equal_p, rtx_equal_for_thread_p): Likewise. * local-alloc.c (contains_replace_regs, memref_referenced_p): Likewise. * loop.c (record_excess_regs, rtx_equal_for_loop_p, add_label_notes, replace_call_address, count_nonfixed_reads, invariant_p, find_single_use_in_loop, find_mem_givs, find_life_end, maybe_eliminate_biv_1, update_reg_last_use): Likewise. * print-rtl.c (reg_names, print_rtx): Likewise. * recog.c (validate_replace_rtx_1, find_single_use_1): Likewise. * reg-stack.c (stack_regs_mentioned_p, record_label_references, record_reg_life_pat, swap_rtx_condition, goto_block_pat, print_blocks): Likewise. * regclass.c (fix_register, record_address_regs, reg_scan_mark_refs): Likewise. * regmove.c (stable_but_for_p): Likewise. * reload.c (loc_mentioned_in_p, operands_match_p, find_reloads_toplevsubst_reg_equivs, find_reloads_address_1, copy_replacements, refers_to_regno_for_reload_p, refers_to_mem_for_reload_p, find_inc_amount, regno_clobbered_p, reload_when_needed_name, reg_class_names, debug_reload_to_stream): Likewise. * reload1.c (eliminate_regs, scan_paradoxical_subregs, delete_address_reloads_1, count_occurrences, reload_cse_mem_conflict_p, reload_combine_note_use, add_auto_inc_notes): Likewise. * resource.c (mark_referenced_resources, mark_set_resources): Likewise. * rtlanal.c (rtx_unstable_p, rtx_varies_p, rtx_addr_varies_p, reg_mentioned_p, regs_set_between_p, modified_between_p, modified_in_p, refers_to_regno_p, reg_overlap_mentioned_p, rtx_equal_p, volatile_insn_p, volatile_refs_p, side_effects_p, may_trap_p, inequality_comparisons_p, replace_rtx, replace_regs, jmp_uses_reg_or_mem, for_each_rtx, regno_use_in): Likewise. * sched.c (sched_analyze_2, attach_deaths): Likewise. * stupid.c (stupid_mark_refs): Likewise. * unroll.c (remap_split_bivs): Likewise. * varasm.c (mark_constants): Likewise. * a29k/a29k.c (uses_local_reg_p): Likewise. * alpha/alpha.c (summarize_insn): Likewise. * arm/arm.c (symbol_mentioned_p, label_mentioned_p, eliminate_lr2ip): Likewise. * arm/thumb.c (symbol_mentioned_p, label_mentioned_p): Likewise. * i386/i386.c (symbolic_reference_mentioned_p, copy_all_rtx, reg_mentioned_in_mem): Likewise. * ns32k/ns32k.c (global_symbolic_reference_mentioned_p, symbolic_reference_mentioned_p): Likewise. * romp/romp.c (unsigned_comparisons_p, hash_rtx): Likewise. * sh/sh.c (regs_used, mark_use): Likewise. * vax/vax.c (vax_rtx_cost): Likewise. From-SVN: r28784
1999-08-21 01:05:25 +02:00
register const char *fmt = GET_RTX_FORMAT (GET_CODE (x));
1992-02-01 09:24:22 +01:00
for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
{
if (fmt[i] == 'e')
update_reg_last_use (XEXP (x, i), insn);
else if (fmt[i] == 'E')
for (j = XVECLEN (x, i) - 1; j >= 0; j--)
update_reg_last_use (XVECEXP (x, i, j), insn);
}
}
}
/* Given an insn INSN and condition COND, return the condition in a
canonical form to simplify testing by callers. Specifically:
1992-02-01 09:24:22 +01:00
(1) The code will always be a comparison operation (EQ, NE, GT, etc.).
(2) Both operands will be machine operands; (cc0) will have been replaced.
(3) If an operand is a constant, it will be the second operand.
(4) (LE x const) will be replaced with (LT x <const+1>) and similarly
for GE, GEU, and LEU.
If the condition cannot be understood, or is an inequality floating-point
comparison which needs to be reversed, 0 will be returned.
If REVERSE is non-zero, then reverse the condition prior to canonizing it.
If EARLIEST is non-zero, it is a pointer to a place where the earliest
insn used in locating the condition was found. If a replacement test
of the condition is desired, it should be placed in front of that
insn and we will be sure that the inputs are still valid.
If WANT_REG is non-zero, we wish the condition to be relative to that
register, if possible. Therefore, do not canonicalize the condition
further. */
1992-02-01 09:24:22 +01:00
rtx
canonicalize_condition (insn, cond, reverse, earliest, want_reg)
rtx insn;
rtx cond;
int reverse;
1992-02-01 09:24:22 +01:00
rtx *earliest;
rtx want_reg;
1992-02-01 09:24:22 +01:00
{
enum rtx_code code;
rtx prev = insn;
1992-02-01 09:24:22 +01:00
rtx set;
rtx tem;
rtx op0, op1;
int reverse_code = 0;
int did_reverse_condition = 0;
enum machine_mode mode;
1992-02-01 09:24:22 +01:00
code = GET_CODE (cond);
mode = GET_MODE (cond);
op0 = XEXP (cond, 0);
op1 = XEXP (cond, 1);
1992-02-01 09:24:22 +01:00
if (reverse)
{
code = reverse_condition (code);
did_reverse_condition ^= 1;
}
1992-02-01 09:24:22 +01:00
if (earliest)
*earliest = insn;
1992-02-01 09:24:22 +01:00
/* If we are comparing a register with zero, see if the register is set
in the previous insn to a COMPARE or a comparison operation. Perform
the same tests as a function of STORE_FLAG_VALUE as find_comparison_args
in cse.c */
while (GET_RTX_CLASS (code) == '<'
&& op1 == CONST0_RTX (GET_MODE (op0))
&& op0 != want_reg)
1992-02-01 09:24:22 +01:00
{
/* Set non-zero when we find something of interest. */
rtx x = 0;
#ifdef HAVE_cc0
/* If comparison with cc0, import actual comparison from compare
insn. */
if (op0 == cc0_rtx)
{
if ((prev = prev_nonnote_insn (prev)) == 0
|| GET_CODE (prev) != INSN
|| (set = single_set (prev)) == 0
|| SET_DEST (set) != cc0_rtx)
return 0;
op0 = SET_SRC (set);
op1 = CONST0_RTX (GET_MODE (op0));
if (earliest)
*earliest = prev;
}
#endif
/* If this is a COMPARE, pick up the two things being compared. */
if (GET_CODE (op0) == COMPARE)
{
op1 = XEXP (op0, 1);
op0 = XEXP (op0, 0);
continue;
}
else if (GET_CODE (op0) != REG)
break;
/* Go back to the previous insn. Stop if it is not an INSN. We also
stop if it isn't a single set or if it has a REG_INC note because
we don't want to bother dealing with it. */
if ((prev = prev_nonnote_insn (prev)) == 0
|| GET_CODE (prev) != INSN
|| FIND_REG_INC_NOTE (prev, 0)
|| (set = single_set (prev)) == 0)
break;
/* If this is setting OP0, get what it sets it to if it looks
relevant. */
if (rtx_equal_p (SET_DEST (set), op0))
1992-02-01 09:24:22 +01:00
{
enum machine_mode inner_mode = GET_MODE (SET_DEST (set));
1992-02-01 09:24:22 +01:00
/* ??? We may not combine comparisons done in a CCmode with
comparisons not done in a CCmode. This is to aid targets
like Alpha that have an IEEE compliant EQ instruction, and
a non-IEEE compliant BEQ instruction. The use of CCmode is
actually artificial, simply to prevent the combination, but
should not affect other platforms.
However, we must allow VOIDmode comparisons to match either
CCmode or non-CCmode comparison, because some ports have
modeless comparisons inside branch patterns.
??? This mode check should perhaps look more like the mode check
in simplify_comparison in combine. */
1992-02-01 09:24:22 +01:00
if ((GET_CODE (SET_SRC (set)) == COMPARE
|| (((code == NE
|| (code == LT
&& GET_MODE_CLASS (inner_mode) == MODE_INT
&& (GET_MODE_BITSIZE (inner_mode)
<= HOST_BITS_PER_WIDE_INT)
&& (STORE_FLAG_VALUE
& ((HOST_WIDE_INT) 1
<< (GET_MODE_BITSIZE (inner_mode) - 1))))
#ifdef FLOAT_STORE_FLAG_VALUE
|| (code == LT
&& GET_MODE_CLASS (inner_mode) == MODE_FLOAT
&& (REAL_VALUE_NEGATIVE
(FLOAT_STORE_FLAG_VALUE (inner_mode))))
#endif
))
&& GET_RTX_CLASS (GET_CODE (SET_SRC (set))) == '<'))
&& (((GET_MODE_CLASS (mode) == MODE_CC)
== (GET_MODE_CLASS (inner_mode) == MODE_CC))
|| mode == VOIDmode || inner_mode == VOIDmode))
1992-02-01 09:24:22 +01:00
x = SET_SRC (set);
else if (((code == EQ
|| (code == GE
&& (GET_MODE_BITSIZE (inner_mode)
<= HOST_BITS_PER_WIDE_INT)
&& GET_MODE_CLASS (inner_mode) == MODE_INT
&& (STORE_FLAG_VALUE
& ((HOST_WIDE_INT) 1
<< (GET_MODE_BITSIZE (inner_mode) - 1))))
#ifdef FLOAT_STORE_FLAG_VALUE
|| (code == GE
&& GET_MODE_CLASS (inner_mode) == MODE_FLOAT
&& (REAL_VALUE_NEGATIVE
(FLOAT_STORE_FLAG_VALUE (inner_mode))))
#endif
))
&& GET_RTX_CLASS (GET_CODE (SET_SRC (set))) == '<'
&& (((GET_MODE_CLASS (mode) == MODE_CC)
== (GET_MODE_CLASS (inner_mode) == MODE_CC))
|| mode == VOIDmode || inner_mode == VOIDmode))
1992-02-01 09:24:22 +01:00
{
/* We might have reversed a LT to get a GE here. But this wasn't
actually the comparison of data, so we don't flag that we
have had to reverse the condition. */
did_reverse_condition ^= 1;
reverse_code = 1;
x = SET_SRC (set);
}
else
break;
1992-02-01 09:24:22 +01:00
}
else if (reg_set_p (op0, prev))
/* If this sets OP0, but not directly, we have to give up. */
break;
if (x)
{
if (GET_RTX_CLASS (GET_CODE (x)) == '<')
code = GET_CODE (x);
if (reverse_code)
{
code = reverse_condition (code);
rtl.def: Add unordered fp comparisions. * rtl.def: Add unordered fp comparisions. * tree.def: Likewise. * tree.h: Add ISO C 9x unordered fp comparision builtins. * builtins.c (expand_tree_builtin): New function. * c-typeck.c (build_function_call): Use it. (build_binary_op): Support unordered compares. * c-common.c (c_common_nodes_and_builtins): Add unordered compares. * combine.c (known_cond): Handle reverse_condition returning UNKNOWN. (reversible_comparison_p): Allow UNORDERED/ORDERED to be reversed. * cse.c (fold_rtx): Check FLOAT_MODE_P before reversing. (record_jump_equiv): Handle reverse_condition returning UNKNOWN. * jump.c (reverse_condition): Don't abort for UNLE etc, but return UNKNOWN. (swap_condition): Handle unordered compares. (thread_jumps): Check can_reverse before reversing. * loop.c (get_condition): Likewise. Allow UNORERED/ORDERED to be reversed for FP. * optabs.c (can_compare_p): New argument CODE. Verify branch or setcc is present before acking for cmp_optab. Update all callers. (prepare_float_lib_cmp, init_optabs): Handle UNORDERED. * expmed.c (do_cmp_and_jump): Update for can_compare_p. * expr.c (expand_expr): Likewise. Support unordered compares. (do_jump, do_store_flag): Likewise. * expr.h (enum libfunc_index): Add unordered compares. * Makefile.in (FPBIT_FUNCS): Add _unord_sf. (DPBIT_FUNCS): Add _unord_df. * config/fp-bit.c (_unord_f2): New. * fp-test.c (main): Try unordered compare builtins. * alpha-protos.h (alpha_fp_comparison_operator): Declare. * alpha.c (alpha_comparison_operator): Check mode properly. (alpha_swapped_comparison_operator): Likewise. (signed_comparison_operator): Likewise. (alpha_fp_comparison_operator): New. (alpha_emit_conditional_branch): Handle unordered compares. * alpha.h (PREDICATE_CODES): Update. * alpha.md (fp compares): Use alpha_fp_comparison_operator. (bunordered, bordered): New. * cp/call.c (build_over_call): Use expand_tree_builtin. * cp/typeck.c (build_function_call_real): Likewise. (build_binary_op_nodefault): Handle unordered compares. * gcc.c-torture/execute/ieee/fp-cmp-4.c: New. From-SVN: r31591
2000-01-24 21:10:04 +01:00
if (code == UNKNOWN)
return 0;
1992-02-01 09:24:22 +01:00
did_reverse_condition ^= 1;
reverse_code = 0;
}
op0 = XEXP (x, 0), op1 = XEXP (x, 1);
if (earliest)
*earliest = prev;
}
}
/* If constant is first, put it last. */
if (CONSTANT_P (op0))
code = swap_condition (code), tem = op0, op0 = op1, op1 = tem;
/* If OP0 is the result of a comparison, we weren't able to find what
was really being compared, so fail. */
if (GET_MODE_CLASS (GET_MODE (op0)) == MODE_CC)
return 0;
/* Canonicalize any ordered comparison with integers involving equality
if we can do computations in the relevant mode and we do not
overflow. */
if (GET_CODE (op1) == CONST_INT
&& GET_MODE (op0) != VOIDmode
&& GET_MODE_BITSIZE (GET_MODE (op0)) <= HOST_BITS_PER_WIDE_INT)
1992-02-01 09:24:22 +01:00
{
HOST_WIDE_INT const_val = INTVAL (op1);
unsigned HOST_WIDE_INT uconst_val = const_val;
unsigned HOST_WIDE_INT max_val
= (unsigned HOST_WIDE_INT) GET_MODE_MASK (GET_MODE (op0));
1992-02-01 09:24:22 +01:00
switch (code)
{
case LE:
Warning fixes: * Makefile.in (sched.o): Depend on recog.h. * alias.c (REG_BASE_VALUE): Cast the result of REGNO() macro to (unsigned) when comparing against one. (find_base_value): Likewise. (record_base_value): Cast variable `regno' to (unsigned) when comparing against one. Cast the result of REGNO() macro to (unsigned) when comparing against one. (memrefs_conflict_p): Change type of variables `r_x' and `r_y' to unsigned. (init_alias_analysis): Add unsigned variable `ui'. Use it as loop variable where an unsigned index is needed. * caller-save.c (init_caller_save): Cast `-1' to (enum insn_code) before comparing against one. * collect2.c: Add prototypes for functions `error', `fatal' and `fatal_perror'. Make these functions take variable arguments instead of faking it with a fixed number of args. (write_c_file_stat): Cast the argument of ctype macro to (unsigned char). * combine.c (can_combine_p): Mark parameter `pred' with ATTRIBUTE_UNUSED. (find_split_point): Cast variable `src' to (unsigned HOST_WIDE_INT) when comparing against one. HOST_WIDE_INT) when comparing against one. (simplify_rtx): Cast 1 to (unsigned HOST_WIDE_INT) in shift. (simplify_logical): Likewise. (force_to_mode): Cast result of INTVAL() macro to (unsigned HOST_WIDE_INT) when comparing against one. Cast 1 to (unsigned HOST_WIDE_INT) in shift. (simplify_and_const_int): Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (merge_outer_ops): Cast variable const0 to `unsigned HOST_WIDE_INT' when comparing against the result of GET_MODE_MASK() macro. (simplify_comparison): Likewise for variable `c0'. Cast variable `const_op' to `unsigned HOST_WIDE_INT' when comparing against one. Cast `1' to `unsigned HOST_WIDE_INT' in shift. Cast the result of `GET_MODE_MASK()/2' to `HOST_WIDE_INT' when comparing against one. Cast `1' to `unsigned HOST_WIDE_INT' in shift. Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (distribute_notes): Wrap variable `cc0_setter' in macro `HAVE_cc0'. config/mips/mips.c (gen_int_relational): Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (output_block_move): Cast `sizeof' expression to (int) when comparing against one. (function_arg): Cast BITS_PER_WORD to `unsigned' when comparing against one. (save_restore_insns): Cast `base_offset' to `long' to match format specifier in fprintf. * config/mips/mips.h (Pmode): Cast the result of `Pmode' macro to `enum machine_mode'. * flow.c (life_analysis_1): Remove unused variable `insn'. * gcc.c (translate_options): Move variables `j' and `k' into the scope in which they are used. Change their types to `size_t'. (set_spec): Cast the argument of ctype macro to `unsigned char'. (read_specs): Likewise. (process_command): Cast `sizeof' to (int) when comparing against one. (do_spec_1): Cast the argument of ctype macro to `unsigned char'. (handle_braces): Cast both sides of `==' expression to `long' to ensure sign matching. (main): Cast variable `i' to `int' when comparing against one. * gcov-io.h (__fetch_long): Change type of parameter `bytes' from int to size_t. Cast variable `i' to size_t when comparing against one. * genattrtab.c (convert_set_attr_alternative): Remove unused parameter `insn_code'. All callers changed. (convert_set_attr): Likewise. * genrecog.c (add_to_sequence): Cast result of XVECLEN() macro to size_t when comparing against one. Likewise for variable `len'. * global.c (global_alloc): Cast variable `max_regno' to size_t when comparing against one. Likewise for variable `max_allocno'. * jump.c (sets_cc0_p): Mark parameter `x' with ATTRIBUTE_UNUSED. * local-alloc.c (validate_equiv_mem_from_store): Mark parameter `set' with ATTRIBUTE_UNUSED. (find_free_reg): Cast `sizeof' expression to (int) when comparing against one. * loop.c (count_loop_regs_set): Remove unused variable `dest'. (strength_reduce): Mark parameter `bct_p' with ATTRIBUTE_UNUSED. (get_condition): Cast variable `const_val' to `unsigned HOST_WIDE_INT' when comparing against one. Cast unsigned expression to HOST_WIDE_INT when comparing against one. (insert_loop_mem): Mark parameter `data' with ATTRIBUTE_UNUSED. (load_mems_and_recount_loop_regs_set): Cast variable `nregs' to `unsigned' when comparing against one. * protoize.c (is_id_char): Change type of parameter `ch' to unsigned char. (munge_compile_params): Cast argument of ctype macro to (const unsigned char). (process_aux_info_file): Cast variable `aux_info_size' to int when comparing against one. (forward_to_next_token_char): Cast argument of ctype macro to `const unsigned char'. (edit_formals_lists): Likewise. (find_rightmost_formals_list): Likewise. (add_local_decl): Likewise. (add_global_decls): Likewise. (edit_fn_definition): Likewise. (do_cleaning): Likewise. (scan_for_missed_items): Likewise. (edit_file): Cast variable `orig_size' to (int) when comparing against one. (main): Cast argument of ctype macro to `const unsigned char'. * recog.c (const_int_operand): Mark parameter `mode' with ATTRIBUTE_UNUSED. * regclass.c (record_reg_classes): Change type of variable `c' to `unsigned char'. Cast `char' array index to `unsigned char'. * reload.c (push_secondary_reload): Cast argument to REG_CLASS_FROM_LETTER() macro to `unsigned char'. * reload1.c (calculate_needs): Cast `char' array index to `unsigned char'. (set_label_offsets): Change type of variable `i' to unsigned int. Cast result of XVECLEN() macro to unsigned when comparing against one. (mark_not_eliminable): Change type of variable `i' to unsigned. (order_regs_for_reload): Likewise. Cast `max_regno' to unsigned when comparing against one. (reload_as_needed): Cast macro NUM_ELIMINABLE_REGS to (int) when comparing against one. (choose_reload_regs): Hide unused label `fail'. (reload_cse_simplify_operands): Cast `char' array index to `unsigned char'. (reload_combine_note_store): Mark parameter `set' with ATTRIBUTE_UNUSED. Cast UNITS_PER_WORD to unsigned when comparing against one. (reload_cse_move2add): Remove unused variable `src2'. * sched.c: Include recog.h. (sched_note_set): Remove unused parameter `b'. All callers changed. (split_hard_reg_notes): Likewise for parameter `orig_insn'. (blockage_range): Cast result of UNIT_BLOCKED() macro to (int) when comparing against one. * stupid.c (stupid_find_reg): Mark parameter `changes_size' with ATTRIBUTE_UNUSED. Cast `sizeof' expression to (int) when comparing against one. * unroll.c (precondition_loop_p): Remove unused parameter `loop_end'. All callers changed. From-SVN: r23079
1998-10-14 11:02:55 +02:00
if ((unsigned HOST_WIDE_INT) const_val != max_val >> 1)
code = LT, op1 = GEN_INT (const_val + 1);
break;
1992-02-01 09:24:22 +01:00
/* When cross-compiling, const_val might be sign-extended from
BITS_PER_WORD to HOST_BITS_PER_WIDE_INT */
case GE:
Warning fixes: * Makefile.in (sched.o): Depend on recog.h. * alias.c (REG_BASE_VALUE): Cast the result of REGNO() macro to (unsigned) when comparing against one. (find_base_value): Likewise. (record_base_value): Cast variable `regno' to (unsigned) when comparing against one. Cast the result of REGNO() macro to (unsigned) when comparing against one. (memrefs_conflict_p): Change type of variables `r_x' and `r_y' to unsigned. (init_alias_analysis): Add unsigned variable `ui'. Use it as loop variable where an unsigned index is needed. * caller-save.c (init_caller_save): Cast `-1' to (enum insn_code) before comparing against one. * collect2.c: Add prototypes for functions `error', `fatal' and `fatal_perror'. Make these functions take variable arguments instead of faking it with a fixed number of args. (write_c_file_stat): Cast the argument of ctype macro to (unsigned char). * combine.c (can_combine_p): Mark parameter `pred' with ATTRIBUTE_UNUSED. (find_split_point): Cast variable `src' to (unsigned HOST_WIDE_INT) when comparing against one. HOST_WIDE_INT) when comparing against one. (simplify_rtx): Cast 1 to (unsigned HOST_WIDE_INT) in shift. (simplify_logical): Likewise. (force_to_mode): Cast result of INTVAL() macro to (unsigned HOST_WIDE_INT) when comparing against one. Cast 1 to (unsigned HOST_WIDE_INT) in shift. (simplify_and_const_int): Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (merge_outer_ops): Cast variable const0 to `unsigned HOST_WIDE_INT' when comparing against the result of GET_MODE_MASK() macro. (simplify_comparison): Likewise for variable `c0'. Cast variable `const_op' to `unsigned HOST_WIDE_INT' when comparing against one. Cast `1' to `unsigned HOST_WIDE_INT' in shift. Cast the result of `GET_MODE_MASK()/2' to `HOST_WIDE_INT' when comparing against one. Cast `1' to `unsigned HOST_WIDE_INT' in shift. Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (distribute_notes): Wrap variable `cc0_setter' in macro `HAVE_cc0'. config/mips/mips.c (gen_int_relational): Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (output_block_move): Cast `sizeof' expression to (int) when comparing against one. (function_arg): Cast BITS_PER_WORD to `unsigned' when comparing against one. (save_restore_insns): Cast `base_offset' to `long' to match format specifier in fprintf. * config/mips/mips.h (Pmode): Cast the result of `Pmode' macro to `enum machine_mode'. * flow.c (life_analysis_1): Remove unused variable `insn'. * gcc.c (translate_options): Move variables `j' and `k' into the scope in which they are used. Change their types to `size_t'. (set_spec): Cast the argument of ctype macro to `unsigned char'. (read_specs): Likewise. (process_command): Cast `sizeof' to (int) when comparing against one. (do_spec_1): Cast the argument of ctype macro to `unsigned char'. (handle_braces): Cast both sides of `==' expression to `long' to ensure sign matching. (main): Cast variable `i' to `int' when comparing against one. * gcov-io.h (__fetch_long): Change type of parameter `bytes' from int to size_t. Cast variable `i' to size_t when comparing against one. * genattrtab.c (convert_set_attr_alternative): Remove unused parameter `insn_code'. All callers changed. (convert_set_attr): Likewise. * genrecog.c (add_to_sequence): Cast result of XVECLEN() macro to size_t when comparing against one. Likewise for variable `len'. * global.c (global_alloc): Cast variable `max_regno' to size_t when comparing against one. Likewise for variable `max_allocno'. * jump.c (sets_cc0_p): Mark parameter `x' with ATTRIBUTE_UNUSED. * local-alloc.c (validate_equiv_mem_from_store): Mark parameter `set' with ATTRIBUTE_UNUSED. (find_free_reg): Cast `sizeof' expression to (int) when comparing against one. * loop.c (count_loop_regs_set): Remove unused variable `dest'. (strength_reduce): Mark parameter `bct_p' with ATTRIBUTE_UNUSED. (get_condition): Cast variable `const_val' to `unsigned HOST_WIDE_INT' when comparing against one. Cast unsigned expression to HOST_WIDE_INT when comparing against one. (insert_loop_mem): Mark parameter `data' with ATTRIBUTE_UNUSED. (load_mems_and_recount_loop_regs_set): Cast variable `nregs' to `unsigned' when comparing against one. * protoize.c (is_id_char): Change type of parameter `ch' to unsigned char. (munge_compile_params): Cast argument of ctype macro to (const unsigned char). (process_aux_info_file): Cast variable `aux_info_size' to int when comparing against one. (forward_to_next_token_char): Cast argument of ctype macro to `const unsigned char'. (edit_formals_lists): Likewise. (find_rightmost_formals_list): Likewise. (add_local_decl): Likewise. (add_global_decls): Likewise. (edit_fn_definition): Likewise. (do_cleaning): Likewise. (scan_for_missed_items): Likewise. (edit_file): Cast variable `orig_size' to (int) when comparing against one. (main): Cast argument of ctype macro to `const unsigned char'. * recog.c (const_int_operand): Mark parameter `mode' with ATTRIBUTE_UNUSED. * regclass.c (record_reg_classes): Change type of variable `c' to `unsigned char'. Cast `char' array index to `unsigned char'. * reload.c (push_secondary_reload): Cast argument to REG_CLASS_FROM_LETTER() macro to `unsigned char'. * reload1.c (calculate_needs): Cast `char' array index to `unsigned char'. (set_label_offsets): Change type of variable `i' to unsigned int. Cast result of XVECLEN() macro to unsigned when comparing against one. (mark_not_eliminable): Change type of variable `i' to unsigned. (order_regs_for_reload): Likewise. Cast `max_regno' to unsigned when comparing against one. (reload_as_needed): Cast macro NUM_ELIMINABLE_REGS to (int) when comparing against one. (choose_reload_regs): Hide unused label `fail'. (reload_cse_simplify_operands): Cast `char' array index to `unsigned char'. (reload_combine_note_store): Mark parameter `set' with ATTRIBUTE_UNUSED. Cast UNITS_PER_WORD to unsigned when comparing against one. (reload_cse_move2add): Remove unused variable `src2'. * sched.c: Include recog.h. (sched_note_set): Remove unused parameter `b'. All callers changed. (split_hard_reg_notes): Likewise for parameter `orig_insn'. (blockage_range): Cast result of UNIT_BLOCKED() macro to (int) when comparing against one. * stupid.c (stupid_find_reg): Mark parameter `changes_size' with ATTRIBUTE_UNUSED. Cast `sizeof' expression to (int) when comparing against one. * unroll.c (precondition_loop_p): Remove unused parameter `loop_end'. All callers changed. From-SVN: r23079
1998-10-14 11:02:55 +02:00
if ((HOST_WIDE_INT) (const_val & max_val)
!= (((HOST_WIDE_INT) 1
<< (GET_MODE_BITSIZE (GET_MODE (op0)) - 1))))
code = GT, op1 = GEN_INT (const_val - 1);
break;
1992-02-01 09:24:22 +01:00
case LEU:
if (uconst_val < max_val)
code = LTU, op1 = GEN_INT (uconst_val + 1);
break;
1992-02-01 09:24:22 +01:00
case GEU:
if (uconst_val != 0)
code = GTU, op1 = GEN_INT (uconst_val - 1);
break;
default:
break;
}
1992-02-01 09:24:22 +01:00
}
/* If this was floating-point and we reversed anything other than an
rtl.def: Add unordered fp comparisions. * rtl.def: Add unordered fp comparisions. * tree.def: Likewise. * tree.h: Add ISO C 9x unordered fp comparision builtins. * builtins.c (expand_tree_builtin): New function. * c-typeck.c (build_function_call): Use it. (build_binary_op): Support unordered compares. * c-common.c (c_common_nodes_and_builtins): Add unordered compares. * combine.c (known_cond): Handle reverse_condition returning UNKNOWN. (reversible_comparison_p): Allow UNORDERED/ORDERED to be reversed. * cse.c (fold_rtx): Check FLOAT_MODE_P before reversing. (record_jump_equiv): Handle reverse_condition returning UNKNOWN. * jump.c (reverse_condition): Don't abort for UNLE etc, but return UNKNOWN. (swap_condition): Handle unordered compares. (thread_jumps): Check can_reverse before reversing. * loop.c (get_condition): Likewise. Allow UNORERED/ORDERED to be reversed for FP. * optabs.c (can_compare_p): New argument CODE. Verify branch or setcc is present before acking for cmp_optab. Update all callers. (prepare_float_lib_cmp, init_optabs): Handle UNORDERED. * expmed.c (do_cmp_and_jump): Update for can_compare_p. * expr.c (expand_expr): Likewise. Support unordered compares. (do_jump, do_store_flag): Likewise. * expr.h (enum libfunc_index): Add unordered compares. * Makefile.in (FPBIT_FUNCS): Add _unord_sf. (DPBIT_FUNCS): Add _unord_df. * config/fp-bit.c (_unord_f2): New. * fp-test.c (main): Try unordered compare builtins. * alpha-protos.h (alpha_fp_comparison_operator): Declare. * alpha.c (alpha_comparison_operator): Check mode properly. (alpha_swapped_comparison_operator): Likewise. (signed_comparison_operator): Likewise. (alpha_fp_comparison_operator): New. (alpha_emit_conditional_branch): Handle unordered compares. * alpha.h (PREDICATE_CODES): Update. * alpha.md (fp compares): Use alpha_fp_comparison_operator. (bunordered, bordered): New. * cp/call.c (build_over_call): Use expand_tree_builtin. * cp/typeck.c (build_function_call_real): Likewise. (build_binary_op_nodefault): Handle unordered compares. * gcc.c-torture/execute/ieee/fp-cmp-4.c: New. From-SVN: r31591
2000-01-24 21:10:04 +01:00
EQ or NE or (UN)ORDERED, return zero. */
1992-02-01 09:24:22 +01:00
if (TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT
rtl.def: Add unordered fp comparisions. * rtl.def: Add unordered fp comparisions. * tree.def: Likewise. * tree.h: Add ISO C 9x unordered fp comparision builtins. * builtins.c (expand_tree_builtin): New function. * c-typeck.c (build_function_call): Use it. (build_binary_op): Support unordered compares. * c-common.c (c_common_nodes_and_builtins): Add unordered compares. * combine.c (known_cond): Handle reverse_condition returning UNKNOWN. (reversible_comparison_p): Allow UNORDERED/ORDERED to be reversed. * cse.c (fold_rtx): Check FLOAT_MODE_P before reversing. (record_jump_equiv): Handle reverse_condition returning UNKNOWN. * jump.c (reverse_condition): Don't abort for UNLE etc, but return UNKNOWN. (swap_condition): Handle unordered compares. (thread_jumps): Check can_reverse before reversing. * loop.c (get_condition): Likewise. Allow UNORERED/ORDERED to be reversed for FP. * optabs.c (can_compare_p): New argument CODE. Verify branch or setcc is present before acking for cmp_optab. Update all callers. (prepare_float_lib_cmp, init_optabs): Handle UNORDERED. * expmed.c (do_cmp_and_jump): Update for can_compare_p. * expr.c (expand_expr): Likewise. Support unordered compares. (do_jump, do_store_flag): Likewise. * expr.h (enum libfunc_index): Add unordered compares. * Makefile.in (FPBIT_FUNCS): Add _unord_sf. (DPBIT_FUNCS): Add _unord_df. * config/fp-bit.c (_unord_f2): New. * fp-test.c (main): Try unordered compare builtins. * alpha-protos.h (alpha_fp_comparison_operator): Declare. * alpha.c (alpha_comparison_operator): Check mode properly. (alpha_swapped_comparison_operator): Likewise. (signed_comparison_operator): Likewise. (alpha_fp_comparison_operator): New. (alpha_emit_conditional_branch): Handle unordered compares. * alpha.h (PREDICATE_CODES): Update. * alpha.md (fp compares): Use alpha_fp_comparison_operator. (bunordered, bordered): New. * cp/call.c (build_over_call): Use expand_tree_builtin. * cp/typeck.c (build_function_call_real): Likewise. (build_binary_op_nodefault): Handle unordered compares. * gcc.c-torture/execute/ieee/fp-cmp-4.c: New. From-SVN: r31591
2000-01-24 21:10:04 +01:00
&& did_reverse_condition
&& code != NE && code != EQ && code != UNORDERED && code != ORDERED
&& ! flag_fast_math
1992-02-01 09:24:22 +01:00
&& GET_MODE_CLASS (GET_MODE (op0)) == MODE_FLOAT)
return 0;
#ifdef HAVE_cc0
/* Never return CC0; return zero instead. */
if (op0 == cc0_rtx)
return 0;
#endif
return gen_rtx_fmt_ee (code, VOIDmode, op0, op1);
1992-02-01 09:24:22 +01:00
}
/* Given a jump insn JUMP, return the condition that will cause it to branch
to its JUMP_LABEL. If the condition cannot be understood, or is an
inequality floating-point comparison which needs to be reversed, 0 will
be returned.
If EARLIEST is non-zero, it is a pointer to a place where the earliest
insn used in locating the condition was found. If a replacement test
of the condition is desired, it should be placed in front of that
insn and we will be sure that the inputs are still valid. */
rtx
get_condition (jump, earliest)
rtx jump;
rtx *earliest;
{
rtx cond;
int reverse;
rtx set;
/* If this is not a standard conditional jump, we can't parse it. */
if (GET_CODE (jump) != JUMP_INSN
|| ! any_condjump_p (jump))
return 0;
set = pc_set (jump);
cond = XEXP (SET_SRC (set), 0);
/* If this branches to JUMP_LABEL when the condition is false, reverse
the condition. */
reverse
= GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF
&& XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (jump);
return canonicalize_condition (jump, cond, reverse, earliest, NULL_RTX);
}
1992-02-01 09:24:22 +01:00
/* Similar to above routine, except that we also put an invariant last
unless both operands are invariants. */
rtx
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
get_condition_for_loop (loop, x)
const struct loop *loop;
1992-02-01 09:24:22 +01:00
rtx x;
{
rtx comparison = get_condition (x, NULL_PTR);
1992-02-01 09:24:22 +01:00
if (comparison == 0
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
|| ! loop_invariant_p (loop, XEXP (comparison, 0))
|| loop_invariant_p (loop, XEXP (comparison, 1)))
1992-02-01 09:24:22 +01:00
return comparison;
return gen_rtx_fmt_ee (swap_condition (GET_CODE (comparison)), VOIDmode,
XEXP (comparison, 1), XEXP (comparison, 0));
1992-02-01 09:24:22 +01:00
}
/* Scan the function and determine whether it has indirect (computed) jumps.
This is taken mostly from flow.c; similar code exists elsewhere
in the compiler. It may be useful to put this into rtlanal.c. */
static int
indirect_jump_in_function_p (start)
rtx start;
{
rtx insn;
for (insn = start; insn; insn = NEXT_INSN (insn))
if (computed_jump_p (insn))
return 1;
return 0;
}
1998-08-19 14:30:47 +02:00
/* Add MEM to the LOOP_MEMS array, if appropriate. See the
documentation for LOOP_MEMS for the definition of `appropriate'.
This function is called from prescan_loop via for_each_rtx. */
static int
insert_loop_mem (mem, data)
rtx *mem;
Warning fixes: * Makefile.in (sched.o): Depend on recog.h. * alias.c (REG_BASE_VALUE): Cast the result of REGNO() macro to (unsigned) when comparing against one. (find_base_value): Likewise. (record_base_value): Cast variable `regno' to (unsigned) when comparing against one. Cast the result of REGNO() macro to (unsigned) when comparing against one. (memrefs_conflict_p): Change type of variables `r_x' and `r_y' to unsigned. (init_alias_analysis): Add unsigned variable `ui'. Use it as loop variable where an unsigned index is needed. * caller-save.c (init_caller_save): Cast `-1' to (enum insn_code) before comparing against one. * collect2.c: Add prototypes for functions `error', `fatal' and `fatal_perror'. Make these functions take variable arguments instead of faking it with a fixed number of args. (write_c_file_stat): Cast the argument of ctype macro to (unsigned char). * combine.c (can_combine_p): Mark parameter `pred' with ATTRIBUTE_UNUSED. (find_split_point): Cast variable `src' to (unsigned HOST_WIDE_INT) when comparing against one. HOST_WIDE_INT) when comparing against one. (simplify_rtx): Cast 1 to (unsigned HOST_WIDE_INT) in shift. (simplify_logical): Likewise. (force_to_mode): Cast result of INTVAL() macro to (unsigned HOST_WIDE_INT) when comparing against one. Cast 1 to (unsigned HOST_WIDE_INT) in shift. (simplify_and_const_int): Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (merge_outer_ops): Cast variable const0 to `unsigned HOST_WIDE_INT' when comparing against the result of GET_MODE_MASK() macro. (simplify_comparison): Likewise for variable `c0'. Cast variable `const_op' to `unsigned HOST_WIDE_INT' when comparing against one. Cast `1' to `unsigned HOST_WIDE_INT' in shift. Cast the result of `GET_MODE_MASK()/2' to `HOST_WIDE_INT' when comparing against one. Cast `1' to `unsigned HOST_WIDE_INT' in shift. Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (distribute_notes): Wrap variable `cc0_setter' in macro `HAVE_cc0'. config/mips/mips.c (gen_int_relational): Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (output_block_move): Cast `sizeof' expression to (int) when comparing against one. (function_arg): Cast BITS_PER_WORD to `unsigned' when comparing against one. (save_restore_insns): Cast `base_offset' to `long' to match format specifier in fprintf. * config/mips/mips.h (Pmode): Cast the result of `Pmode' macro to `enum machine_mode'. * flow.c (life_analysis_1): Remove unused variable `insn'. * gcc.c (translate_options): Move variables `j' and `k' into the scope in which they are used. Change their types to `size_t'. (set_spec): Cast the argument of ctype macro to `unsigned char'. (read_specs): Likewise. (process_command): Cast `sizeof' to (int) when comparing against one. (do_spec_1): Cast the argument of ctype macro to `unsigned char'. (handle_braces): Cast both sides of `==' expression to `long' to ensure sign matching. (main): Cast variable `i' to `int' when comparing against one. * gcov-io.h (__fetch_long): Change type of parameter `bytes' from int to size_t. Cast variable `i' to size_t when comparing against one. * genattrtab.c (convert_set_attr_alternative): Remove unused parameter `insn_code'. All callers changed. (convert_set_attr): Likewise. * genrecog.c (add_to_sequence): Cast result of XVECLEN() macro to size_t when comparing against one. Likewise for variable `len'. * global.c (global_alloc): Cast variable `max_regno' to size_t when comparing against one. Likewise for variable `max_allocno'. * jump.c (sets_cc0_p): Mark parameter `x' with ATTRIBUTE_UNUSED. * local-alloc.c (validate_equiv_mem_from_store): Mark parameter `set' with ATTRIBUTE_UNUSED. (find_free_reg): Cast `sizeof' expression to (int) when comparing against one. * loop.c (count_loop_regs_set): Remove unused variable `dest'. (strength_reduce): Mark parameter `bct_p' with ATTRIBUTE_UNUSED. (get_condition): Cast variable `const_val' to `unsigned HOST_WIDE_INT' when comparing against one. Cast unsigned expression to HOST_WIDE_INT when comparing against one. (insert_loop_mem): Mark parameter `data' with ATTRIBUTE_UNUSED. (load_mems_and_recount_loop_regs_set): Cast variable `nregs' to `unsigned' when comparing against one. * protoize.c (is_id_char): Change type of parameter `ch' to unsigned char. (munge_compile_params): Cast argument of ctype macro to (const unsigned char). (process_aux_info_file): Cast variable `aux_info_size' to int when comparing against one. (forward_to_next_token_char): Cast argument of ctype macro to `const unsigned char'. (edit_formals_lists): Likewise. (find_rightmost_formals_list): Likewise. (add_local_decl): Likewise. (add_global_decls): Likewise. (edit_fn_definition): Likewise. (do_cleaning): Likewise. (scan_for_missed_items): Likewise. (edit_file): Cast variable `orig_size' to (int) when comparing against one. (main): Cast argument of ctype macro to `const unsigned char'. * recog.c (const_int_operand): Mark parameter `mode' with ATTRIBUTE_UNUSED. * regclass.c (record_reg_classes): Change type of variable `c' to `unsigned char'. Cast `char' array index to `unsigned char'. * reload.c (push_secondary_reload): Cast argument to REG_CLASS_FROM_LETTER() macro to `unsigned char'. * reload1.c (calculate_needs): Cast `char' array index to `unsigned char'. (set_label_offsets): Change type of variable `i' to unsigned int. Cast result of XVECLEN() macro to unsigned when comparing against one. (mark_not_eliminable): Change type of variable `i' to unsigned. (order_regs_for_reload): Likewise. Cast `max_regno' to unsigned when comparing against one. (reload_as_needed): Cast macro NUM_ELIMINABLE_REGS to (int) when comparing against one. (choose_reload_regs): Hide unused label `fail'. (reload_cse_simplify_operands): Cast `char' array index to `unsigned char'. (reload_combine_note_store): Mark parameter `set' with ATTRIBUTE_UNUSED. Cast UNITS_PER_WORD to unsigned when comparing against one. (reload_cse_move2add): Remove unused variable `src2'. * sched.c: Include recog.h. (sched_note_set): Remove unused parameter `b'. All callers changed. (split_hard_reg_notes): Likewise for parameter `orig_insn'. (blockage_range): Cast result of UNIT_BLOCKED() macro to (int) when comparing against one. * stupid.c (stupid_find_reg): Mark parameter `changes_size' with ATTRIBUTE_UNUSED. Cast `sizeof' expression to (int) when comparing against one. * unroll.c (precondition_loop_p): Remove unused parameter `loop_end'. All callers changed. From-SVN: r23079
1998-10-14 11:02:55 +02:00
void *data ATTRIBUTE_UNUSED;
1998-08-19 14:30:47 +02:00
{
struct loop_info *loop_info = data;
1998-08-19 14:30:47 +02:00
int i;
rtx m = *mem;
if (m == NULL_RTX)
return 0;
switch (GET_CODE (m))
{
case MEM:
break;
case CLOBBER:
/* We're not interested in MEMs that are only clobbered. */
return -1;
1998-08-19 14:30:47 +02:00
case CONST_DOUBLE:
/* We're not interested in the MEM associated with a
CONST_DOUBLE, so there's no need to traverse into this. */
return -1;
case EXPR_LIST:
/* We're not interested in any MEMs that only appear in notes. */
return -1;
1998-08-19 14:30:47 +02:00
default:
/* This is not a MEM. */
return 0;
}
/* See if we've already seen this MEM. */
for (i = 0; i < loop_info->mems_idx; ++i)
if (rtx_equal_p (m, loop_info->mems[i].mem))
1998-08-19 14:30:47 +02:00
{
if (GET_MODE (m) != GET_MODE (loop_info->mems[i].mem))
1998-08-19 14:30:47 +02:00
/* The modes of the two memory accesses are different. If
this happens, something tricky is going on, and we just
don't optimize accesses to this MEM. */
loop_info->mems[i].optimize = 0;
1998-08-19 14:30:47 +02:00
return 0;
}
/* Resize the array, if necessary. */
if (loop_info->mems_idx == loop_info->mems_allocated)
1998-08-19 14:30:47 +02:00
{
if (loop_info->mems_allocated != 0)
loop_info->mems_allocated *= 2;
1998-08-19 14:30:47 +02:00
else
loop_info->mems_allocated = 32;
1998-08-19 14:30:47 +02:00
loop_info->mems = (loop_mem_info *)
xrealloc (loop_info->mems,
loop_info->mems_allocated * sizeof (loop_mem_info));
1998-08-19 14:30:47 +02:00
}
/* Actually insert the MEM. */
loop_info->mems[loop_info->mems_idx].mem = m;
1998-08-19 14:30:47 +02:00
/* We can't hoist this MEM out of the loop if it's a BLKmode MEM
because we can't put it in a register. We still store it in the
table, though, so that if we see the same address later, but in a
non-BLK mode, we'll not think we can optimize it at that point. */
loop_info->mems[loop_info->mems_idx].optimize = (GET_MODE (m) != BLKmode);
loop_info->mems[loop_info->mems_idx].reg = NULL_RTX;
++loop_info->mems_idx;
return 0;
1998-08-19 14:30:47 +02:00
}
/* Like load_mems, but also ensures that REGS->SET_IN_LOOP,
REGS->MAY_NOT_OPTIMIZE, REGS->SINGLE_USAGE, and INSN_COUNT have the correct
1998-08-19 14:30:47 +02:00
values after load_mems. */
static void
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
load_mems_and_recount_loop_regs_set (loop, insn_count)
const struct loop *loop;
1998-08-19 14:30:47 +02:00
int *insn_count;
{
struct loop_regs *regs = LOOP_REGS (loop);
1998-08-19 14:30:47 +02:00
int nregs = max_reg_num ();
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
load_mems (loop);
/* Recalculate regs->set_in_loop and friends since load_mems may have
1998-08-19 14:30:47 +02:00
created new registers. */
if (max_reg_num () > nregs)
{
int i;
int old_nregs;
old_nregs = nregs;
nregs = max_reg_num ();
if ((unsigned) nregs > regs->set_in_loop->num_elements)
{
/* Grow all the arrays. */
VARRAY_GROW (regs->set_in_loop, nregs);
VARRAY_GROW (regs->n_times_set, nregs);
VARRAY_GROW (regs->may_not_optimize, nregs);
VARRAY_GROW (regs->single_usage, nregs);
}
/* Clear the arrays */
alias.c [...] (init_alias_analysis, [...]): Use memset () instead of bzero (). * alias.c (init_alias_analysis), calls.c (expand_call, emit_library_call_value_1), combine.c (init_reg_last_arrays), cse.c (new_basic_block), dbxout.c (dbxout_type), diagnostic.c (init_output_buffer, set_diagnostic_context), dwarf2out.c (equate_decl_number_to_die, build_abbrev_table), emit-rtl.c (init_emit_once), fold-const.c (mul_double, div_and_round_double), function.c (assign_parms), gcse.c (compute_can_copy, alloc_gcse_mem, alloc_reg_set_mem, record_one_set, compute_hash_table, compute_set_hash_table, compute_expr_hash_table), genattrtab.c (optimize_attrs), global.c (global_alloc, global_conflicts), haifa-sched.c (compute_trg_info, clear_units, schedule_block), integrate.c (initialize_for_inline, expand_inline_function), jump.c (thread_jumps), local-alloc.c (local_alloc), loop.c (combine_movables, count_loop_regs_set, load_mems_and_recount_loop_regs_set), print-tree.c (debug_tree), regclass.c (init_reg_sets, init_reg_sets_1, regclass, record_reg_classes, allocate_reg_info), reload.c (get_secondary_mem, remove_address_replacements, find_reloads), reload1.c (reload, set_initial_label_offsets, finish_spills, reload_as_needed, choose_reload_regs_init, reload_cse_simplify_operands), reorg.c (dbr_schedule), sbitmap.c (sbitmap_zero), simplify-rtx.c (simplify_plus_minus), ssa.c (rename_registers), stmt.c (expand_end_case), unroll.c (unroll_loop), varray.c (varray_grow), objc/objc-act.c: Use memset () instead of bzero (). ch: * actions.c (check_missing_cases), typeck.c (build_chill_slice, build_chill_cast): Use memset () instead of bzero (). cp: * class.c (duplicate_tag_error, build_vtbl_initializer), decl.c (push_binding_level), error.c (cp_tree_printer), pt.c (process_partial_specialization, tsubst_template_arg_vector), search.c (lookup_member): Use memset () instead of bzero (). java: * expr.c (note_instructions), jcf-io.c (find_class), jcf-parse.c (init_outgoing_cpool), lex.c (java_init_lex): Use memset () instead of bzero (). From-SVN: r37303
2000-11-07 23:50:06 +01:00
memset ((char *) &regs->set_in_loop->data, 0, nregs * sizeof (int));
memset ((char *) &regs->may_not_optimize->data, 0, nregs * sizeof (char));
memset ((char *) &regs->single_usage->data, 0, nregs * sizeof (rtx));
1998-08-19 14:30:47 +02:00
count_loop_regs_set (loop, regs->may_not_optimize, regs->single_usage,
insn_count, nregs);
1998-08-19 14:30:47 +02:00
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
{
VARRAY_CHAR (regs->may_not_optimize, i) = 1;
VARRAY_INT (regs->set_in_loop, i) = 1;
}
#ifdef AVOID_CCMODE_COPIES
/* Don't try to move insns which set CC registers if we should not
create CCmode register copies. */
for (i = max_reg_num () - 1; i >= FIRST_PSEUDO_REGISTER; i--)
if (GET_MODE_CLASS (GET_MODE (regno_reg_rtx[i])) == MODE_CC)
VARRAY_CHAR (regs->may_not_optimize, i) = 1;
#endif
/* Set regs->n_times_set for the new registers. */
bcopy ((char *) (&regs->set_in_loop->data.i[0] + old_nregs),
(char *) (&regs->n_times_set->data.i[0] + old_nregs),
1998-08-19 14:30:47 +02:00
(nregs - old_nregs) * sizeof (int));
}
}
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
/* Move MEMs into registers for the duration of the loop. */
1998-08-19 14:30:47 +02:00
static void
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
load_mems (loop)
const struct loop *loop;
1998-08-19 14:30:47 +02:00
{
struct loop_info *loop_info = LOOP_INFO (loop);
struct loop_regs *regs = LOOP_REGS (loop);
1998-08-19 14:30:47 +02:00
int maybe_never = 0;
int i;
rtx p;
rtx label = NULL_RTX;
rtx end_label;
/* Nonzero if the next instruction may never be executed. */
int next_maybe_never = 0;
int last_max_reg = max_reg_num ();
1998-08-19 14:30:47 +02:00
if (loop_info->mems_idx == 0)
return;
1998-08-19 14:30:47 +02:00
/* We cannot use next_label here because it skips over normal insns. */
end_label = next_nonnote_insn (loop->end);
if (end_label && GET_CODE (end_label) != CODE_LABEL)
end_label = NULL_RTX;
/* Check to see if it's possible that some instructions in the loop are
never executed. Also check if there is a goto out of the loop other
than right after the end of the loop. */
for (p = next_insn_in_loop (loop, loop->scan_start);
p != NULL_RTX && ! maybe_never;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
p = next_insn_in_loop (loop, p))
{
if (GET_CODE (p) == CODE_LABEL)
maybe_never = 1;
else if (GET_CODE (p) == JUMP_INSN
/* If we enter the loop in the middle, and scan
around to the beginning, don't set maybe_never
for that. This must be an unconditional jump,
otherwise the code at the top of the loop might
never be executed. Unconditional jumps are
followed a by barrier then loop end. */
&& ! (GET_CODE (p) == JUMP_INSN
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
&& JUMP_LABEL (p) == loop->top
&& NEXT_INSN (NEXT_INSN (p)) == loop->end
&& any_uncondjump_p (p)))
1998-08-19 14:30:47 +02:00
{
/* If this is a jump outside of the loop but not right
after the end of the loop, we would have to emit new fixup
sequences for each such label. */
if (JUMP_LABEL (p) != end_label
&& (INSN_UID (JUMP_LABEL (p)) >= max_uid_for_loop
|| INSN_LUID (JUMP_LABEL (p)) < INSN_LUID (loop->start)
|| INSN_LUID (JUMP_LABEL (p)) > INSN_LUID (loop->end)))
return;
if (!any_condjump_p (p))
/* Something complicated. */
1998-08-19 14:30:47 +02:00
maybe_never = 1;
else
/* If there are any more instructions in the loop, they
might not be reached. */
next_maybe_never = 1;
}
else if (next_maybe_never)
maybe_never = 1;
}
/* Find start of the extended basic block that enters the loop. */
for (p = loop->start;
PREV_INSN (p) && GET_CODE (p) != CODE_LABEL;
p = PREV_INSN (p))
;
cselib_init ();
/* Build table of mems that get set to constant values before the
loop. */
for (; p != loop->start; p = NEXT_INSN (p))
cselib_process_insn (p);
/* Actually move the MEMs. */
for (i = 0; i < loop_info->mems_idx; ++i)
{
regset_head load_copies;
regset_head store_copies;
int written = 0;
rtx reg;
rtx mem = loop_info->mems[i].mem;
rtx mem_list_entry;
1998-08-19 14:30:47 +02:00
if (MEM_VOLATILE_P (mem)
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
|| loop_invariant_p (loop, XEXP (mem, 0)) != 1)
/* There's no telling whether or not MEM is modified. */
loop_info->mems[i].optimize = 0;
/* Go through the MEMs written to in the loop to see if this
one is aliased by one of them. */
mem_list_entry = loop_info->store_mems;
while (mem_list_entry)
1998-08-19 14:30:47 +02:00
{
if (rtx_equal_p (mem, XEXP (mem_list_entry, 0)))
written = 1;
else if (true_dependence (XEXP (mem_list_entry, 0), VOIDmode,
mem, rtx_varies_p))
1998-08-19 14:30:47 +02:00
{
/* MEM is indeed aliased by this store. */
loop_info->mems[i].optimize = 0;
break;
1998-08-19 14:30:47 +02:00
}
mem_list_entry = XEXP (mem_list_entry, 1);
}
if (flag_float_store && written
&& GET_MODE_CLASS (GET_MODE (mem)) == MODE_FLOAT)
loop_info->mems[i].optimize = 0;
/* If this MEM is written to, we must be sure that there
are no reads from another MEM that aliases this one. */
if (loop_info->mems[i].optimize && written)
{
int j;
1998-08-19 14:30:47 +02:00
for (j = 0; j < loop_info->mems_idx; ++j)
{
if (j == i)
continue;
else if (true_dependence (mem,
VOIDmode,
loop_info->mems[j].mem,
rtx_varies_p))
1998-08-19 14:30:47 +02:00
{
/* It's not safe to hoist loop_info->mems[i] out of
the loop because writes to it might not be
seen by reads from loop_info->mems[j]. */
loop_info->mems[i].optimize = 0;
break;
1998-08-19 14:30:47 +02:00
}
}
}
1998-08-19 14:30:47 +02:00
if (maybe_never && may_trap_p (mem))
/* We can't access the MEM outside the loop; it might
cause a trap that wouldn't have happened otherwise. */
loop_info->mems[i].optimize = 0;
if (!loop_info->mems[i].optimize)
/* We thought we were going to lift this MEM out of the
loop, but later discovered that we could not. */
continue;
1998-08-19 14:30:47 +02:00
INIT_REG_SET (&load_copies);
INIT_REG_SET (&store_copies);
/* Allocate a pseudo for this MEM. We set REG_USERVAR_P in
order to keep scan_loop from moving stores to this MEM
out of the loop just because this REG is neither a
user-variable nor used in the loop test. */
reg = gen_reg_rtx (GET_MODE (mem));
REG_USERVAR_P (reg) = 1;
loop_info->mems[i].reg = reg;
/* Now, replace all references to the MEM with the
corresponding pesudos. */
maybe_never = 0;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (p = next_insn_in_loop (loop, loop->scan_start);
p != NULL_RTX;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
p = next_insn_in_loop (loop, p))
{
alias.c (mark_constant_function): Use INSN_P. * alias.c (mark_constant_function): Use INSN_P. (init_alias_analysis): Likewise. * combine.c (combine_instructions): Use INSN_P. (can_combine_p): Likewise. (try_combine): Likewise. (distribute_notes): Likewise. (distribute_links): Likewise. * cse.c (cse_around_loop): Use INSN_P. (invalidate_skipped_block): Likewise. (cse_set_around_loop): Likewise. (cse_end_of_basic_block): Likewise. (delete_trivially_dead_insns): Likewise. * emit-rtl.c (unshare_all_rtl_again): Use INSN_P. (unshare_all_rtl_1): Likewise. (next_cc0_user): Likewise. (try_split make_insn_raw): Likewise. (remove_unnecessary_notes): Likewise. * final.c (shorten_branches): Use INSN_P. (leaf_renumber_regs): Likewise. (leaf_renumber_regs_insn): Likewise. * flow.c (find_label_refs): Use INSN_P. (verify_wide_reg): Likewise. (notice_stack_pointer_modification): Likewise. (count_or_remove_death_notes): Likewise. (verify_flow_info): Likewise. (clear_log_links): Likewise. * function.c (fixup_var_refs_insns): Use INSN_P. (compute_insns_for_mem): Likewise. * gcse.c (alloc_gcse_mem): Use INSN_P. (compute_sets): Likewise. (compute_hash_table): Likewise. (classic_gcse): Likewise. (cprop): Likewise. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks_1): Likewise. * global.c (expand_preferences): Use INSN_P. (build_insn_chain): Likewise. * graph.c (node_data): Use INSN_P. * haifa-sched.c (priority): Use INSN_P. (rm_line_notes): Likewise. (rm_other_notes): Likewise. (find_insn_reg_weight): Likewise. (init_target_units): Likewise. (schedule_block): Likewise. (compute_block_forward_dependences): Likewise. (debug_dependencies): Likewise. (set_priorities): Likewise. * integrate.c (function_cannot_inline_p): Use INSN_P. (save_parm_insns): Likewise. (copy_insn_list): Likewise. * jump.c (mark_all_labels): Use INSN_P. (never_reached_warning): Likewise. * lcm.c (optimize_mode_switching): Use INSN_P. * local-alloc.c (validate_equiv_mem): Use INSN_P. (memref_used_between_p): Likewise. (update_equiv_regs): Likewise. (block_alloc): Likewise. (no_conflict_p): Likewise. * loop.c (scan_loop): Use INSN_P. (find_and_verify_loops): Likewise. (count_loop_regs_set): Likewise. (loop_reg_used_before_p): Likewise. (strength_reduce): Likewise. (recombine_givs): Likewise. (check_dbra_loop): Likewise. (load_mems): Likewise. (try_copy_prop): Likewise. * print-rtl.c (print_rtx): Use INSN_P. * recog.c (find_single_use): Use INSN_P. * reg-stack.c (stack_regs_mentioned): Use INSN_P. (next_flags_user): Likewise. (swap_rtx_condition): Likewise. * regmove.c (mark_flags_life_zones): Use INSN_P. (optimize_reg_copy_1): Likewise. (optimize_reg_copy_2): Likewise. (optimize_reg_copy_3): Likewise. (reg_is_remote_constant_p): Likewise. (fixup_match_2): Likewise. (regmove_optimize): Likewise. (fixup_match_1): Likewise. * regrename.c (build_def_use): Use INSN_P. (replace_reg_in_block): Likewise. (consider_use): Likewise. * reload.c (find_equiv_reg): Use INSN_P. * reload1.c (reload): Use INSN_P. (maybe_fix_stack_asms): Likewise. (calculate_needs_all_insns): Likewise. (reload_as_needed): Likewise. (emit_output_reload_insns): Likewise. (delete_address_reloads_1): Likewise. (reload_cse_regs_1): Likewise. (reload_combine): Likewise. (reload_cse_move2add): Likewise. * reorg.c (redundant_insn): Use INSN_P. (dbr_schedule): Likewise. * resource.c (find_dead_or_set_registers): Use INSN_P. (mark_target_live_regs): Likewise. * rtlanal.c (reg_used_between_p): Use INSN_P. (reg_referenced_between_p): Likewise. (reg_set_between_p): Likewise. (reg_set_p): Likewise. (single_set): Likewise. (multiple_sets): Likewise. (find_last_value): Likewise. (reg_set_last): Likewise. (find_reg_note): Likewise. (find_regno_note): Likewise. * sibcall.c (sequence_uses_addressof): Use INSN_P. * simplify-rtx.c (cselib_process_insn): Use INSN_P. * ssa.c (find_evaluations): Use INSN_P. (rename_block): Likewise. (rename_equivalent_regs): Likewise. * unroll.c (loop_find_equiv_value): Use INSN_P. (set_dominates_use): Likewise. * varasm.c (mark_constant_pool): Use INSN_P. (mark_constants): Likewise. * config/alpha/alpha.c (alpha_does_function_need_gp): Use INSN_P. (alphaev4_next_group): Likewise. (alphaev5_next_group): Likewise. * config/c4x/c4x.c (c4x_process_after_reload): Use INSN_P. (c4x_rptb_rpts_p): Likewise. * config/mips/mips.c (mips16_optimize_gp): Use INSN_P. * config/rs6000/rs6000.c (uses_TOC): Use INSN_P. (rs6000_adjust_priority): Likewise. * config/sh/sh.c (sh_loop_align): Use INSN_P. (machine_dependent_reorg): Likewise. (split_branches): Likewise. * config/tahoe/tahoe.c (tahoe_cmp_check): Use INSN_P. From-SVN: r35494
2000-08-04 22:28:08 +02:00
if (INSN_P (p))
{
rtx set;
set = single_set (p);
/* See if this copies the mem into a register that isn't
modified afterwards. We'll try to do copy propagation
a little further on. */
if (set
/* @@@ This test is _way_ too conservative. */
&& ! maybe_never
&& GET_CODE (SET_DEST (set)) == REG
&& REGNO (SET_DEST (set)) >= FIRST_PSEUDO_REGISTER
&& REGNO (SET_DEST (set)) < last_max_reg
&& VARRAY_INT (regs->n_times_set,
REGNO (SET_DEST (set))) == 1
&& rtx_equal_p (SET_SRC (set), mem))
SET_REGNO_REG_SET (&load_copies, REGNO (SET_DEST (set)));
/* See if this copies the mem from a register that isn't
modified afterwards. We'll try to remove the
redundant copy later on by doing a little register
renaming and copy propagation. This will help
to untangle things for the BIV detection code. */
if (set
&& ! maybe_never
&& GET_CODE (SET_SRC (set)) == REG
&& REGNO (SET_SRC (set)) >= FIRST_PSEUDO_REGISTER
&& REGNO (SET_SRC (set)) < last_max_reg
&& VARRAY_INT (regs->n_times_set, REGNO (SET_SRC (set))) == 1
&& rtx_equal_p (SET_DEST (set), mem))
SET_REGNO_REG_SET (&store_copies, REGNO (SET_SRC (set)));
/* Replace the memory reference with the shadow register. */
replace_loop_mems (p, loop_info->mems[i].mem,
loop_info->mems[i].reg);
}
if (GET_CODE (p) == CODE_LABEL
|| GET_CODE (p) == JUMP_INSN)
maybe_never = 1;
}
1998-08-19 14:30:47 +02:00
if (! apply_change_group ())
/* We couldn't replace all occurrences of the MEM. */
loop_info->mems[i].optimize = 0;
else
{
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
/* Load the memory immediately before LOOP->START, which is
the NOTE_LOOP_BEG. */
cselib_val *e = cselib_lookup (mem, VOIDmode, 0);
rtx set;
rtx best = mem;
int j;
struct elt_loc_list *const_equiv = 0;
if (e)
{
struct elt_loc_list *equiv;
struct elt_loc_list *best_equiv = 0;
for (equiv = e->locs; equiv; equiv = equiv->next)
{
if (CONSTANT_P (equiv->loc))
const_equiv = equiv;
else if (GET_CODE (equiv->loc) == REG
/* Extending hard register lifetimes cuases crash
on SRC targets. Doing so on non-SRC is
probably also not good idea, since we most
probably have pseudoregister equivalence as
well. */
&& REGNO (equiv->loc) >= FIRST_PSEUDO_REGISTER)
best_equiv = equiv;
}
/* Use the constant equivalence if that is cheap enough. */
if (! best_equiv)
best_equiv = const_equiv;
else if (const_equiv
&& (rtx_cost (const_equiv->loc, SET)
<= rtx_cost (best_equiv->loc, SET)))
{
best_equiv = const_equiv;
const_equiv = 0;
}
/* If best_equiv is nonzero, we know that MEM is set to a
constant or register before the loop. We will use this
knowledge to initialize the shadow register with that
constant or reg rather than by loading from MEM. */
if (best_equiv)
best = copy_rtx (best_equiv->loc);
}
set = gen_move_insn (reg, best);
set = emit_insn_before (set, loop->start);
if (const_equiv)
REG_NOTES (set) = gen_rtx_EXPR_LIST (REG_EQUAL,
copy_rtx (const_equiv->loc),
REG_NOTES (set));
1998-08-19 14:30:47 +02:00
if (written)
{
if (label == NULL_RTX)
1998-08-19 14:30:47 +02:00
{
label = gen_label_rtx ();
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
emit_label_after (label, loop->end);
1998-08-19 14:30:47 +02:00
}
/* Store the memory immediately after END, which is
the NOTE_LOOP_END. */
set = gen_move_insn (copy_rtx (mem), reg);
emit_insn_after (set, label);
}
if (loop_dump_stream)
{
fprintf (loop_dump_stream, "Hoisted regno %d %s from ",
REGNO (reg), (written ? "r/w" : "r/o"));
print_rtl (loop_dump_stream, mem);
fputc ('\n', loop_dump_stream);
1998-08-19 14:30:47 +02:00
}
/* Attempt a bit of copy propagation. This helps untangle the
data flow, and enables {basic,general}_induction_var to find
more bivs/givs. */
EXECUTE_IF_SET_IN_REG_SET
(&load_copies, FIRST_PSEUDO_REGISTER, j,
{
try_copy_prop (loop, reg, j);
});
CLEAR_REG_SET (&load_copies);
EXECUTE_IF_SET_IN_REG_SET
(&store_copies, FIRST_PSEUDO_REGISTER, j,
{
try_swap_copy_prop (loop, reg, j);
});
CLEAR_REG_SET (&store_copies);
1998-08-19 14:30:47 +02:00
}
}
if (label != NULL_RTX && end_label != NULL_RTX)
1998-08-19 14:30:47 +02:00
{
/* Now, we need to replace all references to the previous exit
label with the new one. */
rtx_pair rr;
rr.r1 = end_label;
rr.r2 = label;
1998-08-19 14:30:47 +02:00
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (p = loop->start; p != loop->end; p = NEXT_INSN (p))
{
for_each_rtx (&p, replace_label, &rr);
/* If this is a JUMP_INSN, then we also need to fix the JUMP_LABEL
field. This is not handled by for_each_rtx because it doesn't
handle unprinted ('0') fields. We need to update JUMP_LABEL
because the immediately following unroll pass will use it.
replace_label would not work anyways, because that only handles
LABEL_REFs. */
if (GET_CODE (p) == JUMP_INSN && JUMP_LABEL (p) == end_label)
JUMP_LABEL (p) = label;
}
1998-08-19 14:30:47 +02:00
}
cselib_finish ();
1998-08-19 14:30:47 +02:00
}
/* For communication between note_reg_stored and its caller. */
struct note_reg_stored_arg
{
int set_seen;
rtx reg;
};
/* Called via note_stores, record in SET_SEEN whether X, which is written,
is equal to ARG. */
static void
note_reg_stored (x, setter, arg)
Makefile.in (toplev.o): Depend on loop.h. * Makefile.in (toplev.o): Depend on loop.h. * dwarfout.c: Include tm_p.h. * emit-rtl.c (restore_emit_status): Mark parameter with ATTRIBUTE_UNUSED. * final.c (final_scan_insn): Likewise. * flow.c (flow_nodes_print, flow_exits_print, flow_loops_cfg_dump, flow_loop_nested_p, flow_loop_exits_find, flow_loop_nodes_find, flow_depth_first_order_compute, flow_loop_pre_header_find, flow_loop_tree_node_add, flow_loops_tree_build, flow_loop_level_compute, flow_loops_level_compute, flow_loop_outside_edge_p): Add prototypes. (recompute_reg_usage): Mark parameters with ATTRIBUTE_UNUSED. * ggc-callbacks.c (lang_mark_tree, lang_mark_false_label_stack): Mark with ATTRIBUTE_NORETURN. * hash.c (hash_newfunc): Mark parameter with ATTRIBUTE_UNUSED. * local-alloc.c (no_conflict_p): Likewise. * loop.c (insert_bct): Hide definitions of variables with hidden usage. (note_reg_stored): Mark parameter with ATTRIBUTE_UNUSED. * regclass.c (memory_move_secondary_cost): Mark variable `mem' with ATTRIBUTE_UNUSED. (record_reg_classes): Mark parameter with ATTRIBUTE_UNUSED. (reg_scan): Likewise. * reload.c (find_reloads): Remove unused variables `changed'. * reload1.c (reload_reg_class_lower): Don't unnecessarily cast away const-ness. (allocate_reload_reg): Mark parameter with ATTRIBUTE_UNUSED. Remove unused variable `insn'. * toplev.c: Include loop.h. (report_file_and_line): Remove unnecessary prototype. * tree.c (build_block): Mark parameter with ATTRIBUTE_UNUSED. * unroll.c (biv_total_increment): Likewise. From-SVN: r31085
1999-12-24 15:04:54 +01:00
rtx x, setter ATTRIBUTE_UNUSED;
void *arg;
{
struct note_reg_stored_arg *t = (struct note_reg_stored_arg *) arg;
if (t->reg == x)
t->set_seen = 1;
}
/* Try to replace every occurrence of pseudo REGNO with REPLACEMENT.
There must be exactly one insn that sets this pseudo; it will be
deleted if all replacements succeed and we can prove that the register
loop.c (current_loop_info): Delete. 2000-01-26 Michael Hayes <m.hayes@elec.canterbury.ac.nz> * loop.c (current_loop_info): Delete. (consec_sets_invariant_p): Add loop argument, update callers. (get_condition_for_loop): Likewise. (count_nonfixed_reads, update_giv_derive): Likewise. (simplify_giv_expr, general_induction_var): Likewise. (consec_sets_giv, recombine_givs): Likewise. (move_movables): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_mem_givs, check_final_value): Likewise. (record_giv, maybe_eliminate_biv, maybe_eliminate_biv_1): Likewise. (loop_invariant_p): Rename from invariant_p, add loop argument, and update callers. (basic_induction_var): Add loop argument, delete loop_level argument, and update callers. * unroll.c (iteration_info): Delete loop_start and loop_end arguments, add loop argument, and update callers. (find_splittable_regs, find_splittable_givs): Likewise. (reg_dead_after_loop, loop_find_equiv_value): Likewise. (final_biv_value, final_giv_value, back_branch_in_range_p): Likewise. (biv_total_increment): Delete loop_start and loop_end arguments; update callers. (precondition_loop_p): Delete loop_start and loop_info arguments; update callers. * loop.h (get_condition_for_loop): Add loop argument. (biv_total_increment): Delete loop_start and loop_end arguments. (precondition_loop_p): Delete loop_start and loop_info arguments; add loop argument. (final_biv_value): Delete loop_start and loop_end arguments; add loop argument. (final_giv_value, back_branch_in_range_p): Likewise. From-SVN: r31618
2000-01-25 23:49:56 +01:00
is not used after the loop. */
* Rework fields used to describe positions of bitfields and modify sizes to be unsigned and use HOST_WIDE_INT. * alias.c (reg_known_value_size): Now unsigned. * c-typeck.c (build_unary_op, case ADDR_EXPR): Use byte_position. (really_start_incremental_init): Use bitsize_zero_node. (push_init_level, pop_init_level, output_init_element): Likewise. Use bitsize_unit_node and bitsize_one_node. (output_pending_init_elements, process_init_element): Likewise. * combine.c (combine_max_regno, reg_sign_bit_copies): Now unsigned. (make_extraction): Position and length HOST_WIDE_INT and unsigned HOST_WIDE_INT, respectively. (get_pos_from_mask): Passed in value is unsigned HOST_WIDE_INT. (num_sign_bit_copies): Returns unsigned. BITWIDTH now unsigned; rework arithmetic. Remove recursive call from arg to MAX. (combine_instructions, init_reg_last_arrays): NREGS now unsigned. (setup_incoming_promotions, can_combine_p, try_combine, simplify_set): REGNO now unsigned. (set_nonzero_bit_and_sign_copies): NUM now unsigned. (find_split_point, expand_compound_operation, make_extraction): LEN now unsigned HOST_WIDE_INT, POS now HOST_WIDE_INT. (make_field_assignment): Likewise. (combine_simplify_rtx): Add cast. (expand_compound_operation): MODEWIDTH now unsigned; rework arithmetic. (force_to_mode): WIDTH now unsigned; add cast. (if_then_else_cond): SIZE now unsigned. (nonzero_bits): MODE_WIDTH, RESULT_WIDTH, and WIDTH now unsigned. (extended_count): Now returns unsigned. (simplify_shift_const): COUNT unsigned; arg is now INPUT_COUNT. Add SIGNED_COUNT variable; MODE_WORDS and FIRST_COUNT now unsigned. (simplify_comparison): MODE_WIDTH now unsigned. (update_table_tick): REGNO and ENDREGNO now unsigned; new var R. (mark_used_regs_combine): Likewise; rework arithmetic. (record_value_for_reg): REGNO, ENDREGNO, and I now unsigned. (record_dead_and_set_regs, reg_dead_at_p, distribute_notes): Likewise. (record_promoted_value): REGNO now unsigned. (get_last_value_validate): REGNO, ENDREGNO, and J now unsigned. (get_last_value): REGNO now unsigned. (use_crosses_set_p): REGNO and ENDREGNO now unsigned. (reg_dead_regno, reg_dead_endregno): Now unsigned. (remove_death): Arg REGNO now unsigned. (move_deaths): REGNO, DEADREGNO, DEADEND, OUREND, and I now unsigned. (reg_bitfield_target_p): REGNO, REGNO, ENDREGNO, and ENDTREGNO now unsigned. * convert.c (convert_to_integer): INPREC and OUTPREC now unsigned. * cse.c (struct qty_table_elem): FIRST_REG and LAST_REG now unsigned. (struct cse_reg_info): REGNO now unsigned. (cached_regno): Now unsigned. (REGNO_QTY_VALID_P): Add cast. (make_new_qty, make_regs_eqv, delete_reg_eqiv): Regno args unsigned. (remove_invalid_regs): Likewise. (remove_invalid_subreg_refs): Likewise; arg WORD also unsigned as are variables END and I. (get_cse_reg_info, insert): Likewise. (mention_regs, invalidate_for_call): REGNO, ENDREGNO, and I unsigned. (canon_hash): Likewise. (insert_regs, lookup_for_remove): REGNO now unsigned. (invalidate): REGNO, ENDREGNO, TREGNO, and TENDREGNO now unsigned. New variable RN. * dbxout.c (dbxout_parms, dbxout_reg_parms): Don't check for REGNO < 0. * dwarf2out.c (dwarf2ou_frame_debug_expr): Remove cast. * emit-rtl.c (subreg_realpart_p): Add cast. (operand_subword): Arg I is now unsigned as is var PARTWORDS. (operand_subword_force): Arg I is now unsigned. * except.c (eh_regs): Variable I is now unsigned. * explow.c (hard_function_value): BYTES is unsigned HOST_WIDE_INT. * expmed.c (store_fixed_bit_field): Position is HOST_WIDE_INT; length is unsigned HOST_WIDE_INT; likewise for internal variables. (store_split_bit_field, extract_fixed_bit_field): Likewise. (extract_split_bit_field, store_bit_field, extract_bit_field): Likewise. * expr.c (store_constructor_fields, store_constructor, store_field): Positions are HOST_WIDE_INT and lengths are unsigned HOST_WIDE_INT. (expand_assignment, expand_expr, expand_expr_unaligned): Likewise. (do_jump): Likewise. (move_by_pieces, move_by_pieces_ninsns, clear_by_pieces): MAX_SIZE is now unsigned. (emit_group_load): BYTEPOS is HOST_WIDE_INT; BYTELEN is unsigned. (emit_group_store): Likewise. (emit_move_insn): I now unsigned. (store_constructor): Use host_integerp, tree_low_cst, and bitsize_unit_node. (get_inner_reference): Return bitpos and bitsize as HOST_WIDE_INT. Rework all calculations to use trees and new fields. * expr.h (promoted_input_arg): Regno now unsigned. (store_bit_field, extract_bit_field): Adjust types of pos and size. (mark_seen_cases): Arg is HOST_WIDE_INT. * flow.c (verify_wide_reg_1): REGNO now unsigned. * fold-const.c (decode_field_reference): Size and pos HOST_WIDE_INT; precisions and alignments are unsigned. (optimize_bit_field_compare, fold_truthop): Likewise. (int_const_binop): Adjust threshold for size_int_type_wide call. (fold_convert): Likewise. (size_int_type_wide): Make table larger and fix thinko that only had half of table used. (all_ones_mask_p, fold): Precisions are unsigned. * function.c (put_reg_info_stack): REGNO is unsigned. (instantiate_decl): Size is HOST_WIDE_INT. (instantiate_virtual_regs): I is unsigned. (assign_parms): REGNO, REGNOI, and REGNOR are unsigned. (promoted_input_arg): REGNO is unsigned. * function.h (struct function): x_max_parm_reg is now unsigned. * gcse.c (max_gcse_regno): Now unsigned. (struct null_pointer_info): min_reg and max_reg now unsigned. (lookup_set, next_set): REGNO arg now unsigned. (compute_hash_table): REGNO and I now unsigned. (handle_avail_expr): regnum_for_replacing now unsigned. (cprop_insn): REGNO now unsigned. (delete_null_pointer_checks_1): BLOCK_REG now pointer to unsigned. * ggc-common.c (ggc_mark_tree_children, case FIELD_DECL): New case. * global.c (set_preference): SRC_REGNO, DEST_REGNO, and I now unsigned. * hard-reg-set.h (reg_class_size): Now unsigned. * integrate.c (mark_stores): LAST_REG and I now unsigned; new UREGNO. * jump.c (mark_modified_reg): I now unsigned; add cast. (rtx_equal_for_thread_p): Add cast. * loop.c (max_reg_before_loop): Now unsigned. (struct_movable): REGNO now unsigned. (try_copy_prop): REGNO arg unsigned. (regs_match_p): XN and YN now unsigned. (consec_sets_invariant_p, maybe_eliminate_biv): REGNO now unsigned. (strength_reduce): Likewise; NREGS also unsigned. (first_increment_giv, last_increment_giv unsigned): Now unsigned. * loop.h (struct iv_class): REGNO now unsigned. (max_reg_before_loop, first_increment_giv, last_increment_giv): Now unsigned. * machmode.h (mode_size, mode_unit_size): Now unsigned. (mode_for_size, smallest_mode_for_size): Pass size as unsigned. * optabs.c (expand_binop): I and NWORDS now unsigned. (expand_unop): I now unsigned. * print-tree.c (print_node): Don't print DECL_FIELD_BITPOS, but do print DECL_FIELD_OFFSET and DECL_FIELD_BIT_OFFSET. * real.c (significand_size): Now returns unsigned. * real.h (significand_size): Likewise. * regclass.c (reg_class_size): Now unsigned. (choose_hard_reg_mode): Both operands now unsigned. (record_reg_classes): REGNO and NR now unsigned. (reg_scan): NREGS now unsigned. (reg_scan_update): old_max_regno now unsigned. (reg_scan_mark_refs): Arg MIN_REGNO and var REGNO now unsigned. * reload.c (find_valid_class): BEST_SIZE now unsigned. (find_dummy_reload): REGNO, NWORDS, and I now unsigned. (hard_reg_set_here_p): Args BEG_REGNO and END_REGNO now unsigned. Likewise for variable R. (refers_to_regno_for_reload_p): Args REGNO and END_REGNO now unsigned, as are variables INNER_REGNO and INNER_ENDREGNO; add new variable R. (find_equiv_reg): Add casts. (regno_clobbered_p): Arg REGNO now unsigned. * reload.h (struct reload): NREGS now unsigned. (refers_to_regno_for_reload_p): Regno args are unsigned. (regno_clobbered_p): Likewise. * reload1.c (reg_max_ref_width, spill_stack_slot_width): Now unsigned. (compute_use_by_pseudos): REGNO now unsigned. (find_reg): I and J now unsigned, new variable K, and change loop variables accordingly; THIS_NREGS now unsigned. (alter_reg): INHERENT_SIZE and TOTAL_SIZE now unsigned. (spill_hard_reg): REGNO arg now unsigned; add casts. (forget_old_reloads_1): REGNO, NR, and I now unsigned. (mark_reload_reg_in_use): Arg REGNO and vars NREGS and I now unsigned. (clear_reload_reg_in_use): Arg REGNO and vars NREGS, START_REGNO, END_REGNO, CONFLICT_START, and CONFLICT_END now unsigned. (reload_reg_free_p, reload_reg_reaches_end_p): Arg REGNO now unsigned. (choose_reload_regs): MAX_GROUP_SIZE now unsigned. (emit_reload_insns): REGNO now unsigned. (reload_cse_move2add): Add cast. (move2add_note_store): REGNO and I now unsigned; new variable ENDREGNO and rework loop. * resource.c (mark_referenced_resources, mark_set_resources): New variable R; REGNO and LAST_REGNO now unsigned. (mark_target_live_regs): J and REGNO now unsigned. * rtl.c (mode_size, mode_unit_size): Now unsigned. * rtl.h (union rtunion_def): New field rtuint. (XCUINT): New macro. (ADDRESSOF_REGNO, REGNO, SUBREG_WORD): New XCUINT. (operand_subword, operand_subword_force): Word number is unsigned. (choose_hard_reg_mode): Operands are unsigned. (refers_to-regno_p, dead_or_set_regno_p): Regno arg is unsigned. (find_regno_note, find_regno_fusage, replace_regs): Likewise. (regno_use_in, combine_instructions, remove_death): Likewise. (reg_scan, reg_scan_update): Likewise. (extended_count): Return is unsigned. * rtlanal.c (refers_to_regno_p): Args REGNO and ENDREGNO and vars I, INNER_REGNO, and INNER_ENDREGNO now unsigned; new variable X_REGNO. (reg_overlap_mentioned_p): REGNO and ENDREGNO now unsigned. (reg_set_last_first_regno, reg_set_last_last_regno): Now unsigned. (reg_reg_last_1): FIRS and LAST now unsigned. (dead_or_set_p): REGNO, LAST_REGNO, and I now unsigned. (dead_or_set_regno_p): Arg TEST_REGNO and vars REGNO and ENDREGNO now unsigned. (find_regno_note, regno_use_in): Arg REGNO now unsigned. (find_regno_fusage): Likewise; also var REGNOTE now unsigned. (find_reg_fusage): Variables REGNO, END_REGNO, and I now unsigned. (replace_regs): Arg NREGS now unsigned. * sdbout.c (sdbout_parms, sdbout_reg_parms): Don't check REGNO < 0. * simplify-rtx.c (simplify_unary_operation): WIDTH now unsigned. (simplify_binary_operation): Likewise. (cselib_invalidate_regno): Arg REGNO and variables ENDREGNO, I, and THIS_LAST now unsigned. (cselib_record_set): Add cast. * ssa.c (ssa_max_reg_num): Now unsigned. (rename_block): REGNO now unsigned. * stmt.c (expand_return): Bit positions unsigned HOST_WIDE_INT; sizes now unsigned. (all_cases_count): Just return -1 not -2. COUNT, MINVAL, and LASTVAL now HOST_WIDE_INT. Rework tests to use trees whenever possible. Use host_integerp and tree_low_cst. (mark_seen_cases): COUNT arg now HOST_WIDE_INT; Likewise variable NEXT_NODE_OFFSET; XLO now unsigned. (check_for_full_enumeration_handing): BYTES_NEEDED, I to HOST_WIDE_INT. * stor-layout.c (mode_for_size): SIZE arg now unsigned. (smallest_mode_for_size): Likewise. (layout_decl): Simplify handing of a specified DECL_SIZE_UNIT. KNOWN_ALIGN is now an alignment, so simplify code. Don't turn off DECL_BIT_FIELD if field is BLKmode, but not type. (start_record_layout): Renamed from new_record_layout_info. Update to new fields. (debug_rli, normalize_rli, rli_size_unit_so_far, rli_size_so_far): New functions. (place_union_field): Renamed from layout_union_field. Update to use new fields in rli. (place_field): Renamed from layout_field. Major rewrite to use new fields in rli; pass alignment to layout_decl. (finalize_record_size): Rework to use new fields in rli and handle union. (compute_record_mode): Rework to simplify and to use new DECL fields. (finalize_type_size): Make rounding more consistent. (finish_union_layout): Deleted. (layout_type, case VOID_TYPE): Don't set TYPE_SIZE_UNIT either. (layout_type, case RECORD_TYPE): Call new function names. (initialize_sizetypes): Set TYPE_IS_SIZETYPE. (set_sizetype): Set TYPE_IS_SIZETYPE earlier. (get_best_mode): UNIT is now unsigned; remove casts. * tree.c (bit_position): Compute from new fields. (byte_position, int_byte_position): New functions. (print_type_hash_statistics): Cast to remove warning. (build_range_type): Use host_integerp and tree_low_cst to try to hash. (build_index_type): Likewise; make subtype of sizetype. (build_index_2_type): Pass sizetype to build_range_type. (build_common_tree_nodes): Use size_int and bitsize_int to initialize nodes; add bitsize_{zero,one,unit}_node. * tree.h (DECL_FIELD_CONTEXT): Use FIELD_DECL_CHECK. (DECL_BIT_FIELD_TYPE, DECL_QUALIFIER, DECL_FCONTEXT): Likewise. (DECL_PACKED, DECL_BIT_FIELD): Likewise. (DECL_FIELD_BITPOS): Deleted. (DECL_FIELD_OFFSET, DECL_FIELD_BIT_OFFSET): New fields. (DECL_RESULT, DECL_SAVED_INSNS): Use FUNCTION_DECL_CHECK. (DECL_FRAME_SIZE, DECL_FUNCTION_CODE, DECL_NO_STATIC_CHAIN): Likewise. (DECL_INLINE, DECL_BUILT_IN_NONANSI, DECL_IS_MALLOC): Likewise. (DECL_BUILT_IN_CLASS, DECL_STATIC_CONSTRUCTOR): Likewise. (DECL_STATIC_DESTRUCTOR, DECL_NO_CHECK_MEMORY_USAGE): Likewise. (DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT, DECL_NO_LIMIT_STACK) Likewise. (DECL_ORIGINAL_TYPE, TYPE_DECL_SUPPRESS_DEBUG): Use TYPE_DECL_CHECK. (DECL_ARG_TYPE_AS_WRITEN, DECL_ARG_TYPE): Use PARM_DECL_CHECK. (DECL_INCOMING_RTL, DECL_TRANSPARENT_UNION): Likewise. (DECL_ALIGN): Adjust to new field in union. (DECL_OFFSET_ALIGN): New field. (DECL_ERROR_ISSUED, DECL_TOO_LATE): Use LABEL_DECL_CHECK. (DECL_IN_TEXT_SECTION): Use VAR_DECL_CHECK. (union tree_decl): Add struct for both aligns. (enum tree_index): Add TI_BITSIZE_{ZERO,ONE,UNIT}. (bitsize_zero_node, bitsize_one_node, bitsize_unit_node): Added. (struct record_layout_info): Rework fields to have offset alignment and byte and bit position. (start_record_layout, place_field): Renamed from old names. (rli_size_so_far, rli_size_unit_so_far, normalize_rli): New decls. (byte_position, int_byte_position): Likewise. (get_inner_reference): Change types of position and length. * unroll.c (unroll_loop): New variable R; use for some loops. MAX_LOCAL_REGNUM and MAXREGNUM now unsigned. (calculate_giv_inc): Arg REGNO now unsigned. (copy_loop_body): REGNO and SRC_REGNO now unsigned. * varasm.c (assemble_variable): Clean up handling of size using host_integerp and tree_low_cst. (decode_addr_const): Use byte, not bit, position. (output_constructor): bitpos and offsets are HOST_WIDE_INT; use tree_low_cst and int_bit_position. * objc/objc-act.c (build_ivar_list_initializer): Use byte_position. * ch/actions.c (check_missing_cases): BYTES_NEEDED is HOST_WIDE_INT. * ch/typeck.c (expand_constant_to_buffer): Use int_byte_position. (extract_constant_from_buffer): Likewise. * cp/class.c (build_vbase_pointer_fields): layout_field now place_field. (get_vfield_offset): Use byte_position. (set_rtti_entry): Set OFFSET to ssizetype zero. (get_binfo_offset_as_int): Deleted. (dfs_record_base_offsets): Use tree_low_cst. (dfs_search_base_offsets): Likewise. (layout_nonempty_base_or_field): Reflect changes in RLI format and call byte_position. (layout_empty_base): Convert offset to ssizetype. (build_base_field): use rli_size_unit_so_far. (dfs_propagate_binfo_offsets): Do computation in proper type. (layout_virtual_bases): Pass ssizetype to propagate_binfo_offsets. (layout_class_type): Reflect changes in RLI names and fields. (finish_struct_1): Set DECL_FIELD_OFFSET. * cp/dump.c (dequeue_and_dump): Call bit_position. * cp/expr.c (cplus_expand_constant): Use byte_position. * cp/rtti.c (expand_class_desc): Use bitsize_one_node. * cp/typeck.c (build_component_addr): Use byte_position and don't special case for zero offset. * f/com.c (ffecom_tree_canonize_ptr_): Use bitsize_zero_node. (ffecom_tree_canonize_ref_): Likewise. * java/class.c (make_field_value): Use byte_position. * java/expr.c (JAVA_ARRAY_LENGTH_OFFSET): Use byte_position. (java_array_data_offset): Likewise. * java/java-tree.h (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Add case to bzero call. From-SVN: r32742
2000-03-25 19:34:13 +01:00
static void
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
try_copy_prop (loop, replacement, regno)
const struct loop *loop;
rtx replacement;
* Rework fields used to describe positions of bitfields and modify sizes to be unsigned and use HOST_WIDE_INT. * alias.c (reg_known_value_size): Now unsigned. * c-typeck.c (build_unary_op, case ADDR_EXPR): Use byte_position. (really_start_incremental_init): Use bitsize_zero_node. (push_init_level, pop_init_level, output_init_element): Likewise. Use bitsize_unit_node and bitsize_one_node. (output_pending_init_elements, process_init_element): Likewise. * combine.c (combine_max_regno, reg_sign_bit_copies): Now unsigned. (make_extraction): Position and length HOST_WIDE_INT and unsigned HOST_WIDE_INT, respectively. (get_pos_from_mask): Passed in value is unsigned HOST_WIDE_INT. (num_sign_bit_copies): Returns unsigned. BITWIDTH now unsigned; rework arithmetic. Remove recursive call from arg to MAX. (combine_instructions, init_reg_last_arrays): NREGS now unsigned. (setup_incoming_promotions, can_combine_p, try_combine, simplify_set): REGNO now unsigned. (set_nonzero_bit_and_sign_copies): NUM now unsigned. (find_split_point, expand_compound_operation, make_extraction): LEN now unsigned HOST_WIDE_INT, POS now HOST_WIDE_INT. (make_field_assignment): Likewise. (combine_simplify_rtx): Add cast. (expand_compound_operation): MODEWIDTH now unsigned; rework arithmetic. (force_to_mode): WIDTH now unsigned; add cast. (if_then_else_cond): SIZE now unsigned. (nonzero_bits): MODE_WIDTH, RESULT_WIDTH, and WIDTH now unsigned. (extended_count): Now returns unsigned. (simplify_shift_const): COUNT unsigned; arg is now INPUT_COUNT. Add SIGNED_COUNT variable; MODE_WORDS and FIRST_COUNT now unsigned. (simplify_comparison): MODE_WIDTH now unsigned. (update_table_tick): REGNO and ENDREGNO now unsigned; new var R. (mark_used_regs_combine): Likewise; rework arithmetic. (record_value_for_reg): REGNO, ENDREGNO, and I now unsigned. (record_dead_and_set_regs, reg_dead_at_p, distribute_notes): Likewise. (record_promoted_value): REGNO now unsigned. (get_last_value_validate): REGNO, ENDREGNO, and J now unsigned. (get_last_value): REGNO now unsigned. (use_crosses_set_p): REGNO and ENDREGNO now unsigned. (reg_dead_regno, reg_dead_endregno): Now unsigned. (remove_death): Arg REGNO now unsigned. (move_deaths): REGNO, DEADREGNO, DEADEND, OUREND, and I now unsigned. (reg_bitfield_target_p): REGNO, REGNO, ENDREGNO, and ENDTREGNO now unsigned. * convert.c (convert_to_integer): INPREC and OUTPREC now unsigned. * cse.c (struct qty_table_elem): FIRST_REG and LAST_REG now unsigned. (struct cse_reg_info): REGNO now unsigned. (cached_regno): Now unsigned. (REGNO_QTY_VALID_P): Add cast. (make_new_qty, make_regs_eqv, delete_reg_eqiv): Regno args unsigned. (remove_invalid_regs): Likewise. (remove_invalid_subreg_refs): Likewise; arg WORD also unsigned as are variables END and I. (get_cse_reg_info, insert): Likewise. (mention_regs, invalidate_for_call): REGNO, ENDREGNO, and I unsigned. (canon_hash): Likewise. (insert_regs, lookup_for_remove): REGNO now unsigned. (invalidate): REGNO, ENDREGNO, TREGNO, and TENDREGNO now unsigned. New variable RN. * dbxout.c (dbxout_parms, dbxout_reg_parms): Don't check for REGNO < 0. * dwarf2out.c (dwarf2ou_frame_debug_expr): Remove cast. * emit-rtl.c (subreg_realpart_p): Add cast. (operand_subword): Arg I is now unsigned as is var PARTWORDS. (operand_subword_force): Arg I is now unsigned. * except.c (eh_regs): Variable I is now unsigned. * explow.c (hard_function_value): BYTES is unsigned HOST_WIDE_INT. * expmed.c (store_fixed_bit_field): Position is HOST_WIDE_INT; length is unsigned HOST_WIDE_INT; likewise for internal variables. (store_split_bit_field, extract_fixed_bit_field): Likewise. (extract_split_bit_field, store_bit_field, extract_bit_field): Likewise. * expr.c (store_constructor_fields, store_constructor, store_field): Positions are HOST_WIDE_INT and lengths are unsigned HOST_WIDE_INT. (expand_assignment, expand_expr, expand_expr_unaligned): Likewise. (do_jump): Likewise. (move_by_pieces, move_by_pieces_ninsns, clear_by_pieces): MAX_SIZE is now unsigned. (emit_group_load): BYTEPOS is HOST_WIDE_INT; BYTELEN is unsigned. (emit_group_store): Likewise. (emit_move_insn): I now unsigned. (store_constructor): Use host_integerp, tree_low_cst, and bitsize_unit_node. (get_inner_reference): Return bitpos and bitsize as HOST_WIDE_INT. Rework all calculations to use trees and new fields. * expr.h (promoted_input_arg): Regno now unsigned. (store_bit_field, extract_bit_field): Adjust types of pos and size. (mark_seen_cases): Arg is HOST_WIDE_INT. * flow.c (verify_wide_reg_1): REGNO now unsigned. * fold-const.c (decode_field_reference): Size and pos HOST_WIDE_INT; precisions and alignments are unsigned. (optimize_bit_field_compare, fold_truthop): Likewise. (int_const_binop): Adjust threshold for size_int_type_wide call. (fold_convert): Likewise. (size_int_type_wide): Make table larger and fix thinko that only had half of table used. (all_ones_mask_p, fold): Precisions are unsigned. * function.c (put_reg_info_stack): REGNO is unsigned. (instantiate_decl): Size is HOST_WIDE_INT. (instantiate_virtual_regs): I is unsigned. (assign_parms): REGNO, REGNOI, and REGNOR are unsigned. (promoted_input_arg): REGNO is unsigned. * function.h (struct function): x_max_parm_reg is now unsigned. * gcse.c (max_gcse_regno): Now unsigned. (struct null_pointer_info): min_reg and max_reg now unsigned. (lookup_set, next_set): REGNO arg now unsigned. (compute_hash_table): REGNO and I now unsigned. (handle_avail_expr): regnum_for_replacing now unsigned. (cprop_insn): REGNO now unsigned. (delete_null_pointer_checks_1): BLOCK_REG now pointer to unsigned. * ggc-common.c (ggc_mark_tree_children, case FIELD_DECL): New case. * global.c (set_preference): SRC_REGNO, DEST_REGNO, and I now unsigned. * hard-reg-set.h (reg_class_size): Now unsigned. * integrate.c (mark_stores): LAST_REG and I now unsigned; new UREGNO. * jump.c (mark_modified_reg): I now unsigned; add cast. (rtx_equal_for_thread_p): Add cast. * loop.c (max_reg_before_loop): Now unsigned. (struct_movable): REGNO now unsigned. (try_copy_prop): REGNO arg unsigned. (regs_match_p): XN and YN now unsigned. (consec_sets_invariant_p, maybe_eliminate_biv): REGNO now unsigned. (strength_reduce): Likewise; NREGS also unsigned. (first_increment_giv, last_increment_giv unsigned): Now unsigned. * loop.h (struct iv_class): REGNO now unsigned. (max_reg_before_loop, first_increment_giv, last_increment_giv): Now unsigned. * machmode.h (mode_size, mode_unit_size): Now unsigned. (mode_for_size, smallest_mode_for_size): Pass size as unsigned. * optabs.c (expand_binop): I and NWORDS now unsigned. (expand_unop): I now unsigned. * print-tree.c (print_node): Don't print DECL_FIELD_BITPOS, but do print DECL_FIELD_OFFSET and DECL_FIELD_BIT_OFFSET. * real.c (significand_size): Now returns unsigned. * real.h (significand_size): Likewise. * regclass.c (reg_class_size): Now unsigned. (choose_hard_reg_mode): Both operands now unsigned. (record_reg_classes): REGNO and NR now unsigned. (reg_scan): NREGS now unsigned. (reg_scan_update): old_max_regno now unsigned. (reg_scan_mark_refs): Arg MIN_REGNO and var REGNO now unsigned. * reload.c (find_valid_class): BEST_SIZE now unsigned. (find_dummy_reload): REGNO, NWORDS, and I now unsigned. (hard_reg_set_here_p): Args BEG_REGNO and END_REGNO now unsigned. Likewise for variable R. (refers_to_regno_for_reload_p): Args REGNO and END_REGNO now unsigned, as are variables INNER_REGNO and INNER_ENDREGNO; add new variable R. (find_equiv_reg): Add casts. (regno_clobbered_p): Arg REGNO now unsigned. * reload.h (struct reload): NREGS now unsigned. (refers_to_regno_for_reload_p): Regno args are unsigned. (regno_clobbered_p): Likewise. * reload1.c (reg_max_ref_width, spill_stack_slot_width): Now unsigned. (compute_use_by_pseudos): REGNO now unsigned. (find_reg): I and J now unsigned, new variable K, and change loop variables accordingly; THIS_NREGS now unsigned. (alter_reg): INHERENT_SIZE and TOTAL_SIZE now unsigned. (spill_hard_reg): REGNO arg now unsigned; add casts. (forget_old_reloads_1): REGNO, NR, and I now unsigned. (mark_reload_reg_in_use): Arg REGNO and vars NREGS and I now unsigned. (clear_reload_reg_in_use): Arg REGNO and vars NREGS, START_REGNO, END_REGNO, CONFLICT_START, and CONFLICT_END now unsigned. (reload_reg_free_p, reload_reg_reaches_end_p): Arg REGNO now unsigned. (choose_reload_regs): MAX_GROUP_SIZE now unsigned. (emit_reload_insns): REGNO now unsigned. (reload_cse_move2add): Add cast. (move2add_note_store): REGNO and I now unsigned; new variable ENDREGNO and rework loop. * resource.c (mark_referenced_resources, mark_set_resources): New variable R; REGNO and LAST_REGNO now unsigned. (mark_target_live_regs): J and REGNO now unsigned. * rtl.c (mode_size, mode_unit_size): Now unsigned. * rtl.h (union rtunion_def): New field rtuint. (XCUINT): New macro. (ADDRESSOF_REGNO, REGNO, SUBREG_WORD): New XCUINT. (operand_subword, operand_subword_force): Word number is unsigned. (choose_hard_reg_mode): Operands are unsigned. (refers_to-regno_p, dead_or_set_regno_p): Regno arg is unsigned. (find_regno_note, find_regno_fusage, replace_regs): Likewise. (regno_use_in, combine_instructions, remove_death): Likewise. (reg_scan, reg_scan_update): Likewise. (extended_count): Return is unsigned. * rtlanal.c (refers_to_regno_p): Args REGNO and ENDREGNO and vars I, INNER_REGNO, and INNER_ENDREGNO now unsigned; new variable X_REGNO. (reg_overlap_mentioned_p): REGNO and ENDREGNO now unsigned. (reg_set_last_first_regno, reg_set_last_last_regno): Now unsigned. (reg_reg_last_1): FIRS and LAST now unsigned. (dead_or_set_p): REGNO, LAST_REGNO, and I now unsigned. (dead_or_set_regno_p): Arg TEST_REGNO and vars REGNO and ENDREGNO now unsigned. (find_regno_note, regno_use_in): Arg REGNO now unsigned. (find_regno_fusage): Likewise; also var REGNOTE now unsigned. (find_reg_fusage): Variables REGNO, END_REGNO, and I now unsigned. (replace_regs): Arg NREGS now unsigned. * sdbout.c (sdbout_parms, sdbout_reg_parms): Don't check REGNO < 0. * simplify-rtx.c (simplify_unary_operation): WIDTH now unsigned. (simplify_binary_operation): Likewise. (cselib_invalidate_regno): Arg REGNO and variables ENDREGNO, I, and THIS_LAST now unsigned. (cselib_record_set): Add cast. * ssa.c (ssa_max_reg_num): Now unsigned. (rename_block): REGNO now unsigned. * stmt.c (expand_return): Bit positions unsigned HOST_WIDE_INT; sizes now unsigned. (all_cases_count): Just return -1 not -2. COUNT, MINVAL, and LASTVAL now HOST_WIDE_INT. Rework tests to use trees whenever possible. Use host_integerp and tree_low_cst. (mark_seen_cases): COUNT arg now HOST_WIDE_INT; Likewise variable NEXT_NODE_OFFSET; XLO now unsigned. (check_for_full_enumeration_handing): BYTES_NEEDED, I to HOST_WIDE_INT. * stor-layout.c (mode_for_size): SIZE arg now unsigned. (smallest_mode_for_size): Likewise. (layout_decl): Simplify handing of a specified DECL_SIZE_UNIT. KNOWN_ALIGN is now an alignment, so simplify code. Don't turn off DECL_BIT_FIELD if field is BLKmode, but not type. (start_record_layout): Renamed from new_record_layout_info. Update to new fields. (debug_rli, normalize_rli, rli_size_unit_so_far, rli_size_so_far): New functions. (place_union_field): Renamed from layout_union_field. Update to use new fields in rli. (place_field): Renamed from layout_field. Major rewrite to use new fields in rli; pass alignment to layout_decl. (finalize_record_size): Rework to use new fields in rli and handle union. (compute_record_mode): Rework to simplify and to use new DECL fields. (finalize_type_size): Make rounding more consistent. (finish_union_layout): Deleted. (layout_type, case VOID_TYPE): Don't set TYPE_SIZE_UNIT either. (layout_type, case RECORD_TYPE): Call new function names. (initialize_sizetypes): Set TYPE_IS_SIZETYPE. (set_sizetype): Set TYPE_IS_SIZETYPE earlier. (get_best_mode): UNIT is now unsigned; remove casts. * tree.c (bit_position): Compute from new fields. (byte_position, int_byte_position): New functions. (print_type_hash_statistics): Cast to remove warning. (build_range_type): Use host_integerp and tree_low_cst to try to hash. (build_index_type): Likewise; make subtype of sizetype. (build_index_2_type): Pass sizetype to build_range_type. (build_common_tree_nodes): Use size_int and bitsize_int to initialize nodes; add bitsize_{zero,one,unit}_node. * tree.h (DECL_FIELD_CONTEXT): Use FIELD_DECL_CHECK. (DECL_BIT_FIELD_TYPE, DECL_QUALIFIER, DECL_FCONTEXT): Likewise. (DECL_PACKED, DECL_BIT_FIELD): Likewise. (DECL_FIELD_BITPOS): Deleted. (DECL_FIELD_OFFSET, DECL_FIELD_BIT_OFFSET): New fields. (DECL_RESULT, DECL_SAVED_INSNS): Use FUNCTION_DECL_CHECK. (DECL_FRAME_SIZE, DECL_FUNCTION_CODE, DECL_NO_STATIC_CHAIN): Likewise. (DECL_INLINE, DECL_BUILT_IN_NONANSI, DECL_IS_MALLOC): Likewise. (DECL_BUILT_IN_CLASS, DECL_STATIC_CONSTRUCTOR): Likewise. (DECL_STATIC_DESTRUCTOR, DECL_NO_CHECK_MEMORY_USAGE): Likewise. (DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT, DECL_NO_LIMIT_STACK) Likewise. (DECL_ORIGINAL_TYPE, TYPE_DECL_SUPPRESS_DEBUG): Use TYPE_DECL_CHECK. (DECL_ARG_TYPE_AS_WRITEN, DECL_ARG_TYPE): Use PARM_DECL_CHECK. (DECL_INCOMING_RTL, DECL_TRANSPARENT_UNION): Likewise. (DECL_ALIGN): Adjust to new field in union. (DECL_OFFSET_ALIGN): New field. (DECL_ERROR_ISSUED, DECL_TOO_LATE): Use LABEL_DECL_CHECK. (DECL_IN_TEXT_SECTION): Use VAR_DECL_CHECK. (union tree_decl): Add struct for both aligns. (enum tree_index): Add TI_BITSIZE_{ZERO,ONE,UNIT}. (bitsize_zero_node, bitsize_one_node, bitsize_unit_node): Added. (struct record_layout_info): Rework fields to have offset alignment and byte and bit position. (start_record_layout, place_field): Renamed from old names. (rli_size_so_far, rli_size_unit_so_far, normalize_rli): New decls. (byte_position, int_byte_position): Likewise. (get_inner_reference): Change types of position and length. * unroll.c (unroll_loop): New variable R; use for some loops. MAX_LOCAL_REGNUM and MAXREGNUM now unsigned. (calculate_giv_inc): Arg REGNO now unsigned. (copy_loop_body): REGNO and SRC_REGNO now unsigned. * varasm.c (assemble_variable): Clean up handling of size using host_integerp and tree_low_cst. (decode_addr_const): Use byte, not bit, position. (output_constructor): bitpos and offsets are HOST_WIDE_INT; use tree_low_cst and int_bit_position. * objc/objc-act.c (build_ivar_list_initializer): Use byte_position. * ch/actions.c (check_missing_cases): BYTES_NEEDED is HOST_WIDE_INT. * ch/typeck.c (expand_constant_to_buffer): Use int_byte_position. (extract_constant_from_buffer): Likewise. * cp/class.c (build_vbase_pointer_fields): layout_field now place_field. (get_vfield_offset): Use byte_position. (set_rtti_entry): Set OFFSET to ssizetype zero. (get_binfo_offset_as_int): Deleted. (dfs_record_base_offsets): Use tree_low_cst. (dfs_search_base_offsets): Likewise. (layout_nonempty_base_or_field): Reflect changes in RLI format and call byte_position. (layout_empty_base): Convert offset to ssizetype. (build_base_field): use rli_size_unit_so_far. (dfs_propagate_binfo_offsets): Do computation in proper type. (layout_virtual_bases): Pass ssizetype to propagate_binfo_offsets. (layout_class_type): Reflect changes in RLI names and fields. (finish_struct_1): Set DECL_FIELD_OFFSET. * cp/dump.c (dequeue_and_dump): Call bit_position. * cp/expr.c (cplus_expand_constant): Use byte_position. * cp/rtti.c (expand_class_desc): Use bitsize_one_node. * cp/typeck.c (build_component_addr): Use byte_position and don't special case for zero offset. * f/com.c (ffecom_tree_canonize_ptr_): Use bitsize_zero_node. (ffecom_tree_canonize_ref_): Likewise. * java/class.c (make_field_value): Use byte_position. * java/expr.c (JAVA_ARRAY_LENGTH_OFFSET): Use byte_position. (java_array_data_offset): Likewise. * java/java-tree.h (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Add case to bzero call. From-SVN: r32742
2000-03-25 19:34:13 +01:00
unsigned int regno;
{
/* This is the reg that we are copying from. */
rtx reg_rtx = regno_reg_rtx[regno];
rtx init_insn = 0;
rtx insn;
/* These help keep track of whether we replaced all uses of the reg. */
int replaced_last = 0;
int store_is_first = 0;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
for (insn = next_insn_in_loop (loop, loop->scan_start);
insn != NULL_RTX;
loop.c (this_loop_info): Delete. * loop.c (this_loop_info): Delete. (uid_loop): Add in place of uid_loop_num. All uses updated. (loop_number_exit_count): Delete and replace with entry in loop structure. All uses updated. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (loop_used_count_register): Delete and replace with entry in loop_info structure. (find_and_verify_loops): Add loops argument. (verify_dominator, mark_loop_jump, prescan_loop): Replace loop_start, loop_end, etc. arguments with loop structure pointer. All callers changed. (loop_reg_used_before_p, scan_loop, strength_reduce): Likewise. (check_dbra_loop, next_insn_in_loop, try_copy_prop): Likewise. (load_mems_and_recount_loop_regs_set, load_mems): Likewise. (insert_bct): Likewise. (basic_induction_var): New argument level. * loop.h (struct loop_info): Delete fields num, loops_enclosed, vtop, and cont. Add used_count_register. (uid_loop): Delete declaration. (loop_number_exit_count): Likewise. (loop_number_loop_starts, loop_number_loop_ends): Likewise. (loop_number_loop_cont, loop_number_cont_dominator): Likewise. (loop_outer_loop, loop_used_count_register): Likewise. (loop_invalid, loop_number_exit_labels): Likewise. (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. Include basic-block.h. * unroll.c: (unroll_loop): Replace loop_start and loop_end arguments with loop structure pointer. (loop_precondition_p, loop_iterations): Likewise. * basic-block.h (struct loop): New entries vtop, cont, cont_dominator, start, end, top, scan_start, exit_labels, exit_count. * Makefile.in (LOOP_H): Add basic-block.h to dependencies. From-SVN: r31434
2000-01-15 04:01:49 +01:00
insn = next_insn_in_loop (loop, insn))
{
rtx set;
1999-11-26 12:44:37 +01:00
/* Only substitute within one extended basic block from the initializing
insn. */
if (GET_CODE (insn) == CODE_LABEL && init_insn)
break;
1999-11-26 12:44:37 +01:00
alias.c (mark_constant_function): Use INSN_P. * alias.c (mark_constant_function): Use INSN_P. (init_alias_analysis): Likewise. * combine.c (combine_instructions): Use INSN_P. (can_combine_p): Likewise. (try_combine): Likewise. (distribute_notes): Likewise. (distribute_links): Likewise. * cse.c (cse_around_loop): Use INSN_P. (invalidate_skipped_block): Likewise. (cse_set_around_loop): Likewise. (cse_end_of_basic_block): Likewise. (delete_trivially_dead_insns): Likewise. * emit-rtl.c (unshare_all_rtl_again): Use INSN_P. (unshare_all_rtl_1): Likewise. (next_cc0_user): Likewise. (try_split make_insn_raw): Likewise. (remove_unnecessary_notes): Likewise. * final.c (shorten_branches): Use INSN_P. (leaf_renumber_regs): Likewise. (leaf_renumber_regs_insn): Likewise. * flow.c (find_label_refs): Use INSN_P. (verify_wide_reg): Likewise. (notice_stack_pointer_modification): Likewise. (count_or_remove_death_notes): Likewise. (verify_flow_info): Likewise. (clear_log_links): Likewise. * function.c (fixup_var_refs_insns): Use INSN_P. (compute_insns_for_mem): Likewise. * gcse.c (alloc_gcse_mem): Use INSN_P. (compute_sets): Likewise. (compute_hash_table): Likewise. (classic_gcse): Likewise. (cprop): Likewise. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks_1): Likewise. * global.c (expand_preferences): Use INSN_P. (build_insn_chain): Likewise. * graph.c (node_data): Use INSN_P. * haifa-sched.c (priority): Use INSN_P. (rm_line_notes): Likewise. (rm_other_notes): Likewise. (find_insn_reg_weight): Likewise. (init_target_units): Likewise. (schedule_block): Likewise. (compute_block_forward_dependences): Likewise. (debug_dependencies): Likewise. (set_priorities): Likewise. * integrate.c (function_cannot_inline_p): Use INSN_P. (save_parm_insns): Likewise. (copy_insn_list): Likewise. * jump.c (mark_all_labels): Use INSN_P. (never_reached_warning): Likewise. * lcm.c (optimize_mode_switching): Use INSN_P. * local-alloc.c (validate_equiv_mem): Use INSN_P. (memref_used_between_p): Likewise. (update_equiv_regs): Likewise. (block_alloc): Likewise. (no_conflict_p): Likewise. * loop.c (scan_loop): Use INSN_P. (find_and_verify_loops): Likewise. (count_loop_regs_set): Likewise. (loop_reg_used_before_p): Likewise. (strength_reduce): Likewise. (recombine_givs): Likewise. (check_dbra_loop): Likewise. (load_mems): Likewise. (try_copy_prop): Likewise. * print-rtl.c (print_rtx): Use INSN_P. * recog.c (find_single_use): Use INSN_P. * reg-stack.c (stack_regs_mentioned): Use INSN_P. (next_flags_user): Likewise. (swap_rtx_condition): Likewise. * regmove.c (mark_flags_life_zones): Use INSN_P. (optimize_reg_copy_1): Likewise. (optimize_reg_copy_2): Likewise. (optimize_reg_copy_3): Likewise. (reg_is_remote_constant_p): Likewise. (fixup_match_2): Likewise. (regmove_optimize): Likewise. (fixup_match_1): Likewise. * regrename.c (build_def_use): Use INSN_P. (replace_reg_in_block): Likewise. (consider_use): Likewise. * reload.c (find_equiv_reg): Use INSN_P. * reload1.c (reload): Use INSN_P. (maybe_fix_stack_asms): Likewise. (calculate_needs_all_insns): Likewise. (reload_as_needed): Likewise. (emit_output_reload_insns): Likewise. (delete_address_reloads_1): Likewise. (reload_cse_regs_1): Likewise. (reload_combine): Likewise. (reload_cse_move2add): Likewise. * reorg.c (redundant_insn): Use INSN_P. (dbr_schedule): Likewise. * resource.c (find_dead_or_set_registers): Use INSN_P. (mark_target_live_regs): Likewise. * rtlanal.c (reg_used_between_p): Use INSN_P. (reg_referenced_between_p): Likewise. (reg_set_between_p): Likewise. (reg_set_p): Likewise. (single_set): Likewise. (multiple_sets): Likewise. (find_last_value): Likewise. (reg_set_last): Likewise. (find_reg_note): Likewise. (find_regno_note): Likewise. * sibcall.c (sequence_uses_addressof): Use INSN_P. * simplify-rtx.c (cselib_process_insn): Use INSN_P. * ssa.c (find_evaluations): Use INSN_P. (rename_block): Likewise. (rename_equivalent_regs): Likewise. * unroll.c (loop_find_equiv_value): Use INSN_P. (set_dominates_use): Likewise. * varasm.c (mark_constant_pool): Use INSN_P. (mark_constants): Likewise. * config/alpha/alpha.c (alpha_does_function_need_gp): Use INSN_P. (alphaev4_next_group): Likewise. (alphaev5_next_group): Likewise. * config/c4x/c4x.c (c4x_process_after_reload): Use INSN_P. (c4x_rptb_rpts_p): Likewise. * config/mips/mips.c (mips16_optimize_gp): Use INSN_P. * config/rs6000/rs6000.c (uses_TOC): Use INSN_P. (rs6000_adjust_priority): Likewise. * config/sh/sh.c (sh_loop_align): Use INSN_P. (machine_dependent_reorg): Likewise. (split_branches): Likewise. * config/tahoe/tahoe.c (tahoe_cmp_check): Use INSN_P. From-SVN: r35494
2000-08-04 22:28:08 +02:00
if (! INSN_P (insn))
continue;
/* Is this the initializing insn? */
set = single_set (insn);
if (set
&& GET_CODE (SET_DEST (set)) == REG
&& REGNO (SET_DEST (set)) == regno)
{
if (init_insn)
abort ();
init_insn = insn;
if (REGNO_FIRST_UID (regno) == INSN_UID (insn))
store_is_first = 1;
}
/* Only substitute after seeing the initializing insn. */
if (init_insn && insn != init_insn)
{
struct note_reg_stored_arg arg;
replace_loop_regs (insn, reg_rtx, replacement);
if (REGNO_LAST_UID (regno) == INSN_UID (insn))
replaced_last = 1;
/* Stop replacing when REPLACEMENT is modified. */
arg.reg = replacement;
arg.set_seen = 0;
note_stores (PATTERN (insn), note_reg_stored, &arg);
if (arg.set_seen)
break;
}
}
if (! init_insn)
abort ();
if (apply_change_group ())
{
if (loop_dump_stream)
fprintf (loop_dump_stream, " Replaced reg %d", regno);
if (store_is_first && replaced_last)
{
PUT_CODE (init_insn, NOTE);
NOTE_LINE_NUMBER (init_insn) = NOTE_INSN_DELETED;
if (loop_dump_stream)
fprintf (loop_dump_stream, ", deleting init_insn (%d)",
INSN_UID (init_insn));
}
if (loop_dump_stream)
fprintf (loop_dump_stream, ".\n");
}
}
/* Try to replace occurrences of pseudo REGNO with REPLACEMENT within
loop LOOP if the order of the sets of these registers can be
swapped. There must be exactly one insn within the loop that sets
this pseudo followed immediately by a move insn that sets
REPLACEMENT with REGNO. */
static void
try_swap_copy_prop (loop, replacement, regno)
const struct loop *loop;
rtx replacement;
unsigned int regno;
{
rtx insn;
rtx set;
unsigned int new_regno;
new_regno = REGNO (replacement);
for (insn = next_insn_in_loop (loop, loop->scan_start);
insn != NULL_RTX;
insn = next_insn_in_loop (loop, insn))
{
/* Search for the insn that copies REGNO to NEW_REGNO? */
if (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
&& (set = single_set (insn))
&& GET_CODE (SET_DEST (set)) == REG
&& REGNO (SET_DEST (set)) == new_regno
&& GET_CODE (SET_SRC (set)) == REG
&& REGNO (SET_SRC (set)) == regno)
break;
}
if (insn != NULL_RTX)
{
rtx prev_insn;
rtx prev_set;
/* Some DEF-USE info would come in handy here to make this
function more general. For now, just check the previous insn
which is the most likely candidate for setting REGNO. */
prev_insn = PREV_INSN (insn);
if (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
&& (prev_set = single_set (prev_insn))
&& GET_CODE (SET_DEST (prev_set)) == REG
&& REGNO (SET_DEST (prev_set)) == regno)
{
/* We have:
(set (reg regno) (expr))
(set (reg new_regno) (reg regno))
so try converting this to:
(set (reg new_regno) (expr))
(set (reg regno) (reg new_regno))
The former construct is often generated when a global
variable used for an induction variable is shadowed by a
register (NEW_REGNO). The latter construct improves the
chances of GIV replacement and BIV elimination. */
validate_change (prev_insn, &SET_DEST (prev_set),
replacement, 1);
validate_change (insn, &SET_DEST (set),
SET_SRC (set), 1);
validate_change (insn, &SET_SRC (set),
replacement, 1);
if (apply_change_group ())
{
if (loop_dump_stream)
fprintf (loop_dump_stream,
" Swapped set of reg %d at %d with reg %d at %d.\n",
regno, INSN_UID (insn),
new_regno, INSN_UID (prev_insn));
/* Update first use of REGNO. */
if (REGNO_FIRST_UID (regno) == INSN_UID (prev_insn))
REGNO_FIRST_UID (regno) = INSN_UID (insn);
/* Now perform copy propagation to hopefully
remove all uses of REGNO within the loop. */
try_copy_prop (loop, replacement, regno);
}
}
}
}
1998-08-19 14:30:47 +02:00
/* Replace MEM with its associated pseudo register. This function is
called from load_mems via for_each_rtx. DATA is actually a pointer
to a structure describing the instruction currently being scanned
1998-08-19 14:30:47 +02:00
and the MEM we are currently replacing. */
static int
replace_loop_mem (mem, data)
rtx *mem;
void *data;
{
loop_replace_args *args = (loop_replace_args *) data;
1998-08-19 14:30:47 +02:00
rtx m = *mem;
if (m == NULL_RTX)
return 0;
switch (GET_CODE (m))
{
case MEM:
break;
case CONST_DOUBLE:
/* We're not interested in the MEM associated with a
CONST_DOUBLE, so there's no need to traverse into one. */
return -1;
default:
/* This is not a MEM. */
return 0;
}
if (!rtx_equal_p (args->match, m))
1998-08-19 14:30:47 +02:00
/* This is not the MEM we are currently replacing. */
return 0;
/* Actually replace the MEM. */
validate_change (args->insn, mem, args->replacement, 1);
1998-08-19 14:30:47 +02:00
return 0;
}
static void
replace_loop_mems (insn, mem, reg)
rtx insn;
rtx mem;
rtx reg;
{
loop_replace_args args;
args.insn = insn;
args.match = mem;
args.replacement = reg;
for_each_rtx (&insn, replace_loop_mem, &args);
}
/* Replace one register with another. Called through for_each_rtx; PX points
to the rtx being scanned. DATA is actually a pointer to
a structure of arguments. */
static int
replace_loop_reg (px, data)
rtx *px;
void *data;
{
rtx x = *px;
loop_replace_args *args = (loop_replace_args *) data;
if (x == NULL_RTX)
return 0;
if (x == args->match)
validate_change (args->insn, px, args->replacement, 1);
return 0;
}
static void
replace_loop_regs (insn, reg, replacement)
rtx insn;
rtx reg;
rtx replacement;
{
loop_replace_args args;
args.insn = insn;
args.match = reg;
args.replacement = replacement;
for_each_rtx (&insn, replace_loop_reg, &args);
}
1998-08-19 14:30:47 +02:00
/* Replace occurrences of the old exit label for the loop with the new
one. DATA is an rtx_pair containing the old and new labels,
respectively. */
static int
replace_label (x, data)
rtx *x;
void *data;
{
rtx l = *x;
rtx old_label = ((rtx_pair *) data)->r1;
rtx new_label = ((rtx_pair *) data)->r2;
1998-08-19 14:30:47 +02:00
if (l == NULL_RTX)
return 0;
if (GET_CODE (l) != LABEL_REF)
return 0;
if (XEXP (l, 0) != old_label)
return 0;
1998-08-19 14:30:47 +02:00
XEXP (l, 0) = new_label;
++LABEL_NUSES (new_label);
--LABEL_NUSES (old_label);
return 0;
}
#define LOOP_BLOCK_NUM_1(INSN) \
((INSN) ? (BLOCK_FOR_INSN (INSN) ? BLOCK_NUM (INSN) : - 1) : -1)
/* The notes do not have an assigned block, so look at the next insn. */
#define LOOP_BLOCK_NUM(INSN) \
((INSN) ? (GET_CODE (INSN) == NOTE \
? LOOP_BLOCK_NUM_1 (next_nonnote_insn (INSN)) \
: LOOP_BLOCK_NUM_1 (INSN)) \
: -1)
#define LOOP_INSN_UID(INSN) ((INSN) ? INSN_UID (INSN) : -1)
static void
loop_dump_aux (loop, file, verbose)
const struct loop *loop;
FILE *file;
int verbose ATTRIBUTE_UNUSED;
{
rtx label;
if (! loop || ! file)
return;
/* Print diagnostics to compare our concept of a loop with
what the loop notes say. */
if (! PREV_INSN (loop->first->head)
|| GET_CODE (PREV_INSN (loop->first->head)) != NOTE
|| NOTE_LINE_NUMBER (PREV_INSN (loop->first->head))
!= NOTE_INSN_LOOP_BEG)
fprintf (file, ";; No NOTE_INSN_LOOP_BEG at %d\n",
INSN_UID (PREV_INSN (loop->first->head)));
if (! NEXT_INSN (loop->last->end)
|| GET_CODE (NEXT_INSN (loop->last->end)) != NOTE
|| NOTE_LINE_NUMBER (NEXT_INSN (loop->last->end))
!= NOTE_INSN_LOOP_END)
fprintf (file, ";; No NOTE_INSN_LOOP_END at %d\n",
INSN_UID (NEXT_INSN (loop->last->end)));
if (loop->start)
{
fprintf (file,
";; start %d (%d), cont dom %d (%d), cont %d (%d), vtop %d (%d), end %d (%d)\n",
LOOP_BLOCK_NUM (loop->start),
LOOP_INSN_UID (loop->start),
LOOP_BLOCK_NUM (loop->cont),
LOOP_INSN_UID (loop->cont),
LOOP_BLOCK_NUM (loop->cont),
LOOP_INSN_UID (loop->cont),
LOOP_BLOCK_NUM (loop->vtop),
LOOP_INSN_UID (loop->vtop),
LOOP_BLOCK_NUM (loop->end),
LOOP_INSN_UID (loop->end));
fprintf (file, ";; top %d (%d), scan start %d (%d)\n",
LOOP_BLOCK_NUM (loop->top),
LOOP_INSN_UID (loop->top),
LOOP_BLOCK_NUM (loop->scan_start),
LOOP_INSN_UID (loop->scan_start));
fprintf (file, ";; exit_count %d", loop->exit_count);
if (loop->exit_count)
{
fputs (", labels:", file);
for (label = loop->exit_labels; label; label = LABEL_NEXTREF (label))
{
fprintf (file, " %d ",
LOOP_INSN_UID (XEXP (label, 0)));
}
}
fputs ("\n", file);
/* This can happen when a marked loop appears as two nested loops,
say from while (a || b) {}. The inner loop won't match
the loop markers but the outer one will. */
if (LOOP_BLOCK_NUM (loop->cont) != loop->latch->index)
fprintf (file, ";; NOTE_INSN_LOOP_CONT not in loop latch\n");
}
}
/* Call this function from the debugger to dump LOOP. */
void
debug_loop (loop)
const struct loop *loop;
{
flow_loop_dump (loop, stderr, loop_dump_aux, 1);
}