home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / rtlanal.c < prev    next >
C/C++ Source or Header  |  1991-08-01  |  33KB  |  1,347 lines

  1. /* Analyze RTL for C-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. #include "config.h"
  22. #include "rtl.h"
  23.  
  24. void note_stores ();
  25. int reg_set_p ();
  26.  
  27. /* Bit flags that specify the machine subtype we are compiling for.
  28.    Bits are tested using macros TARGET_... defined in the tm-...h file
  29.    and set by `-m...' switches.  Must be defined in rtlanal.c.  */
  30.  
  31. int target_flags;
  32.  
  33. /* Return 1 if the value of X is unstable
  34.    (would be different at a different point in the program).
  35.    The frame pointer, arg pointer, etc. are considered stable
  36.    (within one function) and so is anything marked `unchanging'.  */
  37.  
  38. int
  39. rtx_unstable_p (x)
  40.      rtx x;
  41. {
  42.   register RTX_CODE code = GET_CODE (x);
  43.   register int i;
  44.   register char *fmt;
  45.  
  46.   if (code == MEM)
  47.     return ! RTX_UNCHANGING_P (x);
  48.  
  49.   if (code == QUEUED)
  50.     return 1;
  51.  
  52.   if (code == CONST || code == CONST_INT)
  53.     return 0;
  54.  
  55.   if (code == REG)
  56.     return ! (REGNO (x) == FRAME_POINTER_REGNUM
  57.           || REGNO (x) == ARG_POINTER_REGNUM
  58.           || RTX_UNCHANGING_P (x));
  59.  
  60.   fmt = GET_RTX_FORMAT (code);
  61.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  62.     if (fmt[i] == 'e')
  63.       if (rtx_unstable_p (XEXP (x, i)))
  64.     return 1;
  65.   return 0;
  66. }
  67.  
  68. /* Return 1 if X has a value that can vary even between two
  69.    executions of the program.  0 means X can be compared reliably
  70.    against certain constants or near-constants.
  71.    The frame pointer and the arg pointer are considered constant.  */
  72.  
  73. int
  74. rtx_varies_p (x)
  75.      rtx x;
  76. {
  77.   register RTX_CODE code = GET_CODE (x);
  78.   register int i;
  79.   register char *fmt;
  80.  
  81.   if (code == MEM)
  82.     return 1;
  83.  
  84.   if (code == QUEUED)
  85.     return 1;
  86.  
  87.   if (code == CONST || code == CONST_INT)
  88.     return 0;
  89.  
  90.   if (code == REG)
  91.     return ! (REGNO (x) == FRAME_POINTER_REGNUM
  92.           || REGNO (x) == ARG_POINTER_REGNUM);
  93.  
  94.   /* The operand 0 of a LO_SUM is considered constant
  95.      (in fact is it related specifically to operand 1).  */
  96.   if (code == LO_SUM)
  97.     return rtx_varies_p (XEXP (x, 1));
  98.  
  99.   fmt = GET_RTX_FORMAT (code);
  100.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  101.     if (fmt[i] == 'e')
  102.       if (rtx_varies_p (XEXP (x, i)))
  103.     return 1;
  104.   return 0;
  105. }
  106.  
  107. /* Return 1 if X refers to a memory location whose address 
  108.    cannot be compared reliably with constant addresses,
  109.    or if X refers to a BLKmode memory object.  */
  110.  
  111. int
  112. rtx_addr_varies_p (x)
  113.      rtx x;
  114. {
  115.   register enum rtx_code code;
  116.   register int i;
  117.   register char *fmt;
  118.  
  119.   if (x == 0)
  120.     return 0;
  121.  
  122.   code = GET_CODE (x);
  123.   if (code == MEM)
  124.     return GET_MODE (x) == BLKmode || rtx_varies_p (XEXP (x, 0));
  125.  
  126.   fmt = GET_RTX_FORMAT (code);
  127.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  128.     if (fmt[i] == 'e')
  129.       if (rtx_addr_varies_p (XEXP (x, i)))
  130.     return 1;
  131.   return 0;
  132. }
  133.  
  134. /* Return the value of the integer term in X, if one is apparent;
  135.    otherwise return 0.
  136.    Only obvious integer terms are detected.
  137.    This is used in cse.c with the `related_value' field.*/
  138.  
  139. int
  140. get_integer_term (x)
  141.      rtx x;
  142. {
  143.   if (GET_CODE (x) == CONST)
  144.     x = XEXP (x, 0);
  145.  
  146.   if (GET_CODE (x) == MINUS
  147.       && GET_CODE (XEXP (x, 1)) == CONST_INT)
  148.     return - INTVAL (XEXP (x, 1));
  149.   if (GET_CODE (x) == PLUS
  150.       && GET_CODE (XEXP (x, 1)) == CONST_INT)
  151.     return INTVAL (XEXP (x, 1));
  152.   return 0;
  153. }
  154.  
  155. /* If X is a constant, return the value sans apparent integer term;
  156.    otherwise return 0.
  157.    Only obvious integer terms are detected.  */
  158.  
  159. rtx
  160. get_related_value (x)
  161.      rtx x;
  162. {
  163.   if (GET_CODE (x) != CONST)
  164.     return 0;
  165.   x = XEXP (x, 0);
  166.   if (GET_CODE (x) == PLUS
  167.       && GET_CODE (XEXP (x, 1)) == CONST_INT)
  168.     return XEXP (x, 0);
  169.   else if (GET_CODE (x) == MINUS
  170.        && GET_CODE (XEXP (x, 1)) == CONST_INT)
  171.     return XEXP (x, 0);
  172.   return 0;
  173. }
  174.  
  175. /* Nonzero if register REG appears somewhere within IN.
  176.    Also works if REG is not a register; in this case it checks
  177.    for a subexpression of IN that is Lisp "equal" to REG.  */
  178.  
  179. int
  180. reg_mentioned_p (reg, in)
  181.      register rtx reg, in;
  182. {
  183.   register char *fmt;
  184.   register int i;
  185.   register enum rtx_code code;
  186.  
  187.   if (in == 0)
  188.     return 0;
  189.  
  190.   if (reg == in)
  191.     return 1;
  192.  
  193.   if (GET_CODE (in) == LABEL_REF)
  194.     return reg == XEXP (in, 0);
  195.  
  196.   code = GET_CODE (in);
  197.  
  198.   switch (code)
  199.     {
  200.       /* Compare registers by number.  */
  201.     case REG:
  202.       return GET_CODE (reg) == REG && REGNO (in) == REGNO (reg);
  203.  
  204.       /* These codes have no constituent expressions
  205.      and are unique.  */
  206.     case SCRATCH:
  207.     case CC0:
  208.     case PC:
  209.       return 0;
  210.  
  211.     case CONST_INT:
  212.       return GET_CODE (reg) == CONST_INT && INTVAL (in) == INTVAL (reg);
  213.       
  214.     case CONST_DOUBLE:
  215.       /* These are kept unique for a given value.  */
  216.       return 0;
  217.     }
  218.  
  219.   if (GET_CODE (reg) == code && rtx_equal_p (reg, in))
  220.     return 1;
  221.  
  222.   fmt = GET_RTX_FORMAT (code);
  223.  
  224.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  225.     {
  226.       if (fmt[i] == 'E')
  227.     {
  228.       register int j;
  229.       for (j = XVECLEN (in, i) - 1; j >= 0; j--)
  230.         if (reg_mentioned_p (reg, XVECEXP (in, i, j)))
  231.           return 1;
  232.     }
  233.       else if (fmt[i] == 'e'
  234.            && reg_mentioned_p (reg, XEXP (in, i)))
  235.     return 1;
  236.     }
  237.   return 0;
  238. }
  239.  
  240. /* Return 1 if in between BEG and END, exclusive of BEG and END, there is
  241.    no CODE_LABEL insn.  */
  242.  
  243. int
  244. no_labels_between_p (beg, end)
  245.      rtx beg, end;
  246. {
  247.   register rtx p;
  248.   for (p = NEXT_INSN (beg); p != end; p = NEXT_INSN (p))
  249.     if (GET_CODE (p) == CODE_LABEL)
  250.       return 0;
  251.   return 1;
  252. }
  253.  
  254. /* Nonzero if register REG is used in an insn between
  255.    FROM_INSN and TO_INSN (exclusive of those two).  */
  256.  
  257. int
  258. reg_used_between_p (reg, from_insn, to_insn)
  259.      rtx reg, from_insn, to_insn;
  260. {
  261.   register rtx insn;
  262.  
  263.   if (from_insn == to_insn)
  264.     return 0;
  265.  
  266.   for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
  267.     if (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
  268.     && reg_overlap_mentioned_p (reg, PATTERN (insn)))
  269.       return 1;
  270.   return 0;
  271. }
  272.  
  273. /* Nonzero if the old value of X, a register, is referenced in BODY.  If X
  274.    is entirely replaced by a new value and the only use is as a SET_DEST,
  275.    we do not consider it a reference.  */
  276.  
  277. int
  278. reg_referenced_p (x, body)
  279.      rtx x;
  280.      rtx body;
  281. {
  282.   int i;
  283.  
  284.   if (GET_CODE (body) == SET)
  285.     {
  286.       if (reg_overlap_mentioned_p (x, SET_SRC (body)))
  287.     return 1;
  288.  
  289.       /* If the destination is anything other than CC0, PC, a REG or a SUBREG
  290.      of a REG that occupies all of the REG, the insn references X if
  291.      it is mentioned in the destination.  */
  292.       if (GET_CODE (SET_DEST (body)) != CC0
  293.       && GET_CODE (SET_DEST (body)) != PC
  294.       && GET_CODE (SET_DEST (body)) != REG
  295.       && ! (GET_CODE (SET_DEST (body)) == SUBREG
  296.         && GET_CODE (SUBREG_REG (SET_DEST (body))) == REG
  297.         && (((GET_MODE_SIZE (GET_MODE (SUBREG_REG (SET_DEST (body))))
  298.               + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
  299.             == ((GET_MODE_SIZE (GET_MODE (SET_DEST (body)))
  300.              + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)))
  301.       && reg_overlap_mentioned_p (x, SET_DEST (body)))
  302.     return 1;
  303.     }
  304.   else if (GET_CODE (body) == PARALLEL)
  305.     for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
  306.       if (reg_referenced_p (x, XVECEXP (body, 0, i)))
  307.     return 1;
  308.  
  309.   return 0;
  310. }
  311.  
  312. /* Nonzero if register REG is referenced in an insn between
  313.    FROM_INSN and TO_INSN (exclusive of those two).  Sets of REG do
  314.    not count. */
  315.  
  316. int
  317. reg_referenced_between_p (reg, from_insn, to_insn)
  318.      rtx reg, from_insn, to_insn;
  319. {
  320.   register rtx insn;
  321.  
  322.   if (from_insn == to_insn)
  323.     return 0;
  324.  
  325.   for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
  326.     if (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
  327.     && reg_referenced_p (reg, PATTERN (insn)))
  328.       return 1;
  329.   return 0;
  330. }
  331.  
  332.  
  333. /* Nonzero if register REG is set or clobbered in an insn between
  334.    FROM_INSN and TO_INSN (exclusive of those two).  */
  335.  
  336. int
  337. reg_set_between_p (reg, from_insn, to_insn)
  338.      rtx reg, from_insn, to_insn;
  339. {
  340.   register rtx insn;
  341.  
  342.   if (from_insn == to_insn)
  343.     return 0;
  344.  
  345.   for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
  346.     if (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
  347.     && reg_set_p (reg, PATTERN (insn)))
  348.       return 1;
  349.   return 0;
  350. }
  351.  
  352. /* Internals of reg_set_between_p.  */
  353.  
  354. static rtx reg_set_reg;
  355. static int reg_set_flag;
  356.  
  357. void
  358. reg_set_p_1 (x)
  359.      rtx x;
  360. {
  361.   /* We don't want to return 1 if X is a MEM that contains a register
  362.      within REG_SET_REG.  */
  363.  
  364.   if ((GET_CODE (x) != MEM)
  365.       && reg_overlap_mentioned_p (reg_set_reg, x))
  366.     reg_set_flag = 1;
  367. }
  368.  
  369. int
  370. reg_set_p (reg, insn)
  371.      rtx reg, insn;
  372. {
  373.   rtx body = insn;
  374.  
  375.   if (GET_CODE (reg) == MEM)
  376.     abort ();
  377.  
  378.   /* We can be passed an insn or part of one.  If we are passed an insn,
  379.      check if a side-effect of the insn clobbers REG.  */
  380.   if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
  381.     {
  382.       if (FIND_REG_INC_NOTE (insn, reg)
  383.       /* We'd like to test call_used_regs here, but rtlanal.c can't
  384.          reference that variable due to its use in genattrtab.  So we'll
  385.          just be more conservative.  */
  386.       || (GET_CODE (insn) == CALL_INSN && GET_CODE (reg) == REG
  387.           && REGNO (reg) < FIRST_PSEUDO_REGISTER))
  388.     return 1;
  389.  
  390.       body = PATTERN (insn);
  391.     }
  392.  
  393.   reg_set_reg = reg;
  394.   reg_set_flag = 0;
  395.   note_stores (body, reg_set_p_1);
  396.   return reg_set_flag;
  397. }
  398.  
  399. /* Given an INSN, return a SET expression if this insn has only a single SET.
  400.    It may also have CLOBBERs, USEs, or SET whose output
  401.    will not be used, which we ignore.  */
  402.  
  403. rtx
  404. single_set (insn)
  405.      rtx insn;
  406. {
  407.   rtx set;
  408.   int i;
  409.   
  410.   if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
  411.     return 0;
  412.  
  413.   if (GET_CODE (PATTERN (insn)) == SET)
  414.     return PATTERN (insn);
  415.   
  416.   else if (GET_CODE (PATTERN (insn)) == PARALLEL)
  417.     {
  418.       for (i = 0, set = 0; i < XVECLEN (PATTERN (insn), 0); i++)
  419.     if (GET_CODE (XVECEXP (PATTERN (insn), 0, i)) == SET
  420.         && ! (find_reg_note (insn, REG_UNUSED,
  421.                 SET_DEST (XVECEXP (PATTERN (insn), 0, i)))
  422.           || side_effects_p (XVECEXP (PATTERN (insn), 0, i))))
  423.       {
  424.         if (set)
  425.           return 0;
  426.         else
  427.           set = XVECEXP (PATTERN (insn), 0, i);
  428.       }
  429.       return set;
  430.     }
  431.   
  432.   return 0;
  433. }
  434.  
  435. /* Return nonzero if register in range [REGNO, ENDREGNO)
  436.    appears either explicitly or implicitly in X
  437.    other than being stored into.
  438.  
  439.    References contained within the substructure at LOC do not count.
  440.    LOC may be zero, meaning don't ignore anything.  */
  441.  
  442. int
  443. refers_to_regno_p (regno, endregno, x, loc)
  444.      int regno, endregno;
  445.      rtx x;
  446.      rtx *loc;
  447. {
  448.   register int i;
  449.   register RTX_CODE code;
  450.   register char *fmt;
  451.  
  452.   if (x == 0)
  453.     return 0;
  454.  
  455.  repeat:
  456.   code = GET_CODE (x);
  457.  
  458.   switch (code)
  459.     {
  460.     case REG:
  461.       i = REGNO (x);
  462.       return (endregno > i
  463.           && regno < i + (i < FIRST_PSEUDO_REGISTER 
  464.                   ? HARD_REGNO_NREGS (i, GET_MODE (x))
  465.                   : 1));
  466.  
  467.     case SUBREG:
  468.       /* If this is a SUBREG of a hard reg, we can see exactly which
  469.      registers are being modified.  Otherwise, handle normally.  */
  470.       if (GET_CODE (SUBREG_REG (x)) == REG
  471.       && REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER)
  472.     {
  473.       int inner_regno = REGNO (SUBREG_REG (x)) + SUBREG_WORD (x);
  474.       int inner_endregno
  475.         = inner_regno + (inner_regno < FIRST_PSEUDO_REGISTER
  476.                  ? HARD_REGNO_NREGS (regno, GET_MODE (x)) : 1);
  477.  
  478.       return endregno > inner_regno && regno < inner_endregno;
  479.     }
  480.       break;
  481.  
  482.     case CLOBBER:
  483.     case SET:
  484.       if (&SET_DEST (x) != loc
  485.       /* Note setting a SUBREG counts as referring to the REG it is in for
  486.          a pseudo but not for hard registers since we can
  487.          treat each word individually.  */
  488.       && ((GET_CODE (SET_DEST (x)) == SUBREG
  489.            && loc != &SUBREG_REG (SET_DEST (x))
  490.            && GET_CODE (SUBREG_REG (SET_DEST (x))) == REG
  491.            && REGNO (SUBREG_REG (SET_DEST (x))) >= FIRST_PSEUDO_REGISTER
  492.            && refers_to_regno_p (regno, endregno,
  493.                      SUBREG_REG (SET_DEST (x)), loc))
  494.           || (GET_CODE (SET_DEST (x)) != REG
  495.           && refers_to_regno_p (regno, endregno, SET_DEST (x), loc))))
  496.     return 1;
  497.  
  498.       if (code == CLOBBER || loc == &SET_SRC (x))
  499.     return 0;
  500.       x = SET_SRC (x);
  501.       goto repeat;
  502.     }
  503.  
  504.   /* X does not match, so try its subexpressions.  */
  505.  
  506.   fmt = GET_RTX_FORMAT (code);
  507.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  508.     {
  509.       if (fmt[i] == 'e' && loc != &XEXP (x, i))
  510.     {
  511.       if (i == 0)
  512.         {
  513.           x = XEXP (x, 0);
  514.           goto repeat;
  515.         }
  516.       else
  517.         if (refers_to_regno_p (regno, endregno, XEXP (x, i), loc))
  518.           return 1;
  519.     }
  520.       else if (fmt[i] == 'E')
  521.     {
  522.       register int j;
  523.       for (j = XVECLEN (x, i) - 1; j >=0; j--)
  524.         if (loc != &XVECEXP (x, i, j)
  525.         && refers_to_regno_p (regno, endregno, XVECEXP (x, i, j), loc))
  526.           return 1;
  527.     }
  528.     }
  529.   return 0;
  530. }
  531.  
  532. /* Nonzero if modifying X will affect IN.  If X is a register or a SUBREG,
  533.    we check if any register number in X conflicts with the relevant register
  534.    numbers.  If X is a constant, return 0.  If X is a MEM, return 1 iff IN
  535.    contains a MEM (we don't bother checking for memory addresses that can't
  536.    conflict because we expect this to be a rare case.  */
  537.  
  538. int
  539. reg_overlap_mentioned_p (x, in)
  540.      rtx x, in;
  541. {
  542.   int regno, endregno;
  543.  
  544.   if (GET_CODE (x) == SUBREG)
  545.     {
  546.       regno = REGNO (SUBREG_REG (x));
  547.       if (regno < FIRST_PSEUDO_REGISTER)
  548.     regno += SUBREG_WORD (x);
  549.     }
  550.   else if (GET_CODE (x) == REG)
  551.     regno = REGNO (x);
  552.   else if (CONSTANT_P (x))
  553.     return 0;
  554.   else if (GET_CODE (x) == MEM)
  555.     {
  556.       char *fmt;
  557.       int i;
  558.  
  559.       if (GET_CODE (in) == MEM)
  560.     return 1;
  561.  
  562.       fmt = GET_RTX_FORMAT (GET_CODE (in));
  563.  
  564.       for (i = GET_RTX_LENGTH (GET_CODE (in)) - 1; i >= 0; i--)
  565.     if (fmt[i] == 'e' && reg_overlap_mentioned_p (x, XEXP (in, i)))
  566.       return 1;
  567.  
  568.       return 0;
  569.     }
  570.   else if (GET_CODE (x) == SCRATCH || GET_CODE (x) == PC
  571.        || GET_CODE (x) == CC0)
  572.     return reg_mentioned_p (x, in);
  573.   else
  574.     abort ();
  575.  
  576.   endregno = regno + (regno < FIRST_PSEUDO_REGISTER
  577.               ? HARD_REGNO_NREGS (regno, GET_MODE (x)) : 1);
  578.  
  579.   return refers_to_regno_p (regno, endregno, in, 0);
  580. }
  581.  
  582. /* Used for communications between the next few functions.  */
  583.  
  584. static int reg_set_last_unknown;
  585. static rtx reg_set_last_value;
  586. static int reg_set_last_first_regno, reg_set_last_last_regno;
  587.  
  588. /* Called via note_stores from reg_set_last.  */
  589.  
  590. static void
  591. reg_set_last_1 (x, pat)
  592.      rtx x;
  593.      rtx pat;
  594. {
  595.   int first, last;
  596.  
  597.   /* If X is not a register, or is not one in the range we care
  598.      about, ignore.  */
  599.   if (GET_CODE (x) != REG)
  600.     return;
  601.  
  602.   first = REGNO (x);
  603.   last = first + (first < FIRST_PSEUDO_REGISTER
  604.           ? HARD_REGNO_NREGS (first, GET_MODE (x)) : 1);
  605.  
  606.   if (first >= reg_set_last_last_regno
  607.       || last <= reg_set_last_first_regno)
  608.     return;
  609.  
  610.   /* If this is a CLOBBER or is some complex LHS, or doesn't modify
  611.      exactly the registers we care about, show we don't know the value.  */
  612.   if (GET_CODE (pat) == CLOBBER || SET_DEST (pat) != x
  613.       || first != reg_set_last_first_regno
  614.       || last != reg_set_last_last_regno)
  615.     reg_set_last_unknown = 1;
  616.   else
  617.     reg_set_last_value = SET_SRC (pat);
  618. }
  619.  
  620. /* Return the last value to which REG was set prior to INSN.  If we can't
  621.    find it easily, return 0. 
  622.  
  623.    We only return a REG or constant because it is too hard to check if a
  624.    MEM remains unchanged.  */
  625.  
  626. rtx
  627. reg_set_last (x, insn)
  628.      rtx x;
  629.      rtx insn;
  630. {
  631.   rtx orig_insn = insn;
  632.  
  633.   reg_set_last_first_regno = REGNO (x);
  634.  
  635.   reg_set_last_last_regno
  636.     = reg_set_last_first_regno
  637.       + (reg_set_last_first_regno < FIRST_PSEUDO_REGISTER
  638.      ? HARD_REGNO_NREGS (reg_set_last_first_regno, GET_MODE (x)) : 1);
  639.  
  640.   reg_set_last_unknown = 0;
  641.   reg_set_last_value = 0;
  642.  
  643.   /* Scan backwards until reg_set_last_1 changed one of the above flags.
  644.      Stop when we reach a label or X is a hard reg and we reach a
  645.      CALL_INSN (if reg_set_last_regno is a hard reg).
  646.  
  647.      If we find a set of X, ensure that its SET_SRC remains unchanged.  */
  648.  
  649.   for (;
  650.        insn && GET_CODE (insn) != CODE_LABEL
  651.        && ! (GET_CODE (insn) == CALL_INSN
  652.          && reg_set_last_last_regno <= FIRST_PSEUDO_REGISTER);
  653.        insn = PREV_INSN (insn))
  654.     if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
  655.       {
  656.     note_stores (PATTERN (insn), reg_set_last_1);
  657.     if (reg_set_last_unknown)
  658.       return 0;
  659.     else if (reg_set_last_value)
  660.       {
  661.         if (CONSTANT_P (reg_set_last_value)
  662.         || (GET_CODE (reg_set_last_value) == REG
  663.             && ! reg_set_between_p (reg_set_last_value,
  664.                         NEXT_INSN (insn), orig_insn)))
  665.           return reg_set_last_value;
  666.         else
  667.           return 0;
  668.       }
  669.       }
  670.  
  671.   return 0;
  672. }
  673.  
  674. /* This is 1 until after reload pass.  */
  675. int rtx_equal_function_value_matters;
  676.  
  677. /* Return 1 if X and Y are identical-looking rtx's.
  678.    This is the Lisp function EQUAL for rtx arguments.  */
  679.  
  680. int
  681. rtx_equal_p (x, y)
  682.      rtx x, y;
  683. {
  684.   register int i;
  685.   register int j;
  686.   register enum rtx_code code;
  687.   register char *fmt;
  688.  
  689.   if (x == y)
  690.     return 1;
  691.   if (x == 0 || y == 0)
  692.     return 0;
  693.  
  694.   code = GET_CODE (x);
  695.   /* Rtx's of different codes cannot be equal.  */
  696.   if (code != GET_CODE (y))
  697.     return 0;
  698.  
  699.   /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.
  700.      (REG:SI x) and (REG:HI x) are NOT equivalent.  */
  701.  
  702.   if (GET_MODE (x) != GET_MODE (y))
  703.     return 0;
  704.  
  705.   /* REG, LABEL_REF, and SYMBOL_REF can be compared nonrecursively.  */
  706.  
  707.   if (code == REG)
  708.     /* Until rtl generation is complete, don't consider the a reference to
  709.        the return register of the current function the same as the return
  710.        from a called function.  This eases the job of function integration.
  711.        Once the distinction no longer they can be considered equivalent.  */
  712.     return (REGNO (x) == REGNO (y)
  713.         && (! rtx_equal_function_value_matters
  714.         || REG_FUNCTION_VALUE_P (x) == REG_FUNCTION_VALUE_P (y)));
  715.   else if (code == LABEL_REF)
  716.     return XEXP (x, 0) == XEXP (y, 0);
  717.   else if (code == SYMBOL_REF)
  718.     return XSTR (x, 0) == XSTR (y, 0);
  719.   else if (code == SCRATCH || code == CONST_DOUBLE)
  720.     return 0;
  721.  
  722.   /* Compare the elements.  If any pair of corresponding elements
  723.      fail to match, return 0 for the whole things.  */
  724.  
  725.   fmt = GET_RTX_FORMAT (code);
  726.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  727.     {
  728.       switch (fmt[i])
  729.     {
  730.     case 'n':
  731.     case 'i':
  732.       if (XINT (x, i) != XINT (y, i))
  733.         return 0;
  734.       break;
  735.  
  736.     case 'V':
  737.     case 'E':
  738.       /* Two vectors must have the same length.  */
  739.       if (XVECLEN (x, i) != XVECLEN (y, i))
  740.         return 0;
  741.  
  742.       /* And the corresponding elements must match.  */
  743.       for (j = 0; j < XVECLEN (x, i); j++)
  744.         if (rtx_equal_p (XVECEXP (x, i, j), XVECEXP (y, i, j)) == 0)
  745.           return 0;
  746.       break;
  747.  
  748.     case 'e':
  749.       if (rtx_equal_p (XEXP (x, i), XEXP (y, i)) == 0)
  750.         return 0;
  751.       break;
  752.  
  753.     case 'S':
  754.     case 's':
  755.       if (strcmp (XSTR (x, i), XSTR (y, i)))
  756.         return 0;
  757.       break;
  758.  
  759.     case 'u':
  760.       /* These are just backpointers, so they don't matter.  */
  761.       break;
  762.  
  763.     case '0':
  764.       break;
  765.  
  766.       /* It is believed that rtx's at this level will never
  767.          contain anything but integers and other rtx's,
  768.          except for within LABEL_REFs and SYMBOL_REFs.  */
  769.     default:
  770.       abort ();
  771.     }
  772.     }
  773.   return 1;
  774. }
  775.  
  776. /* Call FUN on each register or MEM that is stored into or clobbered by X.
  777.    (X would be the pattern of an insn).
  778.    FUN receives two arguments:
  779.      the REG, MEM, CC0 or PC being stored in or clobbered,
  780.      the SET or CLOBBER rtx that does the store.
  781.  
  782.   If the item being stored in or clobbered is a SUBREG of a hard register,
  783.   the SUBREG will be passed.  */
  784.      
  785. void
  786. note_stores (x, fun)
  787.      register rtx x;
  788.      void (*fun) ();
  789. {
  790.   if ((GET_CODE (x) == SET || GET_CODE (x) == CLOBBER))
  791.     {
  792.       register rtx dest = SET_DEST (x);
  793.       while ((GET_CODE (dest) == SUBREG
  794.           && (GET_CODE (SUBREG_REG (dest)) != REG
  795.           || REGNO (SUBREG_REG (dest)) >= FIRST_PSEUDO_REGISTER))
  796.          || GET_CODE (dest) == ZERO_EXTRACT
  797.          || GET_CODE (dest) == SIGN_EXTRACT
  798.          || GET_CODE (dest) == STRICT_LOW_PART)
  799.     dest = XEXP (dest, 0);
  800.       (*fun) (dest, x);
  801.     }
  802.   else if (GET_CODE (x) == PARALLEL)
  803.     {
  804.       register int i;
  805.       for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
  806.     {
  807.       register rtx y = XVECEXP (x, 0, i);
  808.       if (GET_CODE (y) == SET || GET_CODE (y) == CLOBBER)
  809.         {
  810.           register rtx dest = SET_DEST (y);
  811.           while ((GET_CODE (dest) == SUBREG
  812.               && (GET_CODE (SUBREG_REG (dest)) != REG
  813.               || (REGNO (SUBREG_REG (dest))
  814.                   >= FIRST_PSEUDO_REGISTER)))
  815.              || GET_CODE (dest) == ZERO_EXTRACT
  816.              || GET_CODE (dest) == SIGN_EXTRACT
  817.              || GET_CODE (dest) == STRICT_LOW_PART)
  818.         dest = XEXP (dest, 0);
  819.           (*fun) (dest, y);
  820.         }
  821.     }
  822.     }
  823. }
  824.  
  825. /* Return nonzero if X's old contents don't survive after INSN.
  826.    This will be true if X is (cc0) or if X is a register and
  827.    X dies in INSN or because INSN entirely sets X.
  828.  
  829.    "Entirely set" means set directly and not through a SUBREG,
  830.    ZERO_EXTRACT or SIGN_EXTRACT, so no trace of the old contents remains.
  831.    Likewise, REG_INC does not count.
  832.  
  833.    REG may be a hard or pseudo reg.  Renumbering is not taken into account,
  834.    but for this use that makes no difference, since regs don't overlap
  835.    during their lifetimes.  Therefore, this function may be used
  836.    at any time after deaths have been computed (in flow.c).  */
  837.  
  838. int
  839. dead_or_set_p (insn, x)
  840.      rtx insn;
  841.      rtx x;
  842. {
  843.   register rtx link;
  844.   register int regno;
  845.  
  846.   /* Can't use cc0_rtx below since this file is used by genattrtab.c.  */
  847.   if (GET_CODE (x) == CC0)
  848.     return 1;
  849.  
  850.   regno = REGNO (x);
  851.  
  852.   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
  853.     if (REG_NOTE_KIND (link) == REG_DEAD
  854.     && REGNO (XEXP (link, 0)) == regno)
  855.       return 1;
  856.  
  857.   /* A value is totally replaced if it is the destination or the destination
  858.      is a SUBREG of REGNO that does not change the number of words in it.  */
  859.   if (GET_CODE (PATTERN (insn)) == SET)
  860.     {
  861.       rtx dest = SET_DEST (PATTERN (insn));
  862.  
  863.       return ((GET_CODE (dest) == REG && REGNO (dest) == regno)
  864.           || (GET_CODE (dest) == SUBREG
  865.           && (((GET_MODE_SIZE (GET_MODE (dest))
  866.             + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
  867.               == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest)))
  868.                + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
  869.           && GET_CODE (SUBREG_REG (dest)) == REG
  870.           && REGNO (SUBREG_REG (dest)) == regno));
  871.     }
  872.   else if (GET_CODE (PATTERN (insn)) == PARALLEL)
  873.     {
  874.       register int i;
  875.       for (i = XVECLEN (PATTERN (insn), 0) - 1; i >= 0; i--)
  876.     {
  877.       rtx dest = XVECEXP (PATTERN (insn), 0, i);
  878.       if (GET_CODE (dest) == SET
  879.           && ((GET_CODE (SET_DEST (dest)) == REG
  880.            && REGNO (SET_DEST (dest)) == regno)
  881.           || (GET_CODE (dest) == SUBREG
  882.               && (((GET_MODE_SIZE (GET_MODE (dest))
  883.                 + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
  884.               == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest)))
  885.                    + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
  886.               && GET_CODE (SUBREG_REG (dest)) == REG
  887.               && REGNO (SUBREG_REG (dest)) == regno)))
  888.         return 1;
  889.     }
  890.     }
  891.   return 0;
  892. }
  893.  
  894. /* Return the reg-note of kind KIND in insn INSN, if there is one.
  895.    If DATUM is nonzero, look for one whose datum is DATUM.  */
  896.  
  897. rtx
  898. find_reg_note (insn, kind, datum)
  899.      rtx insn;
  900.      enum reg_note kind;
  901.      rtx datum;
  902. {
  903.   register rtx link;
  904.  
  905.   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
  906.     if (REG_NOTE_KIND (link) == kind
  907.     && (datum == 0 || datum == XEXP (link, 0)))
  908.       return link;
  909.   return 0;
  910. }
  911.  
  912. /* Return the reg-note of kind KIND in insn INSN which applies to register
  913.    number REGNO, if any.  Return 0 if there is no such reg-note.  */
  914.  
  915. rtx
  916. find_regno_note (insn, kind, regno)
  917.      rtx insn;
  918.      enum reg_note kind;
  919.      int regno;
  920. {
  921.   register rtx link;
  922.  
  923.   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
  924.     if (REG_NOTE_KIND (link) == kind
  925.     /* Verify that it is a register, so that scratch and MEM won't cause a
  926.        problem here.  */
  927.     && GET_CODE (XEXP (link, 0)) == REG
  928.     && REGNO (XEXP (link, 0)) == regno)
  929.       return link;
  930.   return 0;
  931. }
  932.  
  933. /* Remove register note NOTE from the REG_NOTES of INSN.  */
  934.  
  935. void
  936. remove_note (insn, note)
  937.      register rtx note;
  938.      register rtx insn;
  939. {
  940.   register rtx link;
  941.  
  942.   if (REG_NOTES (insn) == note)
  943.     {
  944.       REG_NOTES (insn) = XEXP (note, 1);
  945.       return;
  946.     }
  947.  
  948.   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
  949.     if (XEXP (link, 1) == note)
  950.       {
  951.     XEXP (link, 1) = XEXP (note, 1);
  952.     return;
  953.       }
  954.  
  955.   abort ();
  956. }
  957.  
  958. /* Nonzero if X contains any volatile memory references
  959.    or volatile ASM_OPERANDS expressions.  */
  960.  
  961. int
  962. volatile_refs_p (x)
  963.      rtx x;
  964. {
  965.   register RTX_CODE code;
  966.  
  967.   code = GET_CODE (x);
  968.   switch (code)
  969.     {
  970.     case LABEL_REF:
  971.     case SYMBOL_REF:
  972.     case CONST_INT:
  973.     case CONST:
  974.     case CONST_DOUBLE:
  975.     case CC0:
  976.     case PC:
  977.     case REG:
  978.     case SCRATCH:
  979.     case CLOBBER:
  980.     case ASM_INPUT:
  981.     case ADDR_VEC:
  982.     case ADDR_DIFF_VEC:
  983.       return 0;
  984.  
  985.     case CALL:
  986.       return 1;
  987.  
  988.     case MEM:
  989.     case ASM_OPERANDS:
  990.       if (MEM_VOLATILE_P (x))
  991.     return 1;
  992.     }
  993.  
  994.   /* Recursively scan the operands of this expression.  */
  995.  
  996.   {
  997.     register char *fmt = GET_RTX_FORMAT (code);
  998.     register int i;
  999.     
  1000.     for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  1001.       {
  1002.     if (fmt[i] == 'e')
  1003.       {
  1004.         if (volatile_refs_p (XEXP (x, i)))
  1005.           return 1;
  1006.       }
  1007.     if (fmt[i] == 'E')
  1008.       {
  1009.         register int j;
  1010.         for (j = 0; j < XVECLEN (x, i); j++)
  1011.           if (volatile_refs_p (XVECEXP (x, i, j)))
  1012.         return 1;
  1013.       }
  1014.       }
  1015.   }
  1016.   return 0;
  1017. }
  1018.  
  1019. /* Similar to above, except that it also rejects register pre- and post-
  1020.    incrementing.  */
  1021.  
  1022. int
  1023. side_effects_p (x)
  1024.      rtx x;
  1025. {
  1026.   register RTX_CODE code;
  1027.  
  1028.   code = GET_CODE (x);
  1029.   switch (code)
  1030.     {
  1031.     case LABEL_REF:
  1032.     case SYMBOL_REF:
  1033.     case CONST_INT:
  1034.     case CONST:
  1035.     case CONST_DOUBLE:
  1036.     case CC0:
  1037.     case PC:
  1038.     case REG:
  1039.     case SCRATCH:
  1040.     case ASM_INPUT:
  1041.     case ADDR_VEC:
  1042.     case ADDR_DIFF_VEC:
  1043.       return 0;
  1044.  
  1045.     case CLOBBER:
  1046.       /* Reject CLOBBER with a non-VOID mode.  These are made by combine.c
  1047.      when some combination can't be done.  If we see one, don't think
  1048.      that we can simplify the expression.  */
  1049.       return (GET_MODE (x) != VOIDmode);
  1050.  
  1051.     case PRE_INC:
  1052.     case PRE_DEC:
  1053.     case POST_INC:
  1054.     case POST_DEC:
  1055.     case CALL:
  1056.       return 1;
  1057.  
  1058.     case MEM:
  1059.     case ASM_OPERANDS:
  1060.       if (MEM_VOLATILE_P (x))
  1061.     return 1;
  1062.     }
  1063.  
  1064.   /* Recursively scan the operands of this expression.  */
  1065.  
  1066.   {
  1067.     register char *fmt = GET_RTX_FORMAT (code);
  1068.     register int i;
  1069.     
  1070.     for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  1071.       {
  1072.     if (fmt[i] == 'e')
  1073.       {
  1074.         if (side_effects_p (XEXP (x, i)))
  1075.           return 1;
  1076.       }
  1077.     if (fmt[i] == 'E')
  1078.       {
  1079.         register int j;
  1080.         for (j = 0; j < XVECLEN (x, i); j++)
  1081.           if (side_effects_p (XVECEXP (x, i, j)))
  1082.         return 1;
  1083.       }
  1084.       }
  1085.   }
  1086.   return 0;
  1087. }
  1088.  
  1089. /* Return nonzero if evaluating rtx X might cause a trap.  */
  1090.  
  1091. int
  1092. may_trap_p (x)
  1093.      rtx x;
  1094. {
  1095.   int i;
  1096.   enum rtx_code code;
  1097.   char *fmt;
  1098.  
  1099.   if (x == 0)
  1100.     return 0;
  1101.   code = GET_CODE (x);
  1102.   switch (code)
  1103.     {
  1104.       /* Handle these cases quickly.  */
  1105.     case CONST_INT:
  1106.     case CONST_DOUBLE:
  1107.     case SYMBOL_REF:
  1108.     case LABEL_REF:
  1109.     case CONST:
  1110.     case PC:
  1111.     case CC0:
  1112.     case REG:
  1113.     case SCRATCH:
  1114.       return 0;
  1115.  
  1116.       /* Memory ref can trap unless it's a static var or a stack slot.  */
  1117.     case MEM:
  1118.       return rtx_varies_p (XEXP (x, 0));
  1119.  
  1120.       /* Division by a non-constant might trap.  */
  1121.     case DIV:
  1122.     case MOD:
  1123.     case UDIV:
  1124.     case UMOD:
  1125.       if (! CONSTANT_P (XEXP (x, 1)))
  1126.     return 1;
  1127.       /* This was const0_rtx, but by not using that,
  1128.      we can link this file into other programs.  */
  1129.       if (GET_CODE (XEXP (x, 1)) == CONST_INT && INTVAL (XEXP (x, 1)) == 0)
  1130.     return 1;
  1131.     default:
  1132.       /* Any floating arithmetic may trap.  */
  1133.       if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
  1134.     return 1;
  1135.     }
  1136.  
  1137.   fmt = GET_RTX_FORMAT (code);
  1138.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  1139.     {
  1140.       if (fmt[i] == 'e')
  1141.     {
  1142.       if (may_trap_p (XEXP (x, i)))
  1143.         return 1;
  1144.     }
  1145.       else if (fmt[i] == 'E')
  1146.     {
  1147.       register int j;
  1148.       for (j = 0; j < XVECLEN (x, i); j++)
  1149.         if (may_trap_p (XVECEXP (x, i, j)))
  1150.           return 1;
  1151.     }
  1152.     }
  1153.   return 0;
  1154. }
  1155.  
  1156. /* Return nonzero if X contains a comparison that is not either EQ or NE,
  1157.    i.e., an inequality.  */
  1158.  
  1159. int
  1160. inequality_comparisons_p (x)
  1161.      rtx x;
  1162. {
  1163.   register char *fmt;
  1164.   register int len, i;
  1165.   register enum rtx_code code = GET_CODE (x);
  1166.  
  1167.   switch (code)
  1168.     {
  1169.     case REG:
  1170.     case SCRATCH:
  1171.     case PC:
  1172.     case CC0:
  1173.     case CONST_INT:
  1174.     case CONST_DOUBLE:
  1175.     case CONST:
  1176.     case LABEL_REF:
  1177.     case SYMBOL_REF:
  1178.       return 0;
  1179.  
  1180.     case LT:
  1181.     case LTU:
  1182.     case GT:
  1183.     case GTU:
  1184.     case LE:
  1185.     case LEU:
  1186.     case GE:
  1187.     case GEU:
  1188.       return 1;
  1189.     }
  1190.  
  1191.   len = GET_RTX_LENGTH (code);
  1192.   fmt = GET_RTX_FORMAT (code);
  1193.  
  1194.   for (i = 0; i < len; i++)
  1195.     {
  1196.       if (fmt[i] == 'e')
  1197.     {
  1198.       if (inequality_comparisons_p (XEXP (x, i)))
  1199.         return 1;
  1200.     }
  1201.       else if (fmt[i] == 'E')
  1202.     {
  1203.       register int j;
  1204.       for (j = XVECLEN (x, i) - 1; j >= 0; j--)
  1205.         if (inequality_comparisons_p (XVECEXP (x, i, j)))
  1206.           return 1;
  1207.     }
  1208.     }
  1209.         
  1210.   return 0;
  1211. }
  1212.  
  1213. /* Replace any occurrence of FROM in X with TO.
  1214.  
  1215.    Note that copying is not done so X must not be shared unless all copies
  1216.    are to be modified.  */
  1217.  
  1218. rtx
  1219. replace_rtx (x, from, to)
  1220.      rtx x, from, to;
  1221. {
  1222.   register int i, j;
  1223.   register char *fmt;
  1224.  
  1225.   if (x == from)
  1226.     return to;
  1227.  
  1228.   /* Allow this function to make replacements in EXPR_LISTs.  */
  1229.   if (x == 0)
  1230.     return 0;
  1231.  
  1232.   fmt = GET_RTX_FORMAT (GET_CODE (x));
  1233.   for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
  1234.     {
  1235.       if (fmt[i] == 'e')
  1236.     XEXP (x, i) = replace_rtx (XEXP (x, i), from, to);
  1237.       else if (fmt[i] == 'E')
  1238.     for (j = XVECLEN (x, i) - 1; j >= 0; j--)
  1239.       XVECEXP (x, i, j) = replace_rtx (XVECEXP (x, i, j), from, to);
  1240.     }
  1241.  
  1242.   return x;
  1243. }  
  1244.  
  1245. /* Throughout the rtx X, replace many registers according to REG_MAP.
  1246.    Return the replacement for X (which may be X with altered contents).
  1247.    REG_MAP[R] is the replacement for register R, or 0 for don't replace.
  1248.    NREGS is the length of REG_MAP; regs >= NREGS are not mapped.  
  1249.  
  1250.    We only support REG_MAP entries of REG or SUBREG.  Also, hard registers
  1251.    should not be mapped to pseudos or vice versa since validate_change
  1252.    is not called.
  1253.  
  1254.    If REPLACE_DEST is 1, replacements are also done in destinations;
  1255.    otherwise, only sources are replaced.  */
  1256.  
  1257. rtx
  1258. replace_regs (x, reg_map, nregs, replace_dest)
  1259.      rtx x;
  1260.      rtx *reg_map;
  1261.      int nregs;
  1262.      int replace_dest;
  1263. {
  1264.   register enum rtx_code code;
  1265.   register int i;
  1266.   register char *fmt;
  1267.  
  1268.   if (x == 0)
  1269.     return x;
  1270.  
  1271.   code = GET_CODE (x);
  1272.   switch (code)
  1273.     {
  1274.     case SCRATCH:
  1275.     case PC:
  1276.     case CC0:
  1277.     case CONST_INT:
  1278.     case CONST_DOUBLE:
  1279.     case CONST:
  1280.     case SYMBOL_REF:
  1281.     case LABEL_REF:
  1282.       return x;
  1283.  
  1284.     case REG:
  1285.       /* Verify that the register has an entry before trying to access it.  */
  1286.       if (REGNO (x) < nregs && reg_map[REGNO (x)] != 0)
  1287.     return reg_map[REGNO (x)];
  1288.       return x;
  1289.  
  1290.     case SUBREG:
  1291.       /* Prevent making nested SUBREGs.  */
  1292.       if (GET_CODE (SUBREG_REG (x)) == REG && REGNO (SUBREG_REG (x)) < nregs
  1293.       && reg_map[REGNO (SUBREG_REG (x))] != 0
  1294.       && GET_CODE (reg_map[REGNO (SUBREG_REG (x))]) == SUBREG)
  1295.     {
  1296.       rtx map_val = reg_map[REGNO (SUBREG_REG (x))];
  1297.       rtx map_inner = SUBREG_REG (map_val);
  1298.  
  1299.       if (GET_MODE (x) == GET_MODE (map_inner))
  1300.         return map_inner;
  1301.       else
  1302.         {
  1303.           /* We cannot call gen_rtx here since we may be linked with
  1304.          genattrtab.c.  */
  1305.           rtx new = rtx_alloc (SUBREG);
  1306.           PUT_MODE (new, GET_MODE (x));
  1307.           SUBREG_REG (new) = map_inner;
  1308.           SUBREG_WORD (new) = SUBREG_WORD (x) + SUBREG_WORD (map_val);
  1309.         }
  1310.     }
  1311.       break;
  1312.  
  1313.     case SET:
  1314.       if (replace_dest)
  1315.     SET_DEST (x) = replace_regs (SET_DEST (x), reg_map, nregs, 0);
  1316.  
  1317.       else if (GET_CODE (SET_DEST (x)) == MEM
  1318.            || GET_CODE (SET_DEST (x)) == STRICT_LOW_PART)
  1319.     /* Even if we are not to replace destinations, replace register if it
  1320.        is CONTAINED in destination (destination is memory or
  1321.        STRICT_LOW_PART).  */
  1322.     XEXP (SET_DEST (x), 0) = replace_regs (XEXP (SET_DEST (x), 0),
  1323.                            reg_map, nregs, 0);
  1324.       else if (GET_CODE (SET_DEST (x)) == ZERO_EXTRACT)
  1325.     /* Similarly, for ZERO_EXTRACT we replace all operands.  */
  1326.     break;
  1327.  
  1328.       SET_SRC (x) = replace_regs (SET_SRC (x), reg_map, nregs, 0);
  1329.       return x;
  1330.     }
  1331.  
  1332.   fmt = GET_RTX_FORMAT (code);
  1333.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  1334.     {
  1335.       if (fmt[i] == 'e')
  1336.     XEXP (x, i) = replace_regs (XEXP (x, i), reg_map, nregs, replace_dest);
  1337.       if (fmt[i] == 'E')
  1338.     {
  1339.       register int j;
  1340.       for (j = 0; j < XVECLEN (x, i); j++)
  1341.         XVECEXP (x, i, j) = replace_regs (XVECEXP (x, i, j), reg_map,
  1342.                           nregs, replace_dest);
  1343.     }
  1344.     }
  1345.   return x;
  1346. }
  1347.