home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / flow.c < prev    next >
C/C++ Source or Header  |  1991-12-13  |  76KB  |  2,408 lines

  1. /* Data flow analysis for GNU compiler.
  2.    Copyright (C) 1987-1991 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. /* This file contains the data flow analysis pass of the compiler.
  22.    It computes data flow information
  23.    which tells combine_instructions which insns to consider combining
  24.    and controls register allocation.
  25.  
  26.    Additional data flow information that is too bulky to record
  27.    is generated during the analysis, and is used at that time to
  28.    create autoincrement and autodecrement addressing.
  29.  
  30.    The first step is dividing the function into basic blocks.
  31.    find_basic_blocks does this.  Then life_analysis determines
  32.    where each register is live and where it is dead.
  33.  
  34.    ** find_basic_blocks **
  35.  
  36.    find_basic_blocks divides the current function's rtl
  37.    into basic blocks.  It records the beginnings and ends of the
  38.    basic blocks in the vectors basic_block_head and basic_block_end,
  39.    and the number of blocks in n_basic_blocks.
  40.  
  41.    find_basic_blocks also finds any unreachable loops
  42.    and deletes them.
  43.  
  44.    ** life_analysis **
  45.  
  46.    life_analysis is called immediately after find_basic_blocks.
  47.    It uses the basic block information to determine where each
  48.    hard or pseudo register is live.
  49.  
  50.    ** live-register info **
  51.  
  52.    The information about where each register is live is in two parts:
  53.    the REG_NOTES of insns, and the vector basic_block_live_at_start.
  54.  
  55.    basic_block_live_at_start has an element for each basic block,
  56.    and the element is a bit-vector with a bit for each hard or pseudo
  57.    register.  The bit is 1 if the register is live at the beginning
  58.    of the basic block.
  59.  
  60.    To each insn's REG_NOTES is added an element for each register
  61.    that is live before the insn or set by the insn, but is dead
  62.    after the insn.
  63.  
  64.    To determine which registers are live after any insn, one can
  65.    start from the beginning of the basic block and scan insns, noting
  66.    which registers are set by each insn and which die there.
  67.  
  68.    ** Other actions of life_analysis **
  69.  
  70.    life_analysis sets up the LOG_LINKS fields of insns because the
  71.    information needed to do so is readily available.
  72.  
  73.    life_analysis deletes insns whose only effect is to store a value
  74.    that is never used.
  75.  
  76.    life_analysis notices cases where a reference to a register as
  77.    a memory address can be combined with a preceding or following
  78.    incrementation or decrementation of the register.  The separate
  79.    instruction to increment or decrement is deleted and the address
  80.    is changed to a POST_INC or similar rtx.
  81.  
  82.    Each time an incrementing or decrementing address is created,
  83.    a REG_INC element is added to the insn's REG_NOTES list.
  84.  
  85.    life_analysis fills in certain vectors containing information about
  86.    register usage: reg_n_refs, reg_n_deaths, reg_n_sets, reg_live_length,
  87.    reg_n_calls_crosses and reg_basic_block.  */
  88.  
  89. #include <stdio.h>
  90. #include "config.h"
  91. #include "rtl.h"
  92. #include "basic-block.h"
  93. #include "insn-config.h"
  94. #include "regs.h"
  95. #include "hard-reg-set.h"
  96. #include "flags.h"
  97. #include "output.h"
  98.  
  99. #include "obstack.h"
  100. #define obstack_chunk_alloc xmalloc
  101. #define obstack_chunk_free free
  102.  
  103. extern int xmalloc ();
  104. extern void free ();
  105.  
  106. /* Get the basic block number of an insn.
  107.    This info should not be expected to remain available
  108.    after the end of life_analysis.  */
  109.  
  110. #define BLOCK_NUM(INSN)  uid_block_number[INSN_UID (INSN)]
  111.  
  112. /* This is where the BLOCK_NUM values are really stored.
  113.    This is set up by find_basic_blocks and used there and in life_analysis,
  114.    and then freed.  */
  115.  
  116. static short *uid_block_number;
  117.  
  118. /* INSN_VOLATILE (insn) is 1 if the insn refers to anything volatile.  */
  119.  
  120. #define INSN_VOLATILE(INSN) uid_volatile[INSN_UID (INSN)]
  121. static char *uid_volatile;
  122.  
  123. /* Number of basic blocks in the current function.  */
  124.  
  125. int n_basic_blocks;
  126.  
  127. /* Maximum register number used in this function, plus one.  */
  128.  
  129. int max_regno;
  130.  
  131. /* Maximum number of SCRATCH rtx's used in any basic block of this function. */
  132.  
  133. int max_scratch;
  134.  
  135. /* Number of SCRATCH rtx's in the current block.  */
  136.  
  137. static int num_scratch;
  138.  
  139. /* Indexed by n, gives number of basic block that  (REG n) is used in.
  140.    If the value is REG_BLOCK_GLOBAL (-2),
  141.    it means (REG n) is used in more than one basic block.
  142.    REG_BLOCK_UNKNOWN (-1) means it hasn't been seen yet so we don't know.
  143.    This information remains valid for the rest of the compilation
  144.    of the current function; it is used to control register allocation.  */
  145.  
  146. short *reg_basic_block;
  147.  
  148. /* Indexed by n, gives number of times (REG n) is used or set, each
  149.    weighted by its loop-depth.
  150.    This information remains valid for the rest of the compilation
  151.    of the current function; it is used to control register allocation.  */
  152.  
  153. short *reg_n_refs;
  154.  
  155. /* Indexed by N, gives number of places register N dies.
  156.    This information remains valid for the rest of the compilation
  157.    of the current function; it is used to control register allocation.  */
  158.  
  159. short *reg_n_deaths;
  160.  
  161. /* Indexed by N, gives 1 if that reg is live across any CALL_INSNs.
  162.    This information remains valid for the rest of the compilation
  163.    of the current function; it is used to control register allocation.  */
  164.  
  165. int *reg_n_calls_crossed;
  166.  
  167. /* Total number of instructions at which (REG n) is live.
  168.    The larger this is, the less priority (REG n) gets for
  169.    allocation in a real register.
  170.    This information remains valid for the rest of the compilation
  171.    of the current function; it is used to control register allocation.
  172.  
  173.    local-alloc.c may alter this number to change the priority.
  174.  
  175.    Negative values are special.
  176.    -1 is used to mark a pseudo reg which has a constant or memory equivalent
  177.    and is used infrequently enough that it should not get a hard register.
  178.    -2 is used to mark a pseudo reg for a parameter, when a frame pointer
  179.    is not required.  global-alloc.c makes an allocno for this but does
  180.    not try to assign a hard register to it.  */
  181.  
  182. int *reg_live_length;
  183.  
  184. /* Element N is the next insn that uses (hard or pseudo) register number N
  185.    within the current basic block; or zero, if there is no such insn.
  186.    This is valid only during the final backward scan in propagate_block.  */
  187.  
  188. static rtx *reg_next_use;
  189.  
  190. /* Size of a regset for the current function,
  191.    in (1) bytes and (2) elements.  */
  192.  
  193. int regset_bytes;
  194. int regset_size;
  195.  
  196. /* Element N is first insn in basic block N.
  197.    This info lasts until we finish compiling the function.  */
  198.  
  199. rtx *basic_block_head;
  200.  
  201. /* Element N is last insn in basic block N.
  202.    This info lasts until we finish compiling the function.  */
  203.  
  204. rtx *basic_block_end;
  205.  
  206. /* Element N is a regset describing the registers live
  207.    at the start of basic block N.
  208.    This info lasts until we finish compiling the function.  */
  209.  
  210. regset *basic_block_live_at_start;
  211.  
  212. /* Regset of regs live when calls to `setjmp'-like functions happen.  */
  213.  
  214. regset regs_live_at_setjmp;
  215.  
  216. /* List made of EXPR_LIST rtx's which gives pairs of pseudo registers
  217.    that have to go in the same hard reg.
  218.    The first two regs in the list are a pair, and the next two
  219.    are another pair, etc.  */
  220. rtx regs_may_share;
  221.  
  222. /* Element N is nonzero if control can drop into basic block N
  223.    from the preceding basic block.  Freed after life_analysis.  */
  224.  
  225. static char *basic_block_drops_in;
  226.  
  227. /* Element N is depth within loops of the last insn in basic block number N.
  228.    Freed after life_analysis.  */
  229.  
  230. static short *basic_block_loop_depth;
  231.  
  232. /* Element N nonzero if basic block N can actually be reached.
  233.    Vector exists only during find_basic_blocks.  */
  234.  
  235. static char *block_live_static;
  236.  
  237. /* Depth within loops of basic block being scanned for lifetime analysis,
  238.    plus one.  This is the weight attached to references to registers.  */
  239.  
  240. static int loop_depth;
  241.  
  242. /* During propagate_block, this is set for the insn that follows
  243.    an insn to set the cc.  The value is non-zero if that insn is dead.  */
  244.  
  245. static int following_insn_dead;
  246.  
  247. /* During propagate_block, this contains the last MEM stored into.  It
  248.    is used to eliminate consecutive stores to the same location.  */
  249.  
  250. static rtx last_mem_set;
  251.  
  252. /* Forward declarations */
  253. static void find_basic_blocks ();
  254. static void life_analysis ();
  255. static void mark_label_ref ();
  256. void allocate_for_life_analysis (); /* Used also in stupid_life_analysis */
  257. static void init_regset_vector ();
  258. static void propagate_block ();
  259. static void mark_set_regs ();
  260. static void mark_used_regs ();
  261. static int insn_dead_p ();
  262. static int libcall_dead_p ();
  263. static int try_pre_increment ();
  264. static int try_pre_increment_1 ();
  265. static rtx find_use_as_address ();
  266. void dump_flow_info ();
  267.  
  268. /* Find basic blocks of the current function and perform data flow analysis.
  269.    F is the first insn of the function and NREGS the number of register numbers
  270.    in use.  */
  271.  
  272. void
  273. flow_analysis (f, nregs, file)
  274.      rtx f;
  275.      int nregs;
  276.      FILE *file;
  277. {
  278.   register rtx insn;
  279.   register int i;
  280.   register int max_uid = 0;
  281.  
  282.   /* Count the basic blocks.  Also find maximum insn uid value used.  */
  283.  
  284.   {
  285.     register RTX_CODE prev_code = JUMP_INSN;
  286.     register RTX_CODE code;
  287.  
  288.     for (insn = f, i = 0; insn; insn = NEXT_INSN (insn))
  289.       {
  290.     code = GET_CODE (insn);
  291.     if (INSN_UID (insn) > max_uid)
  292.       max_uid = INSN_UID (insn);
  293.     if (code == CODE_LABEL
  294.         || (prev_code != INSN && prev_code != CALL_INSN
  295.         && prev_code != CODE_LABEL
  296.         && (code == INSN || code == CALL_INSN || code == JUMP_INSN)))
  297.       i++;
  298.     if (code != NOTE)
  299.       prev_code = code;
  300.       }
  301.   }
  302.  
  303.   /* Allocate some tables that last till end of compiling this function
  304.      and some needed only in find_basic_blocks and life_analysis.  */
  305.  
  306.   n_basic_blocks = i;
  307.   basic_block_head = (rtx *) oballoc (n_basic_blocks * sizeof (rtx));
  308.   basic_block_end = (rtx *) oballoc (n_basic_blocks * sizeof (rtx));
  309.   basic_block_drops_in = (char *) alloca (n_basic_blocks);
  310.   basic_block_loop_depth = (short *) alloca (n_basic_blocks * sizeof (short));
  311.   uid_block_number = (short *) alloca ((max_uid + 1) * sizeof (short));
  312.   uid_volatile = (char *) alloca (max_uid + 1);
  313.   bzero (uid_volatile, max_uid + 1);
  314.  
  315.   find_basic_blocks (f);
  316.   life_analysis (f, nregs);
  317.   if (file)
  318.     dump_flow_info (file);
  319.  
  320.   basic_block_drops_in = 0;
  321.   uid_block_number = 0;
  322.   basic_block_loop_depth = 0;
  323. }
  324.  
  325. /* Find all basic blocks of the function whose first insn is F.
  326.    Store the correct data in the tables that describe the basic blocks,
  327.    set up the chains of references for each CODE_LABEL, and
  328.    delete any entire basic blocks that cannot be reached.  */
  329.  
  330. static void
  331. find_basic_blocks (f)
  332.      rtx f;
  333. {
  334.   register rtx insn;
  335.   register int i;
  336.   register char *block_live = (char *) alloca (n_basic_blocks);
  337.   register char *block_marked = (char *) alloca (n_basic_blocks);
  338.   /* List of label_refs to all labels whose addresses are taken
  339.      and used as data.  */
  340.   rtx label_value_list = 0;
  341.  
  342.   block_live_static = block_live;
  343.   bzero (block_live, n_basic_blocks);
  344.   bzero (block_marked, n_basic_blocks);
  345.  
  346.   /* Initialize with just block 0 reachable and no blocks marked.  */
  347.   if (n_basic_blocks > 0)
  348.     block_live[0] = 1;
  349.  
  350.   /* Initialize the ref chain of each label to 0.  */
  351.   /* Record where all the blocks start and end and their depth in loops.  */
  352.   /* For each insn, record the block it is in.  */
  353.   /* Also mark as reachable any blocks headed by labels that
  354.      must not be deleted.  */
  355.  
  356.   {
  357.     register RTX_CODE prev_code = JUMP_INSN;
  358.     register RTX_CODE code;
  359.     int depth = 1;
  360.  
  361.     for (insn = f, i = -1; insn; insn = NEXT_INSN (insn))
  362.       {
  363.     code = GET_CODE (insn);
  364.     if (code == NOTE)
  365.       {
  366.         if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG)
  367.           depth++;
  368.         else if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_END)
  369.           depth--;
  370.       }
  371.     else if (code == CODE_LABEL
  372.          || (prev_code != INSN && prev_code != CALL_INSN
  373.              && prev_code != CODE_LABEL
  374.              && (code == INSN || code == CALL_INSN || code == JUMP_INSN)))
  375.       {
  376.         basic_block_head[++i] = insn;
  377.         basic_block_end[i] = insn;
  378.         basic_block_loop_depth[i] = depth;
  379.         if (code == CODE_LABEL)
  380.           {
  381.         LABEL_REFS (insn) = insn;
  382.         /* Any label that cannot be deleted
  383.            is considered to start a reachable block.  */
  384.         if (LABEL_PRESERVE_P (insn))
  385.           block_live[i] = 1;
  386.           }
  387.       }
  388.     else if (code == INSN || code == CALL_INSN || code == JUMP_INSN)
  389.       {
  390.         basic_block_end[i] = insn;
  391.         basic_block_loop_depth[i] = depth;
  392.       }
  393.  
  394.     /* Make a list of all labels referred to other than by jumps.  */
  395.     if (code == INSN || code == CALL_INSN)
  396.       {
  397.         rtx note = find_reg_note (insn, REG_LABEL, 0);
  398.         if (note != 0)
  399.           label_value_list = gen_rtx (EXPR_LIST, VOIDmode,
  400.                       gen_rtx (LABEL_REF, Pmode, 
  401.                            XEXP (note, 0)),
  402.                       label_value_list);
  403.       }
  404.  
  405.     BLOCK_NUM (insn) = i;
  406.     if (code != NOTE)
  407.       prev_code = code;
  408.       }
  409.     if (i + 1 != n_basic_blocks)
  410.       abort ();
  411.   }
  412.  
  413.   /* Record which basic blocks control can drop in to.  */
  414.  
  415.   {
  416.     register int i;
  417.     for (i = 0; i < n_basic_blocks; i++)
  418.       {
  419.     register rtx insn = PREV_INSN (basic_block_head[i]);
  420.     /* TEMP1 is used to avoid a bug in Sequent's compiler.  */
  421.     register int temp1;
  422.     while (insn && GET_CODE (insn) == NOTE)
  423.       insn = PREV_INSN (insn);
  424.     temp1 = insn && GET_CODE (insn) != BARRIER;
  425.     basic_block_drops_in[i] = temp1;
  426.       }
  427.   }
  428.  
  429.   /* Now find which basic blocks can actually be reached
  430.      and put all jump insns' LABEL_REFS onto the ref-chains
  431.      of their target labels.  */
  432.  
  433.   if (n_basic_blocks > 0)
  434.     {
  435.       int something_marked = 1;
  436.  
  437.       /* Find all indirect jump insns and mark them as possibly jumping
  438.      to all the labels whose addresses are explicitly used.
  439.      This is because, when there are computed gotos,
  440.      we can't tell which labels they jump to, of all the possibilities.  */
  441.  
  442.       for (insn = f; insn; insn = NEXT_INSN (insn))
  443.     if (GET_CODE (insn) == JUMP_INSN
  444.         && GET_CODE (PATTERN (insn)) == SET
  445.         && SET_DEST (PATTERN (insn)) == pc_rtx
  446.         && GET_CODE (SET_SRC (PATTERN (insn))) == REG)
  447.       mark_label_ref (label_value_list, insn, 0);
  448.  
  449.       /* Pass over all blocks, marking each block that is reachable
  450.      and has not yet been marked.
  451.      Keep doing this until, in one pass, no blocks have been marked.
  452.      Then blocks_live and blocks_marked are identical and correct.
  453.      In addition, all jumps actually reachable have been marked.  */
  454.  
  455.       while (something_marked)
  456.     {
  457.       something_marked = 0;
  458.       for (i = 0; i < n_basic_blocks; i++)
  459.         if (block_live[i] && !block_marked[i])
  460.           {
  461.         block_marked[i] = 1;
  462.         something_marked = 1;
  463.         if (i + 1 < n_basic_blocks && basic_block_drops_in[i + 1])
  464.           block_live[i + 1] = 1;
  465.         insn = basic_block_end[i];
  466.         if (GET_CODE (insn) == JUMP_INSN)
  467.           mark_label_ref (PATTERN (insn), insn, 0);
  468.           }
  469.     }
  470.  
  471.       /* Now delete the code for any basic blocks that can't be reached.
  472.      They can occur because jump_optimize does not recognize
  473.      unreachable loops as unreachable.  */
  474.  
  475.       for (i = 0; i < n_basic_blocks; i++)
  476.     if (!block_live[i])
  477.       {
  478.         insn = basic_block_head[i];
  479.         while (1)
  480.           {
  481.         if (GET_CODE (insn) == BARRIER)
  482.           abort ();
  483.         if (GET_CODE (insn) != NOTE)
  484.           {
  485.             PUT_CODE (insn, NOTE);
  486.             NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
  487.             NOTE_SOURCE_FILE (insn) = 0;
  488.           }
  489.         if (insn == basic_block_end[i])
  490.           {
  491.             /* BARRIERs are between basic blocks, not part of one.
  492.                Delete a BARRIER if the preceding jump is deleted.
  493.                We cannot alter a BARRIER into a NOTE
  494.                because it is too short; but we can really delete
  495.                it because it is not part of a basic block.  */
  496.             if (NEXT_INSN (insn) != 0
  497.             && GET_CODE (NEXT_INSN (insn)) == BARRIER)
  498.               delete_insn (NEXT_INSN (insn));
  499.             break;
  500.           }
  501.         insn = NEXT_INSN (insn);
  502.           }
  503.         /* Each time we delete some basic blocks,
  504.            see if there is a jump around them that is
  505.            being turned into a no-op.  If so, delete it.  */
  506.  
  507.         if (block_live[i - 1])
  508.           {
  509.         register int j;
  510.         for (j = i; j < n_basic_blocks; j++)
  511.           if (block_live[j])
  512.             {
  513.               rtx label;
  514.               insn = basic_block_end[i - 1];
  515.               if (GET_CODE (insn) == JUMP_INSN
  516.               /* An unconditional jump is the only possibility
  517.                  we must check for, since a conditional one
  518.                  would make these blocks live.  */
  519.               && simplejump_p (insn)
  520.               && (label = XEXP (SET_SRC (PATTERN (insn)), 0), 1)
  521.               && INSN_UID (label) != 0
  522.               && BLOCK_NUM (label) == j)
  523.             {
  524.               PUT_CODE (insn, NOTE);
  525.               NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
  526.               NOTE_SOURCE_FILE (insn) = 0;
  527.               if (GET_CODE (NEXT_INSN (insn)) != BARRIER)
  528.                 abort ();
  529.               delete_insn (NEXT_INSN (insn));
  530.             }
  531.               break;
  532.             }
  533.           }
  534.       }
  535.     }
  536. }
  537.  
  538. /* Check expression X for label references;
  539.    if one is found, add INSN to the label's chain of references.
  540.  
  541.    CHECKDUP means check for and avoid creating duplicate references
  542.    from the same insn.  Such duplicates do no serious harm but
  543.    can slow life analysis.  CHECKDUP is set only when duplicates
  544.    are likely.  */
  545.  
  546. static void
  547. mark_label_ref (x, insn, checkdup)
  548.      rtx x, insn;
  549.      int checkdup;
  550. {
  551.   register RTX_CODE code;
  552.   register int i;
  553.   register char *fmt;
  554.  
  555.   /* We can be called with NULL when scanning label_value_list.  */
  556.   if (x == 0)
  557.     return;
  558.  
  559.   code = GET_CODE (x);
  560.   if (code == LABEL_REF)
  561.     {
  562.       register rtx label = XEXP (x, 0);
  563.       register rtx y;
  564.       if (GET_CODE (label) != CODE_LABEL)
  565.     abort ();
  566.       /* If the label was never emitted, this insn is junk,
  567.      but avoid a crash trying to refer to BLOCK_NUM (label).
  568.      This can happen as a result of a syntax error
  569.      and a diagnostic has already been printed.  */
  570.       if (INSN_UID (label) == 0)
  571.     return;
  572.       CONTAINING_INSN (x) = insn;
  573.       /* if CHECKDUP is set, check for duplicate ref from same insn
  574.      and don't insert.  */
  575.       if (checkdup)
  576.     for (y = LABEL_REFS (label); y != label; y = LABEL_NEXTREF (y))
  577.       if (CONTAINING_INSN (y) == insn)
  578.         return;
  579.       LABEL_NEXTREF (x) = LABEL_REFS (label);
  580.       LABEL_REFS (label) = x;
  581.       block_live_static[BLOCK_NUM (label)] = 1;
  582.       return;
  583.     }
  584.  
  585.   fmt = GET_RTX_FORMAT (code);
  586.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  587.     {
  588.       if (fmt[i] == 'e')
  589.     mark_label_ref (XEXP (x, i), insn, 0);
  590.       if (fmt[i] == 'E')
  591.     {
  592.       register int j;
  593.       for (j = 0; j < XVECLEN (x, i); j++)
  594.         mark_label_ref (XVECEXP (x, i, j), insn, 1);
  595.     }
  596.     }
  597. }
  598.  
  599. /* Determine which registers are live at the start of each
  600.    basic block of the function whose first insn is F.
  601.    NREGS is the number of registers used in F.
  602.    We allocate the vector basic_block_live_at_start
  603.    and the regsets that it points to, and fill them with the data.
  604.    regset_size and regset_bytes are also set here.  */
  605.  
  606. static void
  607. life_analysis (f, nregs)
  608.      rtx f;
  609.      int nregs;
  610. {
  611.   register regset tem;
  612.   int first_pass;
  613.   int changed;
  614.   /* For each basic block, a bitmask of regs
  615.      live on exit from the block.  */
  616.   regset *basic_block_live_at_end;
  617.   /* For each basic block, a bitmask of regs
  618.      live on entry to a successor-block of this block.
  619.      If this does not match basic_block_live_at_end,
  620.      that must be updated, and the block must be rescanned.  */
  621.   regset *basic_block_new_live_at_end;
  622.   /* For each basic block, a bitmask of regs
  623.      whose liveness at the end of the basic block
  624.      can make a difference in which regs are live on entry to the block.
  625.      These are the regs that are set within the basic block,
  626.      possibly excluding those that are used after they are set.  */
  627.   regset *basic_block_significant;
  628.   register int i;
  629.   rtx insn;
  630.  
  631.   struct obstack flow_obstack;
  632.  
  633.   gcc_obstack_init (&flow_obstack);
  634.  
  635.   max_regno = nregs;
  636.  
  637.   bzero (regs_ever_live, sizeof regs_ever_live);
  638.  
  639.   /* Allocate and zero out many data structures
  640.      that will record the data from lifetime analysis.  */
  641.  
  642.   allocate_for_life_analysis ();
  643.  
  644.   reg_next_use = (rtx *) alloca (nregs * sizeof (rtx));
  645.   bzero (reg_next_use, nregs * sizeof (rtx));
  646.  
  647.   /* Set up several regset-vectors used internally within this function.
  648.      Their meanings are documented above, with their declarations.  */
  649.  
  650.   basic_block_live_at_end = (regset *) alloca (n_basic_blocks * sizeof (regset));
  651.   /* Don't use alloca since that leads to a crash rather than an error message
  652.      if there isn't enough space.
  653.      Don't use oballoc since we may need to allocate other things during
  654.      this function on the temporary obstack.  */
  655.   tem = (regset) obstack_alloc (&flow_obstack, n_basic_blocks * regset_bytes);
  656.   bzero (tem, n_basic_blocks * regset_bytes);
  657.   init_regset_vector (basic_block_live_at_end, tem, n_basic_blocks, regset_bytes);
  658.  
  659.   basic_block_new_live_at_end = (regset *) alloca (n_basic_blocks * sizeof (regset));
  660.   tem = (regset) obstack_alloc (&flow_obstack, n_basic_blocks * regset_bytes);
  661.   bzero (tem, n_basic_blocks * regset_bytes);
  662.   init_regset_vector (basic_block_new_live_at_end, tem, n_basic_blocks, regset_bytes);
  663.  
  664.   basic_block_significant = (regset *) alloca (n_basic_blocks * sizeof (regset));
  665.   tem = (regset) obstack_alloc (&flow_obstack, n_basic_blocks * regset_bytes);
  666.   bzero (tem, n_basic_blocks * regset_bytes);
  667.   init_regset_vector (basic_block_significant, tem, n_basic_blocks, regset_bytes);
  668.  
  669.   /* Record which insns refer to any volatile memory
  670.      or for any reason can't be deleted just because they are dead stores.
  671.      Also, delete any insns that copy a register to itself. */
  672.  
  673.   for (insn = f; insn; insn = NEXT_INSN (insn))
  674.     {
  675.       enum rtx_code code1 = GET_CODE (insn);
  676.       if (code1 == CALL_INSN)
  677.     INSN_VOLATILE (insn) = 1;
  678.       else if (code1 == INSN || code1 == JUMP_INSN)
  679.     {
  680.       /* Delete (in effect) any obvious no-op moves.  */
  681.       if (GET_CODE (PATTERN (insn)) == SET
  682.           && GET_CODE (SET_DEST (PATTERN (insn))) == REG
  683.           && GET_CODE (SET_SRC (PATTERN (insn))) == REG
  684.           && REGNO (SET_DEST (PATTERN (insn))) ==
  685.             REGNO (SET_SRC (PATTERN (insn)))
  686.           /* Insns carrying these notes are useful later on.  */
  687.           && ! find_reg_note (insn, REG_EQUAL, 0))
  688.         {
  689.           PUT_CODE (insn, NOTE);
  690.           NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
  691.           NOTE_SOURCE_FILE (insn) = 0;
  692.         }
  693.       else if (GET_CODE (PATTERN (insn)) == PARALLEL)
  694.         {
  695.           /* If nothing but SETs of registers to themselves,
  696.          this insn can also be deleted.  */
  697.           for (i = 0; i < XVECLEN (PATTERN (insn), 0); i++)
  698.         {
  699.           rtx tem = XVECEXP (PATTERN (insn), 0, i);
  700.  
  701.           if (GET_CODE (tem) == USE
  702.               || GET_CODE (tem) == CLOBBER)
  703.             continue;
  704.             
  705.           if (GET_CODE (tem) != SET
  706.               || GET_CODE (SET_DEST (tem)) != REG
  707.               || GET_CODE (SET_SRC (tem)) != REG
  708.               || REGNO (SET_DEST (tem)) != REGNO (SET_SRC (tem)))
  709.             break;
  710.         }
  711.         
  712.           if (i == XVECLEN (PATTERN (insn), 0)
  713.           /* Insns carrying these notes are useful later on.  */
  714.           && ! find_reg_note (insn, REG_EQUAL, 0))
  715.         {
  716.           PUT_CODE (insn, NOTE);
  717.           NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
  718.           NOTE_SOURCE_FILE (insn) = 0;
  719.         }
  720.           else
  721.         INSN_VOLATILE (insn) = volatile_refs_p (PATTERN (insn));
  722.         }
  723.       else if (GET_CODE (PATTERN (insn)) != USE)
  724.         INSN_VOLATILE (insn) = volatile_refs_p (PATTERN (insn));
  725.       /* A SET that makes space on the stack cannot be dead.
  726.          (Such SETs occur only for allocating variable-size data,
  727.          so they will always have a PLUS or MINUS according to the
  728.          direction of stack growth.)
  729.          Even if this function never uses this stack pointer value,
  730.          signal handlers do!  */
  731.       else if (code1 == INSN && GET_CODE (PATTERN (insn)) == SET
  732.            && SET_DEST (PATTERN (insn)) == stack_pointer_rtx
  733. #ifdef STACK_GROWS_DOWNWARD
  734.            && GET_CODE (SET_SRC (PATTERN (insn))) == MINUS
  735. #else
  736.            && GET_CODE (SET_SRC (PATTERN (insn))) == PLUS
  737. #endif
  738.            && XEXP (SET_SRC (PATTERN (insn)), 0) == stack_pointer_rtx)
  739.         INSN_VOLATILE (insn) = 1;
  740.     }
  741.     }
  742.  
  743.   if (n_basic_blocks > 0)
  744. #ifdef EXIT_IGNORE_STACK
  745.     if (! EXIT_IGNORE_STACK
  746.     || (! FRAME_POINTER_REQUIRED && flag_omit_frame_pointer))
  747. #endif
  748.       {
  749.     /* If exiting needs the right stack value,
  750.        consider the stack pointer live at the end of the function.  */
  751.     basic_block_live_at_end[n_basic_blocks - 1]
  752.       [STACK_POINTER_REGNUM / REGSET_ELT_BITS]
  753.         |= 1 << (STACK_POINTER_REGNUM % REGSET_ELT_BITS);
  754.     basic_block_new_live_at_end[n_basic_blocks - 1]
  755.       [STACK_POINTER_REGNUM / REGSET_ELT_BITS]
  756.         |= 1 << (STACK_POINTER_REGNUM % REGSET_ELT_BITS);
  757.       }
  758.  
  759.   /* Propagate life info through the basic blocks
  760.      around the graph of basic blocks.
  761.  
  762.      This is a relaxation process: each time a new register
  763.      is live at the end of the basic block, we must scan the block
  764.      to determine which registers are, as a consequence, live at the beginning
  765.      of that block.  These registers must then be marked live at the ends
  766.      of all the blocks that can transfer control to that block.
  767.      The process continues until it reaches a fixed point.  */
  768.  
  769.   first_pass = 1;
  770.   changed = 1;
  771.   while (changed)
  772.     {
  773.       changed = 0;
  774.       for (i = n_basic_blocks - 1; i >= 0; i--)
  775.     {
  776.       int consider = first_pass;
  777.       int must_rescan = first_pass;
  778.       register int j;
  779.  
  780.       if (!first_pass)
  781.         {
  782.           /* Set CONSIDER if this block needs thinking about at all
  783.          (that is, if the regs live now at the end of it
  784.          are not the same as were live at the end of it when
  785.          we last thought about it).
  786.          Set must_rescan if it needs to be thought about
  787.          instruction by instruction (that is, if any additional
  788.          reg that is live at the end now but was not live there before
  789.          is one of the significant regs of this basic block).  */
  790.  
  791.           for (j = 0; j < regset_size; j++)
  792.         {
  793.           register int x = (basic_block_new_live_at_end[i][j]
  794.                     & ~basic_block_live_at_end[i][j]);
  795.           if (x)
  796.             consider = 1;
  797.           if (x & basic_block_significant[i][j])
  798.             {
  799.               must_rescan = 1;
  800.               consider = 1;
  801.               break;
  802.             }
  803.         }
  804.  
  805.           if (! consider)
  806.         continue;
  807.         }
  808.  
  809.       /* The live_at_start of this block may be changing,
  810.          so another pass will be required after this one.  */
  811.       changed = 1;
  812.  
  813.       if (! must_rescan)
  814.         {
  815.           /* No complete rescan needed;
  816.          just record those variables newly known live at end
  817.          as live at start as well.  */
  818.           for (j = 0; j < regset_size; j++)
  819.         {
  820.           register int x = basic_block_new_live_at_end[i][j]
  821.             & ~basic_block_live_at_end[i][j];
  822.           basic_block_live_at_start[i][j] |= x;
  823.           basic_block_live_at_end[i][j] |= x;
  824.         }
  825.         }
  826.       else
  827.         {
  828.           /* Update the basic_block_live_at_start
  829.          by propagation backwards through the block.  */
  830.           bcopy (basic_block_new_live_at_end[i],
  831.              basic_block_live_at_end[i], regset_bytes);
  832.           bcopy (basic_block_live_at_end[i],
  833.              basic_block_live_at_start[i], regset_bytes);
  834.           propagate_block (basic_block_live_at_start[i],
  835.                    basic_block_head[i], basic_block_end[i], 0,
  836.                    first_pass ? basic_block_significant[i] : 0,
  837.                    i);
  838.         }
  839.  
  840.       {
  841.         register rtx jump, head;
  842.         /* Update the basic_block_new_live_at_end's of the block
  843.            that falls through into this one (if any).  */
  844.         head = basic_block_head[i];
  845.         jump = PREV_INSN (head);
  846.         if (basic_block_drops_in[i])
  847.           {
  848.         register int from_block = BLOCK_NUM (jump);
  849.         register int j;
  850.         for (j = 0; j < regset_size; j++)
  851.           basic_block_new_live_at_end[from_block][j]
  852.             |= basic_block_live_at_start[i][j];
  853.           }
  854.         /* Update the basic_block_new_live_at_end's of
  855.            all the blocks that jump to this one.  */
  856.         if (GET_CODE (head) == CODE_LABEL)
  857.           for (jump = LABEL_REFS (head);
  858.            jump != head;
  859.            jump = LABEL_NEXTREF (jump))
  860.         {
  861.           register int from_block = BLOCK_NUM (CONTAINING_INSN (jump));
  862.           register int j;
  863.           for (j = 0; j < regset_size; j++)
  864.             basic_block_new_live_at_end[from_block][j]
  865.               |= basic_block_live_at_start[i][j];
  866.         }
  867.       }
  868. #ifdef USE_C_ALLOCA
  869.       alloca (0);
  870. #endif
  871.     }
  872.       first_pass = 0;
  873.     }
  874.  
  875.   /* The only pseudos that are live at the beginning of the function are
  876.      those that were not set anywhere in the function.  local-alloc doesn't
  877.      know how to handle these correctly, so mark them as not local to any
  878.      one basic block.  */
  879.  
  880.   if (n_basic_blocks > 0)
  881.     for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
  882.       if (basic_block_live_at_start[0][i / REGSET_ELT_BITS]
  883.       & (1 << (i % REGSET_ELT_BITS)))
  884.     reg_basic_block[i] = REG_BLOCK_GLOBAL;
  885.  
  886.   /* Now the life information is accurate.
  887.      Make one more pass over each basic block
  888.      to delete dead stores, create autoincrement addressing
  889.      and record how many times each register is used, is set, or dies.
  890.  
  891.      To save time, we operate directly in basic_block_live_at_end[i],
  892.      thus destroying it (in fact, converting it into a copy of
  893.      basic_block_live_at_start[i]).  This is ok now because
  894.      basic_block_live_at_end[i] is no longer used past this point.  */
  895.  
  896.   max_scratch = 0;
  897.  
  898.   for (i = 0; i < n_basic_blocks; i++)
  899.     {
  900.       propagate_block (basic_block_live_at_end[i],
  901.                basic_block_head[i], basic_block_end[i], 1, 0, i);
  902. #ifdef USE_C_ALLOCA
  903.       alloca (0);
  904. #endif
  905.     }
  906.  
  907. #if 0
  908.   /* Something live during a setjmp should not be put in a register
  909.      on certain machines which restore regs from stack frames
  910.      rather than from the jmpbuf.
  911.      But we don't need to do this for the user's variables, since
  912.      ANSI says only volatile variables need this.  */
  913. #ifdef LONGJMP_RESTORE_FROM_STACK
  914.   for (i = FIRST_PSEUDO_REGISTER; i < nregs; i++)
  915.     if (regs_live_at_setjmp[i / REGSET_ELT_BITS] & (1 << (i % REGSET_ELT_BITS))
  916.     && regno_reg_rtx[i] != 0 && ! REG_USERVAR_P (regno_reg_rtx[i]))
  917.       {
  918.     reg_live_length[i] = -1;
  919.     reg_basic_block[i] = -1;
  920.       }
  921. #endif
  922. #endif
  923.  
  924.   /* We have a problem with any pseudoreg that
  925.      lives across the setjmp.  ANSI says that if a
  926.      user variable does not change in value
  927.      between the setjmp and the longjmp, then the longjmp preserves it.
  928.      This includes longjmp from a place where the pseudo appears dead.
  929.      (In principle, the value still exists if it is in scope.)
  930.      If the pseudo goes in a hard reg, some other value may occupy
  931.      that hard reg where this pseudo is dead, thus clobbering the pseudo.
  932.      Conclusion: such a pseudo must not go in a hard reg.  */
  933.   for (i = FIRST_PSEUDO_REGISTER; i < nregs; i++)
  934.     if (regs_live_at_setjmp[i / REGSET_ELT_BITS] & (1 << (i % REGSET_ELT_BITS))
  935.     && regno_reg_rtx[i] != 0)
  936.       {
  937.     reg_live_length[i] = -1;
  938.     reg_basic_block[i] = -1;
  939.       }
  940.  
  941.   obstack_free (&flow_obstack, 0);
  942. }
  943.  
  944. /* Subroutines of life analysis.  */
  945.  
  946. /* Allocate the permanent data structures that represent the results
  947.    of life analysis.  Not static since used also for stupid life analysis.  */
  948.  
  949. void
  950. allocate_for_life_analysis ()
  951. {
  952.   register int i;
  953.   register regset tem;
  954.  
  955.   regset_size = ((max_regno + REGSET_ELT_BITS - 1) / REGSET_ELT_BITS);
  956.   regset_bytes = regset_size * sizeof (*(regset)0);
  957.  
  958.   reg_n_refs = (short *) oballoc (max_regno * sizeof (short));
  959.   bzero (reg_n_refs, max_regno * sizeof (short));
  960.  
  961.   reg_n_sets = (short *) oballoc (max_regno * sizeof (short));
  962.   bzero (reg_n_sets, max_regno * sizeof (short));
  963.  
  964.   reg_n_deaths = (short *) oballoc (max_regno * sizeof (short));
  965.   bzero (reg_n_deaths, max_regno * sizeof (short));
  966.  
  967.   reg_live_length = (int *) oballoc (max_regno * sizeof (int));
  968.   bzero (reg_live_length, max_regno * sizeof (int));
  969.  
  970.   reg_n_calls_crossed = (int *) oballoc (max_regno * sizeof (int));
  971.   bzero (reg_n_calls_crossed, max_regno * sizeof (int));
  972.  
  973.   reg_basic_block = (short *) oballoc (max_regno * sizeof (short));
  974.   for (i = 0; i < max_regno; i++)
  975.     reg_basic_block[i] = REG_BLOCK_UNKNOWN;
  976.  
  977.   basic_block_live_at_start = (regset *) oballoc (n_basic_blocks * sizeof (regset));
  978.   tem = (regset) oballoc (n_basic_blocks * regset_bytes);
  979.   bzero (tem, n_basic_blocks * regset_bytes);
  980.   init_regset_vector (basic_block_live_at_start, tem, n_basic_blocks, regset_bytes);
  981.  
  982.   regs_live_at_setjmp = (regset) oballoc (regset_bytes);
  983.   bzero (regs_live_at_setjmp, regset_bytes);
  984. }
  985.  
  986. /* Make each element of VECTOR point at a regset,
  987.    taking the space for all those regsets from SPACE.
  988.    SPACE is of type regset, but it is really as long as NELTS regsets.
  989.    BYTES_PER_ELT is the number of bytes in one regset.  */
  990.  
  991. static void
  992. init_regset_vector (vector, space, nelts, bytes_per_elt)
  993.      regset *vector;
  994.      regset space;
  995.      int nelts;
  996.      int bytes_per_elt;
  997. {
  998.   register int i;
  999.   register regset p = space;
  1000.  
  1001.   for (i = 0; i < nelts; i++)
  1002.     {
  1003.       vector[i] = p;
  1004.       p += bytes_per_elt / sizeof (*p);
  1005.     }
  1006. }
  1007.  
  1008. /* Compute the registers live at the beginning of a basic block
  1009.    from those live at the end.
  1010.  
  1011.    When called, OLD contains those live at the end.
  1012.    On return, it contains those live at the beginning.
  1013.    FIRST and LAST are the first and last insns of the basic block.
  1014.  
  1015.    FINAL is nonzero if we are doing the final pass which is not
  1016.    for computing the life info (since that has already been done)
  1017.    but for acting on it.  On this pass, we delete dead stores,
  1018.    set up the logical links and dead-variables lists of instructions,
  1019.    and merge instructions for autoincrement and autodecrement addresses.
  1020.  
  1021.    SIGNIFICANT is nonzero only the first time for each basic block.
  1022.    If it is nonzero, it points to a regset in which we store
  1023.    a 1 for each register that is set within the block.
  1024.  
  1025.    BNUM is the number of the basic block.  */
  1026.  
  1027. static void
  1028. propagate_block (old, first, last, final, significant, bnum)
  1029.      register regset old;
  1030.      rtx first;
  1031.      rtx last;
  1032.      int final;
  1033.      regset significant;
  1034.      int bnum;
  1035. {
  1036.   register rtx insn;
  1037.   rtx prev;
  1038.   regset live;
  1039.   regset dead;
  1040.  
  1041.   /* The following variables are used only if FINAL is nonzero.  */
  1042.   /* This vector gets one element for each reg that has been live
  1043.      at any point in the basic block that has been scanned so far.
  1044.      SOMETIMES_MAX says how many elements are in use so far.
  1045.      In each element, OFFSET is the byte-number within a regset
  1046.      for the register described by the element, and BIT is a mask
  1047.      for that register's bit within the byte.  */
  1048.   register struct foo { short offset; short bit; } *regs_sometimes_live;
  1049.   int sometimes_max = 0;
  1050.   /* This regset has 1 for each reg that we have seen live so far.
  1051.      It and REGS_SOMETIMES_LIVE are updated together.  */
  1052.   regset maxlive;
  1053.  
  1054.   /* The loop depth may change in the middle of a basic block.  Since we
  1055.      scan from end to beginning, we start with the depth at the end of the
  1056.      current basic block, and adjust as we pass ends and starts of loops.  */
  1057.   loop_depth = basic_block_loop_depth[bnum];
  1058.  
  1059.   dead = (regset) alloca (regset_bytes);
  1060.   live = (regset) alloca (regset_bytes);
  1061.  
  1062.   following_insn_dead = 0;
  1063.   last_mem_set = 0;
  1064.  
  1065.   /* Include any notes at the end of the block in the scan.
  1066.      This is in case the block ends with a call to setjmp.  */
  1067.  
  1068.   while (NEXT_INSN (last) != 0 && GET_CODE (NEXT_INSN (last)) == NOTE)
  1069.     {
  1070.       /* Look for loop boundaries, we are going forward here.  */
  1071.       last = NEXT_INSN (last);
  1072.       if (NOTE_LINE_NUMBER (last) == NOTE_INSN_LOOP_BEG)
  1073.     loop_depth++;
  1074.       else if (NOTE_LINE_NUMBER (last) == NOTE_INSN_LOOP_END)
  1075.     loop_depth--;
  1076.     }
  1077.  
  1078.   if (final)
  1079.     {
  1080.       register int i, offset, bit;
  1081.  
  1082.       num_scratch = 0;
  1083.       maxlive = (regset) alloca (regset_bytes);
  1084.       bcopy (old, maxlive, regset_bytes);
  1085.       regs_sometimes_live
  1086.     = (struct foo *) alloca (max_regno * sizeof (struct foo));
  1087.  
  1088.       /* Process the regs live at the end of the block.
  1089.      Enter them in MAXLIVE and REGS_SOMETIMES_LIVE.
  1090.      Also mark them as not local to any one basic block.  */
  1091.  
  1092.       for (offset = 0, i = 0; offset < regset_size; offset++)
  1093.     for (bit = 1; bit; bit <<= 1, i++)
  1094.       {
  1095.         if (i == max_regno)
  1096.           break;
  1097.         if (old[offset] & bit)
  1098.           {
  1099.         reg_basic_block[i] = REG_BLOCK_GLOBAL;
  1100.         regs_sometimes_live[sometimes_max].offset = offset;
  1101.         regs_sometimes_live[sometimes_max].bit = i % REGSET_ELT_BITS;
  1102.         sometimes_max++;
  1103.           }
  1104.       }
  1105.     }
  1106.  
  1107.   /* Scan the block an insn at a time from end to beginning.  */
  1108.  
  1109.   for (insn = last; ; insn = prev)
  1110.     {
  1111.       prev = PREV_INSN (insn);
  1112.  
  1113.       /* Look for loop boundaries, remembering that we are going backwards.  */
  1114.       if (GET_CODE (insn) == NOTE
  1115.       && NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_END)
  1116.     loop_depth++;
  1117.       else if (GET_CODE (insn) == NOTE
  1118.            && NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG)
  1119.     loop_depth--;
  1120.  
  1121.       /* If we have LOOP_DEPTH == 0, there has been a bookkeeping error. 
  1122.      Abort now rather than setting register status incorrectly.  */
  1123.       if (loop_depth == 0)
  1124.     abort ();
  1125.  
  1126.       /* If this is a call to `setjmp' et al,
  1127.      warn if any non-volatile datum is live.  */
  1128.  
  1129.       if (final && GET_CODE (insn) == NOTE
  1130.       && NOTE_LINE_NUMBER (insn) == NOTE_INSN_SETJMP)
  1131.     {
  1132.       int i;
  1133.       for (i = 0; i < regset_size; i++)
  1134.         regs_live_at_setjmp[i] |= old[i];
  1135.     }
  1136.  
  1137.       /* Update the life-status of regs for this insn.
  1138.      First DEAD gets which regs are set in this insn
  1139.      then LIVE gets which regs are used in this insn.
  1140.      Then the regs live before the insn
  1141.      are those live after, with DEAD regs turned off,
  1142.      and then LIVE regs turned on.  */
  1143.  
  1144.       if (GET_CODE (insn) == INSN
  1145.       || GET_CODE (insn) == JUMP_INSN
  1146.       || GET_CODE (insn) == CALL_INSN)
  1147.     {
  1148.       register int i;
  1149.       rtx note = find_reg_note (insn, REG_RETVAL, 0);
  1150.  
  1151. #ifdef HAVE_cc0
  1152.       /* If this is the insn that comes after a test or compare,
  1153.          record whether the ccs are dead.  */
  1154.       if (GET_CODE (PREV_INSN (insn)) == INSN
  1155.           && GET_CODE (PATTERN (PREV_INSN (insn))) == SET
  1156.           && SET_DEST (PATTERN (PREV_INSN (insn))) == cc0_rtx)
  1157.         following_insn_dead = insn_dead_p (PATTERN (insn), old);
  1158. #endif
  1159.  
  1160.       /* If an instruction consists of just dead store(s) on final pass,
  1161.          "delete" it by turning it into a NOTE of type NOTE_INSN_DELETED.
  1162.          We could really delete it with delete_insn, but that
  1163.          can cause trouble for first or last insn in a basic block.  */
  1164.       if (final && insn_dead_p (PATTERN (insn), old)
  1165.           /* Don't delete something that refers to volatile storage!  */
  1166.           && ! INSN_VOLATILE (insn))
  1167.         {
  1168.           rtx oldpat = PATTERN (insn);
  1169.           PUT_CODE (insn, NOTE);
  1170.           NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
  1171.           NOTE_SOURCE_FILE (insn) = 0;
  1172. #ifdef HAVE_cc0
  1173.           /* If this insn references cc0, delete previous too.  */
  1174.           if (reg_mentioned_p (cc0_rtx, oldpat))
  1175.         {
  1176.           rtx prev = prev_nonnote_insn (insn);
  1177.           if (! (GET_CODE (prev) == INSN
  1178.              && GET_CODE (PATTERN (prev)) == SET
  1179.              && SET_DEST (PATTERN (prev)) == cc0_rtx))
  1180.             abort ();
  1181.           PUT_CODE (prev, NOTE);
  1182.           NOTE_LINE_NUMBER (prev) = NOTE_INSN_DELETED;
  1183.           NOTE_SOURCE_FILE (prev) = 0;
  1184.         }
  1185. #endif
  1186.           /* If this insn is copying the return value from a library call,
  1187.          delete the entire library call.  */
  1188.           if (note && libcall_dead_p (oldpat, old, note, insn))
  1189.         {
  1190.           rtx first = XEXP (note, 0);
  1191.           rtx prev = insn;
  1192.           while (INSN_DELETED_P (first))
  1193.             first = NEXT_INSN (first);
  1194.           while (prev != first)
  1195.             {
  1196.               prev = PREV_INSN (prev);
  1197.               PUT_CODE (prev, NOTE);
  1198.               NOTE_LINE_NUMBER (prev) = NOTE_INSN_DELETED;
  1199.               NOTE_SOURCE_FILE (prev) = 0;
  1200.             }
  1201.         }
  1202.           goto flushed;
  1203.         }
  1204.  
  1205.       for (i = 0; i < regset_size; i++)
  1206.         {
  1207.           dead[i] = 0;    /* Faster than bzero here */
  1208.           live[i] = 0;    /* since regset_size is usually small */
  1209.         }
  1210.  
  1211.       /* See if this is an increment or decrement that can be
  1212.          merged into a following memory address.  */
  1213. #ifdef AUTO_INC_DEC
  1214.       {
  1215.         register rtx x = PATTERN (insn);
  1216.         /* Does this instruction increment or decrement a register?  */
  1217.         if (final && GET_CODE (x) == SET
  1218.         && GET_CODE (SET_DEST (x)) == REG
  1219.         && (GET_CODE (SET_SRC (x)) == PLUS
  1220.             || GET_CODE (SET_SRC (x)) == MINUS)
  1221.         && XEXP (SET_SRC (x), 0) == SET_DEST (x)
  1222.         && GET_CODE (XEXP (SET_SRC (x), 1)) == CONST_INT
  1223.         /* Ok, look for a following memory ref we can combine with.
  1224.            If one is found, change the memory ref to a PRE_INC
  1225.            or PRE_DEC, cancel this insn, and return 1.
  1226.            Return 0 if nothing has been done.  */
  1227.         && try_pre_increment_1 (insn))
  1228.           goto flushed;
  1229.       }
  1230. #endif /* AUTO_INC_DEC */
  1231.  
  1232.       /* If this is not the final pass, and this insn is copying the
  1233.          value of a library call and it's dead, don't scan the
  1234.          insns that perform the library call, so that the call's
  1235.          arguments are not marked live.  */
  1236.       if (note && insn_dead_p (PATTERN (insn), old)
  1237.           && libcall_dead_p (PATTERN (insn), old, note, insn))
  1238.         {
  1239.           /* Mark the dest reg as `significant'.  */
  1240.           mark_set_regs (old, dead, PATTERN (insn), 0, significant);
  1241.  
  1242.           insn = XEXP (note, 0);
  1243.           prev = PREV_INSN (insn);
  1244.         }
  1245.       else if (GET_CODE (PATTERN (insn)) == SET
  1246.            && SET_DEST (PATTERN (insn)) == stack_pointer_rtx
  1247.            && GET_CODE (SET_SRC (PATTERN (insn))) == PLUS
  1248.            && XEXP (SET_SRC (PATTERN (insn)), 0) == stack_pointer_rtx
  1249.            && GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == CONST_INT)
  1250.         /* We have an insn to pop a constant amount off the stack.
  1251.            (Such insns use PLUS regardless of the direction of the stack,
  1252.            and any insn to adjust the stack by a constant is always a pop.)
  1253.            These insns, if not dead stores, have no effect on life.  */
  1254.         ;
  1255.       else
  1256.         {
  1257.           /* LIVE gets the regs used in INSN; DEAD gets those set by it.  */
  1258.           mark_set_regs (old, dead, PATTERN (insn), final ? insn : 0,
  1259.                  significant);
  1260.           mark_used_regs (old, live, PATTERN (insn), final, insn);
  1261.  
  1262.           if (GET_CODE (insn) == CALL_INSN)
  1263.         {
  1264.           register int i;
  1265.  
  1266.           /* Each call clobbers all call-clobbered regs.
  1267.              Note that the function-value reg is one of these, and
  1268.              mark_set_regs has already had a chance to handle it. 
  1269.  
  1270.              If calls are considered to kill global registers, it
  1271.              can confused reorg into thinking that they are dead
  1272.              since they are not live at the start of a basic block
  1273.              and are never set.  Therefore, we do not kill
  1274.              global-regsisters on a function call even if they happen
  1275.              to be call-clobbered.  */
  1276.  
  1277.           for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  1278.             if (call_used_regs[i] && ! global_regs[i])
  1279.               dead[i / REGSET_ELT_BITS] |=
  1280.             (1 << (i % REGSET_ELT_BITS));
  1281.  
  1282.           /* The stack ptr is used (honorarily) by a CALL insn.  */
  1283.           live[STACK_POINTER_REGNUM / REGSET_ELT_BITS]
  1284.             |= (1 << (STACK_POINTER_REGNUM % REGSET_ELT_BITS));
  1285.         }
  1286.  
  1287.           /* Update OLD for the registers used or set.  */
  1288.           for (i = 0; i < regset_size; i++)
  1289.         {
  1290.           old[i] &= ~dead[i];
  1291.           old[i] |= live[i];
  1292.         }
  1293.  
  1294.           if (GET_CODE (insn) == CALL_INSN && final)
  1295.         {
  1296.           /* Any regs live at the time of a call instruction
  1297.              must not go in a register clobbered by calls.
  1298.              Find all regs now live and record this for them.  Show
  1299.              this call changes memory.  */
  1300.  
  1301.           register struct foo *p = regs_sometimes_live;
  1302.  
  1303.           for (i = 0; i < sometimes_max; i++, p++)
  1304.             if (old[p->offset] & (1 << p->bit))
  1305.               reg_n_calls_crossed[p->offset * REGSET_ELT_BITS + p->bit]+= 1;
  1306.           last_mem_set = 0;
  1307.         }
  1308.         }
  1309.  
  1310.       /* On final pass, add any additional sometimes-live regs
  1311.          into MAXLIVE and REGS_SOMETIMES_LIVE.
  1312.          Also update counts of how many insns each reg is live at.  */
  1313.  
  1314.       if (final)
  1315.         {
  1316.           for (i = 0; i < regset_size; i++)
  1317.         {
  1318.           register int diff = live[i] & ~maxlive[i];
  1319.  
  1320.           if (diff)
  1321.             {
  1322.               register int regno;
  1323.               maxlive[i] |= diff;
  1324.               for (regno = 0; diff && regno < REGSET_ELT_BITS; regno++)
  1325.             if (diff & (1 << regno))
  1326.               {
  1327.                 regs_sometimes_live[sometimes_max].offset = i;
  1328.                 regs_sometimes_live[sometimes_max].bit = regno;
  1329.                 diff &= ~ (1 << regno);
  1330.                 sometimes_max++;
  1331.               }
  1332.             }
  1333.         }
  1334.  
  1335.           {
  1336.         register struct foo *p = regs_sometimes_live;
  1337.         for (i = 0; i < sometimes_max; i++, p++)
  1338.           {
  1339.             if (old[p->offset] & (1 << p->bit))
  1340.               reg_live_length[p->offset * REGSET_ELT_BITS + p->bit]++;
  1341.           }
  1342.           }
  1343.         }
  1344.     }
  1345.     flushed: ;
  1346.       if (insn == first)
  1347.     break;
  1348.     }
  1349.  
  1350.   if (num_scratch > max_scratch)
  1351.     max_scratch = num_scratch;
  1352. }
  1353.  
  1354. /* Return 1 if X (the body of an insn, or part of it) is just dead stores
  1355.    (SET expressions whose destinations are registers dead after the insn).
  1356.    NEEDED is the regset that says which regs are alive after the insn.  */
  1357.  
  1358. static int
  1359. insn_dead_p (x, needed)
  1360.      rtx x;
  1361.      regset needed;
  1362. {
  1363.   register RTX_CODE code = GET_CODE (x);
  1364. #if 0
  1365.   /* Make sure insns to set the stack pointer are never deleted.  */
  1366.   needed[STACK_POINTER_REGNUM / REGSET_ELT_BITS]
  1367.     |= 1 << (STACK_POINTER_REGNUM % REGSET_ELT_BITS);
  1368. #endif
  1369.   /* Make sure insns to set the frame pointer are never deleted.  */
  1370.   needed[FRAME_POINTER_REGNUM / REGSET_ELT_BITS]
  1371.     |= 1 << (FRAME_POINTER_REGNUM % REGSET_ELT_BITS);
  1372.   if (ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM)
  1373.     /* Make sure insns to set the arg pointer are never deleted.  */
  1374.     needed[ARG_POINTER_REGNUM / REGSET_ELT_BITS]
  1375.       |= 1 << (ARG_POINTER_REGNUM % REGSET_ELT_BITS);
  1376.  
  1377.   /* If setting something that's a reg or part of one,
  1378.      see if that register's altered value will be live.  */
  1379.  
  1380.   if (code == SET)
  1381.     {
  1382.       register rtx r = SET_DEST (x);
  1383.       /* A SET that is a subroutine call cannot be dead.  */
  1384.       if (GET_CODE (SET_SRC (x)) == CALL)
  1385.     return 0;
  1386.  
  1387.       if (last_mem_set && ! MEM_VOLATILE_P (r)
  1388.       && rtx_equal_p (r, last_mem_set))
  1389.     return 1;
  1390.  
  1391.       while (GET_CODE (r) == SUBREG
  1392.          || GET_CODE (r) == STRICT_LOW_PART
  1393.          || GET_CODE (r) == ZERO_EXTRACT
  1394.          || GET_CODE (r) == SIGN_EXTRACT)
  1395.     r = SUBREG_REG (r);
  1396.       if (GET_CODE (r) == REG)
  1397.     {
  1398.       register int regno = REGNO (r);
  1399.       register int offset = regno / REGSET_ELT_BITS;
  1400.       register int bit = 1 << (regno % REGSET_ELT_BITS);
  1401.       return (! (regno < FIRST_PSEUDO_REGISTER && global_regs[regno])
  1402.           && (needed[offset] & bit) == 0);
  1403.     }
  1404.     }
  1405.   /* If performing several activities,
  1406.      insn is dead if each activity is individually dead.
  1407.      Also, CLOBBERs and USEs can be ignored; a CLOBBER or USE
  1408.      that's inside a PARALLEL doesn't make the insn worth keeping.  */
  1409.   else if (code == PARALLEL)
  1410.     {
  1411.       register int i = XVECLEN (x, 0);
  1412.       for (i--; i >= 0; i--)
  1413.     {
  1414.       rtx elt = XVECEXP (x, 0, i);
  1415.       if (!insn_dead_p (elt, needed)
  1416.           && GET_CODE (elt) != CLOBBER
  1417.           && GET_CODE (elt) != USE)
  1418.         return 0;
  1419.     }
  1420.       return 1;
  1421.     }
  1422.   /* We do not check CLOBBER or USE here.
  1423.      An insn consisting of just a CLOBBER or just a USE
  1424.      should not be deleted.  */
  1425.   return 0;
  1426. }
  1427.  
  1428. /* If X is the pattern of the last insn in a libcall, and assuming X is dead,
  1429.    return 1 if the entire library call is dead.
  1430.    This is true if X copies a register (hard or pseudo)
  1431.    and if the hard return  reg of the call insn is dead.
  1432.    (The caller should have tested the destination of X already for death.)
  1433.  
  1434.    If this insn doesn't just copy a register, then we don't
  1435.    have an ordinary libcall.  In that case, cse could not have
  1436.    managed to substitute the source for the dest later on,
  1437.    so we can assume the libcall is dead.
  1438.  
  1439.    NEEDED is the bit vector of pseudoregs live before this insn.
  1440.    NOTE is the REG_RETVAL note of the insn.  INSN is the insn itself.  */
  1441.  
  1442. static int
  1443. libcall_dead_p (x, needed, note, insn)
  1444.      rtx x;
  1445.      regset needed;
  1446.      rtx note;
  1447.      rtx insn;
  1448. {
  1449.   register RTX_CODE code = GET_CODE (x);
  1450.  
  1451.   if (code == SET)
  1452.     {
  1453.       register rtx r = SET_SRC (x);
  1454.       if (GET_CODE (r) == REG)
  1455.     {
  1456.       rtx call = XEXP (note, 0);
  1457.       register int regno;
  1458.       register int offset;
  1459.       register int bit;
  1460.  
  1461.       /* Find the call insn.  */
  1462.       while (call != insn && GET_CODE (call) != CALL_INSN)
  1463.         call = NEXT_INSN (call);
  1464.  
  1465.       /* If there is none, do nothing special,
  1466.          since ordinary death handling can understand these insns.  */
  1467.       if (call == insn)
  1468.         return 0;
  1469.  
  1470.       /* See if the hard reg holding the value is dead.  */
  1471.       /* If this is a "parallel" insn, find the call within it.  */
  1472.       call = PATTERN (call);
  1473.       if (GET_CODE (call) == PARALLEL)
  1474.         call = XVECEXP (call, 0, 0);
  1475.       if (GET_CODE (call) != SET)
  1476.         abort ();
  1477.  
  1478.       /* See if the hard reg holding the value is dead.  */
  1479.           regno = REGNO (SET_DEST (call));
  1480.       offset = regno / REGSET_ELT_BITS;
  1481.       bit = 1 << (regno % REGSET_ELT_BITS);
  1482.       return (needed[offset] & bit) == 0;
  1483.     }
  1484.     }
  1485.   return 1;
  1486. }
  1487.  
  1488. /* Return 1 if register REGNO was used before it was set.
  1489.    In other words, if it is live at function entry.  */
  1490.  
  1491. int
  1492. regno_uninitialized (regno)
  1493.      int regno;
  1494. {
  1495.   if (n_basic_blocks == 0)
  1496.     return 0;
  1497.  
  1498.   return (basic_block_live_at_start[0][regno / REGSET_ELT_BITS]
  1499.       & (1 << (regno % REGSET_ELT_BITS)));
  1500. }
  1501.  
  1502. /* 1 if register REGNO was alive at a place where `setjmp' was called
  1503.    and was set more than once or is an argument.
  1504.    Such regs may be clobbered by `longjmp'.  */
  1505.  
  1506. int
  1507. regno_clobbered_at_setjmp (regno)
  1508.      int regno;
  1509. {
  1510.   if (n_basic_blocks == 0)
  1511.     return 0;
  1512.  
  1513.   return ((reg_n_sets[regno] > 1
  1514.        || (basic_block_live_at_start[0][regno / REGSET_ELT_BITS]
  1515.            & (1 << (regno % REGSET_ELT_BITS))))
  1516.       && (regs_live_at_setjmp[regno / REGSET_ELT_BITS]
  1517.           & (1 << (regno % REGSET_ELT_BITS))));
  1518. }
  1519.  
  1520. /* Process the registers that are set within X.
  1521.    Their bits are set to 1 in the regset DEAD,
  1522.    because they are dead prior to this insn.
  1523.  
  1524.    If INSN is nonzero, it is the insn being processed
  1525.    and the fact that it is nonzero implies this is the FINAL pass
  1526.    in propagate_block.  In this case, various info about register
  1527.    usage is stored, LOG_LINKS fields of insns are set up.  */
  1528.  
  1529. static void mark_set_1 ();
  1530.  
  1531. static void
  1532. mark_set_regs (needed, dead, x, insn, significant)
  1533.      regset needed;
  1534.      regset dead;
  1535.      rtx x;
  1536.      rtx insn;
  1537.      regset significant;
  1538. {
  1539.   register RTX_CODE code = GET_CODE (x);
  1540.  
  1541.   if (code == SET || code == CLOBBER)
  1542.     mark_set_1 (needed, dead, x, insn, significant);
  1543.   else if (code == PARALLEL)
  1544.     {
  1545.       register int i;
  1546.       for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
  1547.     {
  1548.       code = GET_CODE (XVECEXP (x, 0, i));
  1549.       if (code == SET || code == CLOBBER)
  1550.         mark_set_1 (needed, dead, XVECEXP (x, 0, i), insn, significant);
  1551.     }
  1552.     }
  1553. }
  1554.  
  1555. /* Process a single SET rtx, X.  */
  1556.  
  1557. static void
  1558. mark_set_1 (needed, dead, x, insn, significant)
  1559.      regset needed;
  1560.      regset dead;
  1561.      rtx x;
  1562.      rtx insn;
  1563.      regset significant;
  1564. {
  1565.   register int regno;
  1566.   register rtx reg = SET_DEST (x);
  1567.  
  1568.   if (reg == 0)
  1569.     return;
  1570.  
  1571.   /* Modifying just one hardware register of a multi-reg value
  1572.      or just a byte field of a register
  1573.      does not mean the value from before this insn is now dead.
  1574.      But it does mean liveness of that register at the end of the block
  1575.      is significant.
  1576.  
  1577.      Within mark_set_1, however, we treat it as if the register is
  1578.      indeed modified.  mark_used_regs will, however, also treat this
  1579.      register as being used.  Thus, we treat these insns as setting a
  1580.      new value for the register as a function of its old value.  This
  1581.      cases LOG_LINKS to be made appropriately and this will help combine.  */
  1582.  
  1583.   while (GET_CODE (reg) == SUBREG || GET_CODE (reg) == ZERO_EXTRACT
  1584.      || GET_CODE (reg) == SIGN_EXTRACT
  1585.      || GET_CODE (reg) == STRICT_LOW_PART)
  1586.     reg = XEXP (reg, 0);
  1587.  
  1588.   /* If we are writing into memory or into a register mentioned in the
  1589.      address of the last thing stored into memory, show we don't know
  1590.      what the last store was.  If we are writing memory, save the address
  1591.      unless it is volatile.  */
  1592.   if (GET_CODE (reg) == MEM
  1593.       || (GET_CODE (reg) == REG
  1594.       && last_mem_set != 0 && reg_overlap_mentioned_p (reg, last_mem_set)))
  1595.     last_mem_set = 0;
  1596.     
  1597.   if (GET_CODE (reg) == MEM && ! side_effects_p (reg)
  1598.       /* There are no REG_INC notes for SP, so we can't assume we'll see 
  1599.      everything that invalidates it.  To be safe, don't eliminate any
  1600.      stores though SP; none of them should be redundant anyway.  */
  1601.       && ! reg_mentioned_p (stack_pointer_rtx, reg))
  1602.     last_mem_set = reg;
  1603.  
  1604.   if (GET_CODE (reg) == REG
  1605.       && (regno = REGNO (reg), regno != FRAME_POINTER_REGNUM)
  1606.       && regno != ARG_POINTER_REGNUM
  1607.       && ! (regno < FIRST_PSEUDO_REGISTER && global_regs[regno]))
  1608.     /* && regno != STACK_POINTER_REGNUM) -- let's try without this.  */
  1609.     {
  1610.       register int offset = regno / REGSET_ELT_BITS;
  1611.       register int bit = 1 << (regno % REGSET_ELT_BITS);
  1612.       int is_needed = 0;
  1613.  
  1614.       /* Mark it as a significant register for this basic block.  */
  1615.       if (significant)
  1616.     significant[offset] |= bit;
  1617.  
  1618.       /* Mark it as as dead before this insn.  */
  1619.       dead[offset] |= bit;
  1620.  
  1621.       /* A hard reg in a wide mode may really be multiple registers.
  1622.      If so, mark all of them just like the first.  */
  1623.       if (regno < FIRST_PSEUDO_REGISTER)
  1624.     {
  1625.       int n;
  1626.  
  1627.       /* Nothing below is needed for the stack pointer; get out asap.
  1628.          Eg, log links aren't needed, since combine won't use them.  */
  1629.       if (regno == STACK_POINTER_REGNUM)
  1630.         return;
  1631.  
  1632.       n = HARD_REGNO_NREGS (regno, GET_MODE (reg));
  1633.       while (--n > 0)
  1634.         {
  1635.           if (significant)
  1636.         significant[(regno + n) / REGSET_ELT_BITS]
  1637.           |= 1 << ((regno + n) % REGSET_ELT_BITS);
  1638.           dead[(regno + n) / REGSET_ELT_BITS]
  1639.         |= 1 << ((regno + n) % REGSET_ELT_BITS);
  1640.           is_needed |= (needed[(regno + n) / REGSET_ELT_BITS]
  1641.                 & 1 << ((regno + n) % REGSET_ELT_BITS));
  1642.         }
  1643.     }
  1644.       /* Additional data to record if this is the final pass.  */
  1645.       if (insn)
  1646.     {
  1647.       register rtx y = reg_next_use[regno];
  1648.       register int blocknum = BLOCK_NUM (insn);
  1649.  
  1650.       /* If this is a hard reg, record this function uses the reg.  */
  1651.  
  1652.       if (regno < FIRST_PSEUDO_REGISTER)
  1653.         {
  1654.           register int i;
  1655.           int endregno = regno + HARD_REGNO_NREGS (regno, GET_MODE (reg));
  1656.  
  1657.           for (i = regno; i < endregno; i++)
  1658.         {
  1659.           regs_ever_live[i] = 1;
  1660.           reg_n_sets[i]++;
  1661.         }
  1662.         }
  1663.       else
  1664.         {
  1665.           /* Keep track of which basic blocks each reg appears in.  */
  1666.  
  1667.           if (reg_basic_block[regno] == REG_BLOCK_UNKNOWN)
  1668.         reg_basic_block[regno] = blocknum;
  1669.           else if (reg_basic_block[regno] != blocknum)
  1670.         reg_basic_block[regno] = REG_BLOCK_GLOBAL;
  1671.  
  1672.           /* Count (weighted) references, stores, etc.  This counts a
  1673.          register twice if it is modified, but that is correct.  */
  1674.           reg_n_sets[regno]++;
  1675.  
  1676.           reg_n_refs[regno] += loop_depth;
  1677.           
  1678.           /* The insns where a reg is live are normally counted
  1679.          elsewhere, but we want the count to include the insn
  1680.          where the reg is set, and the normal counting mechanism
  1681.          would not count it.  */
  1682.           reg_live_length[regno]++;
  1683.         }
  1684.  
  1685.       /* The next use is no longer "next", since a store intervenes.  */
  1686.       reg_next_use[regno] = 0;
  1687.  
  1688.       if ((needed[offset] & bit) || is_needed)
  1689.         {
  1690.           /* Make a logical link from the next following insn
  1691.          that uses this register, back to this insn.
  1692.          The following insns have already been processed.
  1693.  
  1694.          We don't build a LOG_LINK for hard registers containing
  1695.          in ASM_OPERANDs.  If these registers get replaced,
  1696.          we might wind up changing the semantics of the insn,
  1697.          even if reload can make what appear to be valid assignments
  1698.          later.  */
  1699.           if (y && (BLOCK_NUM (y) == blocknum)
  1700.           && (regno >= FIRST_PSEUDO_REGISTER
  1701.               || asm_noperands (PATTERN (y)) < 0))
  1702.         LOG_LINKS (y)
  1703.           = gen_rtx (INSN_LIST, VOIDmode, insn, LOG_LINKS (y));
  1704.         }
  1705.       else
  1706.         {
  1707.           /* Note that dead stores have already been deleted when possible
  1708.          If we get here, we have found a dead store that cannot
  1709.          be eliminated (because the same insn does something useful).
  1710.          Indicate this by marking the reg being set as dying here.  */
  1711.           REG_NOTES (insn)
  1712.         = gen_rtx (EXPR_LIST, REG_UNUSED, reg, REG_NOTES (insn));
  1713.           reg_n_deaths[REGNO (reg)]++;
  1714.         }
  1715.     }
  1716.     }
  1717.  
  1718.   /* If this is the last pass and this is a SCRATCH, show it will be dying
  1719.      here and count it.  */
  1720.   else if (GET_CODE (reg) == SCRATCH && insn != 0)
  1721.     {
  1722.       REG_NOTES (insn)
  1723.     = gen_rtx (EXPR_LIST, REG_UNUSED, reg, REG_NOTES (insn));
  1724.       num_scratch++;
  1725.     }
  1726. }
  1727.  
  1728. #ifdef AUTO_INC_DEC
  1729.  
  1730. /* X is a MEM found in INSN.  See if we can convert it into an auto-increment
  1731.    reference.  */
  1732.  
  1733. static void
  1734. find_auto_inc (needed, x, insn)
  1735.      regset needed;
  1736.      rtx x;
  1737.      rtx insn;
  1738. {
  1739.   rtx addr = XEXP (x, 0);
  1740.   int offset = 0;
  1741.  
  1742.   /* Here we detect use of an index register which might be good for
  1743.      postincrement, postdecrement, preincrement, or predecrement.  */
  1744.  
  1745.   if (GET_CODE (addr) == PLUS && GET_CODE (XEXP (addr, 1)) == CONST_INT)
  1746.     offset = INTVAL (XEXP (addr, 1)), addr = XEXP (addr, 0);
  1747.  
  1748.   if (GET_CODE (addr) == REG)
  1749.     {
  1750.       register rtx y;
  1751.       register int size = GET_MODE_SIZE (GET_MODE (x));
  1752.       rtx use;
  1753.       rtx incr;
  1754.       int regno = REGNO (addr);
  1755.  
  1756.       /* Is the next use an increment that might make auto-increment? */
  1757.       incr = reg_next_use[regno];
  1758.       if (incr && GET_CODE (PATTERN (incr)) == SET
  1759.       && BLOCK_NUM (incr) == BLOCK_NUM (insn)
  1760.       /* Can't add side effects to jumps; if reg is spilled and
  1761.          reloaded, there's no way to store back the altered value.  */
  1762.       && GET_CODE (insn) != JUMP_INSN
  1763.       && (y = SET_SRC (PATTERN (incr)), GET_CODE (y) == PLUS)
  1764.       && XEXP (y, 0) == addr
  1765.       && GET_CODE (XEXP (y, 1)) == CONST_INT
  1766.       && (0
  1767. #ifdef HAVE_POST_INCREMENT
  1768.           || (INTVAL (XEXP (y, 1)) == size && offset == 0)
  1769. #endif
  1770. #ifdef HAVE_POST_DECREMENT
  1771.           || (INTVAL (XEXP (y, 1)) == - size && offset == 0)
  1772. #endif
  1773. #ifdef HAVE_PRE_INCREMENT
  1774.           || (INTVAL (XEXP (y, 1)) == size && offset == size)
  1775. #endif
  1776. #ifdef HAVE_PRE_DECREMENT
  1777.           || (INTVAL (XEXP (y, 1)) == - size && offset == - size)
  1778. #endif
  1779.           )
  1780.       /* Make sure this reg appears only once in this insn.  */
  1781.       && (use = find_use_as_address (PATTERN (insn), addr, offset),
  1782.           use != 0 && use != (rtx) 1))
  1783.     {
  1784.       int win = 0;
  1785.       rtx q = SET_DEST (PATTERN (incr));
  1786.  
  1787.       if (dead_or_set_p (incr, addr))
  1788.         win = 1;
  1789.       else if (GET_CODE (q) == REG && ! reg_used_between_p (q, insn, incr))
  1790.         {
  1791.           /* We have *p followed by q = p+size.
  1792.          Both p and q must be live afterward,
  1793.          and q must be dead before.
  1794.          Change it to q = p, ...*q..., q = q+size.
  1795.          Then fall into the usual case.  */
  1796.           rtx temp;
  1797.           start_sequence ();
  1798.           emit_move_insn (q, addr);
  1799.           temp = gen_sequence ();
  1800.           end_sequence ();
  1801.           emit_insn_before (temp, insn);
  1802.           XEXP (x, 0) = q;
  1803.           XEXP (y, 0) = q;
  1804.  
  1805.           /* INCR will become a NOTE and INSN won't contain a
  1806.          use of ADDR.  If a use of ADDR was just placed in
  1807.          the insn before INSN, make that the next use. 
  1808.          Otherwise, invalidate it.  */
  1809.           if (GET_CODE (PREV_INSN (insn)) == INSN
  1810.           && GET_CODE (PATTERN (PREV_INSN (insn))) == SET
  1811.           && SET_SRC (PATTERN (PREV_INSN (insn))) == addr)
  1812.         reg_next_use[regno] = PREV_INSN (insn);
  1813.           else
  1814.         reg_next_use[regno] = 0;
  1815.  
  1816.           addr = q;
  1817.           regno = REGNO (q);
  1818.           win = 1;
  1819.  
  1820.           /* REGNO is now used in INCR which is below INSN, but
  1821.          it previously wasn't live here.  If we don't mark
  1822.          it as needed, we'll put a REG_DEAD note for it
  1823.          on this insn, which is incorrect.  */
  1824.           needed[regno / REGSET_ELT_BITS]
  1825.         |= 1 << (regno % REGSET_ELT_BITS);
  1826.  
  1827.           /* If there are any calls between INSN and INCR, show
  1828.          that REGNO now crosses them.  */
  1829.           for (temp = insn; temp != incr; temp = NEXT_INSN (temp))
  1830.         if (GET_CODE (temp) == CALL_INSN)
  1831.           reg_n_calls_crossed[regno]++;
  1832.         }
  1833.  
  1834.       if (win)
  1835.         {
  1836.           /* We have found a suitable auto-increment: do POST_INC around
  1837.          the register here, and patch out the increment instruction 
  1838.          that follows. */
  1839.           XEXP (x, 0) = gen_rtx ((INTVAL (XEXP (y, 1)) == size
  1840.                       ? (offset ? PRE_INC : POST_INC)
  1841.                       : (offset ? PRE_DEC : POST_DEC)),
  1842.                      Pmode, addr);
  1843.  
  1844.           /* Record that this insn has an implicit side effect.  */
  1845.           REG_NOTES (insn)
  1846.         = gen_rtx (EXPR_LIST, REG_INC, addr, REG_NOTES (insn));
  1847.  
  1848.           /* Modify the old increment-insn to simply copy
  1849.          the already-incremented value of our register.  */
  1850.           SET_SRC (PATTERN (incr)) = addr;
  1851.           /* Indicate insn must be re-recognized.  */
  1852.           INSN_CODE (incr) = -1;
  1853.  
  1854.           /* If that makes it a no-op (copying the register into itself)
  1855.          then delete it so it won't appear to be a "use" and a "set"
  1856.          of this register.  */
  1857.           if (SET_DEST (PATTERN (incr)) == addr)
  1858.         {
  1859.           PUT_CODE (incr, NOTE);
  1860.           NOTE_LINE_NUMBER (incr) = NOTE_INSN_DELETED;
  1861.           NOTE_SOURCE_FILE (incr) = 0;
  1862.         }
  1863.  
  1864.           if (regno >= FIRST_PSEUDO_REGISTER)
  1865.         {
  1866.           /* Count an extra reference to the reg.  When a reg is
  1867.              incremented, spilling it is worse, so we want to make
  1868.              that less likely.  */
  1869.           reg_n_refs[regno] += loop_depth;
  1870.           /* Count the increment as a setting of the register,
  1871.              even though it isn't a SET in rtl.  */
  1872.           reg_n_sets[regno]++;
  1873.         }
  1874.         }
  1875.     }
  1876.     }
  1877. }
  1878. #endif /* AUTO_INC_DEC */
  1879.  
  1880. /* Scan expression X and store a 1-bit in LIVE for each reg it uses.
  1881.    This is done assuming the registers needed from X
  1882.    are those that have 1-bits in NEEDED.
  1883.  
  1884.    On the final pass, FINAL is 1.  This means try for autoincrement
  1885.    and count the uses and deaths of each pseudo-reg.
  1886.  
  1887.    INSN is the containing instruction.  */
  1888.  
  1889. static void
  1890. mark_used_regs (needed, live, x, final, insn)
  1891.      regset needed;
  1892.      regset live;
  1893.      rtx x;
  1894.      rtx insn;
  1895.      int final;
  1896. {
  1897.   register RTX_CODE code;
  1898.   register int regno;
  1899.  
  1900.  retry:
  1901.   code = GET_CODE (x);
  1902.   switch (code)
  1903.     {
  1904.     case LABEL_REF:
  1905.     case SYMBOL_REF:
  1906.     case CONST_INT:
  1907.     case CONST:
  1908.     case CONST_DOUBLE:
  1909.     case CC0:
  1910.     case PC:
  1911.     case CLOBBER:
  1912.     case ADDR_VEC:
  1913.     case ADDR_DIFF_VEC:
  1914.     case ASM_INPUT:
  1915.       return;
  1916.  
  1917.     case MEM:
  1918.       if (final)
  1919.     {
  1920.       /* Invalidate the data for the last MEM stored.  We could do this
  1921.          only if the addresses conflict, but this doesn't seem
  1922.          worthwhile.  */
  1923.       last_mem_set = 0;
  1924.  
  1925. #ifdef AUTO_INC_DEC
  1926.       find_auto_inc (needed, x, insn);
  1927. #endif
  1928.     }
  1929.       break;
  1930.  
  1931.     case REG:
  1932.       /* See a register other than being set
  1933.      => mark it as needed.  */
  1934.  
  1935.       regno = REGNO (x);
  1936.       if (regno != FRAME_POINTER_REGNUM)
  1937.       /* && regno != ARG_POINTER_REGNUM) -- and without this.  */
  1938.     /* && regno != STACK_POINTER_REGNUM) -- let's try without this.  */
  1939.     {
  1940.       register int offset = regno / REGSET_ELT_BITS;
  1941.       register int bit = 1 << (regno % REGSET_ELT_BITS);
  1942.       int is_needed = 0;
  1943.  
  1944.       live[offset] |= bit;
  1945.       /* A hard reg in a wide mode may really be multiple registers.
  1946.          If so, mark all of them just like the first.  */
  1947.       if (regno < FIRST_PSEUDO_REGISTER)
  1948.         {
  1949.           int n;
  1950.  
  1951.           /* For stack ptr or arg pointer,
  1952.          nothing below can be necessary, so waste no more time.  */
  1953.           if (regno == STACK_POINTER_REGNUM
  1954.           || regno == ARG_POINTER_REGNUM)
  1955.         return;
  1956.           /* No death notes for global register variables;
  1957.          their values are live after this function exits.  */
  1958.           if (global_regs[regno])
  1959.         return;
  1960.  
  1961.           n = HARD_REGNO_NREGS (regno, GET_MODE (x));
  1962.           while (--n > 0)
  1963.         {
  1964.           live[(regno + n) / REGSET_ELT_BITS]
  1965.             |= 1 << ((regno + n) % REGSET_ELT_BITS);
  1966.           is_needed |= (needed[(regno + n) / REGSET_ELT_BITS]
  1967.                 & 1 << ((regno + n) % REGSET_ELT_BITS));
  1968.         }
  1969.         }
  1970.       if (final)
  1971.         {
  1972.           /* Record where each reg is used, so when the reg
  1973.          is set we know the next insn that uses it.  */
  1974.  
  1975.           reg_next_use[regno] = insn;
  1976.  
  1977.           if (regno < FIRST_PSEUDO_REGISTER)
  1978.         {
  1979.           /* If a hard reg is being used,
  1980.              record that this function does use it.  */
  1981.  
  1982.           register int i;
  1983.           i = HARD_REGNO_NREGS (regno, GET_MODE (x));
  1984.           if (i == 0)
  1985.             i = 1;
  1986.           do
  1987.             regs_ever_live[regno + --i] = 1;
  1988.           while (i > 0);
  1989.         }
  1990.           else
  1991.         {
  1992.           /* Keep track of which basic block each reg appears in.  */
  1993.  
  1994.           register int blocknum = BLOCK_NUM (insn);
  1995.  
  1996.           if (reg_basic_block[regno] == REG_BLOCK_UNKNOWN)
  1997.             reg_basic_block[regno] = blocknum;
  1998.           else if (reg_basic_block[regno] != blocknum)
  1999.             reg_basic_block[regno] = REG_BLOCK_GLOBAL;
  2000.  
  2001.           /* Count (weighted) number of uses of each reg.  */
  2002.  
  2003.           reg_n_refs[regno] += loop_depth;
  2004.         }
  2005.  
  2006.           /* Record and count the insns in which a reg dies.
  2007.          If it is used in this insn and was dead below the insn
  2008.          then it dies in this insn. */
  2009.  
  2010.           if (!(needed[offset] & bit) && !is_needed
  2011.           && ! find_regno_note (insn, REG_DEAD, regno)
  2012.           /* Use the same scheme as combine.c, don't put both REG_DEAD
  2013.              and REG_UNUSED notes on the same insn.  */
  2014.           && ! find_regno_note (insn, REG_UNUSED, regno)
  2015.           /* The 386 needs these notes on its register 8.  */
  2016. #if 0
  2017.           && (regno >= FIRST_PSEUDO_REGISTER || ! fixed_regs[regno])
  2018. #endif
  2019.           )
  2020.         {
  2021.           REG_NOTES (insn)
  2022.             = gen_rtx (EXPR_LIST, REG_DEAD, x, REG_NOTES (insn));
  2023.           reg_n_deaths[regno]++;
  2024.         }
  2025.         }
  2026.     }
  2027.       return;
  2028.  
  2029.     case SET:
  2030.       {
  2031.     register rtx testreg = SET_DEST (x);
  2032.     int mark_dest = 0;
  2033.  
  2034.     /* If storing into MEM, don't show it as being used.  But do
  2035.        show the address as being used.  */
  2036.     if (GET_CODE (testreg) == MEM)
  2037.       {
  2038. #ifdef AUTO_INC_DEC
  2039.         if (final)
  2040.           find_auto_inc (needed, testreg, insn);
  2041. #endif
  2042.         mark_used_regs (needed, live, XEXP (testreg, 0), final, insn);
  2043.         mark_used_regs (needed, live, SET_SRC (x), final, insn);
  2044.         return;
  2045.       }
  2046.         
  2047.     /* Storing in STRICT_LOW_PART is like storing in a reg
  2048.        in that this SET might be dead, so ignore it in TESTREG.
  2049.        but in some other ways it is like using the reg.
  2050.  
  2051.        Storing in a SUBREG or a bit field is like storing the entire
  2052.        register in that if the register's value is not used
  2053.        then this SET is not needed.  */
  2054.     while (GET_CODE (testreg) == STRICT_LOW_PART
  2055.            || GET_CODE (testreg) == ZERO_EXTRACT
  2056.            || GET_CODE (testreg) == SIGN_EXTRACT
  2057.            || GET_CODE (testreg) == SUBREG)
  2058.       {
  2059.         /* Modifying a single register in an alternate mode
  2060.            does not use any of the old value.  But these other
  2061.            ways of storing in a register do use the old value.  */
  2062.         if (GET_CODE (testreg) == SUBREG
  2063.         && !(REG_SIZE (SUBREG_REG (testreg)) > REG_SIZE (testreg)))
  2064.           ;
  2065.         else
  2066.           mark_dest = 1;
  2067.  
  2068.         testreg = XEXP (testreg, 0);
  2069.       }
  2070.  
  2071.     /* If this is a store into a register,
  2072.        recursively scan the only value being stored,
  2073.        and only if the register's value is live after this insn.
  2074.        If the value being computed here would never be used
  2075.        then the values it uses don't need to be computed either.  */
  2076.  
  2077.     if (GET_CODE (testreg) == REG
  2078.         && (regno = REGNO (testreg), regno != FRAME_POINTER_REGNUM)
  2079.         && regno != ARG_POINTER_REGNUM
  2080.         && ! (regno < FIRST_PSEUDO_REGISTER && global_regs[regno]))
  2081. #if 0 /* This was added in 1.25, but screws up death notes for hard regs.
  2082.      It probably isn't really needed anyway.  */
  2083.         && (regno >= FIRST_PSEUDO_REGISTER
  2084.         || INSN_VOLATILE (insn))
  2085. #endif
  2086.       {
  2087.         register int offset = regno / REGSET_ELT_BITS;
  2088.         register int bit = 1 << (regno % REGSET_ELT_BITS);
  2089.         if ((needed[offset] & bit)
  2090.         /* If insn refers to volatile, we mustn't delete it,
  2091.            so its inputs are all needed.  */
  2092.         || INSN_VOLATILE (insn))
  2093.           {
  2094.         mark_used_regs (needed, live, SET_SRC (x), final, insn);
  2095.         if (mark_dest)
  2096.           mark_used_regs (needed, live, SET_DEST (x), final, insn);
  2097.           }
  2098.         return;
  2099.       }
  2100. #ifdef HAVE_cc0
  2101.     /* The inputs for setting the cc are dead if the cc use is dead.  */
  2102.     if (SET_DEST (x) == cc0_rtx)
  2103.       {
  2104.         if (! following_insn_dead)
  2105.           mark_used_regs (needed, live, SET_SRC (x), final, insn);
  2106.         return;
  2107.       }
  2108. #endif
  2109.       }
  2110.       break;
  2111.     }
  2112.  
  2113.   /* Recursively scan the operands of this expression.  */
  2114.  
  2115.   {
  2116.     register char *fmt = GET_RTX_FORMAT (code);
  2117.     register int i;
  2118.     
  2119.     for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  2120.       {
  2121.     if (fmt[i] == 'e')
  2122.       {
  2123.         /* Tail recursive case: save a function call level.  */
  2124.         if (i == 0)
  2125.           {
  2126.         x = XEXP (x, 0);
  2127.         goto retry;
  2128.           }
  2129.         mark_used_regs (needed, live, XEXP (x, i), final, insn);
  2130.       }
  2131.     else if (fmt[i] == 'E')
  2132.       {
  2133.         register int j;
  2134.         for (j = 0; j < XVECLEN (x, i); j++)
  2135.           mark_used_regs (needed, live, XVECEXP (x, i, j), final, insn);
  2136.       }
  2137.       }
  2138.   }
  2139. }
  2140.  
  2141. #ifdef AUTO_INC_DEC
  2142.  
  2143. static int
  2144. try_pre_increment_1 (insn)
  2145.      rtx insn;
  2146. {
  2147.   /* Find the next use of this reg.  If in same basic block,
  2148.      make it do pre-increment or pre-decrement if appropriate.  */
  2149.   rtx x = PATTERN (insn);
  2150.   int amount = ((GET_CODE (SET_SRC (x)) == PLUS ? 1 : -1)
  2151.         * INTVAL (XEXP (SET_SRC (x), 1)));
  2152.   int regno = REGNO (SET_DEST (x));
  2153.   rtx y = reg_next_use[regno];
  2154.   if (y != 0
  2155.       && BLOCK_NUM (y) == BLOCK_NUM (insn)
  2156.       && try_pre_increment (y, SET_DEST (PATTERN (insn)),
  2157.                 amount))
  2158.     {
  2159.       /* We have found a suitable auto-increment
  2160.      and already changed insn Y to do it.
  2161.      So flush this increment-instruction.  */
  2162.       PUT_CODE (insn, NOTE);
  2163.       NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
  2164.       NOTE_SOURCE_FILE (insn) = 0;
  2165.       /* Count a reference to this reg for the increment
  2166.      insn we are deleting.  When a reg is incremented.
  2167.      spilling it is worse, so we want to make that
  2168.      less likely.  */
  2169.       if (regno >= FIRST_PSEUDO_REGISTER)
  2170.     {
  2171.       reg_n_refs[regno] += loop_depth;
  2172.       reg_n_sets[regno]++;
  2173.     }
  2174.       return 1;
  2175.     }
  2176.   return 0;
  2177. }
  2178.  
  2179. /* Try to change INSN so that it does pre-increment or pre-decrement
  2180.    addressing on register REG in order to add AMOUNT to REG.
  2181.    AMOUNT is negative for pre-decrement.
  2182.    Returns 1 if the change could be made.
  2183.    This checks all about the validity of the result of modifying INSN.  */
  2184.  
  2185. static int
  2186. try_pre_increment (insn, reg, amount)
  2187.      rtx insn, reg;
  2188.      int amount;
  2189. {
  2190.   register rtx use;
  2191.  
  2192.   /* Nonzero if we can try to make a pre-increment or pre-decrement.
  2193.      For example, addl $4,r1; movl (r1),... can become movl +(r1),...  */
  2194.   int pre_ok = 0;
  2195.   /* Nonzero if we can try to make a post-increment or post-decrement.
  2196.      For example, addl $4,r1; movl -4(r1),... can become movl (r1)+,...
  2197.      It is possible for both PRE_OK and POST_OK to be nonzero if the machine
  2198.      supports both pre-inc and post-inc, or both pre-dec and post-dec.  */
  2199.   int post_ok = 0;
  2200.  
  2201.   /* Nonzero if the opportunity actually requires post-inc or post-dec.  */
  2202.   int do_post = 0;
  2203.  
  2204.   /* From the sign of increment, see which possibilities are conceivable
  2205.      on this target machine.  */
  2206. #ifdef HAVE_PRE_INCREMENT
  2207.   if (amount > 0)
  2208.     pre_ok = 1;
  2209. #endif
  2210. #ifdef HAVE_POST_INCREMENT
  2211.   if (amount > 0)
  2212.     post_ok = 1;
  2213. #endif
  2214.  
  2215. #ifdef HAVE_PRE_DECREMENT
  2216.   if (amount < 0)
  2217.     pre_ok = 1;
  2218. #endif
  2219. #ifdef HAVE_POST_DECREMENT
  2220.   if (amount < 0)
  2221.     post_ok = 1;
  2222. #endif
  2223.  
  2224.   if (! (pre_ok || post_ok))
  2225.     return 0;
  2226.  
  2227.   /* It is not safe to add a side effect to a jump insn
  2228.      because if the incremented register is spilled and must be reloaded
  2229.      there would be no way to store the incremented value back in memory.  */
  2230.  
  2231.   if (GET_CODE (insn) == JUMP_INSN)
  2232.     return 0;
  2233.  
  2234.   use = 0;
  2235.   if (pre_ok)
  2236.     use = find_use_as_address (PATTERN (insn), reg, 0);
  2237.   if (post_ok && (use == 0 || use == (rtx) 1))
  2238.     {
  2239.       use = find_use_as_address (PATTERN (insn), reg, -amount);
  2240.       do_post = 1;
  2241.     }
  2242.  
  2243.   if (use == 0 || use == (rtx) 1)
  2244.     return 0;
  2245.  
  2246.   if (GET_MODE_SIZE (GET_MODE (use)) != (amount > 0 ? amount : - amount))
  2247.     return 0;
  2248.  
  2249.   XEXP (use, 0) = gen_rtx (amount > 0
  2250.                ? (do_post ? POST_INC : PRE_INC)
  2251.                : (do_post ? POST_DEC : PRE_DEC),
  2252.                Pmode, reg);
  2253.  
  2254.   /* Record that this insn now has an implicit side effect on X.  */
  2255.   REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, reg, REG_NOTES (insn));
  2256.   return 1;
  2257. }
  2258.  
  2259. #endif /* AUTO_INC_DEC */
  2260.  
  2261. /* Find the place in the rtx X where REG is used as a memory address.
  2262.    Return the MEM rtx that so uses it.
  2263.    If PLUSCONST is nonzero, search instead for a memory address equivalent to
  2264.    (plus REG (const_int PLUSCONST)).
  2265.  
  2266.    If such an address does not appear, return 0.
  2267.    If REG appears more than once, or is used other than in such an address,
  2268.    return (rtx)1.  */
  2269.  
  2270. static rtx
  2271. find_use_as_address (x, reg, plusconst)
  2272.      register rtx x;
  2273.      rtx reg;
  2274.      int plusconst;
  2275. {
  2276.   enum rtx_code code = GET_CODE (x);
  2277.   char *fmt = GET_RTX_FORMAT (code);
  2278.   register int i;
  2279.   register rtx value = 0;
  2280.   register rtx tem;
  2281.  
  2282.   if (code == MEM && XEXP (x, 0) == reg && plusconst == 0)
  2283.     return x;
  2284.  
  2285.   if (code == MEM && GET_CODE (XEXP (x, 0)) == PLUS
  2286.       && XEXP (XEXP (x, 0), 0) == reg
  2287.       && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
  2288.       && INTVAL (XEXP (XEXP (x, 0), 1)) == plusconst)
  2289.     return x;
  2290.  
  2291.   if (code == SIGN_EXTRACT || code == ZERO_EXTRACT)
  2292.     {
  2293.       /* If REG occurs inside a MEM used in a bit-field reference,
  2294.      that is unacceptable.  */
  2295.       if (find_use_as_address (XEXP (x, 0), reg, 0) != 0)
  2296.     return (rtx) 1;
  2297.     }
  2298.  
  2299.   if (x == reg)
  2300.     return (rtx) 1;
  2301.  
  2302.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  2303.     {
  2304.       if (fmt[i] == 'e')
  2305.     {
  2306.       tem = find_use_as_address (XEXP (x, i), reg, plusconst);
  2307.       if (value == 0)
  2308.         value = tem;
  2309.       else if (tem != 0)
  2310.         return (rtx) 1;
  2311.     }
  2312.       if (fmt[i] == 'E')
  2313.     {
  2314.       register int j;
  2315.       for (j = XVECLEN (x, i) - 1; j >= 0; j--)
  2316.         {
  2317.           tem = find_use_as_address (XVECEXP (x, i, j), reg, plusconst);
  2318.           if (value == 0)
  2319.         value = tem;
  2320.           else if (tem != 0)
  2321.         return (rtx) 1;
  2322.         }
  2323.     }
  2324.     }
  2325.  
  2326.   return value;
  2327. }
  2328.  
  2329. /* Write information about registers and basic blocks into FILE.
  2330.    This is part of making a debugging dump.  */
  2331.  
  2332. void
  2333. dump_flow_info (file)
  2334.      FILE *file;
  2335. {
  2336.   register int i;
  2337.   static char *reg_class_names[] = REG_CLASS_NAMES;
  2338.  
  2339.   fprintf (file, "%d registers.\n", max_regno);
  2340.  
  2341.   for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
  2342.     if (reg_n_refs[i])
  2343.       {
  2344.     enum reg_class class;
  2345.     fprintf (file, "\nRegister %d used %d times across %d insns",
  2346.          i, reg_n_refs[i], reg_live_length[i]);
  2347.     if (reg_basic_block[i] >= 0)
  2348.       fprintf (file, " in block %d", reg_basic_block[i]);
  2349.     if (reg_n_deaths[i] != 1)
  2350.       fprintf (file, "; dies in %d places", reg_n_deaths[i]);
  2351.     if (reg_n_calls_crossed[i] == 1)
  2352.       fprintf (file, "; crosses 1 call");
  2353.     else if (reg_n_calls_crossed[i])
  2354.       fprintf (file, "; crosses %d calls", reg_n_calls_crossed[i]);
  2355.     if (PSEUDO_REGNO_BYTES (i) != UNITS_PER_WORD)
  2356.       fprintf (file, "; %d bytes", PSEUDO_REGNO_BYTES (i));
  2357.     class = reg_preferred_class (i);
  2358.     if (class != GENERAL_REGS)
  2359.       {
  2360.         if (reg_preferred_or_nothing (i))
  2361.           fprintf (file, "; %s or none", reg_class_names[(int) class]);
  2362.         else
  2363.           fprintf (file, "; pref %s", reg_class_names[(int) class]);
  2364.       }
  2365.     if (REGNO_POINTER_FLAG (i))
  2366.       fprintf (file, "; pointer");
  2367.     fprintf (file, ".\n");
  2368.       }
  2369.   fprintf (file, "\n%d basic blocks.\n", n_basic_blocks);
  2370.   for (i = 0; i < n_basic_blocks; i++)
  2371.     {
  2372.       register rtx head, jump;
  2373.       register int regno;
  2374.       fprintf (file, "\nBasic block %d: first insn %d, last %d.\n",
  2375.            i,
  2376.            INSN_UID (basic_block_head[i]),
  2377.            INSN_UID (basic_block_end[i]));
  2378.       /* The control flow graph's storage is freed
  2379.      now when flow_analysis returns.
  2380.      Don't try to print it if it is gone.  */
  2381.       if (basic_block_drops_in)
  2382.     {
  2383.       fprintf (file, "Reached from blocks: ");
  2384.       head = basic_block_head[i];
  2385.       if (GET_CODE (head) == CODE_LABEL)
  2386.         for (jump = LABEL_REFS (head);
  2387.          jump != head;
  2388.          jump = LABEL_NEXTREF (jump))
  2389.           {
  2390.         register int from_block = BLOCK_NUM (CONTAINING_INSN (jump));
  2391.         fprintf (file, " %d", from_block);
  2392.           }
  2393.       if (basic_block_drops_in[i])
  2394.         fprintf (file, " previous");
  2395.     }
  2396.       fprintf (file, "\nRegisters live at start:");
  2397.       for (regno = 0; regno < max_regno; regno++)
  2398.     {
  2399.       register int offset = regno / REGSET_ELT_BITS;
  2400.       register int bit = 1 << (regno % REGSET_ELT_BITS);
  2401.       if (basic_block_live_at_start[i][offset] & bit)
  2402.           fprintf (file, " %d", regno);
  2403.     }
  2404.       fprintf (file, "\n");
  2405.     }
  2406.   fprintf (file, "\n");
  2407. }
  2408.