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

Generated by: LCOV version 2.6-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.