LCOV - code coverage report
Current view: top level - gcc - emit-rtl.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 83.4 % 2820 2351
Test Date: 2026-06-20 15:32:29 Functions: 86.7 % 264 229
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Emit RTL for the GCC expander.
       2              :    Copyright (C) 1987-2026 Free Software Foundation, Inc.
       3              : 
       4              : This file is part of GCC.
       5              : 
       6              : GCC is free software; you can redistribute it and/or modify it under
       7              : the terms of the GNU General Public License as published by the Free
       8              : Software Foundation; either version 3, or (at your option) any later
       9              : version.
      10              : 
      11              : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12              : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13              : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14              : for more details.
      15              : 
      16              : You should have received a copy of the GNU General Public License
      17              : along with GCC; see the file COPYING3.  If not see
      18              : <http://www.gnu.org/licenses/>.  */
      19              : 
      20              : 
      21              : /* Middle-to-low level generation of rtx code and insns.
      22              : 
      23              :    This file contains support functions for creating rtl expressions
      24              :    and manipulating them in the doubly-linked chain of insns.
      25              : 
      26              :    The patterns of the insns are created by machine-dependent
      27              :    routines in insn-emit.cc, which is generated automatically from
      28              :    the machine description.  These routines make the individual rtx's
      29              :    of the pattern with `gen_rtx_fmt_ee' and others in genrtl.[ch],
      30              :    which are automatically generated from rtl.def; what is machine
      31              :    dependent is the kind of rtx's they make and what arguments they
      32              :    use.  */
      33              : 
      34              : #include "config.h"
      35              : #include "system.h"
      36              : #include "coretypes.h"
      37              : #include "memmodel.h"
      38              : #include "backend.h"
      39              : #include "target.h"
      40              : #include "rtl.h"
      41              : #include "tree.h"
      42              : #include "df.h"
      43              : #include "tm_p.h"
      44              : #include "stringpool.h"
      45              : #include "insn-config.h"
      46              : #include "regs.h"
      47              : #include "emit-rtl.h"
      48              : #include "recog.h"
      49              : #include "diagnostic-core.h"
      50              : #include "alias.h"
      51              : #include "fold-const.h"
      52              : #include "varasm.h"
      53              : #include "cfgrtl.h"
      54              : #include "tree-eh.h"
      55              : #include "explow.h"
      56              : #include "expr.h"
      57              : #include "builtins.h"
      58              : #include "rtl-iter.h"
      59              : #include "stor-layout.h"
      60              : #include "opts.h"
      61              : #include "optabs.h"
      62              : #include "predict.h"
      63              : #include "rtx-vector-builder.h"
      64              : #include "gimple.h"
      65              : #include "gimple-ssa.h"
      66              : #include "bbitmap.h"
      67              : 
      68              : struct target_rtl default_target_rtl;
      69              : #if SWITCHABLE_TARGET
      70              : struct target_rtl *this_target_rtl = &default_target_rtl;
      71              : #endif
      72              : 
      73              : #define initial_regno_reg_rtx (this_target_rtl->x_initial_regno_reg_rtx)
      74              : 
      75              : /* Commonly used modes.  */
      76              : 
      77              : scalar_int_mode byte_mode;      /* Mode whose width is BITS_PER_UNIT.  */
      78              : scalar_int_mode word_mode;      /* Mode whose width is BITS_PER_WORD.  */
      79              : scalar_int_mode ptr_mode;       /* Mode whose width is POINTER_SIZE.  */
      80              : 
      81              : /* Datastructures maintained for currently processed function in RTL form.  */
      82              : 
      83              : struct rtl_data x_rtl;
      84              : 
      85              : /* Indexed by pseudo register number, gives the rtx for that pseudo.
      86              :    Allocated in parallel with regno_pointer_align.
      87              :    FIXME: We could put it into emit_status struct, but gengtype is not able to deal
      88              :    with length attribute nested in top level structures.  */
      89              : 
      90              : rtx * regno_reg_rtx;
      91              : 
      92              : /* This is *not* reset after each function.  It gives each CODE_LABEL
      93              :    in the entire compilation a unique label number.  */
      94              : 
      95              : static GTY(()) int label_num = 1;
      96              : 
      97              : /* We record floating-point CONST_DOUBLEs in each floating-point mode for
      98              :    the values of 0, 1, and 2.  For the integer entries and VOIDmode, we
      99              :    record a copy of const[012]_rtx and constm1_rtx.  CONSTM1_RTX
     100              :    is set only for MODE_INT and MODE_VECTOR_INT modes.  */
     101              : 
     102              : rtx const_tiny_rtx[4][(int) MAX_MACHINE_MODE];
     103              : 
     104              : rtx const_true_rtx;
     105              : 
     106              : REAL_VALUE_TYPE dconst0;
     107              : REAL_VALUE_TYPE dconst1;
     108              : REAL_VALUE_TYPE dconst2;
     109              : REAL_VALUE_TYPE dconstm0;
     110              : REAL_VALUE_TYPE dconstm1;
     111              : REAL_VALUE_TYPE dconsthalf;
     112              : REAL_VALUE_TYPE dconstinf;
     113              : REAL_VALUE_TYPE dconstninf;
     114              : 
     115              : /* Record fixed-point constant 0 and 1.  */
     116              : FIXED_VALUE_TYPE fconst0[MAX_FCONST0];
     117              : FIXED_VALUE_TYPE fconst1[MAX_FCONST1];
     118              : 
     119              : /* We make one copy of (const_int C) where C is in
     120              :    [- MAX_SAVED_CONST_INT, MAX_SAVED_CONST_INT]
     121              :    to save space during the compilation and simplify comparisons of
     122              :    integers.  */
     123              : 
     124              : rtx const_int_rtx[MAX_SAVED_CONST_INT * 2 + 1];
     125              : 
     126              : /* Standard pieces of rtx, to be substituted directly into things.  */
     127              : rtx pc_rtx;
     128              : rtx ret_rtx;
     129              : rtx simple_return_rtx;
     130              : 
     131              : /* Marker used for denoting an INSN, which should never be accessed (i.e.,
     132              :    this pointer should normally never be dereferenced), but is required to be
     133              :    distinct from NULL_RTX.  Currently used by peephole2 pass.  */
     134              : rtx_insn *invalid_insn_rtx;
     135              : 
     136              : /* A hash table storing CONST_INTs whose absolute value is greater
     137              :    than MAX_SAVED_CONST_INT.  */
     138              : 
     139              : struct const_int_hasher : ggc_cache_ptr_hash<rtx_def>
     140              : {
     141              :   typedef HOST_WIDE_INT compare_type;
     142              : 
     143              :   static hashval_t hash (rtx i);
     144              :   static bool equal (rtx i, HOST_WIDE_INT h);
     145              : };
     146              : 
     147              : static GTY ((cache)) hash_table<const_int_hasher> *const_int_htab;
     148              : 
     149              : struct const_wide_int_hasher : ggc_cache_ptr_hash<rtx_def>
     150              : {
     151              :   static hashval_t hash (rtx x);
     152              :   static bool equal (rtx x, rtx y);
     153              : };
     154              : 
     155              : static GTY ((cache)) hash_table<const_wide_int_hasher> *const_wide_int_htab;
     156              : 
     157              : struct const_poly_int_hasher : ggc_cache_ptr_hash<rtx_def>
     158              : {
     159              :   typedef std::pair<machine_mode, poly_wide_int_ref> compare_type;
     160              : 
     161              :   static hashval_t hash (rtx x);
     162              :   static bool equal (rtx x, const compare_type &y);
     163              : };
     164              : 
     165              : static GTY ((cache)) hash_table<const_poly_int_hasher> *const_poly_int_htab;
     166              : 
     167              : /* A hash table storing register attribute structures.  */
     168              : struct reg_attr_hasher : ggc_cache_ptr_hash<reg_attrs>
     169              : {
     170              :   static hashval_t hash (reg_attrs *x);
     171              :   static bool equal (reg_attrs *a, reg_attrs *b);
     172              : };
     173              : 
     174              : static GTY ((cache)) hash_table<reg_attr_hasher> *reg_attrs_htab;
     175              : 
     176              : /* A hash table storing all CONST_DOUBLEs.  */
     177              : struct const_double_hasher : ggc_cache_ptr_hash<rtx_def>
     178              : {
     179              :   static hashval_t hash (rtx x);
     180              :   static bool equal (rtx x, rtx y);
     181              : };
     182              : 
     183              : static GTY ((cache)) hash_table<const_double_hasher> *const_double_htab;
     184              : 
     185              : /* A hash table storing all CONST_FIXEDs.  */
     186              : struct const_fixed_hasher : ggc_cache_ptr_hash<rtx_def>
     187              : {
     188              :   static hashval_t hash (rtx x);
     189              :   static bool equal (rtx x, rtx y);
     190              : };
     191              : 
     192              : static GTY ((cache)) hash_table<const_fixed_hasher> *const_fixed_htab;
     193              : 
     194              : #define cur_insn_uid (crtl->emit.x_cur_insn_uid)
     195              : #define cur_debug_insn_uid (crtl->emit.x_cur_debug_insn_uid)
     196              : #define first_label_num (crtl->emit.x_first_label_num)
     197              : 
     198              : static void set_used_decls (tree);
     199              : static void mark_label_nuses (rtx);
     200              : #if TARGET_SUPPORTS_WIDE_INT
     201              : static rtx lookup_const_wide_int (rtx);
     202              : #endif
     203              : static rtx lookup_const_double (rtx);
     204              : static rtx lookup_const_fixed (rtx);
     205              : static rtx gen_const_vector (machine_mode, int);
     206              : static void copy_rtx_if_shared_1 (rtx *orig);
     207              : 
     208              : /* Probability of the conditional branch currently proceeded by try_split.  */
     209              : profile_probability split_branch_probability;
     210              : 
     211              : /* Returns a hash code for X (which is a really a CONST_INT).  */
     212              : 
     213              : hashval_t
     214   3385016244 : const_int_hasher::hash (rtx x)
     215              : {
     216   3385016244 :   return (hashval_t) INTVAL (x);
     217              : }
     218              : 
     219              : /* Returns true if the value represented by X (which is really a
     220              :    CONST_INT) is the same as that given by Y (which is really a
     221              :    HOST_WIDE_INT *).  */
     222              : 
     223              : bool
     224   4267736933 : const_int_hasher::equal (rtx x, HOST_WIDE_INT y)
     225              : {
     226   4267736933 :   return (INTVAL (x) == y);
     227              : }
     228              : 
     229              : #if TARGET_SUPPORTS_WIDE_INT
     230              : /* Returns a hash code for X (which is a really a CONST_WIDE_INT).  */
     231              : 
     232              : hashval_t
     233      1417446 : const_wide_int_hasher::hash (rtx x)
     234              : {
     235      1417446 :   int i;
     236      1417446 :   unsigned HOST_WIDE_INT hash = 0;
     237      1417446 :   const_rtx xr = x;
     238              : 
     239      4278905 :   for (i = 0; i < CONST_WIDE_INT_NUNITS (xr); i++)
     240      2861459 :     hash += CONST_WIDE_INT_ELT (xr, i);
     241              : 
     242      1417446 :   return (hashval_t) hash;
     243              : }
     244              : 
     245              : /* Returns true if the value represented by X (which is really a
     246              :    CONST_WIDE_INT) is the same as that given by Y (which is really a
     247              :    CONST_WIDE_INT).  */
     248              : 
     249              : bool
     250      1439531 : const_wide_int_hasher::equal (rtx x, rtx y)
     251              : {
     252      1439531 :   int i;
     253      1439531 :   const_rtx xr = x;
     254      1439531 :   const_rtx yr = y;
     255      1439531 :   if (CONST_WIDE_INT_NUNITS (xr) != CONST_WIDE_INT_NUNITS (yr))
     256              :     return false;
     257              : 
     258      2500428 :   for (i = 0; i < CONST_WIDE_INT_NUNITS (xr); i++)
     259      1998096 :     if (CONST_WIDE_INT_ELT (xr, i) != CONST_WIDE_INT_ELT (yr, i))
     260              :       return false;
     261              : 
     262              :   return true;
     263              : }
     264              : #endif
     265              : 
     266              : /* Returns a hash code for CONST_POLY_INT X.  */
     267              : 
     268              : hashval_t
     269            0 : const_poly_int_hasher::hash (rtx x)
     270              : {
     271            0 :   inchash::hash h;
     272            0 :   h.add_int (GET_MODE (x));
     273            0 :   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
     274            0 :     h.add_wide_int (CONST_POLY_INT_COEFFS (x)[i]);
     275            0 :   return h.end ();
     276              : }
     277              : 
     278              : /* Returns true if CONST_POLY_INT X is an rtx representation of Y.  */
     279              : 
     280              : bool
     281            0 : const_poly_int_hasher::equal (rtx x, const compare_type &y)
     282              : {
     283            0 :   if (GET_MODE (x) != y.first)
     284              :     return false;
     285            0 :   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
     286            0 :     if (CONST_POLY_INT_COEFFS (x)[i] != y.second.coeffs[i])
     287              :       return false;
     288              :   return true;
     289              : }
     290              : 
     291              : /* Returns a hash code for X (which is really a CONST_DOUBLE).  */
     292              : hashval_t
     293     18805384 : const_double_hasher::hash (rtx x)
     294              : {
     295     18805384 :   const_rtx const value = x;
     296     18805384 :   hashval_t h;
     297              : 
     298     18805384 :   if (TARGET_SUPPORTS_WIDE_INT == 0 && GET_MODE (value) == VOIDmode)
     299              :     h = CONST_DOUBLE_LOW (value) ^ CONST_DOUBLE_HIGH (value);
     300              :   else
     301              :     {
     302     18805384 :       h = real_hash (CONST_DOUBLE_REAL_VALUE (value));
     303              :       /* MODE is used in the comparison, so it should be in the hash.  */
     304     18805384 :       h ^= GET_MODE (value);
     305              :     }
     306     18805384 :   return h;
     307              : }
     308              : 
     309              : /* Returns true if the value represented by X (really a ...)
     310              :    is the same as that represented by Y (really a ...) */
     311              : bool
     312     12857251 : const_double_hasher::equal (rtx x, rtx y)
     313              : {
     314     12857251 :   const_rtx const a = x, b = y;
     315              : 
     316     12857251 :   if (GET_MODE (a) != GET_MODE (b))
     317              :     return false;
     318      4615392 :   if (TARGET_SUPPORTS_WIDE_INT == 0 && GET_MODE (a) == VOIDmode)
     319              :     return (CONST_DOUBLE_LOW (a) == CONST_DOUBLE_LOW (b)
     320              :             && CONST_DOUBLE_HIGH (a) == CONST_DOUBLE_HIGH (b));
     321              :   else
     322      4615392 :     return real_identical (CONST_DOUBLE_REAL_VALUE (a),
     323      4615392 :                            CONST_DOUBLE_REAL_VALUE (b));
     324              : }
     325              : 
     326              : /* Returns a hash code for X (which is really a CONST_FIXED).  */
     327              : 
     328              : hashval_t
     329     12240589 : const_fixed_hasher::hash (rtx x)
     330              : {
     331     12240589 :   const_rtx const value = x;
     332     12240589 :   hashval_t h;
     333              : 
     334     12240589 :   h = fixed_hash (CONST_FIXED_VALUE (value));
     335              :   /* MODE is used in the comparison, so it should be in the hash.  */
     336     12240589 :   h ^= GET_MODE (value);
     337     12240589 :   return h;
     338              : }
     339              : 
     340              : /* Returns true if the value represented by X is the same as that
     341              :    represented by Y.  */
     342              : 
     343              : bool
     344      6123844 : const_fixed_hasher::equal (rtx x, rtx y)
     345              : {
     346      6123844 :   const_rtx const a = x, b = y;
     347              : 
     348      6123844 :   if (GET_MODE (a) != GET_MODE (b))
     349              :     return false;
     350       582704 :   return fixed_identical (CONST_FIXED_VALUE (a), CONST_FIXED_VALUE (b));
     351              : }
     352              : 
     353              : /* Return true if the given memory attributes are equal.  */
     354              : 
     355              : bool
     356    225042584 : mem_attrs_eq_p (const class mem_attrs *p, const class mem_attrs *q)
     357              : {
     358    225042584 :   if (p == q)
     359              :     return true;
     360    221849515 :   if (!p || !q)
     361              :     return false;
     362    221394112 :   return (p->alias == q->alias
     363    139693448 :           && p->offset_known_p == q->offset_known_p
     364    111066985 :           && (!p->offset_known_p || known_eq (p->offset, q->offset))
     365     95908695 :           && p->size_known_p == q->size_known_p
     366     92639329 :           && (!p->size_known_p || known_eq (p->size, q->size))
     367     79590781 :           && p->align == q->align
     368     65131208 :           && p->addrspace == q->addrspace
     369    286242728 :           && (p->expr == q->expr
     370     30163582 :               || (p->expr != NULL_TREE && q->expr != NULL_TREE
     371     23310914 :                   && operand_equal_p (p->expr, q->expr, 0))));
     372              : }
     373              : 
     374              : /* Set MEM's memory attributes so that they are the same as ATTRS.  */
     375              : 
     376              : static void
     377     98989326 : set_mem_attrs (rtx mem, mem_attrs *attrs)
     378              : {
     379              :   /* If everything is the default, we can just clear the attributes.  */
     380     98989326 :   if (mem_attrs_eq_p (attrs, mode_mem_attrs[(int) GET_MODE (mem)]))
     381              :     {
     382      3533906 :       MEM_ATTRS (mem) = 0;
     383      3533906 :       return;
     384              :     }
     385              : 
     386     95455420 :   if (!MEM_ATTRS (mem)
     387     95455420 :       || !mem_attrs_eq_p (attrs, MEM_ATTRS (mem)))
     388              :     {
     389     72860148 :       MEM_ATTRS (mem) = ggc_alloc<mem_attrs> ();
     390     72860148 :       memcpy (MEM_ATTRS (mem), attrs, sizeof (mem_attrs));
     391              :     }
     392              : }
     393              : 
     394              : /* Returns a hash code for X (which is a really a reg_attrs *).  */
     395              : 
     396              : hashval_t
     397    312513763 : reg_attr_hasher::hash (reg_attrs *x)
     398              : {
     399    312513763 :   const reg_attrs *const p = x;
     400              : 
     401    312513763 :   inchash::hash h;
     402    312513763 :   h.add_ptr (p->decl);
     403    312513763 :   h.add_poly_hwi (p->offset);
     404    312513763 :   return h.end ();
     405              : }
     406              : 
     407              : /* Returns true if the value represented by X  is the same as that given by
     408              :    Y.  */
     409              : 
     410              : bool
     411    302258912 : reg_attr_hasher::equal (reg_attrs *x, reg_attrs *y)
     412              : {
     413    302258912 :   const reg_attrs *const p = x;
     414    302258912 :   const reg_attrs *const q = y;
     415              : 
     416    302258912 :   return (p->decl == q->decl && known_eq (p->offset, q->offset));
     417              : }
     418              : /* Allocate a new reg_attrs structure and insert it into the hash table if
     419              :    one identical to it is not already in the table.  We are doing this for
     420              :    MEM of mode MODE.  */
     421              : 
     422              : static reg_attrs *
     423     64446215 : get_reg_attrs (tree decl, poly_int64 offset)
     424              : {
     425     64446215 :   reg_attrs attrs;
     426              : 
     427              :   /* If everything is the default, we can just return zero.  */
     428     64446215 :   if (decl == 0 && known_eq (offset, 0))
     429              :     return 0;
     430              : 
     431     58871716 :   attrs.decl = decl;
     432     58871716 :   attrs.offset = offset;
     433              : 
     434     58871716 :   reg_attrs **slot = reg_attrs_htab->find_slot (&attrs, INSERT);
     435     58871716 :   if (*slot == 0)
     436              :     {
     437     29697700 :       *slot = ggc_alloc<reg_attrs> ();
     438     29697700 :       memcpy (*slot, &attrs, sizeof (reg_attrs));
     439              :     }
     440              : 
     441     58871716 :   return *slot;
     442              : }
     443              : 
     444              : 
     445              : #if !HAVE_blockage
     446              : /* Generate an empty ASM_INPUT, which is used to block attempts to schedule,
     447              :    and to block register equivalences to be seen across this insn.  */
     448              : 
     449              : rtx
     450              : gen_blockage (void)
     451              : {
     452              :   rtx x = gen_rtx_ASM_INPUT (VOIDmode, "");
     453              :   MEM_VOLATILE_P (x) = true;
     454              :   return x;
     455              : }
     456              : #endif
     457              : 
     458              : 
     459              : /* Set the mode and register number of X to MODE and REGNO.  */
     460              : 
     461              : void
     462   1716278289 : set_mode_and_regno (rtx x, machine_mode mode, unsigned int regno)
     463              : {
     464   1716278289 :   unsigned int nregs = (HARD_REGISTER_NUM_P (regno)
     465   1716278289 :                         ? hard_regno_nregs (regno, mode)
     466   1284910244 :                         : 1);
     467   1716278289 :   PUT_MODE_RAW (x, mode);
     468   1716278289 :   set_regno_raw (x, regno, nregs);
     469   1716278289 : }
     470              : 
     471              : /* Initialize a fresh REG rtx with mode MODE and register REGNO.  */
     472              : 
     473              : rtx
     474    348155943 : init_raw_REG (rtx x, machine_mode mode, unsigned int regno)
     475              : {
     476    348155943 :   set_mode_and_regno (x, mode, regno);
     477    348155943 :   REG_ATTRS (x) = NULL;
     478    348155943 :   ORIGINAL_REGNO (x) = regno;
     479    348155943 :   return x;
     480              : }
     481              : 
     482              : /* Generate a new REG rtx.  Make sure ORIGINAL_REGNO is set properly, and
     483              :    don't attempt to share with the various global pieces of rtl (such as
     484              :    frame_pointer_rtx).  */
     485              : 
     486              : rtx
     487    346114343 : gen_raw_REG (machine_mode mode, unsigned int regno)
     488              : {
     489    346114343 :   rtx x = rtx_alloc (REG MEM_STAT_INFO);
     490    346114343 :   init_raw_REG (x, mode, regno);
     491    346114343 :   return x;
     492              : }
     493              : 
     494              : /* There are some RTL codes that require special attention; the generation
     495              :    functions do the raw handling.  If you add to this list, modify
     496              :    special_rtx in gengenrtl.cc as well.  */
     497              : 
     498              : rtx_expr_list *
     499    203859173 : gen_rtx_EXPR_LIST (machine_mode mode, rtx expr, rtx expr_list)
     500              : {
     501    203859173 :   return as_a <rtx_expr_list *> (gen_rtx_fmt_ee (EXPR_LIST, mode, expr,
     502    203859173 :                                                  expr_list));
     503              : }
     504              : 
     505              : rtx_insn_list *
     506     93547024 : gen_rtx_INSN_LIST (machine_mode mode, rtx insn, rtx insn_list)
     507              : {
     508     93547024 :   return as_a <rtx_insn_list *> (gen_rtx_fmt_ue (INSN_LIST, mode, insn,
     509     93547024 :                                                  insn_list));
     510              : }
     511              : 
     512              : rtx_insn *
     513       834978 : gen_rtx_INSN (machine_mode mode, rtx_insn *prev_insn, rtx_insn *next_insn,
     514              :               basic_block bb, rtx pattern, location_t location, int code,
     515              :               rtx reg_notes)
     516              : {
     517       834978 :   return as_a <rtx_insn *> (gen_rtx_fmt_uuBeLie (INSN, mode,
     518              :                                                  prev_insn, next_insn,
     519              :                                                  bb, pattern, location, code,
     520       834978 :                                                  reg_notes));
     521              : }
     522              : 
     523              : rtx
     524   1385718697 : gen_rtx_CONST_INT (machine_mode mode ATTRIBUTE_UNUSED, HOST_WIDE_INT arg)
     525              : {
     526   1385718697 :   if (arg >= - MAX_SAVED_CONST_INT && arg <= MAX_SAVED_CONST_INT)
     527    927004180 :     return const_int_rtx[arg + MAX_SAVED_CONST_INT];
     528              : 
     529              : #if STORE_FLAG_VALUE != 1 && STORE_FLAG_VALUE != -1
     530              :   if (const_true_rtx && arg == STORE_FLAG_VALUE)
     531              :     return const_true_rtx;
     532              : #endif
     533              : 
     534              :   /* Look up the CONST_INT in the hash table.  */
     535    458714517 :   rtx *slot = const_int_htab->find_slot_with_hash (arg, (hashval_t) arg,
     536              :                                                    INSERT);
     537    458714517 :   if (*slot == 0)
     538     35584573 :     *slot = gen_rtx_raw_CONST_INT (VOIDmode, arg);
     539              : 
     540    458714517 :   return *slot;
     541              : }
     542              : 
     543              : rtx
     544   1301352702 : gen_int_mode (poly_int64 c, machine_mode mode)
     545              : {
     546   1301352702 :   c = trunc_int_for_mode (c, mode);
     547   1301352702 :   if (c.is_constant ())
     548   1301352702 :     return GEN_INT (c.coeffs[0]);
     549              :   unsigned int prec = GET_MODE_PRECISION (as_a <scalar_mode> (mode));
     550              :   return immed_wide_int_const (poly_wide_int::from (c, prec, SIGNED), mode);
     551              : }
     552              : 
     553              : /* CONST_DOUBLEs might be created from pairs of integers, or from
     554              :    REAL_VALUE_TYPEs.  Also, their length is known only at run time,
     555              :    so we cannot use gen_rtx_raw_CONST_DOUBLE.  */
     556              : 
     557              : /* Determine whether REAL, a CONST_DOUBLE, already exists in the
     558              :    hash table.  If so, return its counterpart; otherwise add it
     559              :    to the hash table and return it.  */
     560              : static rtx
     561     10055373 : lookup_const_double (rtx real)
     562              : {
     563     10055373 :   rtx *slot = const_double_htab->find_slot (real, INSERT);
     564     10055373 :   if (*slot == 0)
     565      8068555 :     *slot = real;
     566              : 
     567     10055373 :   return *slot;
     568              : }
     569              : 
     570              : /* Return a CONST_DOUBLE rtx for a floating-point value specified by
     571              :    VALUE in mode MODE.  */
     572              : rtx
     573     10055373 : const_double_from_real_value (REAL_VALUE_TYPE value, machine_mode mode)
     574              : {
     575     10055373 :   rtx real = rtx_alloc (CONST_DOUBLE);
     576     10055373 :   PUT_MODE (real, mode);
     577              : 
     578     10055373 :   real->u.rv = value;
     579              : 
     580     10055373 :   return lookup_const_double (real);
     581              : }
     582              : 
     583              : /* Determine whether FIXED, a CONST_FIXED, already exists in the
     584              :    hash table.  If so, return its counterpart; otherwise add it
     585              :    to the hash table and return it.  */
     586              : 
     587              : static rtx
     588      7573046 : lookup_const_fixed (rtx fixed)
     589              : {
     590      7573046 :   rtx *slot = const_fixed_htab->find_slot (fixed, INSERT);
     591      7573046 :   if (*slot == 0)
     592      7573046 :     *slot = fixed;
     593              : 
     594      7573046 :   return *slot;
     595              : }
     596              : 
     597              : /* Return a CONST_FIXED rtx for a fixed-point value specified by
     598              :    VALUE in mode MODE.  */
     599              : 
     600              : rtx
     601      7573046 : const_fixed_from_fixed_value (FIXED_VALUE_TYPE value, machine_mode mode)
     602              : {
     603      7573046 :   rtx fixed = rtx_alloc (CONST_FIXED);
     604      7573046 :   PUT_MODE (fixed, mode);
     605              : 
     606      7573046 :   fixed->u.fv = value;
     607              : 
     608      7573046 :   return lookup_const_fixed (fixed);
     609              : }
     610              : 
     611              : #if TARGET_SUPPORTS_WIDE_INT == 0
     612              : /* Constructs double_int from rtx CST.  */
     613              : 
     614              : double_int
     615              : rtx_to_double_int (const_rtx cst)
     616              : {
     617              :   double_int r;
     618              : 
     619              :   if (CONST_INT_P (cst))
     620              :       r = double_int::from_shwi (INTVAL (cst));
     621              :   else if (CONST_DOUBLE_AS_INT_P (cst))
     622              :     {
     623              :       r.low = CONST_DOUBLE_LOW (cst);
     624              :       r.high = CONST_DOUBLE_HIGH (cst);
     625              :     }
     626              :   else
     627              :     gcc_unreachable ();
     628              : 
     629              :   return r;
     630              : }
     631              : #endif
     632              : 
     633              : #if TARGET_SUPPORTS_WIDE_INT
     634              : /* Determine whether CONST_WIDE_INT WINT already exists in the hash table.
     635              :    If so, return its counterpart; otherwise add it to the hash table and
     636              :    return it.  */
     637              : 
     638              : static rtx
     639       559923 : lookup_const_wide_int (rtx wint)
     640              : {
     641       559923 :   rtx *slot = const_wide_int_htab->find_slot (wint, INSERT);
     642       559923 :   if (*slot == 0)
     643        57591 :     *slot = wint;
     644              : 
     645       559923 :   return *slot;
     646              : }
     647              : #endif
     648              : 
     649              : /* Return an rtx constant for V, given that the constant has mode MODE.
     650              :    The returned rtx will be a CONST_INT if V fits, otherwise it will be
     651              :    a CONST_DOUBLE (if !TARGET_SUPPORTS_WIDE_INT) or a CONST_WIDE_INT
     652              :    (if TARGET_SUPPORTS_WIDE_INT).  */
     653              : 
     654              : static rtx
     655    706670350 : immed_wide_int_const_1 (const wide_int_ref &v, machine_mode mode)
     656              : {
     657    706670350 :   unsigned int len = v.get_len ();
     658              :   /* Not scalar_int_mode because we also allow pointer bound modes.  */
     659    706670350 :   unsigned int prec = GET_MODE_PRECISION (as_a <scalar_mode> (mode));
     660              : 
     661              :   /* Allow truncation but not extension since we do not know if the
     662              :      number is signed or unsigned.  */
     663    706670350 :   gcc_assert (prec <= v.get_precision ());
     664              : 
     665    706670350 :   if (len < 2 || prec <= HOST_BITS_PER_WIDE_INT)
     666    706110427 :     return gen_int_mode (v.elt (0), mode);
     667              : 
     668              : #if TARGET_SUPPORTS_WIDE_INT
     669       559923 :   {
     670       559923 :     unsigned int i;
     671       559923 :     rtx value;
     672       559923 :     unsigned int blocks_needed
     673       559923 :       = (prec + HOST_BITS_PER_WIDE_INT - 1) / HOST_BITS_PER_WIDE_INT;
     674              : 
     675       559923 :     if (len > blocks_needed)
     676              :       len = blocks_needed;
     677              : 
     678       559923 :     value = const_wide_int_alloc (len);
     679              : 
     680              :     /* It is so tempting to just put the mode in here.  Must control
     681              :        myself ... */
     682       559923 :     PUT_MODE (value, VOIDmode);
     683       559923 :     CWI_PUT_NUM_ELEM (value, len);
     684              : 
     685      1687434 :     for (i = 0; i < len; i++)
     686      1127511 :       CONST_WIDE_INT_ELT (value, i) = v.elt (i);
     687              : 
     688       559923 :     return lookup_const_wide_int (value);
     689              :   }
     690              : #else
     691              :   return immed_double_const (v.elt (0), v.elt (1), mode);
     692              : #endif
     693              : }
     694              : 
     695              : #if TARGET_SUPPORTS_WIDE_INT == 0
     696              : /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair
     697              :    of ints: I0 is the low-order word and I1 is the high-order word.
     698              :    For values that are larger than HOST_BITS_PER_DOUBLE_INT, the
     699              :    implied upper bits are copies of the high bit of i1.  The value
     700              :    itself is neither signed nor unsigned.  Do not use this routine for
     701              :    non-integer modes; convert to REAL_VALUE_TYPE and use
     702              :    const_double_from_real_value.  */
     703              : 
     704              : rtx
     705              : immed_double_const (HOST_WIDE_INT i0, HOST_WIDE_INT i1, machine_mode mode)
     706              : {
     707              :   rtx value;
     708              :   unsigned int i;
     709              : 
     710              :   /* There are the following cases (note that there are no modes with
     711              :      HOST_BITS_PER_WIDE_INT < GET_MODE_BITSIZE (mode) < HOST_BITS_PER_DOUBLE_INT):
     712              : 
     713              :      1) If GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT, then we use
     714              :         gen_int_mode.
     715              :      2) If the value of the integer fits into HOST_WIDE_INT anyway
     716              :         (i.e., i1 consists only from copies of the sign bit, and sign
     717              :         of i0 and i1 are the same), then we return a CONST_INT for i0.
     718              :      3) Otherwise, we create a CONST_DOUBLE for i0 and i1.  */
     719              :   scalar_mode smode;
     720              :   if (is_a <scalar_mode> (mode, &smode)
     721              :       && GET_MODE_BITSIZE (smode) <= HOST_BITS_PER_WIDE_INT)
     722              :     return gen_int_mode (i0, mode);
     723              : 
     724              :   /* If this integer fits in one word, return a CONST_INT.  */
     725              :   if ((i1 == 0 && i0 >= 0) || (i1 == ~0 && i0 < 0))
     726              :     return GEN_INT (i0);
     727              : 
     728              :   /* We use VOIDmode for integers.  */
     729              :   value = rtx_alloc (CONST_DOUBLE);
     730              :   PUT_MODE (value, VOIDmode);
     731              : 
     732              :   CONST_DOUBLE_LOW (value) = i0;
     733              :   CONST_DOUBLE_HIGH (value) = i1;
     734              : 
     735              :   for (i = 2; i < (sizeof CONST_DOUBLE_FORMAT - 1); i++)
     736              :     XWINT (value, i) = 0;
     737              : 
     738              :   return lookup_const_double (value);
     739              : }
     740              : #endif
     741              : 
     742              : /* Return an rtx representation of C in mode MODE.  */
     743              : 
     744              : rtx
     745    706670350 : immed_wide_int_const (const poly_wide_int_ref &c, machine_mode mode)
     746              : {
     747    706670350 :   if (c.is_constant ())
     748    706670350 :     return immed_wide_int_const_1 (c.coeffs[0], mode);
     749              : 
     750              :   /* Not scalar_int_mode because we also allow pointer bound modes.  */
     751              :   unsigned int prec = GET_MODE_PRECISION (as_a <scalar_mode> (mode));
     752              : 
     753              :   /* Allow truncation but not extension since we do not know if the
     754              :      number is signed or unsigned.  */
     755              :   gcc_assert (prec <= c.coeffs[0].get_precision ());
     756              :   poly_wide_int newc = poly_wide_int::from (c, prec, SIGNED);
     757              : 
     758              :   /* See whether we already have an rtx for this constant.  */
     759              :   inchash::hash h;
     760              :   h.add_int (mode);
     761              :   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
     762              :     h.add_wide_int (newc.coeffs[i]);
     763              :   const_poly_int_hasher::compare_type typed_value (mode, newc);
     764              :   rtx *slot = const_poly_int_htab->find_slot_with_hash (typed_value,
     765              :                                                         h.end (), INSERT);
     766              :   rtx x = *slot;
     767              :   if (x)
     768              :     return x;
     769              : 
     770              :   /* Create a new rtx.  There's a choice to be made here between installing
     771              :      the actual mode of the rtx or leaving it as VOIDmode (for consistency
     772              :      with CONST_INT).  In practice the handling of the codes is different
     773              :      enough that we get no benefit from using VOIDmode, and various places
     774              :      assume that VOIDmode implies CONST_INT.  Using the real mode seems like
     775              :      the right long-term direction anyway.  */
     776              :   typedef trailing_wide_ints<NUM_POLY_INT_COEFFS> twi;
     777              :   size_t extra_size = twi::extra_size (prec);
     778              :   x = rtx_alloc_v (CONST_POLY_INT,
     779              :                    sizeof (struct const_poly_int_def) + extra_size);
     780              :   PUT_MODE (x, mode);
     781              :   CONST_POLY_INT_COEFFS (x).set_precision (prec);
     782              :   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
     783              :     CONST_POLY_INT_COEFFS (x)[i] = newc.coeffs[i];
     784              : 
     785              :   *slot = x;
     786              :   return x;
     787              : }
     788              : 
     789              : rtx
     790    189773049 : gen_rtx_REG (machine_mode mode, unsigned int regno)
     791              : {
     792              :   /* In case the MD file explicitly references the frame pointer, have
     793              :      all such references point to the same frame pointer.  This is
     794              :      used during frame pointer elimination to distinguish the explicit
     795              :      references to these registers from pseudos that happened to be
     796              :      assigned to them.
     797              : 
     798              :      If we have eliminated the frame pointer or arg pointer, we will
     799              :      be using it as a normal register, for example as a spill
     800              :      register.  In such cases, we might be accessing it in a mode that
     801              :      is not Pmode and therefore cannot use the pre-allocated rtx.
     802              : 
     803              :      Also don't do this when we are making new REGs in reload, since
     804              :      we don't want to get confused with the real pointers.  */
     805              : 
     806    204251721 :   if (mode == Pmode && !reload_in_progress && !lra_in_progress)
     807              :     {
     808     61051326 :       if (regno == FRAME_POINTER_REGNUM
     809      2982719 :           && (!reload_completed || frame_pointer_needed))
     810      2982719 :         return frame_pointer_rtx;
     811              : 
     812     58068607 :       if (!HARD_FRAME_POINTER_IS_FRAME_POINTER
     813              :           && regno == HARD_FRAME_POINTER_REGNUM
     814      4263605 :           && (!reload_completed || frame_pointer_needed))
     815      3752738 :         return hard_frame_pointer_rtx;
     816              : #if !HARD_FRAME_POINTER_IS_ARG_POINTER
     817     54315869 :       if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
     818              :           && regno == ARG_POINTER_REGNUM)
     819      2986836 :         return arg_pointer_rtx;
     820              : #endif
     821              : #ifdef RETURN_ADDRESS_POINTER_REGNUM
     822              :       if (regno == RETURN_ADDRESS_POINTER_REGNUM)
     823              :         return return_address_pointer_rtx;
     824              : #endif
     825     51329033 :       if (regno == (unsigned) PIC_OFFSET_TABLE_REGNUM
     826            0 :           && PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM
     827     51329033 :           && fixed_regs[PIC_OFFSET_TABLE_REGNUM])
     828            0 :         return pic_offset_table_rtx;
     829     51329033 :       if (regno == STACK_POINTER_REGNUM)
     830      4011430 :         return stack_pointer_rtx;
     831              :     }
     832              : 
     833              : #if 0
     834              :   /* If the per-function register table has been set up, try to re-use
     835              :      an existing entry in that table to avoid useless generation of RTL.
     836              : 
     837              :      This code is disabled for now until we can fix the various backends
     838              :      which depend on having non-shared hard registers in some cases.   Long
     839              :      term we want to re-enable this code as it can significantly cut down
     840              :      on the amount of useless RTL that gets generated.
     841              : 
     842              :      We'll also need to fix some code that runs after reload that wants to
     843              :      set ORIGINAL_REGNO.  */
     844              : 
     845              :   if (cfun
     846              :       && cfun->emit
     847              :       && regno_reg_rtx
     848              :       && regno < FIRST_PSEUDO_REGISTER
     849              :       && reg_raw_mode[regno] == mode)
     850              :     return regno_reg_rtx[regno];
     851              : #endif
     852              : 
     853    176039326 :   return gen_raw_REG (mode, regno);
     854              : }
     855              : 
     856              : rtx
     857    247927842 : gen_rtx_MEM (machine_mode mode, rtx addr)
     858              : {
     859    247927842 :   rtx rt = gen_rtx_raw_MEM (mode, addr);
     860              : 
     861              :   /* This field is not cleared by the mere allocation of the rtx, so
     862              :      we clear it here.  */
     863    247927842 :   MEM_ATTRS (rt) = 0;
     864              : 
     865    247927842 :   return rt;
     866              : }
     867              : 
     868              : /* Generate a memory referring to non-trapping constant memory.  */
     869              : 
     870              : rtx
     871      2098946 : gen_const_mem (machine_mode mode, rtx addr)
     872              : {
     873      2098946 :   rtx mem = gen_rtx_MEM (mode, addr);
     874      2098946 :   MEM_READONLY_P (mem) = 1;
     875      2098946 :   MEM_NOTRAP_P (mem) = 1;
     876      2098946 :   return mem;
     877              : }
     878              : 
     879              : /* Generate a MEM referring to fixed portions of the frame, e.g., register
     880              :    save areas.  */
     881              : 
     882              : rtx
     883      1237360 : gen_frame_mem (machine_mode mode, rtx addr)
     884              : {
     885      1237360 :   rtx mem = gen_rtx_MEM (mode, addr);
     886      1237360 :   MEM_NOTRAP_P (mem) = 1;
     887      1237360 :   set_mem_alias_set (mem, get_frame_alias_set ());
     888      1237360 :   return mem;
     889              : }
     890              : 
     891              : /* Generate a MEM referring to a temporary use of the stack, not part
     892              :     of the fixed stack frame.  For example, something which is pushed
     893              :     by a target splitter.  */
     894              : rtx
     895            0 : gen_tmp_stack_mem (machine_mode mode, rtx addr)
     896              : {
     897            0 :   rtx mem = gen_rtx_MEM (mode, addr);
     898            0 :   MEM_NOTRAP_P (mem) = 1;
     899            0 :   if (!cfun->calls_alloca)
     900            0 :     set_mem_alias_set (mem, get_frame_alias_set ());
     901            0 :   return mem;
     902              : }
     903              : 
     904              : /* We want to create (subreg:OMODE (obj:IMODE) OFFSET).  Return true if
     905              :    this construct would be valid, and false otherwise.  */
     906              : 
     907              : bool
     908     48694169 : validate_subreg (machine_mode omode, machine_mode imode,
     909              :                  const_rtx reg, poly_uint64 offset)
     910              : {
     911     97388338 :   poly_uint64 isize = GET_MODE_SIZE (imode);
     912     97388338 :   poly_uint64 osize = GET_MODE_SIZE (omode);
     913              : 
     914              :   /* The sizes must be ordered, so that we know whether the subreg
     915              :      is partial, paradoxical or complete.  */
     916     48694169 :   if (!ordered_p (isize, osize))
     917              :     return false;
     918              : 
     919              :   /* All subregs must be aligned.  */
     920     48771706 :   if (!multiple_p (offset, osize))
     921              :     return false;
     922              : 
     923              :   /* The subreg offset cannot be outside the inner object.  */
     924     48694149 :   if (maybe_ge (offset, isize))
     925              :     return false;
     926              : 
     927     48694149 :   poly_uint64 regsize = REGMODE_NATURAL_SIZE (imode);
     928              : 
     929              :   /* ??? This should not be here.  Temporarily continue to allow word_mode
     930              :      subregs of anything.  The most common offender is (subreg:SI (reg:DF)).
     931              :      Generally, backends are doing something sketchy but it'll take time to
     932              :      fix them all.  */
     933     48694149 :   if (omode == word_mode)
     934              :     ;
     935              :   /* ??? Similarly, e.g. with (subreg:DF (reg:TI)).  Though store_bit_field
     936              :      is the culprit here, and not the backends.  */
     937     29638456 :   else if (known_ge (osize, regsize) && known_ge (isize, osize))
     938              :     ;
     939              :   /* Allow component subregs of complex and vector.  Though given the below
     940              :      extraction rules, it's not always clear what that means.  */
     941     23587986 :   else if ((COMPLEX_MODE_P (imode) || VECTOR_MODE_P (imode))
     942     24463151 :            && GET_MODE_INNER (imode) == omode)
     943              :     ;
     944              :   /* ??? x86 sse code makes heavy use of *paradoxical* vector subregs,
     945              :      i.e. (subreg:V4SF (reg:SF) 0) or (subreg:V4SF (reg:V2SF) 0).  This
     946              :      surely isn't the cleanest way to represent this.  It's questionable
     947              :      if this ought to be represented at all -- why can't this all be hidden
     948              :      in post-reload splitters that make arbitrarily mode changes to the
     949              :      registers themselves.  */
     950     22196587 :   else if (VECTOR_MODE_P (omode)
     951     24474229 :            && GET_MODE_UNIT_SIZE (omode) == GET_MODE_UNIT_SIZE (imode))
     952              :     ;
     953              :   /* Subregs involving floating point modes are not allowed to
     954              :      change size unless it's an insert into a complex mode.
     955              :      Therefore (subreg:DI (reg:DF) 0) and (subreg:CS (reg:SF) 0) are fine, but
     956              :      (subreg:SI (reg:DF) 0) isn't.  */
     957     22088282 :   else if ((FLOAT_MODE_P (imode) || FLOAT_MODE_P (omode))
     958       263360 :            && !COMPLEX_MODE_P (omode))
     959              :     {
     960       263200 :       if (! (known_eq (isize, osize)
     961              :              /* LRA can use subreg to store a floating point value in
     962              :                 an integer mode.  Although the floating point and the
     963              :                 integer modes need the same number of hard registers,
     964              :                 the size of floating point mode can be less than the
     965              :                 integer mode.  LRA also uses subregs for a register
     966              :                 should be used in different mode in on insn.  */
     967        75638 :              || lra_in_progress))
     968              :         return false;
     969              :     }
     970              : 
     971              :   /* Paradoxical subregs must have offset zero.  */
     972     48620458 :   if (maybe_gt (osize, isize) && !known_eq (offset, 0U))
     973              :     return false;
     974              : 
     975              :   /* Verify that the offset is representable.  */
     976              : 
     977              :   /* Ensure that subregs of hard registers can be folded.  In other words,
     978              :      the hardware register must be valid in the subreg's outer mode,
     979              :      and consequently the subreg can be replaced with a hardware register.  */
     980     48620458 :   if (reg && REG_P (reg) && HARD_REGISTER_P (reg))
     981              :     {
     982       356674 :       unsigned int regno = REGNO (reg);
     983              : 
     984       356674 :       if ((COMPLEX_MODE_P (imode) || VECTOR_MODE_P (imode))
     985       692352 :           && GET_MODE_INNER (imode) == omode)
     986              :         ;
     987       117315 :       else if (!REG_CAN_CHANGE_MODE_P (regno, imode, omode))
     988              :         return false;
     989              : 
     990              :       /* Pass true to allow_stack_regs because targets like x86
     991              :          expect to be able to take subregs of the stack pointer.  */
     992       356581 :       return simplify_subreg_regno (regno, imode, offset, omode, true) >= 0;
     993              :     }
     994              :   /* Do not allow normal SUBREG with stricter alignment than the inner MEM.
     995              : 
     996              :      PR120329: Combine can create paradoxical mem subregs even for
     997              :      strict-alignment targets.  Allow it until combine is fixed.  */
     998     48263784 :   else if (reg && MEM_P (reg) && STRICT_ALIGNMENT
     999              :            && MEM_ALIGN (reg) < GET_MODE_ALIGNMENT (omode)
    1000              :            && known_le (osize, isize))
    1001              :     return false;
    1002              : 
    1003              :   /* If ISIZE is greater than REGSIZE, the inner value is split into blocks
    1004              :      of size REGSIZE.  The outer size must then be ordered wrt REGSIZE,
    1005              :      otherwise we wouldn't know at compile time how many blocks the
    1006              :      outer mode occupies.  */
    1007     48263784 :   if (maybe_gt (isize, regsize) && !ordered_p (osize, regsize))
    1008              :     return false;
    1009              : 
    1010              :   /* For normal pseudo registers, we want most of the same checks.  Namely:
    1011              : 
    1012              :      Assume that the pseudo register will be allocated to hard registers
    1013              :      that can hold REGSIZE bytes each.  If OSIZE is not a multiple of REGSIZE,
    1014              :      the remainder must correspond to the lowpart of the containing hard
    1015              :      register.  If BYTES_BIG_ENDIAN, the lowpart is at the highest offset,
    1016              :      otherwise it is at the lowest offset.
    1017              : 
    1018              :      Given that we've already checked the mode and offset alignment,
    1019              :      we only have to check subblock subregs here.
    1020              : 
    1021              :      For paradoxical little-endian registers, this check is redundant.  The
    1022              :      offset has already been validated to be zero.
    1023              : 
    1024              :      For paradoxical big-endian registers, this check is not valid
    1025              :      because the offset is zero.  */
    1026     48263784 :   if (maybe_lt (osize, regsize)
    1027     22577042 :       && known_le (osize, isize)
    1028     63810139 :       && ! (lra_in_progress && (FLOAT_MODE_P (imode) || FLOAT_MODE_P (omode))))
    1029              :     {
    1030              :       /* It is invalid for the target to pick a register size for a mode
    1031              :          that isn't ordered wrt to the size of that mode.  */
    1032     15531325 :       poly_uint64 block_size = ordered_min (isize, regsize);
    1033     15531325 :       unsigned int start_reg;
    1034     15531325 :       poly_uint64 offset_within_reg;
    1035     15531325 :       if (!can_div_trunc_p (offset, block_size, &start_reg, &offset_within_reg)
    1036     15531325 :           || (BYTES_BIG_ENDIAN
    1037              :               ? maybe_ne (offset_within_reg, block_size - osize)
    1038     15531325 :               : maybe_ne (offset_within_reg, 0U)))
    1039        77557 :         return false;
    1040              :     }
    1041              :   return true;
    1042              : }
    1043              : 
    1044              : rtx
    1045     24184158 : gen_rtx_SUBREG (machine_mode mode, rtx reg, poly_uint64 offset)
    1046              : {
    1047     24184158 :   gcc_assert (validate_subreg (mode, GET_MODE (reg), reg, offset));
    1048     24184158 :   return gen_rtx_raw_SUBREG (mode, reg, offset);
    1049              : }
    1050              : 
    1051              : /* Generate a SUBREG representing the least-significant part of REG if MODE
    1052              :    is smaller than mode of REG, otherwise paradoxical SUBREG.  */
    1053              : 
    1054              : rtx
    1055       572253 : gen_lowpart_SUBREG (machine_mode mode, rtx reg)
    1056              : {
    1057       572253 :   machine_mode inmode;
    1058              : 
    1059       572253 :   inmode = GET_MODE (reg);
    1060       572253 :   if (inmode == VOIDmode)
    1061            0 :     inmode = mode;
    1062       572253 :   return gen_rtx_SUBREG (mode, reg,
    1063       572253 :                          subreg_lowpart_offset (mode, inmode));
    1064              : }
    1065              : 
    1066              : rtx
    1067     94319675 : gen_rtx_VAR_LOCATION (machine_mode mode, tree decl, rtx loc,
    1068              :                       enum var_init_status status)
    1069              : {
    1070     94319675 :   rtx x = gen_rtx_fmt_te (VAR_LOCATION, mode, decl, loc);
    1071     94319675 :   PAT_VAR_LOCATION_STATUS (x) = status;
    1072     94319675 :   return x;
    1073              : }
    1074              : 
    1075              : 
    1076              : /* Create an rtvec and stores within it the RTXen passed in the arguments.  */
    1077              : 
    1078              : rtvec
    1079     23924311 : gen_rtvec (int n, ...)
    1080              : {
    1081     23924311 :   int i;
    1082     23924311 :   rtvec rt_val;
    1083     23924311 :   va_list p;
    1084              : 
    1085     23924311 :   va_start (p, n);
    1086              : 
    1087              :   /* Don't allocate an empty rtvec...  */
    1088     23924311 :   if (n == 0)
    1089              :     {
    1090            0 :       va_end (p);
    1091            0 :       return NULL_RTVEC;
    1092              :     }
    1093              : 
    1094     23924311 :   rt_val = rtvec_alloc (n);
    1095              : 
    1096     91323417 :   for (i = 0; i < n; i++)
    1097     43474795 :     rt_val->elem[i] = va_arg (p, rtx);
    1098              : 
    1099     23924311 :   va_end (p);
    1100     23924311 :   return rt_val;
    1101              : }
    1102              : 
    1103              : rtvec
    1104       459336 : gen_rtvec_v (int n, rtx *argp)
    1105              : {
    1106       459336 :   int i;
    1107       459336 :   rtvec rt_val;
    1108              : 
    1109              :   /* Don't allocate an empty rtvec...  */
    1110       459336 :   if (n == 0)
    1111              :     return NULL_RTVEC;
    1112              : 
    1113       459336 :   rt_val = rtvec_alloc (n);
    1114              : 
    1115      2085687 :   for (i = 0; i < n; i++)
    1116      1167015 :     rt_val->elem[i] = *argp++;
    1117              : 
    1118              :   return rt_val;
    1119              : }
    1120              : 
    1121              : rtvec
    1122            0 : gen_rtvec_v (int n, rtx_insn **argp)
    1123              : {
    1124            0 :   int i;
    1125            0 :   rtvec rt_val;
    1126              : 
    1127              :   /* Don't allocate an empty rtvec...  */
    1128            0 :   if (n == 0)
    1129              :     return NULL_RTVEC;
    1130              : 
    1131            0 :   rt_val = rtvec_alloc (n);
    1132              : 
    1133            0 :   for (i = 0; i < n; i++)
    1134            0 :     rt_val->elem[i] = *argp++;
    1135              : 
    1136              :   return rt_val;
    1137              : }
    1138              : 
    1139              : 
    1140              : /* Return the number of bytes between the start of an OUTER_MODE
    1141              :    in-memory value and the start of an INNER_MODE in-memory value,
    1142              :    given that the former is a lowpart of the latter.  It may be a
    1143              :    paradoxical lowpart, in which case the offset will be negative
    1144              :    on big-endian targets.  */
    1145              : 
    1146              : poly_int64
    1147     72626608 : byte_lowpart_offset (machine_mode outer_mode,
    1148              :                      machine_mode inner_mode)
    1149              : {
    1150     72626608 :   if (paradoxical_subreg_p (outer_mode, inner_mode))
    1151      3860090 :     return -subreg_lowpart_offset (inner_mode, outer_mode);
    1152              :   else
    1153     68766518 :     return subreg_lowpart_offset (outer_mode, inner_mode);
    1154              : }
    1155              : 
    1156              : /* Return the offset of (subreg:OUTER_MODE (mem:INNER_MODE X) OFFSET)
    1157              :    from address X.  For paradoxical big-endian subregs this is a
    1158              :    negative value, otherwise it's the same as OFFSET.  */
    1159              : 
    1160              : poly_int64
    1161     11865232 : subreg_memory_offset (machine_mode outer_mode, machine_mode inner_mode,
    1162              :                       poly_uint64 offset)
    1163              : {
    1164     11865232 :   if (paradoxical_subreg_p (outer_mode, inner_mode))
    1165              :     {
    1166      3357286 :       gcc_assert (known_eq (offset, 0U));
    1167      3357286 :       return -subreg_lowpart_offset (inner_mode, outer_mode);
    1168              :     }
    1169      8507946 :   return offset;
    1170              : }
    1171              : 
    1172              : /* As above, but return the offset that existing subreg X would have
    1173              :    if SUBREG_REG (X) were stored in memory.  The only significant thing
    1174              :    about the current SUBREG_REG is its mode.  */
    1175              : 
    1176              : poly_int64
    1177       580303 : subreg_memory_offset (const_rtx x)
    1178              : {
    1179      1160606 :   return subreg_memory_offset (GET_MODE (x), GET_MODE (SUBREG_REG (x)),
    1180       580303 :                                SUBREG_BYTE (x));
    1181              : }
    1182              : 
    1183              : /* Generate a REG rtx for a new pseudo register of mode MODE.
    1184              :    This pseudo is assigned the next sequential register number.  */
    1185              : 
    1186              : rtx
    1187     66810056 : gen_reg_rtx (machine_mode mode)
    1188              : {
    1189     66810056 :   rtx val;
    1190     66810056 :   unsigned int align = GET_MODE_ALIGNMENT (mode);
    1191              : 
    1192     66810056 :   gcc_assert (can_create_pseudo_p ());
    1193              : 
    1194              :   /* If a virtual register with bigger mode alignment is generated,
    1195              :      increase stack alignment estimation because it might be spilled
    1196              :      to stack later.  */
    1197     66810056 :   if (SUPPORTS_STACK_ALIGNMENT
    1198     66810056 :       && crtl->stack_alignment_estimated < align
    1199       351106 :       && !crtl->stack_realign_processed)
    1200              :     {
    1201       350031 :       unsigned int min_align = MINIMUM_ALIGNMENT (NULL, mode, align);
    1202       350031 :       if (crtl->stack_alignment_estimated < min_align)
    1203       350031 :         crtl->stack_alignment_estimated = min_align;
    1204              :     }
    1205              : 
    1206     66810056 :   if (generating_concat_p
    1207     50349032 :       && (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
    1208     50349032 :           || GET_MODE_CLASS (mode) == MODE_COMPLEX_INT))
    1209              :     {
    1210              :       /* For complex modes, don't make a single pseudo.
    1211              :          Instead, make a CONCAT of two pseudos.
    1212              :          This allows noncontiguous allocation of the real and imaginary parts,
    1213              :          which makes much better code.  Besides, allocating DCmode
    1214              :          pseudos overstrains reload on some machines like the 386.  */
    1215       205843 :       rtx realpart, imagpart;
    1216       205843 :       machine_mode partmode = GET_MODE_INNER (mode);
    1217              : 
    1218       205843 :       realpart = gen_reg_rtx (partmode);
    1219       205843 :       imagpart = gen_reg_rtx (partmode);
    1220       205843 :       return gen_rtx_CONCAT (mode, realpart, imagpart);
    1221              :     }
    1222              : 
    1223              :   /* Do not call gen_reg_rtx with uninitialized crtl.  */
    1224     66604213 :   gcc_assert (crtl->emit.regno_pointer_align_length);
    1225              : 
    1226     66604213 :   crtl->emit.ensure_regno_capacity ();
    1227     66604213 :   gcc_assert (reg_rtx_no < crtl->emit.regno_pointer_align_length);
    1228              : 
    1229     66604213 :   val = gen_raw_REG (mode, reg_rtx_no);
    1230     66604213 :   regno_reg_rtx[reg_rtx_no++] = val;
    1231     66604213 :   return val;
    1232              : }
    1233              : 
    1234              : /* Make sure m_regno_pointer_align, and regno_reg_rtx are large
    1235              :    enough to have elements in the range 0 <= idx <= reg_rtx_no.  */
    1236              : 
    1237              : void
    1238     66605439 : emit_status::ensure_regno_capacity ()
    1239              : {
    1240     66605439 :   int old_size = regno_pointer_align_length;
    1241              : 
    1242     66605439 :   if (reg_rtx_no < old_size)
    1243              :     return;
    1244              : 
    1245       174990 :   int new_size = old_size * 2;
    1246       174990 :   while (reg_rtx_no >= new_size)
    1247            0 :     new_size *= 2;
    1248              : 
    1249       174990 :   char *tmp = XRESIZEVEC (char, regno_pointer_align, new_size);
    1250       174990 :   memset (tmp + old_size, 0, new_size - old_size);
    1251       174990 :   regno_pointer_align = (unsigned char *) tmp;
    1252              : 
    1253       174990 :   rtx *new1 = GGC_RESIZEVEC (rtx, regno_reg_rtx, new_size);
    1254       174990 :   memset (new1 + old_size, 0, (new_size - old_size) * sizeof (rtx));
    1255       174990 :   regno_reg_rtx = new1;
    1256              : 
    1257       174990 :   crtl->emit.regno_pointer_align_length = new_size;
    1258              : }
    1259              : 
    1260              : /* Return TRUE if REG is a PARM_DECL, FALSE otherwise.  */
    1261              : 
    1262              : bool
    1263        10721 : reg_is_parm_p (rtx reg)
    1264              : {
    1265        10721 :   tree decl;
    1266              : 
    1267        10721 :   gcc_assert (REG_P (reg));
    1268        10721 :   decl = REG_EXPR (reg);
    1269         8275 :   return (decl && TREE_CODE (decl) == PARM_DECL);
    1270              : }
    1271              : 
    1272              : /* Update NEW with the same attributes as REG, but with OFFSET added
    1273              :    to the REG_OFFSET.  */
    1274              : 
    1275              : static void
    1276     18024142 : update_reg_offset (rtx new_rtx, rtx reg, poly_int64 offset)
    1277              : {
    1278     18024142 :   REG_ATTRS (new_rtx) = get_reg_attrs (REG_EXPR (reg),
    1279     18024142 :                                        REG_OFFSET (reg) + offset);
    1280     18024142 : }
    1281              : 
    1282              : /* Generate a register with same attributes as REG, but with OFFSET
    1283              :    added to the REG_OFFSET.  */
    1284              : 
    1285              : rtx
    1286     10618899 : gen_rtx_REG_offset (rtx reg, machine_mode mode, unsigned int regno,
    1287              :                     poly_int64 offset)
    1288              : {
    1289              :   /* Use gen_raw_REG rather than gen_rtx_REG, because otherwise we'd
    1290              :      overwrite REG_ATTRS (and in the callers often ORIGINAL_REGNO too)
    1291              :      of the shared REG rtxes like stack_pointer_rtx etc.  This should
    1292              :      happen only for SUBREGs from DEBUG_INSNs, RA should ensure
    1293              :      multi-word registers don't overlap the special registers like
    1294              :      stack pointer.  */
    1295     10618899 :   rtx new_rtx = gen_raw_REG (mode, regno);
    1296              : 
    1297     10618899 :   update_reg_offset (new_rtx, reg, offset);
    1298     10618899 :   return new_rtx;
    1299              : }
    1300              : 
    1301              : /* Generate a new pseudo-register with the same attributes as REG, but
    1302              :    with OFFSET added to the REG_OFFSET.  */
    1303              : 
    1304              : rtx
    1305       606836 : gen_reg_rtx_offset (rtx reg, machine_mode mode, int offset)
    1306              : {
    1307       606836 :   rtx new_rtx = gen_reg_rtx (mode);
    1308              : 
    1309       606836 :   update_reg_offset (new_rtx, reg, offset);
    1310       606836 :   return new_rtx;
    1311              : }
    1312              : 
    1313              : /* Adjust REG in-place so that it has mode MODE.  It is assumed that the
    1314              :    new register is a (possibly paradoxical) lowpart of the old one.  */
    1315              : 
    1316              : void
    1317      2858283 : adjust_reg_mode (rtx reg, machine_mode mode)
    1318              : {
    1319      2858283 :   update_reg_offset (reg, reg, byte_lowpart_offset (mode, GET_MODE (reg)));
    1320      2858283 :   PUT_MODE (reg, mode);
    1321      2858283 : }
    1322              : 
    1323              : /* Copy REG's attributes from X, if X has any attributes.  If REG and X
    1324              :    have different modes, REG is a (possibly paradoxical) lowpart of X.  */
    1325              : 
    1326              : void
    1327     72886801 : set_reg_attrs_from_value (rtx reg, rtx x)
    1328              : {
    1329     72886801 :   poly_int64 offset;
    1330     72886801 :   bool can_be_reg_pointer = true;
    1331              : 
    1332              :   /* Don't call mark_reg_pointer for incompatible pointer sign
    1333              :      extension.  */
    1334     72886801 :   while (GET_CODE (x) == SIGN_EXTEND
    1335              :          || GET_CODE (x) == ZERO_EXTEND
    1336     73821181 :          || GET_CODE (x) == TRUNCATE
    1337     73821181 :          || (GET_CODE (x) == SUBREG && subreg_lowpart_p (x)))
    1338              :     {
    1339              : #if defined(POINTERS_EXTEND_UNSIGNED)
    1340       934380 :       if (((GET_CODE (x) == SIGN_EXTEND && POINTERS_EXTEND_UNSIGNED)
    1341              :            || (GET_CODE (x) == ZERO_EXTEND && ! POINTERS_EXTEND_UNSIGNED)
    1342       373059 :            || (paradoxical_subreg_p (x)
    1343        18395 :                && ! (SUBREG_PROMOTED_VAR_P (x)
    1344            0 :                      && SUBREG_CHECK_PROMOTED_SIGN (x,
    1345              :                                                     POINTERS_EXTEND_UNSIGNED))))
    1346       952775 :           && !targetm.have_ptr_extend ())
    1347              :         can_be_reg_pointer = false;
    1348              : #endif
    1349       934380 :       x = XEXP (x, 0);
    1350              :     }
    1351              : 
    1352              :   /* Hard registers can be reused for multiple purposes within the same
    1353              :      function, so setting REG_ATTRS, REG_POINTER and REG_POINTER_ALIGN
    1354              :      on them is wrong.  */
    1355     72886801 :   if (HARD_REGISTER_P (reg))
    1356     47261172 :     return;
    1357              : 
    1358     25625629 :   offset = byte_lowpart_offset (GET_MODE (reg), GET_MODE (x));
    1359     25625629 :   if (MEM_P (x))
    1360              :     {
    1361      5699911 :       if (MEM_OFFSET_KNOWN_P (x))
    1362      2623986 :         REG_ATTRS (reg) = get_reg_attrs (MEM_EXPR (x),
    1363      2623986 :                                          MEM_OFFSET (x) + offset);
    1364      5173404 :       if (can_be_reg_pointer && MEM_POINTER (x))
    1365       632106 :         mark_reg_pointer (reg, 0);
    1366              :     }
    1367     20452225 :   else if (REG_P (x))
    1368              :     {
    1369      6570929 :       if (REG_ATTRS (x))
    1370      3940124 :         update_reg_offset (reg, x, offset);
    1371      6570929 :       if (can_be_reg_pointer && REG_POINTER (x))
    1372      1855887 :         mark_reg_pointer (reg, REGNO_POINTER_ALIGN (REGNO (x)));
    1373              :     }
    1374              : }
    1375              : 
    1376              : /* Generate a REG rtx for a new pseudo register, copying the mode
    1377              :    and attributes from X.  */
    1378              : 
    1379              : rtx
    1380       557241 : gen_reg_rtx_and_attrs (rtx x)
    1381              : {
    1382       557241 :   rtx reg = gen_reg_rtx (GET_MODE (x));
    1383       557241 :   set_reg_attrs_from_value (reg, x);
    1384       557241 :   return reg;
    1385              : }
    1386              : 
    1387              : /* Set the register attributes for registers contained in PARM_RTX.
    1388              :    Use needed values from memory attributes of MEM.  */
    1389              : 
    1390              : void
    1391       110273 : set_reg_attrs_for_parm (rtx parm_rtx, rtx mem)
    1392              : {
    1393       110273 :   if (REG_P (parm_rtx))
    1394       110273 :     set_reg_attrs_from_value (parm_rtx, mem);
    1395            0 :   else if (GET_CODE (parm_rtx) == PARALLEL)
    1396              :     {
    1397              :       /* Check for a NULL entry in the first slot, used to indicate that the
    1398              :          parameter goes both on the stack and in registers.  */
    1399            0 :       int i = XEXP (XVECEXP (parm_rtx, 0, 0), 0) ? 0 : 1;
    1400            0 :       for (; i < XVECLEN (parm_rtx, 0); i++)
    1401              :         {
    1402            0 :           rtx x = XVECEXP (parm_rtx, 0, i);
    1403            0 :           if (REG_P (XEXP (x, 0)))
    1404            0 :             REG_ATTRS (XEXP (x, 0))
    1405            0 :               = get_reg_attrs (MEM_EXPR (mem),
    1406            0 :                                INTVAL (XEXP (x, 1)));
    1407              :         }
    1408              :     }
    1409       110273 : }
    1410              : 
    1411              : /* Set the REG_ATTRS for registers in value X, given that X represents
    1412              :    decl T.  */
    1413              : 
    1414              : void
    1415     65941052 : set_reg_attrs_for_decl_rtl (tree t, rtx x)
    1416              : {
    1417     65941052 :   if (!t)
    1418              :     return;
    1419     65940856 :   tree tdecl = t;
    1420     65940856 :   if (GET_CODE (x) == SUBREG)
    1421              :     {
    1422          611 :       gcc_assert (subreg_lowpart_p (x));
    1423          611 :       x = SUBREG_REG (x);
    1424              :     }
    1425     65940856 :   if (REG_P (x))
    1426     43264302 :     REG_ATTRS (x)
    1427     43264302 :       = get_reg_attrs (t, byte_lowpart_offset (GET_MODE (x),
    1428     43264302 :                                                DECL_P (tdecl)
    1429     21312434 :                                                ? DECL_MODE (tdecl)
    1430     21951868 :                                                : TYPE_MODE (TREE_TYPE (tdecl))));
    1431     65940856 :   if (GET_CODE (x) == CONCAT)
    1432              :     {
    1433       210768 :       if (REG_P (XEXP (x, 0)))
    1434       210768 :         REG_ATTRS (XEXP (x, 0)) = get_reg_attrs (t, 0);
    1435       210768 :       if (REG_P (XEXP (x, 1)))
    1436       210768 :         REG_ATTRS (XEXP (x, 1))
    1437       421536 :           = get_reg_attrs (t, GET_MODE_UNIT_SIZE (GET_MODE (XEXP (x, 0))));
    1438              :     }
    1439     65940856 :   if (GET_CODE (x) == PARALLEL)
    1440              :     {
    1441        60117 :       int i, start;
    1442              : 
    1443              :       /* Check for a NULL entry, used to indicate that the parameter goes
    1444              :          both on the stack and in registers.  */
    1445        60117 :       if (XEXP (XVECEXP (x, 0, 0), 0))
    1446              :         start = 0;
    1447              :       else
    1448            0 :         start = 1;
    1449              : 
    1450       172366 :       for (i = start; i < XVECLEN (x, 0); i++)
    1451              :         {
    1452       112249 :           rtx y = XVECEXP (x, 0, i);
    1453       112249 :           if (REG_P (XEXP (y, 0)))
    1454       112249 :             REG_ATTRS (XEXP (y, 0)) = get_reg_attrs (t, INTVAL (XEXP (y, 1)));
    1455              :         }
    1456              :     }
    1457              : }
    1458              : 
    1459              : /* Assign the RTX X to declaration T.  */
    1460              : 
    1461              : void
    1462    608209241 : set_decl_rtl (tree t, rtx x)
    1463              : {
    1464    608209241 :   DECL_WRTL_CHECK (t)->decl_with_rtl.rtl = x;
    1465    608209241 :   if (x)
    1466     33413756 :     set_reg_attrs_for_decl_rtl (t, x);
    1467    608209241 : }
    1468              : 
    1469              : /* Assign the RTX X to parameter declaration T.  BY_REFERENCE_P is true
    1470              :    if the ABI requires the parameter to be passed by reference.  */
    1471              : 
    1472              : void
    1473      3208126 : set_decl_incoming_rtl (tree t, rtx x, bool by_reference_p)
    1474              : {
    1475      3208126 :   DECL_INCOMING_RTL (t) = x;
    1476      3208126 :   if (x && !by_reference_p)
    1477      3203164 :     set_reg_attrs_for_decl_rtl (t, x);
    1478      3208126 : }
    1479              : 
    1480              : /* Identify REG (which may be a CONCAT) as a user register.  */
    1481              : 
    1482              : void
    1483      6234860 : mark_user_reg (rtx reg)
    1484              : {
    1485      6234860 :   if (GET_CODE (reg) == CONCAT)
    1486              :     {
    1487         3583 :       REG_USERVAR_P (XEXP (reg, 0)) = 1;
    1488         3583 :       REG_USERVAR_P (XEXP (reg, 1)) = 1;
    1489              :     }
    1490              :   else
    1491              :     {
    1492      6231277 :       gcc_assert (REG_P (reg));
    1493      6231277 :       REG_USERVAR_P (reg) = 1;
    1494              :     }
    1495      6234860 : }
    1496              : 
    1497              : /* Identify REG as a probable pointer register and show its alignment
    1498              :    as ALIGN, if nonzero.  */
    1499              : 
    1500              : void
    1501     16818533 : mark_reg_pointer (rtx reg, int align)
    1502              : {
    1503     16818533 :   if (! REG_POINTER (reg))
    1504              :     {
    1505     10672327 :       REG_POINTER (reg) = 1;
    1506              : 
    1507     10672327 :       if (align)
    1508      9263545 :         REGNO_POINTER_ALIGN (REGNO (reg)) = align;
    1509              :     }
    1510      6146206 :   else if (align && align < REGNO_POINTER_ALIGN (REGNO (reg)))
    1511              :     /* We can no-longer be sure just how aligned this pointer is.  */
    1512      1289587 :     REGNO_POINTER_ALIGN (REGNO (reg)) = align;
    1513     16818533 : }
    1514              : 
    1515              : /* Return 1 plus largest pseudo reg number used in the current function.  */
    1516              : 
    1517              : int
    1518   6919987492 : max_reg_num (void)
    1519              : {
    1520   6919987492 :   return reg_rtx_no;
    1521              : }
    1522              : 
    1523              : /* Return 1 + the largest label number used so far in the current function.  */
    1524              : 
    1525              : int
    1526      4029567 : max_label_num (void)
    1527              : {
    1528      4029567 :   return label_num;
    1529              : }
    1530              : 
    1531              : /* Return first label number used in this function (if any were used).  */
    1532              : 
    1533              : int
    1534      2539422 : get_first_label_num (void)
    1535              : {
    1536      2539422 :   return first_label_num;
    1537              : }
    1538              : 
    1539              : /* If the rtx for label was created during the expansion of a nested
    1540              :    function, then first_label_num won't include this label number.
    1541              :    Fix this now so that array indices work later.  */
    1542              : 
    1543              : void
    1544        26845 : maybe_set_first_label_num (rtx_code_label *x)
    1545              : {
    1546        26845 :   if (CODE_LABEL_NUMBER (x) < first_label_num)
    1547          389 :     first_label_num = CODE_LABEL_NUMBER (x);
    1548        26845 : }
    1549              : 
    1550              : /* For use by the RTL function loader, when mingling with normal
    1551              :    functions.
    1552              :    Ensure that label_num is greater than the label num of X, to avoid
    1553              :    duplicate labels in the generated assembler.  */
    1554              : 
    1555              : void
    1556           28 : maybe_set_max_label_num (rtx_code_label *x)
    1557              : {
    1558           28 :   if (CODE_LABEL_NUMBER (x) >= label_num)
    1559           24 :     label_num = CODE_LABEL_NUMBER (x) + 1;
    1560           28 : }
    1561              : 
    1562              : 
    1563              : /* Return a value representing some low-order bits of X, where the number
    1564              :    of low-order bits is given by MODE.  Note that no conversion is done
    1565              :    between floating-point and fixed-point values, rather, the bit
    1566              :    representation is returned.
    1567              : 
    1568              :    This function handles the cases in common between gen_lowpart, below,
    1569              :    and two variants in cse.cc and combine.cc.  These are the cases that can
    1570              :    be safely handled at all points in the compilation.
    1571              : 
    1572              :    If this is not a case we can handle, return 0.  */
    1573              : 
    1574              : rtx
    1575     51253624 : gen_lowpart_common (machine_mode mode, rtx x)
    1576              : {
    1577    102526984 :   poly_uint64 msize = GET_MODE_SIZE (mode);
    1578     51263492 :   machine_mode innermode;
    1579              : 
    1580              :   /* Unfortunately, this routine doesn't take a parameter for the mode of X,
    1581              :      so we have to make one up.  Yuk.  */
    1582     51263492 :   innermode = GET_MODE (x);
    1583     51263492 :   if (CONST_INT_P (x)
    1584     51263492 :       && known_le (msize * BITS_PER_UNIT,
    1585              :                    (unsigned HOST_WIDE_INT) HOST_BITS_PER_WIDE_INT))
    1586     15759171 :     innermode = int_mode_for_size (HOST_BITS_PER_WIDE_INT, 0).require ();
    1587     35504321 :   else if (innermode == VOIDmode)
    1588       192882 :     innermode = int_mode_for_size (HOST_BITS_PER_DOUBLE_INT, 0).require ();
    1589              : 
    1590     51263492 :   gcc_assert (innermode != VOIDmode && innermode != BLKmode);
    1591              : 
    1592     51263492 :   if (innermode == mode)
    1593              :     return x;
    1594              : 
    1595              :   /* The size of the outer and inner modes must be ordered.  */
    1596     58719982 :   poly_uint64 xsize = GET_MODE_SIZE (innermode);
    1597     29359991 :   if (!ordered_p (msize, xsize))
    1598              :     return 0;
    1599              : 
    1600     29359991 :   if (SCALAR_FLOAT_MODE_P (mode))
    1601              :     {
    1602              :       /* Don't allow paradoxical FLOAT_MODE subregs.  */
    1603       262975 :       if (maybe_gt (msize, xsize))
    1604              :         return 0;
    1605              :     }
    1606              :   else
    1607              :     {
    1608              :       /* MODE must occupy no more of the underlying registers than X.  */
    1609     29097016 :       poly_uint64 regsize = REGMODE_NATURAL_SIZE (innermode);
    1610     29097016 :       unsigned int mregs, xregs;
    1611     45834174 :       if (!can_div_away_from_zero_p (msize, regsize, &mregs)
    1612     29097016 :           || !can_div_away_from_zero_p (xsize, regsize, &xregs)
    1613     29097016 :           || mregs > xregs)
    1614      9279464 :         return 0;
    1615              :     }
    1616              : 
    1617     29358606 :   scalar_int_mode int_mode, int_innermode, from_mode;
    1618     29358606 :   if ((GET_CODE (x) == ZERO_EXTEND || GET_CODE (x) == SIGN_EXTEND)
    1619       155391 :       && is_a <scalar_int_mode> (mode, &int_mode)
    1620     29358606 :       && is_a <scalar_int_mode> (innermode, &int_innermode)
    1621     29513945 :       && is_a <scalar_int_mode> (GET_MODE (XEXP (x, 0)), &from_mode))
    1622              :     {
    1623              :       /* If we are getting the low-order part of something that has been
    1624              :          sign- or zero-extended, we can either just use the object being
    1625              :          extended or make a narrower extension.  If we want an even smaller
    1626              :          piece than the size of the object being extended, call ourselves
    1627              :          recursively.
    1628              : 
    1629              :          This case is used mostly by combine and cse.  */
    1630              : 
    1631       155339 :       if (from_mode == int_mode)
    1632              :         return XEXP (x, 0);
    1633        39249 :       else if (GET_MODE_SIZE (int_mode) < GET_MODE_SIZE (from_mode))
    1634              :         return gen_lowpart_common (int_mode, XEXP (x, 0));
    1635         9645 :       else if (GET_MODE_SIZE (int_mode) < GET_MODE_SIZE (int_innermode))
    1636         2956 :         return gen_rtx_fmt_e (GET_CODE (x), int_mode, XEXP (x, 0));
    1637              :     }
    1638     29203267 :   else if (GET_CODE (x) == SUBREG || REG_P (x)
    1639              :            || GET_CODE (x) == CONCAT || GET_CODE (x) == CONST_VECTOR
    1640     16392814 :            || CONST_DOUBLE_AS_FLOAT_P (x) || CONST_SCALAR_INT_P (x)
    1641              :            || CONST_POLY_INT_P (x))
    1642     19925447 :     return lowpart_subreg (mode, x, innermode);
    1643              : 
    1644              :   /* Otherwise, we can't do this.  */
    1645              :   return 0;
    1646              : }
    1647              : 
    1648              : rtx
    1649         8933 : gen_highpart (machine_mode mode, rtx x)
    1650              : {
    1651        17866 :   poly_uint64 msize = GET_MODE_SIZE (mode);
    1652         8933 :   rtx result;
    1653              : 
    1654              :   /* This case loses if X is a subreg.  To catch bugs early,
    1655              :      complain if an invalid MODE is used even in other cases.  */
    1656        10667 :   gcc_assert (known_le (msize, (unsigned int) UNITS_PER_WORD)
    1657              :               || known_eq (msize, GET_MODE_UNIT_SIZE (GET_MODE (x))));
    1658              : 
    1659              :   /* gen_lowpart_common handles a lot of special cases due to needing to handle
    1660              :      paradoxical subregs; it only calls simplify_gen_subreg when certain that
    1661              :      it will produce something meaningful.  The only case we need to handle
    1662              :      specially here is MEM.  */
    1663         8933 :   if (MEM_P (x))
    1664              :     {
    1665          137 :       poly_int64 offset = subreg_highpart_offset (mode, GET_MODE (x));
    1666          137 :       return adjust_address (x, mode, offset);
    1667              :     }
    1668              : 
    1669         8796 :   result = simplify_gen_subreg (mode, x, GET_MODE (x),
    1670         8796 :                                 subreg_highpart_offset (mode, GET_MODE (x)));
    1671              :   /* Since we handle MEM directly above, we should never get a MEM back
    1672              :      from simplify_gen_subreg.  */
    1673         8796 :   gcc_assert (result && !MEM_P (result));
    1674              : 
    1675              :   return result;
    1676              : }
    1677              : 
    1678              : /* Like gen_highpart, but accept mode of EXP operand in case EXP can
    1679              :    be VOIDmode constant.  */
    1680              : rtx
    1681            0 : gen_highpart_mode (machine_mode outermode, machine_mode innermode, rtx exp)
    1682              : {
    1683            0 :   if (GET_MODE (exp) != VOIDmode)
    1684              :     {
    1685            0 :       gcc_assert (GET_MODE (exp) == innermode);
    1686            0 :       return gen_highpart (outermode, exp);
    1687              :     }
    1688            0 :   return simplify_gen_subreg (outermode, exp, innermode,
    1689            0 :                               subreg_highpart_offset (outermode, innermode));
    1690              : }
    1691              : 
    1692              : /* Return the SUBREG_BYTE for a lowpart subreg whose outer mode has
    1693              :    OUTER_BYTES bytes and whose inner mode has INNER_BYTES bytes.  */
    1694              : 
    1695              : poly_uint64
    1696    224108701 : subreg_size_lowpart_offset (poly_uint64 outer_bytes, poly_uint64 inner_bytes)
    1697              : {
    1698    224108701 :   gcc_checking_assert (ordered_p (outer_bytes, inner_bytes));
    1699    224108701 :   if (maybe_gt (outer_bytes, inner_bytes))
    1700              :     /* Paradoxical subregs always have a SUBREG_BYTE of 0.  */
    1701     50154246 :     return 0;
    1702              : 
    1703    173954455 :   if (BYTES_BIG_ENDIAN && WORDS_BIG_ENDIAN)
    1704              :     return inner_bytes - outer_bytes;
    1705    173954455 :   else if (!BYTES_BIG_ENDIAN && !WORDS_BIG_ENDIAN)
    1706    173954455 :     return 0;
    1707              :   else
    1708              :     return subreg_size_offset_from_lsb (outer_bytes, inner_bytes, 0);
    1709              : }
    1710              : 
    1711              : /* Return the SUBREG_BYTE for a highpart subreg whose outer mode has
    1712              :    OUTER_BYTES bytes and whose inner mode has INNER_BYTES bytes.  */
    1713              : 
    1714              : poly_uint64
    1715        43196 : subreg_size_highpart_offset (poly_uint64 outer_bytes, poly_uint64 inner_bytes)
    1716              : {
    1717        43196 :   gcc_assert (known_ge (inner_bytes, outer_bytes));
    1718              : 
    1719              :   if (BYTES_BIG_ENDIAN && WORDS_BIG_ENDIAN)
    1720              :     return 0;
    1721              :   else if (!BYTES_BIG_ENDIAN && !WORDS_BIG_ENDIAN)
    1722        43196 :     return inner_bytes - outer_bytes;
    1723              :   else
    1724              :     return subreg_size_offset_from_lsb (outer_bytes, inner_bytes,
    1725              :                                         (inner_bytes - outer_bytes)
    1726              :                                         * BITS_PER_UNIT);
    1727              : }
    1728              : 
    1729              : /* Return true iff X, assumed to be a SUBREG,
    1730              :    refers to the least significant part of its containing reg.
    1731              :    If X is not a SUBREG, always return true (it is its own low part!).  */
    1732              : 
    1733              : bool
    1734     52182948 : subreg_lowpart_p (const_rtx x)
    1735              : {
    1736     52182948 :   if (GET_CODE (x) != SUBREG)
    1737              :     return true;
    1738     52182948 :   else if (GET_MODE (SUBREG_REG (x)) == VOIDmode)
    1739              :     return false;
    1740              : 
    1741     52182948 :   return known_eq (subreg_lowpart_offset (GET_MODE (x),
    1742              :                                           GET_MODE (SUBREG_REG (x))),
    1743              :                    SUBREG_BYTE (x));
    1744              : }
    1745              : 
    1746              : /* Return subword OFFSET of operand OP.
    1747              :    The word number, OFFSET, is interpreted as the word number starting
    1748              :    at the low-order address.  OFFSET 0 is the low-order word if not
    1749              :    WORDS_BIG_ENDIAN, otherwise it is the high-order word.
    1750              : 
    1751              :    If we cannot extract the required word, we return zero.  Otherwise,
    1752              :    an rtx corresponding to the requested word will be returned.
    1753              : 
    1754              :    VALIDATE_ADDRESS is nonzero if the address should be validated.  Before
    1755              :    reload has completed, a valid address will always be returned.  After
    1756              :    reload, if a valid address cannot be returned, we return zero.
    1757              : 
    1758              :    If VALIDATE_ADDRESS is zero, we simply form the required address; validating
    1759              :    it is the responsibility of the caller.
    1760              : 
    1761              :    MODE is the mode of OP in case it is a CONST_INT.
    1762              : 
    1763              :    ??? This is still rather broken for some cases.  The problem for the
    1764              :    moment is that all callers of this thing provide no 'goal mode' to
    1765              :    tell us to work with.  This exists because all callers were written
    1766              :    in a word based SUBREG world.
    1767              :    Now use of this function can be deprecated by simplify_subreg in most
    1768              :    cases.
    1769              :  */
    1770              : 
    1771              : rtx
    1772        82178 : operand_subword (rtx op, poly_uint64 offset, int validate_address,
    1773              :                  machine_mode mode)
    1774              : {
    1775        82178 :   if (mode == VOIDmode)
    1776         3024 :     mode = GET_MODE (op);
    1777              : 
    1778         3024 :   gcc_assert (mode != VOIDmode);
    1779              : 
    1780              :   /* If OP is narrower than a word, fail.  */
    1781        82178 :   if (mode != BLKmode
    1782       176855 :       && maybe_lt (GET_MODE_SIZE (mode), UNITS_PER_WORD))
    1783              :     return 0;
    1784              : 
    1785              :   /* If we want a word outside OP, return zero.  */
    1786        82178 :   if (mode != BLKmode
    1787       176855 :       && maybe_gt ((offset + 1) * UNITS_PER_WORD, GET_MODE_SIZE (mode)))
    1788            0 :     return const0_rtx;
    1789              : 
    1790              :   /* Form a new MEM at the requested address.  */
    1791        82178 :   if (MEM_P (op))
    1792              :     {
    1793        10821 :       rtx new_rtx = adjust_address_nv (op, word_mode, offset * UNITS_PER_WORD);
    1794              : 
    1795         9613 :       if (! validate_address)
    1796              :         return new_rtx;
    1797              : 
    1798         9613 :       else if (reload_completed)
    1799              :         {
    1800            0 :           if (! strict_memory_address_addr_space_p (word_mode,
    1801              :                                                     XEXP (new_rtx, 0),
    1802            0 :                                                     MEM_ADDR_SPACE (op)))
    1803              :             return 0;
    1804              :         }
    1805              :       else
    1806         9613 :         return replace_equiv_address (new_rtx, XEXP (new_rtx, 0));
    1807              :     }
    1808              : 
    1809              :   /* Rest can be handled by simplify_subreg.  */
    1810        86967 :   return simplify_gen_subreg (word_mode, op, mode, (offset * UNITS_PER_WORD));
    1811              : }
    1812              : 
    1813              : /* Similar to `operand_subword', but never return 0.  If we can't
    1814              :    extract the required subword, put OP into a register and try again.
    1815              :    The second attempt must succeed.  We always validate the address in
    1816              :    this case.
    1817              : 
    1818              :    MODE is the mode of OP, in case it is CONST_INT.  */
    1819              : 
    1820              : rtx
    1821        61908 : operand_subword_force (rtx op, poly_uint64 offset, machine_mode mode)
    1822              : {
    1823        61908 :   rtx result = operand_subword (op, offset, 1, mode);
    1824              : 
    1825        61908 :   if (result)
    1826              :     return result;
    1827              : 
    1828            0 :   if (mode != BLKmode && mode != VOIDmode)
    1829              :     {
    1830              :       /* If this is a register which cannot be accessed by words, copy it
    1831              :          to a pseudo register.  */
    1832            0 :       if (REG_P (op))
    1833            0 :         op = copy_to_reg (op);
    1834              :       else
    1835            0 :         op = force_reg (mode, op);
    1836              :     }
    1837              : 
    1838            0 :   result = operand_subword (op, offset, 1, mode);
    1839            0 :   gcc_assert (result);
    1840              : 
    1841              :   return result;
    1842              : }
    1843              : 
    1844     30997482 : mem_attrs::mem_attrs ()
    1845     30997482 :   : expr (NULL_TREE),
    1846     30997482 :     offset (0),
    1847     30997482 :     size (0),
    1848     30997482 :     alias (0),
    1849     30997482 :     align (0),
    1850     30997482 :     addrspace (ADDR_SPACE_GENERIC),
    1851     30997482 :     offset_known_p (false),
    1852     30997482 :     size_known_p (false)
    1853     30997482 : {}
    1854              : 
    1855              : /* Returns true if both MEM_EXPR can be considered equal
    1856              :    and false otherwise.  */
    1857              : 
    1858              : bool
    1859        43340 : mem_expr_equal_p (const_tree expr1, const_tree expr2)
    1860              : {
    1861        43340 :   if (expr1 == expr2)
    1862              :     return true;
    1863              : 
    1864        42570 :   if (! expr1 || ! expr2)
    1865              :     return false;
    1866              : 
    1867        33076 :   if (TREE_CODE (expr1) != TREE_CODE (expr2))
    1868              :     return false;
    1869              : 
    1870        31442 :   return operand_equal_p (expr1, expr2, 0);
    1871              : }
    1872              : 
    1873              : /* Return OFFSET if XEXP (MEM, 0) - OFFSET is known to be ALIGN
    1874              :    bits aligned for 0 <= OFFSET < ALIGN / BITS_PER_UNIT, or
    1875              :    -1 if not known.  */
    1876              : 
    1877              : int
    1878           20 : get_mem_align_offset (rtx mem, unsigned int align)
    1879              : {
    1880           20 :   tree expr;
    1881           20 :   poly_uint64 offset;
    1882              : 
    1883              :   /* This function can't use
    1884              :      if (!MEM_EXPR (mem) || !MEM_OFFSET_KNOWN_P (mem)
    1885              :          || (MAX (MEM_ALIGN (mem),
    1886              :                   MAX (align, get_object_alignment (MEM_EXPR (mem))))
    1887              :              < align))
    1888              :        return -1;
    1889              :      else
    1890              :        return (- MEM_OFFSET (mem)) & (align / BITS_PER_UNIT - 1);
    1891              :      for two reasons:
    1892              :      - COMPONENT_REFs in MEM_EXPR can have NULL first operand,
    1893              :        for <variable>.  get_inner_reference doesn't handle it and
    1894              :        even if it did, the alignment in that case needs to be determined
    1895              :        from DECL_FIELD_CONTEXT's TYPE_ALIGN.
    1896              :      - it would do suboptimal job for COMPONENT_REFs, even if MEM_EXPR
    1897              :        isn't sufficiently aligned, the object it is in might be.  */
    1898           20 :   gcc_assert (MEM_P (mem));
    1899           20 :   expr = MEM_EXPR (mem);
    1900           20 :   if (expr == NULL_TREE || !MEM_OFFSET_KNOWN_P (mem))
    1901              :     return -1;
    1902              : 
    1903           19 :   offset = MEM_OFFSET (mem);
    1904           19 :   if (DECL_P (expr))
    1905              :     {
    1906            2 :       if (DECL_ALIGN (expr) < align)
    1907              :         return -1;
    1908              :     }
    1909           17 :   else if (INDIRECT_REF_P (expr))
    1910              :     {
    1911            0 :       if (TYPE_ALIGN (TREE_TYPE (expr)) < (unsigned int) align)
    1912              :         return -1;
    1913              :     }
    1914           17 :   else if (TREE_CODE (expr) == COMPONENT_REF)
    1915              :     {
    1916            0 :       while (1)
    1917              :         {
    1918            0 :           tree inner = TREE_OPERAND (expr, 0);
    1919            0 :           tree field = TREE_OPERAND (expr, 1);
    1920            0 :           tree byte_offset = component_ref_field_offset (expr);
    1921            0 :           tree bit_offset = DECL_FIELD_BIT_OFFSET (field);
    1922              : 
    1923            0 :           poly_uint64 suboffset;
    1924            0 :           if (!byte_offset
    1925            0 :               || !poly_int_tree_p (byte_offset, &suboffset)
    1926            0 :               || !tree_fits_uhwi_p (bit_offset))
    1927            0 :             return -1;
    1928              : 
    1929            0 :           offset += suboffset;
    1930            0 :           offset += tree_to_uhwi (bit_offset) / BITS_PER_UNIT;
    1931              : 
    1932            0 :           if (inner == NULL_TREE)
    1933              :             {
    1934            0 :               if (TYPE_ALIGN (DECL_FIELD_CONTEXT (field))
    1935              :                   < (unsigned int) align)
    1936              :                 return -1;
    1937            0 :               break;
    1938              :             }
    1939            0 :           else if (DECL_P (inner))
    1940              :             {
    1941            0 :               if (DECL_ALIGN (inner) < align)
    1942              :                 return -1;
    1943              :               break;
    1944              :             }
    1945            0 :           else if (TREE_CODE (inner) != COMPONENT_REF)
    1946              :             return -1;
    1947            0 :           expr = inner;
    1948            0 :         }
    1949              :     }
    1950              :   else
    1951              :     return -1;
    1952              : 
    1953            0 :   HOST_WIDE_INT misalign;
    1954            0 :   if (!known_misalignment (offset, align / BITS_PER_UNIT, &misalign))
    1955              :     return -1;
    1956            0 :   return misalign;
    1957              : }
    1958              : 
    1959              : /* Given REF (a MEM) and T, either the type of X or the expression
    1960              :    corresponding to REF, set the memory attributes.  OBJECTP is nonzero
    1961              :    if we are making a new object of this type.  BITPOS is nonzero if
    1962              :    there is an offset outstanding on T that will be applied later.  */
    1963              : 
    1964              : void
    1965     30997482 : set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
    1966              :                                  poly_int64 bitpos)
    1967              : {
    1968     30997482 :   poly_int64 apply_bitpos = 0;
    1969     30997482 :   tree type;
    1970     30997482 :   class mem_attrs attrs, *defattrs, *refattrs;
    1971     30997482 :   addr_space_t as;
    1972              : 
    1973              :   /* It can happen that type_for_mode was given a mode for which there
    1974              :      is no language-level type.  In which case it returns NULL, which
    1975              :      we can see here.  */
    1976     30997482 :   if (t == NULL_TREE)
    1977            0 :     return;
    1978              : 
    1979     30997482 :   type = TYPE_P (t) ? t : TREE_TYPE (t);
    1980     30997482 :   if (type == error_mark_node)
    1981              :     return;
    1982              : 
    1983              :   /* If we have already set DECL_RTL = ref, get_alias_set will get the
    1984              :      wrong answer, as it assumes that DECL_RTL already has the right alias
    1985              :      info.  Callers should not set DECL_RTL until after the call to
    1986              :      set_mem_attributes.  */
    1987     30997482 :   gcc_assert (!DECL_P (t) || ref != DECL_RTL_IF_SET (t));
    1988              : 
    1989              :   /* Get the alias set from the expression or type (perhaps using a
    1990              :      front-end routine) and use it.  */
    1991     30997482 :   attrs.alias = get_alias_set (t);
    1992              : 
    1993     30997482 :   MEM_VOLATILE_P (ref) |= TYPE_VOLATILE (type);
    1994     30997482 :   MEM_POINTER (ref) = POINTER_TYPE_P (type);
    1995              : 
    1996              :   /* Default values from pre-existing memory attributes if present.  */
    1997     30997482 :   refattrs = MEM_ATTRS (ref);
    1998     30997482 :   if (refattrs)
    1999              :     {
    2000              :       /* ??? Can this ever happen?  Calling this routine on a MEM that
    2001              :          already carries memory attributes should probably be invalid.  */
    2002     12360444 :       attrs.expr = refattrs->expr;
    2003     12360444 :       attrs.offset_known_p = refattrs->offset_known_p;
    2004     12360444 :       attrs.offset = refattrs->offset;
    2005     12360444 :       attrs.size_known_p = refattrs->size_known_p;
    2006     12360444 :       attrs.size = refattrs->size;
    2007     12360444 :       attrs.align = refattrs->align;
    2008              :     }
    2009              : 
    2010              :   /* Otherwise, default values from the mode of the MEM reference.  */
    2011              :   else
    2012              :     {
    2013     18637038 :       defattrs = mode_mem_attrs[(int) GET_MODE (ref)];
    2014     18637038 :       gcc_assert (!defattrs->expr);
    2015     18637038 :       gcc_assert (!defattrs->offset_known_p);
    2016              : 
    2017              :       /* Respect mode size.  */
    2018     18637038 :       attrs.size_known_p = defattrs->size_known_p;
    2019     18637038 :       attrs.size = defattrs->size;
    2020              :       /* ??? Is this really necessary?  We probably should always get
    2021              :          the size from the type below.  */
    2022              : 
    2023              :       /* Respect mode alignment for STRICT_ALIGNMENT targets if T is a type;
    2024              :          if T is an object, always compute the object alignment below.  */
    2025     18637038 :       if (TYPE_P (t))
    2026      2036802 :         attrs.align = defattrs->align;
    2027              :       else
    2028     16600236 :         attrs.align = BITS_PER_UNIT;
    2029              :       /* ??? If T is a type, respecting mode alignment may *also* be wrong
    2030              :          e.g. if the type carries an alignment attribute.  Should we be
    2031              :          able to simply always use TYPE_ALIGN?  */
    2032              :     }
    2033              : 
    2034              :   /* We can set the alignment from the type if we are making an object or if
    2035              :      this is an INDIRECT_REF.  */
    2036     30997482 :   if (objectp || TREE_CODE (t) == INDIRECT_REF)
    2037      9874541 :     attrs.align = MAX (attrs.align, TYPE_ALIGN (type));
    2038              : 
    2039              :   /* If the size is known, we can set that.  */
    2040     30997482 :   tree new_size = TYPE_SIZE_UNIT (type);
    2041              : 
    2042              :   /* The address-space is that of the type.  */
    2043     30997482 :   as = TYPE_ADDR_SPACE (type);
    2044              : 
    2045              :   /* If T is not a type, we may be able to deduce some more information about
    2046              :      the expression.  */
    2047     30997482 :   if (! TYPE_P (t))
    2048              :     {
    2049     28954412 :       tree base;
    2050              : 
    2051     28954412 :       if (TREE_THIS_VOLATILE (t))
    2052       178121 :         MEM_VOLATILE_P (ref) = 1;
    2053              : 
    2054              :       /* Now remove any conversions: they don't change what the underlying
    2055              :          object is.  Likewise for SAVE_EXPR.  */
    2056     28959030 :       while (CONVERT_EXPR_P (t)
    2057              :              || TREE_CODE (t) == VIEW_CONVERT_EXPR
    2058     28959030 :              || TREE_CODE (t) == SAVE_EXPR)
    2059         4618 :         t = TREE_OPERAND (t, 0);
    2060              : 
    2061              :       /* Note whether this expression can trap.  */
    2062     28954412 :       MEM_NOTRAP_P (ref) = !tree_could_trap_p (t);
    2063              : 
    2064     28954412 :       base = get_base_address (t);
    2065     28954412 :       if (base)
    2066              :         {
    2067     28954412 :           if (DECL_P (base)
    2068     16860972 :               && TREE_READONLY (base)
    2069      2196809 :               && (TREE_STATIC (base) || DECL_EXTERNAL (base))
    2070     30819183 :               && !TREE_THIS_VOLATILE (base))
    2071      1864392 :             MEM_READONLY_P (ref) = 1;
    2072              : 
    2073              :           /* Mark static const strings readonly as well.  */
    2074     28954412 :           if (TREE_CODE (base) == STRING_CST
    2075       284632 :               && TREE_READONLY (base)
    2076     29214188 :               && TREE_STATIC (base))
    2077       259776 :             MEM_READONLY_P (ref) = 1;
    2078              : 
    2079              :           /* Address-space information is on the base object.  */
    2080     28954412 :           if (TREE_CODE (base) == MEM_REF
    2081     28954412 :               || TREE_CODE (base) == TARGET_MEM_REF)
    2082     11808796 :             as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (base,
    2083              :                                                                       0))));
    2084              :           else
    2085     17145616 :             as = TYPE_ADDR_SPACE (TREE_TYPE (base));
    2086              :         }
    2087              : 
    2088              :       /* If this expression uses it's parent's alias set, mark it such
    2089              :          that we won't change it.  */
    2090     28954412 :       if (component_uses_parent_alias_set_from (t) != NULL_TREE)
    2091      1093002 :         MEM_KEEP_ALIAS_SET_P (ref) = 1;
    2092              : 
    2093              :       /* If this is a decl, set the attributes of the MEM from it.  */
    2094     28954412 :       if (DECL_P (t))
    2095              :         {
    2096      7863814 :           attrs.expr = t;
    2097      7863814 :           attrs.offset_known_p = true;
    2098      7863814 :           attrs.offset = 0;
    2099      7863814 :           apply_bitpos = bitpos;
    2100      7863814 :           new_size = DECL_SIZE_UNIT (t);
    2101              :         }
    2102              : 
    2103              :       /* ???  If we end up with a constant or a descriptor do not
    2104              :          record a MEM_EXPR.  */
    2105     21090598 :       else if (CONSTANT_CLASS_P (t)
    2106     20992980 :                || TREE_CODE (t) == CONSTRUCTOR)
    2107              :         ;
    2108              : 
    2109              :       /* If this is a field reference, record it.  */
    2110     20992980 :       else if (TREE_CODE (t) == COMPONENT_REF)
    2111              :         {
    2112      9441698 :           attrs.expr = t;
    2113      9441698 :           attrs.offset_known_p = true;
    2114      9441698 :           attrs.offset = 0;
    2115      9441698 :           apply_bitpos = bitpos;
    2116      9441698 :           if (DECL_BIT_FIELD (TREE_OPERAND (t, 1)))
    2117        66079 :             new_size = DECL_SIZE_UNIT (TREE_OPERAND (t, 1));
    2118              :         }
    2119              : 
    2120              :       /* Else record it.  */
    2121              :       else
    2122              :         {
    2123     11551282 :           gcc_assert (handled_component_p (t)
    2124              :                       || TREE_CODE (t) == MEM_REF
    2125              :                       || TREE_CODE (t) == TARGET_MEM_REF);
    2126     11551282 :           attrs.expr = t;
    2127     11551282 :           attrs.offset_known_p = true;
    2128     11551282 :           attrs.offset = 0;
    2129     11551282 :           apply_bitpos = bitpos;
    2130              :         }
    2131              : 
    2132              :       /* If this is a reference based on a partitioned decl replace the
    2133              :          base with a MEM_REF of the pointer representative we created
    2134              :          during stack slot partitioning.  */
    2135     28954412 :       if (attrs.expr
    2136     28856794 :           && VAR_P (base)
    2137     13768288 :           && ! is_global_var (base)
    2138     37415563 :           && cfun->gimple_df->decls_to_pointers != NULL)
    2139              :         {
    2140      3823072 :           tree *namep = cfun->gimple_df->decls_to_pointers->get (base);
    2141      3823072 :           if (namep)
    2142              :             {
    2143      2219400 :               attrs.expr = unshare_expr (attrs.expr);
    2144      2219400 :               tree *orig_base = &attrs.expr;
    2145      4677695 :               while (handled_component_p (*orig_base))
    2146      2458295 :                 orig_base = &TREE_OPERAND (*orig_base, 0);
    2147      2219400 :               if (TREE_CODE (*orig_base) == MEM_REF
    2148      2219400 :                   || TREE_CODE (*orig_base) == TARGET_MEM_REF)
    2149       669766 :                 TREE_OPERAND (*orig_base, 0) = *namep;
    2150              :               else
    2151              :                 {
    2152      1549634 :                   tree aptrt = reference_alias_ptr_type (*orig_base);
    2153      1549634 :                   *orig_base = build2 (MEM_REF, TREE_TYPE (*orig_base),
    2154              :                                        *namep, build_int_cst (aptrt, 0));
    2155              :                 }
    2156              :             }
    2157              :         }
    2158              : 
    2159              :       /* Compute the alignment.  */
    2160     28954412 :       unsigned int obj_align;
    2161     28954412 :       unsigned HOST_WIDE_INT obj_bitpos;
    2162     28954412 :       get_object_alignment_1 (t, &obj_align, &obj_bitpos);
    2163     28954412 :       unsigned int diff_align = known_alignment (obj_bitpos - bitpos);
    2164     28954412 :       if (diff_align != 0)
    2165      3809544 :         obj_align = MIN (obj_align, diff_align);
    2166     28954412 :       attrs.align = MAX (attrs.align, obj_align);
    2167              :     }
    2168              : 
    2169     30997482 :   poly_uint64 const_size;
    2170     30997482 :   if (poly_int_tree_p (new_size, &const_size))
    2171              :     {
    2172     30409080 :       attrs.size_known_p = true;
    2173     30409080 :       attrs.size = const_size;
    2174              :     }
    2175              : 
    2176              :   /* If we modified OFFSET based on T, then subtract the outstanding
    2177              :      bit position offset.  Similarly, increase the size of the accessed
    2178              :      object to contain the negative offset.  */
    2179     30997482 :   if (maybe_ne (apply_bitpos, 0))
    2180              :     {
    2181      2721289 :       gcc_assert (attrs.offset_known_p);
    2182      2721289 :       poly_int64 bytepos = bits_to_bytes_round_down (apply_bitpos);
    2183      2721289 :       attrs.offset -= bytepos;
    2184      2721289 :       if (attrs.size_known_p)
    2185     30997482 :         attrs.size += bytepos;
    2186              :     }
    2187              : 
    2188              :   /* Now set the attributes we computed above.  */
    2189     30997482 :   attrs.addrspace = as;
    2190     30997482 :   set_mem_attrs (ref, &attrs);
    2191              : }
    2192              : 
    2193              : void
    2194     27001409 : set_mem_attributes (rtx ref, tree t, int objectp)
    2195              : {
    2196     27001409 :   set_mem_attributes_minus_bitpos (ref, t, objectp, 0);
    2197     27001409 : }
    2198              : 
    2199              : /* Set the alias set of MEM to SET.  */
    2200              : 
    2201              : void
    2202      7655063 : set_mem_alias_set (rtx mem, alias_set_type set)
    2203              : {
    2204              :   /* If the new and old alias sets don't conflict, something is wrong.  */
    2205     10745007 :   gcc_checking_assert (alias_sets_conflict_p (set, MEM_ALIAS_SET (mem)));
    2206      7655063 :   mem_attrs attrs (*get_mem_attrs (mem));
    2207      7655063 :   attrs.alias = set;
    2208      7655063 :   set_mem_attrs (mem, &attrs);
    2209      7655063 : }
    2210              : 
    2211              : /* Set the address space of MEM to ADDRSPACE (target-defined).  */
    2212              : 
    2213              : void
    2214      9806294 : set_mem_addr_space (rtx mem, addr_space_t addrspace)
    2215              : {
    2216      9806294 :   mem_attrs attrs (*get_mem_attrs (mem));
    2217      9806294 :   attrs.addrspace = addrspace;
    2218      9806294 :   set_mem_attrs (mem, &attrs);
    2219      9806294 : }
    2220              : 
    2221              : /* Set the alignment of MEM to ALIGN bits.  */
    2222              : 
    2223              : void
    2224     12655312 : set_mem_align (rtx mem, unsigned int align)
    2225              : {
    2226     12655312 :   mem_attrs attrs (*get_mem_attrs (mem));
    2227     12655312 :   attrs.align = align;
    2228     12655312 :   set_mem_attrs (mem, &attrs);
    2229     12655312 : }
    2230              : 
    2231              : /* Set the expr for MEM to EXPR.  */
    2232              : 
    2233              : void
    2234      6794383 : set_mem_expr (rtx mem, tree expr)
    2235              : {
    2236      6794383 :   mem_attrs attrs (*get_mem_attrs (mem));
    2237      6794383 :   attrs.expr = expr;
    2238      6794383 :   set_mem_attrs (mem, &attrs);
    2239      6794383 : }
    2240              : 
    2241              : /* Set the offset of MEM to OFFSET.  */
    2242              : 
    2243              : void
    2244          134 : set_mem_offset (rtx mem, poly_int64 offset)
    2245              : {
    2246          134 :   mem_attrs attrs (*get_mem_attrs (mem));
    2247          134 :   attrs.offset_known_p = true;
    2248          134 :   attrs.offset = offset;
    2249          134 :   set_mem_attrs (mem, &attrs);
    2250          134 : }
    2251              : 
    2252              : /* Clear the offset of MEM.  */
    2253              : 
    2254              : void
    2255        87021 : clear_mem_offset (rtx mem)
    2256              : {
    2257        87021 :   mem_attrs attrs (*get_mem_attrs (mem));
    2258        87021 :   attrs.offset_known_p = false;
    2259        87021 :   set_mem_attrs (mem, &attrs);
    2260        87021 : }
    2261              : 
    2262              : /* Set the size of MEM to SIZE.  */
    2263              : 
    2264              : void
    2265      2480062 : set_mem_size (rtx mem, poly_int64 size)
    2266              : {
    2267      2480062 :   mem_attrs attrs (*get_mem_attrs (mem));
    2268      2480062 :   attrs.size_known_p = true;
    2269      2480062 :   attrs.size = size;
    2270      2480062 :   set_mem_attrs (mem, &attrs);
    2271      2480062 : }
    2272              : 
    2273              : /* Clear the size of MEM.  */
    2274              : 
    2275              : void
    2276          552 : clear_mem_size (rtx mem)
    2277              : {
    2278          552 :   mem_attrs attrs (*get_mem_attrs (mem));
    2279          552 :   attrs.size_known_p = false;
    2280          552 :   set_mem_attrs (mem, &attrs);
    2281          552 : }
    2282              : 
    2283              : /* Return a memory reference like MEMREF, but with its mode changed to MODE
    2284              :    and its address changed to ADDR.  (VOIDmode means don't change the mode.
    2285              :    NULL for ADDR means don't change the address.)  VALIDATE is nonzero if the
    2286              :    returned memory location is required to be valid.  INPLACE is true if any
    2287              :    changes can be made directly to MEMREF or false if MEMREF must be treated
    2288              :    as immutable.
    2289              : 
    2290              :    The memory attributes are not changed.  */
    2291              : 
    2292              : static rtx
    2293    493824755 : change_address_1 (rtx memref, machine_mode mode, rtx addr, int validate,
    2294              :                   bool inplace)
    2295              : {
    2296    493824755 :   addr_space_t as;
    2297    493824755 :   rtx new_rtx;
    2298              : 
    2299    493824755 :   gcc_assert (MEM_P (memref));
    2300    493824755 :   as = MEM_ADDR_SPACE (memref);
    2301    493824755 :   if (mode == VOIDmode)
    2302    467651423 :     mode = GET_MODE (memref);
    2303    493824755 :   if (addr == 0)
    2304           60 :     addr = XEXP (memref, 0);
    2305    473904428 :   if (mode == GET_MODE (memref) && addr == XEXP (memref, 0)
    2306    830827749 :       && (!validate || memory_address_addr_space_p (mode, addr, as)))
    2307    336878885 :     return memref;
    2308              : 
    2309              :   /* Don't validate address for LRA.  LRA can make the address valid
    2310              :      by itself in most efficient way.  */
    2311    156945870 :   if (validate && !lra_in_progress)
    2312              :     {
    2313     22834147 :       if (reload_in_progress || reload_completed)
    2314      3824537 :         gcc_assert (memory_address_addr_space_p (mode, addr, as));
    2315              :       else
    2316     19009610 :         addr = memory_address_addr_space (mode, addr, as);
    2317              :     }
    2318              : 
    2319    156945870 :   if (rtx_equal_p (addr, XEXP (memref, 0)) && mode == GET_MODE (memref))
    2320              :     return memref;
    2321              : 
    2322    152900652 :   if (inplace)
    2323              :     {
    2324       259818 :       XEXP (memref, 0) = addr;
    2325       259818 :       return memref;
    2326              :     }
    2327              : 
    2328    152640834 :   new_rtx = gen_rtx_MEM (mode, addr);
    2329    152640834 :   MEM_COPY_ATTRIBUTES (new_rtx, memref);
    2330    152640834 :   return new_rtx;
    2331              : }
    2332              : 
    2333              : /* Like change_address_1 with VALIDATE nonzero, but we are not saying in what
    2334              :    way we are changing MEMREF, so we only preserve the alias set.  */
    2335              : 
    2336              : rtx
    2337       282227 : change_address (rtx memref, machine_mode mode, rtx addr)
    2338              : {
    2339       282227 :   rtx new_rtx = change_address_1 (memref, mode, addr, 1, false);
    2340       282227 :   machine_mode mmode = GET_MODE (new_rtx);
    2341       282227 :   class mem_attrs *defattrs;
    2342              : 
    2343       282227 :   mem_attrs attrs (*get_mem_attrs (memref));
    2344       282227 :   defattrs = mode_mem_attrs[(int) mmode];
    2345       282227 :   attrs.expr = NULL_TREE;
    2346       282227 :   attrs.offset_known_p = false;
    2347       282227 :   attrs.size_known_p = defattrs->size_known_p;
    2348       282227 :   attrs.size = defattrs->size;
    2349       282227 :   attrs.align = defattrs->align;
    2350              : 
    2351              :   /* If there are no changes, just return the original memory reference.  */
    2352       282227 :   if (new_rtx == memref)
    2353              :     {
    2354        67965 :       if (mem_attrs_eq_p (get_mem_attrs (memref), &attrs))
    2355              :         return new_rtx;
    2356              : 
    2357        56309 :       new_rtx = gen_rtx_MEM (mmode, XEXP (memref, 0));
    2358        56309 :       MEM_COPY_ATTRIBUTES (new_rtx, memref);
    2359              :     }
    2360              : 
    2361       270571 :   set_mem_attrs (new_rtx, &attrs);
    2362       270571 :   return new_rtx;
    2363              : }
    2364              : 
    2365              : /* Return a memory reference like MEMREF, but with its mode changed
    2366              :    to MODE and its address offset by OFFSET bytes.  If VALIDATE is
    2367              :    nonzero, the memory address is forced to be valid.
    2368              :    If ADJUST_ADDRESS is zero, OFFSET is only used to update MEM_ATTRS
    2369              :    and the caller is responsible for adjusting MEMREF base register.
    2370              :    If ADJUST_OBJECT is zero, the underlying object associated with the
    2371              :    memory reference is left unchanged and the caller is responsible for
    2372              :    dealing with it.  Otherwise, if the new memory reference is outside
    2373              :    the underlying object, even partially, then the object is dropped.
    2374              :    SIZE, if nonzero, is the size of an access in cases where MODE
    2375              :    has no inherent size.  */
    2376              : 
    2377              : rtx
    2378     34521665 : adjust_address_1 (rtx memref, machine_mode mode, poly_int64 offset,
    2379              :                   int validate, int adjust_address, int adjust_object,
    2380              :                   poly_int64 size)
    2381              : {
    2382     34521665 :   rtx addr = XEXP (memref, 0);
    2383     34521665 :   rtx new_rtx;
    2384     34521665 :   scalar_int_mode address_mode;
    2385     34521665 :   class mem_attrs attrs (*get_mem_attrs (memref)), *defattrs;
    2386     34521665 :   unsigned HOST_WIDE_INT max_align;
    2387              : #ifdef POINTERS_EXTEND_UNSIGNED
    2388     34521665 :   scalar_int_mode pointer_mode
    2389     34521665 :     = targetm.addr_space.pointer_mode (attrs.addrspace);
    2390              : #endif
    2391              : 
    2392              :   /* VOIDmode means no mode change for change_address_1.  */
    2393     34521665 :   if (mode == VOIDmode)
    2394        16931 :     mode = GET_MODE (memref);
    2395              : 
    2396              :   /* Take the size of non-BLKmode accesses from the mode.  */
    2397     34521665 :   defattrs = mode_mem_attrs[(int) mode];
    2398     34521665 :   if (defattrs->size_known_p)
    2399     28769638 :     size = defattrs->size;
    2400              : 
    2401              :   /* If there are no changes, just return the original memory reference.  */
    2402     34521665 :   if (mode == GET_MODE (memref)
    2403     14731568 :       && known_eq (offset, 0)
    2404      8631195 :       && (known_eq (size, 0)
    2405      3682236 :           || (attrs.size_known_p && known_eq (attrs.size, size)))
    2406     47983560 :       && (!validate || memory_address_addr_space_p (mode, addr,
    2407      4831329 :                                                     attrs.addrspace)))
    2408      8630560 :     return memref;
    2409              : 
    2410              :   /* ??? Prefer to create garbage instead of creating shared rtl.
    2411              :      This may happen even if offset is nonzero -- consider
    2412              :      (plus (plus reg reg) const_int) -- so do this always.  */
    2413     25891105 :   addr = copy_rtx (addr);
    2414              : 
    2415              :   /* Convert a possibly large offset to a signed value within the
    2416              :      range of the target address space.  */
    2417     25891105 :   address_mode = get_address_mode (memref);
    2418     25891105 :   offset = trunc_int_for_mode (offset, address_mode);
    2419              : 
    2420     25891105 :   if (adjust_address)
    2421              :     {
    2422              :       /* If MEMREF is a LO_SUM and the offset is within the alignment of the
    2423              :          object, we can merge it into the LO_SUM.  */
    2424     25863994 :       if (GET_MODE (memref) != BLKmode
    2425     11921631 :           && GET_CODE (addr) == LO_SUM
    2426     25863994 :           && known_in_range_p (offset,
    2427            0 :                                0, (GET_MODE_ALIGNMENT (GET_MODE (memref))
    2428            0 :                                    / BITS_PER_UNIT)))
    2429            0 :         addr = gen_rtx_LO_SUM (address_mode, XEXP (addr, 0),
    2430              :                                plus_constant (address_mode,
    2431              :                                               XEXP (addr, 1), offset));
    2432              : #ifdef POINTERS_EXTEND_UNSIGNED
    2433              :       /* If MEMREF is a ZERO_EXTEND from pointer_mode and the offset is valid
    2434              :          in that mode, we merge it into the ZERO_EXTEND.  We take advantage of
    2435              :          the fact that pointers are not allowed to overflow.  */
    2436     25863994 :       else if (POINTERS_EXTEND_UNSIGNED > 0
    2437     25863994 :                && GET_CODE (addr) == ZERO_EXTEND
    2438           12 :                && GET_MODE (XEXP (addr, 0)) == pointer_mode
    2439     25863996 :                && known_eq (trunc_int_for_mode (offset, pointer_mode), offset))
    2440            2 :         addr = gen_rtx_ZERO_EXTEND (address_mode,
    2441              :                                     plus_constant (pointer_mode,
    2442              :                                                    XEXP (addr, 0), offset));
    2443              : #endif
    2444              :       else
    2445     25863992 :         addr = plus_constant (address_mode, addr, offset);
    2446              :     }
    2447              : 
    2448     25891105 :   new_rtx = change_address_1 (memref, mode, addr, validate, false);
    2449              : 
    2450              :   /* If the address is a REG, change_address_1 rightfully returns memref,
    2451              :      but this would destroy memref's MEM_ATTRS.  */
    2452     25891105 :   if (new_rtx == memref && maybe_ne (offset, 0))
    2453        27066 :     new_rtx = copy_rtx (new_rtx);
    2454              : 
    2455              :   /* Conservatively drop the object if we don't know where we start from.  */
    2456     25891105 :   if (adjust_object && (!attrs.offset_known_p || !attrs.size_known_p))
    2457              :     {
    2458         4357 :       attrs.expr = NULL_TREE;
    2459         4357 :       attrs.alias = 0;
    2460              :     }
    2461              : 
    2462              :   /* Compute the new values of the memory attributes due to this adjustment.
    2463              :      We add the offsets and update the alignment.  */
    2464     25891105 :   if (attrs.offset_known_p)
    2465              :     {
    2466     22046216 :       attrs.offset += offset;
    2467              : 
    2468              :       /* Drop the object if the new left end is not within its bounds.  */
    2469     22046216 :       if (adjust_object && maybe_lt (attrs.offset, 0))
    2470              :         {
    2471        25659 :           attrs.expr = NULL_TREE;
    2472        25659 :           attrs.alias = 0;
    2473              :         }
    2474              :     }
    2475              : 
    2476              :   /* Compute the new alignment by taking the MIN of the alignment and the
    2477              :      lowest-order set bit in OFFSET, but don't change the alignment if OFFSET
    2478              :      if zero.  */
    2479     25891105 :   if (maybe_ne (offset, 0))
    2480              :     {
    2481     11824959 :       max_align = known_alignment (offset) * BITS_PER_UNIT;
    2482     11824959 :       attrs.align = MIN (attrs.align, max_align);
    2483              :     }
    2484              : 
    2485     25891105 :   if (maybe_ne (size, 0))
    2486              :     {
    2487              :       /* Drop the object if the new right end is not within its bounds.  */
    2488     25245630 :       if (adjust_object && maybe_gt (offset + size, attrs.size))
    2489              :         {
    2490        64794 :           attrs.expr = NULL_TREE;
    2491        64794 :           attrs.alias = 0;
    2492              :         }
    2493     25245630 :       attrs.size_known_p = true;
    2494     25245630 :       attrs.size = size;
    2495              :     }
    2496       645475 :   else if (attrs.size_known_p)
    2497              :     {
    2498       638948 :       gcc_assert (!adjust_object);
    2499     25891105 :       attrs.size -= offset;
    2500              :       /* ??? The store_by_pieces machinery generates negative sizes,
    2501              :          so don't assert for that here.  */
    2502              :     }
    2503              : 
    2504     25891105 :   set_mem_attrs (new_rtx, &attrs);
    2505              : 
    2506     25891105 :   return new_rtx;
    2507              : }
    2508              : 
    2509              : /* Return a memory reference like MEMREF, but with its mode changed
    2510              :    to MODE and its address changed to ADDR, which is assumed to be
    2511              :    MEMREF offset by OFFSET bytes.  If VALIDATE is
    2512              :    nonzero, the memory address is forced to be valid.  */
    2513              : 
    2514              : rtx
    2515        53517 : adjust_automodify_address_1 (rtx memref, machine_mode mode, rtx addr,
    2516              :                              poly_int64 offset, int validate)
    2517              : {
    2518        53517 :   memref = change_address_1 (memref, VOIDmode, addr, validate, false);
    2519        53517 :   return adjust_address_1 (memref, mode, offset, validate, 0, 0, 0);
    2520              : }
    2521              : 
    2522              : /* Return a memory reference like MEMREF, but whose address is changed by
    2523              :    adding OFFSET, an RTX, to it.  POW2 is the highest power of two factor
    2524              :    known to be in OFFSET (possibly 1).  */
    2525              : 
    2526              : rtx
    2527       912570 : offset_address (rtx memref, rtx offset, unsigned HOST_WIDE_INT pow2)
    2528              : {
    2529       912570 :   rtx new_rtx, addr = XEXP (memref, 0);
    2530       912570 :   machine_mode address_mode;
    2531       912570 :   class mem_attrs *defattrs;
    2532              : 
    2533       912570 :   mem_attrs attrs (*get_mem_attrs (memref));
    2534       912570 :   address_mode = get_address_mode (memref);
    2535       912570 :   new_rtx = simplify_gen_binary (PLUS, address_mode, addr, offset);
    2536              : 
    2537              :   /* At this point we don't know _why_ the address is invalid.  It
    2538              :      could have secondary memory references, multiplies or anything.
    2539              : 
    2540              :      However, if we did go and rearrange things, we can wind up not
    2541              :      being able to recognize the magic around pic_offset_table_rtx.
    2542              :      This stuff is fragile, and is yet another example of why it is
    2543              :      bad to expose PIC machinery too early.  */
    2544      1823400 :   if (! memory_address_addr_space_p (GET_MODE (memref), new_rtx,
    2545       912570 :                                      attrs.addrspace)
    2546       139441 :       && GET_CODE (addr) == PLUS
    2547      1004373 :       && XEXP (addr, 0) == pic_offset_table_rtx)
    2548              :     {
    2549         1740 :       addr = force_reg (GET_MODE (addr), addr);
    2550         1740 :       new_rtx = simplify_gen_binary (PLUS, address_mode, addr, offset);
    2551              :     }
    2552              : 
    2553       912570 :   update_temp_slot_address (XEXP (memref, 0), new_rtx);
    2554       912570 :   new_rtx = change_address_1 (memref, VOIDmode, new_rtx, 1, false);
    2555              : 
    2556              :   /* If there are no changes, just return the original memory reference.  */
    2557       912570 :   if (new_rtx == memref)
    2558              :     return new_rtx;
    2559              : 
    2560              :   /* Update the alignment to reflect the offset.  Reset the offset, which
    2561              :      we don't know.  */
    2562       912570 :   defattrs = mode_mem_attrs[(int) GET_MODE (new_rtx)];
    2563       912570 :   attrs.offset_known_p = false;
    2564       912570 :   attrs.size_known_p = defattrs->size_known_p;
    2565       912570 :   attrs.size = defattrs->size;
    2566       912570 :   attrs.align = MIN (attrs.align, pow2 * BITS_PER_UNIT);
    2567       912570 :   set_mem_attrs (new_rtx, &attrs);
    2568       912570 :   return new_rtx;
    2569              : }
    2570              : 
    2571              : /* Return a memory reference like MEMREF, but with its address changed to
    2572              :    ADDR.  The caller is asserting that the actual piece of memory pointed
    2573              :    to is the same, just the form of the address is being changed, such as
    2574              :    by putting something into a register.  INPLACE is true if any changes
    2575              :    can be made directly to MEMREF or false if MEMREF must be treated as
    2576              :    immutable.  */
    2577              : 
    2578              : rtx
    2579     12759596 : replace_equiv_address (rtx memref, rtx addr, bool inplace)
    2580              : {
    2581              :   /* change_address_1 copies the memory attribute structure without change
    2582              :      and that's exactly what we want here.  */
    2583     12759596 :   update_temp_slot_address (XEXP (memref, 0), addr);
    2584     12759596 :   return change_address_1 (memref, VOIDmode, addr, 1, inplace);
    2585              : }
    2586              : 
    2587              : /* Likewise, but the reference is not required to be valid.  */
    2588              : 
    2589              : rtx
    2590    453925740 : replace_equiv_address_nv (rtx memref, rtx addr, bool inplace)
    2591              : {
    2592    453925740 :   return change_address_1 (memref, VOIDmode, addr, 0, inplace);
    2593              : }
    2594              : 
    2595              : 
    2596              : /* Emit insns to reload VALUE into a new register.  VALUE is an
    2597              :    auto-increment or auto-decrement RTX whose operand is a register or
    2598              :    memory location; so reloading involves incrementing that location.
    2599              : 
    2600              :    INC_AMOUNT is the number to increment or decrement by (always
    2601              :    positive and ignored for POST_MODIFY/PRE_MODIFY).
    2602              : 
    2603              :    Return a pseudo containing the result.  */
    2604              : rtx
    2605            0 : address_reload_context::emit_autoinc (rtx value, poly_int64 inc_amount)
    2606              : {
    2607              :   /* Since we're going to call recog, and might be called within recog,
    2608              :      we need to ensure we save and restore recog_data.  */
    2609            0 :   recog_data_saver recog_save;
    2610              : 
    2611              :   /* REG or MEM to be copied and incremented.  */
    2612            0 :   rtx incloc = XEXP (value, 0);
    2613              : 
    2614            0 :   const rtx_code code = GET_CODE (value);
    2615            0 :   const bool post_p
    2616            0 :     = code == POST_DEC || code == POST_INC || code == POST_MODIFY;
    2617              : 
    2618            0 :   bool plus_p = true;
    2619            0 :   rtx inc;
    2620            0 :   if (code == PRE_MODIFY || code == POST_MODIFY)
    2621              :     {
    2622            0 :       gcc_assert (GET_CODE (XEXP (value, 1)) == PLUS
    2623              :                   || GET_CODE (XEXP (value, 1)) == MINUS);
    2624            0 :       gcc_assert (rtx_equal_p (XEXP (XEXP (value, 1), 0), XEXP (value, 0)));
    2625            0 :       plus_p = GET_CODE (XEXP (value, 1)) == PLUS;
    2626            0 :       inc = XEXP (XEXP (value, 1), 1);
    2627              :     }
    2628              :   else
    2629              :     {
    2630            0 :       if (code == PRE_DEC || code == POST_DEC)
    2631            0 :         inc_amount = -inc_amount;
    2632              : 
    2633            0 :       inc = gen_int_mode (inc_amount, GET_MODE (value));
    2634              :     }
    2635              : 
    2636            0 :   rtx result;
    2637            0 :   if (!post_p && REG_P (incloc))
    2638              :     result = incloc;
    2639              :   else
    2640              :     {
    2641            0 :       result = get_reload_reg ();
    2642              :       /* First copy the location to the result register.  */
    2643            0 :       emit_insn (gen_move_insn (result, incloc));
    2644              :     }
    2645              : 
    2646              :   /* See if we can directly increment INCLOC.  */
    2647            0 :   rtx_insn *last = get_last_insn ();
    2648            0 :   rtx_insn *add_insn = emit_insn (plus_p
    2649            0 :                                   ? gen_add2_insn (incloc, inc)
    2650            0 :                                   : gen_sub2_insn (incloc, inc));
    2651            0 :   const int icode = recog_memoized (add_insn);
    2652            0 :   if (icode >= 0)
    2653              :     {
    2654            0 :       if (!post_p && result != incloc)
    2655            0 :         emit_insn (gen_move_insn (result, incloc));
    2656            0 :       return result;
    2657              :     }
    2658            0 :   delete_insns_since (last);
    2659              : 
    2660              :   /* If couldn't do the increment directly, must increment in RESULT.
    2661              :      The way we do this depends on whether this is pre- or
    2662              :      post-increment.  For pre-increment, copy INCLOC to the reload
    2663              :      register, increment it there, then save back.  */
    2664            0 :   if (!post_p)
    2665              :     {
    2666            0 :       if (incloc != result)
    2667            0 :         emit_insn (gen_move_insn (result, incloc));
    2668            0 :       if (plus_p)
    2669            0 :         emit_insn (gen_add2_insn (result, inc));
    2670              :       else
    2671            0 :         emit_insn (gen_sub2_insn (result, inc));
    2672            0 :       if (incloc != result)
    2673            0 :         emit_insn (gen_move_insn (incloc, result));
    2674              :     }
    2675              :   else
    2676              :     {
    2677              :       /* Post-increment.
    2678              : 
    2679              :          Because this might be a jump insn or a compare, and because
    2680              :          RESULT may not be available after the insn in an input
    2681              :          reload, we must do the incrementing before the insn being
    2682              :          reloaded for.
    2683              : 
    2684              :          We have already copied INCLOC to RESULT.  Increment the copy in
    2685              :          RESULT, save that back, then decrement RESULT so it has
    2686              :          the original value.  */
    2687            0 :       if (plus_p)
    2688            0 :         emit_insn (gen_add2_insn (result, inc));
    2689              :       else
    2690            0 :         emit_insn (gen_sub2_insn (result, inc));
    2691            0 :       emit_insn (gen_move_insn (incloc, result));
    2692              :       /* Restore non-modified value for the result.  We prefer this
    2693              :          way because it does not require an additional hard
    2694              :          register.  */
    2695            0 :       if (plus_p)
    2696              :         {
    2697            0 :           poly_int64 offset;
    2698            0 :           if (poly_int_rtx_p (inc, &offset))
    2699            0 :             emit_insn (gen_add2_insn (result,
    2700              :                                       gen_int_mode (-offset,
    2701            0 :                                                     GET_MODE (result))));
    2702              :           else
    2703            0 :             emit_insn (gen_sub2_insn (result, inc));
    2704              :         }
    2705              :       else
    2706            0 :         emit_insn (gen_add2_insn (result, inc));
    2707              :     }
    2708              :   return result;
    2709            0 : }
    2710              : 
    2711              : /* Return a memory reference like MEM, but with the address reloaded into a
    2712              :    pseudo register.  */
    2713              : 
    2714              : rtx
    2715            0 : force_reload_address (rtx mem)
    2716              : {
    2717            0 :   rtx addr = XEXP (mem, 0);
    2718            0 :   if (GET_RTX_CLASS (GET_CODE (addr)) == RTX_AUTOINC)
    2719              :     {
    2720            0 :       const auto size = GET_MODE_SIZE (GET_MODE (mem));
    2721            0 :       addr = address_reload_context ().emit_autoinc (addr, size);
    2722              :     }
    2723              :   else
    2724            0 :     addr = force_reg (Pmode, addr);
    2725              : 
    2726            0 :   return replace_equiv_address (mem, addr);
    2727              : }
    2728              : 
    2729              : /* Return a memory reference like MEMREF, but with its mode widened to
    2730              :    MODE and offset by OFFSET.  This would be used by targets that e.g.
    2731              :    cannot issue QImode memory operations and have to use SImode memory
    2732              :    operations plus masking logic.  */
    2733              : 
    2734              : rtx
    2735            0 : widen_memory_access (rtx memref, machine_mode mode, poly_int64 offset)
    2736              : {
    2737            0 :   rtx new_rtx = adjust_address_1 (memref, mode, offset, 1, 1, 0, 0);
    2738            0 :   poly_uint64 size = GET_MODE_SIZE (mode);
    2739              : 
    2740              :   /* If there are no changes, just return the original memory reference.  */
    2741            0 :   if (new_rtx == memref)
    2742              :     return new_rtx;
    2743              : 
    2744            0 :   mem_attrs attrs (*get_mem_attrs (new_rtx));
    2745              : 
    2746              :   /* If we don't know what offset we were at within the expression, then
    2747              :      we can't know if we've overstepped the bounds.  */
    2748            0 :   if (! attrs.offset_known_p)
    2749            0 :     attrs.expr = NULL_TREE;
    2750              : 
    2751            0 :   while (attrs.expr)
    2752              :     {
    2753            0 :       if (TREE_CODE (attrs.expr) == COMPONENT_REF)
    2754              :         {
    2755            0 :           tree field = TREE_OPERAND (attrs.expr, 1);
    2756            0 :           tree offset = component_ref_field_offset (attrs.expr);
    2757              : 
    2758            0 :           if (! DECL_SIZE_UNIT (field))
    2759              :             {
    2760            0 :               attrs.expr = NULL_TREE;
    2761            0 :               break;
    2762              :             }
    2763              : 
    2764              :           /* Is the field at least as large as the access?  If so, ok,
    2765              :              otherwise strip back to the containing structure.  */
    2766            0 :           if (poly_int_tree_p (DECL_SIZE_UNIT (field))
    2767            0 :               && known_ge (wi::to_poly_offset (DECL_SIZE_UNIT (field)), size)
    2768            0 :               && known_ge (attrs.offset, 0))
    2769              :             break;
    2770              : 
    2771            0 :           poly_uint64 suboffset;
    2772            0 :           if (!poly_int_tree_p (offset, &suboffset))
    2773              :             {
    2774            0 :               attrs.expr = NULL_TREE;
    2775            0 :               break;
    2776              :             }
    2777              : 
    2778            0 :           attrs.expr = TREE_OPERAND (attrs.expr, 0);
    2779            0 :           attrs.offset += suboffset;
    2780            0 :           attrs.offset += (tree_to_uhwi (DECL_FIELD_BIT_OFFSET (field))
    2781            0 :                            / BITS_PER_UNIT);
    2782              :         }
    2783              :       /* Similarly for the decl.  */
    2784            0 :       else if (DECL_P (attrs.expr)
    2785            0 :                && DECL_SIZE_UNIT (attrs.expr)
    2786            0 :                && poly_int_tree_p (DECL_SIZE_UNIT (attrs.expr))
    2787            0 :                && known_ge (wi::to_poly_offset (DECL_SIZE_UNIT (attrs.expr)),
    2788              :                            size)
    2789            0 :                && known_ge (attrs.offset, 0))
    2790              :         break;
    2791              :       else
    2792              :         {
    2793              :           /* The widened memory access overflows the expression, which means
    2794              :              that it could alias another expression.  Zap it.  */
    2795            0 :           attrs.expr = NULL_TREE;
    2796            0 :           break;
    2797              :         }
    2798              :     }
    2799              : 
    2800            0 :   if (! attrs.expr)
    2801            0 :     attrs.offset_known_p = false;
    2802              : 
    2803              :   /* The widened memory may alias other stuff, so zap the alias set.  */
    2804              :   /* ??? Maybe use get_alias_set on any remaining expression.  */
    2805            0 :   attrs.alias = 0;
    2806            0 :   attrs.size_known_p = true;
    2807            0 :   attrs.size = size;
    2808            0 :   set_mem_attrs (new_rtx, &attrs);
    2809            0 :   return new_rtx;
    2810              : }
    2811              : 
    2812              : /* A fake decl that is used as the MEM_EXPR of spill slots.  */
    2813              : static GTY(()) tree spill_slot_decl;
    2814              : 
    2815              : tree
    2816    809768383 : get_spill_slot_decl (bool force_build_p)
    2817              : {
    2818    809768383 :   tree d = spill_slot_decl;
    2819    809768383 :   rtx rd;
    2820              : 
    2821    809768383 :   if (d || !force_build_p)
    2822              :     return d;
    2823              : 
    2824        30223 :   d = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
    2825              :                   VAR_DECL, get_identifier ("%sfp"), void_type_node);
    2826        30223 :   DECL_ARTIFICIAL (d) = 1;
    2827        30223 :   DECL_IGNORED_P (d) = 1;
    2828        30223 :   TREE_USED (d) = 1;
    2829        30223 :   spill_slot_decl = d;
    2830              : 
    2831        30223 :   rd = gen_rtx_MEM (BLKmode, frame_pointer_rtx);
    2832        30223 :   MEM_NOTRAP_P (rd) = 1;
    2833        30223 :   mem_attrs attrs (*mode_mem_attrs[(int) BLKmode]);
    2834        30223 :   attrs.alias = new_alias_set ();
    2835        30223 :   attrs.expr = d;
    2836        30223 :   set_mem_attrs (rd, &attrs);
    2837        30223 :   SET_DECL_RTL (d, rd);
    2838              : 
    2839        30223 :   return d;
    2840              : }
    2841              : 
    2842              : /* Given MEM, a result from assign_stack_local, fill in the memory
    2843              :    attributes as appropriate for a register allocator spill slot.
    2844              :    These slots are not aliasable by other memory.  We arrange for
    2845              :    them all to use a single MEM_EXPR, so that the aliasing code can
    2846              :    work properly in the case of shared spill slots.  */
    2847              : 
    2848              : void
    2849      1408554 : set_mem_attrs_for_spill (rtx mem)
    2850              : {
    2851      1408554 :   rtx addr;
    2852              : 
    2853      1408554 :   mem_attrs attrs (*get_mem_attrs (mem));
    2854      1408554 :   attrs.expr = get_spill_slot_decl (true);
    2855      1408554 :   attrs.alias = MEM_ALIAS_SET (DECL_RTL (attrs.expr));
    2856      1408554 :   attrs.addrspace = ADDR_SPACE_GENERIC;
    2857              : 
    2858              :   /* We expect the incoming memory to be of the form:
    2859              :         (mem:MODE (plus (reg sfp) (const_int offset)))
    2860              :      with perhaps the plus missing for offset = 0.  */
    2861      1408554 :   addr = XEXP (mem, 0);
    2862      1408554 :   attrs.offset_known_p = true;
    2863      1408554 :   strip_offset (addr, &attrs.offset);
    2864              : 
    2865      1408554 :   set_mem_attrs (mem, &attrs);
    2866      1408554 :   MEM_NOTRAP_P (mem) = 1;
    2867      1408554 : }
    2868              : 
    2869              : /* Return a newly created CODE_LABEL rtx with a unique label number.  */
    2870              : 
    2871              : rtx_code_label *
    2872     15176062 : gen_label_rtx (void)
    2873              : {
    2874     15176062 :   return as_a <rtx_code_label *> (
    2875              :             gen_rtx_CODE_LABEL (VOIDmode, NULL_RTX, NULL_RTX,
    2876     15176062 :                                 NULL, label_num++, NULL));
    2877              : }
    2878              : 
    2879              : /* For procedure integration.  */
    2880              : 
    2881              : /* Install new pointers to the first and last insns in the chain.
    2882              :    Also, set cur_insn_uid to one higher than the last in use.
    2883              :    Used for an inline-procedure after copying the insn chain.  */
    2884              : 
    2885              : void
    2886            8 : set_new_first_and_last_insn (rtx_insn *first, rtx_insn *last)
    2887              : {
    2888            8 :   rtx_insn *insn;
    2889              : 
    2890            8 :   set_first_insn (first);
    2891            8 :   set_last_insn (last);
    2892            8 :   cur_insn_uid = 0;
    2893              : 
    2894            8 :   if (param_min_nondebug_insn_uid || MAY_HAVE_DEBUG_INSNS)
    2895              :     {
    2896            0 :       int debug_count = 0;
    2897              : 
    2898            0 :       cur_insn_uid = param_min_nondebug_insn_uid - 1;
    2899            0 :       cur_debug_insn_uid = 0;
    2900              : 
    2901            0 :       for (insn = first; insn; insn = NEXT_INSN (insn))
    2902            0 :         if (INSN_UID (insn) < param_min_nondebug_insn_uid)
    2903            0 :           cur_debug_insn_uid = MAX (cur_debug_insn_uid, INSN_UID (insn));
    2904              :         else
    2905              :           {
    2906            0 :             cur_insn_uid = MAX (cur_insn_uid, INSN_UID (insn));
    2907            0 :             if (DEBUG_INSN_P (insn))
    2908            0 :               debug_count++;
    2909              :           }
    2910              : 
    2911            0 :       if (debug_count)
    2912            0 :         cur_debug_insn_uid = param_min_nondebug_insn_uid + debug_count;
    2913              :       else
    2914            0 :         cur_debug_insn_uid++;
    2915              :     }
    2916              :   else
    2917            8 :     for (insn = first; insn; insn = NEXT_INSN (insn))
    2918            0 :       cur_insn_uid = MAX (cur_insn_uid, INSN_UID (insn));
    2919              : 
    2920            8 :   cur_insn_uid++;
    2921            8 : }
    2922              : 
    2923              : /* Go through all the RTL insn bodies and copy any invalid shared
    2924              :    structure.  This routine should only be called once.  */
    2925              : 
    2926              : static void
    2927      2977518 : unshare_all_rtl_1 (rtx_insn *insn)
    2928              : {
    2929              :   /* Unshare just about everything else.  */
    2930      2977518 :   unshare_all_rtl_in_chain (insn);
    2931              : 
    2932              :   /* Make sure the addresses of stack slots found outside the insn chain
    2933              :      (such as, in DECL_RTL of a variable) are not shared
    2934              :      with the insn chain.
    2935              : 
    2936              :      This special care is necessary when the stack slot MEM does not
    2937              :      actually appear in the insn chain.  If it does appear, its address
    2938              :      is unshared from all else at that point.  */
    2939      2977518 :   unsigned int i;
    2940      2977518 :   rtx temp;
    2941      9210581 :   FOR_EACH_VEC_SAFE_ELT (stack_slot_list, i, temp)
    2942      3255545 :     (*stack_slot_list)[i] = copy_rtx_if_shared (temp);
    2943      2977518 : }
    2944              : 
    2945              : /* Go through all the RTL insn bodies and copy any invalid shared
    2946              :    structure, again.  This is a fairly expensive thing to do so it
    2947              :    should be done sparingly.  */
    2948              : 
    2949              : void
    2950      1488370 : unshare_all_rtl_again (rtx_insn *insn)
    2951              : {
    2952      1488370 :   rtx_insn *p;
    2953      1488370 :   tree decl;
    2954              : 
    2955    165796965 :   for (p = insn; p; p = NEXT_INSN (p))
    2956    164308595 :     if (INSN_P (p))
    2957              :       {
    2958    129492243 :         reset_used_flags (PATTERN (p));
    2959    129492243 :         reset_used_flags (REG_NOTES (p));
    2960    129492243 :         if (CALL_P (p))
    2961      5963612 :           reset_used_flags (CALL_INSN_FUNCTION_USAGE (p));
    2962              :       }
    2963              : 
    2964              :   /* Make sure that virtual stack slots are not shared.  */
    2965      1488370 :   set_used_decls (DECL_INITIAL (cfun->decl));
    2966              : 
    2967              :   /* Make sure that virtual parameters are not shared.  */
    2968      4607029 :   for (decl = DECL_ARGUMENTS (cfun->decl); decl; decl = DECL_CHAIN (decl))
    2969      3118659 :     set_used_flags (DECL_RTL (decl));
    2970              : 
    2971              :   rtx temp;
    2972              :   unsigned int i;
    2973      3895088 :   FOR_EACH_VEC_SAFE_ELT (stack_slot_list, i, temp)
    2974      2406718 :     reset_used_flags (temp);
    2975              : 
    2976      1488370 :   unshare_all_rtl_1 (insn);
    2977      1488370 : }
    2978              : 
    2979              : void
    2980      1489148 : unshare_all_rtl (void)
    2981              : {
    2982      1489148 :   unshare_all_rtl_1 (get_insns ());
    2983              : 
    2984      4608366 :   for (tree decl = DECL_ARGUMENTS (cfun->decl); decl; decl = DECL_CHAIN (decl))
    2985              :     {
    2986      3119218 :       if (DECL_RTL_SET_P (decl))
    2987      3119218 :         SET_DECL_RTL (decl, copy_rtx_if_shared (DECL_RTL (decl)));
    2988      3119218 :       DECL_INCOMING_RTL (decl) = copy_rtx_if_shared (DECL_INCOMING_RTL (decl));
    2989              :     }
    2990      1489148 : }
    2991              : 
    2992              : 
    2993              : /* Check that ORIG is not marked when it should not be and mark ORIG as in use,
    2994              :    Recursively does the same for subexpressions.  */
    2995              : 
    2996              : static void
    2997  54920053017 : verify_rtx_sharing (rtx orig, rtx insn)
    2998              : {
    2999  54920053017 :   rtx x = orig;
    3000  54920053017 :   int i;
    3001  54920053017 :   enum rtx_code code;
    3002  54920053017 :   const char *format_ptr;
    3003              : 
    3004  54920053017 :   if (x == 0)
    3005              :     return;
    3006              : 
    3007  45598119662 :   code = GET_CODE (x);
    3008              : 
    3009              :   /* These types may be freely shared.  */
    3010              : 
    3011  45598119662 :   switch (code)
    3012              :     {
    3013              :     case REG:
    3014              :     case DEBUG_EXPR:
    3015              :     case VALUE:
    3016              :     CASE_CONST_ANY:
    3017              :     case SYMBOL_REF:
    3018              :     case LABEL_REF:
    3019              :     case CODE_LABEL:
    3020              :     case PC:
    3021              :     case RETURN:
    3022              :     case SIMPLE_RETURN:
    3023              :     case SCRATCH:
    3024              :       /* SCRATCH must be shared because they represent distinct values.  */
    3025              :       return;
    3026   1942900255 :     case CLOBBER:
    3027              :       /* Share clobbers of hard registers, but do not share pseudo reg
    3028              :          clobbers or clobbers of hard registers that originated as pseudos.
    3029              :          This is needed to allow safe register renaming.  */
    3030   1942900255 :       if (REG_P (XEXP (x, 0))
    3031    763844935 :           && HARD_REGISTER_NUM_P (REGNO (XEXP (x, 0)))
    3032   2703720661 :           && HARD_REGISTER_NUM_P (ORIGINAL_REGNO (XEXP (x, 0))))
    3033              :         return;
    3034              :       break;
    3035              : 
    3036     35311000 :     case CONST:
    3037     35311000 :       if (shared_const_p (orig))
    3038              :         return;
    3039              :       break;
    3040              : 
    3041   2741892447 :     case MEM:
    3042              :       /* A MEM is allowed to be shared if its address is constant.  */
    3043   2741892447 :       if (CONSTANT_ADDRESS_P (XEXP (x, 0))
    3044   2741892447 :           || reload_completed || reload_in_progress)
    3045              :         return;
    3046              : 
    3047              :       break;
    3048              : 
    3049              :     default:
    3050              :       break;
    3051              :     }
    3052              : 
    3053              :   /* This rtx may not be shared.  If it has already been seen,
    3054              :      replace it with a copy of itself.  */
    3055  22056300769 :   if (flag_checking && RTX_FLAG (x, used))
    3056              :     {
    3057            0 :       error ("invalid rtl sharing found in the insn");
    3058            0 :       debug_rtx (insn);
    3059            0 :       error ("shared rtx");
    3060            0 :       debug_rtx (x);
    3061            0 :       internal_error ("internal consistency failure");
    3062              :     }
    3063  22056300769 :   gcc_assert (!RTX_FLAG (x, used));
    3064              : 
    3065  22056300769 :   RTX_FLAG (x, used) = 1;
    3066              : 
    3067              :   /* Now scan the subexpressions recursively.  */
    3068              : 
    3069  22056300769 :   format_ptr = GET_RTX_FORMAT (code);
    3070              : 
    3071  62005128811 :   for (i = 0; i < GET_RTX_LENGTH (code); i++)
    3072              :     {
    3073  39948828042 :       switch (*format_ptr++)
    3074              :         {
    3075  34971010036 :         case 'e':
    3076  34971010036 :           verify_rtx_sharing (XEXP (x, i), insn);
    3077  34971010036 :           break;
    3078              : 
    3079    897226994 :         case 'E':
    3080    897226994 :           if (XVEC (x, i) != NULL)
    3081              :             {
    3082    897226994 :               int j;
    3083    897226994 :               int len = XVECLEN (x, i);
    3084              : 
    3085   2704909094 :               for (j = 0; j < len; j++)
    3086              :                 {
    3087              :                   /* We allow sharing of ASM_OPERANDS inside single
    3088              :                      instruction.  */
    3089   1807682100 :                   if (j && GET_CODE (XVECEXP (x, i, j)) == SET
    3090     54354028 :                       && (GET_CODE (SET_SRC (XVECEXP (x, i, j)))
    3091              :                           == ASM_OPERANDS))
    3092      3131737 :                     verify_rtx_sharing (SET_DEST (XVECEXP (x, i, j)), insn);
    3093              :                   else
    3094   1804550363 :                     verify_rtx_sharing (XVECEXP (x, i, j), insn);
    3095              :                 }
    3096              :             }
    3097              :           break;
    3098              :         }
    3099              :     }
    3100              : }
    3101              : 
    3102              : /* Reset used-flags for INSN.  */
    3103              : 
    3104              : static void
    3105  17734694768 : reset_insn_used_flags (rtx insn)
    3106              : {
    3107  17734694768 :   gcc_assert (INSN_P (insn));
    3108  17734694768 :   reset_used_flags (PATTERN (insn));
    3109  17734694768 :   reset_used_flags (REG_NOTES (insn));
    3110  17734694768 :   if (CALL_P (insn))
    3111    813332226 :     reset_used_flags (CALL_INSN_FUNCTION_USAGE (insn));
    3112  17734694768 : }
    3113              : 
    3114              : /* Go through all the RTL insn bodies and clear all the USED bits.  */
    3115              : 
    3116              : static void
    3117    188667882 : reset_all_used_flags (void)
    3118              : {
    3119    188667882 :   rtx_insn *p;
    3120              : 
    3121  23977878532 :   for (p = get_insns (); p; p = NEXT_INSN (p))
    3122  23789210650 :     if (INSN_P (p))
    3123              :       {
    3124  17734694768 :         rtx pat = PATTERN (p);
    3125  17734694768 :         if (GET_CODE (pat) != SEQUENCE)
    3126  17734694768 :           reset_insn_used_flags (p);
    3127              :         else
    3128              :           {
    3129            0 :             gcc_assert (REG_NOTES (p) == NULL);
    3130            0 :             for (int i = 0; i < XVECLEN (pat, 0); i++)
    3131              :               {
    3132            0 :                 rtx insn = XVECEXP (pat, 0, i);
    3133            0 :                 if (INSN_P (insn))
    3134            0 :                   reset_insn_used_flags (insn);
    3135              :               }
    3136              :           }
    3137              :       }
    3138    188667882 : }
    3139              : 
    3140              : /* Verify sharing in INSN.  */
    3141              : 
    3142              : static void
    3143   8867347384 : verify_insn_sharing (rtx insn)
    3144              : {
    3145   8867347384 :   gcc_assert (INSN_P (insn));
    3146   8867347384 :   verify_rtx_sharing (PATTERN (insn), insn);
    3147   8867347384 :   verify_rtx_sharing (REG_NOTES (insn), insn);
    3148   8867347384 :   if (CALL_P (insn))
    3149    406666113 :     verify_rtx_sharing (CALL_INSN_FUNCTION_USAGE (insn), insn);
    3150   8867347384 : }
    3151              : 
    3152              : /* Go through all the RTL insn bodies and check that there is no unexpected
    3153              :    sharing in between the subexpressions.  */
    3154              : 
    3155              : DEBUG_FUNCTION void
    3156     94333941 : verify_rtl_sharing (void)
    3157              : {
    3158     94333941 :   rtx_insn *p;
    3159              : 
    3160     94333941 :   timevar_push (TV_VERIFY_RTL_SHARING);
    3161              : 
    3162     94333941 :   reset_all_used_flags ();
    3163              : 
    3164  11988939266 :   for (p = get_insns (); p; p = NEXT_INSN (p))
    3165  11894605325 :     if (INSN_P (p))
    3166              :       {
    3167   8867347384 :         rtx pat = PATTERN (p);
    3168   8867347384 :         if (GET_CODE (pat) != SEQUENCE)
    3169   8867347384 :           verify_insn_sharing (p);
    3170              :         else
    3171            0 :           for (int i = 0; i < XVECLEN (pat, 0); i++)
    3172              :               {
    3173            0 :                 rtx insn = XVECEXP (pat, 0, i);
    3174            0 :                 if (INSN_P (insn))
    3175            0 :                   verify_insn_sharing (insn);
    3176              :               }
    3177              :       }
    3178              : 
    3179     94333941 :   reset_all_used_flags ();
    3180              : 
    3181     94333941 :   timevar_pop (TV_VERIFY_RTL_SHARING);
    3182     94333941 : }
    3183              : 
    3184              : /* Go through all the RTL insn bodies and copy any invalid shared structure.
    3185              :    Assumes the mark bits are cleared at entry.  */
    3186              : 
    3187              : void
    3188      9422975 : unshare_all_rtl_in_chain (rtx_insn *insn)
    3189              : {
    3190    353596769 :   for (; insn; insn = NEXT_INSN (insn))
    3191    344173794 :     if (INSN_P (insn))
    3192              :       {
    3193    280509645 :         PATTERN (insn) = copy_rtx_if_shared (PATTERN (insn));
    3194    280509645 :         REG_NOTES (insn) = copy_rtx_if_shared (REG_NOTES (insn));
    3195    280509645 :         if (CALL_P (insn))
    3196     11919980 :           CALL_INSN_FUNCTION_USAGE (insn)
    3197     11919980 :             = copy_rtx_if_shared (CALL_INSN_FUNCTION_USAGE (insn));
    3198              :       }
    3199      9422975 : }
    3200              : 
    3201              : /* Go through all virtual stack slots of a function and mark them as
    3202              :    shared.  We never replace the DECL_RTLs themselves with a copy,
    3203              :    but expressions mentioned into a DECL_RTL cannot be shared with
    3204              :    expressions in the instruction stream.
    3205              : 
    3206              :    Note that reload may convert pseudo registers into memories in-place.
    3207              :    Pseudo registers are always shared, but MEMs never are.  Thus if we
    3208              :    reset the used flags on MEMs in the instruction stream, we must set
    3209              :    them again on MEMs that appear in DECL_RTLs.  */
    3210              : 
    3211              : static void
    3212     15976698 : set_used_decls (tree blk)
    3213              : {
    3214     15976698 :   tree t;
    3215              : 
    3216              :   /* Mark decls.  */
    3217     34555131 :   for (t = BLOCK_VARS (blk); t; t = DECL_CHAIN (t))
    3218     18578433 :     if (DECL_RTL_SET_P (t))
    3219      2278238 :       set_used_flags (DECL_RTL (t));
    3220              : 
    3221              :   /* Now process sub-blocks.  */
    3222     30465026 :   for (t = BLOCK_SUBBLOCKS (blk); t; t = BLOCK_CHAIN (t))
    3223     14488328 :     set_used_decls (t);
    3224     15976698 : }
    3225              : 
    3226              : /* Mark ORIG as in use, and return a copy of it if it was already in use.
    3227              :    Recursively does the same for subexpressions.  Uses
    3228              :    copy_rtx_if_shared_1 to reduce stack space.  */
    3229              : 
    3230              : rtx
    3231    609597219 : copy_rtx_if_shared (rtx orig)
    3232              : {
    3233    609597219 :   copy_rtx_if_shared_1 (&orig);
    3234    609597219 :   return orig;
    3235              : }
    3236              : 
    3237              : /* Mark *ORIG1 as in use, and set it to a copy of it if it was already in
    3238              :    use.  Recursively does the same for subexpressions.  */
    3239              : 
    3240              : static void
    3241   1074641554 : copy_rtx_if_shared_1 (rtx *orig1)
    3242              : {
    3243   1074641554 :   rtx x;
    3244   1074641554 :   int i;
    3245   1074641554 :   enum rtx_code code;
    3246   1074641554 :   rtx *last_ptr;
    3247   1074641554 :   const char *format_ptr;
    3248   1074641554 :   int copied = 0;
    3249   1776823834 :   int length;
    3250              : 
    3251              :   /* Repeat is used to turn tail-recursion into iteration.  */
    3252   1776823834 : repeat:
    3253   1776823834 :   x = *orig1;
    3254              : 
    3255   1776823834 :   if (x == 0)
    3256              :     return;
    3257              : 
    3258   1464077271 :   code = GET_CODE (x);
    3259              : 
    3260              :   /* These types may be freely shared.  */
    3261              : 
    3262   1464077271 :   switch (code)
    3263              :     {
    3264              :     case REG:
    3265              :     case DEBUG_EXPR:
    3266              :     case VALUE:
    3267              :     CASE_CONST_ANY:
    3268              :     case SYMBOL_REF:
    3269              :     case LABEL_REF:
    3270              :     case CODE_LABEL:
    3271              :     case PC:
    3272              :     case RETURN:
    3273              :     case SIMPLE_RETURN:
    3274              :     case SCRATCH:
    3275              :       /* SCRATCH must be shared because they represent distinct values.  */
    3276              :       return;
    3277     60276596 :     case CLOBBER:
    3278              :       /* Share clobbers of hard registers, but do not share pseudo reg
    3279              :          clobbers or clobbers of hard registers that originated as pseudos.
    3280              :          This is needed to allow safe register renaming.  */
    3281     60276596 :       if (REG_P (XEXP (x, 0))
    3282     27289905 :           && HARD_REGISTER_NUM_P (REGNO (XEXP (x, 0)))
    3283     87395324 :           && HARD_REGISTER_NUM_P (ORIGINAL_REGNO (XEXP (x, 0))))
    3284              :         return;
    3285              :       break;
    3286              : 
    3287      5577917 :     case CONST:
    3288      5577917 :       if (shared_const_p (x))
    3289              :         return;
    3290              :       break;
    3291              : 
    3292              :     case DEBUG_INSN:
    3293              :     case INSN:
    3294              :     case JUMP_INSN:
    3295              :     case CALL_INSN:
    3296              :     case NOTE:
    3297              :     case BARRIER:
    3298              :       /* The chain of insns is not being copied.  */
    3299              :       return;
    3300              : 
    3301              :     default:
    3302              :       break;
    3303              :     }
    3304              : 
    3305              :   /* This rtx may not be shared.  If it has already been seen,
    3306              :      replace it with a copy of itself.  */
    3307              : 
    3308    727478969 :   if (RTX_FLAG (x, used))
    3309              :     {
    3310      4813199 :       x = shallow_copy_rtx (x);
    3311      4813199 :       copied = 1;
    3312              :     }
    3313    727478969 :   RTX_FLAG (x, used) = 1;
    3314              : 
    3315              :   /* Now scan the subexpressions recursively.
    3316              :      We can store any replaced subexpressions directly into X
    3317              :      since we know X is not shared!  Any vectors in X
    3318              :      must be copied if X was copied.  */
    3319              : 
    3320    727478969 :   format_ptr = GET_RTX_FORMAT (code);
    3321    727478969 :   length = GET_RTX_LENGTH (code);
    3322    727478969 :   last_ptr = NULL;
    3323              : 
    3324   2054444447 :   for (i = 0; i < length; i++)
    3325              :     {
    3326   1326965478 :       switch (*format_ptr++)
    3327              :         {
    3328   1105823057 :         case 'e':
    3329   1105823057 :           if (last_ptr)
    3330    434260157 :             copy_rtx_if_shared_1 (last_ptr);
    3331   1105823057 :           last_ptr = &XEXP (x, i);
    3332   1105823057 :           break;
    3333              : 
    3334     31361849 :         case 'E':
    3335     31361849 :           if (XVEC (x, i) != NULL)
    3336              :             {
    3337     31361849 :               int j;
    3338     31361849 :               int len = XVECLEN (x, i);
    3339              : 
    3340              :               /* Copy the vector iff I copied the rtx and the length
    3341              :                  is nonzero.  */
    3342     31361849 :               if (copied && len > 0)
    3343         1487 :                 XVEC (x, i) = gen_rtvec_v (len, XVEC (x, i)->elem);
    3344              : 
    3345              :               /* Call recursively on all inside the vector.  */
    3346     92765407 :               for (j = 0; j < len; j++)
    3347              :                 {
    3348     61403558 :                   if (last_ptr)
    3349     30784178 :                     copy_rtx_if_shared_1 (last_ptr);
    3350     61403558 :                   last_ptr = &XVECEXP (x, i, j);
    3351              :                 }
    3352              :             }
    3353              :           break;
    3354              :         }
    3355              :     }
    3356    727478969 :   *orig1 = x;
    3357    727478969 :   if (last_ptr)
    3358              :     {
    3359    702182280 :       orig1 = last_ptr;
    3360    702182280 :       goto repeat;
    3361              :     }
    3362              : }
    3363              : 
    3364              : /* Set the USED bit in X and its non-shareable subparts to FLAG.  */
    3365              : 
    3366              : static void
    3367  77554299610 : mark_used_flags (rtx x, int flag)
    3368              : {
    3369  >12065*10^7 :   int i, j;
    3370  >12065*10^7 :   enum rtx_code code;
    3371  >12065*10^7 :   const char *format_ptr;
    3372  >12065*10^7 :   int length;
    3373              : 
    3374              :   /* Repeat is used to turn tail-recursion into iteration.  */
    3375  >12065*10^7 : repeat:
    3376  >12065*10^7 :   if (x == 0)
    3377              :     return;
    3378              : 
    3379  >10185*10^7 :   code = GET_CODE (x);
    3380              : 
    3381              :   /* These types may be freely shared so we needn't do any resetting
    3382              :      for them.  */
    3383              : 
    3384  >10185*10^7 :   switch (code)
    3385              :     {
    3386              :     case REG:
    3387              :     case DEBUG_EXPR:
    3388              :     case VALUE:
    3389              :     CASE_CONST_ANY:
    3390              :     case SYMBOL_REF:
    3391              :     case CODE_LABEL:
    3392              :     case PC:
    3393              :     case RETURN:
    3394              :     case SIMPLE_RETURN:
    3395              :       return;
    3396              : 
    3397              :     case DEBUG_INSN:
    3398              :     case INSN:
    3399              :     case JUMP_INSN:
    3400              :     case CALL_INSN:
    3401              :     case NOTE:
    3402              :     case LABEL_REF:
    3403              :     case BARRIER:
    3404              :       /* The chain of insns is not being copied.  */
    3405              :       return;
    3406              : 
    3407  52555145213 :     default:
    3408  52555145213 :       break;
    3409              :     }
    3410              : 
    3411  52555145213 :   RTX_FLAG (x, used) = flag;
    3412              : 
    3413  52555145213 :   format_ptr = GET_RTX_FORMAT (code);
    3414  52555145213 :   length = GET_RTX_LENGTH (code);
    3415              : 
    3416  >10382*10^7 :   for (i = 0; i < length; i++)
    3417              :     {
    3418  94372415725 :       switch (*format_ptr++)
    3419              :         {
    3420  80387367060 :         case 'e':
    3421  80387367060 :           if (i == length-1)
    3422              :             {
    3423  43100443581 :               x = XEXP (x, i);
    3424  43100443581 :               goto repeat;
    3425              :             }
    3426  37286923479 :           mark_used_flags (XEXP (x, i), flag);
    3427  37286923479 :           break;
    3428              : 
    3429              :         case 'E':
    3430   5535461411 :           for (j = 0; j < XVECLEN (x, i); j++)
    3431   3685491521 :             mark_used_flags (XVECEXP (x, i, j), flag);
    3432              :           break;
    3433              :         }
    3434              :     }
    3435              : }
    3436              : 
    3437              : /* Clear all the USED bits in X to allow copy_rtx_if_shared to be used
    3438              :    to look for shared sub-parts.  */
    3439              : 
    3440              : void
    3441  36574386048 : reset_used_flags (rtx x)
    3442              : {
    3443  36574386048 :   mark_used_flags (x, 0);
    3444  36574386048 : }
    3445              : 
    3446              : /* Set all the USED bits in X to allow copy_rtx_if_shared to be used
    3447              :    to look for shared sub-parts.  */
    3448              : 
    3449              : void
    3450      7498562 : set_used_flags (rtx x)
    3451              : {
    3452      7498562 :   mark_used_flags (x, 1);
    3453      7498562 : }
    3454              : 
    3455              : /* Copy X if necessary so that it won't be altered by changes in OTHER.
    3456              :    Return X or the rtx for the pseudo reg the value of X was copied into.
    3457              :    OTHER must be valid as a SET_DEST.  */
    3458              : 
    3459              : rtx
    3460            0 : make_safe_from (rtx x, rtx other)
    3461              : {
    3462            0 :   while (1)
    3463            0 :     switch (GET_CODE (other))
    3464              :       {
    3465            0 :       case SUBREG:
    3466            0 :         other = SUBREG_REG (other);
    3467            0 :         break;
    3468            0 :       case STRICT_LOW_PART:
    3469            0 :       case SIGN_EXTEND:
    3470            0 :       case ZERO_EXTEND:
    3471            0 :         other = XEXP (other, 0);
    3472            0 :         break;
    3473            0 :       default:
    3474            0 :         goto done;
    3475              :       }
    3476            0 :  done:
    3477            0 :   if ((MEM_P (other)
    3478            0 :        && ! CONSTANT_P (x)
    3479            0 :        && !REG_P (x)
    3480            0 :        && GET_CODE (x) != SUBREG)
    3481            0 :       || (REG_P (other)
    3482            0 :           && (REGNO (other) < FIRST_PSEUDO_REGISTER
    3483            0 :               || reg_mentioned_p (other, x))))
    3484              :     {
    3485            0 :       rtx temp = gen_reg_rtx (GET_MODE (x));
    3486            0 :       emit_move_insn (temp, x);
    3487            0 :       return temp;
    3488              :     }
    3489              :   return x;
    3490              : }
    3491              : 
    3492              : /* Emission of insns (adding them to the doubly-linked list).  */
    3493              : 
    3494              : /* Return the last insn emitted, even if it is in a sequence now pushed.  */
    3495              : 
    3496              : rtx_insn *
    3497            0 : get_last_insn_anywhere (void)
    3498              : {
    3499            0 :   struct sequence_stack *seq;
    3500            0 :   for (seq = get_current_sequence (); seq; seq = seq->next)
    3501            0 :     if (seq->last != 0)
    3502              :       return seq->last;
    3503              :   return 0;
    3504              : }
    3505              : 
    3506              : /* Return the first nonnote insn emitted in current sequence or current
    3507              :    function.  This routine looks inside SEQUENCEs.  */
    3508              : 
    3509              : rtx_insn *
    3510            0 : get_first_nonnote_insn (void)
    3511              : {
    3512            0 :   rtx_insn *insn = get_insns ();
    3513              : 
    3514            0 :   if (insn)
    3515              :     {
    3516            0 :       if (NOTE_P (insn))
    3517            0 :         for (insn = next_insn (insn);
    3518            0 :              insn && NOTE_P (insn);
    3519            0 :              insn = next_insn (insn))
    3520            0 :           continue;
    3521              :       else
    3522              :         {
    3523            0 :           if (NONJUMP_INSN_P (insn)
    3524            0 :               && GET_CODE (PATTERN (insn)) == SEQUENCE)
    3525            0 :             insn = as_a <rtx_sequence *> (PATTERN (insn))->insn (0);
    3526              :         }
    3527              :     }
    3528              : 
    3529            0 :   return insn;
    3530              : }
    3531              : 
    3532              : /* Return the last nonnote insn emitted in current sequence or current
    3533              :    function.  This routine looks inside SEQUENCEs.  */
    3534              : 
    3535              : rtx_insn *
    3536            0 : get_last_nonnote_insn (void)
    3537              : {
    3538            0 :   rtx_insn *insn = get_last_insn ();
    3539              : 
    3540            0 :   if (insn)
    3541              :     {
    3542            0 :       if (NOTE_P (insn))
    3543            0 :         for (insn = previous_insn (insn);
    3544            0 :              insn && NOTE_P (insn);
    3545            0 :              insn = previous_insn (insn))
    3546            0 :           continue;
    3547              :       else
    3548              :         {
    3549            0 :           if (NONJUMP_INSN_P (insn))
    3550            0 :             if (rtx_sequence *seq = dyn_cast <rtx_sequence *> (PATTERN (insn)))
    3551            0 :               insn = seq->insn (seq->len () - 1);
    3552              :         }
    3553              :     }
    3554              : 
    3555            0 :   return insn;
    3556              : }
    3557              : 
    3558              : /* Return the number of actual (non-debug) insns emitted in this
    3559              :    function.  */
    3560              : 
    3561              : int
    3562      2012461 : get_max_insn_count (void)
    3563              : {
    3564      2012461 :   int n = cur_insn_uid;
    3565              : 
    3566              :   /* The table size must be stable across -g, to avoid codegen
    3567              :      differences due to debug insns, and not be affected by
    3568              :      -fmin-insn-uid, to avoid excessive table size and to simplify
    3569              :      debugging of -fcompare-debug failures.  */
    3570      2012461 :   if (cur_debug_insn_uid > param_min_nondebug_insn_uid)
    3571      2012461 :     n -= cur_debug_insn_uid;
    3572              :   else
    3573            0 :     n -= param_min_nondebug_insn_uid;
    3574              : 
    3575      2012461 :   return n;
    3576              : }
    3577              : 
    3578              : 
    3579              : /* Return the next insn.  If it is a SEQUENCE, return the first insn
    3580              :    of the sequence.  */
    3581              : 
    3582              : rtx_insn *
    3583    126240849 : next_insn (rtx_insn *insn)
    3584              : {
    3585    126240849 :   if (insn)
    3586              :     {
    3587    126240849 :       insn = NEXT_INSN (insn);
    3588    125935676 :       if (insn && NONJUMP_INSN_P (insn)
    3589    140360319 :           && GET_CODE (PATTERN (insn)) == SEQUENCE)
    3590            0 :         insn = as_a <rtx_sequence *> (PATTERN (insn))->insn (0);
    3591              :     }
    3592              : 
    3593    126240849 :   return insn;
    3594              : }
    3595              : 
    3596              : /* Return the previous insn.  If it is a SEQUENCE, return the last insn
    3597              :    of the sequence.  */
    3598              : 
    3599              : rtx_insn *
    3600        71436 : previous_insn (rtx_insn *insn)
    3601              : {
    3602        71436 :   if (insn)
    3603              :     {
    3604        71436 :       insn = PREV_INSN (insn);
    3605        71436 :       if (insn && NONJUMP_INSN_P (insn))
    3606         8491 :         if (rtx_sequence *seq = dyn_cast <rtx_sequence *> (PATTERN (insn)))
    3607            0 :           insn = seq->insn (seq->len () - 1);
    3608              :     }
    3609              : 
    3610        71436 :   return insn;
    3611              : }
    3612              : 
    3613              : /* Return the next insn after INSN that is not a NOTE.  This routine does not
    3614              :    look inside SEQUENCEs.  */
    3615              : 
    3616              : rtx_insn *
    3617       549264 : next_nonnote_insn (rtx_insn *insn)
    3618              : {
    3619       572976 :   while (insn)
    3620              :     {
    3621       572976 :       insn = NEXT_INSN (insn);
    3622       572976 :       if (insn == 0 || !NOTE_P (insn))
    3623              :         break;
    3624              :     }
    3625              : 
    3626       549264 :   return insn;
    3627              : }
    3628              : 
    3629              : /* Return the next insn after INSN that is not a DEBUG_INSN.  This
    3630              :    routine does not look inside SEQUENCEs.  */
    3631              : 
    3632              : rtx_insn *
    3633      5969452 : next_nondebug_insn (rtx_insn *insn)
    3634              : {
    3635      8048407 :   while (insn)
    3636              :     {
    3637      8048407 :       insn = NEXT_INSN (insn);
    3638      8048407 :       if (insn == 0 || !DEBUG_INSN_P (insn))
    3639              :         break;
    3640              :     }
    3641              : 
    3642      5969452 :   return insn;
    3643              : }
    3644              : 
    3645              : /* Return the previous insn before INSN that is not a NOTE.  This routine does
    3646              :    not look inside SEQUENCEs.  */
    3647              : 
    3648              : rtx_insn *
    3649     88779405 : prev_nonnote_insn (rtx_insn *insn)
    3650              : {
    3651     93627998 :   while (insn)
    3652              :     {
    3653     93627998 :       insn = PREV_INSN (insn);
    3654     93627998 :       if (insn == 0 || !NOTE_P (insn))
    3655              :         break;
    3656              :     }
    3657              : 
    3658     88779405 :   return insn;
    3659              : }
    3660              : 
    3661              : /* Return the previous insn before INSN that is not a DEBUG_INSN.
    3662              :    This routine does not look inside SEQUENCEs.  */
    3663              : 
    3664              : rtx_insn *
    3665      1968438 : prev_nondebug_insn (rtx_insn *insn)
    3666              : {
    3667      4113468 :   while (insn)
    3668              :     {
    3669      4113468 :       insn = PREV_INSN (insn);
    3670      4113468 :       if (insn == 0 || !DEBUG_INSN_P (insn))
    3671              :         break;
    3672              :     }
    3673              : 
    3674      1968438 :   return insn;
    3675              : }
    3676              : 
    3677              : /* Return the next insn after INSN that is not a NOTE nor DEBUG_INSN.
    3678              :    This routine does not look inside SEQUENCEs.  */
    3679              : 
    3680              : rtx_insn *
    3681     51098457 : next_nonnote_nondebug_insn (rtx_insn *insn)
    3682              : {
    3683     68864826 :   while (insn)
    3684              :     {
    3685     68864826 :       insn = NEXT_INSN (insn);
    3686     68864826 :       if (insn == 0 || (!NOTE_P (insn) && !DEBUG_INSN_P (insn)))
    3687              :         break;
    3688              :     }
    3689              : 
    3690     51098457 :   return insn;
    3691              : }
    3692              : 
    3693              : /* Return the next insn after INSN that is not a NOTE nor DEBUG_INSN,
    3694              :    but stop the search before we enter another basic block.  This
    3695              :    routine does not look inside SEQUENCEs.
    3696              :    NOTE: This can potentially bleed into next BB. If current insn is
    3697              :          last insn of BB, followed by a code_label before the start of
    3698              :          the next BB, code_label will be returned. But this is the
    3699              :          behavior rest of gcc assumes/relies on e.g. get_last_bb_insn.  */
    3700              : 
    3701              : rtx_insn *
    3702      7184981 : next_nonnote_nondebug_insn_bb (rtx_insn *insn)
    3703              : {
    3704      7215822 :   while (insn)
    3705              :     {
    3706      7215822 :       insn = NEXT_INSN (insn);
    3707      7215822 :       if (insn == 0)
    3708              :         break;
    3709      6992406 :       if (DEBUG_INSN_P (insn))
    3710            0 :         continue;
    3711      6992406 :       if (!NOTE_P (insn))
    3712              :         break;
    3713      2053782 :       if (NOTE_INSN_BASIC_BLOCK_P (insn))
    3714              :         return NULL;
    3715              :     }
    3716              : 
    3717              :   return insn;
    3718              : }
    3719              : 
    3720              : /* Return the previous insn before INSN that is not a NOTE nor DEBUG_INSN.
    3721              :    This routine does not look inside SEQUENCEs.  */
    3722              : 
    3723              : rtx_insn *
    3724    119937076 : prev_nonnote_nondebug_insn (rtx_insn *insn)
    3725              : {
    3726    221696790 :   while (insn)
    3727              :     {
    3728    221696790 :       insn = PREV_INSN (insn);
    3729    221696790 :       if (insn == 0 || (!NOTE_P (insn) && !DEBUG_INSN_P (insn)))
    3730              :         break;
    3731              :     }
    3732              : 
    3733    119937076 :   return insn;
    3734              : }
    3735              : 
    3736              : /* Return the previous insn before INSN that is not a NOTE nor
    3737              :    DEBUG_INSN, but stop the search before we enter another basic
    3738              :    block.  This routine does not look inside SEQUENCEs.  */
    3739              : 
    3740              : rtx_insn *
    3741     68781330 : prev_nonnote_nondebug_insn_bb (rtx_insn *insn)
    3742              : {
    3743    132334561 :   while (insn)
    3744              :     {
    3745    132334561 :       insn = PREV_INSN (insn);
    3746    132334561 :       if (insn == 0)
    3747              :         break;
    3748    132333971 :       if (DEBUG_INSN_P (insn))
    3749     54189621 :         continue;
    3750     78144350 :       if (!NOTE_P (insn))
    3751              :         break;
    3752     20958435 :       if (NOTE_INSN_BASIC_BLOCK_P (insn))
    3753              :         return NULL;
    3754              :     }
    3755              : 
    3756              :   return insn;
    3757              : }
    3758              : 
    3759              : /* Return the next INSN, CALL_INSN, JUMP_INSN or DEBUG_INSN after INSN;
    3760              :    or 0, if there is none.  This routine does not look inside
    3761              :    SEQUENCEs.  */
    3762              : 
    3763              : rtx_insn *
    3764      3997113 : next_real_insn (rtx_insn *insn)
    3765              : {
    3766      4055865 :   while (insn)
    3767              :     {
    3768      4055865 :       insn = NEXT_INSN (insn);
    3769      4055865 :       if (insn == 0 || INSN_P (insn))
    3770              :         break;
    3771              :     }
    3772              : 
    3773      3997113 :   return insn;
    3774              : }
    3775              : 
    3776              : /* Return the last INSN, CALL_INSN, JUMP_INSN or DEBUG_INSN before INSN;
    3777              :    or 0, if there is none.  This routine does not look inside
    3778              :    SEQUENCEs.  */
    3779              : 
    3780              : rtx_insn *
    3781       969251 : prev_real_insn (rtx_insn *insn)
    3782              : {
    3783      2861669 :   while (insn)
    3784              :     {
    3785      2861669 :       insn = PREV_INSN (insn);
    3786      2861669 :       if (insn == 0 || INSN_P (insn))
    3787              :         break;
    3788              :     }
    3789              : 
    3790       969251 :   return insn;
    3791              : }
    3792              : 
    3793              : /* Return the next INSN, CALL_INSN or JUMP_INSN after INSN;
    3794              :    or 0, if there is none.  This routine does not look inside
    3795              :    SEQUENCEs.  */
    3796              : 
    3797              : rtx_insn *
    3798            0 : next_real_nondebug_insn (rtx uncast_insn)
    3799              : {
    3800            0 :   rtx_insn *insn = safe_as_a <rtx_insn *> (uncast_insn);
    3801              : 
    3802            0 :   while (insn)
    3803              :     {
    3804            0 :       insn = NEXT_INSN (insn);
    3805            0 :       if (insn == 0 || NONDEBUG_INSN_P (insn))
    3806              :         break;
    3807              :     }
    3808              : 
    3809            0 :   return insn;
    3810              : }
    3811              : 
    3812              : /* Return the last INSN, CALL_INSN or JUMP_INSN before INSN;
    3813              :    or 0, if there is none.  This routine does not look inside
    3814              :    SEQUENCEs.  */
    3815              : 
    3816              : rtx_insn *
    3817      4942211 : prev_real_nondebug_insn (rtx_insn *insn)
    3818              : {
    3819     15059433 :   while (insn)
    3820              :     {
    3821     15059433 :       insn = PREV_INSN (insn);
    3822     15059433 :       if (insn == 0 || NONDEBUG_INSN_P (insn))
    3823              :         break;
    3824              :     }
    3825              : 
    3826      4942211 :   return insn;
    3827              : }
    3828              : 
    3829              : /* Return the last CALL_INSN in the current list, or 0 if there is none.
    3830              :    This routine does not look inside SEQUENCEs.  */
    3831              : 
    3832              : rtx_call_insn *
    3833     11906955 : last_call_insn (void)
    3834              : {
    3835     11906955 :   rtx_insn *insn;
    3836              : 
    3837     12033557 :   for (insn = get_last_insn ();
    3838     12033557 :        insn && !CALL_P (insn);
    3839       126602 :        insn = PREV_INSN (insn))
    3840              :     ;
    3841              : 
    3842     11906955 :   return safe_as_a <rtx_call_insn *> (insn);
    3843              : }
    3844              : 
    3845              : bool
    3846   1116842598 : active_insn_p (const rtx_insn *insn)
    3847              : {
    3848   1116842598 :   return (CALL_P (insn) || JUMP_P (insn)
    3849   1116842598 :           || JUMP_TABLE_DATA_P (insn) /* FIXME */
    3850   1116842598 :           || (NONJUMP_INSN_P (insn)
    3851    673241176 :               && (! reload_completed
    3852    478744407 :                   || (GET_CODE (PATTERN (insn)) != USE
    3853    477159058 :                       && GET_CODE (PATTERN (insn)) != CLOBBER))));
    3854              : }
    3855              : 
    3856              : /* Find the next insn after INSN that really does something.  This routine
    3857              :    does not look inside SEQUENCEs.  After reload this also skips over
    3858              :    standalone USE and CLOBBER insn.  */
    3859              : 
    3860              : rtx_insn *
    3861    111183912 : next_active_insn (rtx_insn *insn)
    3862              : {
    3863    245312189 :   while (insn)
    3864              :     {
    3865    245312189 :       insn = NEXT_INSN (insn);
    3866    356496101 :       if (insn == 0 || active_insn_p (insn))
    3867              :         break;
    3868              :     }
    3869              : 
    3870    111183912 :   return insn;
    3871              : }
    3872              : 
    3873              : /* Find the last insn before INSN that really does something.  This routine
    3874              :    does not look inside SEQUENCEs.  After reload this also skips over
    3875              :    standalone USE and CLOBBER insn.  */
    3876              : 
    3877              : rtx_insn *
    3878        45109 : prev_active_insn (rtx_insn *insn)
    3879              : {
    3880       134455 :   while (insn)
    3881              :     {
    3882       134455 :       insn = PREV_INSN (insn);
    3883       179564 :       if (insn == 0 || active_insn_p (insn))
    3884              :         break;
    3885              :     }
    3886              : 
    3887        45109 :   return insn;
    3888              : }
    3889              : 
    3890              : /* Find a RTX_AUTOINC class rtx which matches DATA.  */
    3891              : 
    3892              : static int
    3893            0 : find_auto_inc (const_rtx x, const_rtx reg)
    3894              : {
    3895            0 :   subrtx_iterator::array_type array;
    3896            0 :   FOR_EACH_SUBRTX (iter, array, x, NONCONST)
    3897              :     {
    3898            0 :       const_rtx x = *iter;
    3899            0 :       if (GET_RTX_CLASS (GET_CODE (x)) == RTX_AUTOINC
    3900            0 :           && rtx_equal_p (reg, XEXP (x, 0)))
    3901            0 :         return true;
    3902              :     }
    3903            0 :   return false;
    3904            0 : }
    3905              : 
    3906              : /* Increment the label uses for all labels present in rtx.  */
    3907              : 
    3908              : static void
    3909     55596495 : mark_label_nuses (rtx x)
    3910              : {
    3911     55596495 :   enum rtx_code code;
    3912     55596495 :   int i, j;
    3913     55596495 :   const char *fmt;
    3914              : 
    3915     55596495 :   code = GET_CODE (x);
    3916     55596500 :   if (code == LABEL_REF && LABEL_P (label_ref_label (x)))
    3917            1 :     LABEL_NUSES (label_ref_label (x))++;
    3918              : 
    3919     55596495 :   fmt = GET_RTX_FORMAT (code);
    3920    137308526 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    3921              :     {
    3922     81712031 :       if (fmt[i] == 'e')
    3923     43752832 :         mark_label_nuses (XEXP (x, i));
    3924     37959199 :       else if (fmt[i] == 'E')
    3925      3754085 :         for (j = XVECLEN (x, i) - 1; j >= 0; j--)
    3926      2599821 :           mark_label_nuses (XVECEXP (x, i, j));
    3927              :     }
    3928     55596495 : }
    3929              : 
    3930              : 
    3931              : /* Try splitting insns that can be split for better scheduling.
    3932              :    PAT is the pattern which might split.
    3933              :    TRIAL is the insn providing PAT.
    3934              :    LAST is nonzero if we should return the last insn of the sequence produced.
    3935              : 
    3936              :    If this routine succeeds in splitting, it returns the first or last
    3937              :    replacement insn depending on the value of LAST.  Otherwise, it
    3938              :    returns TRIAL.  If the insn to be returned can be split, it will be.  */
    3939              : 
    3940              : rtx_insn *
    3941    381776348 : try_split (rtx pat, rtx_insn *trial, int last)
    3942              : {
    3943    381776348 :   rtx_insn *before, *after;
    3944    381776348 :   rtx note;
    3945    381776348 :   rtx_insn *seq, *tem;
    3946    381776348 :   profile_probability probability;
    3947    381776348 :   rtx_insn *insn_last, *insn;
    3948    381776348 :   int njumps = 0;
    3949    381776348 :   rtx_insn *call_insn = NULL;
    3950              : 
    3951    381776348 :   if (any_condjump_p (trial)
    3952    381776348 :       && (note = find_reg_note (trial, REG_BR_PROB, 0)))
    3953     14562063 :     split_branch_probability
    3954     14562063 :       = profile_probability::from_reg_br_prob_note (XINT (note, 0));
    3955              :   else
    3956    367214285 :     split_branch_probability = profile_probability::uninitialized ();
    3957              : 
    3958    381776348 :   probability = split_branch_probability;
    3959              : 
    3960    381776348 :   seq = split_insns (pat, trial);
    3961              : 
    3962    381776348 :   split_branch_probability = profile_probability::uninitialized ();
    3963              : 
    3964    381776348 :   if (!seq)
    3965              :     return trial;
    3966              : 
    3967              :   int split_insn_count = 0;
    3968              :   /* Avoid infinite loop if any insn of the result matches
    3969              :      the original pattern.  */
    3970              :   insn_last = seq;
    3971      9259555 :   while (1)
    3972              :     {
    3973      9259555 :       if (INSN_P (insn_last)
    3974      9259555 :           && rtx_equal_p (PATTERN (insn_last), pat))
    3975              :         return trial;
    3976      9258044 :       split_insn_count++;
    3977      9258044 :       if (!NEXT_INSN (insn_last))
    3978              :         break;
    3979              :       insn_last = NEXT_INSN (insn_last);
    3980              :     }
    3981              : 
    3982              :   /* We're not good at redistributing frame information if
    3983              :      the split occurs before reload or if it results in more
    3984              :      than one insn.  */
    3985      6153864 :   if (RTX_FRAME_RELATED_P (trial))
    3986              :     {
    3987           24 :       if (!reload_completed || split_insn_count != 1)
    3988              :         return trial;
    3989              : 
    3990           24 :       rtx_insn *new_insn = seq;
    3991           24 :       rtx_insn *old_insn = trial;
    3992           24 :       copy_frame_info_to_split_insn (old_insn, new_insn);
    3993              :     }
    3994              : 
    3995              :   /* We will be adding the new sequence to the function.  The splitters
    3996              :      may have introduced invalid RTL sharing, so unshare the sequence now.  */
    3997      6153864 :   unshare_all_rtl_in_chain (seq);
    3998              : 
    3999              :   /* Mark labels and copy flags.  */
    4000     15411908 :   for (insn = insn_last; insn ; insn = PREV_INSN (insn))
    4001              :     {
    4002      9258044 :       if (JUMP_P (insn))
    4003              :         {
    4004         6313 :           if (JUMP_P (trial))
    4005         5483 :             CROSSING_JUMP_P (insn) = CROSSING_JUMP_P (trial);
    4006         6313 :           mark_jump_label (PATTERN (insn), insn, 0);
    4007         6313 :           njumps++;
    4008         6313 :           if (probability.initialized_p ()
    4009         5453 :               && any_condjump_p (insn)
    4010        11766 :               && !find_reg_note (insn, REG_BR_PROB, 0))
    4011              :             {
    4012              :               /* We can preserve the REG_BR_PROB notes only if exactly
    4013              :                  one jump is created, otherwise the machine description
    4014              :                  is responsible for this step using
    4015              :                  split_branch_probability variable.  */
    4016         5453 :               gcc_assert (njumps == 1);
    4017         5453 :               add_reg_br_prob_note (insn, probability);
    4018              :             }
    4019              :         }
    4020              :     }
    4021              : 
    4022              :   /* If we are splitting a CALL_INSN, look for the CALL_INSN
    4023              :      in SEQ and copy any additional information across.  */
    4024      6153864 :   if (CALL_P (trial))
    4025              :     {
    4026            0 :       for (insn = insn_last; insn ; insn = PREV_INSN (insn))
    4027            0 :         if (CALL_P (insn))
    4028              :           {
    4029            0 :             gcc_assert (call_insn == NULL_RTX);
    4030            0 :             call_insn = insn;
    4031              : 
    4032              :             /* Add the old CALL_INSN_FUNCTION_USAGE to whatever the
    4033              :                target may have explicitly specified.  */
    4034            0 :             rtx *p = &CALL_INSN_FUNCTION_USAGE (insn);
    4035            0 :             while (*p)
    4036            0 :               p = &XEXP (*p, 1);
    4037            0 :             *p = CALL_INSN_FUNCTION_USAGE (trial);
    4038              : 
    4039              :             /* Preserve the ABI information from the original call.  */
    4040            0 :             CALL_INSN_ABI_ID (insn) = CALL_INSN_ABI_ID (trial);
    4041              : 
    4042              :             /* If the old call was a sibling call, the new one must
    4043              :                be too.  */
    4044            0 :             SIBLING_CALL_P (insn) = SIBLING_CALL_P (trial);
    4045              :           }
    4046              :     }
    4047              : 
    4048              :   /* Copy notes, particularly those related to the CFG.  */
    4049      7960037 :   for (note = REG_NOTES (trial); note; note = XEXP (note, 1))
    4050              :     {
    4051      1806173 :       switch (REG_NOTE_KIND (note))
    4052              :         {
    4053         2806 :         case REG_EH_REGION:
    4054         2806 :           copy_reg_eh_region_note_backward (note, insn_last, NULL);
    4055         2806 :           break;
    4056              : 
    4057              :         case REG_NORETURN:
    4058              :         case REG_SETJMP:
    4059              :         case REG_TM:
    4060              :         case REG_CALL_NOCF_CHECK:
    4061              :         case REG_CALL_ARG_LOCATION:
    4062            0 :           for (insn = insn_last; insn != NULL_RTX; insn = PREV_INSN (insn))
    4063              :             {
    4064            0 :               if (CALL_P (insn))
    4065            0 :                 add_reg_note (insn, REG_NOTE_KIND (note), XEXP (note, 0));
    4066              :             }
    4067              :           break;
    4068              : 
    4069              :         case REG_NON_LOCAL_GOTO:
    4070              :         case REG_LABEL_TARGET:
    4071            0 :           for (insn = insn_last; insn != NULL_RTX; insn = PREV_INSN (insn))
    4072              :             {
    4073            0 :               if (JUMP_P (insn))
    4074            0 :                 add_reg_note (insn, REG_NOTE_KIND (note), XEXP (note, 0));
    4075              :             }
    4076              :           break;
    4077              : 
    4078              :         case REG_INC:
    4079              :           if (!AUTO_INC_DEC)
    4080              :             break;
    4081              : 
    4082              :           for (insn = insn_last; insn != NULL_RTX; insn = PREV_INSN (insn))
    4083              :             {
    4084              :               rtx reg = XEXP (note, 0);
    4085              :               if (!FIND_REG_INC_NOTE (insn, reg)
    4086              :                   && find_auto_inc (PATTERN (insn), reg))
    4087              :                 add_reg_note (insn, REG_INC, reg);
    4088              :             }
    4089              :           break;
    4090              : 
    4091       308823 :         case REG_ARGS_SIZE:
    4092       308823 :           fixup_args_size_notes (NULL, insn_last, get_args_size (note));
    4093       308823 :           break;
    4094              : 
    4095            0 :         case REG_CALL_DECL:
    4096            0 :         case REG_UNTYPED_CALL:
    4097            0 :           gcc_assert (call_insn != NULL_RTX);
    4098            0 :           add_reg_note (call_insn, REG_NOTE_KIND (note), XEXP (note, 0));
    4099            0 :           break;
    4100              : 
    4101              :         default:
    4102              :           break;
    4103              :         }
    4104              :     }
    4105              : 
    4106              :   /* If there are LABELS inside the split insns increment the
    4107              :      usage count so we don't delete the label.  */
    4108      6153864 :   if (INSN_P (trial))
    4109              :     {
    4110              :       insn = insn_last;
    4111     15411908 :       while (insn != NULL_RTX)
    4112              :         {
    4113              :           /* JUMP_P insns have already been "marked" above.  */
    4114      9258044 :           if (NONJUMP_INSN_P (insn))
    4115      9243842 :             mark_label_nuses (PATTERN (insn));
    4116              : 
    4117      9258044 :           insn = PREV_INSN (insn);
    4118              :         }
    4119              :     }
    4120              : 
    4121      6153864 :   before = PREV_INSN (trial);
    4122      6153864 :   after = NEXT_INSN (trial);
    4123              : 
    4124      6153864 :   emit_insn_after_setloc (seq, trial, INSN_LOCATION (trial));
    4125              : 
    4126      6153864 :   delete_insn (trial);
    4127              : 
    4128              :   /* Recursively call try_split for each new insn created; by the
    4129              :      time control returns here that insn will be fully split, so
    4130              :      set LAST and continue from the insn after the one returned.
    4131              :      We can't use next_active_insn here since AFTER may be a note.
    4132              :      Ignore deleted insns, which can be occur if not optimizing.  */
    4133     21565772 :   for (tem = NEXT_INSN (before); tem != after; tem = NEXT_INSN (tem))
    4134      9258044 :     if (! tem->deleted () && INSN_P (tem))
    4135      9250155 :       tem = try_split (PATTERN (tem), tem, 1);
    4136              : 
    4137              :   /* Return either the first or the last insn, depending on which was
    4138              :      requested.  */
    4139      6153864 :   return last
    4140      6153864 :     ? (after ? PREV_INSN (after) : get_last_insn ())
    4141            0 :     : NEXT_INSN (before);
    4142              : }
    4143              : 
    4144              : /* Make and return an INSN rtx, initializing all its slots.
    4145              :    Store PATTERN in the pattern slots.  */
    4146              : 
    4147              : rtx_insn *
    4148    125352572 : make_insn_raw (rtx pattern)
    4149              : {
    4150    125352572 :   rtx_insn *insn;
    4151              : 
    4152    125352572 :   insn = as_a <rtx_insn *> (rtx_alloc (INSN));
    4153              : 
    4154    125352572 :   INSN_UID (insn) = cur_insn_uid++;
    4155    125352572 :   PATTERN (insn) = pattern;
    4156    125352572 :   INSN_CODE (insn) = -1;
    4157    125352572 :   REG_NOTES (insn) = NULL;
    4158    125352572 :   INSN_LOCATION (insn) = curr_insn_location ();
    4159    125352572 :   BLOCK_FOR_INSN (insn) = NULL;
    4160              : 
    4161              : #ifdef ENABLE_RTL_CHECKING
    4162              :   if (insn
    4163              :       && INSN_P (insn)
    4164              :       && (returnjump_p (insn)
    4165              :           || (GET_CODE (insn) == SET
    4166              :               && SET_DEST (insn) == pc_rtx)))
    4167              :     {
    4168              :       warning (0, "ICE: %<emit_insn%> used where %<emit_jump_insn%> needed:");
    4169              :       debug_rtx (insn);
    4170              :     }
    4171              : #endif
    4172              : 
    4173    125352572 :   return insn;
    4174              : }
    4175              : 
    4176              : /* Like `make_insn_raw' but make a DEBUG_INSN instead of an insn.  */
    4177              : 
    4178              : static rtx_insn *
    4179     49081293 : make_debug_insn_raw (rtx pattern)
    4180              : {
    4181     49081293 :   rtx_debug_insn *insn;
    4182              : 
    4183     49081293 :   insn = as_a <rtx_debug_insn *> (rtx_alloc (DEBUG_INSN));
    4184     49081293 :   INSN_UID (insn) = cur_debug_insn_uid++;
    4185     49081293 :   if (cur_debug_insn_uid > param_min_nondebug_insn_uid)
    4186     49081293 :     INSN_UID (insn) = cur_insn_uid++;
    4187              : 
    4188     49081293 :   PATTERN (insn) = pattern;
    4189     49081293 :   INSN_CODE (insn) = -1;
    4190     49081293 :   REG_NOTES (insn) = NULL;
    4191     49081293 :   INSN_LOCATION (insn) = curr_insn_location ();
    4192     49081293 :   BLOCK_FOR_INSN (insn) = NULL;
    4193              : 
    4194     49081293 :   return insn;
    4195              : }
    4196              : 
    4197              : /* Like `make_insn_raw' but make a JUMP_INSN instead of an insn.  */
    4198              : 
    4199              : static rtx_insn *
    4200     17884502 : make_jump_insn_raw (rtx pattern)
    4201              : {
    4202     17884502 :   rtx_jump_insn *insn;
    4203              : 
    4204     17884502 :   insn = as_a <rtx_jump_insn *> (rtx_alloc (JUMP_INSN));
    4205     17884502 :   INSN_UID (insn) = cur_insn_uid++;
    4206              : 
    4207     17884502 :   PATTERN (insn) = pattern;
    4208     17884502 :   INSN_CODE (insn) = -1;
    4209     17884502 :   REG_NOTES (insn) = NULL;
    4210     17884502 :   JUMP_LABEL (insn) = NULL;
    4211     17884502 :   INSN_LOCATION (insn) = curr_insn_location ();
    4212     17884502 :   BLOCK_FOR_INSN (insn) = NULL;
    4213              : 
    4214     17884502 :   return insn;
    4215              : }
    4216              : 
    4217              : /* Like `make_insn_raw' but make a CALL_INSN instead of an insn.  */
    4218              : 
    4219              : static rtx_insn *
    4220      6268197 : make_call_insn_raw (rtx pattern)
    4221              : {
    4222      6268197 :   rtx_call_insn *insn;
    4223              : 
    4224      6268197 :   insn = as_a <rtx_call_insn *> (rtx_alloc (CALL_INSN));
    4225      6268197 :   INSN_UID (insn) = cur_insn_uid++;
    4226              : 
    4227      6268197 :   PATTERN (insn) = pattern;
    4228      6268197 :   INSN_CODE (insn) = -1;
    4229      6268197 :   REG_NOTES (insn) = NULL;
    4230      6268197 :   CALL_INSN_FUNCTION_USAGE (insn) = NULL;
    4231      6268197 :   CALL_INSN_ABI_ID (insn) = 0;
    4232      6268197 :   INSN_LOCATION (insn) = curr_insn_location ();
    4233      6268197 :   BLOCK_FOR_INSN (insn) = NULL;
    4234              : 
    4235      6268197 :   return insn;
    4236              : }
    4237              : 
    4238              : /* Like `make_insn_raw' but make a NOTE instead of an insn.  */
    4239              : 
    4240              : static rtx_note *
    4241    161622084 : make_note_raw (enum insn_note subtype)
    4242              : {
    4243              :   /* Some notes are never created this way at all.  These notes are
    4244              :      only created by patching out insns.  */
    4245    161622084 :   gcc_assert (subtype != NOTE_INSN_DELETED_LABEL
    4246              :               && subtype != NOTE_INSN_DELETED_DEBUG_LABEL);
    4247              : 
    4248    161622084 :   rtx_note *note = as_a <rtx_note *> (rtx_alloc (NOTE));
    4249    161622084 :   INSN_UID (note) = cur_insn_uid++;
    4250    161622084 :   NOTE_KIND (note) = subtype;
    4251    161622084 :   BLOCK_FOR_INSN (note) = NULL;
    4252    161622084 :   memset (&NOTE_DATA (note), 0, sizeof (NOTE_DATA (note)));
    4253    161622084 :   return note;
    4254              : }
    4255              : 
    4256              : /* Add INSN to the end of the doubly-linked list, between PREV and NEXT.
    4257              :    INSN may be any object that can appear in the chain: INSN_P and NOTE_P objects,
    4258              :    but also BARRIERs and JUMP_TABLE_DATAs.  PREV and NEXT may be NULL.  */
    4259              : 
    4260              : static inline void
    4261    583616358 : link_insn_into_chain (rtx_insn *insn, rtx_insn *prev, rtx_insn *next)
    4262              : {
    4263    583616358 :   SET_PREV_INSN (insn) = prev;
    4264    583616358 :   SET_NEXT_INSN (insn) = next;
    4265    583616358 :   if (prev != NULL)
    4266              :     {
    4267    416641784 :       SET_NEXT_INSN (prev) = insn;
    4268    416641784 :       if (NONJUMP_INSN_P (prev) && GET_CODE (PATTERN (prev)) == SEQUENCE)
    4269              :         {
    4270            0 :           rtx_sequence *sequence = as_a <rtx_sequence *> (PATTERN (prev));
    4271            0 :           SET_NEXT_INSN (sequence->insn (sequence->len () - 1)) = insn;
    4272              :         }
    4273              :     }
    4274    583616358 :   if (next != NULL)
    4275              :     {
    4276    166067348 :       SET_PREV_INSN (next) = insn;
    4277    166067348 :       if (NONJUMP_INSN_P (next) && GET_CODE (PATTERN (next)) == SEQUENCE)
    4278              :         {
    4279            0 :           rtx_sequence *sequence = as_a <rtx_sequence *> (PATTERN (next));
    4280            0 :           SET_PREV_INSN (sequence->insn (0)) = insn;
    4281              :         }
    4282              :     }
    4283              : 
    4284    583616358 :   if (NONJUMP_INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE)
    4285              :     {
    4286            0 :       rtx_sequence *sequence = as_a <rtx_sequence *> (PATTERN (insn));
    4287            0 :       SET_PREV_INSN (sequence->insn (0)) = prev;
    4288            0 :       SET_NEXT_INSN (sequence->insn (sequence->len () - 1)) = next;
    4289              :     }
    4290    583616358 : }
    4291              : 
    4292              : /* Add INSN to the end of the doubly-linked list.
    4293              :    INSN may be an INSN, JUMP_INSN, CALL_INSN, CODE_LABEL, BARRIER or NOTE.  */
    4294              : 
    4295              : void
    4296    406477218 : add_insn (rtx_insn *insn)
    4297              : {
    4298    406477218 :   rtx_insn *prev = get_last_insn ();
    4299    406477218 :   link_insn_into_chain (insn, prev, NULL);
    4300    406477218 :   if (get_insns () == NULL)
    4301    166781639 :     set_first_insn (insn);
    4302    406477218 :   set_last_insn (insn);
    4303    406477218 : }
    4304              : 
    4305              : /* Add INSN into the doubly-linked list after insn AFTER.  */
    4306              : 
    4307              : static void
    4308     64608243 : add_insn_after_nobb (rtx_insn *insn, rtx_insn *after)
    4309              : {
    4310     64608243 :   rtx_insn *next = NEXT_INSN (after);
    4311              : 
    4312     64608243 :   gcc_assert (!optimize || !after->deleted ());
    4313              : 
    4314     64608243 :   link_insn_into_chain (insn, after, next);
    4315              : 
    4316     64608243 :   if (next == NULL)
    4317              :     {
    4318              :       struct sequence_stack *seq;
    4319              : 
    4320     11071792 :       for (seq = get_current_sequence (); seq; seq = seq->next)
    4321     11071792 :         if (after == seq->last)
    4322              :           {
    4323     11071792 :             seq->last = insn;
    4324     11071792 :             break;
    4325              :           }
    4326              :     }
    4327     64608243 : }
    4328              : 
    4329              : /* Add INSN into the doubly-linked list before insn BEFORE.  */
    4330              : 
    4331              : static void
    4332    112530897 : add_insn_before_nobb (rtx_insn *insn, rtx_insn *before)
    4333              : {
    4334    112530897 :   rtx_insn *prev = PREV_INSN (before);
    4335              : 
    4336    112530897 :   gcc_assert (!optimize || !before->deleted ());
    4337              : 
    4338    112530897 :   link_insn_into_chain (insn, prev, before);
    4339              : 
    4340    112530897 :   if (prev == NULL)
    4341              :     {
    4342              :       struct sequence_stack *seq;
    4343              : 
    4344       192935 :       for (seq = get_current_sequence (); seq; seq = seq->next)
    4345       192935 :         if (before == seq->first)
    4346              :           {
    4347       192935 :             seq->first = insn;
    4348       192935 :             break;
    4349              :           }
    4350              : 
    4351       192935 :       gcc_assert (seq);
    4352              :     }
    4353    112530897 : }
    4354              : 
    4355              : /* Like add_insn_after_nobb, but try to set BLOCK_FOR_INSN.
    4356              :    If BB is NULL, an attempt is made to infer the bb from before.
    4357              : 
    4358              :    This and the next function should be the only functions called
    4359              :    to insert an insn once delay slots have been filled since only
    4360              :    they know how to update a SEQUENCE. */
    4361              : 
    4362              : void
    4363     63273327 : add_insn_after (rtx_insn *insn, rtx_insn *after, basic_block bb)
    4364              : {
    4365     63273327 :   add_insn_after_nobb (insn, after);
    4366     63273327 :   if (!BARRIER_P (after)
    4367     63242715 :       && !BARRIER_P (insn)
    4368    118990556 :       && (bb = BLOCK_FOR_INSN (after)))
    4369              :     {
    4370     45325516 :       set_block_for_insn (insn, bb);
    4371     45325516 :       if (INSN_P (insn))
    4372       816633 :         df_insn_rescan (insn);
    4373              :       /* Should not happen as first in the BB is always
    4374              :          either NOTE or LABEL.  */
    4375     45325516 :       if (BB_END (bb) == after
    4376              :           /* Avoid clobbering of structure when creating new BB.  */
    4377      1008689 :           && !BARRIER_P (insn)
    4378      1008689 :           && !NOTE_INSN_BASIC_BLOCK_P (insn))
    4379       332527 :         BB_END (bb) = insn;
    4380              :     }
    4381     63273327 : }
    4382              : 
    4383              : /* Like add_insn_before_nobb, but try to set BLOCK_FOR_INSN.
    4384              :    If BB is NULL, an attempt is made to infer the bb from before.
    4385              : 
    4386              :    This and the previous function should be the only functions called
    4387              :    to insert an insn once delay slots have been filled since only
    4388              :    they know how to update a SEQUENCE. */
    4389              : 
    4390              : void
    4391     91130656 : add_insn_before (rtx_insn *insn, rtx_insn *before, basic_block bb)
    4392              : {
    4393     91130656 :   add_insn_before_nobb (insn, before);
    4394              : 
    4395     91130656 :   if (BARRIER_P (insn))
    4396              :     return;
    4397              : 
    4398     91130539 :   if (!bb
    4399     22351855 :       && !BARRIER_P (before))
    4400     22351854 :     bb = BLOCK_FOR_INSN (before);
    4401              : 
    4402     22351855 :   if (bb)
    4403              :     {
    4404     87481894 :       set_block_for_insn (insn, bb);
    4405     87481894 :       if (INSN_P (insn))
    4406     13070233 :         df_insn_rescan (insn);
    4407              :       /* Should not happen as first in the BB is always either NOTE or
    4408              :          LABEL.  */
    4409     87481894 :       gcc_assert (BB_HEAD (bb) != insn
    4410              :                   /* Avoid clobbering of structure when creating new BB.  */
    4411              :                   || BARRIER_P (insn)
    4412              :                   || NOTE_INSN_BASIC_BLOCK_P (insn));
    4413              :     }
    4414              : }
    4415              : 
    4416              : /* Replace insn with an deleted instruction note.  */
    4417              : 
    4418              : void
    4419     14077428 : set_insn_deleted (rtx_insn *insn)
    4420              : {
    4421     14077428 :   if (INSN_P (insn))
    4422     14077428 :     df_insn_delete (insn);
    4423     14077428 :   PUT_CODE (insn, NOTE);
    4424     14077428 :   NOTE_KIND (insn) = NOTE_INSN_DELETED;
    4425     14077428 : }
    4426              : 
    4427              : 
    4428              : /* Unlink INSN from the insn chain.
    4429              : 
    4430              :    This function knows how to handle sequences.
    4431              : 
    4432              :    This function does not invalidate data flow information associated with
    4433              :    INSN (i.e. does not call df_insn_delete).  That makes this function
    4434              :    usable for only disconnecting an insn from the chain, and re-emit it
    4435              :    elsewhere later.
    4436              : 
    4437              :    To later insert INSN elsewhere in the insn chain via add_insn and
    4438              :    similar functions, PREV_INSN and NEXT_INSN must be nullified by
    4439              :    the caller.  Nullifying them here breaks many insn chain walks.
    4440              : 
    4441              :    To really delete an insn and related DF information, use delete_insn.  */
    4442              : 
    4443              : void
    4444    133654430 : remove_insn (rtx_insn *insn)
    4445              : {
    4446    133654430 :   rtx_insn *next = NEXT_INSN (insn);
    4447    133654430 :   rtx_insn *prev = PREV_INSN (insn);
    4448    133654430 :   basic_block bb;
    4449              : 
    4450    133654430 :   if (prev)
    4451              :     {
    4452    133654169 :       SET_NEXT_INSN (prev) = next;
    4453    133654169 :       if (NONJUMP_INSN_P (prev) && GET_CODE (PATTERN (prev)) == SEQUENCE)
    4454              :         {
    4455            0 :           rtx_sequence *sequence = as_a <rtx_sequence *> (PATTERN (prev));
    4456            0 :           SET_NEXT_INSN (sequence->insn (sequence->len () - 1)) = next;
    4457              :         }
    4458              :     }
    4459              :   else
    4460              :     {
    4461              :       struct sequence_stack *seq;
    4462              : 
    4463          261 :       for (seq = get_current_sequence (); seq; seq = seq->next)
    4464          261 :         if (insn == seq->first)
    4465              :           {
    4466          261 :             seq->first = next;
    4467          261 :             break;
    4468              :           }
    4469              : 
    4470          261 :       gcc_assert (seq);
    4471              :     }
    4472              : 
    4473    133654430 :   if (next)
    4474              :     {
    4475    131549540 :       SET_PREV_INSN (next) = prev;
    4476    131549540 :       if (NONJUMP_INSN_P (next) && GET_CODE (PATTERN (next)) == SEQUENCE)
    4477              :         {
    4478            0 :           rtx_sequence *sequence = as_a <rtx_sequence *> (PATTERN (next));
    4479            0 :           SET_PREV_INSN (sequence->insn (0)) = prev;
    4480              :         }
    4481              :     }
    4482              :   else
    4483              :     {
    4484              :       struct sequence_stack *seq;
    4485              : 
    4486      2104890 :       for (seq = get_current_sequence (); seq; seq = seq->next)
    4487      2104890 :         if (insn == seq->last)
    4488              :           {
    4489      2104890 :             seq->last = prev;
    4490      2104890 :             break;
    4491              :           }
    4492              : 
    4493      2104890 :       gcc_assert (seq);
    4494              :     }
    4495              : 
    4496              :   /* Fix up basic block boundaries, if necessary.  */
    4497    133654430 :   if (!BARRIER_P (insn)
    4498    133654430 :       && (bb = BLOCK_FOR_INSN (insn)))
    4499              :     {
    4500    130677805 :       if (BB_HEAD (bb) == insn)
    4501              :         {
    4502              :           /* Never ever delete the basic block note without deleting whole
    4503              :              basic block.  */
    4504      2447744 :           gcc_assert (!NOTE_P (insn));
    4505      2447744 :           BB_HEAD (bb) = next;
    4506              :         }
    4507    130677805 :       if (BB_END (bb) == insn)
    4508     22426025 :         BB_END (bb) = prev;
    4509              :     }
    4510    133654430 : }
    4511              : 
    4512              : /* Append CALL_FUSAGE to the CALL_INSN_FUNCTION_USAGE for CALL_INSN.  */
    4513              : 
    4514              : void
    4515      6213762 : add_function_usage_to (rtx call_insn, rtx call_fusage)
    4516              : {
    4517      6213762 :   gcc_assert (call_insn && CALL_P (call_insn));
    4518              : 
    4519              :   /* Put the register usage information on the CALL.  If there is already
    4520              :      some usage information, put ours at the end.  */
    4521      6213762 :   if (CALL_INSN_FUNCTION_USAGE (call_insn))
    4522              :     {
    4523              :       rtx link;
    4524              : 
    4525      1359856 :       for (link = CALL_INSN_FUNCTION_USAGE (call_insn); XEXP (link, 1) != 0;
    4526              :            link = XEXP (link, 1))
    4527              :         ;
    4528              : 
    4529       602287 :       XEXP (link, 1) = call_fusage;
    4530              :     }
    4531              :   else
    4532      5611475 :     CALL_INSN_FUNCTION_USAGE (call_insn) = call_fusage;
    4533      6213762 : }
    4534              : 
    4535              : /* Delete all insns made since FROM.
    4536              :    FROM becomes the new last instruction.  */
    4537              : 
    4538              : void
    4539      1258286 : delete_insns_since (rtx_insn *from)
    4540              : {
    4541      1258286 :   if (from == 0)
    4542       146449 :     set_first_insn (0);
    4543              :   else
    4544      1111837 :     SET_NEXT_INSN (from) = 0;
    4545      1258286 :   set_last_insn (from);
    4546      1258286 : }
    4547              : 
    4548              : /* This function is deprecated, please use sequences instead.
    4549              : 
    4550              :    Move a consecutive bunch of insns to a different place in the chain.
    4551              :    The insns to be moved are those between FROM and TO.
    4552              :    They are moved to a new position after the insn AFTER.
    4553              :    AFTER must not be FROM or TO or any insn in between.
    4554              : 
    4555              :    This function does not know about SEQUENCEs and hence should not be
    4556              :    called after delay-slot filling has been done.  */
    4557              : 
    4558              : void
    4559      1799987 : reorder_insns_nobb (rtx_insn *from, rtx_insn *to, rtx_insn *after)
    4560              : {
    4561      1799987 :   if (flag_checking)
    4562              :     {
    4563      2383662 :       for (rtx_insn *x = from; x != to; x = NEXT_INSN (x))
    4564       583697 :         gcc_assert (after != x);
    4565      1799965 :       gcc_assert (after != to);
    4566              :     }
    4567              : 
    4568              :   /* Splice this bunch out of where it is now.  */
    4569      1799987 :   if (PREV_INSN (from))
    4570      1799987 :     SET_NEXT_INSN (PREV_INSN (from)) = NEXT_INSN (to);
    4571      1799987 :   if (NEXT_INSN (to))
    4572      1791162 :     SET_PREV_INSN (NEXT_INSN (to)) = PREV_INSN (from);
    4573      1799987 :   if (get_last_insn () == to)
    4574         8825 :     set_last_insn (PREV_INSN (from));
    4575      1799987 :   if (get_insns () == from)
    4576            0 :     set_first_insn (NEXT_INSN (to));
    4577              : 
    4578              :   /* Make the new neighbors point to it and it to them.  */
    4579      1799987 :   if (NEXT_INSN (after))
    4580      1792535 :     SET_PREV_INSN (NEXT_INSN (after)) = to;
    4581              : 
    4582      1799987 :   SET_NEXT_INSN (to) = NEXT_INSN (after);
    4583      1799987 :   SET_PREV_INSN (from) = after;
    4584      1799987 :   SET_NEXT_INSN (after) = from;
    4585      1799987 :   if (after == get_last_insn ())
    4586         7452 :     set_last_insn (to);
    4587      1799987 : }
    4588              : 
    4589              : /* Same as function above, but take care to update BB boundaries.  */
    4590              : void
    4591      1169364 : reorder_insns (rtx_insn *from, rtx_insn *to, rtx_insn *after)
    4592              : {
    4593      1169364 :   rtx_insn *prev = PREV_INSN (from);
    4594      1169364 :   basic_block bb, bb2;
    4595              : 
    4596      1169364 :   reorder_insns_nobb (from, to, after);
    4597              : 
    4598      1169364 :   if (!BARRIER_P (after)
    4599      1169364 :       && (bb = BLOCK_FOR_INSN (after)))
    4600              :     {
    4601      1162231 :       rtx_insn *x;
    4602      1162231 :       df_set_bb_dirty (bb);
    4603              : 
    4604      1162231 :       if (!BARRIER_P (from)
    4605      1162231 :           && (bb2 = BLOCK_FOR_INSN (from)))
    4606              :         {
    4607      1162231 :           if (BB_END (bb2) == to)
    4608        17078 :             BB_END (bb2) = prev;
    4609      1162231 :           df_set_bb_dirty (bb2);
    4610              :         }
    4611              : 
    4612      1162231 :       if (BB_END (bb) == after)
    4613       333182 :         BB_END (bb) = to;
    4614              : 
    4615      2380950 :       for (x = from; x != NEXT_INSN (to); x = NEXT_INSN (x))
    4616      1218719 :         if (!BARRIER_P (x))
    4617      1218719 :           df_insn_change_bb (x, bb);
    4618              :     }
    4619      1169364 : }
    4620              : 
    4621              : 
    4622              : /* Emit insn(s) of given code and pattern
    4623              :    at a specified place within the doubly-linked list.
    4624              : 
    4625              :    All of the emit_foo global entry points accept an object
    4626              :    X which is either an insn list or a PATTERN of a single
    4627              :    instruction.
    4628              : 
    4629              :    There are thus a few canonical ways to generate code and
    4630              :    emit it at a specific place in the instruction stream.  For
    4631              :    example, consider the instruction named SPOT and the fact that
    4632              :    we would like to emit some instructions before SPOT.  We might
    4633              :    do it like this:
    4634              : 
    4635              :         start_sequence ();
    4636              :         ... emit the new instructions ...
    4637              :         insns_head = end_sequence ();
    4638              : 
    4639              :         emit_insn_before (insns_head, SPOT);
    4640              : 
    4641              :    It used to be common to generate SEQUENCE rtl instead, but that
    4642              :    is a relic of the past which no longer occurs.  The reason is that
    4643              :    SEQUENCE rtl results in much fragmented RTL memory since the SEQUENCE
    4644              :    generated would almost certainly die right after it was created.  */
    4645              : 
    4646              : static rtx_insn *
    4647     11545873 : emit_pattern_before_noloc (rtx x, rtx_insn *before, rtx_insn *last,
    4648              :                            basic_block bb,
    4649              :                            rtx_insn *(*make_raw) (rtx))
    4650              : {
    4651     11545873 :   rtx_insn *insn;
    4652              : 
    4653     11545873 :   gcc_assert (before);
    4654              : 
    4655     11545873 :   if (x == NULL_RTX)
    4656              :     return last;
    4657              : 
    4658     11532191 :   switch (GET_CODE (x))
    4659              :     {
    4660     10076375 :     case DEBUG_INSN:
    4661     10076375 :     case INSN:
    4662     10076375 :     case JUMP_INSN:
    4663     10076375 :     case CALL_INSN:
    4664     10076375 :     case CODE_LABEL:
    4665     10076375 :     case BARRIER:
    4666     10076375 :     case NOTE:
    4667     10076375 :       insn = as_a <rtx_insn *> (x);
    4668     32418897 :       while (insn)
    4669              :         {
    4670     12266147 :           rtx_insn *next = NEXT_INSN (insn);
    4671     12266147 :           add_insn_before (insn, before, bb);
    4672     12266147 :           last = insn;
    4673     12266147 :           insn = next;
    4674              :         }
    4675              :       break;
    4676              : 
    4677              : #ifdef ENABLE_RTL_CHECKING
    4678              :     case SEQUENCE:
    4679              :       gcc_unreachable ();
    4680              :       break;
    4681              : #endif
    4682              : 
    4683      1455816 :     default:
    4684      1455816 :       last = (*make_raw) (x);
    4685      1455816 :       add_insn_before (last, before, bb);
    4686      1455816 :       break;
    4687              :     }
    4688              : 
    4689              :   return last;
    4690              : }
    4691              : 
    4692              : /* Make X be output before the instruction BEFORE.  */
    4693              : 
    4694              : rtx_insn *
    4695       459226 : emit_insn_before_noloc (rtx x, rtx_insn *before, basic_block bb)
    4696              : {
    4697       459226 :   return emit_pattern_before_noloc (x, before, before, bb, make_insn_raw);
    4698              : }
    4699              : 
    4700              : /* Make an instruction with body X and code JUMP_INSN
    4701              :    and output it before the instruction BEFORE.  */
    4702              : 
    4703              : rtx_jump_insn *
    4704            0 : emit_jump_insn_before_noloc (rtx x, rtx_insn *before)
    4705              : {
    4706            0 :   return as_a <rtx_jump_insn *> (
    4707              :                 emit_pattern_before_noloc (x, before, NULL, NULL,
    4708            0 :                                            make_jump_insn_raw));
    4709              : }
    4710              : 
    4711              : /* Make an instruction with body X and code CALL_INSN
    4712              :    and output it before the instruction BEFORE.  */
    4713              : 
    4714              : rtx_insn *
    4715            0 : emit_call_insn_before_noloc (rtx x, rtx_insn *before)
    4716              : {
    4717            0 :   return emit_pattern_before_noloc (x, before, NULL, NULL,
    4718            0 :                                     make_call_insn_raw);
    4719              : }
    4720              : 
    4721              : /* Make an instruction with body X and code DEBUG_INSN
    4722              :    and output it before the instruction BEFORE.  */
    4723              : 
    4724              : rtx_insn *
    4725            0 : emit_debug_insn_before_noloc (rtx x, rtx_insn *before)
    4726              : {
    4727            0 :   return emit_pattern_before_noloc (x, before, NULL, NULL,
    4728            0 :                                     make_debug_insn_raw);
    4729              : }
    4730              : 
    4731              : /* Make an insn of code BARRIER
    4732              :    and output it before the insn BEFORE.  */
    4733              : 
    4734              : rtx_barrier *
    4735            0 : emit_barrier_before (rtx_insn *before)
    4736              : {
    4737            0 :   rtx_barrier *insn = as_a <rtx_barrier *> (rtx_alloc (BARRIER));
    4738              : 
    4739            0 :   INSN_UID (insn) = cur_insn_uid++;
    4740              : 
    4741            0 :   add_insn_before (insn, before, NULL);
    4742            0 :   return insn;
    4743              : }
    4744              : 
    4745              : /* Emit the label LABEL before the insn BEFORE.  */
    4746              : 
    4747              : rtx_code_label *
    4748      6507018 : emit_label_before (rtx_code_label *label, rtx_insn *before)
    4749              : {
    4750      6507018 :   gcc_checking_assert (INSN_UID (label) == 0);
    4751      6507018 :   INSN_UID (label) = cur_insn_uid++;
    4752      6507018 :   add_insn_before (label, before, NULL);
    4753      6507018 :   return label;
    4754              : }
    4755              : 
    4756              : /* Helper for emit_insn_after, handles lists of instructions
    4757              :    efficiently.  */
    4758              : 
    4759              : static rtx_insn *
    4760     24425177 : emit_insn_after_1 (rtx_insn *first, rtx_insn *after, basic_block bb)
    4761              : {
    4762     24425177 :   rtx_insn *last;
    4763     24425177 :   rtx_insn *after_after;
    4764     24425177 :   if (!bb && !BARRIER_P (after))
    4765     19620998 :     bb = BLOCK_FOR_INSN (after);
    4766              : 
    4767     19620998 :   if (bb)
    4768              :     {
    4769     24425107 :       df_set_bb_dirty (bb);
    4770     67668638 :       for (last = first; NEXT_INSN (last); last = NEXT_INSN (last))
    4771     18818424 :         if (!BARRIER_P (last))
    4772              :           {
    4773     18816783 :             set_block_for_insn (last, bb);
    4774     18816783 :             df_insn_rescan (last);
    4775              :           }
    4776     24425107 :       if (!BARRIER_P (last))
    4777              :         {
    4778     24425107 :           set_block_for_insn (last, bb);
    4779     24425107 :           df_insn_rescan (last);
    4780              :         }
    4781     24425107 :       if (BB_END (bb) == after)
    4782      9148976 :         BB_END (bb) = last;
    4783              :     }
    4784              :   else
    4785           70 :     for (last = first; NEXT_INSN (last); last = NEXT_INSN (last))
    4786            0 :       continue;
    4787              : 
    4788     24425177 :   after_after = NEXT_INSN (after);
    4789              : 
    4790     24425177 :   SET_NEXT_INSN (after) = first;
    4791     24425177 :   SET_PREV_INSN (first) = after;
    4792     24425177 :   SET_NEXT_INSN (last) = after_after;
    4793     24425177 :   if (after_after)
    4794     24314066 :     SET_PREV_INSN (after_after) = last;
    4795              : 
    4796     24425177 :   if (after == get_last_insn ())
    4797       111111 :     set_last_insn (last);
    4798              : 
    4799     24425177 :   return last;
    4800              : }
    4801              : 
    4802              : static rtx_insn *
    4803     29397561 : emit_pattern_after_noloc (rtx x, rtx_insn *after, basic_block bb,
    4804              :                           rtx_insn *(*make_raw)(rtx))
    4805              : {
    4806     29397561 :   rtx_insn *last = after;
    4807              : 
    4808     29397561 :   gcc_assert (after);
    4809              : 
    4810     29397561 :   if (x == NULL_RTX)
    4811              :     return last;
    4812              : 
    4813     28840955 :   switch (GET_CODE (x))
    4814              :     {
    4815     24425177 :     case DEBUG_INSN:
    4816     24425177 :     case INSN:
    4817     24425177 :     case JUMP_INSN:
    4818     24425177 :     case CALL_INSN:
    4819     24425177 :     case CODE_LABEL:
    4820     24425177 :     case BARRIER:
    4821     24425177 :     case NOTE:
    4822     24425177 :       last = emit_insn_after_1 (as_a <rtx_insn *> (x), after, bb);
    4823     24425177 :       break;
    4824              : 
    4825              : #ifdef ENABLE_RTL_CHECKING
    4826              :     case SEQUENCE:
    4827              :       gcc_unreachable ();
    4828              :       break;
    4829              : #endif
    4830              : 
    4831      4415778 :     default:
    4832      4415778 :       last = (*make_raw) (x);
    4833      4415778 :       add_insn_after (last, after, bb);
    4834      4415778 :       break;
    4835              :     }
    4836              : 
    4837              :   return last;
    4838              : }
    4839              : 
    4840              : /* Make X be output after the insn AFTER and set the BB of insn.  If
    4841              :    BB is NULL, an attempt is made to infer the BB from AFTER.  */
    4842              : 
    4843              : rtx_insn *
    4844      5044780 : emit_insn_after_noloc (rtx x, rtx_insn *after, basic_block bb)
    4845              : {
    4846      5044780 :   return emit_pattern_after_noloc (x, after, bb, make_insn_raw);
    4847              : }
    4848              : 
    4849              : 
    4850              : /* Make an insn of code JUMP_INSN with body X
    4851              :    and output it after the insn AFTER.  */
    4852              : 
    4853              : rtx_jump_insn *
    4854         2061 : emit_jump_insn_after_noloc (rtx x, rtx_insn *after)
    4855              : {
    4856         2061 :   return as_a <rtx_jump_insn *> (
    4857         2061 :                 emit_pattern_after_noloc (x, after, NULL, make_jump_insn_raw));
    4858              : }
    4859              : 
    4860              : /* Make an instruction with body X and code CALL_INSN
    4861              :    and output it after the instruction AFTER.  */
    4862              : 
    4863              : rtx_insn *
    4864            0 : emit_call_insn_after_noloc (rtx x, rtx_insn *after)
    4865              : {
    4866            0 :   return emit_pattern_after_noloc (x, after, NULL, make_call_insn_raw);
    4867              : }
    4868              : 
    4869              : /* Make an instruction with body X and code CALL_INSN
    4870              :    and output it after the instruction AFTER.  */
    4871              : 
    4872              : rtx_insn *
    4873            0 : emit_debug_insn_after_noloc (rtx x, rtx_insn *after)
    4874              : {
    4875            0 :   return emit_pattern_after_noloc (x, after, NULL, make_debug_insn_raw);
    4876              : }
    4877              : 
    4878              : /* Make an insn of code BARRIER
    4879              :    and output it after the insn AFTER.  */
    4880              : 
    4881              : rtx_barrier *
    4882      7525486 : emit_barrier_after (rtx_insn *after)
    4883              : {
    4884      7525486 :   rtx_barrier *insn = as_a <rtx_barrier *> (rtx_alloc (BARRIER));
    4885              : 
    4886      7525486 :   INSN_UID (insn) = cur_insn_uid++;
    4887              : 
    4888      7525486 :   add_insn_after (insn, after, NULL);
    4889      7525486 :   return insn;
    4890              : }
    4891              : 
    4892              : /* Emit the label LABEL after the insn AFTER.  */
    4893              : 
    4894              : rtx_insn *
    4895            0 : emit_label_after (rtx_insn *label, rtx_insn *after)
    4896              : {
    4897            0 :   gcc_checking_assert (INSN_UID (label) == 0);
    4898            0 :   INSN_UID (label) = cur_insn_uid++;
    4899            0 :   add_insn_after (label, after, NULL);
    4900            0 :   return label;
    4901              : }
    4902              : 
    4903              : /* Notes require a bit of special handling: Some notes need to have their
    4904              :    BLOCK_FOR_INSN set, others should never have it set, and some should
    4905              :    have it set or clear depending on the context.   */
    4906              : 
    4907              : /* Return true iff a note of kind SUBTYPE should be emitted with routines
    4908              :    that never set BLOCK_FOR_INSN on NOTE.  BB_BOUNDARY is true if the
    4909              :    caller is asked to emit a note before BB_HEAD, or after BB_END.  */
    4910              : 
    4911              : static bool
    4912    144942735 : note_outside_basic_block_p (enum insn_note subtype, bool on_bb_boundary_p)
    4913              : {
    4914            0 :   switch (subtype)
    4915              :     {
    4916              :       /* NOTE_INSN_SWITCH_TEXT_SECTIONS only appears between basic blocks.  */
    4917              :       case NOTE_INSN_SWITCH_TEXT_SECTIONS:
    4918              :         return true;
    4919              : 
    4920              :       /* Notes for var tracking and EH region markers can appear between or
    4921              :          inside basic blocks.  If the caller is emitting on the basic block
    4922              :          boundary, do not set BLOCK_FOR_INSN on the new note.  */
    4923     58220904 :       case NOTE_INSN_VAR_LOCATION:
    4924     58220904 :       case NOTE_INSN_EH_REGION_BEG:
    4925     58220904 :       case NOTE_INSN_EH_REGION_END:
    4926            0 :         return on_bb_boundary_p;
    4927              : 
    4928              :       /* Otherwise, BLOCK_FOR_INSN must be set.  */
    4929            0 :       default:
    4930            0 :         return false;
    4931              :     }
    4932              : }
    4933              : 
    4934              : /* Emit a note of subtype SUBTYPE after the insn AFTER.  */
    4935              : 
    4936              : rtx_note *
    4937     52640819 : emit_note_after (enum insn_note subtype, rtx_insn *after)
    4938              : {
    4939     52640819 :   rtx_note *note = make_note_raw (subtype);
    4940     52640819 :   basic_block bb = BARRIER_P (after) ? NULL : BLOCK_FOR_INSN (after);
    4941     52610207 :   bool on_bb_boundary_p = (bb != NULL && BB_END (bb) == after);
    4942              : 
    4943     52640819 :   if (note_outside_basic_block_p (subtype, on_bb_boundary_p))
    4944      1334916 :     add_insn_after_nobb (note, after);
    4945              :   else
    4946     51305903 :     add_insn_after (note, after, bb);
    4947     52640819 :   return note;
    4948              : }
    4949              : 
    4950              : /* Emit a note of subtype SUBTYPE before the insn BEFORE.  */
    4951              : 
    4952              : rtx_note *
    4953     92301916 : emit_note_before (enum insn_note subtype, rtx_insn *before)
    4954              : {
    4955     92301916 :   rtx_note *note = make_note_raw (subtype);
    4956     92301916 :   basic_block bb = BARRIER_P (before) ? NULL : BLOCK_FOR_INSN (before);
    4957     92301915 :   bool on_bb_boundary_p = (bb != NULL && BB_HEAD (bb) == before);
    4958              : 
    4959     92301916 :   if (note_outside_basic_block_p (subtype, on_bb_boundary_p))
    4960     21400241 :     add_insn_before_nobb (note, before);
    4961              :   else
    4962     70901675 :     add_insn_before (note, before, bb);
    4963     92301916 :   return note;
    4964              : }
    4965              : 
    4966              : /* Insert PATTERN after AFTER, setting its INSN_LOCATION to LOC.
    4967              :    MAKE_RAW indicates how to turn PATTERN into a real insn.  */
    4968              : 
    4969              : static rtx_insn *
    4970     22214322 : emit_pattern_after_setloc (rtx pattern, rtx_insn *after, location_t loc,
    4971              :                            rtx_insn *(*make_raw) (rtx))
    4972              : {
    4973     22214322 :   rtx_insn *last = emit_pattern_after_noloc (pattern, after, NULL, make_raw);
    4974              : 
    4975     22214322 :   if (pattern == NULL_RTX || !loc)
    4976              :     return last;
    4977              : 
    4978     15733939 :   after = NEXT_INSN (after);
    4979      4253610 :   while (1)
    4980              :     {
    4981     19987549 :       if (active_insn_p (after)
    4982     18877502 :           && !JUMP_TABLE_DATA_P (after) /* FIXME */
    4983     38865051 :           && !INSN_LOCATION (after))
    4984     18871414 :         INSN_LOCATION (after) = loc;
    4985     19987549 :       if (after == last)
    4986              :         break;
    4987      4253610 :       after = NEXT_INSN (after);
    4988              :     }
    4989              :   return last;
    4990              : }
    4991              : 
    4992              : /* Insert PATTERN after AFTER.  MAKE_RAW indicates how to turn PATTERN
    4993              :    into a real insn.  SKIP_DEBUG_INSNS indicates whether to insert after
    4994              :    any DEBUG_INSNs.  */
    4995              : 
    4996              : static rtx_insn *
    4997     10832897 : emit_pattern_after (rtx pattern, rtx_insn *after, bool skip_debug_insns,
    4998              :                     rtx_insn *(*make_raw) (rtx))
    4999              : {
    5000     10832897 :   rtx_insn *prev = after;
    5001              : 
    5002     10832897 :   if (skip_debug_insns)
    5003     11399387 :     while (DEBUG_INSN_P (prev))
    5004      2019477 :       prev = PREV_INSN (prev);
    5005              : 
    5006     10832897 :   if (INSN_P (prev))
    5007      8696499 :     return emit_pattern_after_setloc (pattern, after, INSN_LOCATION (prev),
    5008      8696499 :                                       make_raw);
    5009              :   else
    5010      2136398 :     return emit_pattern_after_noloc (pattern, after, NULL, make_raw);
    5011              : }
    5012              : 
    5013              : /* Like emit_insn_after_noloc, but set INSN_LOCATION according to LOC.  */
    5014              : rtx_insn *
    5015      8382198 : emit_insn_after_setloc (rtx pattern, rtx_insn *after, location_t loc)
    5016              : {
    5017      8382198 :   return emit_pattern_after_setloc (pattern, after, loc, make_insn_raw);
    5018              : }
    5019              : 
    5020              : /* Like emit_insn_after_noloc, but set INSN_LOCATION according to AFTER.  */
    5021              : rtx_insn *
    5022      8747354 : emit_insn_after (rtx pattern, rtx_insn *after)
    5023              : {
    5024      8747354 :   return emit_pattern_after (pattern, after, true, make_insn_raw);
    5025              : }
    5026              : 
    5027              : /* Like emit_jump_insn_after_noloc, but set INSN_LOCATION according to LOC.  */
    5028              : rtx_jump_insn *
    5029      5135625 : emit_jump_insn_after_setloc (rtx pattern, rtx_insn *after, location_t loc)
    5030              : {
    5031      5135625 :   return as_a <rtx_jump_insn *> (
    5032      5135625 :         emit_pattern_after_setloc (pattern, after, loc, make_jump_insn_raw));
    5033              : }
    5034              : 
    5035              : /* Like emit_jump_insn_after_noloc, but set INSN_LOCATION according to AFTER.  */
    5036              : rtx_jump_insn *
    5037       607972 : emit_jump_insn_after (rtx pattern, rtx_insn *after)
    5038              : {
    5039       607972 :   return as_a <rtx_jump_insn *> (
    5040       607972 :         emit_pattern_after (pattern, after, true, make_jump_insn_raw));
    5041              : }
    5042              : 
    5043              : /* Like emit_call_insn_after_noloc, but set INSN_LOCATION according to LOC.  */
    5044              : rtx_insn *
    5045            0 : emit_call_insn_after_setloc (rtx pattern, rtx_insn *after, location_t loc)
    5046              : {
    5047            0 :   return emit_pattern_after_setloc (pattern, after, loc, make_call_insn_raw);
    5048              : }
    5049              : 
    5050              : /* Like emit_call_insn_after_noloc, but set INSN_LOCATION according to AFTER.  */
    5051              : rtx_insn *
    5052        24584 : emit_call_insn_after (rtx pattern, rtx_insn *after)
    5053              : {
    5054        24584 :   return emit_pattern_after (pattern, after, true, make_call_insn_raw);
    5055              : }
    5056              : 
    5057              : /* Like emit_debug_insn_after_noloc, but set INSN_LOCATION according to LOC.  */
    5058              : rtx_insn *
    5059            0 : emit_debug_insn_after_setloc (rtx pattern, rtx_insn *after, location_t loc)
    5060              : {
    5061            0 :   return emit_pattern_after_setloc (pattern, after, loc, make_debug_insn_raw);
    5062              : }
    5063              : 
    5064              : /* Like emit_debug_insn_after_noloc, but set INSN_LOCATION according to AFTER.  */
    5065              : rtx_insn *
    5066      1452987 : emit_debug_insn_after (rtx pattern, rtx_insn *after)
    5067              : {
    5068      1452987 :   return emit_pattern_after (pattern, after, false, make_debug_insn_raw);
    5069              : }
    5070              : 
    5071              : /* Insert PATTERN before BEFORE, setting its INSN_LOCATION to LOC.
    5072              :    MAKE_RAW indicates how to turn PATTERN into a real insn.  INSNP
    5073              :    indicates if PATTERN is meant for an INSN as opposed to a JUMP_INSN,
    5074              :    CALL_INSN, etc.  */
    5075              : 
    5076              : static rtx_insn *
    5077     10505813 : emit_pattern_before_setloc (rtx pattern, rtx_insn *before, location_t loc,
    5078              :                             bool insnp, rtx_insn *(*make_raw) (rtx))
    5079              : {
    5080     10505813 :   rtx_insn *first = PREV_INSN (before);
    5081     10832688 :   rtx_insn *last = emit_pattern_before_noloc (pattern, before,
    5082              :                                               insnp ? before : NULL,
    5083              :                                               NULL, make_raw);
    5084              : 
    5085     10505813 :   if (pattern == NULL_RTX || !loc)
    5086              :     return last;
    5087              : 
    5088      9492053 :   if (!first)
    5089        87681 :     first = get_insns ();
    5090              :   else
    5091      9404372 :     first = NEXT_INSN (first);
    5092      1512603 :   while (1)
    5093              :     {
    5094     11004656 :       if (active_insn_p (first)
    5095     10464056 :           && !JUMP_TABLE_DATA_P (first) /* FIXME */
    5096     21468712 :           && !INSN_LOCATION (first))
    5097     10239684 :         INSN_LOCATION (first) = loc;
    5098     11004656 :       if (first == last)
    5099              :         break;
    5100      1512603 :       first = NEXT_INSN (first);
    5101              :     }
    5102              :   return last;
    5103              : }
    5104              : 
    5105              : /* Insert PATTERN before BEFORE.  MAKE_RAW indicates how to turn PATTERN
    5106              :    into a real insn.  SKIP_DEBUG_INSNS indicates whether to insert
    5107              :    before any DEBUG_INSNs.  INSNP indicates if PATTERN is meant for an
    5108              :    INSN as opposed to a JUMP_INSN, CALL_INSN, etc.  */
    5109              : 
    5110              : static rtx_insn *
    5111     10727106 : emit_pattern_before (rtx pattern, rtx_insn *before, bool skip_debug_insns,
    5112              :                      bool insnp, rtx_insn *(*make_raw) (rtx))
    5113              : {
    5114     10727106 :   rtx_insn *next = before;
    5115              : 
    5116     10727106 :   if (skip_debug_insns)
    5117     10408363 :     while (DEBUG_INSN_P (next))
    5118           31 :       next = PREV_INSN (next);
    5119              : 
    5120     10727106 :   if (INSN_P (next))
    5121     10146272 :     return emit_pattern_before_setloc (pattern, before, INSN_LOCATION (next),
    5122     10146272 :                                        insnp, make_raw);
    5123              :   else
    5124       582107 :     return emit_pattern_before_noloc (pattern, before,
    5125              :                                       insnp ? before : NULL,
    5126       580834 :                                       NULL, make_raw);
    5127              : }
    5128              : 
    5129              : /* Like emit_insn_before_noloc, but set INSN_LOCATION according to LOC.  */
    5130              : rtx_insn *
    5131       359541 : emit_insn_before_setloc (rtx pattern, rtx_insn *before, location_t loc)
    5132              : {
    5133       359541 :   return emit_pattern_before_setloc (pattern, before, loc, true,
    5134       359541 :                                      make_insn_raw);
    5135              : }
    5136              : 
    5137              : /* Like emit_insn_before_noloc, but set INSN_LOCATION according to BEFORE.  */
    5138              : rtx_insn *
    5139     10398958 : emit_insn_before (rtx pattern, rtx_insn *before)
    5140              : {
    5141     10398958 :   return emit_pattern_before (pattern, before, true, true, make_insn_raw);
    5142              : }
    5143              : 
    5144              : /* like emit_insn_before_noloc, but set INSN_LOCATION according to LOC.  */
    5145              : rtx_jump_insn *
    5146            0 : emit_jump_insn_before_setloc (rtx pattern, rtx_insn *before, location_t loc)
    5147              : {
    5148            0 :   return as_a <rtx_jump_insn *> (
    5149              :         emit_pattern_before_setloc (pattern, before, loc, false,
    5150            0 :                                     make_jump_insn_raw));
    5151              : }
    5152              : 
    5153              : /* Like emit_jump_insn_before_noloc, but set INSN_LOCATION according to BEFORE.  */
    5154              : rtx_jump_insn *
    5155         9374 : emit_jump_insn_before (rtx pattern, rtx_insn *before)
    5156              : {
    5157         9374 :   return as_a <rtx_jump_insn *> (
    5158              :         emit_pattern_before (pattern, before, true, false,
    5159         9374 :                              make_jump_insn_raw));
    5160              : }
    5161              : 
    5162              : /* Like emit_insn_before_noloc, but set INSN_LOCATION according to LOC.  */
    5163              : rtx_insn *
    5164            0 : emit_call_insn_before_setloc (rtx pattern, rtx_insn *before, location_t loc)
    5165              : {
    5166            0 :   return emit_pattern_before_setloc (pattern, before, loc, false,
    5167            0 :                                      make_call_insn_raw);
    5168              : }
    5169              : 
    5170              : /* Like emit_call_insn_before_noloc,
    5171              :    but set insn_location according to BEFORE.  */
    5172              : rtx_insn *
    5173            0 : emit_call_insn_before (rtx pattern, rtx_insn *before)
    5174              : {
    5175            0 :   return emit_pattern_before (pattern, before, true, false,
    5176            0 :                               make_call_insn_raw);
    5177              : }
    5178              : 
    5179              : /* Like emit_insn_before_noloc, but set INSN_LOCATION according to LOC.  */
    5180              : rtx_insn *
    5181            0 : emit_debug_insn_before_setloc (rtx pattern, rtx_insn *before, location_t loc)
    5182              : {
    5183            0 :   return emit_pattern_before_setloc (pattern, before, loc, false,
    5184            0 :                                      make_debug_insn_raw);
    5185              : }
    5186              : 
    5187              : /* Like emit_debug_insn_before_noloc,
    5188              :    but set insn_location according to BEFORE.  */
    5189              : rtx_insn *
    5190       318774 : emit_debug_insn_before (rtx pattern, rtx_insn *before)
    5191              : {
    5192       318774 :   return emit_pattern_before (pattern, before, false, false,
    5193       318774 :                               make_debug_insn_raw);
    5194              : }
    5195              : 
    5196              : /* Take X and emit it at the end of the doubly-linked
    5197              :    INSN list.
    5198              : 
    5199              :    Returns the last insn emitted.  */
    5200              : 
    5201              : rtx_insn *
    5202    242976490 : emit_insn (rtx x)
    5203              : {
    5204    242976490 :   rtx_insn *last = get_last_insn ();
    5205    242976490 :   rtx_insn *insn;
    5206              : 
    5207    242976490 :   if (x == NULL_RTX)
    5208              :     return last;
    5209              : 
    5210    238377079 :   switch (GET_CODE (x))
    5211              :     {
    5212    116706399 :     case DEBUG_INSN:
    5213    116706399 :     case INSN:
    5214    116706399 :     case JUMP_INSN:
    5215    116706399 :     case CALL_INSN:
    5216    116706399 :     case CODE_LABEL:
    5217    116706399 :     case BARRIER:
    5218    116706399 :     case NOTE:
    5219    116706399 :       insn = as_a <rtx_insn *> (x);
    5220    396792974 :       while (insn)
    5221              :         {
    5222    163380176 :           rtx_insn *next = NEXT_INSN (insn);
    5223    163380176 :           add_insn (insn);
    5224    163380176 :           last = insn;
    5225    163380176 :           insn = next;
    5226              :         }
    5227              :       break;
    5228              : 
    5229              : #ifdef ENABLE_RTL_CHECKING
    5230              :     case JUMP_TABLE_DATA:
    5231              :     case SEQUENCE:
    5232              :       gcc_unreachable ();
    5233              :       break;
    5234              : #endif
    5235              : 
    5236    121670680 :     default:
    5237    121670680 :       last = make_insn_raw (x);
    5238    121670680 :       add_insn (last);
    5239    121670680 :       break;
    5240              :     }
    5241              : 
    5242              :   return last;
    5243              : }
    5244              : 
    5245              : /* Make an insn of code DEBUG_INSN with pattern X
    5246              :    and add it to the end of the doubly-linked list.  */
    5247              : 
    5248              : rtx_insn *
    5249     47309532 : emit_debug_insn (rtx x)
    5250              : {
    5251     47309532 :   rtx_insn *last = get_last_insn ();
    5252     47309532 :   rtx_insn *insn;
    5253              : 
    5254     47309532 :   if (x == NULL_RTX)
    5255              :     return last;
    5256              : 
    5257     47309532 :   switch (GET_CODE (x))
    5258              :     {
    5259            0 :     case DEBUG_INSN:
    5260            0 :     case INSN:
    5261            0 :     case JUMP_INSN:
    5262            0 :     case CALL_INSN:
    5263            0 :     case CODE_LABEL:
    5264            0 :     case BARRIER:
    5265            0 :     case NOTE:
    5266            0 :       insn = as_a <rtx_insn *> (x);
    5267            0 :       while (insn)
    5268              :         {
    5269            0 :           rtx_insn *next = NEXT_INSN (insn);
    5270            0 :           add_insn (insn);
    5271            0 :           last = insn;
    5272            0 :           insn = next;
    5273              :         }
    5274              :       break;
    5275              : 
    5276              : #ifdef ENABLE_RTL_CHECKING
    5277              :     case JUMP_TABLE_DATA:
    5278              :     case SEQUENCE:
    5279              :       gcc_unreachable ();
    5280              :       break;
    5281              : #endif
    5282              : 
    5283     47309532 :     default:
    5284     47309532 :       last = make_debug_insn_raw (x);
    5285     47309532 :       add_insn (last);
    5286     47309532 :       break;
    5287              :     }
    5288              : 
    5289              :   return last;
    5290              : }
    5291              : 
    5292              : /* Make an insn of code JUMP_INSN with pattern X
    5293              :    and add it to the end of the doubly-linked list.  */
    5294              : 
    5295              : rtx_insn *
    5296     29141162 : emit_jump_insn (rtx x)
    5297              : {
    5298     29141162 :   rtx_insn *last = NULL;
    5299     29141162 :   rtx_insn *insn;
    5300              : 
    5301     29141162 :   switch (GET_CODE (x))
    5302              :     {
    5303     11752595 :     case DEBUG_INSN:
    5304     11752595 :     case INSN:
    5305     11752595 :     case JUMP_INSN:
    5306     11752595 :     case CALL_INSN:
    5307     11752595 :     case CODE_LABEL:
    5308     11752595 :     case BARRIER:
    5309     11752595 :     case NOTE:
    5310     11752595 :       insn = as_a <rtx_insn *> (x);
    5311     44739987 :       while (insn)
    5312              :         {
    5313     21234797 :           rtx_insn *next = NEXT_INSN (insn);
    5314     21234797 :           add_insn (insn);
    5315     21234797 :           last = insn;
    5316     21234797 :           insn = next;
    5317              :         }
    5318              :       break;
    5319              : 
    5320              : #ifdef ENABLE_RTL_CHECKING
    5321              :     case JUMP_TABLE_DATA:
    5322              :     case SEQUENCE:
    5323              :       gcc_unreachable ();
    5324              :       break;
    5325              : #endif
    5326              : 
    5327     17388567 :     default:
    5328     17388567 :       last = make_jump_insn_raw (x);
    5329     17388567 :       add_insn (last);
    5330     17388567 :       break;
    5331              :     }
    5332              : 
    5333     29141162 :   return last;
    5334              : }
    5335              : 
    5336              : /* Make an insn of code JUMP_INSN with pattern X,
    5337              :    add a REG_BR_PROB note that indicates very likely probability,
    5338              :    and add it to the end of the doubly-linked list.  */
    5339              : 
    5340              : rtx_insn *
    5341            0 : emit_likely_jump_insn (rtx x)
    5342              : {
    5343            0 :   rtx_insn *jump = emit_jump_insn (x);
    5344            0 :   add_reg_br_prob_note (jump, profile_probability::very_likely ());
    5345            0 :   return jump;
    5346              : }
    5347              : 
    5348              : /* Make an insn of code JUMP_INSN with pattern X,
    5349              :    add a REG_BR_PROB note that indicates very unlikely probability,
    5350              :    and add it to the end of the doubly-linked list.  */
    5351              : 
    5352              : rtx_insn *
    5353            0 : emit_unlikely_jump_insn (rtx x)
    5354              : {
    5355            0 :   rtx_insn *jump = emit_jump_insn (x);
    5356            0 :   add_reg_br_prob_note (jump, profile_probability::very_unlikely ());
    5357            0 :   return jump;
    5358              : }
    5359              : 
    5360              : /* Make an insn of code CALL_INSN with pattern X
    5361              :    and add it to the end of the doubly-linked list.  */
    5362              : 
    5363              : rtx_insn *
    5364      6248019 : emit_call_insn (rtx x)
    5365              : {
    5366      6248019 :   rtx_insn *insn;
    5367              : 
    5368      6248019 :   switch (GET_CODE (x))
    5369              :     {
    5370         4406 :     case DEBUG_INSN:
    5371         4406 :     case INSN:
    5372         4406 :     case JUMP_INSN:
    5373         4406 :     case CALL_INSN:
    5374         4406 :     case CODE_LABEL:
    5375         4406 :     case BARRIER:
    5376         4406 :     case NOTE:
    5377         4406 :       insn = emit_insn (x);
    5378         4406 :       break;
    5379              : 
    5380              : #ifdef ENABLE_RTL_CHECKING
    5381              :     case SEQUENCE:
    5382              :     case JUMP_TABLE_DATA:
    5383              :       gcc_unreachable ();
    5384              :       break;
    5385              : #endif
    5386              : 
    5387      6243613 :     default:
    5388      6243613 :       insn = make_call_insn_raw (x);
    5389      6243613 :       add_insn (insn);
    5390      6243613 :       break;
    5391              :     }
    5392              : 
    5393      6248019 :   return insn;
    5394              : }
    5395              : 
    5396              : /* Add the label LABEL to the end of the doubly-linked list.  */
    5397              : 
    5398              : rtx_code_label *
    5399      8666654 : emit_label (rtx uncast_label)
    5400              : {
    5401      8666654 :   rtx_code_label *label = as_a <rtx_code_label *> (uncast_label);
    5402              : 
    5403      8666654 :   gcc_checking_assert (INSN_UID (label) == 0);
    5404      8666654 :   INSN_UID (label) = cur_insn_uid++;
    5405      8666654 :   add_insn (label);
    5406      8666654 :   return label;
    5407              : }
    5408              : 
    5409              : /* Make an insn of code JUMP_TABLE_DATA
    5410              :    and add it to the end of the doubly-linked list.  */
    5411              : 
    5412              : rtx_jump_table_data *
    5413         7133 : emit_jump_table_data (rtx table)
    5414              : {
    5415         7133 :   rtx_jump_table_data *jump_table_data =
    5416         7133 :     as_a <rtx_jump_table_data *> (rtx_alloc (JUMP_TABLE_DATA));
    5417         7133 :   INSN_UID (jump_table_data) = cur_insn_uid++;
    5418         7133 :   PATTERN (jump_table_data) = table;
    5419         7133 :   BLOCK_FOR_INSN (jump_table_data) = NULL;
    5420         7133 :   add_insn (jump_table_data);
    5421         7133 :   return jump_table_data;
    5422              : }
    5423              : 
    5424              : /* Make an insn of code BARRIER
    5425              :    and add it to the end of the doubly-linked list.  */
    5426              : 
    5427              : rtx_barrier *
    5428      3497886 : emit_barrier (void)
    5429              : {
    5430      3497886 :   rtx_barrier *barrier = as_a <rtx_barrier *> (rtx_alloc (BARRIER));
    5431      3497886 :   INSN_UID (barrier) = cur_insn_uid++;
    5432      3497886 :   add_insn (barrier);
    5433      3497886 :   return barrier;
    5434              : }
    5435              : 
    5436              : /* Emit a copy of note ORIG.  */
    5437              : 
    5438              : rtx_note *
    5439       175405 : emit_note_copy (rtx_note *orig)
    5440              : {
    5441       175405 :   enum insn_note kind = (enum insn_note) NOTE_KIND (orig);
    5442       175405 :   rtx_note *note = make_note_raw (kind);
    5443       175405 :   NOTE_DATA (note) = NOTE_DATA (orig);
    5444       175405 :   add_insn (note);
    5445       175405 :   return note;
    5446              : }
    5447              : 
    5448              : /* Make an insn of code NOTE or type NOTE_NO
    5449              :    and add it to the end of the doubly-linked list.  */
    5450              : 
    5451              : rtx_note *
    5452     16503944 : emit_note (enum insn_note kind)
    5453              : {
    5454     16503944 :   rtx_note *note = make_note_raw (kind);
    5455     16503944 :   add_insn (note);
    5456     16503944 :   return note;
    5457              : }
    5458              : 
    5459              : /* Emit a clobber of lvalue X.  */
    5460              : 
    5461              : rtx_insn *
    5462       546776 : emit_clobber (rtx x)
    5463              : {
    5464              :   /* CONCATs should not appear in the insn stream.  */
    5465       546776 :   if (GET_CODE (x) == CONCAT)
    5466              :     {
    5467            0 :       emit_clobber (XEXP (x, 0));
    5468            0 :       return emit_clobber (XEXP (x, 1));
    5469              :     }
    5470       546776 :   return emit_insn (gen_rtx_CLOBBER (VOIDmode, x));
    5471              : }
    5472              : 
    5473              : /* Return a sequence of insns to clobber lvalue X.  */
    5474              : 
    5475              : rtx_insn *
    5476            0 : gen_clobber (rtx x)
    5477              : {
    5478            0 :   rtx_insn *seq;
    5479              : 
    5480            0 :   start_sequence ();
    5481            0 :   emit_clobber (x);
    5482            0 :   seq = end_sequence ();
    5483            0 :   return seq;
    5484              : }
    5485              : 
    5486              : /* Emit a use of rvalue X.  */
    5487              : 
    5488              : rtx_insn *
    5489       795945 : emit_use (rtx x)
    5490              : {
    5491              :   /* CONCATs should not appear in the insn stream.  */
    5492       795945 :   if (GET_CODE (x) == CONCAT)
    5493              :     {
    5494            0 :       emit_use (XEXP (x, 0));
    5495            0 :       return emit_use (XEXP (x, 1));
    5496              :     }
    5497       795945 :   return emit_insn (gen_rtx_USE (VOIDmode, x));
    5498              : }
    5499              : 
    5500              : /* Return a sequence of insns to use rvalue X.  */
    5501              : 
    5502              : rtx_insn *
    5503            0 : gen_use (rtx x)
    5504              : {
    5505            0 :   rtx_insn *seq;
    5506              : 
    5507            0 :   start_sequence ();
    5508            0 :   emit_use (x);
    5509            0 :   seq = end_sequence ();
    5510            0 :   return seq;
    5511              : }
    5512              : 
    5513              : /* Notes like REG_EQUAL and REG_EQUIV refer to a set in an instruction.
    5514              :    Return the set in INSN that such notes describe, or NULL if the notes
    5515              :    have no meaning for INSN.  */
    5516              : 
    5517              : rtx
    5518    224429216 : set_for_reg_notes (rtx insn)
    5519              : {
    5520    224429216 :   rtx pat, reg;
    5521              : 
    5522    224429216 :   if (!INSN_P (insn))
    5523              :     return NULL_RTX;
    5524              : 
    5525    224424698 :   pat = PATTERN (insn);
    5526    224424698 :   if (GET_CODE (pat) == PARALLEL)
    5527              :     {
    5528              :       /* We do not use single_set because that ignores SETs of unused
    5529              :          registers.  REG_EQUAL and REG_EQUIV notes really do require the
    5530              :          PARALLEL to have a single SET.  */
    5531     18280601 :       if (multiple_sets (insn))
    5532              :         return NULL_RTX;
    5533     17594300 :       pat = XVECEXP (pat, 0, 0);
    5534              :     }
    5535              : 
    5536    223738397 :   if (GET_CODE (pat) != SET)
    5537              :     return NULL_RTX;
    5538              : 
    5539    127244711 :   reg = SET_DEST (pat);
    5540              : 
    5541              :   /* Notes apply to the contents of a STRICT_LOW_PART.  */
    5542    127244711 :   if (GET_CODE (reg) == STRICT_LOW_PART
    5543    127238571 :       || GET_CODE (reg) == ZERO_EXTRACT)
    5544         8178 :     reg = XEXP (reg, 0);
    5545              : 
    5546              :   /* Check that we have a register.  */
    5547    127244711 :   if (!(REG_P (reg) || GET_CODE (reg) == SUBREG))
    5548              :     return NULL_RTX;
    5549              : 
    5550              :   return pat;
    5551              : }
    5552              : 
    5553              : /* Place a note of KIND on insn INSN with DATUM as the datum. If a
    5554              :    note of this type already exists, remove it first.  */
    5555              : 
    5556              : rtx
    5557     22629230 : set_unique_reg_note (rtx insn, enum reg_note kind, rtx datum)
    5558              : {
    5559     22629230 :   rtx note = find_reg_note (insn, kind, NULL_RTX);
    5560              : 
    5561     22629230 :   switch (kind)
    5562              :     {
    5563     22629230 :     case REG_EQUAL:
    5564     22629230 :     case REG_EQUIV:
    5565              :       /* We need to support the REG_EQUAL on USE trick of find_reloads.  */
    5566     22629230 :       if (!set_for_reg_notes (insn) && GET_CODE (PATTERN (insn)) != USE)
    5567              :         return NULL_RTX;
    5568              : 
    5569              :       /* Don't add ASM_OPERAND REG_EQUAL/REG_EQUIV notes.
    5570              :          It serves no useful purpose and breaks eliminate_regs.  */
    5571     22594449 :       if (GET_CODE (datum) == ASM_OPERANDS)
    5572              :         return NULL_RTX;
    5573              : 
    5574              :       /* Notes with side effects are dangerous.  Even if the side-effect
    5575              :          initially mirrors one in PATTERN (INSN), later optimizations
    5576              :          might alter the way that the final register value is calculated
    5577              :          and so move or alter the side-effect in some way.  The note would
    5578              :          then no longer be a valid substitution for SET_SRC.  */
    5579     22585002 :       if (side_effects_p (datum))
    5580              :         return NULL_RTX;
    5581              :       break;
    5582              : 
    5583              :     default:
    5584              :       break;
    5585              :     }
    5586              : 
    5587     22584536 :   if (note)
    5588      7718542 :     XEXP (note, 0) = datum;
    5589              :   else
    5590              :     {
    5591     14865994 :       add_reg_note (insn, kind, datum);
    5592     14865994 :       note = REG_NOTES (insn);
    5593              :     }
    5594              : 
    5595     22584536 :   switch (kind)
    5596              :     {
    5597     22584536 :     case REG_EQUAL:
    5598     22584536 :     case REG_EQUIV:
    5599     22584536 :       df_notes_rescan (as_a <rtx_insn *> (insn));
    5600     22584536 :       break;
    5601              :     default:
    5602              :       break;
    5603              :     }
    5604              : 
    5605              :   return note;
    5606              : }
    5607              : 
    5608              : /* Like set_unique_reg_note, but don't do anything unless INSN sets DST.  */
    5609              : rtx
    5610      1398393 : set_dst_reg_note (rtx insn, enum reg_note kind, rtx datum, rtx dst)
    5611              : {
    5612      1398393 :   rtx set = set_for_reg_notes (insn);
    5613              : 
    5614      1398393 :   if (set && SET_DEST (set) == dst)
    5615      1383443 :     return set_unique_reg_note (insn, kind, datum);
    5616              :   return NULL_RTX;
    5617              : }
    5618              : 
    5619              : /* Emit the rtl pattern X as an appropriate kind of insn.  Also emit a
    5620              :    following barrier if the instruction needs one and if ALLOW_BARRIER_P
    5621              :    is true.
    5622              : 
    5623              :    If X is a label, it is simply added into the insn chain.  */
    5624              : 
    5625              : rtx_insn *
    5626     18495701 : emit (rtx x, bool allow_barrier_p)
    5627              : {
    5628     18495701 :   enum rtx_code code = classify_insn (x);
    5629              : 
    5630     18495701 :   switch (code)
    5631              :     {
    5632            0 :     case CODE_LABEL:
    5633            0 :       return emit_label (x);
    5634      9250847 :     case INSN:
    5635      9250847 :       return emit_insn (x);
    5636      9238640 :     case  JUMP_INSN:
    5637      9238640 :       {
    5638      9238640 :         rtx_insn *insn = emit_jump_insn (x);
    5639      9238640 :         if (allow_barrier_p
    5640      9238640 :             && (any_uncondjump_p (insn) || GET_CODE (x) == RETURN))
    5641            0 :           return emit_barrier ();
    5642              :         return insn;
    5643              :       }
    5644         6214 :     case CALL_INSN:
    5645         6214 :       return emit_call_insn (x);
    5646            0 :     case DEBUG_INSN:
    5647            0 :       return emit_debug_insn (x);
    5648            0 :     default:
    5649            0 :       gcc_unreachable ();
    5650              :     }
    5651              : }
    5652              : 
    5653              : /* Space for free sequence stack entries.  */
    5654              : static GTY ((deletable)) struct sequence_stack *free_sequence_stack;
    5655              : 
    5656              : /* Begin emitting insns to a sequence.  If this sequence will contain
    5657              :    something that might cause the compiler to pop arguments to function
    5658              :    calls (because those pops have previously been deferred; see
    5659              :    INHIBIT_DEFER_POP for more details), use do_pending_stack_adjust
    5660              :    before calling this function.  That will ensure that the deferred
    5661              :    pops are not accidentally emitted in the middle of this sequence.  */
    5662              : 
    5663              : void
    5664    233023026 : start_sequence (void)
    5665              : {
    5666    233023026 :   struct sequence_stack *tem;
    5667              : 
    5668    233023026 :   if (free_sequence_stack != NULL)
    5669              :     {
    5670    232352667 :       tem = free_sequence_stack;
    5671    232352667 :       free_sequence_stack = tem->next;
    5672              :     }
    5673              :   else
    5674       670359 :     tem = ggc_alloc<sequence_stack> ();
    5675              : 
    5676    233023026 :   tem->next = get_current_sequence ()->next;
    5677    233023026 :   tem->first = get_insns ();
    5678    233023026 :   tem->last = get_last_insn ();
    5679    233023026 :   get_current_sequence ()->next = tem;
    5680              : 
    5681    233023026 :   set_first_insn (0);
    5682    233023026 :   set_last_insn (0);
    5683    233023026 : }
    5684              : 
    5685              : /* Set up the insn chain starting with FIRST as the current sequence,
    5686              :    saving the previously current one.  See the documentation for
    5687              :    start_sequence for more information about how to use this function.  */
    5688              : 
    5689              : void
    5690      5390287 : push_to_sequence (rtx_insn *first)
    5691              : {
    5692      5390287 :   rtx_insn *last;
    5693              : 
    5694      5390287 :   start_sequence ();
    5695              : 
    5696     14179532 :   for (last = first; last && NEXT_INSN (last); last = NEXT_INSN (last))
    5697              :     ;
    5698              : 
    5699      5390287 :   set_first_insn (first);
    5700      5390287 :   set_last_insn (last);
    5701      5390287 : }
    5702              : 
    5703              : /* Like push_to_sequence, but take the last insn as an argument to avoid
    5704              :    looping through the list.  */
    5705              : 
    5706              : void
    5707        78204 : push_to_sequence2 (rtx_insn *first, rtx_insn *last)
    5708              : {
    5709        78204 :   start_sequence ();
    5710              : 
    5711        78204 :   set_first_insn (first);
    5712        78204 :   set_last_insn (last);
    5713        78204 : }
    5714              : 
    5715              : /* Set up the outer-level insn chain
    5716              :    as the current sequence, saving the previously current one.  */
    5717              : 
    5718              : void
    5719          476 : push_topmost_sequence (void)
    5720              : {
    5721          476 :   struct sequence_stack *top;
    5722              : 
    5723          476 :   start_sequence ();
    5724              : 
    5725          476 :   top = get_topmost_sequence ();
    5726          476 :   set_first_insn (top->first);
    5727          476 :   set_last_insn (top->last);
    5728          476 : }
    5729              : 
    5730              : /* After emitting to the outer-level insn chain, update the outer-level
    5731              :    insn chain, and restore the previous saved state.  */
    5732              : 
    5733              : void
    5734          476 : pop_topmost_sequence (void)
    5735              : {
    5736          476 :   struct sequence_stack *top;
    5737              : 
    5738          476 :   top = get_topmost_sequence ();
    5739          476 :   top->first = get_insns ();
    5740          476 :   top->last = get_last_insn ();
    5741              : 
    5742          476 :   end_sequence ();
    5743          476 : }
    5744              : 
    5745              : /* After emitting to a sequence, restore the previous saved state and return
    5746              :    the start of the completed sequence.
    5747              : 
    5748              :    If the compiler might have deferred popping arguments while
    5749              :    generating this sequence, and this sequence will not be immediately
    5750              :    inserted into the instruction stream, use do_pending_stack_adjust
    5751              :    before calling this function.  That will ensure that the deferred
    5752              :    pops are inserted into this sequence, and not into some random
    5753              :    location in the instruction stream.  See INHIBIT_DEFER_POP for more
    5754              :    information about deferred popping of arguments.  */
    5755              : 
    5756              : rtx_insn *
    5757    233023024 : end_sequence (void)
    5758              : {
    5759    233023024 :   rtx_insn *insns = get_insns ();
    5760              : 
    5761    233023024 :   struct sequence_stack *tem = get_current_sequence ()->next;
    5762              : 
    5763    233023024 :   set_first_insn (tem->first);
    5764    233023024 :   set_last_insn (tem->last);
    5765    233023024 :   get_current_sequence ()->next = tem->next;
    5766              : 
    5767    233023024 :   memset (tem, 0, sizeof (*tem));
    5768    233023024 :   tem->next = free_sequence_stack;
    5769    233023024 :   free_sequence_stack = tem;
    5770              : 
    5771    233023024 :   return insns;
    5772              : }
    5773              : 
    5774              : /* Return true if currently emitting into a sequence.  */
    5775              : 
    5776              : bool
    5777      4960371 : in_sequence_p (void)
    5778              : {
    5779      4960371 :   return get_current_sequence ()->next != 0;
    5780              : }
    5781              : 
    5782              : /* Put the various virtual registers into REGNO_REG_RTX.  */
    5783              : 
    5784              : static void
    5785      1715698 : init_virtual_regs (void)
    5786              : {
    5787      1715698 :   regno_reg_rtx[VIRTUAL_INCOMING_ARGS_REGNUM] = virtual_incoming_args_rtx;
    5788      1715698 :   regno_reg_rtx[VIRTUAL_STACK_VARS_REGNUM] = virtual_stack_vars_rtx;
    5789      1715698 :   regno_reg_rtx[VIRTUAL_STACK_DYNAMIC_REGNUM] = virtual_stack_dynamic_rtx;
    5790      1715698 :   regno_reg_rtx[VIRTUAL_OUTGOING_ARGS_REGNUM] = virtual_outgoing_args_rtx;
    5791      1715698 :   regno_reg_rtx[VIRTUAL_CFA_REGNUM] = virtual_cfa_rtx;
    5792      1715698 :   regno_reg_rtx[VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM]
    5793      1715698 :     = virtual_preferred_stack_boundary_rtx;
    5794      1715698 : }
    5795              : 
    5796              : 
    5797              : /* Used by copy_insn_1 to avoid copying SCRATCHes more than once.  */
    5798              : static rtx copy_insn_scratch_in[MAX_RECOG_OPERANDS];
    5799              : static rtx copy_insn_scratch_out[MAX_RECOG_OPERANDS];
    5800              : static int copy_insn_n_scratches;
    5801              : 
    5802              : /* When an insn is being copied by copy_insn_1, this is nonzero if we have
    5803              :    copied an ASM_OPERANDS.
    5804              :    In that case, it is the original input-operand vector.  */
    5805              : static rtvec orig_asm_operands_vector;
    5806              : 
    5807              : /* When an insn is being copied by copy_insn_1, this is nonzero if we have
    5808              :    copied an ASM_OPERANDS.
    5809              :    In that case, it is the copied input-operand vector.  */
    5810              : static rtvec copy_asm_operands_vector;
    5811              : 
    5812              : /* Likewise for the constraints vector.  */
    5813              : static rtvec orig_asm_constraints_vector;
    5814              : static rtvec copy_asm_constraints_vector;
    5815              : 
    5816              : /* Recursively create a new copy of an rtx for copy_insn.
    5817              :    This function differs from copy_rtx in that it handles SCRATCHes and
    5818              :    ASM_OPERANDs properly.
    5819              :    Normally, this function is not used directly; use copy_insn as front end.
    5820              :    However, you could first copy an insn pattern with copy_insn and then use
    5821              :    this function afterwards to properly copy any REG_NOTEs containing
    5822              :    SCRATCHes.  */
    5823              : 
    5824              : rtx
    5825     22376695 : copy_insn_1 (rtx orig)
    5826              : {
    5827     22376695 :   rtx copy;
    5828     22376695 :   int i, j;
    5829     22376695 :   RTX_CODE code;
    5830     22376695 :   const char *format_ptr;
    5831              : 
    5832     22376695 :   if (orig == NULL)
    5833              :     return NULL;
    5834              : 
    5835     22375377 :   code = GET_CODE (orig);
    5836              : 
    5837     22375377 :   switch (code)
    5838              :     {
    5839              :     case REG:
    5840              :     case DEBUG_EXPR:
    5841              :     CASE_CONST_ANY:
    5842              :     case SYMBOL_REF:
    5843              :     case CODE_LABEL:
    5844              :     case PC:
    5845              :     case RETURN:
    5846              :     case SIMPLE_RETURN:
    5847              :       return orig;
    5848      1034613 :     case CLOBBER:
    5849              :       /* Share clobbers of hard registers, but do not share pseudo reg
    5850              :          clobbers or clobbers of hard registers that originated as pseudos.
    5851              :          This is needed to allow safe register renaming.  */
    5852      1034613 :       if (REG_P (XEXP (orig, 0))
    5853       459175 :           && HARD_REGISTER_NUM_P (REGNO (XEXP (orig, 0)))
    5854      1493782 :           && HARD_REGISTER_NUM_P (ORIGINAL_REGNO (XEXP (orig, 0))))
    5855              :         return orig;
    5856              :       break;
    5857              : 
    5858              :     case SCRATCH:
    5859        71885 :       for (i = 0; i < copy_insn_n_scratches; i++)
    5860         1595 :         if (copy_insn_scratch_in[i] == orig)
    5861         1539 :           return copy_insn_scratch_out[i];
    5862              :       break;
    5863              : 
    5864       106253 :     case CONST:
    5865       106253 :       if (shared_const_p (orig))
    5866              :         return orig;
    5867              :       break;
    5868              : 
    5869              :       /* A MEM with a constant address is not sharable.  The problem is that
    5870              :          the constant address may need to be reloaded.  If the mem is shared,
    5871              :          then reloading one copy of this mem will cause all copies to appear
    5872              :          to have been reloaded.  */
    5873              : 
    5874              :     default:
    5875              :       break;
    5876              :     }
    5877              : 
    5878              :   /* Copy the various flags, fields, and other information.  We assume
    5879              :      that all fields need copying, and then clear the fields that should
    5880              :      not be copied.  That is the sensible default behavior, and forces
    5881              :      us to explicitly document why we are *not* copying a flag.  */
    5882      9928855 :   copy = shallow_copy_rtx (orig);
    5883              : 
    5884              :   /* We do not copy JUMP, CALL, or FRAME_RELATED for INSNs.  */
    5885      9928855 :   if (INSN_P (orig))
    5886              :     {
    5887            0 :       RTX_FLAG (copy, jump) = 0;
    5888            0 :       RTX_FLAG (copy, call) = 0;
    5889            0 :       RTX_FLAG (copy, frame_related) = 0;
    5890              :     }
    5891              : 
    5892      9928855 :   format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
    5893              : 
    5894     27303165 :   for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
    5895     17374310 :     switch (*format_ptr++)
    5896              :       {
    5897     14300352 :       case 'e':
    5898     14300352 :         if (XEXP (orig, i) != NULL)
    5899     14278824 :           XEXP (copy, i) = copy_insn_1 (XEXP (orig, i));
    5900              :         break;
    5901              : 
    5902       644311 :       case 'E':
    5903       644311 :       case 'V':
    5904       644311 :         if (XVEC (orig, i) == orig_asm_constraints_vector)
    5905           12 :           XVEC (copy, i) = copy_asm_constraints_vector;
    5906       644299 :         else if (XVEC (orig, i) == orig_asm_operands_vector)
    5907           12 :           XVEC (copy, i) = copy_asm_operands_vector;
    5908       644287 :         else if (XVEC (orig, i) != NULL)
    5909              :           {
    5910       644287 :             XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
    5911      1907394 :             for (j = 0; j < XVECLEN (copy, i); j++)
    5912      1263107 :               XVECEXP (copy, i, j) = copy_insn_1 (XVECEXP (orig, i, j));
    5913              :           }
    5914              :         break;
    5915              : 
    5916              :       case 't':
    5917              :       case 'w':
    5918              :       case 'i':
    5919              :       case 'L':
    5920              :       case 'p':
    5921              :       case 's':
    5922              :       case 'S':
    5923              :       case 'u':
    5924              :       case '0':
    5925              :         /* These are left unchanged.  */
    5926              :         break;
    5927              : 
    5928            0 :       default:
    5929            0 :         gcc_unreachable ();
    5930              :       }
    5931              : 
    5932      9928855 :   if (code == SCRATCH)
    5933              :     {
    5934        70290 :       i = copy_insn_n_scratches++;
    5935        70290 :       gcc_assert (i < MAX_RECOG_OPERANDS);
    5936        70290 :       copy_insn_scratch_in[i] = orig;
    5937        70290 :       copy_insn_scratch_out[i] = copy;
    5938              :     }
    5939      9858565 :   else if (code == ASM_OPERANDS)
    5940              :     {
    5941          215 :       orig_asm_operands_vector = ASM_OPERANDS_INPUT_VEC (orig);
    5942          215 :       copy_asm_operands_vector = ASM_OPERANDS_INPUT_VEC (copy);
    5943          215 :       orig_asm_constraints_vector = ASM_OPERANDS_INPUT_CONSTRAINT_VEC (orig);
    5944          215 :       copy_asm_constraints_vector = ASM_OPERANDS_INPUT_CONSTRAINT_VEC (copy);
    5945              :     }
    5946              : 
    5947              :   return copy;
    5948              : }
    5949              : 
    5950              : /* Create a new copy of an rtx.
    5951              :    This function differs from copy_rtx in that it handles SCRATCHes and
    5952              :    ASM_OPERANDs properly.
    5953              :    INSN doesn't really have to be a full INSN; it could be just the
    5954              :    pattern.  */
    5955              : rtx
    5956      3841429 : copy_insn (rtx insn)
    5957              : {
    5958      3841429 :   copy_insn_n_scratches = 0;
    5959      3841429 :   orig_asm_operands_vector = 0;
    5960      3841429 :   orig_asm_constraints_vector = 0;
    5961      3841429 :   copy_asm_operands_vector = 0;
    5962      3841429 :   copy_asm_constraints_vector = 0;
    5963      3841429 :   return copy_insn_1 (insn);
    5964              : }
    5965              : 
    5966              : /* Return a copy of INSN that can be used in a SEQUENCE delay slot,
    5967              :    on that assumption that INSN itself remains in its original place.  */
    5968              : 
    5969              : rtx_insn *
    5970            0 : copy_delay_slot_insn (rtx_insn *insn)
    5971              : {
    5972              :   /* Copy INSN with its rtx_code, all its notes, location etc.  */
    5973            0 :   insn = as_a <rtx_insn *> (copy_rtx (insn));
    5974            0 :   INSN_UID (insn) = cur_insn_uid++;
    5975            0 :   return insn;
    5976              : }
    5977              : 
    5978              : /* Initialize data structures and variables in this file
    5979              :    before generating rtl for each function.  */
    5980              : 
    5981              : void
    5982      1715698 : init_emit (void)
    5983              : {
    5984      1715698 :   set_first_insn (NULL);
    5985      1715698 :   set_last_insn (NULL);
    5986      1715698 :   if (param_min_nondebug_insn_uid)
    5987            0 :     cur_insn_uid = param_min_nondebug_insn_uid;
    5988              :   else
    5989      1715698 :     cur_insn_uid = 1;
    5990      1715698 :   cur_debug_insn_uid = 1;
    5991      1715698 :   reg_rtx_no = LAST_VIRTUAL_REGISTER + 1;
    5992      1715698 :   first_label_num = label_num;
    5993      1715698 :   get_current_sequence ()->next = NULL;
    5994              : 
    5995              :   /* Init the tables that describe all the pseudo regs.  */
    5996              : 
    5997      1715698 :   crtl->emit.regno_pointer_align_length = LAST_VIRTUAL_REGISTER + 101;
    5998              : 
    5999      1715698 :   crtl->emit.regno_pointer_align
    6000      1715698 :     = XCNEWVEC (unsigned char, crtl->emit.regno_pointer_align_length);
    6001              : 
    6002      1715698 :   regno_reg_rtx
    6003      1715698 :     = ggc_cleared_vec_alloc<rtx> (crtl->emit.regno_pointer_align_length);
    6004              : 
    6005              :   /* Put copies of all the hard registers into regno_reg_rtx.  */
    6006      1715698 :   memcpy (regno_reg_rtx,
    6007      1715698 :           initial_regno_reg_rtx,
    6008              :           FIRST_PSEUDO_REGISTER * sizeof (rtx));
    6009              : 
    6010              :   /* Put copies of all the virtual register rtx into regno_reg_rtx.  */
    6011      1715698 :   init_virtual_regs ();
    6012              : 
    6013              :   /* Indicate that the virtual registers and stack locations are
    6014              :      all pointers.  */
    6015      1715698 :   REG_POINTER (stack_pointer_rtx) = 1;
    6016      1715698 :   REG_POINTER (frame_pointer_rtx) = 1;
    6017      1715698 :   REG_POINTER (hard_frame_pointer_rtx) = 1;
    6018      1715698 :   REG_POINTER (arg_pointer_rtx) = 1;
    6019              : 
    6020      1715698 :   REG_POINTER (virtual_incoming_args_rtx) = 1;
    6021      1715698 :   REG_POINTER (virtual_stack_vars_rtx) = 1;
    6022      1715698 :   REG_POINTER (virtual_stack_dynamic_rtx) = 1;
    6023      1715698 :   REG_POINTER (virtual_outgoing_args_rtx) = 1;
    6024      1715698 :   REG_POINTER (virtual_cfa_rtx) = 1;
    6025              : 
    6026              : #ifdef STACK_BOUNDARY
    6027      1715698 :   REGNO_POINTER_ALIGN (STACK_POINTER_REGNUM) = STACK_BOUNDARY;
    6028      1715698 :   REGNO_POINTER_ALIGN (FRAME_POINTER_REGNUM) = STACK_BOUNDARY;
    6029      1715698 :   REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = STACK_BOUNDARY;
    6030      1715698 :   REGNO_POINTER_ALIGN (ARG_POINTER_REGNUM) = STACK_BOUNDARY;
    6031              : 
    6032      1715698 :   REGNO_POINTER_ALIGN (VIRTUAL_INCOMING_ARGS_REGNUM) = STACK_BOUNDARY;
    6033      1715698 :   REGNO_POINTER_ALIGN (VIRTUAL_STACK_VARS_REGNUM) = STACK_BOUNDARY;
    6034      1715698 :   REGNO_POINTER_ALIGN (VIRTUAL_STACK_DYNAMIC_REGNUM) = STACK_BOUNDARY;
    6035      1715698 :   REGNO_POINTER_ALIGN (VIRTUAL_OUTGOING_ARGS_REGNUM) = STACK_BOUNDARY;
    6036              : 
    6037      1715698 :   REGNO_POINTER_ALIGN (VIRTUAL_CFA_REGNUM) = BITS_PER_WORD;
    6038              : #endif
    6039              : 
    6040              : #ifdef INIT_EXPANDERS
    6041              :   INIT_EXPANDERS;
    6042              : #endif
    6043      1715698 : }
    6044              : 
    6045              : /* Return the value of element I of CONST_VECTOR X as a wide_int.  */
    6046              : 
    6047              : wide_int
    6048         1068 : const_vector_int_elt (const_rtx x, unsigned int i)
    6049              : {
    6050              :   /* First handle elements that are directly encoded.  */
    6051         1068 :   machine_mode elt_mode = GET_MODE_INNER (GET_MODE (x));
    6052         1068 :   if (i < (unsigned int) XVECLEN (x, 0))
    6053            0 :     return rtx_mode_t (CONST_VECTOR_ENCODED_ELT (x, i), elt_mode);
    6054              : 
    6055              :   /* Identify the pattern that contains element I and work out the index of
    6056              :      the last encoded element for that pattern.  */
    6057         1068 :   unsigned int encoded_nelts = const_vector_encoded_nelts (x);
    6058         1068 :   unsigned int npatterns = CONST_VECTOR_NPATTERNS (x);
    6059         1068 :   unsigned int count = i / npatterns;
    6060         1068 :   unsigned int pattern = i % npatterns;
    6061         1068 :   unsigned int final_i = encoded_nelts - npatterns + pattern;
    6062              : 
    6063              :   /* If there are no steps, the final encoded value is the right one.  */
    6064         1068 :   if (!CONST_VECTOR_STEPPED_P (x))
    6065            0 :     return rtx_mode_t (CONST_VECTOR_ENCODED_ELT (x, final_i), elt_mode);
    6066              : 
    6067              :   /* Otherwise work out the value from the last two encoded elements.  */
    6068         1068 :   rtx v1 = CONST_VECTOR_ENCODED_ELT (x, final_i - npatterns);
    6069         1068 :   rtx v2 = CONST_VECTOR_ENCODED_ELT (x, final_i);
    6070         1068 :   wide_int diff = wi::sub (rtx_mode_t (v2, elt_mode),
    6071         1068 :                            rtx_mode_t (v1, elt_mode));
    6072         1068 :   return wi::add (rtx_mode_t (v2, elt_mode), (count - 2) * diff);
    6073         1068 : }
    6074              : 
    6075              : /* Return the value of element I of CONST_VECTOR X.  */
    6076              : 
    6077              : rtx
    6078      4667095 : const_vector_elt (const_rtx x, unsigned int i)
    6079              : {
    6080              :   /* First handle elements that are directly encoded.  */
    6081      4667095 :   if (i < (unsigned int) XVECLEN (x, 0))
    6082      4664959 :     return CONST_VECTOR_ENCODED_ELT (x, i);
    6083              : 
    6084              :   /* If there are no steps, the final encoded value is the right one.  */
    6085         2136 :   if (!CONST_VECTOR_STEPPED_P (x))
    6086              :     {
    6087              :       /* Identify the pattern that contains element I and work out the index of
    6088              :          the last encoded element for that pattern.  */
    6089         1068 :       unsigned int encoded_nelts = const_vector_encoded_nelts (x);
    6090         1068 :       unsigned int npatterns = CONST_VECTOR_NPATTERNS (x);
    6091         1068 :       unsigned int pattern = i % npatterns;
    6092         1068 :       unsigned int final_i = encoded_nelts - npatterns + pattern;
    6093         1068 :       return CONST_VECTOR_ENCODED_ELT (x, final_i);
    6094              :     }
    6095              : 
    6096              :   /* Otherwise work out the value from the last two encoded elements.  */
    6097         1068 :   return immed_wide_int_const (const_vector_int_elt (x, i),
    6098         2136 :                                GET_MODE_INNER (GET_MODE (x)));
    6099              : }
    6100              : 
    6101              : /* Return true if X is a valid element for a CONST_VECTOR of the given
    6102              :   mode.  */
    6103              : 
    6104              : bool
    6105       549211 : valid_for_const_vector_p (machine_mode, rtx x)
    6106              : {
    6107       549211 :   return (CONST_SCALAR_INT_P (x)
    6108              :           || CONST_POLY_INT_P (x)
    6109       168577 :           || CONST_DOUBLE_AS_FLOAT_P (x)
    6110       698697 :           || CONST_FIXED_P (x));
    6111              : }
    6112              : 
    6113              : /* Generate a vector constant of mode MODE in which every element has
    6114              :    value ELT.  */
    6115              : 
    6116              : rtx
    6117     43012393 : gen_const_vec_duplicate (machine_mode mode, rtx elt)
    6118              : {
    6119     43012393 :   rtx_vector_builder builder (mode, 1, 1);
    6120     43012393 :   builder.quick_push (elt);
    6121     43012393 :   return builder.build ();
    6122     43012393 : }
    6123              : 
    6124              : /* Return a vector rtx of mode MODE in which every element has value X.
    6125              :    The result will be a constant if X is constant.  */
    6126              : 
    6127              : rtx
    6128       253072 : gen_vec_duplicate (machine_mode mode, rtx x)
    6129              : {
    6130       253072 :   if (valid_for_const_vector_p (mode, x))
    6131       109310 :     return gen_const_vec_duplicate (mode, x);
    6132       143762 :   return gen_rtx_VEC_DUPLICATE (mode, x);
    6133              : }
    6134              : 
    6135              : /* A subroutine of const_vec_series_p that handles the case in which:
    6136              : 
    6137              :      (GET_CODE (X) == CONST_VECTOR
    6138              :       && CONST_VECTOR_NPATTERNS (X) == 1
    6139              :       && !CONST_VECTOR_DUPLICATE_P (X))
    6140              : 
    6141              :    is known to hold.  */
    6142              : 
    6143              : bool
    6144         5772 : const_vec_series_p_1 (const_rtx x, rtx *base_out, rtx *step_out)
    6145              : {
    6146              :   /* Stepped sequences are only defined for integers, to avoid specifying
    6147              :      rounding behavior.  */
    6148         5772 :   if (GET_MODE_CLASS (GET_MODE (x)) != MODE_VECTOR_INT)
    6149              :     return false;
    6150              : 
    6151              :   /* A non-duplicated vector with two elements can always be seen as a
    6152              :      series with a nonzero step.  Longer vectors must have a stepped
    6153              :      encoding.  */
    6154         5772 :   if (maybe_ne (CONST_VECTOR_NUNITS (x), 2)
    6155         5772 :       && !CONST_VECTOR_STEPPED_P (x))
    6156              :     return false;
    6157              : 
    6158              :   /* Calculate the step between the first and second elements.  */
    6159         5768 :   scalar_mode inner = GET_MODE_INNER (GET_MODE (x));
    6160         5768 :   rtx base = CONST_VECTOR_ELT (x, 0);
    6161        11536 :   rtx step = simplify_binary_operation (MINUS, inner,
    6162         5768 :                                         CONST_VECTOR_ENCODED_ELT (x, 1), base);
    6163         5768 :   if (rtx_equal_p (step, CONST0_RTX (inner)))
    6164              :     return false;
    6165              : 
    6166              :   /* If we have a stepped encoding, check that the step between the
    6167              :      second and third elements is the same as STEP.  */
    6168         5768 :   if (CONST_VECTOR_STEPPED_P (x))
    6169              :     {
    6170         9232 :       rtx diff = simplify_binary_operation (MINUS, inner,
    6171              :                                             CONST_VECTOR_ENCODED_ELT (x, 2),
    6172         4616 :                                             CONST_VECTOR_ENCODED_ELT (x, 1));
    6173         4616 :       if (!rtx_equal_p (step, diff))
    6174              :         return false;
    6175              :     }
    6176              : 
    6177         5768 :   *base_out = base;
    6178         5768 :   *step_out = step;
    6179         5768 :   return true;
    6180              : }
    6181              : 
    6182              : /* Generate a vector constant of mode MODE in which element I has
    6183              :    the value BASE + I * STEP.  */
    6184              : 
    6185              : rtx
    6186          645 : gen_const_vec_series (machine_mode mode, rtx base, rtx step)
    6187              : {
    6188          645 :   gcc_assert (valid_for_const_vector_p (mode, base)
    6189              :               && valid_for_const_vector_p (mode, step));
    6190              : 
    6191          645 :   rtx_vector_builder builder (mode, 1, 3);
    6192          645 :   builder.quick_push (base);
    6193         1935 :   for (int i = 1; i < 3; ++i)
    6194         1290 :     builder.quick_push (simplify_gen_binary (PLUS, GET_MODE_INNER (mode),
    6195         1290 :                                              builder[i - 1], step));
    6196          645 :   return builder.build ();
    6197          645 : }
    6198              : 
    6199              : /* Generate a vector of mode MODE in which element I has the value
    6200              :    BASE + I * STEP.  The result will be a constant if BASE and STEP
    6201              :    are both constants.  */
    6202              : 
    6203              : rtx
    6204         4995 : gen_vec_series (machine_mode mode, rtx base, rtx step)
    6205              : {
    6206         4995 :   if (step == const0_rtx)
    6207          204 :     return gen_vec_duplicate (mode, base);
    6208         4791 :   if (valid_for_const_vector_p (mode, base)
    6209         4791 :       && valid_for_const_vector_p (mode, step))
    6210            0 :     return gen_const_vec_series (mode, base, step);
    6211         4791 :   return gen_rtx_VEC_SERIES (mode, base, step);
    6212              : }
    6213              : 
    6214              : /* Generate a new vector constant for mode MODE and constant value
    6215              :    CONSTANT.  */
    6216              : 
    6217              : static rtx
    6218     41651753 : gen_const_vector (machine_mode mode, int constant)
    6219              : {
    6220     41651753 :   machine_mode inner = GET_MODE_INNER (mode);
    6221              : 
    6222     41651753 :   gcc_assert (!DECIMAL_FLOAT_MODE_P (inner));
    6223              : 
    6224     41651753 :   rtx el = const_tiny_rtx[constant][(int) inner];
    6225     41651753 :   gcc_assert (el);
    6226              : 
    6227     41651753 :   return gen_const_vec_duplicate (mode, el);
    6228              : }
    6229              : 
    6230              : /* Generate a vector like gen_rtx_raw_CONST_VEC, but use the zero vector when
    6231              :    all elements are zero, and the one vector when all elements are one.  */
    6232              : rtx
    6233       165673 : gen_rtx_CONST_VECTOR (machine_mode mode, rtvec v)
    6234              : {
    6235       331346 :   gcc_assert (known_eq (GET_MODE_NUNITS (mode), GET_NUM_ELEM (v)));
    6236              : 
    6237              :   /* If the values are all the same, check to see if we can use one of the
    6238              :      standard constant vectors.  */
    6239       165673 :   if (rtvec_all_equal_p (v))
    6240        50525 :     return gen_const_vec_duplicate (mode, RTVEC_ELT (v, 0));
    6241              : 
    6242       115148 :   unsigned int nunits = GET_NUM_ELEM (v);
    6243       115148 :   rtx_vector_builder builder (mode, nunits, 1);
    6244       674222 :   for (unsigned int i = 0; i < nunits; ++i)
    6245       559074 :     builder.quick_push (RTVEC_ELT (v, i));
    6246       115148 :   return builder.build (v);
    6247       115148 : }
    6248              : 
    6249              : /* Initialise global register information required by all functions.  */
    6250              : 
    6251              : void
    6252       789626 : init_emit_regs (void)
    6253              : {
    6254       789626 :   int i;
    6255       789626 :   machine_mode mode;
    6256       789626 :   mem_attrs *attrs;
    6257              : 
    6258              :   /* Reset register attributes */
    6259       789626 :   reg_attrs_htab->empty ();
    6260              : 
    6261              :   /* We need reg_raw_mode, so initialize the modes now.  */
    6262       789626 :   init_reg_modes_target ();
    6263              : 
    6264              :   /* Assign register numbers to the globally defined register rtx.  */
    6265       804653 :   stack_pointer_rtx = gen_raw_REG (Pmode, STACK_POINTER_REGNUM);
    6266       804653 :   frame_pointer_rtx = gen_raw_REG (Pmode, FRAME_POINTER_REGNUM);
    6267       804653 :   hard_frame_pointer_rtx = gen_raw_REG (Pmode, HARD_FRAME_POINTER_REGNUM);
    6268       804653 :   arg_pointer_rtx = gen_raw_REG (Pmode, ARG_POINTER_REGNUM);
    6269      2368878 :   virtual_incoming_args_rtx =
    6270       804653 :     gen_raw_REG (Pmode, VIRTUAL_INCOMING_ARGS_REGNUM);
    6271      2368878 :   virtual_stack_vars_rtx =
    6272       804653 :     gen_raw_REG (Pmode, VIRTUAL_STACK_VARS_REGNUM);
    6273      2368878 :   virtual_stack_dynamic_rtx =
    6274       804653 :     gen_raw_REG (Pmode, VIRTUAL_STACK_DYNAMIC_REGNUM);
    6275      2368878 :   virtual_outgoing_args_rtx =
    6276       804653 :     gen_raw_REG (Pmode, VIRTUAL_OUTGOING_ARGS_REGNUM);
    6277       804653 :   virtual_cfa_rtx = gen_raw_REG (Pmode, VIRTUAL_CFA_REGNUM);
    6278      2368878 :   virtual_preferred_stack_boundary_rtx =
    6279       804653 :     gen_raw_REG (Pmode, VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM);
    6280              : 
    6281              :   /* Initialize RTL for commonly used hard registers.  These are
    6282              :      copied into regno_reg_rtx as we begin to compile each function.  */
    6283     73435218 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    6284     72645592 :     initial_regno_reg_rtx[i] = gen_raw_REG (reg_raw_mode[i], i);
    6285              : 
    6286              : #ifdef RETURN_ADDRESS_POINTER_REGNUM
    6287              :   return_address_pointer_rtx
    6288              :     = gen_raw_REG (Pmode, RETURN_ADDRESS_POINTER_REGNUM);
    6289              : #endif
    6290              : 
    6291       789626 :   pic_offset_table_rtx = NULL_RTX;
    6292       789626 :   if ((unsigned) PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM)
    6293        20387 :     pic_offset_table_rtx = gen_raw_REG (Pmode, PIC_OFFSET_TABLE_REGNUM);
    6294              : 
    6295              :   /* Process stack-limiting command-line options.  */
    6296       789626 :   if (opt_fstack_limit_symbol_arg != NULL)
    6297            0 :     stack_limit_rtx
    6298            0 :       = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (opt_fstack_limit_symbol_arg));
    6299       789626 :   if (opt_fstack_limit_register_no >= 0)
    6300            0 :     stack_limit_rtx = gen_rtx_REG (Pmode, opt_fstack_limit_register_no);
    6301              : 
    6302     98703250 :   for (i = 0; i < (int) MAX_MACHINE_MODE; i++)
    6303              :     {
    6304     97913624 :       mode = (machine_mode) i;
    6305     97913624 :       attrs = ggc_cleared_alloc<mem_attrs> ();
    6306     97913624 :       attrs->align = BITS_PER_UNIT;
    6307     97913624 :       attrs->addrspace = ADDR_SPACE_GENERIC;
    6308     97913624 :       if (mode != BLKmode && mode != VOIDmode)
    6309              :         {
    6310     96334372 :           attrs->size_known_p = true;
    6311    192668744 :           attrs->size = GET_MODE_SIZE (mode);
    6312     96334372 :           if (STRICT_ALIGNMENT)
    6313              :             attrs->align = GET_MODE_ALIGNMENT (mode);
    6314              :         }
    6315     97913624 :       mode_mem_attrs[i] = attrs;
    6316              :     }
    6317              : 
    6318       789626 :   split_branch_probability = profile_probability::uninitialized ();
    6319       789626 : }
    6320              : 
    6321              : /* Initialize global machine_mode variables.  */
    6322              : 
    6323              : void
    6324       298479 : init_derived_machine_modes (void)
    6325              : {
    6326       298479 :   opt_scalar_int_mode mode_iter, opt_byte_mode, opt_word_mode;
    6327      2387832 :   FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
    6328              :     {
    6329      2089353 :       scalar_int_mode mode = mode_iter.require ();
    6330              : 
    6331      2387832 :       if (GET_MODE_BITSIZE (mode) == BITS_PER_UNIT
    6332      2089353 :           && !opt_byte_mode.exists ())
    6333       298479 :         opt_byte_mode = mode;
    6334              : 
    6335      4178706 :       if (GET_MODE_BITSIZE (mode) == BITS_PER_WORD
    6336      2089353 :           && !opt_word_mode.exists ())
    6337       298479 :         opt_word_mode = mode;
    6338              :     }
    6339              : 
    6340       298479 :   byte_mode = opt_byte_mode.require ();
    6341       298479 :   word_mode = opt_word_mode.require ();
    6342       298479 :   ptr_mode = as_a <scalar_int_mode>
    6343       312967 :     (mode_for_size (POINTER_SIZE, GET_MODE_CLASS (Pmode), 0).require ());
    6344       298479 : }
    6345              : 
    6346              : /* Create some permanent unique rtl objects shared between all functions.  */
    6347              : 
    6348              : void
    6349       291271 : init_emit_once (void)
    6350              : {
    6351       291271 :   int i;
    6352       291271 :   machine_mode mode;
    6353       291271 :   scalar_float_mode double_mode;
    6354       291271 :   opt_scalar_mode smode_iter;
    6355              : 
    6356              :   /* Initialize the CONST_INT, CONST_WIDE_INT, CONST_DOUBLE,
    6357              :      CONST_FIXED, and memory attribute hash tables.  */
    6358       291271 :   const_int_htab = hash_table<const_int_hasher>::create_ggc (37);
    6359              : 
    6360              : #if TARGET_SUPPORTS_WIDE_INT
    6361       291271 :   const_wide_int_htab = hash_table<const_wide_int_hasher>::create_ggc (37);
    6362              : #endif
    6363       291271 :   const_double_htab = hash_table<const_double_hasher>::create_ggc (37);
    6364              : 
    6365       291271 :   if (NUM_POLY_INT_COEFFS > 1)
    6366              :     const_poly_int_htab = hash_table<const_poly_int_hasher>::create_ggc (37);
    6367              : 
    6368       291271 :   const_fixed_htab = hash_table<const_fixed_hasher>::create_ggc (37);
    6369              : 
    6370       291271 :   reg_attrs_htab = hash_table<reg_attr_hasher>::create_ggc (37);
    6371              : 
    6372              : #ifdef INIT_EXPANDERS
    6373              :   /* This is to initialize {init|mark|free}_machine_status before the first
    6374              :      call to push_function_context_to.  This is needed by the Chill front
    6375              :      end which calls push_function_context_to before the first call to
    6376              :      init_function_start.  */
    6377              :   INIT_EXPANDERS;
    6378              : #endif
    6379              : 
    6380              :   /* Create the unique rtx's for certain rtx codes and operand values.  */
    6381              : 
    6382              :   /* Don't use gen_rtx_CONST_INT here since gen_rtx_CONST_INT in this case
    6383              :      tries to use these variables.  */
    6384     37865230 :   for (i = - MAX_SAVED_CONST_INT; i <= MAX_SAVED_CONST_INT; i++)
    6385     75147918 :     const_int_rtx[i + MAX_SAVED_CONST_INT] =
    6386     37573959 :       gen_rtx_raw_CONST_INT (VOIDmode, (HOST_WIDE_INT) i);
    6387              : 
    6388       291271 :   if (STORE_FLAG_VALUE >= - MAX_SAVED_CONST_INT
    6389              :       && STORE_FLAG_VALUE <= MAX_SAVED_CONST_INT)
    6390       291271 :     const_true_rtx = const_int_rtx[STORE_FLAG_VALUE + MAX_SAVED_CONST_INT];
    6391              :   else
    6392              :     const_true_rtx = gen_rtx_CONST_INT (VOIDmode, STORE_FLAG_VALUE);
    6393              : 
    6394       291271 :   mode = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
    6395       291271 :   double_mode = as_a<scalar_float_mode> (mode);
    6396              : 
    6397       291271 :   real_from_integer (&dconst0, double_mode, 0, SIGNED);
    6398       291271 :   real_from_integer (&dconst1, double_mode, 1, SIGNED);
    6399       291271 :   real_from_integer (&dconst2, double_mode, 2, SIGNED);
    6400              : 
    6401       291271 :   dconstm0 = dconst0;
    6402       291271 :   dconstm0.sign = 1;
    6403              : 
    6404       291271 :   dconstm1 = dconst1;
    6405       291271 :   dconstm1.sign = 1;
    6406              : 
    6407       291271 :   dconsthalf = dconst1;
    6408       291271 :   SET_REAL_EXP (&dconsthalf, REAL_EXP (&dconsthalf) - 1);
    6409              : 
    6410       291271 :   real_inf (&dconstinf);
    6411       291271 :   real_inf (&dconstninf, true);
    6412              : 
    6413      1165084 :   for (i = 0; i < 3; i++)
    6414              :     {
    6415       873813 :       const REAL_VALUE_TYPE *const r =
    6416              :         (i == 0 ? &dconst0 : i == 1 ? &dconst1 : &dconst2);
    6417              : 
    6418      6116691 :       FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT)
    6419      5242878 :         const_tiny_rtx[i][(int) mode] =
    6420      5242878 :           const_double_from_real_value (*r, mode);
    6421              : 
    6422      3495252 :       FOR_EACH_MODE_IN_CLASS (mode, MODE_DECIMAL_FLOAT)
    6423      2621439 :         const_tiny_rtx[i][(int) mode] =
    6424      2621439 :           const_double_from_real_value (*r, mode);
    6425              : 
    6426       873813 :       const_tiny_rtx[i][(int) VOIDmode] = GEN_INT (i);
    6427              : 
    6428      6990504 :       FOR_EACH_MODE_IN_CLASS (mode, MODE_INT)
    6429      6116691 :         const_tiny_rtx[i][(int) mode] = GEN_INT (i);
    6430              : 
    6431      2621439 :       for (mode = MIN_MODE_PARTIAL_INT;
    6432      3495252 :            mode <= MAX_MODE_PARTIAL_INT;
    6433      2621439 :            mode = (machine_mode)((int)(mode) + 1))
    6434      2621439 :         const_tiny_rtx[i][(int) mode] = GEN_INT (i);
    6435              :     }
    6436              : 
    6437       291271 :   const_tiny_rtx[3][(int) VOIDmode] = constm1_rtx;
    6438              : 
    6439      2330168 :   FOR_EACH_MODE_IN_CLASS (mode, MODE_INT)
    6440      2038897 :     const_tiny_rtx[3][(int) mode] = constm1_rtx;
    6441              : 
    6442              :   /* For BImode, 1 and -1 are unsigned and signed interpretations
    6443              :      of the same value.  */
    6444       291271 :   for (mode = MIN_MODE_BOOL;
    6445       582542 :        mode <= MAX_MODE_BOOL;
    6446       291271 :        mode = (machine_mode)((int)(mode) + 1))
    6447              :     {
    6448       291271 :       const_tiny_rtx[0][(int) mode] = const0_rtx;
    6449       291271 :       if (mode == BImode)
    6450              :         {
    6451       291271 :           const_tiny_rtx[1][(int) mode] = const_true_rtx;
    6452       291271 :           const_tiny_rtx[3][(int) mode] = const_true_rtx;
    6453              :         }
    6454              :       else
    6455              :         {
    6456              :           const_tiny_rtx[1][(int) mode] = const1_rtx;
    6457              :           const_tiny_rtx[3][(int) mode] = constm1_rtx;
    6458              :         }
    6459              :     }
    6460              : 
    6461       873813 :   for (mode = MIN_MODE_PARTIAL_INT;
    6462      1165084 :        mode <= MAX_MODE_PARTIAL_INT;
    6463       873813 :        mode = (machine_mode)((int)(mode) + 1))
    6464       873813 :     const_tiny_rtx[3][(int) mode] = constm1_rtx;
    6465              : 
    6466      3203981 :   FOR_EACH_MODE_IN_CLASS (mode, MODE_COMPLEX_INT)
    6467              :     {
    6468      2912710 :       rtx inner = const_tiny_rtx[0][(int)GET_MODE_INNER (mode)];
    6469      2912710 :       const_tiny_rtx[0][(int) mode] = gen_rtx_CONCAT (mode, inner, inner);
    6470              :     }
    6471              : 
    6472      2038897 :   FOR_EACH_MODE_IN_CLASS (mode, MODE_COMPLEX_FLOAT)
    6473              :     {
    6474      1747626 :       rtx inner = const_tiny_rtx[0][(int)GET_MODE_INNER (mode)];
    6475      1747626 :       const_tiny_rtx[0][(int) mode] = gen_rtx_CONCAT (mode, inner, inner);
    6476              :     }
    6477              : 
    6478       291271 :   FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_BOOL)
    6479              :     {
    6480            0 :       const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0);
    6481            0 :       const_tiny_rtx[3][(int) mode] = gen_const_vector (mode, 3);
    6482            0 :       if (GET_MODE_INNER (mode) == BImode)
    6483              :         /* As for BImode, "all 1" and "all -1" are unsigned and signed
    6484              :            interpretations of the same value.  */
    6485            0 :         const_tiny_rtx[1][(int) mode] = const_tiny_rtx[3][(int) mode];
    6486              :       else
    6487            0 :         const_tiny_rtx[1][(int) mode] = gen_const_vector (mode, 1);
    6488              :     }
    6489              : 
    6490      9320672 :   FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_INT)
    6491              :     {
    6492      9029401 :       const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0);
    6493      9029401 :       const_tiny_rtx[1][(int) mode] = gen_const_vector (mode, 1);
    6494      9029401 :       const_tiny_rtx[3][(int) mode] = gen_const_vector (mode, 3);
    6495              :     }
    6496              : 
    6497      7573046 :   FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_FLOAT)
    6498              :     {
    6499      7281775 :       const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0);
    6500      7281775 :       const_tiny_rtx[1][(int) mode] = gen_const_vector (mode, 1);
    6501              :     }
    6502              : 
    6503      1747626 :   FOR_EACH_MODE_IN_CLASS (smode_iter, MODE_FRACT)
    6504              :     {
    6505      1456355 :       scalar_mode smode = smode_iter.require ();
    6506      1456355 :       FCONST0 (smode).data.high = 0;
    6507      1456355 :       FCONST0 (smode).data.low = 0;
    6508      1456355 :       FCONST0 (smode).mode = smode;
    6509      2912710 :       const_tiny_rtx[0][(int) smode]
    6510      1456355 :         = CONST_FIXED_FROM_FIXED_VALUE (FCONST0 (smode), smode);
    6511              :     }
    6512              : 
    6513      1747626 :   FOR_EACH_MODE_IN_CLASS (smode_iter, MODE_UFRACT)
    6514              :     {
    6515      1456355 :       scalar_mode smode = smode_iter.require ();
    6516      1456355 :       FCONST0 (smode).data.high = 0;
    6517      1456355 :       FCONST0 (smode).data.low = 0;
    6518      1456355 :       FCONST0 (smode).mode = smode;
    6519      2912710 :       const_tiny_rtx[0][(int) smode]
    6520      1456355 :         = CONST_FIXED_FROM_FIXED_VALUE (FCONST0 (smode), smode);
    6521              :     }
    6522              : 
    6523      1456355 :   FOR_EACH_MODE_IN_CLASS (smode_iter, MODE_ACCUM)
    6524              :     {
    6525      1165084 :       scalar_mode smode = smode_iter.require ();
    6526      1165084 :       FCONST0 (smode).data.high = 0;
    6527      1165084 :       FCONST0 (smode).data.low = 0;
    6528      1165084 :       FCONST0 (smode).mode = smode;
    6529      2330168 :       const_tiny_rtx[0][(int) smode]
    6530      1165084 :         = CONST_FIXED_FROM_FIXED_VALUE (FCONST0 (smode), smode);
    6531              : 
    6532              :       /* We store the value 1.  */
    6533      1165084 :       FCONST1 (smode).data.high = 0;
    6534      1165084 :       FCONST1 (smode).data.low = 0;
    6535      1165084 :       FCONST1 (smode).mode = smode;
    6536      2330168 :       FCONST1 (smode).data
    6537      1165084 :         = double_int_one.lshift (GET_MODE_FBIT (smode),
    6538              :                                  HOST_BITS_PER_DOUBLE_INT,
    6539      1165084 :                                  SIGNED_FIXED_POINT_MODE_P (smode));
    6540      2330168 :       const_tiny_rtx[1][(int) smode]
    6541      1165084 :         = CONST_FIXED_FROM_FIXED_VALUE (FCONST1 (smode), smode);
    6542              :     }
    6543              : 
    6544      1456355 :   FOR_EACH_MODE_IN_CLASS (smode_iter, MODE_UACCUM)
    6545              :     {
    6546      1165084 :       scalar_mode smode = smode_iter.require ();
    6547      1165084 :       FCONST0 (smode).data.high = 0;
    6548      1165084 :       FCONST0 (smode).data.low = 0;
    6549      1165084 :       FCONST0 (smode).mode = smode;
    6550      2330168 :       const_tiny_rtx[0][(int) smode]
    6551      1165084 :         = CONST_FIXED_FROM_FIXED_VALUE (FCONST0 (smode), smode);
    6552              : 
    6553              :       /* We store the value 1.  */
    6554      1165084 :       FCONST1 (smode).data.high = 0;
    6555      1165084 :       FCONST1 (smode).data.low = 0;
    6556      1165084 :       FCONST1 (smode).mode = smode;
    6557      2330168 :       FCONST1 (smode).data
    6558      1165084 :         = double_int_one.lshift (GET_MODE_FBIT (smode),
    6559              :                                  HOST_BITS_PER_DOUBLE_INT,
    6560      1165084 :                                  SIGNED_FIXED_POINT_MODE_P (smode));
    6561      2330168 :       const_tiny_rtx[1][(int) smode]
    6562      1165084 :         = CONST_FIXED_FROM_FIXED_VALUE (FCONST1 (smode), smode);
    6563              :     }
    6564              : 
    6565       291271 :   FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_FRACT)
    6566              :     {
    6567            0 :       const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0);
    6568              :     }
    6569              : 
    6570       291271 :   FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_UFRACT)
    6571              :     {
    6572            0 :       const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0);
    6573              :     }
    6574              : 
    6575       291271 :   FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_ACCUM)
    6576              :     {
    6577            0 :       const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0);
    6578            0 :       const_tiny_rtx[1][(int) mode] = gen_const_vector (mode, 1);
    6579              :     }
    6580              : 
    6581       291271 :   FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_UACCUM)
    6582              :     {
    6583            0 :       const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0);
    6584            0 :       const_tiny_rtx[1][(int) mode] = gen_const_vector (mode, 1);
    6585              :     }
    6586              : 
    6587     35826333 :   for (i = (int) CCmode; i < (int) MAX_MACHINE_MODE; ++i)
    6588     35535062 :     if (GET_MODE_CLASS ((machine_mode) i) == MODE_CC)
    6589      3495252 :       const_tiny_rtx[0][i] = const0_rtx;
    6590              : 
    6591       291271 :   pc_rtx = gen_rtx_fmt_ (PC, VOIDmode);
    6592       291271 :   ret_rtx = gen_rtx_fmt_ (RETURN, VOIDmode);
    6593       291271 :   simple_return_rtx = gen_rtx_fmt_ (SIMPLE_RETURN, VOIDmode);
    6594       291271 :   invalid_insn_rtx = gen_rtx_INSN (VOIDmode,
    6595              :                                    /*prev_insn=*/NULL,
    6596              :                                    /*next_insn=*/NULL,
    6597              :                                    /*bb=*/NULL,
    6598              :                                    /*pattern=*/NULL_RTX,
    6599              :                                    /*location=*/-1,
    6600              :                                    CODE_FOR_nothing,
    6601              :                                    /*reg_notes=*/NULL_RTX);
    6602       291271 : }
    6603              : 
    6604              : /* Produce exact duplicate of insn INSN after AFTER.
    6605              :    Care updating of libcall regions if present.  */
    6606              : 
    6607              : rtx_insn *
    6608      3624868 : emit_copy_of_insn_after (rtx_insn *insn, rtx_insn *after)
    6609              : {
    6610      3624868 :   rtx_insn *new_rtx;
    6611      3624868 :   rtx link;
    6612              : 
    6613      3624868 :   switch (GET_CODE (insn))
    6614              :     {
    6615      1728730 :     case INSN:
    6616      1728730 :       new_rtx = emit_insn_after (copy_insn (PATTERN (insn)), after);
    6617      1728730 :       break;
    6618              : 
    6619       495446 :     case JUMP_INSN:
    6620       495446 :       new_rtx = emit_jump_insn_after (copy_insn (PATTERN (insn)), after);
    6621       495446 :       CROSSING_JUMP_P (new_rtx) = CROSSING_JUMP_P (insn);
    6622       495446 :       break;
    6623              : 
    6624      1376108 :     case DEBUG_INSN:
    6625      1376108 :       new_rtx = emit_debug_insn_after (copy_insn (PATTERN (insn)), after);
    6626      1376108 :       break;
    6627              : 
    6628        24584 :     case CALL_INSN:
    6629        24584 :       new_rtx = emit_call_insn_after (copy_insn (PATTERN (insn)), after);
    6630        24584 :       if (CALL_INSN_FUNCTION_USAGE (insn))
    6631        21528 :         CALL_INSN_FUNCTION_USAGE (new_rtx)
    6632        21528 :           = copy_insn (CALL_INSN_FUNCTION_USAGE (insn));
    6633        24584 :       CALL_INSN_ABI_ID (new_rtx) = CALL_INSN_ABI_ID (insn);
    6634        24584 :       SIBLING_CALL_P (new_rtx) = SIBLING_CALL_P (insn);
    6635        24584 :       RTL_CONST_CALL_P (new_rtx) = RTL_CONST_CALL_P (insn);
    6636        24584 :       RTL_PURE_CALL_P (new_rtx) = RTL_PURE_CALL_P (insn);
    6637        24584 :       RTL_LOOPING_CONST_OR_PURE_CALL_P (new_rtx)
    6638        24584 :         = RTL_LOOPING_CONST_OR_PURE_CALL_P (insn);
    6639        24584 :       break;
    6640              : 
    6641            0 :     default:
    6642            0 :       gcc_unreachable ();
    6643              :     }
    6644              : 
    6645              :   /* Update LABEL_NUSES.  */
    6646      3624868 :   if (NONDEBUG_INSN_P (insn))
    6647      2248760 :     mark_jump_label (PATTERN (new_rtx), new_rtx, 0);
    6648              : 
    6649      3624868 :   INSN_LOCATION (new_rtx) = INSN_LOCATION (insn);
    6650              : 
    6651              :   /* If the old insn is frame related, then so is the new one.  This is
    6652              :      primarily needed for IA-64 unwind info which marks epilogue insns,
    6653              :      which may be duplicated by the basic block reordering code.  */
    6654      3624868 :   RTX_FRAME_RELATED_P (new_rtx) = RTX_FRAME_RELATED_P (insn);
    6655              : 
    6656              :   /* Locate the end of existing REG_NOTES in NEW_RTX.  */
    6657      3624868 :   rtx *ptail = &REG_NOTES (new_rtx);
    6658      3624874 :   while (*ptail != NULL_RTX)
    6659            6 :     ptail = &XEXP (*ptail, 1);
    6660              : 
    6661              :   /* Copy all REG_NOTES except REG_LABEL_OPERAND since mark_jump_label
    6662              :      will make them.  REG_LABEL_TARGETs are created there too, but are
    6663              :      supposed to be sticky, so we copy them.  */
    6664      5977476 :   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    6665      2352608 :     if (REG_NOTE_KIND (link) != REG_LABEL_OPERAND)
    6666              :       {
    6667      2352602 :         *ptail = duplicate_reg_note (link);
    6668      2352602 :         ptail = &XEXP (*ptail, 1);
    6669              :       }
    6670              : 
    6671      3624868 :   INSN_CODE (new_rtx) = INSN_CODE (insn);
    6672      3624868 :   return new_rtx;
    6673              : }
    6674              : 
    6675              : static GTY((deletable)) rtx hard_reg_clobbers [NUM_MACHINE_MODES][FIRST_PSEUDO_REGISTER];
    6676              : rtx
    6677      4486948 : gen_hard_reg_clobber (machine_mode mode, unsigned int regno)
    6678              : {
    6679      4486948 :   if (hard_reg_clobbers[mode][regno])
    6680              :     return hard_reg_clobbers[mode][regno];
    6681              :   else
    6682       189070 :     return (hard_reg_clobbers[mode][regno] =
    6683       378140 :             gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (mode, regno)));
    6684              : }
    6685              : 
    6686              : location_t prologue_location;
    6687              : location_t epilogue_location;
    6688              : 
    6689              : /* Hold current location information and last location information, so the
    6690              :    datastructures are built lazily only when some instructions in given
    6691              :    place are needed.  */
    6692              : static location_t curr_location;
    6693              : 
    6694              : /* Allocate insn location datastructure.  */
    6695              : void
    6696      1729244 : insn_locations_init (void)
    6697              : {
    6698      1729244 :   prologue_location = epilogue_location = 0;
    6699      1729244 :   curr_location = UNKNOWN_LOCATION;
    6700      1729244 : }
    6701              : 
    6702              : /* At the end of emit stage, clear current location.  */
    6703              : void
    6704      1490915 : insn_locations_finalize (void)
    6705              : {
    6706      1490915 :   epilogue_location = curr_location;
    6707      1490915 :   curr_location = UNKNOWN_LOCATION;
    6708      1490915 : }
    6709              : 
    6710              : /* Set current location.  */
    6711              : void
    6712    147222622 : set_curr_insn_location (location_t location)
    6713              : {
    6714    147222622 :   curr_location = location;
    6715    147222622 : }
    6716              : 
    6717              : /* Get current location.  */
    6718              : location_t
    6719    259201179 : curr_insn_location (void)
    6720              : {
    6721    259201179 :   return curr_location;
    6722              : }
    6723              : 
    6724              : /* Set the location of the insn chain starting at INSN to LOC.  */
    6725              : void
    6726      3615421 : set_insn_locations (rtx_insn *insn, location_t loc)
    6727              : {
    6728     16232630 :   while (insn)
    6729              :     {
    6730     12617209 :       if (INSN_P (insn))
    6731     10669700 :         INSN_LOCATION (insn) = loc;
    6732     12617209 :       insn = NEXT_INSN (insn);
    6733              :     }
    6734      3615421 : }
    6735              : 
    6736              : /* Return lexical scope block insn belongs to.  */
    6737              : tree
    6738     48227846 : insn_scope (const rtx_insn *insn)
    6739              : {
    6740     48227846 :   return LOCATION_BLOCK (INSN_LOCATION (insn));
    6741              : }
    6742              : 
    6743              : /* Return line number of the statement that produced this insn.  */
    6744              : int
    6745            0 : insn_line (const rtx_insn *insn)
    6746              : {
    6747            0 :   return LOCATION_LINE (INSN_LOCATION (insn));
    6748              : }
    6749              : 
    6750              : /* Return source file of the statement that produced this insn.  */
    6751              : const char *
    6752            0 : insn_file (const rtx_insn *insn)
    6753              : {
    6754            0 :   return LOCATION_FILE (INSN_LOCATION (insn));
    6755              : }
    6756              : 
    6757              : /* Return expanded location of the statement that produced this insn.  */
    6758              : expanded_location
    6759     83665616 : insn_location (const rtx_insn *insn)
    6760              : {
    6761     83665616 :   return expand_location (INSN_LOCATION (insn));
    6762              : }
    6763              : 
    6764              : /* Return true if memory model MODEL requires a pre-operation (release-style)
    6765              :    barrier or a post-operation (acquire-style) barrier.  While not universal,
    6766              :    this function matches behavior of several targets.  */
    6767              : 
    6768              : bool
    6769            0 : need_atomic_barrier_p (enum memmodel model, bool pre)
    6770              : {
    6771            0 :   switch (model & MEMMODEL_BASE_MASK)
    6772              :     {
    6773              :     case MEMMODEL_RELAXED:
    6774              :     case MEMMODEL_CONSUME:
    6775              :       return false;
    6776            0 :     case MEMMODEL_RELEASE:
    6777            0 :       return pre;
    6778            0 :     case MEMMODEL_ACQUIRE:
    6779            0 :       return !pre;
    6780            0 :     case MEMMODEL_ACQ_REL:
    6781            0 :     case MEMMODEL_SEQ_CST:
    6782            0 :       return true;
    6783            0 :     default:
    6784            0 :       gcc_unreachable ();
    6785              :     }
    6786              : }
    6787              : 
    6788              : /* Return a constant shift amount for shifting a value of mode MODE
    6789              :    by VALUE bits.  */
    6790              : 
    6791              : rtx
    6792    213916165 : gen_int_shift_amount (machine_mode, poly_int64 value)
    6793              : {
    6794              :   /* Use a 64-bit mode, to avoid any truncation.
    6795              : 
    6796              :      ??? Perhaps this should be automatically derived from the .md files
    6797              :      instead, or perhaps have a target hook.  */
    6798    213916165 :   scalar_int_mode shift_mode = (BITS_PER_UNIT == 8
    6799              :                                 ? DImode
    6800              :                                 : int_mode_for_size (64, 0).require ());
    6801    213916165 :   return gen_int_mode (value, shift_mode);
    6802              : }
    6803              : 
    6804              : namespace {
    6805              : /* Helper class for expanding an rtx using the encoding generated by
    6806              :    genemit.cc.  The code needs to be kept in sync with there.  */
    6807              : 
    6808              : class rtx_expander
    6809              : {
    6810              : public:
    6811              :   rtx_expander (const uint8_t *, rtx *);
    6812              : 
    6813              :   rtx get_rtx ();
    6814              :   rtvec get_rtvec ();
    6815              :   void expand_seq ();
    6816              : 
    6817              : protected:
    6818              :   uint64_t get_uint ();
    6819     83225044 :   machine_mode get_mode () { return machine_mode (get_uint ()); }
    6820              :   char *get_string ();
    6821              :   rtx get_shared_operand ();
    6822              :   rtx get_unshared_operand ();
    6823              : 
    6824              :   rtx get_rtx (expand_opcode);
    6825              :   rtx get_rtx (rtx_code, machine_mode);
    6826              : 
    6827              :   /* Points to the first unread byte.  */
    6828              :   const uint8_t *m_seq;
    6829              : 
    6830              :   /* The operands passed to the gen_* function.  */
    6831              :   rtx *m_operands;
    6832              : 
    6833              :   /* A bitmap of operands that have already been used to replace a
    6834              :      MATCH_OPERAND or MATCH_DUP.  In order to ensure correct sharing,
    6835              :      further replacements need to use a copy of the operand, rather than
    6836              :      the original rtx.  */
    6837              :   bbitmap<MAX_RECOG_OPERANDS> m_used;
    6838              : };
    6839              : }
    6840              : 
    6841     24764517 : rtx_expander::rtx_expander (const uint8_t *seq, rtx *operands)
    6842     24764517 :   : m_seq (seq), m_operands (operands), m_used ()
    6843            0 : {}
    6844              : 
    6845              : /* Read and return the next encoded "BEB128" integer.  */
    6846              : 
    6847              : inline uint64_t
    6848    241271084 : rtx_expander::get_uint ()
    6849              : {
    6850    241271084 :   const uint8_t *seq = m_seq;
    6851    241271084 :   uint64_t res = 0;
    6852    243309407 :   do
    6853    243309407 :     res = (res << 7) | (*seq & 127);
    6854    243309407 :   while (*seq++ >= 128);
    6855    241271084 :   m_seq = seq;
    6856    241271084 :   return res;
    6857              : }
    6858              : 
    6859              : /* Read an operand number and return the associated operand rtx,
    6860              :    without copying it.  */
    6861              : 
    6862              : rtx
    6863       962577 : rtx_expander::get_shared_operand ()
    6864              : {
    6865       962577 :   return m_operands[get_uint ()];
    6866              : }
    6867              : 
    6868              : /* Read an operand number and return a correctly-shared instance of
    6869              :    the associated operand rtx.  This can be either the original rtx
    6870              :    or a copy.  */
    6871              : 
    6872              : rtx
    6873     44146500 : rtx_expander::get_unshared_operand ()
    6874              : {
    6875     44146500 :   auto opno = get_uint ();
    6876     44146500 :   auto mask = m_used.from_index (opno);
    6877     44146500 :   if (m_used & mask)
    6878      2848422 :     return copy_rtx (m_operands[opno]);
    6879              : 
    6880     41298078 :   m_used |= mask;
    6881     41298078 :   return m_operands[opno];
    6882              : }
    6883              : 
    6884              : /* Read an encoded rtx.  */
    6885              : 
    6886              : rtx
    6887    125939190 : rtx_expander::get_rtx ()
    6888              : {
    6889    125939190 :   auto FIRST_CODE = (unsigned) expand_opcode::FIRST_CODE;
    6890    125939190 :   auto opcode = get_uint ();
    6891    125939190 :   if (opcode < FIRST_CODE)
    6892     49596025 :     return get_rtx (expand_opcode (opcode));
    6893     76343165 :   return get_rtx (rtx_code (opcode - FIRST_CODE), NUM_MACHINE_MODES);
    6894              : }
    6895              : 
    6896              : /* Read an encoded rtx that starts with the given opcode.  */
    6897              : 
    6898              : rtx
    6899     49596025 : rtx_expander::get_rtx (expand_opcode opcode)
    6900              : {
    6901     49596025 :   switch (opcode)
    6902              :     {
    6903              :     case expand_opcode::NO_RTX:
    6904              :       return NULL_RTX;
    6905              : 
    6906     44146500 :     case expand_opcode::MATCH_OPERAND:
    6907     44146500 :       return get_unshared_operand ();
    6908              : 
    6909        42918 :     case expand_opcode::MATCH_OPERATOR_WITH_MODE:
    6910        42918 :       {
    6911        42918 :         auto mode = get_mode ();
    6912        42918 :         auto op = get_shared_operand ();
    6913        42918 :         return get_rtx (GET_CODE (op), mode);
    6914              :       }
    6915              : 
    6916       917757 :     case expand_opcode::MATCH_OPERATOR:
    6917       917757 :       {
    6918       917757 :         auto op = get_shared_operand ();
    6919       917757 :         return get_rtx (GET_CODE (op), GET_MODE (op));
    6920              :       }
    6921              : 
    6922         1902 :     case expand_opcode::MATCH_PARALLEL:
    6923         1902 :       return get_shared_operand ();
    6924              : 
    6925      4486948 :     case expand_opcode::CLOBBER_REG:
    6926      4486948 :       {
    6927      4486948 :         auto mode = get_mode ();
    6928      4486948 :         auto regno = get_uint ();
    6929      4486948 :         return gen_hard_reg_clobber (mode, regno);
    6930              :       }
    6931              : 
    6932              :     case expand_opcode::FIRST_CODE:
    6933              :       break;
    6934              :     }
    6935            0 :   gcc_unreachable ();
    6936              : }
    6937              : 
    6938              : /* Read the rest of an rtx of code CODE.  If such rtxes are not always
    6939              :    VOIDmode, MODE is the mode that the rtx should have, or NUM_MACHINE_MODES
    6940              :    if the mode is encoded at the current iterator position.  */
    6941              : 
    6942              : rtx
    6943     77303840 : rtx_expander::get_rtx (rtx_code code, machine_mode mode)
    6944              : {
    6945     77303840 :   switch (code)
    6946              :     {
    6947              :       /* Please keep the cases below in sync with gengenrtl.cc:special_rtx.  */
    6948              : 
    6949            0 :     case EXPR_LIST:
    6950            0 :     case INSN_LIST:
    6951            0 :     case INSN:
    6952            0 :       gcc_unreachable ();
    6953              : 
    6954      4813064 :     case CONST_INT:
    6955      9626128 :       return GEN_INT (get_uint ());
    6956              : 
    6957      1885758 :     case REG:
    6958      1885758 :       if (mode == NUM_MACHINE_MODES)
    6959      3771516 :         mode = get_mode ();
    6960      3771516 :       return gen_rtx_REG (mode, get_uint ());
    6961              : 
    6962        53421 :     case SUBREG:
    6963        53421 :       {
    6964        53421 :         if (mode == NUM_MACHINE_MODES)
    6965       106842 :           mode = get_mode ();
    6966        53421 :         auto reg = get_rtx ();
    6967        53421 :         auto byte = get_uint ();
    6968        53421 :         return gen_rtx_SUBREG (mode, reg, byte);
    6969              :       }
    6970              : 
    6971      2464692 :     case MEM:
    6972      2464692 :       if (mode == NUM_MACHINE_MODES)
    6973      4929384 :         mode = get_mode ();
    6974      2464692 :       return gen_rtx_MEM (mode, get_rtx ());
    6975              : 
    6976      9294303 :     case PC:
    6977      9294303 :       return pc_rtx;
    6978              : 
    6979            0 :     case RETURN:
    6980            0 :       return ret_rtx;
    6981              : 
    6982      1586326 :     case SIMPLE_RETURN:
    6983      1586326 :       return simple_return_rtx;
    6984              : 
    6985         1911 :     case CONST_VECTOR:
    6986         1911 :       if (mode == NUM_MACHINE_MODES)
    6987         3822 :         mode = get_mode ();
    6988         1911 :       return gen_rtx_CONST_VECTOR (mode, get_rtvec ());
    6989              : 
    6990              :       /* Please keep the cases below in sync with
    6991              :          gengenrtl.cc:excluded_rtx.  */
    6992              : 
    6993            0 :     case VAR_LOCATION:
    6994            0 :       gcc_unreachable ();
    6995              : 
    6996            0 :     case CONST_DOUBLE:
    6997              :       /* genemit.cc only accepts zero const_doubles.  */
    6998            0 :       if (mode == NUM_MACHINE_MODES)
    6999            0 :         mode = get_mode ();
    7000            0 :       return CONST0_RTX (mode);
    7001              : 
    7002            0 :     case CONST_WIDE_INT:
    7003            0 :     case CONST_POLY_INT:
    7004            0 :     case CONST_FIXED:
    7005            0 :       gcc_unreachable ();
    7006              : 
    7007     57204365 :     default:
    7008     57204365 :       break;
    7009              :     }
    7010              : 
    7011     57204365 :   rtx x = rtx_alloc (code);
    7012     57204365 :   if (!always_void_p (code))
    7013              :     {
    7014     33637549 :       if (mode == NUM_MACHINE_MODES)
    7015     65353748 :         mode = get_mode ();
    7016     33637549 :       PUT_MODE_RAW (x, mode);
    7017              :     }
    7018              : 
    7019     57204365 :   const char *fmt = GET_RTX_FORMAT (code);
    7020    147763489 :   for (unsigned int i = 0; fmt[i]; ++i)
    7021     90559124 :     switch (fmt[i])
    7022              :       {
    7023              :         /* Please keep these cases in sync with
    7024              :            gengenrtl.cc:type_from_format.  */
    7025              : 
    7026      1806867 :       case 'i':
    7027      1806867 :         XINT (x, i) = get_uint ();
    7028      1806867 :         break;
    7029              : 
    7030            0 :       case 'L':
    7031            0 :       case 'w':
    7032            0 :       case 'p':
    7033            0 :       case 's':
    7034            0 :         gcc_unreachable ();
    7035              : 
    7036     81479750 :       case 'e':  case 'u':
    7037     81479750 :         XEXP (x, i) = get_rtx ();
    7038     81479750 :         break;
    7039              : 
    7040      7272507 :       case 'E':
    7041      7272507 :         XVEC (x, i) = get_rtvec ();
    7042      7272507 :         break;
    7043              : 
    7044            0 :       case 't':
    7045            0 :       case 'B':
    7046            0 :       default:
    7047            0 :         gcc_unreachable ();
    7048              :       }
    7049              : 
    7050              :   return x;
    7051              : }
    7052              : 
    7053              : /* Read an encoded rtvec.  */
    7054              : 
    7055              : rtvec
    7056      7274418 : rtx_expander::get_rtvec ()
    7057              : {
    7058      7274418 :   unsigned int len = get_uint ();
    7059      7274418 :   rtvec v = rtvec_alloc (len);
    7060     23404638 :   for (unsigned int i = 0; i < len; ++i)
    7061     16130220 :     RTVEC_ELT (v, i) = get_rtx ();
    7062      7274418 :   return v;
    7063              : }
    7064              : 
    7065              : /* Read and emit an encoded sequence of instructions.  */
    7066              : 
    7067              : void
    7068      8289819 : rtx_expander::expand_seq ()
    7069              : {
    7070      8289819 :   unsigned int len = get_uint ();
    7071     17626228 :   for (unsigned int i = 0; i < len; ++i)
    7072      9336409 :     emit (get_rtx (), i < len - 1);
    7073      8289819 : }
    7074              : 
    7075              : /* Read an rtx from the bytecode in SEQ, which was generated by genemit.cc.
    7076              :    Replace operand placeholders with the values given in OPERANDS.  */
    7077              : 
    7078              : rtx
    7079     16474698 : expand_rtx (const uint8_t *seq, rtx *operands)
    7080              : {
    7081     16474698 :   return rtx_expander (seq, operands).get_rtx ();
    7082              : }
    7083              : 
    7084              : /* Read and emit a sequence of instructions from the bytecode in SEQ,
    7085              :    which was generated by genemit.cc.  Replace operand placeholders with
    7086              :    the values given in OPERANDS.  */
    7087              : 
    7088              : rtx_insn *
    7089      8289819 : complete_seq (const uint8_t *seq, rtx *operands)
    7090              : {
    7091      8289819 :   rtx_expander (seq, operands).expand_seq ();
    7092      8289819 :   return end_sequence ();
    7093              : }
    7094              : 
    7095              : /* Initialize fields of rtl_data related to stack alignment.  */
    7096              : 
    7097              : void
    7098      1489249 : rtl_data::init_stack_alignment ()
    7099              : {
    7100      1489249 :   stack_alignment_needed = STACK_BOUNDARY;
    7101      1489249 :   max_used_stack_slot_alignment = STACK_BOUNDARY;
    7102      1489249 :   stack_alignment_estimated = 0;
    7103      1489249 :   preferred_stack_boundary = STACK_BOUNDARY;
    7104      1489249 : }
    7105              : 
    7106              : 
    7107              : #include "gt-emit-rtl.h"
        

Generated by: LCOV version 2.4-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.