From 14a774a9d22db91fb6387cb8eb61060b61782f29 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Sun, 31 Oct 1999 20:11:22 -0500 Subject: [multiple changes] Fri Oct 29 15:25:07 1999 Arnaud Charlet * 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 * 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 * 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 * 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 * 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 * 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 --- gcc/cse.c | 261 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 132 insertions(+), 129 deletions(-) (limited to 'gcc/cse.c') diff --git a/gcc/cse.c b/gcc/cse.c index f6ebb068297..e94851342dd 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -291,13 +291,14 @@ static rtx this_insn; static int *reg_next_eqv; static int *reg_prev_eqv; -struct cse_reg_info { +struct cse_reg_info +{ /* The number of times the register has been altered in the current basic block. */ int reg_tick; /* The next cse_reg_info structure in the free or used list. */ - struct cse_reg_info* next; + struct cse_reg_info *next; /* The REG_TICK value at which rtx's containing this register are valid in the hash table. If this does not equal the current @@ -576,7 +577,8 @@ static int constant_pool_entries_cost; /* This data describes a block that will be processed by cse_basic_block. */ -struct cse_basic_block_data { +struct cse_basic_block_data +{ /* Lowest CUID value of insns in block. */ int low_cuid; /* Highest CUID value of insns in block. */ @@ -588,14 +590,15 @@ struct cse_basic_block_data { /* Size of current branch path, if any. */ int path_size; /* Current branch path, indicating which branches will be taken. */ - struct branch_path { - /* The branch insn. */ - rtx branch; - /* Whether it should be taken or not. AROUND is the same as taken - except that it is used when the destination label is not preceded + struct branch_path + { + /* The branch insn. */ + rtx branch; + /* Whether it should be taken or not. AROUND is the same as taken + except that it is used when the destination label is not preceded by a BARRIER. */ - enum taken {TAKEN, NOT_TAKEN, AROUND} status; - } path[PATHLENGTH]; + enum taken {TAKEN, NOT_TAKEN, AROUND} status; + } path[PATHLENGTH]; }; /* Nonzero if X has the form (PLUS frame-pointer integer). We check for @@ -692,7 +695,9 @@ static void record_jump_equiv PROTO((rtx, int)); static void record_jump_cond PROTO((enum rtx_code, enum machine_mode, rtx, rtx, int)); static void cse_insn PROTO((rtx, rtx)); -static int note_mem_written PROTO((rtx)); +#ifdef AUTO_INC_DEC +static int addr_affects_sp_p PROTO((rtx)); +#endif static void invalidate_from_clobbers PROTO((rtx)); static rtx cse_process_notes PROTO((rtx, rtx)); static void cse_around_loop PROTO((rtx)); @@ -1721,21 +1726,18 @@ flush_hash_table () remove_from_table (p, i); } } - - -/* Remove from the hash table, or mark as invalid, - all expressions whose values could be altered by storing in X. - X is a register, a subreg, or a memory reference with nonvarying address - (because, when a memory reference with a varying address is stored in, - all memory references are removed by invalidate_memory - so specific invalidation is superfluous). - FULL_MODE, if not VOIDmode, indicates that this much should be invalidated - instead of just the amount indicated by the mode of X. This is only used - for bitfield stores into memory. - - A nonvarying address may be just a register or just - a symbol reference, or it may be either of those plus - a numeric offset. */ + +/* Remove from the hash table, or mark as invalid, all expressions whose + values could be altered by storing in X. X is a register, a subreg, or + a memory reference with nonvarying address (because, when a memory + reference with a varying address is stored in, all memory references are + removed by invalidate_memory so specific invalidation is superfluous). + FULL_MODE, if not VOIDmode, indicates that this much should be + invalidated instead of just the amount indicated by the mode of X. This + is only used for bitfield stores into memory. + + A nonvarying address may be just a register or just a symbol reference, + or it may be either of those plus a numeric offset. */ static void invalidate (x, full_mode) @@ -1745,130 +1747,118 @@ invalidate (x, full_mode) register int i; register struct table_elt *p; - /* If X is a register, dependencies on its contents - are recorded through the qty number mechanism. - Just change the qty number of the register, - mark it as invalid for expressions that refer to it, - and remove it itself. */ - - if (GET_CODE (x) == REG) + switch (GET_CODE (x)) { - register int regno = REGNO (x); - register unsigned hash = HASH (x, GET_MODE (x)); - - /* Remove REGNO from any quantity list it might be on and indicate - that its value might have changed. If it is a pseudo, remove its - entry from the hash table. + case REG: + { + /* If X is a register, dependencies on its contents are recorded + through the qty number mechanism. Just change the qty number of + the register, mark it as invalid for expressions that refer to it, + and remove it itself. */ + register int regno = REGNO (x); + register unsigned hash = HASH (x, GET_MODE (x)); - For a hard register, we do the first two actions above for any - additional hard registers corresponding to X. Then, if any of these - registers are in the table, we must remove any REG entries that - overlap these registers. */ + /* Remove REGNO from any quantity list it might be on and indicate + that its value might have changed. If it is a pseudo, remove its + entry from the hash table. - delete_reg_equiv (regno); - REG_TICK (regno)++; + For a hard register, we do the first two actions above for any + additional hard registers corresponding to X. Then, if any of these + registers are in the table, we must remove any REG entries that + overlap these registers. */ - if (regno >= FIRST_PSEUDO_REGISTER) - { - /* Because a register can be referenced in more than one mode, - we might have to remove more than one table entry. */ + delete_reg_equiv (regno); + REG_TICK (regno)++; - struct table_elt *elt; + if (regno >= FIRST_PSEUDO_REGISTER) + { + /* Because a register can be referenced in more than one mode, + we might have to remove more than one table entry. */ + struct table_elt *elt; - while ((elt = lookup_for_remove (x, hash, GET_MODE (x)))) - remove_from_table (elt, hash); - } - else - { - HOST_WIDE_INT in_table - = TEST_HARD_REG_BIT (hard_regs_in_table, regno); - int endregno = regno + HARD_REGNO_NREGS (regno, GET_MODE (x)); - int tregno, tendregno; - register struct table_elt *p, *next; + while ((elt = lookup_for_remove (x, hash, GET_MODE (x)))) + remove_from_table (elt, hash); + } + else + { + HOST_WIDE_INT in_table + = TEST_HARD_REG_BIT (hard_regs_in_table, regno); + int endregno = regno + HARD_REGNO_NREGS (regno, GET_MODE (x)); + int tregno, tendregno; + register struct table_elt *p, *next; - CLEAR_HARD_REG_BIT (hard_regs_in_table, regno); + CLEAR_HARD_REG_BIT (hard_regs_in_table, regno); - for (i = regno + 1; i < endregno; i++) - { - in_table |= TEST_HARD_REG_BIT (hard_regs_in_table, i); - CLEAR_HARD_REG_BIT (hard_regs_in_table, i); - delete_reg_equiv (i); - REG_TICK (i)++; - } + for (i = regno + 1; i < endregno; i++) + { + in_table |= TEST_HARD_REG_BIT (hard_regs_in_table, i); + CLEAR_HARD_REG_BIT (hard_regs_in_table, i); + delete_reg_equiv (i); + REG_TICK (i)++; + } - if (in_table) - for (hash = 0; hash < NBUCKETS; hash++) - for (p = table[hash]; p; p = next) - { - next = p->next_same_hash; + if (in_table) + for (hash = 0; hash < NBUCKETS; hash++) + for (p = table[hash]; p; p = next) + { + next = p->next_same_hash; if (GET_CODE (p->exp) != REG || REGNO (p->exp) >= FIRST_PSEUDO_REGISTER) continue; - - tregno = REGNO (p->exp); - tendregno - = tregno + HARD_REGNO_NREGS (tregno, GET_MODE (p->exp)); - if (tendregno > regno && tregno < endregno) - remove_from_table (p, hash); - } - } - + + tregno = REGNO (p->exp); + tendregno + = tregno + HARD_REGNO_NREGS (tregno, GET_MODE (p->exp)); + if (tendregno > regno && tregno < endregno) + remove_from_table (p, hash); + } + } + } return; - } - if (GET_CODE (x) == SUBREG) - { - if (GET_CODE (SUBREG_REG (x)) != REG) - abort (); + case SUBREG: invalidate (SUBREG_REG (x), VOIDmode); return; - } - - /* If X is a parallel, invalidate all of its elements. */ - if (GET_CODE (x) == PARALLEL) - { + case PARALLEL: for (i = XVECLEN (x, 0) - 1; i >= 0 ; --i) invalidate (XVECEXP (x, 0, i), VOIDmode); return; - } - /* If X is an expr_list, this is part of a disjoint return value; - extract the location in question ignoring the offset. */ - - if (GET_CODE (x) == EXPR_LIST) - { + case EXPR_LIST: + /* This is part of a disjoint return value; extract the location in + question ignoring the offset. */ invalidate (XEXP (x, 0), VOIDmode); return; - } - - /* X is not a register; it must be a memory reference with - a nonvarying address. Remove all hash table elements - that refer to overlapping pieces of memory. */ - if (GET_CODE (x) != MEM) - abort (); - - if (full_mode == VOIDmode) - full_mode = GET_MODE (x); + case MEM: + /* Remove all hash table elements that refer to overlapping pieces of + memory. */ + if (full_mode == VOIDmode) + full_mode = GET_MODE (x); - for (i = 0; i < NBUCKETS; i++) - { - register struct table_elt *next; - for (p = table[i]; p; p = next) + for (i = 0; i < NBUCKETS; i++) { - next = p->next_same_hash; - /* Invalidate ASM_OPERANDS which reference memory (this is easier - than checking all the aliases). */ - if (p->in_memory - && (GET_CODE (p->exp) != MEM - || true_dependence (x, full_mode, p->exp, cse_rtx_varies_p))) - remove_from_table (p, i); + register struct table_elt *next; + + for (p = table[i]; p; p = next) + { + next = p->next_same_hash; + if (p->in_memory + && (GET_CODE (p->exp) != MEM + || true_dependence (x, full_mode, p->exp, + cse_rtx_varies_p))) + remove_from_table (p, i); + } } + return; + + default: + abort (); } } - + /* Remove all expressions that refer to register REGNO, since they are already invalid, and we are about to mark that register valid again and don't want the old @@ -2215,7 +2205,9 @@ canon_hash (x, mode) return hash; case MEM: - if (MEM_VOLATILE_P (x)) + /* We don't record if marked volatile or if BLKmode since we don't + know the size of the move. */ + if (MEM_VOLATILE_P (x) || GET_MODE (x) == BLKmode) { do_not_record = 1; return 0; @@ -6171,6 +6163,7 @@ cse_insn (insn, libcall_insn) } /* Remove from the hash table all expressions that reference memory. */ + static void invalidate_memory () { @@ -6186,13 +6179,15 @@ invalidate_memory () } } -/* XXX ??? The name of this function bears little resemblance to - what this function actually does. FIXME. */ +#ifdef AUTO_INC_DEC + +/* If ADDR is an address that implicitly affects the stack pointer, return + 1 and update the register tables to show the effect. Else, return 0. */ + static int -note_mem_written (addr) +addr_affects_sp_p (addr) register rtx addr; { - /* Pushing or popping the stack invalidates just the stack pointer. */ if ((GET_CODE (addr) == PRE_DEC || GET_CODE (addr) == PRE_INC || GET_CODE (addr) == POST_DEC || GET_CODE (addr) == POST_INC) && GET_CODE (XEXP (addr, 0)) == REG @@ -6204,10 +6199,13 @@ note_mem_written (addr) /* This should be *very* rare. */ if (TEST_HARD_REG_BIT (hard_regs_in_table, STACK_POINTER_REGNUM)) invalidate (stack_pointer_rtx, VOIDmode); + return 1; } + return 0; } +#endif /* Perform invalidation on the basis of everything about an insn except for invalidating the actual places that are SET in it. @@ -6432,7 +6430,9 @@ invalidate_skipped_set (dest, set, data) enum rtx_code code = GET_CODE (dest); if (code == MEM - && ! note_mem_written (dest) /* If this is not a stack push ... */ +#ifdef AUTO_INC_DEC + && ! addr_affects_sp_p (dest) /* If this is not a stack push ... */ +#endif /* There are times when an address can appear varying and be a PLUS during this scan when it would be a fixed address were we to know the proper equivalences. So invalidate all memory if there is @@ -6605,10 +6605,13 @@ cse_set_around_loop (x, insn, loop_start) } } - /* Now invalidate anything modified by X. */ - note_mem_written (SET_DEST (x)); +#ifdef AUTO_INC_DEC + /* Deal with the destination of X affecting the stack pointer. */ + addr_affects_sp_p (SET_DEST (x)); +#endif - /* See comment on similar code in cse_insn for explanation of these tests. */ + /* See comment on similar code in cse_insn for explanation of these + tests. */ if (GET_CODE (SET_DEST (x)) == REG || GET_CODE (SET_DEST (x)) == SUBREG || GET_CODE (SET_DEST (x)) == MEM) invalidate (SET_DEST (x), VOIDmode); -- cgit v1.2.1