LCOV - code coverage report
Current view: top level - gcc - expr.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 80.6 % 6825 5499
Test Date: 2025-02-01 13:18:56 Functions: 93.8 % 177 166
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Convert tree expression to rtl instructions, for GNU compiler.
       2                 :             :    Copyright (C) 1988-2025 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                 :             : #include "config.h"
      21                 :             : #include "system.h"
      22                 :             : #include "coretypes.h"
      23                 :             : #include "backend.h"
      24                 :             : #include "target.h"
      25                 :             : #include "rtl.h"
      26                 :             : #include "tree.h"
      27                 :             : #include "gimple.h"
      28                 :             : #include "predict.h"
      29                 :             : #include "memmodel.h"
      30                 :             : #include "tm_p.h"
      31                 :             : #include "ssa.h"
      32                 :             : #include "optabs.h"
      33                 :             : #include "expmed.h"
      34                 :             : #include "regs.h"
      35                 :             : #include "emit-rtl.h"
      36                 :             : #include "recog.h"
      37                 :             : #include "cgraph.h"
      38                 :             : #include "diagnostic.h"
      39                 :             : #include "alias.h"
      40                 :             : #include "fold-const.h"
      41                 :             : #include "stor-layout.h"
      42                 :             : #include "attribs.h"
      43                 :             : #include "varasm.h"
      44                 :             : #include "except.h"
      45                 :             : #include "insn-attr.h"
      46                 :             : #include "dojump.h"
      47                 :             : #include "explow.h"
      48                 :             : #include "calls.h"
      49                 :             : #include "stmt.h"
      50                 :             : /* Include expr.h after insn-config.h so we get HAVE_conditional_move.  */
      51                 :             : #include "expr.h"
      52                 :             : #include "optabs-tree.h"
      53                 :             : #include "libfuncs.h"
      54                 :             : #include "reload.h"
      55                 :             : #include "langhooks.h"
      56                 :             : #include "common/common-target.h"
      57                 :             : #include "tree-dfa.h"
      58                 :             : #include "tree-ssa-live.h"
      59                 :             : #include "tree-outof-ssa.h"
      60                 :             : #include "tree-ssa-address.h"
      61                 :             : #include "builtins.h"
      62                 :             : #include "ccmp.h"
      63                 :             : #include "gimple-iterator.h"
      64                 :             : #include "gimple-fold.h"
      65                 :             : #include "rtx-vector-builder.h"
      66                 :             : #include "tree-pretty-print.h"
      67                 :             : #include "flags.h"
      68                 :             : #include "internal-fn.h"
      69                 :             : 
      70                 :             : 
      71                 :             : /* If this is nonzero, we do not bother generating VOLATILE
      72                 :             :    around volatile memory references, and we are willing to
      73                 :             :    output indirect addresses.  If cse is to follow, we reject
      74                 :             :    indirect addresses so a useful potential cse is generated;
      75                 :             :    if it is used only once, instruction combination will produce
      76                 :             :    the same indirect address eventually.  */
      77                 :             : int cse_not_expected;
      78                 :             : 
      79                 :             : static bool block_move_libcall_safe_for_call_parm (void);
      80                 :             : static bool emit_block_move_via_pattern (rtx, rtx, rtx, unsigned, unsigned,
      81                 :             :                                          HOST_WIDE_INT, unsigned HOST_WIDE_INT,
      82                 :             :                                          unsigned HOST_WIDE_INT,
      83                 :             :                                          unsigned HOST_WIDE_INT, bool);
      84                 :             : static void emit_block_move_via_loop (rtx, rtx, rtx, unsigned, int);
      85                 :             : static void emit_block_move_via_sized_loop (rtx, rtx, rtx, unsigned, unsigned);
      86                 :             : static void emit_block_move_via_oriented_loop (rtx, rtx, rtx, unsigned, unsigned);
      87                 :             : static rtx emit_block_cmp_via_loop (rtx, rtx, rtx, tree, rtx, bool,
      88                 :             :                                     unsigned, unsigned);
      89                 :             : static rtx_insn *compress_float_constant (rtx, rtx);
      90                 :             : static rtx get_subtarget (rtx);
      91                 :             : static rtx store_field (rtx, poly_int64, poly_int64, poly_uint64, poly_uint64,
      92                 :             :                         machine_mode, tree, alias_set_type, bool, bool);
      93                 :             : 
      94                 :             : static unsigned HOST_WIDE_INT highest_pow2_factor_for_target (const_tree, const_tree);
      95                 :             : 
      96                 :             : static bool is_aligning_offset (const_tree, const_tree);
      97                 :             : static rtx reduce_to_bit_field_precision (rtx, rtx, tree);
      98                 :             : static rtx do_store_flag (const_sepops, rtx, machine_mode);
      99                 :             : #ifdef PUSH_ROUNDING
     100                 :             : static void emit_single_push_insn (machine_mode, rtx, tree);
     101                 :             : #endif
     102                 :             : static void do_tablejump (rtx, machine_mode, rtx, rtx, rtx,
     103                 :             :                           profile_probability);
     104                 :             : static rtx const_vector_from_tree (tree);
     105                 :             : static tree tree_expr_size (const_tree);
     106                 :             : static void convert_mode_scalar (rtx, rtx, int);
     107                 :             : 
     108                 :             : 
     109                 :             : /* This is run to set up which modes can be used
     110                 :             :    directly in memory and to initialize the block move optab.  It is run
     111                 :             :    at the beginning of compilation and when the target is reinitialized.  */
     112                 :             : 
     113                 :             : void
     114                 :      208913 : init_expr_target (void)
     115                 :             : {
     116                 :      208913 :   rtx pat;
     117                 :      208913 :   int num_clobbers;
     118                 :      208913 :   rtx mem, mem1;
     119                 :      208913 :   rtx reg;
     120                 :             : 
     121                 :             :   /* Try indexing by frame ptr and try by stack ptr.
     122                 :             :      It is known that on the Convex the stack ptr isn't a valid index.
     123                 :             :      With luck, one or the other is valid on any machine.  */
     124                 :      208913 :   mem = gen_rtx_MEM (word_mode, stack_pointer_rtx);
     125                 :      208913 :   mem1 = gen_rtx_MEM (word_mode, frame_pointer_rtx);
     126                 :             : 
     127                 :             :   /* A scratch register we can modify in-place below to avoid
     128                 :             :      useless RTL allocations.  */
     129                 :      208913 :   reg = gen_rtx_REG (word_mode, LAST_VIRTUAL_REGISTER + 1);
     130                 :             : 
     131                 :      208913 :   rtx_insn *insn = as_a<rtx_insn *> (rtx_alloc (INSN));
     132                 :      208913 :   pat = gen_rtx_SET (NULL_RTX, NULL_RTX);
     133                 :      208913 :   PATTERN (insn) = pat;
     134                 :             : 
     135                 :    27367603 :   for (machine_mode mode = VOIDmode; (int) mode < NUM_MACHINE_MODES;
     136                 :    27158690 :        mode = (machine_mode) ((int) mode + 1))
     137                 :             :     {
     138                 :    27158690 :       int regno;
     139                 :             : 
     140                 :    27158690 :       direct_load[(int) mode] = direct_store[(int) mode] = 0;
     141                 :    27158690 :       PUT_MODE (mem, mode);
     142                 :    27158690 :       PUT_MODE (mem1, mode);
     143                 :             : 
     144                 :             :       /* See if there is some register that can be used in this mode and
     145                 :             :          directly loaded or stored from memory.  */
     146                 :             : 
     147                 :    27158690 :       if (mode != VOIDmode && mode != BLKmode)
     148                 :  1861066488 :         for (regno = 0; regno < FIRST_PSEUDO_REGISTER
     149                 :  1887807352 :              && (direct_load[(int) mode] == 0 || direct_store[(int) mode] == 0);
     150                 :             :              regno++)
     151                 :             :           {
     152                 :  1861066488 :             if (!targetm.hard_regno_mode_ok (regno, mode))
     153                 :  1746733812 :               continue;
     154                 :             : 
     155                 :   114332676 :             set_mode_and_regno (reg, mode, regno);
     156                 :             : 
     157                 :   114332676 :             SET_SRC (pat) = mem;
     158                 :   114332676 :             SET_DEST (pat) = reg;
     159                 :   114332676 :             if (recog (pat, insn, &num_clobbers) >= 0)
     160                 :     7029904 :               direct_load[(int) mode] = 1;
     161                 :             : 
     162                 :   114332676 :             SET_SRC (pat) = mem1;
     163                 :   114332676 :             SET_DEST (pat) = reg;
     164                 :   114332676 :             if (recog (pat, insn, &num_clobbers) >= 0)
     165                 :     7029904 :               direct_load[(int) mode] = 1;
     166                 :             : 
     167                 :   114332676 :             SET_SRC (pat) = reg;
     168                 :   114332676 :             SET_DEST (pat) = mem;
     169                 :   114332676 :             if (recog (pat, insn, &num_clobbers) >= 0)
     170                 :     7029904 :               direct_store[(int) mode] = 1;
     171                 :             : 
     172                 :   114332676 :             SET_SRC (pat) = reg;
     173                 :   114332676 :             SET_DEST (pat) = mem1;
     174                 :   114332676 :             if (recog (pat, insn, &num_clobbers) >= 0)
     175                 :     7029904 :               direct_store[(int) mode] = 1;
     176                 :             :           }
     177                 :             :     }
     178                 :             : 
     179                 :      208913 :   mem = gen_rtx_MEM (VOIDmode, gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 1));
     180                 :             : 
     181                 :      208913 :   opt_scalar_float_mode mode_iter;
     182                 :     1462391 :   FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_FLOAT)
     183                 :             :     {
     184                 :     1253478 :       scalar_float_mode mode = mode_iter.require ();
     185                 :     1253478 :       scalar_float_mode srcmode;
     186                 :     4387173 :       FOR_EACH_MODE_UNTIL (srcmode, mode)
     187                 :             :         {
     188                 :     3133695 :           enum insn_code ic;
     189                 :             : 
     190                 :     3133695 :           ic = can_extend_p (mode, srcmode, 0);
     191                 :     3133695 :           if (ic == CODE_FOR_nothing)
     192                 :     2502269 :             continue;
     193                 :             : 
     194                 :      631426 :           PUT_MODE (mem, srcmode);
     195                 :             : 
     196                 :      631426 :           if (insn_operand_matches (ic, 1, mem))
     197                 :      629346 :             float_extend_from_mem[mode][srcmode] = true;
     198                 :             :         }
     199                 :             :     }
     200                 :      208913 : }
     201                 :             : 
     202                 :             : /* This is run at the start of compiling a function.  */
     203                 :             : 
     204                 :             : void
     205                 :     1642372 : init_expr (void)
     206                 :             : {
     207                 :     1642372 :   memset (&crtl->expr, 0, sizeof (crtl->expr));
     208                 :     1642372 : }
     209                 :             : 
     210                 :             : /* Copy data from FROM to TO, where the machine modes are not the same.
     211                 :             :    Both modes may be integer, or both may be floating, or both may be
     212                 :             :    fixed-point.
     213                 :             :    UNSIGNEDP should be nonzero if FROM is an unsigned type.
     214                 :             :    This causes zero-extension instead of sign-extension.  */
     215                 :             : 
     216                 :             : void
     217                 :     1783749 : convert_move (rtx to, rtx from, int unsignedp)
     218                 :             : {
     219                 :     1783749 :   machine_mode to_mode = GET_MODE (to);
     220                 :     1783749 :   machine_mode from_mode = GET_MODE (from);
     221                 :             : 
     222                 :     1783749 :   gcc_assert (to_mode != BLKmode);
     223                 :     1783749 :   gcc_assert (from_mode != BLKmode);
     224                 :             : 
     225                 :             :   /* If the source and destination are already the same, then there's
     226                 :             :      nothing to do.  */
     227                 :     1783749 :   if (to == from)
     228                 :     1783749 :     return;
     229                 :             : 
     230                 :             :   /* If FROM is a SUBREG that indicates that we have already done at least
     231                 :             :      the required extension, strip it.  We don't handle such SUBREGs as
     232                 :             :      TO here.  */
     233                 :             : 
     234                 :     1783749 :   scalar_int_mode to_int_mode;
     235                 :     1783749 :   if (GET_CODE (from) == SUBREG
     236                 :      107925 :       && SUBREG_PROMOTED_VAR_P (from)
     237                 :     1783749 :       && is_a <scalar_int_mode> (to_mode, &to_int_mode)
     238                 :     1783749 :       && (GET_MODE_PRECISION (subreg_promoted_mode (from))
     239                 :           0 :           >= GET_MODE_PRECISION (to_int_mode))
     240                 :     1783749 :       && SUBREG_CHECK_PROMOTED_SIGN (from, unsignedp))
     241                 :             :     {
     242                 :           0 :       scalar_int_mode int_orig_mode;
     243                 :           0 :       scalar_int_mode int_inner_mode;
     244                 :           0 :       machine_mode orig_mode = GET_MODE (from);
     245                 :             : 
     246                 :           0 :       from = gen_lowpart (to_int_mode, SUBREG_REG (from));
     247                 :           0 :       from_mode = to_int_mode;
     248                 :             : 
     249                 :             :       /* Preserve SUBREG_PROMOTED_VAR_P if the new mode is wider than
     250                 :             :          the original mode, but narrower than the inner mode.  */
     251                 :           0 :       if (GET_CODE (from) == SUBREG
     252                 :           0 :           && is_a <scalar_int_mode> (orig_mode, &int_orig_mode)
     253                 :           0 :           && GET_MODE_PRECISION (to_int_mode)
     254                 :           0 :              > GET_MODE_PRECISION (int_orig_mode)
     255                 :           0 :           && is_a <scalar_int_mode> (GET_MODE (SUBREG_REG (from)),
     256                 :             :                                      &int_inner_mode)
     257                 :           0 :           && GET_MODE_PRECISION (int_inner_mode)
     258                 :           0 :              > GET_MODE_PRECISION (to_int_mode))
     259                 :             :         {
     260                 :           0 :           SUBREG_PROMOTED_VAR_P (from) = 1;
     261                 :           0 :           SUBREG_PROMOTED_SET (from, unsignedp);
     262                 :             :         }
     263                 :             :     }
     264                 :             : 
     265                 :     1783749 :   gcc_assert (GET_CODE (to) != SUBREG || !SUBREG_PROMOTED_VAR_P (to));
     266                 :             : 
     267                 :     1783749 :   if (to_mode == from_mode
     268                 :     1735912 :       || (from_mode == VOIDmode && CONSTANT_P (from)))
     269                 :             :     {
     270                 :       48093 :       emit_move_insn (to, from);
     271                 :       48093 :       return;
     272                 :             :     }
     273                 :             : 
     274                 :     1735656 :   if (VECTOR_MODE_P (to_mode) || VECTOR_MODE_P (from_mode))
     275                 :             :     {
     276                 :       28536 :       if (GET_MODE_UNIT_PRECISION (to_mode)
     277                 :       14268 :           > GET_MODE_UNIT_PRECISION (from_mode))
     278                 :             :         {
     279                 :        5564 :           optab op = unsignedp ? zext_optab : sext_optab;
     280                 :        5564 :           insn_code icode = convert_optab_handler (op, to_mode, from_mode);
     281                 :        5564 :           if (icode != CODE_FOR_nothing)
     282                 :             :             {
     283                 :         780 :               emit_unop_insn (icode, to, from,
     284                 :             :                               unsignedp ? ZERO_EXTEND : SIGN_EXTEND);
     285                 :         780 :               return;
     286                 :             :             }
     287                 :             :         }
     288                 :             : 
     289                 :       26976 :       if (GET_MODE_UNIT_PRECISION (to_mode)
     290                 :       13488 :           < GET_MODE_UNIT_PRECISION (from_mode))
     291                 :             :         {
     292                 :        1904 :           insn_code icode = convert_optab_handler (trunc_optab,
     293                 :             :                                                    to_mode, from_mode);
     294                 :        1904 :           if (icode != CODE_FOR_nothing)
     295                 :             :             {
     296                 :         864 :               emit_unop_insn (icode, to, from, TRUNCATE);
     297                 :         864 :               return;
     298                 :             :             }
     299                 :             :         }
     300                 :             : 
     301                 :       37872 :       gcc_assert (known_eq (GET_MODE_BITSIZE (from_mode),
     302                 :             :                             GET_MODE_BITSIZE (to_mode)));
     303                 :             : 
     304                 :       12624 :       if (VECTOR_MODE_P (to_mode))
     305                 :       12624 :         from = force_subreg (to_mode, from, GET_MODE (from), 0);
     306                 :             :       else
     307                 :           0 :         to = simplify_gen_subreg (from_mode, to, GET_MODE (to), 0);
     308                 :             : 
     309                 :       12624 :       emit_move_insn (to, from);
     310                 :       12624 :       return;
     311                 :             :     }
     312                 :             : 
     313                 :     1721388 :   if (GET_CODE (to) == CONCAT && GET_CODE (from) == CONCAT)
     314                 :             :     {
     315                 :           0 :       convert_move (XEXP (to, 0), XEXP (from, 0), unsignedp);
     316                 :           0 :       convert_move (XEXP (to, 1), XEXP (from, 1), unsignedp);
     317                 :           0 :       return;
     318                 :             :     }
     319                 :             : 
     320                 :     1721388 :   convert_mode_scalar (to, from, unsignedp);
     321                 :             : }
     322                 :             : 
     323                 :             : /* Like convert_move, but deals only with scalar modes.  */
     324                 :             : 
     325                 :             : static void
     326                 :     1721432 : convert_mode_scalar (rtx to, rtx from, int unsignedp)
     327                 :             : {
     328                 :             :   /* Both modes should be scalar types.  */
     329                 :     1721437 :   scalar_mode from_mode = as_a <scalar_mode> (GET_MODE (from));
     330                 :     1721437 :   scalar_mode to_mode = as_a <scalar_mode> (GET_MODE (to));
     331                 :     1721437 :   bool to_real = SCALAR_FLOAT_MODE_P (to_mode);
     332                 :     1721437 :   bool from_real = SCALAR_FLOAT_MODE_P (from_mode);
     333                 :     1721437 :   enum insn_code code;
     334                 :     1721437 :   rtx libcall;
     335                 :             : 
     336                 :     1721437 :   gcc_assert (to_real == from_real);
     337                 :             : 
     338                 :             :   /* rtx code for making an equivalent value.  */
     339                 :     1721437 :   enum rtx_code equiv_code = (unsignedp < 0 ? UNKNOWN
     340                 :     1721437 :                               : (unsignedp ? ZERO_EXTEND : SIGN_EXTEND));
     341                 :             : 
     342                 :     1721437 :   auto acceptable_same_precision_modes
     343                 :         580 :     = [] (scalar_mode from_mode, scalar_mode to_mode) -> bool
     344                 :             :     {
     345                 :         580 :       if (DECIMAL_FLOAT_MODE_P (from_mode) != DECIMAL_FLOAT_MODE_P (to_mode))
     346                 :             :         return true;
     347                 :             : 
     348                 :             :       /* arm_bfloat_half_format <-> ieee_half_format */
     349                 :           2 :       if ((REAL_MODE_FORMAT (from_mode) == &arm_bfloat_half_format
     350                 :           1 :            && REAL_MODE_FORMAT (to_mode) == &ieee_half_format)
     351                 :           2 :           || (REAL_MODE_FORMAT (to_mode) == &arm_bfloat_half_format
     352                 :           1 :               && REAL_MODE_FORMAT (from_mode) == &ieee_half_format))
     353                 :             :         return true;
     354                 :             : 
     355                 :             :       /* ibm_extended_format <-> ieee_quad_format */
     356                 :           0 :       if ((REAL_MODE_FORMAT (from_mode) == &ibm_extended_format
     357                 :           0 :            && REAL_MODE_FORMAT (to_mode) == &ieee_quad_format)
     358                 :           0 :           || (REAL_MODE_FORMAT (from_mode) == &ieee_quad_format
     359                 :           0 :               && REAL_MODE_FORMAT (to_mode) == &ibm_extended_format))
     360                 :           0 :         return true;
     361                 :             : 
     362                 :             :       return false;
     363                 :             :     };
     364                 :             : 
     365                 :     1721437 :   if (to_real)
     366                 :             :     {
     367                 :      184500 :       rtx value;
     368                 :      184500 :       rtx_insn *insns;
     369                 :      184500 :       convert_optab tab;
     370                 :             : 
     371                 :      184500 :       gcc_assert ((GET_MODE_PRECISION (from_mode)
     372                 :             :                    != GET_MODE_PRECISION (to_mode))
     373                 :             :                   || acceptable_same_precision_modes (from_mode, to_mode));
     374                 :             : 
     375                 :      184500 :       if (GET_MODE_PRECISION (from_mode) == GET_MODE_PRECISION (to_mode))
     376                 :             :         {
     377                 :         580 :           if ((REAL_MODE_FORMAT (to_mode) == &arm_bfloat_half_format
     378                 :           1 :                && REAL_MODE_FORMAT (from_mode) == &ieee_half_format)
     379                 :         580 :               || (REAL_MODE_FORMAT (to_mode) == &ieee_quad_format
     380                 :           0 :                   && REAL_MODE_FORMAT (from_mode) == &ibm_extended_format))
     381                 :             :             /* libgcc implements just __trunchfbf2, not __extendhfbf2;
     382                 :             :                and __trunctfkf2, not __extendtfkf2.  */
     383                 :             :             tab = trunc_optab;
     384                 :             :           else
     385                 :             :             /* Conversion between decimal float and binary float, same
     386                 :             :                size.  */
     387                 :         579 :             tab = DECIMAL_FLOAT_MODE_P (from_mode) ? trunc_optab : sext_optab;
     388                 :             :         }
     389                 :      183920 :       else if (GET_MODE_PRECISION (from_mode) < GET_MODE_PRECISION (to_mode))
     390                 :             :         tab = sext_optab;
     391                 :             :       else
     392                 :       19108 :         tab = trunc_optab;
     393                 :             : 
     394                 :             :       /* Try converting directly if the insn is supported.  */
     395                 :             : 
     396                 :      184500 :       code = convert_optab_handler (tab, to_mode, from_mode);
     397                 :      184500 :       if (code != CODE_FOR_nothing)
     398                 :             :         {
     399                 :      160249 :           emit_unop_insn (code, to, from,
     400                 :             :                           tab == sext_optab ? FLOAT_EXTEND : FLOAT_TRUNCATE);
     401                 :      160249 :           return;
     402                 :             :         }
     403                 :             : 
     404                 :             : #ifdef HAVE_SFmode
     405                 :       24251 :       if (REAL_MODE_FORMAT (from_mode) == &arm_bfloat_half_format
     406                 :       24251 :           && REAL_MODE_FORMAT (SFmode) == &ieee_single_format)
     407                 :             :         {
     408                 :        2642 :           if (GET_MODE_PRECISION (to_mode) > GET_MODE_PRECISION (SFmode))
     409                 :             :             {
     410                 :             :               /* To cut down on libgcc size, implement
     411                 :             :                  BFmode -> {DF,XF,TF}mode conversions by
     412                 :             :                  BFmode -> SFmode -> {DF,XF,TF}mode conversions.  */
     413                 :           4 :               rtx temp = gen_reg_rtx (SFmode);
     414                 :           4 :               convert_mode_scalar (temp, from, unsignedp);
     415                 :           4 :               convert_mode_scalar (to, temp, unsignedp);
     416                 :           4 :               return;
     417                 :             :             }
     418                 :        2638 :           if (REAL_MODE_FORMAT (to_mode) == &ieee_half_format)
     419                 :             :             {
     420                 :             :               /* Similarly, implement BFmode -> HFmode as
     421                 :             :                  BFmode -> SFmode -> HFmode conversion where SFmode
     422                 :             :                  has superset of BFmode values.  We don't need
     423                 :             :                  to handle sNaNs by raising exception and turning
     424                 :             :                  it into qNaN though, as that can be done in the
     425                 :             :                  SFmode -> HFmode conversion too.  */
     426                 :           1 :               rtx temp = gen_reg_rtx (SFmode);
     427                 :           1 :               int save_flag_finite_math_only = flag_finite_math_only;
     428                 :           1 :               flag_finite_math_only = true;
     429                 :           1 :               convert_mode_scalar (temp, from, unsignedp);
     430                 :           1 :               flag_finite_math_only = save_flag_finite_math_only;
     431                 :           1 :               convert_mode_scalar (to, temp, unsignedp);
     432                 :           1 :               return;
     433                 :             :             }
     434                 :        2637 :           if (to_mode == SFmode
     435                 :        2637 :               && !HONOR_NANS (from_mode)
     436                 :          40 :               && !HONOR_NANS (to_mode)
     437                 :        2677 :               && optimize_insn_for_speed_p ())
     438                 :             :             {
     439                 :             :               /* If we don't expect sNaNs, for BFmode -> SFmode we can just
     440                 :             :                  shift the bits up.  */
     441                 :          39 :               machine_mode fromi_mode, toi_mode;
     442                 :          78 :               if (int_mode_for_size (GET_MODE_BITSIZE (from_mode),
     443                 :          39 :                                      0).exists (&fromi_mode)
     444                 :          39 :                   && int_mode_for_size (GET_MODE_BITSIZE (to_mode),
     445                 :           0 :                                         0).exists (&toi_mode))
     446                 :             :                 {
     447                 :          39 :                   start_sequence ();
     448                 :          39 :                   rtx fromi = force_lowpart_subreg (fromi_mode, from,
     449                 :             :                                                     from_mode);
     450                 :          39 :                   rtx tof = NULL_RTX;
     451                 :          39 :                   if (fromi)
     452                 :             :                     {
     453                 :          39 :                       rtx toi;
     454                 :          39 :                       if (GET_MODE (fromi) == VOIDmode)
     455                 :           0 :                         toi = simplify_unary_operation (ZERO_EXTEND, toi_mode,
     456                 :             :                                                         fromi, fromi_mode);
     457                 :             :                       else
     458                 :             :                         {
     459                 :          39 :                           toi = gen_reg_rtx (toi_mode);
     460                 :          39 :                           convert_mode_scalar (toi, fromi, 1);
     461                 :             :                         }
     462                 :          39 :                       toi
     463                 :          78 :                         = maybe_expand_shift (LSHIFT_EXPR, toi_mode, toi,
     464                 :          39 :                                               GET_MODE_PRECISION (to_mode)
     465                 :          39 :                                               - GET_MODE_PRECISION (from_mode),
     466                 :             :                                               NULL_RTX, 1);
     467                 :          39 :                       if (toi)
     468                 :             :                         {
     469                 :          39 :                           tof = force_lowpart_subreg (to_mode, toi, toi_mode);
     470                 :          39 :                           if (tof)
     471                 :          39 :                             emit_move_insn (to, tof);
     472                 :             :                         }
     473                 :             :                     }
     474                 :          39 :                   insns = get_insns ();
     475                 :          39 :                   end_sequence ();
     476                 :          39 :                   if (tof)
     477                 :             :                     {
     478                 :          39 :                       emit_insn (insns);
     479                 :          39 :                       return;
     480                 :             :                     }
     481                 :             :                 }
     482                 :             :             }
     483                 :             :         }
     484                 :       24207 :       if (REAL_MODE_FORMAT (from_mode) == &ieee_single_format
     485                 :        5015 :           && REAL_MODE_FORMAT (to_mode) == &arm_bfloat_half_format
     486                 :        1818 :           && !HONOR_NANS (from_mode)
     487                 :           0 :           && !HONOR_NANS (to_mode)
     488                 :           0 :           && !flag_rounding_math
     489                 :       24207 :           && optimize_insn_for_speed_p ())
     490                 :             :         {
     491                 :             :           /* If we don't expect qNaNs nor sNaNs and can assume rounding
     492                 :             :              to nearest, we can expand the conversion inline as
     493                 :             :              (fromi + 0x7fff + ((fromi >> 16) & 1)) >> 16.  */
     494                 :           0 :           machine_mode fromi_mode, toi_mode;
     495                 :           0 :           if (int_mode_for_size (GET_MODE_BITSIZE (from_mode),
     496                 :           0 :                                  0).exists (&fromi_mode)
     497                 :           0 :               && int_mode_for_size (GET_MODE_BITSIZE (to_mode),
     498                 :           0 :                                     0).exists (&toi_mode))
     499                 :             :             {
     500                 :           0 :               start_sequence ();
     501                 :           0 :               rtx fromi = force_lowpart_subreg (fromi_mode, from, from_mode);
     502                 :           0 :               rtx tof = NULL_RTX;
     503                 :           0 :               do
     504                 :             :                 {
     505                 :           0 :                   if (!fromi)
     506                 :             :                     break;
     507                 :           0 :                   int shift = (GET_MODE_PRECISION (from_mode)
     508                 :           0 :                                - GET_MODE_PRECISION (to_mode));
     509                 :           0 :                   rtx temp1
     510                 :           0 :                     = maybe_expand_shift (RSHIFT_EXPR, fromi_mode, fromi,
     511                 :             :                                           shift, NULL_RTX, 1);
     512                 :           0 :                   if (!temp1)
     513                 :             :                     break;
     514                 :           0 :                   rtx temp2
     515                 :           0 :                     = expand_binop (fromi_mode, and_optab, temp1, const1_rtx,
     516                 :             :                                     NULL_RTX, 1, OPTAB_DIRECT);
     517                 :           0 :                   if (!temp2)
     518                 :             :                     break;
     519                 :           0 :                   rtx temp3
     520                 :           0 :                     = expand_binop (fromi_mode, add_optab, fromi,
     521                 :           0 :                                     gen_int_mode ((HOST_WIDE_INT_1U
     522                 :           0 :                                                    << (shift - 1)) - 1,
     523                 :             :                                                   fromi_mode), NULL_RTX,
     524                 :             :                                     1, OPTAB_DIRECT);
     525                 :           0 :                   if (!temp3)
     526                 :             :                     break;
     527                 :           0 :                   rtx temp4
     528                 :           0 :                     = expand_binop (fromi_mode, add_optab, temp3, temp2,
     529                 :             :                                     NULL_RTX, 1, OPTAB_DIRECT);
     530                 :           0 :                   if (!temp4)
     531                 :             :                     break;
     532                 :           0 :                   rtx temp5 = maybe_expand_shift (RSHIFT_EXPR, fromi_mode,
     533                 :             :                                                   temp4, shift, NULL_RTX, 1);
     534                 :           0 :                   if (!temp5)
     535                 :             :                     break;
     536                 :           0 :                   rtx temp6 = force_lowpart_subreg (toi_mode, temp5,
     537                 :             :                                                     fromi_mode);
     538                 :           0 :                   if (!temp6)
     539                 :             :                     break;
     540                 :           0 :                   tof = force_lowpart_subreg (to_mode, temp6, toi_mode);
     541                 :           0 :                   if (tof)
     542                 :           0 :                     emit_move_insn (to, tof);
     543                 :             :                 }
     544                 :             :               while (0);
     545                 :           0 :               insns = get_insns ();
     546                 :           0 :               end_sequence ();
     547                 :           0 :               if (tof)
     548                 :             :                 {
     549                 :           0 :                   emit_insn (insns);
     550                 :           0 :                   return;
     551                 :             :                 }
     552                 :             :             }
     553                 :             :         }
     554                 :             : #endif
     555                 :             : 
     556                 :             :       /* Otherwise use a libcall.  */
     557                 :       24207 :       libcall = convert_optab_libfunc (tab, to_mode, from_mode);
     558                 :             : 
     559                 :             :       /* Is this conversion implemented yet?  */
     560                 :       24207 :       gcc_assert (libcall);
     561                 :             : 
     562                 :       24207 :       start_sequence ();
     563                 :       24207 :       value = emit_library_call_value (libcall, NULL_RTX, LCT_CONST, to_mode,
     564                 :             :                                        from, from_mode);
     565                 :       24207 :       insns = get_insns ();
     566                 :       24207 :       end_sequence ();
     567                 :       24207 :       emit_libcall_block (insns, to, value,
     568                 :        7506 :                           tab == trunc_optab ? gen_rtx_FLOAT_TRUNCATE (to_mode,
     569                 :             :                                                                        from)
     570                 :       16701 :                           : gen_rtx_FLOAT_EXTEND (to_mode, from));
     571                 :       24207 :       return;
     572                 :             :     }
     573                 :             : 
     574                 :             :   /* Handle pointer conversion.  */                     /* SPEE 900220.  */
     575                 :             :   /* If the target has a converter from FROM_MODE to TO_MODE, use it.  */
     576                 :     1536937 :   {
     577                 :     1536937 :     convert_optab ctab;
     578                 :             : 
     579                 :     1536937 :     if (GET_MODE_PRECISION (from_mode) > GET_MODE_PRECISION (to_mode))
     580                 :             :       ctab = trunc_optab;
     581                 :     1343930 :     else if (unsignedp)
     582                 :             :       ctab = zext_optab;
     583                 :             :     else
     584                 :      671652 :       ctab = sext_optab;
     585                 :             : 
     586                 :     1536937 :     if (convert_optab_handler (ctab, to_mode, from_mode)
     587                 :             :         != CODE_FOR_nothing)
     588                 :             :       {
     589                 :     1338658 :         emit_unop_insn (convert_optab_handler (ctab, to_mode, from_mode),
     590                 :             :                         to, from, UNKNOWN);
     591                 :     1338658 :         return;
     592                 :             :       }
     593                 :             :   }
     594                 :             : 
     595                 :             :   /* Targets are expected to provide conversion insns between PxImode and
     596                 :             :      xImode for all MODE_PARTIAL_INT modes they use, but no others.  */
     597                 :      198279 :   if (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT)
     598                 :             :     {
     599                 :           0 :       scalar_int_mode full_mode
     600                 :           0 :         = smallest_int_mode_for_size (GET_MODE_BITSIZE (to_mode)).require ();
     601                 :             : 
     602                 :           0 :       gcc_assert (convert_optab_handler (trunc_optab, to_mode, full_mode)
     603                 :             :                   != CODE_FOR_nothing);
     604                 :             : 
     605                 :           0 :       if (full_mode != from_mode)
     606                 :           0 :         from = convert_to_mode (full_mode, from, unsignedp);
     607                 :           0 :       emit_unop_insn (convert_optab_handler (trunc_optab, to_mode, full_mode),
     608                 :             :                       to, from, UNKNOWN);
     609                 :           0 :       return;
     610                 :             :     }
     611                 :      198279 :   if (GET_MODE_CLASS (from_mode) == MODE_PARTIAL_INT)
     612                 :             :     {
     613                 :           0 :       rtx new_from;
     614                 :           0 :       scalar_int_mode full_mode
     615                 :           0 :         = smallest_int_mode_for_size (GET_MODE_BITSIZE (from_mode)).require ();
     616                 :           0 :       convert_optab ctab = unsignedp ? zext_optab : sext_optab;
     617                 :           0 :       enum insn_code icode;
     618                 :             : 
     619                 :           0 :       icode = convert_optab_handler (ctab, full_mode, from_mode);
     620                 :           0 :       gcc_assert (icode != CODE_FOR_nothing);
     621                 :             : 
     622                 :           0 :       if (to_mode == full_mode)
     623                 :             :         {
     624                 :           0 :           emit_unop_insn (icode, to, from, UNKNOWN);
     625                 :           0 :           return;
     626                 :             :         }
     627                 :             : 
     628                 :           0 :       new_from = gen_reg_rtx (full_mode);
     629                 :           0 :       emit_unop_insn (icode, new_from, from, UNKNOWN);
     630                 :             : 
     631                 :             :       /* else proceed to integer conversions below.  */
     632                 :           0 :       from_mode = full_mode;
     633                 :           0 :       from = new_from;
     634                 :             :     }
     635                 :             : 
     636                 :             :    /* Make sure both are fixed-point modes or both are not.  */
     637                 :      198279 :    gcc_assert (ALL_SCALAR_FIXED_POINT_MODE_P (from_mode) ==
     638                 :             :                ALL_SCALAR_FIXED_POINT_MODE_P (to_mode));
     639                 :      198279 :    if (ALL_SCALAR_FIXED_POINT_MODE_P (from_mode))
     640                 :             :     {
     641                 :             :       /* If we widen from_mode to to_mode and they are in the same class,
     642                 :             :          we won't saturate the result.
     643                 :             :          Otherwise, always saturate the result to play safe.  */
     644                 :           0 :       if (GET_MODE_CLASS (from_mode) == GET_MODE_CLASS (to_mode)
     645                 :           0 :           && GET_MODE_SIZE (from_mode) < GET_MODE_SIZE (to_mode))
     646                 :           0 :         expand_fixed_convert (to, from, 0, 0);
     647                 :             :       else
     648                 :           0 :         expand_fixed_convert (to, from, 0, 1);
     649                 :           0 :       return;
     650                 :             :     }
     651                 :             : 
     652                 :             :   /* Now both modes are integers.  */
     653                 :             : 
     654                 :             :   /* Handle expanding beyond a word.  */
     655                 :      198279 :   if (GET_MODE_PRECISION (from_mode) < GET_MODE_PRECISION (to_mode)
     656                 :      200983 :       && GET_MODE_PRECISION (to_mode) > BITS_PER_WORD)
     657                 :             :     {
     658                 :        5272 :       rtx_insn *insns;
     659                 :        5272 :       rtx lowpart;
     660                 :        5272 :       rtx fill_value;
     661                 :        5272 :       rtx lowfrom;
     662                 :        5272 :       int i;
     663                 :        5272 :       scalar_mode lowpart_mode;
     664                 :       10544 :       int nwords = CEIL (GET_MODE_SIZE (to_mode), UNITS_PER_WORD);
     665                 :             : 
     666                 :             :       /* Try converting directly if the insn is supported.  */
     667                 :        5272 :       if ((code = can_extend_p (to_mode, from_mode, unsignedp))
     668                 :             :           != CODE_FOR_nothing)
     669                 :             :         {
     670                 :             :           /* If FROM is a SUBREG, put it into a register.  Do this
     671                 :             :              so that we always generate the same set of insns for
     672                 :             :              better cse'ing; if an intermediate assignment occurred,
     673                 :             :              we won't be doing the operation directly on the SUBREG.  */
     674                 :           0 :           if (optimize > 0 && GET_CODE (from) == SUBREG)
     675                 :           0 :             from = force_reg (from_mode, from);
     676                 :           0 :           emit_unop_insn (code, to, from, equiv_code);
     677                 :           0 :           return;
     678                 :             :         }
     679                 :             :       /* Next, try converting via full word.  */
     680                 :        5272 :       else if (GET_MODE_PRECISION (from_mode) < BITS_PER_WORD
     681                 :        5272 :                && ((code = can_extend_p (to_mode, word_mode, unsignedp))
     682                 :             :                    != CODE_FOR_nothing))
     683                 :             :         {
     684                 :        5272 :           rtx word_to = gen_reg_rtx (word_mode);
     685                 :        5272 :           if (REG_P (to))
     686                 :             :             {
     687                 :        5203 :               if (reg_overlap_mentioned_p (to, from))
     688                 :           0 :                 from = force_reg (from_mode, from);
     689                 :        5203 :               emit_clobber (to);
     690                 :             :             }
     691                 :        5272 :           convert_move (word_to, from, unsignedp);
     692                 :        5272 :           emit_unop_insn (code, to, word_to, equiv_code);
     693                 :        5272 :           return;
     694                 :             :         }
     695                 :             : 
     696                 :             :       /* No special multiword conversion insn; do it by hand.  */
     697                 :           0 :       start_sequence ();
     698                 :             : 
     699                 :             :       /* Since we will turn this into a no conflict block, we must ensure
     700                 :             :          the source does not overlap the target so force it into an isolated
     701                 :             :          register when maybe so.  Likewise for any MEM input, since the
     702                 :             :          conversion sequence might require several references to it and we
     703                 :             :          must ensure we're getting the same value every time.  */
     704                 :             : 
     705                 :           0 :       if (MEM_P (from) || reg_overlap_mentioned_p (to, from))
     706                 :           0 :         from = force_reg (from_mode, from);
     707                 :             : 
     708                 :             :       /* Get a copy of FROM widened to a word, if necessary.  */
     709                 :           0 :       if (GET_MODE_PRECISION (from_mode) < BITS_PER_WORD)
     710                 :           0 :         lowpart_mode = word_mode;
     711                 :             :       else
     712                 :             :         lowpart_mode = from_mode;
     713                 :             : 
     714                 :           0 :       lowfrom = convert_to_mode (lowpart_mode, from, unsignedp);
     715                 :             : 
     716                 :           0 :       lowpart = gen_lowpart (lowpart_mode, to);
     717                 :           0 :       emit_move_insn (lowpart, lowfrom);
     718                 :             : 
     719                 :             :       /* Compute the value to put in each remaining word.  */
     720                 :           0 :       if (unsignedp)
     721                 :           0 :         fill_value = const0_rtx;
     722                 :             :       else
     723                 :           0 :         fill_value = emit_store_flag_force (gen_reg_rtx (word_mode),
     724                 :             :                                             LT, lowfrom, const0_rtx,
     725                 :             :                                             lowpart_mode, 0, -1);
     726                 :             : 
     727                 :             :       /* Fill the remaining words.  */
     728                 :           0 :       for (i = GET_MODE_SIZE (lowpart_mode) / UNITS_PER_WORD; i < nwords; i++)
     729                 :             :         {
     730                 :           0 :           int index = (WORDS_BIG_ENDIAN ? nwords - i - 1 : i);
     731                 :           0 :           rtx subword = operand_subword (to, index, 1, to_mode);
     732                 :             : 
     733                 :           0 :           gcc_assert (subword);
     734                 :             : 
     735                 :           0 :           if (fill_value != subword)
     736                 :           0 :             emit_move_insn (subword, fill_value);
     737                 :             :         }
     738                 :             : 
     739                 :           0 :       insns = get_insns ();
     740                 :           0 :       end_sequence ();
     741                 :             : 
     742                 :           0 :       emit_insn (insns);
     743                 :           0 :       return;
     744                 :             :     }
     745                 :             : 
     746                 :             :   /* Truncating multi-word to a word or less.  */
     747                 :      193007 :   if (GET_MODE_PRECISION (from_mode) > BITS_PER_WORD
     748                 :      193007 :       && GET_MODE_PRECISION (to_mode) <= BITS_PER_WORD)
     749                 :             :     {
     750                 :       70460 :       if (!((MEM_P (from)
     751                 :         555 :              && ! MEM_VOLATILE_P (from)
     752                 :         555 :              && direct_load[(int) to_mode]
     753                 :         555 :              && ! mode_dependent_address_p (XEXP (from, 0),
     754                 :         555 :                                             MEM_ADDR_SPACE (from)))
     755                 :       39747 :             || REG_P (from)
     756                 :             :             || GET_CODE (from) == SUBREG))
     757                 :           0 :         from = force_reg (from_mode, from);
     758                 :       40302 :       convert_move (to, gen_lowpart (word_mode, from), 0);
     759                 :       40302 :       return;
     760                 :             :     }
     761                 :             : 
     762                 :             :   /* Now follow all the conversions between integers
     763                 :             :      no more than a word long.  */
     764                 :             : 
     765                 :             :   /* For truncation, usually we can just refer to FROM in a narrower mode.  */
     766                 :      305410 :   if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode)
     767                 :      152705 :       && TRULY_NOOP_TRUNCATION_MODES_P (to_mode, from_mode))
     768                 :             :     {
     769                 :      164870 :       if (!((MEM_P (from)
     770                 :       12751 :              && ! MEM_VOLATILE_P (from)
     771                 :       12692 :              && direct_load[(int) to_mode]
     772                 :       12692 :              && ! mode_dependent_address_p (XEXP (from, 0),
     773                 :       12692 :                                             MEM_ADDR_SPACE (from)))
     774                 :      140013 :             || REG_P (from)
     775                 :             :             || GET_CODE (from) == SUBREG))
     776                 :         916 :         from = force_reg (from_mode, from);
     777                 :      128764 :       if (REG_P (from) && REGNO (from) < FIRST_PSEUDO_REGISTER
     778                 :      152706 :           && !targetm.hard_regno_mode_ok (REGNO (from), to_mode))
     779                 :           0 :         from = copy_to_reg (from);
     780                 :      152705 :       emit_move_insn (to, gen_lowpart (to_mode, from));
     781                 :      152705 :       return;
     782                 :             :     }
     783                 :             : 
     784                 :             :   /* Handle extension.  */
     785                 :           0 :   if (GET_MODE_PRECISION (to_mode) > GET_MODE_PRECISION (from_mode))
     786                 :             :     {
     787                 :             :       /* Convert directly if that works.  */
     788                 :           0 :       if ((code = can_extend_p (to_mode, from_mode, unsignedp))
     789                 :             :           != CODE_FOR_nothing)
     790                 :             :         {
     791                 :           0 :           emit_unop_insn (code, to, from, equiv_code);
     792                 :           0 :           return;
     793                 :             :         }
     794                 :             :       else
     795                 :             :         {
     796                 :           0 :           rtx tmp;
     797                 :           0 :           int shift_amount;
     798                 :             : 
     799                 :             :           /* Search for a mode to convert via.  */
     800                 :           0 :           opt_scalar_mode intermediate_iter;
     801                 :           0 :           FOR_EACH_MODE_FROM (intermediate_iter, from_mode)
     802                 :             :             {
     803                 :           0 :               scalar_mode intermediate = intermediate_iter.require ();
     804                 :           0 :               if (((can_extend_p (to_mode, intermediate, unsignedp)
     805                 :             :                     != CODE_FOR_nothing)
     806                 :           0 :                    || (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (intermediate)
     807                 :           0 :                        && TRULY_NOOP_TRUNCATION_MODES_P (to_mode,
     808                 :             :                                                          intermediate)))
     809                 :           0 :                   && (can_extend_p (intermediate, from_mode, unsignedp)
     810                 :             :                       != CODE_FOR_nothing))
     811                 :             :                 {
     812                 :           0 :                   convert_move (to, convert_to_mode (intermediate, from,
     813                 :             :                                                      unsignedp), unsignedp);
     814                 :           0 :                   return;
     815                 :             :                 }
     816                 :             :             }
     817                 :             : 
     818                 :             :           /* No suitable intermediate mode.
     819                 :             :              Generate what we need with shifts.  */
     820                 :           0 :           shift_amount = (GET_MODE_PRECISION (to_mode)
     821                 :           0 :                           - GET_MODE_PRECISION (from_mode));
     822                 :           0 :           from = gen_lowpart (to_mode, force_reg (from_mode, from));
     823                 :           0 :           tmp = expand_shift (LSHIFT_EXPR, to_mode, from, shift_amount,
     824                 :             :                               to, unsignedp);
     825                 :           0 :           tmp = expand_shift (RSHIFT_EXPR, to_mode, tmp, shift_amount,
     826                 :             :                               to, unsignedp);
     827                 :           0 :           if (tmp != to)
     828                 :           0 :             emit_move_insn (to, tmp);
     829                 :           0 :           return;
     830                 :             :         }
     831                 :             :     }
     832                 :             : 
     833                 :             :   /* Support special truncate insns for certain modes.  */
     834                 :           0 :   if (convert_optab_handler (trunc_optab, to_mode,
     835                 :             :                              from_mode) != CODE_FOR_nothing)
     836                 :             :     {
     837                 :           0 :       emit_unop_insn (convert_optab_handler (trunc_optab, to_mode, from_mode),
     838                 :             :                       to, from, UNKNOWN);
     839                 :           0 :       return;
     840                 :             :     }
     841                 :             : 
     842                 :             :   /* Handle truncation of volatile memrefs, and so on;
     843                 :             :      the things that couldn't be truncated directly,
     844                 :             :      and for which there was no special instruction.
     845                 :             : 
     846                 :             :      ??? Code above formerly short-circuited this, for most integer
     847                 :             :      mode pairs, with a force_reg in from_mode followed by a recursive
     848                 :             :      call to this routine.  Appears always to have been wrong.  */
     849                 :           0 :   if (GET_MODE_PRECISION (to_mode) < GET_MODE_PRECISION (from_mode))
     850                 :             :     {
     851                 :           0 :       rtx temp = force_reg (to_mode, gen_lowpart (to_mode, from));
     852                 :           0 :       emit_move_insn (to, temp);
     853                 :           0 :       return;
     854                 :             :     }
     855                 :             : 
     856                 :             :   /* Mode combination is not recognized.  */
     857                 :           0 :   gcc_unreachable ();
     858                 :             : }
     859                 :             : 
     860                 :             : /* Return an rtx for a value that would result
     861                 :             :    from converting X to mode MODE.
     862                 :             :    Both X and MODE may be floating, or both integer.
     863                 :             :    UNSIGNEDP is nonzero if X is an unsigned value.
     864                 :             :    This can be done by referring to a part of X in place
     865                 :             :    or by copying to a new temporary with conversion.  */
     866                 :             : 
     867                 :             : rtx
     868                 :     1771582 : convert_to_mode (machine_mode mode, rtx x, int unsignedp)
     869                 :             : {
     870                 :     1771582 :   return convert_modes (mode, VOIDmode, x, unsignedp);
     871                 :             : }
     872                 :             : 
     873                 :             : /* Return an rtx for a value that would result
     874                 :             :    from converting X from mode OLDMODE to mode MODE.
     875                 :             :    Both modes may be floating, or both integer.
     876                 :             :    UNSIGNEDP is nonzero if X is an unsigned value.
     877                 :             : 
     878                 :             :    This can be done by referring to a part of X in place
     879                 :             :    or by copying to a new temporary with conversion.
     880                 :             : 
     881                 :             :    You can give VOIDmode for OLDMODE, if you are sure X has a nonvoid mode.  */
     882                 :             : 
     883                 :             : rtx
     884                 :     4124611 : convert_modes (machine_mode mode, machine_mode oldmode, rtx x, int unsignedp)
     885                 :             : {
     886                 :     4124611 :   rtx temp;
     887                 :     4124611 :   scalar_int_mode int_mode;
     888                 :             : 
     889                 :             :   /* If FROM is a SUBREG that indicates that we have already done at least
     890                 :             :      the required extension, strip it.  */
     891                 :             : 
     892                 :     4124611 :   if (GET_CODE (x) == SUBREG
     893                 :       74245 :       && SUBREG_PROMOTED_VAR_P (x)
     894                 :     4124611 :       && is_a <scalar_int_mode> (mode, &int_mode)
     895                 :     4124611 :       && (GET_MODE_PRECISION (subreg_promoted_mode (x))
     896                 :           3 :           >= GET_MODE_PRECISION (int_mode))
     897                 :     4124614 :       && SUBREG_CHECK_PROMOTED_SIGN (x, unsignedp))
     898                 :             :     {
     899                 :           3 :       scalar_int_mode int_orig_mode;
     900                 :           3 :       scalar_int_mode int_inner_mode;
     901                 :           3 :       machine_mode orig_mode = GET_MODE (x);
     902                 :           3 :       x = gen_lowpart (int_mode, SUBREG_REG (x));
     903                 :             : 
     904                 :             :       /* Preserve SUBREG_PROMOTED_VAR_P if the new mode is wider than
     905                 :             :          the original mode, but narrower than the inner mode.  */
     906                 :           3 :       if (GET_CODE (x) == SUBREG
     907                 :           0 :           && is_a <scalar_int_mode> (orig_mode, &int_orig_mode)
     908                 :           0 :           && GET_MODE_PRECISION (int_mode)
     909                 :           0 :              > GET_MODE_PRECISION (int_orig_mode)
     910                 :           0 :           && is_a <scalar_int_mode> (GET_MODE (SUBREG_REG (x)),
     911                 :             :                                      &int_inner_mode)
     912                 :           3 :           && GET_MODE_PRECISION (int_inner_mode)
     913                 :           0 :              > GET_MODE_PRECISION (int_mode))
     914                 :             :         {
     915                 :           0 :           SUBREG_PROMOTED_VAR_P (x) = 1;
     916                 :           0 :           SUBREG_PROMOTED_SET (x, unsignedp);
     917                 :             :         }
     918                 :             :     }
     919                 :             : 
     920                 :     4124611 :   if (GET_MODE (x) != VOIDmode)
     921                 :     2223159 :     oldmode = GET_MODE (x);
     922                 :             : 
     923                 :     4124611 :   if (mode == oldmode)
     924                 :             :     return x;
     925                 :             : 
     926                 :     3141764 :   if (CONST_SCALAR_INT_P (x)
     927                 :     3141764 :       && is_a <scalar_int_mode> (mode, &int_mode))
     928                 :             :     {
     929                 :             :       /* If the caller did not tell us the old mode, then there is not
     930                 :             :          much to do with respect to canonicalization.  We have to
     931                 :             :          assume that all the bits are significant.  */
     932                 :     1594851 :       if (!is_a <scalar_int_mode> (oldmode))
     933                 :     1529985 :         oldmode = MAX_MODE_INT;
     934                 :     1594851 :       wide_int w = wide_int::from (rtx_mode_t (x, oldmode),
     935                 :     1594851 :                                    GET_MODE_PRECISION (int_mode),
     936                 :     2160688 :                                    unsignedp ? UNSIGNED : SIGNED);
     937                 :     1594851 :       return immed_wide_int_const (w, int_mode);
     938                 :     1594851 :     }
     939                 :             : 
     940                 :             :   /* We can do this with a gen_lowpart if both desired and current modes
     941                 :             :      are integer, and this is either a constant integer, a register, or a
     942                 :             :      non-volatile MEM. */
     943                 :     1546913 :   scalar_int_mode int_oldmode;
     944                 :     1546913 :   if (is_int_mode (mode, &int_mode)
     945                 :     1455064 :       && is_int_mode (oldmode, &int_oldmode)
     946                 :     1455064 :       && GET_MODE_PRECISION (int_mode) <= GET_MODE_PRECISION (int_oldmode)
     947                 :      535631 :       && ((MEM_P (x) && !MEM_VOLATILE_P (x) && direct_load[(int) int_mode])
     948                 :       10482 :           || CONST_POLY_INT_P (x)
     949                 :      525149 :           || (REG_P (x)
     950                 :      488719 :               && (!HARD_REGISTER_P (x)
     951                 :        1027 :                   || targetm.hard_regno_mode_ok (REGNO (x), int_mode))
     952                 :      488719 :               && TRULY_NOOP_TRUNCATION_MODES_P (int_mode, GET_MODE (x)))))
     953                 :      499201 :    return gen_lowpart (int_mode, x);
     954                 :             : 
     955                 :             :   /* Converting from integer constant into mode is always equivalent to an
     956                 :             :      subreg operation.  */
     957                 :     1047712 :   if (VECTOR_MODE_P (mode) && GET_MODE (x) == VOIDmode)
     958                 :             :     {
     959                 :           0 :       gcc_assert (known_eq (GET_MODE_BITSIZE (mode),
     960                 :             :                             GET_MODE_BITSIZE (oldmode)));
     961                 :           0 :       return force_subreg (mode, x, oldmode, 0);
     962                 :             :     }
     963                 :             : 
     964                 :     1047712 :   temp = gen_reg_rtx (mode);
     965                 :     1047712 :   convert_move (temp, x, unsignedp);
     966                 :     1047712 :   return temp;
     967                 :             : }
     968                 :             : 
     969                 :             : /* Variant of convert_modes for ABI parameter passing/return.
     970                 :             :    Return an rtx for a value that would result from converting X from
     971                 :             :    a floating point mode FMODE to wider integer mode MODE.  */
     972                 :             : 
     973                 :             : rtx
     974                 :           0 : convert_float_to_wider_int (machine_mode mode, machine_mode fmode, rtx x)
     975                 :             : {
     976                 :           0 :   gcc_assert (SCALAR_INT_MODE_P (mode) && SCALAR_FLOAT_MODE_P (fmode));
     977                 :           0 :   scalar_int_mode tmp_mode = int_mode_for_mode (fmode).require ();
     978                 :           0 :   rtx tmp = force_reg (tmp_mode, gen_lowpart (tmp_mode, x));
     979                 :           0 :   return convert_modes (mode, tmp_mode, tmp, 1);
     980                 :             : }
     981                 :             : 
     982                 :             : /* Variant of convert_modes for ABI parameter passing/return.
     983                 :             :    Return an rtx for a value that would result from converting X from
     984                 :             :    an integer mode IMODE to a narrower floating point mode MODE.  */
     985                 :             : 
     986                 :             : rtx
     987                 :           0 : convert_wider_int_to_float (machine_mode mode, machine_mode imode, rtx x)
     988                 :             : {
     989                 :           0 :   gcc_assert (SCALAR_FLOAT_MODE_P (mode) && SCALAR_INT_MODE_P (imode));
     990                 :           0 :   scalar_int_mode tmp_mode = int_mode_for_mode (mode).require ();
     991                 :           0 :   rtx tmp = force_reg (tmp_mode, gen_lowpart (tmp_mode, x));
     992                 :           0 :   return gen_lowpart_SUBREG (mode, tmp);
     993                 :             : }
     994                 :             : 
     995                 :             : /* Return the largest alignment we can use for doing a move (or store)
     996                 :             :    of MAX_PIECES.  ALIGN is the largest alignment we could use.  */
     997                 :             : 
     998                 :             : static unsigned int
     999                 :     2484759 : alignment_for_piecewise_move (unsigned int max_pieces, unsigned int align)
    1000                 :             : {
    1001                 :     2484759 :   scalar_int_mode tmode
    1002                 :     2484759 :     = int_mode_for_size (max_pieces * BITS_PER_UNIT, 0).require ();
    1003                 :             : 
    1004                 :     2484759 :   if (align >= GET_MODE_ALIGNMENT (tmode))
    1005                 :     1938336 :     align = GET_MODE_ALIGNMENT (tmode);
    1006                 :             :   else
    1007                 :             :     {
    1008                 :      546423 :       scalar_int_mode xmode = NARROWEST_INT_MODE;
    1009                 :      546423 :       opt_scalar_int_mode mode_iter;
    1010                 :     3287482 :       FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
    1011                 :             :         {
    1012                 :     3283313 :           tmode = mode_iter.require ();
    1013                 :     3283313 :           if (GET_MODE_SIZE (tmode) > max_pieces
    1014                 :     3283313 :               || targetm.slow_unaligned_access (tmode, align))
    1015                 :             :             break;
    1016                 :     2741059 :           xmode = tmode;
    1017                 :             :         }
    1018                 :             : 
    1019                 :      546423 :       align = MAX (align, GET_MODE_ALIGNMENT (xmode));
    1020                 :             :     }
    1021                 :             : 
    1022                 :     2484759 :   return align;
    1023                 :             : }
    1024                 :             : 
    1025                 :             : /* Return true if we know how to implement OP using vectors of bytes.  */
    1026                 :             : static bool
    1027                 :     5306392 : can_use_qi_vectors (by_pieces_operation op)
    1028                 :             : {
    1029                 :     5306392 :   return (op == COMPARE_BY_PIECES
    1030                 :     5306392 :           || op == SET_BY_PIECES
    1031                 :     5306392 :           || op == CLEAR_BY_PIECES);
    1032                 :             : }
    1033                 :             : 
    1034                 :             : /* Return true if optabs exists for the mode and certain by pieces
    1035                 :             :    operations.  */
    1036                 :             : static bool
    1037                 :    23519552 : by_pieces_mode_supported_p (fixed_size_mode mode, by_pieces_operation op)
    1038                 :             : {
    1039                 :    23519552 :   if (optab_handler (mov_optab, mode) == CODE_FOR_nothing)
    1040                 :             :     return false;
    1041                 :             : 
    1042                 :    22683983 :   if ((op == SET_BY_PIECES || op == CLEAR_BY_PIECES)
    1043                 :      483446 :       && VECTOR_MODE_P (mode)
    1044                 :    23013317 :       && optab_handler (vec_duplicate_optab, mode) == CODE_FOR_nothing)
    1045                 :             :     return false;
    1046                 :             : 
    1047                 :    22640590 :   if (op == COMPARE_BY_PIECES
    1048                 :    22640590 :       && !can_compare_p (EQ, mode, ccp_jump))
    1049                 :             :     return false;
    1050                 :             : 
    1051                 :             :   return true;
    1052                 :             : }
    1053                 :             : 
    1054                 :             : /* Return the widest mode that can be used to perform part of an
    1055                 :             :    operation OP on SIZE bytes.  Try to use QI vector modes where
    1056                 :             :    possible.  */
    1057                 :             : static fixed_size_mode
    1058                 :     4834334 : widest_fixed_size_mode_for_size (unsigned int size, by_pieces_operation op)
    1059                 :             : {
    1060                 :     4834334 :   fixed_size_mode result = NARROWEST_INT_MODE;
    1061                 :             : 
    1062                 :     4834334 :   gcc_checking_assert (size > 1);
    1063                 :             : 
    1064                 :             :   /* Use QI vector only if size is wider than a WORD.  */
    1065                 :     4834334 :   if (can_use_qi_vectors (op))
    1066                 :             :     {
    1067                 :      462709 :       machine_mode mode;
    1068                 :      462709 :       fixed_size_mode candidate;
    1069                 :     7430868 :       FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_INT)
    1070                 :     7430868 :         if (is_a<fixed_size_mode> (mode, &candidate)
    1071                 :     8451136 :             && GET_MODE_SIZE (candidate) > UNITS_PER_WORD
    1072                 :     7966248 :             && GET_MODE_INNER (candidate) == QImode)
    1073                 :             :           {
    1074                 :     3511934 :             if (GET_MODE_SIZE (candidate) >= size)
    1075                 :             :               break;
    1076                 :     1293258 :             if (by_pieces_mode_supported_p (candidate, op))
    1077                 :     6968159 :               result = candidate;
    1078                 :             :           }
    1079                 :             : 
    1080                 :      462709 :       if (result != NARROWEST_INT_MODE)
    1081                 :      274034 :         return result;
    1082                 :             :     }
    1083                 :             : 
    1084                 :     4560300 :   opt_scalar_int_mode tmode;
    1085                 :     4560300 :   scalar_int_mode mode;
    1086                 :    36482400 :   FOR_EACH_MODE_IN_CLASS (tmode, MODE_INT)
    1087                 :             :     {
    1088                 :    31922100 :       mode = tmode.require ();
    1089                 :    31922100 :       if (GET_MODE_SIZE (mode) < size
    1090                 :    31922100 :           && by_pieces_mode_supported_p (mode, op))
    1091                 :    22189475 :       result = mode;
    1092                 :             :     }
    1093                 :             : 
    1094                 :     4560300 :   return result;
    1095                 :             : }
    1096                 :             : 
    1097                 :             : /* Determine whether an operation OP on LEN bytes with alignment ALIGN can
    1098                 :             :    and should be performed piecewise.  */
    1099                 :             : 
    1100                 :             : static bool
    1101                 :      908944 : can_do_by_pieces (unsigned HOST_WIDE_INT len, unsigned int align,
    1102                 :             :                   enum by_pieces_operation op)
    1103                 :             : {
    1104                 :      908944 :   return targetm.use_by_pieces_infrastructure_p (len, align, op,
    1105                 :      908944 :                                                  optimize_insn_for_speed_p ());
    1106                 :             : }
    1107                 :             : 
    1108                 :             : /* Determine whether the LEN bytes can be moved by using several move
    1109                 :             :    instructions.  Return nonzero if a call to move_by_pieces should
    1110                 :             :    succeed.  */
    1111                 :             : 
    1112                 :             : bool
    1113                 :      872357 : can_move_by_pieces (unsigned HOST_WIDE_INT len, unsigned int align)
    1114                 :             : {
    1115                 :      872357 :   return can_do_by_pieces (len, align, MOVE_BY_PIECES);
    1116                 :             : }
    1117                 :             : 
    1118                 :             : /* Return number of insns required to perform operation OP by pieces
    1119                 :             :    for L bytes.  ALIGN (in bits) is maximum alignment we can assume.  */
    1120                 :             : 
    1121                 :             : unsigned HOST_WIDE_INT
    1122                 :     1758710 : by_pieces_ninsns (unsigned HOST_WIDE_INT l, unsigned int align,
    1123                 :             :                   unsigned int max_size, by_pieces_operation op)
    1124                 :             : {
    1125                 :     1758710 :   unsigned HOST_WIDE_INT n_insns = 0;
    1126                 :     1758710 :   fixed_size_mode mode;
    1127                 :             : 
    1128                 :     1758710 :   if (targetm.overlap_op_by_pieces_p ())
    1129                 :             :     {
    1130                 :             :       /* NB: Round up L and ALIGN to the widest integer mode for
    1131                 :             :          MAX_SIZE.  */
    1132                 :     1758710 :       mode = widest_fixed_size_mode_for_size (max_size, op);
    1133                 :     1758710 :       gcc_assert (optab_handler (mov_optab, mode) != CODE_FOR_nothing);
    1134                 :     3517420 :       unsigned HOST_WIDE_INT up = ROUND_UP (l, GET_MODE_SIZE (mode));
    1135                 :     1758710 :       if (up > l)
    1136                 :             :         l = up;
    1137                 :     1758710 :       align = GET_MODE_ALIGNMENT (mode);
    1138                 :             :     }
    1139                 :             : 
    1140                 :     1758710 :   align = alignment_for_piecewise_move (MOVE_MAX_PIECES, align);
    1141                 :             : 
    1142                 :     5292526 :   while (max_size > 1 && l > 0)
    1143                 :             :     {
    1144                 :     1775106 :       mode = widest_fixed_size_mode_for_size (max_size, op);
    1145                 :     1775106 :       gcc_assert (optab_handler (mov_optab, mode) != CODE_FOR_nothing);
    1146                 :             : 
    1147                 :     1775106 :       unsigned int modesize = GET_MODE_SIZE (mode);
    1148                 :             : 
    1149                 :     1775106 :       if (align >= GET_MODE_ALIGNMENT (mode))
    1150                 :             :         {
    1151                 :     1775106 :           unsigned HOST_WIDE_INT n_pieces = l / modesize;
    1152                 :     1775106 :           l %= modesize;
    1153                 :     1775106 :           switch (op)
    1154                 :             :             {
    1155                 :     1738519 :             default:
    1156                 :     1738519 :               n_insns += n_pieces;
    1157                 :     1738519 :               break;
    1158                 :             : 
    1159                 :       36587 :             case COMPARE_BY_PIECES:
    1160                 :       36587 :               int batch = targetm.compare_by_pieces_branch_ratio (mode);
    1161                 :       36587 :               int batch_ops = 4 * batch - 1;
    1162                 :       36587 :               unsigned HOST_WIDE_INT full = n_pieces / batch;
    1163                 :       36587 :               n_insns += full * batch_ops;
    1164                 :       36587 :               if (n_pieces % batch != 0)
    1165                 :           0 :                 n_insns++;
    1166                 :             :               break;
    1167                 :             : 
    1168                 :             :             }
    1169                 :             :         }
    1170                 :             :       max_size = modesize;
    1171                 :             :     }
    1172                 :             : 
    1173                 :     1758710 :   gcc_assert (!l);
    1174                 :     1758710 :   return n_insns;
    1175                 :             : }
    1176                 :             : 
    1177                 :             : /* Used when performing piecewise block operations, holds information
    1178                 :             :    about one of the memory objects involved.  The member functions
    1179                 :             :    can be used to generate code for loading from the object and
    1180                 :             :    updating the address when iterating.  */
    1181                 :             : 
    1182                 :             : class pieces_addr
    1183                 :             : {
    1184                 :             :   /* The object being referenced, a MEM.  Can be NULL_RTX to indicate
    1185                 :             :      stack pushes.  */
    1186                 :             :   rtx m_obj;
    1187                 :             :   /* The address of the object.  Can differ from that seen in the
    1188                 :             :      MEM rtx if we copied the address to a register.  */
    1189                 :             :   rtx m_addr;
    1190                 :             :   /* Nonzero if the address on the object has an autoincrement already,
    1191                 :             :      signifies whether that was an increment or decrement.  */
    1192                 :             :   signed char m_addr_inc;
    1193                 :             :   /* Nonzero if we intend to use autoinc without the address already
    1194                 :             :      having autoinc form.  We will insert add insns around each memory
    1195                 :             :      reference, expecting later passes to form autoinc addressing modes.
    1196                 :             :      The only supported options are predecrement and postincrement.  */
    1197                 :             :   signed char m_explicit_inc;
    1198                 :             :   /* True if we have either of the two possible cases of using
    1199                 :             :      autoincrement.  */
    1200                 :             :   bool m_auto;
    1201                 :             :   /* True if this is an address to be used for load operations rather
    1202                 :             :      than stores.  */
    1203                 :             :   bool m_is_load;
    1204                 :             : 
    1205                 :             :   /* Optionally, a function to obtain constants for any given offset into
    1206                 :             :      the objects, and data associated with it.  */
    1207                 :             :   by_pieces_constfn m_constfn;
    1208                 :             :   void *m_cfndata;
    1209                 :             : public:
    1210                 :             :   pieces_addr (rtx, bool, by_pieces_constfn, void *);
    1211                 :             :   rtx adjust (fixed_size_mode, HOST_WIDE_INT, by_pieces_prev * = nullptr);
    1212                 :             :   void increment_address (HOST_WIDE_INT);
    1213                 :             :   void maybe_predec (HOST_WIDE_INT);
    1214                 :             :   void maybe_postinc (HOST_WIDE_INT);
    1215                 :             :   void decide_autoinc (machine_mode, bool, HOST_WIDE_INT);
    1216                 :      679135 :   int get_addr_inc ()
    1217                 :             :   {
    1218                 :      679135 :     return m_addr_inc;
    1219                 :             :   }
    1220                 :             : };
    1221                 :             : 
    1222                 :             : /* Initialize a pieces_addr structure from an object OBJ.  IS_LOAD is
    1223                 :             :    true if the operation to be performed on this object is a load
    1224                 :             :    rather than a store.  For stores, OBJ can be NULL, in which case we
    1225                 :             :    assume the operation is a stack push.  For loads, the optional
    1226                 :             :    CONSTFN and its associated CFNDATA can be used in place of the
    1227                 :             :    memory load.  */
    1228                 :             : 
    1229                 :     1358270 : pieces_addr::pieces_addr (rtx obj, bool is_load, by_pieces_constfn constfn,
    1230                 :     1358270 :                           void *cfndata)
    1231                 :     1358270 :   : m_obj (obj), m_is_load (is_load), m_constfn (constfn), m_cfndata (cfndata)
    1232                 :             : {
    1233                 :     1358270 :   m_addr_inc = 0;
    1234                 :     1358270 :   m_auto = false;
    1235                 :     1358270 :   if (obj)
    1236                 :             :     {
    1237                 :     1269079 :       rtx addr = XEXP (obj, 0);
    1238                 :     1269079 :       rtx_code code = GET_CODE (addr);
    1239                 :     1269079 :       m_addr = addr;
    1240                 :     1269079 :       bool dec = code == PRE_DEC || code == POST_DEC;
    1241                 :     1269079 :       bool inc = code == PRE_INC || code == POST_INC;
    1242                 :     1269079 :       m_auto = inc || dec;
    1243                 :     1269079 :       if (m_auto)
    1244                 :           0 :         m_addr_inc = dec ? -1 : 1;
    1245                 :             : 
    1246                 :             :       /* While we have always looked for these codes here, the code
    1247                 :             :          implementing the memory operation has never handled them.
    1248                 :             :          Support could be added later if necessary or beneficial.  */
    1249                 :     1269079 :       gcc_assert (code != PRE_INC && code != POST_DEC);
    1250                 :             :     }
    1251                 :             :   else
    1252                 :             :     {
    1253                 :       89191 :       m_addr = NULL_RTX;
    1254                 :       89191 :       if (!is_load)
    1255                 :             :         {
    1256                 :          45 :           m_auto = true;
    1257                 :          45 :           if (STACK_GROWS_DOWNWARD)
    1258                 :          45 :             m_addr_inc = -1;
    1259                 :             :           else
    1260                 :             :             m_addr_inc = 1;
    1261                 :             :         }
    1262                 :             :       else
    1263                 :       89146 :         gcc_assert (constfn != NULL);
    1264                 :             :     }
    1265                 :     1358270 :   m_explicit_inc = 0;
    1266                 :     1358270 :   if (constfn)
    1267                 :      111002 :     gcc_assert (is_load);
    1268                 :     1358270 : }
    1269                 :             : 
    1270                 :             : /* Decide whether to use autoinc for an address involved in a memory op.
    1271                 :             :    MODE is the mode of the accesses, REVERSE is true if we've decided to
    1272                 :             :    perform the operation starting from the end, and LEN is the length of
    1273                 :             :    the operation.  Don't override an earlier decision to set m_auto.  */
    1274                 :             : 
    1275                 :             : void
    1276                 :      359858 : pieces_addr::decide_autoinc (machine_mode ARG_UNUSED (mode), bool reverse,
    1277                 :             :                              HOST_WIDE_INT len)
    1278                 :             : {
    1279                 :      359858 :   if (m_auto || m_obj == NULL_RTX)
    1280                 :             :     return;
    1281                 :             : 
    1282                 :      337374 :   bool use_predec = (m_is_load
    1283                 :             :                      ? USE_LOAD_PRE_DECREMENT (mode)
    1284                 :             :                      : USE_STORE_PRE_DECREMENT (mode));
    1285                 :      337374 :   bool use_postinc = (m_is_load
    1286                 :             :                       ? USE_LOAD_POST_INCREMENT (mode)
    1287                 :             :                       : USE_STORE_POST_INCREMENT (mode));
    1288                 :      337374 :   machine_mode addr_mode = get_address_mode (m_obj);
    1289                 :             : 
    1290                 :      337374 :   if (use_predec && reverse)
    1291                 :             :     {
    1292                 :             :       m_addr = copy_to_mode_reg (addr_mode,
    1293                 :             :                                  plus_constant (addr_mode,
    1294                 :             :                                                 m_addr, len));
    1295                 :             :       m_auto = true;
    1296                 :             :       m_explicit_inc = -1;
    1297                 :             :     }
    1298                 :      337374 :   else if (use_postinc && !reverse)
    1299                 :             :     {
    1300                 :             :       m_addr = copy_to_mode_reg (addr_mode, m_addr);
    1301                 :             :       m_auto = true;
    1302                 :             :       m_explicit_inc = 1;
    1303                 :             :     }
    1304                 :      337374 :   else if (CONSTANT_P (m_addr))
    1305                 :       70549 :     m_addr = copy_to_mode_reg (addr_mode, m_addr);
    1306                 :             : }
    1307                 :             : 
    1308                 :             : /* Adjust the address to refer to the data at OFFSET in MODE.  If we
    1309                 :             :    are using autoincrement for this address, we don't add the offset,
    1310                 :             :    but we still modify the MEM's properties.  */
    1311                 :             : 
    1312                 :             : rtx
    1313                 :     3841860 : pieces_addr::adjust (fixed_size_mode mode, HOST_WIDE_INT offset,
    1314                 :             :                      by_pieces_prev *prev)
    1315                 :             : {
    1316                 :     3841860 :   if (m_constfn)
    1317                 :             :     /* Pass the previous data to m_constfn.  */
    1318                 :      262292 :     return m_constfn (m_cfndata, prev, offset, mode);
    1319                 :     3579568 :   if (m_obj == NULL_RTX)
    1320                 :             :     return NULL_RTX;
    1321                 :     3579521 :   if (m_auto)
    1322                 :           0 :     return adjust_automodify_address (m_obj, mode, m_addr, offset);
    1323                 :             :   else
    1324                 :     3579521 :     return adjust_address (m_obj, mode, offset);
    1325                 :             : }
    1326                 :             : 
    1327                 :             : /* Emit an add instruction to increment the address by SIZE.  */
    1328                 :             : 
    1329                 :             : void
    1330                 :           0 : pieces_addr::increment_address (HOST_WIDE_INT size)
    1331                 :             : {
    1332                 :           0 :   rtx amount = gen_int_mode (size, GET_MODE (m_addr));
    1333                 :           0 :   emit_insn (gen_add2_insn (m_addr, amount));
    1334                 :           0 : }
    1335                 :             : 
    1336                 :             : /* If we are supposed to decrement the address after each access, emit code
    1337                 :             :    to do so now.  Increment by SIZE (which has should have the correct sign
    1338                 :             :    already).  */
    1339                 :             : 
    1340                 :             : void
    1341                 :     3841324 : pieces_addr::maybe_predec (HOST_WIDE_INT size)
    1342                 :             : {
    1343                 :     3841324 :   if (m_explicit_inc >= 0)
    1344                 :     3841324 :     return;
    1345                 :           0 :   gcc_assert (HAVE_PRE_DECREMENT);
    1346                 :             :   increment_address (size);
    1347                 :             : }
    1348                 :             : 
    1349                 :             : /* If we are supposed to decrement the address after each access, emit code
    1350                 :             :    to do so now.  Increment by SIZE.  */
    1351                 :             : 
    1352                 :             : void
    1353                 :     3841347 : pieces_addr::maybe_postinc (HOST_WIDE_INT size)
    1354                 :             : {
    1355                 :     3841347 :   if (m_explicit_inc <= 0)
    1356                 :     3841347 :     return;
    1357                 :           0 :   gcc_assert (HAVE_POST_INCREMENT);
    1358                 :             :   increment_address (size);
    1359                 :             : }
    1360                 :             : 
    1361                 :             : /* This structure is used by do_op_by_pieces to describe the operation
    1362                 :             :    to be performed.  */
    1363                 :             : 
    1364                 :             : class op_by_pieces_d
    1365                 :             : {
    1366                 :             :  private:
    1367                 :             :   fixed_size_mode get_usable_mode (fixed_size_mode, unsigned int);
    1368                 :             :   fixed_size_mode smallest_fixed_size_mode_for_size (unsigned int);
    1369                 :             : 
    1370                 :             :  protected:
    1371                 :             :   pieces_addr m_to, m_from;
    1372                 :             :   /* Make m_len read-only so that smallest_fixed_size_mode_for_size can
    1373                 :             :      use it to check the valid mode size.  */
    1374                 :             :   const unsigned HOST_WIDE_INT m_len;
    1375                 :             :   HOST_WIDE_INT m_offset;
    1376                 :             :   unsigned int m_align;
    1377                 :             :   unsigned int m_max_size;
    1378                 :             :   bool m_reverse;
    1379                 :             :   /* True if this is a stack push.  */
    1380                 :             :   bool m_push;
    1381                 :             :   /* True if targetm.overlap_op_by_pieces_p () returns true.  */
    1382                 :             :   bool m_overlap_op_by_pieces;
    1383                 :             :   /* The type of operation that we're performing.  */
    1384                 :             :   by_pieces_operation m_op;
    1385                 :             : 
    1386                 :             :   /* Virtual functions, overriden by derived classes for the specific
    1387                 :             :      operation.  */
    1388                 :             :   virtual void generate (rtx, rtx, machine_mode) = 0;
    1389                 :             :   virtual bool prepare_mode (machine_mode, unsigned int) = 0;
    1390                 :     1090973 :   virtual void finish_mode (machine_mode)
    1391                 :             :   {
    1392                 :     1090973 :   }
    1393                 :             : 
    1394                 :             :  public:
    1395                 :             :   op_by_pieces_d (unsigned int, rtx, bool, rtx, bool, by_pieces_constfn,
    1396                 :             :                   void *, unsigned HOST_WIDE_INT, unsigned int, bool,
    1397                 :             :                   by_pieces_operation);
    1398                 :             :   void run ();
    1399                 :             : };
    1400                 :             : 
    1401                 :             : /* The constructor for an op_by_pieces_d structure.  We require two
    1402                 :             :    objects named TO and FROM, which are identified as loads or stores
    1403                 :             :    by TO_LOAD and FROM_LOAD.  If FROM is a load, the optional FROM_CFN
    1404                 :             :    and its associated FROM_CFN_DATA can be used to replace loads with
    1405                 :             :    constant values.  MAX_PIECES describes the maximum number of bytes
    1406                 :             :    at a time which can be moved efficiently.  LEN describes the length
    1407                 :             :    of the operation.  */
    1408                 :             : 
    1409                 :      679135 : op_by_pieces_d::op_by_pieces_d (unsigned int max_pieces, rtx to,
    1410                 :             :                                 bool to_load, rtx from, bool from_load,
    1411                 :             :                                 by_pieces_constfn from_cfn,
    1412                 :             :                                 void *from_cfn_data,
    1413                 :             :                                 unsigned HOST_WIDE_INT len,
    1414                 :             :                                 unsigned int align, bool push,
    1415                 :      679135 :                                 by_pieces_operation op)
    1416                 :      679135 :   : m_to (to, to_load, NULL, NULL),
    1417                 :      679135 :     m_from (from, from_load, from_cfn, from_cfn_data),
    1418                 :      679135 :     m_len (len), m_max_size (max_pieces + 1),
    1419                 :      679135 :     m_push (push), m_op (op)
    1420                 :             : {
    1421                 :      679135 :   int toi = m_to.get_addr_inc ();
    1422                 :      679135 :   int fromi = m_from.get_addr_inc ();
    1423                 :      679135 :   if (toi >= 0 && fromi >= 0)
    1424                 :      679090 :     m_reverse = false;
    1425                 :          45 :   else if (toi <= 0 && fromi <= 0)
    1426                 :          45 :     m_reverse = true;
    1427                 :             :   else
    1428                 :           0 :     gcc_unreachable ();
    1429                 :             : 
    1430                 :      679135 :   m_offset = m_reverse ? len : 0;
    1431                 :     2538209 :   align = MIN (to ? MEM_ALIGN (to) : align,
    1432                 :             :                from ? MEM_ALIGN (from) : align);
    1433                 :             : 
    1434                 :             :   /* If copying requires more than two move insns,
    1435                 :             :      copy addresses to registers (to make displacements shorter)
    1436                 :             :      and use post-increment if available.  */
    1437                 :      679135 :   if (by_pieces_ninsns (len, align, m_max_size, MOVE_BY_PIECES) > 2)
    1438                 :             :     {
    1439                 :             :       /* Find the mode of the largest comparison.  */
    1440                 :      179929 :       fixed_size_mode mode
    1441                 :      179929 :         = widest_fixed_size_mode_for_size (m_max_size, m_op);
    1442                 :             : 
    1443                 :      179929 :       m_from.decide_autoinc (mode, m_reverse, len);
    1444                 :      179929 :       m_to.decide_autoinc (mode, m_reverse, len);
    1445                 :             :     }
    1446                 :             : 
    1447                 :      679135 :   align = alignment_for_piecewise_move (MOVE_MAX_PIECES, align);
    1448                 :      679135 :   m_align = align;
    1449                 :             : 
    1450                 :      679135 :   m_overlap_op_by_pieces = targetm.overlap_op_by_pieces_p ();
    1451                 :      679135 : }
    1452                 :             : 
    1453                 :             : /* This function returns the largest usable integer mode for LEN bytes
    1454                 :             :    whose size is no bigger than size of MODE.  */
    1455                 :             : 
    1456                 :             : fixed_size_mode
    1457                 :     1151193 : op_by_pieces_d::get_usable_mode (fixed_size_mode mode, unsigned int len)
    1458                 :             : {
    1459                 :     1415237 :   unsigned int size;
    1460                 :     1679281 :   do
    1461                 :             :     {
    1462                 :     1415237 :       size = GET_MODE_SIZE (mode);
    1463                 :     1415237 :       if (len >= size && prepare_mode (mode, m_align))
    1464                 :             :         break;
    1465                 :             :       /* widest_fixed_size_mode_for_size checks SIZE > 1.  */
    1466                 :      264044 :       mode = widest_fixed_size_mode_for_size (size, m_op);
    1467                 :             :     }
    1468                 :             :   while (1);
    1469                 :     1151193 :   return mode;
    1470                 :             : }
    1471                 :             : 
    1472                 :             : /* Return the smallest integer or QI vector mode that is not narrower
    1473                 :             :    than SIZE bytes.  */
    1474                 :             : 
    1475                 :             : fixed_size_mode
    1476                 :      472058 : op_by_pieces_d::smallest_fixed_size_mode_for_size (unsigned int size)
    1477                 :             : {
    1478                 :             :   /* Use QI vector only for > size of WORD.  */
    1479                 :      483377 :   if (can_use_qi_vectors (m_op) && size > UNITS_PER_WORD)
    1480                 :             :     {
    1481                 :        6620 :       machine_mode mode;
    1482                 :        6620 :       fixed_size_mode candidate;
    1483                 :       89719 :       FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_INT)
    1484                 :       89719 :         if (is_a<fixed_size_mode> (mode, &candidate)
    1485                 :      179438 :             && GET_MODE_INNER (candidate) == QImode)
    1486                 :             :           {
    1487                 :             :             /* Don't return a mode wider than M_LEN.  */
    1488                 :       83294 :             if (GET_MODE_SIZE (candidate) > m_len)
    1489                 :             :               break;
    1490                 :             : 
    1491                 :       40078 :             if (GET_MODE_SIZE (candidate) >= size
    1492                 :       40078 :                 && by_pieces_mode_supported_p (candidate, m_op))
    1493                 :        5051 :               return candidate;
    1494                 :             :           }
    1495                 :             :     }
    1496                 :             : 
    1497                 :      467007 :   return smallest_int_mode_for_size (size * BITS_PER_UNIT).require ();
    1498                 :             : }
    1499                 :             : 
    1500                 :             : /* This function contains the main loop used for expanding a block
    1501                 :             :    operation.  First move what we can in the largest integer mode,
    1502                 :             :    then go to successively smaller modes.  For every access, call
    1503                 :             :    GENFUN with the two operands and the EXTRA_DATA.  */
    1504                 :             : 
    1505                 :             : void
    1506                 :      679135 : op_by_pieces_d::run ()
    1507                 :             : {
    1508                 :      679135 :   if (m_len == 0)
    1509                 :             :     return;
    1510                 :             : 
    1511                 :      679135 :   unsigned HOST_WIDE_INT length = m_len;
    1512                 :             : 
    1513                 :             :   /* widest_fixed_size_mode_for_size checks M_MAX_SIZE > 1.  */
    1514                 :      679135 :   fixed_size_mode mode
    1515                 :      679135 :     = widest_fixed_size_mode_for_size (m_max_size, m_op);
    1516                 :      679135 :   mode = get_usable_mode (mode, length);
    1517                 :             : 
    1518                 :      679135 :   by_pieces_prev to_prev = { nullptr, mode };
    1519                 :      679135 :   by_pieces_prev from_prev = { nullptr, mode };
    1520                 :             : 
    1521                 :     1151193 :   do
    1522                 :             :     {
    1523                 :     1151193 :       unsigned int size = GET_MODE_SIZE (mode);
    1524                 :     1151193 :       rtx to1 = NULL_RTX, from1;
    1525                 :             : 
    1526                 :     3071855 :       while (length >= size)
    1527                 :             :         {
    1528                 :     1920662 :           if (m_reverse)
    1529                 :          47 :             m_offset -= size;
    1530                 :             : 
    1531                 :     1920662 :           to1 = m_to.adjust (mode, m_offset, &to_prev);
    1532                 :     1920662 :           to_prev.data = to1;
    1533                 :     1920662 :           to_prev.mode = mode;
    1534                 :     1920662 :           from1 = m_from.adjust (mode, m_offset, &from_prev);
    1535                 :     1920662 :           from_prev.data = from1;
    1536                 :     1920662 :           from_prev.mode = mode;
    1537                 :             : 
    1538                 :     1920662 :           m_to.maybe_predec (-(HOST_WIDE_INT)size);
    1539                 :     1920662 :           m_from.maybe_predec (-(HOST_WIDE_INT)size);
    1540                 :             : 
    1541                 :     1920662 :           generate (to1, from1, mode);
    1542                 :             : 
    1543                 :     1920662 :           m_to.maybe_postinc (size);
    1544                 :     1920662 :           m_from.maybe_postinc (size);
    1545                 :             : 
    1546                 :     1920662 :           if (!m_reverse)
    1547                 :     1920615 :             m_offset += size;
    1548                 :             : 
    1549                 :     1920662 :           length -= size;
    1550                 :             :         }
    1551                 :             : 
    1552                 :     1151193 :       finish_mode (mode);
    1553                 :             : 
    1554                 :     1151193 :       if (length == 0)
    1555                 :             :         return;
    1556                 :             : 
    1557                 :      472058 :       if (!m_push && m_overlap_op_by_pieces)
    1558                 :             :         {
    1559                 :             :           /* NB: Generate overlapping operations if it is not a stack
    1560                 :             :              push since stack push must not overlap.  Get the smallest
    1561                 :             :              fixed size mode for M_LEN bytes.  */
    1562                 :      472058 :           mode = smallest_fixed_size_mode_for_size (length);
    1563                 :      944116 :           mode = get_usable_mode (mode, GET_MODE_SIZE (mode));
    1564                 :      472058 :           int gap = GET_MODE_SIZE (mode) - length;
    1565                 :      472058 :           if (gap > 0)
    1566                 :             :             {
    1567                 :             :               /* If size of MODE > M_LEN, generate the last operation
    1568                 :             :                  in MODE for the remaining bytes with ovelapping memory
    1569                 :             :                  from the previois operation.  */
    1570                 :       43711 :               if (m_reverse)
    1571                 :           0 :                 m_offset += gap;
    1572                 :             :               else
    1573                 :       43711 :                 m_offset -= gap;
    1574                 :       43711 :               length += gap;
    1575                 :             :             }
    1576                 :             :         }
    1577                 :             :       else
    1578                 :             :         {
    1579                 :             :           /* widest_fixed_size_mode_for_size checks SIZE > 1.  */
    1580                 :           0 :           mode = widest_fixed_size_mode_for_size (size, m_op);
    1581                 :           0 :           mode = get_usable_mode (mode, length);
    1582                 :             :         }
    1583                 :             :     }
    1584                 :             :   while (1);
    1585                 :             : }
    1586                 :             : 
    1587                 :             : /* Derived class from op_by_pieces_d, providing support for block move
    1588                 :             :    operations.  */
    1589                 :             : 
    1590                 :             : #ifdef PUSH_ROUNDING
    1591                 :             : #define PUSHG_P(to)  ((to) == nullptr)
    1592                 :             : #else
    1593                 :             : #define PUSHG_P(to)  false
    1594                 :             : #endif
    1595                 :             : 
    1596                 :             : class move_by_pieces_d : public op_by_pieces_d
    1597                 :             : {
    1598                 :             :   insn_gen_fn m_gen_fun;
    1599                 :             :   void generate (rtx, rtx, machine_mode) final override;
    1600                 :             :   bool prepare_mode (machine_mode, unsigned int) final override;
    1601                 :             : 
    1602                 :             :  public:
    1603                 :      556384 :   move_by_pieces_d (rtx to, rtx from, unsigned HOST_WIDE_INT len,
    1604                 :             :                     unsigned int align)
    1605                 :      556384 :     : op_by_pieces_d (MOVE_MAX_PIECES, to, false, from, true, NULL,
    1606                 :     1112768 :                       NULL, len, align, PUSHG_P (to), MOVE_BY_PIECES)
    1607                 :             :   {
    1608                 :      556384 :   }
    1609                 :             :   rtx finish_retmode (memop_ret);
    1610                 :             : };
    1611                 :             : 
    1612                 :             : /* Return true if MODE can be used for a set of copies, given an
    1613                 :             :    alignment ALIGN.  Prepare whatever data is necessary for later
    1614                 :             :    calls to generate.  */
    1615                 :             : 
    1616                 :             : bool
    1617                 :      941366 : move_by_pieces_d::prepare_mode (machine_mode mode, unsigned int align)
    1618                 :             : {
    1619                 :      941366 :   insn_code icode = optab_handler (mov_optab, mode);
    1620                 :      941366 :   m_gen_fun = GEN_FCN (icode);
    1621                 :      941366 :   return icode != CODE_FOR_nothing && align >= GET_MODE_ALIGNMENT (mode);
    1622                 :             : }
    1623                 :             : 
    1624                 :             : /* A callback used when iterating for a compare_by_pieces_operation.
    1625                 :             :    OP0 and OP1 are the values that have been loaded and should be
    1626                 :             :    compared in MODE.  If OP0 is NULL, this means we should generate a
    1627                 :             :    push; otherwise EXTRA_DATA holds a pointer to a pointer to the insn
    1628                 :             :    gen function that should be used to generate the mode.  */
    1629                 :             : 
    1630                 :             : void
    1631                 :     1639226 : move_by_pieces_d::generate (rtx op0, rtx op1,
    1632                 :             :                             machine_mode mode ATTRIBUTE_UNUSED)
    1633                 :             : {
    1634                 :             : #ifdef PUSH_ROUNDING
    1635                 :     1639226 :   if (op0 == NULL_RTX)
    1636                 :             :     {
    1637                 :          47 :       emit_single_push_insn (mode, op1, NULL);
    1638                 :          47 :       return;
    1639                 :             :     }
    1640                 :             : #endif
    1641                 :     1639179 :   emit_insn (m_gen_fun (op0, op1));
    1642                 :             : }
    1643                 :             : 
    1644                 :             : /* Perform the final adjustment at the end of a string to obtain the
    1645                 :             :    correct return value for the block operation.
    1646                 :             :    Return value is based on RETMODE argument.  */
    1647                 :             : 
    1648                 :             : rtx
    1649                 :           0 : move_by_pieces_d::finish_retmode (memop_ret retmode)
    1650                 :             : {
    1651                 :           0 :   gcc_assert (!m_reverse);
    1652                 :           0 :   if (retmode == RETURN_END_MINUS_ONE)
    1653                 :             :     {
    1654                 :           0 :       m_to.maybe_postinc (-1);
    1655                 :           0 :       --m_offset;
    1656                 :             :     }
    1657                 :           0 :   return m_to.adjust (QImode, m_offset);
    1658                 :             : }
    1659                 :             : 
    1660                 :             : /* Generate several move instructions to copy LEN bytes from block FROM to
    1661                 :             :    block TO.  (These are MEM rtx's with BLKmode).
    1662                 :             : 
    1663                 :             :    If PUSH_ROUNDING is defined and TO is NULL, emit_single_push_insn is
    1664                 :             :    used to push FROM to the stack.
    1665                 :             : 
    1666                 :             :    ALIGN is maximum stack alignment we can assume.
    1667                 :             : 
    1668                 :             :    Return value is based on RETMODE argument.  */
    1669                 :             : 
    1670                 :             : rtx
    1671                 :      556384 : move_by_pieces (rtx to, rtx from, unsigned HOST_WIDE_INT len,
    1672                 :             :                 unsigned int align, memop_ret retmode)
    1673                 :             : {
    1674                 :             : #ifndef PUSH_ROUNDING
    1675                 :             :   if (to == NULL)
    1676                 :             :     gcc_unreachable ();
    1677                 :             : #endif
    1678                 :             : 
    1679                 :      556384 :   move_by_pieces_d data (to, from, len, align);
    1680                 :             : 
    1681                 :      556384 :   data.run ();
    1682                 :             : 
    1683                 :      556384 :   if (retmode != RETURN_BEGIN)
    1684                 :           0 :     return data.finish_retmode (retmode);
    1685                 :             :   else
    1686                 :             :     return to;
    1687                 :             : }
    1688                 :             : 
    1689                 :             : /* Derived class from op_by_pieces_d, providing support for block move
    1690                 :             :    operations.  */
    1691                 :             : 
    1692                 :             : class store_by_pieces_d : public op_by_pieces_d
    1693                 :             : {
    1694                 :             :   insn_gen_fn m_gen_fun;
    1695                 :             : 
    1696                 :             :   void generate (rtx, rtx, machine_mode) final override;
    1697                 :             :   bool prepare_mode (machine_mode, unsigned int) final override;
    1698                 :             : 
    1699                 :             :  public:
    1700                 :       89146 :   store_by_pieces_d (rtx to, by_pieces_constfn cfn, void *cfn_data,
    1701                 :             :                      unsigned HOST_WIDE_INT len, unsigned int align,
    1702                 :             :                      by_pieces_operation op)
    1703                 :       89146 :     : op_by_pieces_d (STORE_MAX_PIECES, to, false, NULL_RTX, true, cfn,
    1704                 :      178292 :                       cfn_data, len, align, false, op)
    1705                 :             :   {
    1706                 :       89146 :   }
    1707                 :             :   rtx finish_retmode (memop_ret);
    1708                 :             : };
    1709                 :             : 
    1710                 :             : /* Return true if MODE can be used for a set of stores, given an
    1711                 :             :    alignment ALIGN.  Prepare whatever data is necessary for later
    1712                 :             :    calls to generate.  */
    1713                 :             : 
    1714                 :             : bool
    1715                 :      149607 : store_by_pieces_d::prepare_mode (machine_mode mode, unsigned int align)
    1716                 :             : {
    1717                 :      149607 :   insn_code icode = optab_handler (mov_optab, mode);
    1718                 :      149607 :   m_gen_fun = GEN_FCN (icode);
    1719                 :      149607 :   return icode != CODE_FOR_nothing && align >= GET_MODE_ALIGNMENT (mode);
    1720                 :             : }
    1721                 :             : 
    1722                 :             : /* A callback used when iterating for a store_by_pieces_operation.
    1723                 :             :    OP0 and OP1 are the values that have been loaded and should be
    1724                 :             :    compared in MODE.  If OP0 is NULL, this means we should generate a
    1725                 :             :    push; otherwise EXTRA_DATA holds a pointer to a pointer to the insn
    1726                 :             :    gen function that should be used to generate the mode.  */
    1727                 :             : 
    1728                 :             : void
    1729                 :      218505 : store_by_pieces_d::generate (rtx op0, rtx op1, machine_mode)
    1730                 :             : {
    1731                 :      218505 :   emit_insn (m_gen_fun (op0, op1));
    1732                 :      218505 : }
    1733                 :             : 
    1734                 :             : /* Perform the final adjustment at the end of a string to obtain the
    1735                 :             :    correct return value for the block operation.
    1736                 :             :    Return value is based on RETMODE argument.  */
    1737                 :             : 
    1738                 :             : rtx
    1739                 :         536 : store_by_pieces_d::finish_retmode (memop_ret retmode)
    1740                 :             : {
    1741                 :         536 :   gcc_assert (!m_reverse);
    1742                 :         536 :   if (retmode == RETURN_END_MINUS_ONE)
    1743                 :             :     {
    1744                 :          23 :       m_to.maybe_postinc (-1);
    1745                 :          23 :       --m_offset;
    1746                 :             :     }
    1747                 :         536 :   return m_to.adjust (QImode, m_offset);
    1748                 :             : }
    1749                 :             : 
    1750                 :             : /* Determine whether the LEN bytes generated by CONSTFUN can be
    1751                 :             :    stored to memory using several move instructions.  CONSTFUNDATA is
    1752                 :             :    a pointer which will be passed as argument in every CONSTFUN call.
    1753                 :             :    ALIGN is maximum alignment we can assume.  MEMSETP is true if this is
    1754                 :             :    a memset operation and false if it's a copy of a constant string.
    1755                 :             :    Return true if a call to store_by_pieces should succeed.  */
    1756                 :             : 
    1757                 :             : bool
    1758                 :       62688 : can_store_by_pieces (unsigned HOST_WIDE_INT len,
    1759                 :             :                      by_pieces_constfn constfun,
    1760                 :             :                      void *constfundata, unsigned int align, bool memsetp)
    1761                 :             : {
    1762                 :       62688 :   unsigned HOST_WIDE_INT l;
    1763                 :       62688 :   unsigned int max_size;
    1764                 :       62688 :   HOST_WIDE_INT offset = 0;
    1765                 :       62688 :   enum insn_code icode;
    1766                 :       62688 :   int reverse;
    1767                 :             :   /* cst is set but not used if LEGITIMATE_CONSTANT doesn't use it.  */
    1768                 :       62688 :   rtx cst ATTRIBUTE_UNUSED;
    1769                 :             : 
    1770                 :       62688 :   if (len == 0)
    1771                 :             :     return true;
    1772                 :             : 
    1773                 :      103766 :   if (!targetm.use_by_pieces_infrastructure_p (len, align,
    1774                 :             :                                                memsetp
    1775                 :             :                                                  ? SET_BY_PIECES
    1776                 :             :                                                  : STORE_BY_PIECES,
    1777                 :       62644 :                                                optimize_insn_for_speed_p ()))
    1778                 :             :     return false;
    1779                 :             : 
    1780                 :       46914 :   align = alignment_for_piecewise_move (STORE_MAX_PIECES, align);
    1781                 :             : 
    1782                 :             :   /* We would first store what we can in the largest integer mode, then go to
    1783                 :             :      successively smaller modes.  */
    1784                 :             : 
    1785                 :       46914 :   for (reverse = 0;
    1786                 :       93828 :        reverse <= (HAVE_PRE_DECREMENT || HAVE_POST_DECREMENT);
    1787                 :             :        reverse++)
    1788                 :             :     {
    1789                 :       46914 :       l = len;
    1790                 :       46914 :       max_size = STORE_MAX_PIECES + 1;
    1791                 :      224324 :       while (max_size > 1 && l > 0)
    1792                 :             :         {
    1793                 :      177410 :           auto op = memsetp ? SET_BY_PIECES : STORE_BY_PIECES;
    1794                 :      177410 :           auto mode = widest_fixed_size_mode_for_size (max_size, op);
    1795                 :             : 
    1796                 :      177410 :           icode = optab_handler (mov_optab, mode);
    1797                 :      177410 :           if (icode != CODE_FOR_nothing
    1798                 :      177410 :               && align >= GET_MODE_ALIGNMENT (mode))
    1799                 :             :             {
    1800                 :      177410 :               unsigned int size = GET_MODE_SIZE (mode);
    1801                 :             : 
    1802                 :      308199 :               while (l >= size)
    1803                 :             :                 {
    1804                 :      130789 :                   if (reverse)
    1805                 :             :                     offset -= size;
    1806                 :             : 
    1807                 :      130789 :                   cst = (*constfun) (constfundata, nullptr, offset, mode);
    1808                 :             :                   /* All CONST_VECTORs can be loaded for memset since
    1809                 :             :                      vec_duplicate_optab is a precondition to pick a
    1810                 :             :                      vector mode for the memset expander.  */
    1811                 :      249114 :                   if (!((memsetp && VECTOR_MODE_P (mode))
    1812                 :      118325 :                         || targetm.legitimate_constant_p (mode, cst)))
    1813                 :       15730 :                     return false;
    1814                 :             : 
    1815                 :      130789 :                   if (!reverse)
    1816                 :      130789 :                     offset += size;
    1817                 :             : 
    1818                 :      130789 :                   l -= size;
    1819                 :             :                 }
    1820                 :             :             }
    1821                 :             : 
    1822                 :      354820 :           max_size = GET_MODE_SIZE (mode);
    1823                 :             :         }
    1824                 :             : 
    1825                 :             :       /* The code above should have handled everything.  */
    1826                 :       46914 :       gcc_assert (!l);
    1827                 :             :     }
    1828                 :             : 
    1829                 :             :   return true;
    1830                 :             : }
    1831                 :             : 
    1832                 :             : /* Generate several move instructions to store LEN bytes generated by
    1833                 :             :    CONSTFUN to block TO.  (A MEM rtx with BLKmode).  CONSTFUNDATA is a
    1834                 :             :    pointer which will be passed as argument in every CONSTFUN call.
    1835                 :             :    ALIGN is maximum alignment we can assume.  MEMSETP is true if this is
    1836                 :             :    a memset operation and false if it's a copy of a constant string.
    1837                 :             :    Return value is based on RETMODE argument.  */
    1838                 :             : 
    1839                 :             : rtx
    1840                 :       44397 : store_by_pieces (rtx to, unsigned HOST_WIDE_INT len,
    1841                 :             :                  by_pieces_constfn constfun,
    1842                 :             :                  void *constfundata, unsigned int align, bool memsetp,
    1843                 :             :                  memop_ret retmode)
    1844                 :             : {
    1845                 :       44397 :   if (len == 0)
    1846                 :             :     {
    1847                 :          43 :       gcc_assert (retmode != RETURN_END_MINUS_ONE);
    1848                 :             :       return to;
    1849                 :             :     }
    1850                 :             : 
    1851                 :       81698 :   gcc_assert (targetm.use_by_pieces_infrastructure_p
    1852                 :             :                 (len, align,
    1853                 :             :                  memsetp ? SET_BY_PIECES : STORE_BY_PIECES,
    1854                 :             :                  optimize_insn_for_speed_p ()));
    1855                 :             : 
    1856                 :       44354 :   store_by_pieces_d data (to, constfun, constfundata, len, align,
    1857                 :       44354 :                           memsetp ? SET_BY_PIECES : STORE_BY_PIECES);
    1858                 :       44354 :   data.run ();
    1859                 :             : 
    1860                 :       44354 :   if (retmode != RETURN_BEGIN)
    1861                 :         536 :     return data.finish_retmode (retmode);
    1862                 :             :   else
    1863                 :             :     return to;
    1864                 :             : }
    1865                 :             : 
    1866                 :             : void
    1867                 :       44792 : clear_by_pieces (rtx to, unsigned HOST_WIDE_INT len, unsigned int align)
    1868                 :             : {
    1869                 :       44792 :   if (len == 0)
    1870                 :           0 :     return;
    1871                 :             : 
    1872                 :             :   /* Use builtin_memset_read_str to support vector mode broadcast.  */
    1873                 :       44792 :   char c = 0;
    1874                 :       44792 :   store_by_pieces_d data (to, builtin_memset_read_str, &c, len, align,
    1875                 :       44792 :                           CLEAR_BY_PIECES);
    1876                 :       44792 :   data.run ();
    1877                 :             : }
    1878                 :             : 
    1879                 :             : /* Context used by compare_by_pieces_genfn.  It stores the fail label
    1880                 :             :    to jump to in case of miscomparison, and for branch ratios greater than 1,
    1881                 :             :    it stores an accumulator and the current and maximum counts before
    1882                 :             :    emitting another branch.  */
    1883                 :             : 
    1884                 :             : class compare_by_pieces_d : public op_by_pieces_d
    1885                 :             : {
    1886                 :             :   rtx_code_label *m_fail_label;
    1887                 :             :   rtx m_accumulator;
    1888                 :             :   int m_count, m_batch;
    1889                 :             : 
    1890                 :             :   void generate (rtx, rtx, machine_mode) final override;
    1891                 :             :   bool prepare_mode (machine_mode, unsigned int) final override;
    1892                 :             :   void finish_mode (machine_mode) final override;
    1893                 :             : 
    1894                 :             :  public:
    1895                 :       33605 :   compare_by_pieces_d (rtx op0, rtx op1, by_pieces_constfn op1_cfn,
    1896                 :             :                        void *op1_cfn_data, HOST_WIDE_INT len, int align,
    1897                 :             :                        rtx_code_label *fail_label)
    1898                 :       33605 :     : op_by_pieces_d (COMPARE_MAX_PIECES, op0, true, op1, true, op1_cfn,
    1899                 :       67210 :                       op1_cfn_data, len, align, false, COMPARE_BY_PIECES)
    1900                 :             :   {
    1901                 :       33605 :     m_fail_label = fail_label;
    1902                 :       33605 :   }
    1903                 :             : };
    1904                 :             : 
    1905                 :             : /* A callback used when iterating for a compare_by_pieces_operation.
    1906                 :             :    OP0 and OP1 are the values that have been loaded and should be
    1907                 :             :    compared in MODE.  DATA holds a pointer to the compare_by_pieces_data
    1908                 :             :    context structure.  */
    1909                 :             : 
    1910                 :             : void
    1911                 :       62931 : compare_by_pieces_d::generate (rtx op0, rtx op1, machine_mode mode)
    1912                 :             : {
    1913                 :       62931 :   if (m_batch > 1)
    1914                 :             :     {
    1915                 :           0 :       rtx temp = expand_binop (mode, sub_optab, op0, op1, NULL_RTX,
    1916                 :             :                                true, OPTAB_LIB_WIDEN);
    1917                 :           0 :       if (m_count != 0)
    1918                 :           0 :         temp = expand_binop (mode, ior_optab, m_accumulator, temp, temp,
    1919                 :             :                              true, OPTAB_LIB_WIDEN);
    1920                 :           0 :       m_accumulator = temp;
    1921                 :             : 
    1922                 :           0 :       if (++m_count < m_batch)
    1923                 :             :         return;
    1924                 :             : 
    1925                 :           0 :       m_count = 0;
    1926                 :           0 :       op0 = m_accumulator;
    1927                 :           0 :       op1 = const0_rtx;
    1928                 :           0 :       m_accumulator = NULL_RTX;
    1929                 :             :     }
    1930                 :       62931 :   do_compare_rtx_and_jump (op0, op1, NE, true, mode, NULL_RTX, NULL,
    1931                 :             :                            m_fail_label, profile_probability::uninitialized ());
    1932                 :             : }
    1933                 :             : 
    1934                 :             : /* Return true if MODE can be used for a set of moves and comparisons,
    1935                 :             :    given an alignment ALIGN.  Prepare whatever data is necessary for
    1936                 :             :    later calls to generate.  */
    1937                 :             : 
    1938                 :             : bool
    1939                 :       60220 : compare_by_pieces_d::prepare_mode (machine_mode mode, unsigned int align)
    1940                 :             : {
    1941                 :       60220 :   insn_code icode = optab_handler (mov_optab, mode);
    1942                 :       60220 :   if (icode == CODE_FOR_nothing
    1943                 :       60220 :       || align < GET_MODE_ALIGNMENT (mode)
    1944                 :      120440 :       || !can_compare_p (EQ, mode, ccp_jump))
    1945                 :           0 :     return false;
    1946                 :       60220 :   m_batch = targetm.compare_by_pieces_branch_ratio (mode);
    1947                 :       60220 :   if (m_batch < 0)
    1948                 :             :     return false;
    1949                 :       60220 :   m_accumulator = NULL_RTX;
    1950                 :       60220 :   m_count = 0;
    1951                 :       60220 :   return true;
    1952                 :             : }
    1953                 :             : 
    1954                 :             : /* Called after expanding a series of comparisons in MODE.  If we have
    1955                 :             :    accumulated results for which we haven't emitted a branch yet, do
    1956                 :             :    so now.  */
    1957                 :             : 
    1958                 :             : void
    1959                 :       60220 : compare_by_pieces_d::finish_mode (machine_mode mode)
    1960                 :             : {
    1961                 :       60220 :   if (m_accumulator != NULL_RTX)
    1962                 :           0 :     do_compare_rtx_and_jump (m_accumulator, const0_rtx, NE, true, mode,
    1963                 :             :                              NULL_RTX, NULL, m_fail_label,
    1964                 :             :                              profile_probability::uninitialized ());
    1965                 :       60220 : }
    1966                 :             : 
    1967                 :             : /* Generate several move instructions to compare LEN bytes from blocks
    1968                 :             :    ARG0 and ARG1.  (These are MEM rtx's with BLKmode).
    1969                 :             : 
    1970                 :             :    If PUSH_ROUNDING is defined and TO is NULL, emit_single_push_insn is
    1971                 :             :    used to push FROM to the stack.
    1972                 :             : 
    1973                 :             :    ALIGN is maximum stack alignment we can assume.
    1974                 :             : 
    1975                 :             :    Optionally, the caller can pass a constfn and associated data in A1_CFN
    1976                 :             :    and A1_CFN_DATA. describing that the second operand being compared is a
    1977                 :             :    known constant and how to obtain its data.  */
    1978                 :             : 
    1979                 :             : static rtx
    1980                 :       33605 : compare_by_pieces (rtx arg0, rtx arg1, unsigned HOST_WIDE_INT len,
    1981                 :             :                    rtx target, unsigned int align,
    1982                 :             :                    by_pieces_constfn a1_cfn, void *a1_cfn_data)
    1983                 :             : {
    1984                 :       33605 :   rtx_code_label *fail_label = gen_label_rtx ();
    1985                 :       33605 :   rtx_code_label *end_label = gen_label_rtx ();
    1986                 :             : 
    1987                 :       33605 :   if (target == NULL_RTX
    1988                 :       33605 :       || !REG_P (target) || REGNO (target) < FIRST_PSEUDO_REGISTER)
    1989                 :           1 :     target = gen_reg_rtx (TYPE_MODE (integer_type_node));
    1990                 :             : 
    1991                 :       33605 :   compare_by_pieces_d data (arg0, arg1, a1_cfn, a1_cfn_data, len, align,
    1992                 :       33605 :                             fail_label);
    1993                 :             : 
    1994                 :       33605 :   data.run ();
    1995                 :             : 
    1996                 :       33605 :   emit_move_insn (target, const0_rtx);
    1997                 :       33605 :   emit_jump (end_label);
    1998                 :       33605 :   emit_barrier ();
    1999                 :       33605 :   emit_label (fail_label);
    2000                 :       33605 :   emit_move_insn (target, const1_rtx);
    2001                 :       33605 :   emit_label (end_label);
    2002                 :             : 
    2003                 :       33605 :   return target;
    2004                 :             : }
    2005                 :             : 
    2006                 :             : /* Emit code to move a block Y to a block X.  This may be done with
    2007                 :             :    string-move instructions, with multiple scalar move instructions,
    2008                 :             :    or with a library call.
    2009                 :             : 
    2010                 :             :    Both X and Y must be MEM rtx's (perhaps inside VOLATILE) with mode BLKmode.
    2011                 :             :    SIZE is an rtx that says how long they are.
    2012                 :             :    ALIGN is the maximum alignment we can assume they have.
    2013                 :             :    METHOD describes what kind of copy this is, and what mechanisms may be used.
    2014                 :             :    MIN_SIZE is the minimal size of block to move
    2015                 :             :    MAX_SIZE is the maximal size of block to move, if it cannot be represented
    2016                 :             :    in unsigned HOST_WIDE_INT, than it is mask of all ones.
    2017                 :             :    CTZ_SIZE is the trailing-zeros count of SIZE; even a nonconstant SIZE is
    2018                 :             :    known to be a multiple of 1<<CTZ_SIZE.
    2019                 :             : 
    2020                 :             :    Return the address of the new block, if memcpy is called and returns it,
    2021                 :             :    0 otherwise.  */
    2022                 :             : 
    2023                 :             : rtx
    2024                 :      640370 : emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method,
    2025                 :             :                        unsigned int expected_align, HOST_WIDE_INT expected_size,
    2026                 :             :                        unsigned HOST_WIDE_INT min_size,
    2027                 :             :                        unsigned HOST_WIDE_INT max_size,
    2028                 :             :                        unsigned HOST_WIDE_INT probable_max_size,
    2029                 :             :                        bool bail_out_libcall, bool *is_move_done,
    2030                 :             :                        bool might_overlap, unsigned ctz_size)
    2031                 :             : {
    2032                 :      640370 :   int may_use_call;
    2033                 :      640370 :   rtx retval = 0;
    2034                 :      640370 :   unsigned int align;
    2035                 :             : 
    2036                 :      640370 :   if (is_move_done)
    2037                 :       73716 :     *is_move_done = true;
    2038                 :             : 
    2039                 :      640370 :   gcc_assert (size);
    2040                 :      640370 :   if (CONST_INT_P (size) && INTVAL (size) == 0)
    2041                 :             :     return 0;
    2042                 :             : 
    2043                 :      640093 :   switch (method)
    2044                 :             :     {
    2045                 :             :     case BLOCK_OP_NORMAL:
    2046                 :             :     case BLOCK_OP_TAILCALL:
    2047                 :             :       may_use_call = 1;
    2048                 :             :       break;
    2049                 :             : 
    2050                 :      266174 :     case BLOCK_OP_CALL_PARM:
    2051                 :      266174 :       may_use_call = block_move_libcall_safe_for_call_parm ();
    2052                 :             : 
    2053                 :             :       /* Make inhibit_defer_pop nonzero around the library call
    2054                 :             :          to force it to pop the arguments right away.  */
    2055                 :      266174 :       NO_DEFER_POP;
    2056                 :      266174 :       break;
    2057                 :             : 
    2058                 :         353 :     case BLOCK_OP_NO_LIBCALL:
    2059                 :         353 :       may_use_call = 0;
    2060                 :         353 :       break;
    2061                 :             : 
    2062                 :        1059 :     case BLOCK_OP_NO_LIBCALL_RET:
    2063                 :        1059 :       may_use_call = -1;
    2064                 :        1059 :       break;
    2065                 :             : 
    2066                 :           0 :     default:
    2067                 :           0 :       gcc_unreachable ();
    2068                 :             :     }
    2069                 :             : 
    2070                 :      640093 :   gcc_assert (MEM_P (x) && MEM_P (y));
    2071                 :      640176 :   align = MIN (MEM_ALIGN (x), MEM_ALIGN (y));
    2072                 :      640093 :   gcc_assert (align >= BITS_PER_UNIT);
    2073                 :             : 
    2074                 :             :   /* Make sure we've got BLKmode addresses; store_one_arg can decide that
    2075                 :             :      block copy is more efficient for other large modes, e.g. DCmode.  */
    2076                 :      640093 :   x = adjust_address (x, BLKmode, 0);
    2077                 :      640093 :   y = adjust_address (y, BLKmode, 0);
    2078                 :             : 
    2079                 :             :   /* If source and destination are the same, no need to copy anything.  */
    2080                 :      640093 :   if (rtx_equal_p (x, y)
    2081                 :          10 :       && !MEM_VOLATILE_P (x)
    2082                 :      640103 :       && !MEM_VOLATILE_P (y))
    2083                 :             :     return 0;
    2084                 :             : 
    2085                 :             :   /* Set MEM_SIZE as appropriate for this block copy.  The main place this
    2086                 :             :      can be incorrect is coming from __builtin_memcpy.  */
    2087                 :      640083 :   poly_int64 const_size;
    2088                 :      640083 :   if (poly_int_rtx_p (size, &const_size))
    2089                 :             :     {
    2090                 :      582182 :       x = shallow_copy_rtx (x);
    2091                 :      582182 :       y = shallow_copy_rtx (y);
    2092                 :      582182 :       set_mem_size (x, const_size);
    2093                 :      582182 :       set_mem_size (y, const_size);
    2094                 :             :     }
    2095                 :             : 
    2096                 :      640083 :   bool pieces_ok = CONST_INT_P (size)
    2097                 :      640083 :     && can_move_by_pieces (INTVAL (size), align);
    2098                 :      640083 :   bool pattern_ok = false;
    2099                 :             : 
    2100                 :      640083 :   if (!pieces_ok || might_overlap)
    2101                 :             :     {
    2102                 :       83744 :       pattern_ok
    2103                 :       83744 :         = emit_block_move_via_pattern (x, y, size, align,
    2104                 :             :                                        expected_align, expected_size,
    2105                 :             :                                        min_size, max_size, probable_max_size,
    2106                 :             :                                        might_overlap);
    2107                 :       83744 :       if (!pattern_ok && might_overlap)
    2108                 :             :         {
    2109                 :             :           /* Do not try any of the other methods below as they are not safe
    2110                 :             :              for overlapping moves.  */
    2111                 :       14382 :           *is_move_done = false;
    2112                 :       14382 :           return retval;
    2113                 :             :         }
    2114                 :             :     }
    2115                 :             : 
    2116                 :       69362 :   bool dynamic_direction = false;
    2117                 :       69362 :   if (!pattern_ok && !pieces_ok && may_use_call
    2118                 :       72138 :       && (flag_inline_stringops & (might_overlap ? ILSOP_MEMMOVE : ILSOP_MEMCPY)))
    2119                 :             :     {
    2120                 :      625701 :       may_use_call = 0;
    2121                 :      625701 :       dynamic_direction = might_overlap;
    2122                 :             :     }
    2123                 :             : 
    2124                 :      625701 :   if (pattern_ok)
    2125                 :             :     ;
    2126                 :      592408 :   else if (pieces_ok)
    2127                 :      556339 :     move_by_pieces (x, y, INTVAL (size), align, RETURN_BEGIN);
    2128                 :       36069 :   else if (may_use_call && !might_overlap
    2129                 :       36021 :            && ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (x))
    2130                 :       72090 :            && ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (y)))
    2131                 :             :     {
    2132                 :       36021 :       if (bail_out_libcall)
    2133                 :             :         {
    2134                 :         252 :           if (is_move_done)
    2135                 :         252 :             *is_move_done = false;
    2136                 :         252 :           return retval;
    2137                 :             :         }
    2138                 :             : 
    2139                 :       35769 :       if (may_use_call < 0)
    2140                 :           0 :         return pc_rtx;
    2141                 :             : 
    2142                 :       35769 :       retval = emit_block_copy_via_libcall (x, y, size,
    2143                 :             :                                             method == BLOCK_OP_TAILCALL);
    2144                 :             :     }
    2145                 :          48 :   else if (dynamic_direction)
    2146                 :           0 :     emit_block_move_via_oriented_loop (x, y, size, align, ctz_size);
    2147                 :          48 :   else if (might_overlap)
    2148                 :           0 :     *is_move_done = false;
    2149                 :             :   else
    2150                 :          48 :     emit_block_move_via_sized_loop (x, y, size, align, ctz_size);
    2151                 :             : 
    2152                 :      625449 :   if (method == BLOCK_OP_CALL_PARM)
    2153                 :      266166 :     OK_DEFER_POP;
    2154                 :             : 
    2155                 :             :   return retval;
    2156                 :             : }
    2157                 :             : 
    2158                 :             : rtx
    2159                 :      566654 : emit_block_move (rtx x, rtx y, rtx size, enum block_op_methods method,
    2160                 :             :                  unsigned int ctz_size)
    2161                 :             : {
    2162                 :      566654 :   unsigned HOST_WIDE_INT max, min = 0;
    2163                 :      566654 :   if (GET_CODE (size) == CONST_INT)
    2164                 :      566434 :     min = max = UINTVAL (size);
    2165                 :             :   else
    2166                 :         220 :     max = GET_MODE_MASK (GET_MODE (size));
    2167                 :      566654 :   return emit_block_move_hints (x, y, size, method, 0, -1,
    2168                 :             :                                 min, max, max,
    2169                 :      566654 :                                 false, NULL, false, ctz_size);
    2170                 :             : }
    2171                 :             : 
    2172                 :             : /* A subroutine of emit_block_move.  Returns true if calling the
    2173                 :             :    block move libcall will not clobber any parameters which may have
    2174                 :             :    already been placed on the stack.  */
    2175                 :             : 
    2176                 :             : static bool
    2177                 :      266174 : block_move_libcall_safe_for_call_parm (void)
    2178                 :             : {
    2179                 :      266174 :   tree fn;
    2180                 :             : 
    2181                 :             :   /* If arguments are pushed on the stack, then they're safe.  */
    2182                 :      266174 :   if (targetm.calls.push_argument (0))
    2183                 :             :     return true;
    2184                 :             : 
    2185                 :             :   /* If registers go on the stack anyway, any argument is sure to clobber
    2186                 :             :      an outgoing argument.  */
    2187                 :             : #if defined (REG_PARM_STACK_SPACE)
    2188                 :           3 :   fn = builtin_decl_implicit (BUILT_IN_MEMCPY);
    2189                 :             :   /* Avoid set but not used warning if *REG_PARM_STACK_SPACE doesn't
    2190                 :             :      depend on its argument.  */
    2191                 :           3 :   (void) fn;
    2192                 :           3 :   if (OUTGOING_REG_PARM_STACK_SPACE ((!fn ? NULL_TREE : TREE_TYPE (fn)))
    2193                 :           3 :       && REG_PARM_STACK_SPACE (fn) != 0)
    2194                 :             :     return false;
    2195                 :             : #endif
    2196                 :             : 
    2197                 :             :   /* If any argument goes in memory, then it might clobber an outgoing
    2198                 :             :      argument.  */
    2199                 :           3 :   {
    2200                 :           3 :     CUMULATIVE_ARGS args_so_far_v;
    2201                 :           3 :     cumulative_args_t args_so_far;
    2202                 :           3 :     tree arg;
    2203                 :             : 
    2204                 :           3 :     fn = builtin_decl_implicit (BUILT_IN_MEMCPY);
    2205                 :           3 :     INIT_CUMULATIVE_ARGS (args_so_far_v, TREE_TYPE (fn), NULL_RTX, 0, 3);
    2206                 :           3 :     args_so_far = pack_cumulative_args (&args_so_far_v);
    2207                 :             : 
    2208                 :           3 :     arg = TYPE_ARG_TYPES (TREE_TYPE (fn));
    2209                 :          12 :     for ( ; arg != void_list_node ; arg = TREE_CHAIN (arg))
    2210                 :             :       {
    2211                 :           9 :         machine_mode mode = TYPE_MODE (TREE_VALUE (arg));
    2212                 :           9 :         function_arg_info arg_info (mode, /*named=*/true);
    2213                 :           9 :         rtx tmp = targetm.calls.function_arg (args_so_far, arg_info);
    2214                 :           9 :         if (!tmp || !REG_P (tmp))
    2215                 :           0 :           return false;
    2216                 :           9 :         if (targetm.calls.arg_partial_bytes (args_so_far, arg_info))
    2217                 :             :           return false;
    2218                 :           9 :         targetm.calls.function_arg_advance (args_so_far, arg_info);
    2219                 :             :       }
    2220                 :             :   }
    2221                 :           3 :   return true;
    2222                 :             : }
    2223                 :             : 
    2224                 :             : /* A subroutine of emit_block_move.  Expand a cpymem or movmem pattern;
    2225                 :             :    return true if successful.
    2226                 :             : 
    2227                 :             :    X is the destination of the copy or move.
    2228                 :             :    Y is the source of the copy or move.
    2229                 :             :    SIZE is the size of the block to be moved.
    2230                 :             : 
    2231                 :             :    MIGHT_OVERLAP indicates this originated with expansion of a
    2232                 :             :    builtin_memmove() and the source and destination blocks may
    2233                 :             :    overlap.
    2234                 :             :   */
    2235                 :             : 
    2236                 :             : static bool
    2237                 :       83744 : emit_block_move_via_pattern (rtx x, rtx y, rtx size, unsigned int align,
    2238                 :             :                              unsigned int expected_align,
    2239                 :             :                              HOST_WIDE_INT expected_size,
    2240                 :             :                              unsigned HOST_WIDE_INT min_size,
    2241                 :             :                              unsigned HOST_WIDE_INT max_size,
    2242                 :             :                              unsigned HOST_WIDE_INT probable_max_size,
    2243                 :             :                              bool might_overlap)
    2244                 :             : {
    2245                 :       83744 :   if (expected_align < align)
    2246                 :             :     expected_align = align;
    2247                 :       83744 :   if (expected_size != -1)
    2248                 :             :     {
    2249                 :          12 :       if ((unsigned HOST_WIDE_INT)expected_size > probable_max_size)
    2250                 :           0 :         expected_size = probable_max_size;
    2251                 :          12 :       if ((unsigned HOST_WIDE_INT)expected_size < min_size)
    2252                 :           0 :         expected_size = min_size;
    2253                 :             :     }
    2254                 :             : 
    2255                 :             :   /* Since this is a move insn, we don't care about volatility.  */
    2256                 :       83744 :   temporary_volatile_ok v (true);
    2257                 :             : 
    2258                 :             :   /* Try the most limited insn first, because there's no point
    2259                 :             :      including more than one in the machine description unless
    2260                 :             :      the more limited one has some advantage.  */
    2261                 :             : 
    2262                 :       83744 :   opt_scalar_int_mode mode_iter;
    2263                 :      505408 :   FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
    2264                 :             :     {
    2265                 :      454957 :       scalar_int_mode mode = mode_iter.require ();
    2266                 :      454957 :       enum insn_code code;
    2267                 :      454957 :       if (might_overlap)
    2268                 :      100674 :         code = direct_optab_handler (movmem_optab, mode);
    2269                 :             :       else
    2270                 :      354283 :         code = direct_optab_handler (cpymem_optab, mode);
    2271                 :             : 
    2272                 :      454957 :       if (code != CODE_FOR_nothing
    2273                 :             :           /* We don't need MODE to be narrower than BITS_PER_HOST_WIDE_INT
    2274                 :             :              here because if SIZE is less than the mode mask, as it is
    2275                 :             :              returned by the macro, it will definitely be less than the
    2276                 :             :              actual mode mask.  Since SIZE is within the Pmode address
    2277                 :             :              space, we limit MODE to Pmode.  */
    2278                 :      454957 :           && ((CONST_INT_P (size)
    2279                 :       24361 :                && ((unsigned HOST_WIDE_INT) INTVAL (size)
    2280                 :       24361 :                    <= (GET_MODE_MASK (mode) >> 1)))
    2281                 :       81427 :               || max_size <= (GET_MODE_MASK (mode) >> 1)
    2282                 :      108194 :               || GET_MODE_BITSIZE (mode) >= GET_MODE_BITSIZE (Pmode)))
    2283                 :             :         {
    2284                 :       71186 :           class expand_operand ops[9];
    2285                 :       71186 :           unsigned int nops;
    2286                 :             : 
    2287                 :             :           /* ??? When called via emit_block_move_for_call, it'd be
    2288                 :             :              nice if there were some way to inform the backend, so
    2289                 :             :              that it doesn't fail the expansion because it thinks
    2290                 :             :              emitting the libcall would be more efficient.  */
    2291                 :       71186 :           nops = insn_data[(int) code].n_generator_args;
    2292                 :       71186 :           gcc_assert (nops == 4 || nops == 6 || nops == 8 || nops == 9);
    2293                 :             : 
    2294                 :       71186 :           create_fixed_operand (&ops[0], x);
    2295                 :       71186 :           create_fixed_operand (&ops[1], y);
    2296                 :             :           /* The check above guarantees that this size conversion is valid.  */
    2297                 :       71186 :           create_convert_operand_to (&ops[2], size, mode, true);
    2298                 :       71186 :           create_integer_operand (&ops[3], align / BITS_PER_UNIT);
    2299                 :       71186 :           if (nops >= 6)
    2300                 :             :             {
    2301                 :       71186 :               create_integer_operand (&ops[4], expected_align / BITS_PER_UNIT);
    2302                 :       71186 :               create_integer_operand (&ops[5], expected_size);
    2303                 :             :             }
    2304                 :       71186 :           if (nops >= 8)
    2305                 :             :             {
    2306                 :       71186 :               create_integer_operand (&ops[6], min_size);
    2307                 :             :               /* If we cannot represent the maximal size,
    2308                 :             :                  make parameter NULL.  */
    2309                 :       71186 :               if ((HOST_WIDE_INT) max_size != -1)
    2310                 :       54416 :                 create_integer_operand (&ops[7], max_size);
    2311                 :             :               else
    2312                 :       16770 :                 create_fixed_operand (&ops[7], NULL);
    2313                 :             :             }
    2314                 :       71186 :           if (nops == 9)
    2315                 :             :             {
    2316                 :             :               /* If we cannot represent the maximal size,
    2317                 :             :                  make parameter NULL.  */
    2318                 :       71186 :               if ((HOST_WIDE_INT) probable_max_size != -1)
    2319                 :       55889 :                 create_integer_operand (&ops[8], probable_max_size);
    2320                 :             :               else
    2321                 :       15297 :                 create_fixed_operand (&ops[8], NULL);
    2322                 :             :             }
    2323                 :       71186 :           if (maybe_expand_insn (code, nops, ops))
    2324                 :       33293 :             return true;
    2325                 :             :         }
    2326                 :             :     }
    2327                 :             : 
    2328                 :             :   return false;
    2329                 :       83744 : }
    2330                 :             : 
    2331                 :             : /* Like emit_block_move_via_loop, but choose a suitable INCR based on
    2332                 :             :    ALIGN and CTZ_SIZE.  */
    2333                 :             : 
    2334                 :             : static void
    2335                 :          48 : emit_block_move_via_sized_loop (rtx x, rtx y, rtx size,
    2336                 :             :                                 unsigned int align,
    2337                 :             :                                 unsigned int ctz_size)
    2338                 :             : {
    2339                 :          48 :   int incr = align / BITS_PER_UNIT;
    2340                 :             : 
    2341                 :          48 :   if (CONST_INT_P (size))
    2342                 :           0 :     ctz_size = MAX (ctz_size, (unsigned) wi::ctz (UINTVAL (size)));
    2343                 :             : 
    2344                 :          48 :   if (HOST_WIDE_INT_1U << ctz_size < (unsigned HOST_WIDE_INT) incr)
    2345                 :           0 :     incr = HOST_WIDE_INT_1U << ctz_size;
    2346                 :             : 
    2347                 :          48 :   while (incr > 1 && !can_move_by_pieces (incr, align))
    2348                 :           0 :     incr >>= 1;
    2349                 :             : 
    2350                 :          48 :   gcc_checking_assert (incr);
    2351                 :             : 
    2352                 :          48 :   return emit_block_move_via_loop (x, y, size, align, incr);
    2353                 :             : }
    2354                 :             : 
    2355                 :             : /* Like emit_block_move_via_sized_loop, but besides choosing INCR so
    2356                 :             :    as to ensure safe moves even in case of overlap, output dynamic
    2357                 :             :    tests to choose between two loops, one moving downwards, another
    2358                 :             :    moving upwards.  */
    2359                 :             : 
    2360                 :             : static void
    2361                 :           0 : emit_block_move_via_oriented_loop (rtx x, rtx y, rtx size,
    2362                 :             :                                    unsigned int align,
    2363                 :             :                                    unsigned int ctz_size)
    2364                 :             : {
    2365                 :           0 :   int incr = align / BITS_PER_UNIT;
    2366                 :             : 
    2367                 :           0 :   if (CONST_INT_P (size))
    2368                 :           0 :     ctz_size = MAX (ctz_size, (unsigned) wi::ctz (UINTVAL (size)));
    2369                 :             : 
    2370                 :           0 :   if (HOST_WIDE_INT_1U << ctz_size < (unsigned HOST_WIDE_INT) incr)
    2371                 :           0 :     incr = HOST_WIDE_INT_1U << ctz_size;
    2372                 :             : 
    2373                 :           0 :   while (incr > 1 && !int_mode_for_size (incr, 0).exists ())
    2374                 :           0 :     incr >>= 1;
    2375                 :             : 
    2376                 :           0 :   gcc_checking_assert (incr);
    2377                 :             : 
    2378                 :           0 :   rtx_code_label *upw_label, *end_label;
    2379                 :           0 :   upw_label = gen_label_rtx ();
    2380                 :           0 :   end_label = gen_label_rtx ();
    2381                 :             : 
    2382                 :           0 :   rtx x_addr = force_operand (XEXP (x, 0), NULL_RTX);
    2383                 :           0 :   rtx y_addr = force_operand (XEXP (y, 0), NULL_RTX);
    2384                 :           0 :   do_pending_stack_adjust ();
    2385                 :             : 
    2386                 :           0 :   machine_mode mode = GET_MODE (x_addr);
    2387                 :           0 :   if (mode != GET_MODE (y_addr))
    2388                 :             :     {
    2389                 :           0 :       scalar_int_mode xmode
    2390                 :           0 :         = smallest_int_mode_for_size (GET_MODE_BITSIZE (mode)).require ();
    2391                 :           0 :       scalar_int_mode ymode
    2392                 :           0 :         = smallest_int_mode_for_size (GET_MODE_BITSIZE
    2393                 :           0 :                                       (GET_MODE (y_addr))).require ();
    2394                 :           0 :       if (GET_MODE_BITSIZE (xmode) < GET_MODE_BITSIZE (ymode))
    2395                 :             :         mode = ymode;
    2396                 :             :       else
    2397                 :           0 :         mode = xmode;
    2398                 :             : 
    2399                 :             : #ifndef POINTERS_EXTEND_UNSIGNED
    2400                 :             :       const int POINTERS_EXTEND_UNSIGNED = 1;
    2401                 :             : #endif
    2402                 :           0 :       x_addr = convert_modes (mode, GET_MODE (x_addr), x_addr,
    2403                 :             :                               POINTERS_EXTEND_UNSIGNED);
    2404                 :           0 :       y_addr = convert_modes (mode, GET_MODE (y_addr), y_addr,
    2405                 :             :                               POINTERS_EXTEND_UNSIGNED);
    2406                 :             :     }
    2407                 :             : 
    2408                 :             :   /* Test for overlap: if (x >= y || x + size <= y) goto upw_label.  */
    2409                 :           0 :   emit_cmp_and_jump_insns (x_addr, y_addr, GEU, NULL_RTX, mode,
    2410                 :             :                            true, upw_label,
    2411                 :           0 :                            profile_probability::guessed_always ()
    2412                 :             :                                 .apply_scale (5, 10));
    2413                 :           0 :   rtx tmp = convert_modes (GET_MODE (x_addr), GET_MODE (size), size, true);
    2414                 :           0 :   tmp = simplify_gen_binary (PLUS, GET_MODE (x_addr), x_addr, tmp);
    2415                 :             : 
    2416                 :           0 :   emit_cmp_and_jump_insns (tmp, y_addr, LEU, NULL_RTX, mode,
    2417                 :             :                            true, upw_label,
    2418                 :           0 :                            profile_probability::guessed_always ()
    2419                 :             :                                 .apply_scale (8, 10));
    2420                 :             : 
    2421                 :           0 :   emit_block_move_via_loop (x, y, size, align, -incr);
    2422                 :             : 
    2423                 :           0 :   emit_jump (end_label);
    2424                 :           0 :   emit_label (upw_label);
    2425                 :             : 
    2426                 :           0 :   emit_block_move_via_loop (x, y, size, align, incr);
    2427                 :             : 
    2428                 :           0 :   emit_label (end_label);
    2429                 :           0 : }
    2430                 :             : 
    2431                 :             : /* A subroutine of emit_block_move.  Copy the data via an explicit
    2432                 :             :    loop.  This is used only when libcalls are forbidden, or when
    2433                 :             :    inlining is required.  INCR is the block size to be copied in each
    2434                 :             :    loop iteration.  If it is negative, the absolute value is used, and
    2435                 :             :    the block is copied backwards.  INCR must be a power of two, an
    2436                 :             :    exact divisor for SIZE and ALIGN, and imply a mode that can be
    2437                 :             :    safely copied per iteration assuming no overlap.  */
    2438                 :             : 
    2439                 :             : static void
    2440                 :          48 : emit_block_move_via_loop (rtx x, rtx y, rtx size,
    2441                 :             :                           unsigned int align, int incr)
    2442                 :             : {
    2443                 :          48 :   rtx_code_label *cmp_label, *top_label;
    2444                 :          48 :   rtx iter, x_addr, y_addr, tmp;
    2445                 :          48 :   machine_mode x_addr_mode = get_address_mode (x);
    2446                 :          48 :   machine_mode y_addr_mode = get_address_mode (y);
    2447                 :          48 :   machine_mode iter_mode;
    2448                 :             : 
    2449                 :          48 :   iter_mode = GET_MODE (size);
    2450                 :          48 :   if (iter_mode == VOIDmode)
    2451                 :           0 :     iter_mode = word_mode;
    2452                 :             : 
    2453                 :          48 :   top_label = gen_label_rtx ();
    2454                 :          48 :   cmp_label = gen_label_rtx ();
    2455                 :          48 :   iter = gen_reg_rtx (iter_mode);
    2456                 :             : 
    2457                 :          48 :   bool downwards = incr < 0;
    2458                 :          48 :   rtx iter_init;
    2459                 :          48 :   rtx_code iter_cond;
    2460                 :          48 :   rtx iter_limit;
    2461                 :          48 :   rtx iter_incr;
    2462                 :          48 :   machine_mode move_mode;
    2463                 :          48 :   if (downwards)
    2464                 :             :     {
    2465                 :           0 :       incr = -incr;
    2466                 :           0 :       iter_init = size;
    2467                 :           0 :       iter_cond = GEU;
    2468                 :           0 :       iter_limit = const0_rtx;
    2469                 :           0 :       iter_incr = GEN_INT (incr);
    2470                 :             :     }
    2471                 :             :   else
    2472                 :             :     {
    2473                 :          48 :       iter_init = const0_rtx;
    2474                 :          48 :       iter_cond = LTU;
    2475                 :          48 :       iter_limit = size;
    2476                 :          48 :       iter_incr = GEN_INT (incr);
    2477                 :             :     }
    2478                 :          48 :   emit_move_insn (iter, iter_init);
    2479                 :             : 
    2480                 :          48 :   opt_scalar_int_mode int_move_mode
    2481                 :          48 :     = int_mode_for_size (incr * BITS_PER_UNIT, 1);
    2482                 :          48 :   if (!int_move_mode.exists (&move_mode)
    2483                 :          96 :       || GET_MODE_BITSIZE (int_move_mode.require ()) != incr * BITS_PER_UNIT)
    2484                 :             :     {
    2485                 :           0 :       move_mode = BLKmode;
    2486                 :           0 :       gcc_checking_assert (can_move_by_pieces (incr, align));
    2487                 :             :     }
    2488                 :             : 
    2489                 :          48 :   x_addr = force_operand (XEXP (x, 0), NULL_RTX);
    2490                 :          48 :   y_addr = force_operand (XEXP (y, 0), NULL_RTX);
    2491                 :          48 :   do_pending_stack_adjust ();
    2492                 :             : 
    2493                 :          48 :   emit_jump (cmp_label);
    2494                 :          48 :   emit_label (top_label);
    2495                 :             : 
    2496                 :          48 :   tmp = convert_modes (x_addr_mode, iter_mode, iter, true);
    2497                 :          48 :   x_addr = simplify_gen_binary (PLUS, x_addr_mode, x_addr, tmp);
    2498                 :             : 
    2499                 :          48 :   if (x_addr_mode != y_addr_mode)
    2500                 :           0 :     tmp = convert_modes (y_addr_mode, iter_mode, iter, true);
    2501                 :          48 :   y_addr = simplify_gen_binary (PLUS, y_addr_mode, y_addr, tmp);
    2502                 :             : 
    2503                 :          48 :   x = change_address (x, move_mode, x_addr);
    2504                 :          48 :   y = change_address (y, move_mode, y_addr);
    2505                 :             : 
    2506                 :          48 :   if (move_mode == BLKmode)
    2507                 :             :     {
    2508                 :           0 :       bool done;
    2509                 :           0 :       emit_block_move_hints (x, y, iter_incr, BLOCK_OP_NO_LIBCALL,
    2510                 :             :                              align, incr, incr, incr, incr,
    2511                 :             :                              false, &done, false);
    2512                 :           0 :       gcc_checking_assert (done);
    2513                 :             :     }
    2514                 :             :   else
    2515                 :          48 :     emit_move_insn (x, y);
    2516                 :             : 
    2517                 :          48 :   if (downwards)
    2518                 :           0 :     emit_label (cmp_label);
    2519                 :             : 
    2520                 :          48 :   tmp = expand_simple_binop (iter_mode, PLUS, iter, iter_incr, iter,
    2521                 :             :                              true, OPTAB_LIB_WIDEN);
    2522                 :          48 :   if (tmp != iter)
    2523                 :           0 :     emit_move_insn (iter, tmp);
    2524                 :             : 
    2525                 :          48 :   if (!downwards)
    2526                 :          48 :     emit_label (cmp_label);
    2527                 :             : 
    2528                 :          48 :   emit_cmp_and_jump_insns (iter, iter_limit, iter_cond, NULL_RTX, iter_mode,
    2529                 :             :                            true, top_label,
    2530                 :          48 :                            profile_probability::guessed_always ()
    2531                 :             :                                 .apply_scale (9, 10));
    2532                 :          48 : }
    2533                 :             : 
    2534                 :             : /* Expand a call to memcpy or memmove or memcmp, and return the result.
    2535                 :             :    TAILCALL is true if this is a tail call.  */
    2536                 :             : 
    2537                 :             : rtx
    2538                 :       35772 : emit_block_op_via_libcall (enum built_in_function fncode, rtx dst, rtx src,
    2539                 :             :                            rtx size, bool tailcall)
    2540                 :             : {
    2541                 :       35772 :   rtx dst_addr, src_addr;
    2542                 :       35772 :   tree call_expr, dst_tree, src_tree, size_tree;
    2543                 :       35772 :   machine_mode size_mode;
    2544                 :             : 
    2545                 :             :   /* Since dst and src are passed to a libcall, mark the corresponding
    2546                 :             :      tree EXPR as addressable.  */
    2547                 :       35772 :   tree dst_expr = MEM_EXPR (dst);
    2548                 :       35772 :   tree src_expr = MEM_EXPR (src);
    2549                 :       35772 :   if (dst_expr)
    2550                 :       35470 :     mark_addressable (dst_expr);
    2551                 :       35772 :   if (src_expr)
    2552                 :       35734 :     mark_addressable (src_expr);
    2553                 :             : 
    2554                 :       35772 :   dst_addr = copy_addr_to_reg (XEXP (dst, 0));
    2555                 :       35772 :   dst_addr = convert_memory_address (ptr_mode, dst_addr);
    2556                 :       35772 :   dst_tree = make_tree (ptr_type_node, dst_addr);
    2557                 :             : 
    2558                 :       35772 :   src_addr = copy_addr_to_reg (XEXP (src, 0));
    2559                 :       35772 :   src_addr = convert_memory_address (ptr_mode, src_addr);
    2560                 :       35772 :   src_tree = make_tree (ptr_type_node, src_addr);
    2561                 :             : 
    2562                 :       35772 :   size_mode = TYPE_MODE (sizetype);
    2563                 :       35772 :   size = convert_to_mode (size_mode, size, 1);
    2564                 :       35772 :   size = copy_to_mode_reg (size_mode, size);
    2565                 :       35772 :   size_tree = make_tree (sizetype, size);
    2566                 :             : 
    2567                 :             :   /* It is incorrect to use the libcall calling conventions for calls to
    2568                 :             :      memcpy/memmove/memcmp because they can be provided by the user.  */
    2569                 :       35772 :   tree fn = builtin_decl_implicit (fncode);
    2570                 :       35772 :   call_expr = build_call_expr (fn, 3, dst_tree, src_tree, size_tree);
    2571                 :       35772 :   CALL_EXPR_TAILCALL (call_expr) = tailcall;
    2572                 :             : 
    2573                 :       35772 :   return expand_call (call_expr, NULL_RTX, false);
    2574                 :             : }
    2575                 :             : 
    2576                 :             : /* Try to expand cmpstrn or cmpmem operation ICODE with the given operands.
    2577                 :             :    ARG3_TYPE is the type of ARG3_RTX.  Return the result rtx on success,
    2578                 :             :    otherwise return null.  */
    2579                 :             : 
    2580                 :             : rtx
    2581                 :      204348 : expand_cmpstrn_or_cmpmem (insn_code icode, rtx target, rtx arg1_rtx,
    2582                 :             :                           rtx arg2_rtx, tree arg3_type, rtx arg3_rtx,
    2583                 :             :                           HOST_WIDE_INT align)
    2584                 :             : {
    2585                 :      204348 :   machine_mode insn_mode = insn_data[icode].operand[0].mode;
    2586                 :             : 
    2587                 :      204348 :   if (target && (!REG_P (target) || HARD_REGISTER_P (target)))
    2588                 :             :     target = NULL_RTX;
    2589                 :             : 
    2590                 :      204348 :   class expand_operand ops[5];
    2591                 :      204348 :   create_output_operand (&ops[0], target, insn_mode);
    2592                 :      204348 :   create_fixed_operand (&ops[1], arg1_rtx);
    2593                 :      204348 :   create_fixed_operand (&ops[2], arg2_rtx);
    2594                 :      204348 :   create_convert_operand_from (&ops[3], arg3_rtx, TYPE_MODE (arg3_type),
    2595                 :      204348 :                                TYPE_UNSIGNED (arg3_type));
    2596                 :      204348 :   create_integer_operand (&ops[4], align);
    2597                 :      204348 :   if (maybe_expand_insn (icode, 5, ops))
    2598                 :        5718 :     return ops[0].value;
    2599                 :             :   return NULL_RTX;
    2600                 :             : }
    2601                 :             : 
    2602                 :             : /* Expand a block compare between X and Y with length LEN using the
    2603                 :             :    cmpmem optab, placing the result in TARGET.  LEN_TYPE is the type
    2604                 :             :    of the expression that was used to calculate the length.  ALIGN
    2605                 :             :    gives the known minimum common alignment.  */
    2606                 :             : 
    2607                 :             : static rtx
    2608                 :       76751 : emit_block_cmp_via_cmpmem (rtx x, rtx y, rtx len, tree len_type, rtx target,
    2609                 :             :                            unsigned align)
    2610                 :             : {
    2611                 :             :   /* Note: The cmpstrnsi pattern, if it exists, is not suitable for
    2612                 :             :      implementing memcmp because it will stop if it encounters two
    2613                 :             :      zero bytes.  */
    2614                 :       76751 :   insn_code icode = direct_optab_handler (cmpmem_optab, SImode);
    2615                 :             : 
    2616                 :       76751 :   if (icode == CODE_FOR_nothing)
    2617                 :             :     return NULL_RTX;
    2618                 :             : 
    2619                 :       76751 :   return expand_cmpstrn_or_cmpmem (icode, target, x, y, len_type, len, align);
    2620                 :             : }
    2621                 :             : 
    2622                 :             : /* Emit code to compare a block Y to a block X.  This may be done with
    2623                 :             :    string-compare instructions, with multiple scalar instructions,
    2624                 :             :    or with a library call.
    2625                 :             : 
    2626                 :             :    Both X and Y must be MEM rtx's.  LEN is an rtx that says how long
    2627                 :             :    they are.  LEN_TYPE is the type of the expression that was used to
    2628                 :             :    calculate it, and CTZ_LEN is the known trailing-zeros count of LEN,
    2629                 :             :    so LEN must be a multiple of 1<<CTZ_LEN even if it's not constant.
    2630                 :             : 
    2631                 :             :    If EQUALITY_ONLY is true, it means we don't have to return the tri-state
    2632                 :             :    value of a normal memcmp call, instead we can just compare for equality.
    2633                 :             :    If FORCE_LIBCALL is true, we should emit a call to memcmp rather than
    2634                 :             :    returning NULL_RTX.
    2635                 :             : 
    2636                 :             :    Optionally, the caller can pass a constfn and associated data in Y_CFN
    2637                 :             :    and Y_CFN_DATA. describing that the second operand being compared is a
    2638                 :             :    known constant and how to obtain its data.
    2639                 :             :    Return the result of the comparison, or NULL_RTX if we failed to
    2640                 :             :    perform the operation.  */
    2641                 :             : 
    2642                 :             : rtx
    2643                 :      110361 : emit_block_cmp_hints (rtx x, rtx y, rtx len, tree len_type, rtx target,
    2644                 :             :                       bool equality_only, by_pieces_constfn y_cfn,
    2645                 :             :                       void *y_cfndata, unsigned ctz_len)
    2646                 :             : {
    2647                 :      110361 :   rtx result = 0;
    2648                 :             : 
    2649                 :      110361 :   if (CONST_INT_P (len) && INTVAL (len) == 0)
    2650                 :           6 :     return const0_rtx;
    2651                 :             : 
    2652                 :      110355 :   gcc_assert (MEM_P (x) && MEM_P (y));
    2653                 :      110355 :   unsigned int align = MIN (MEM_ALIGN (x), MEM_ALIGN (y));
    2654                 :      110355 :   gcc_assert (align >= BITS_PER_UNIT);
    2655                 :             : 
    2656                 :      110355 :   x = adjust_address (x, BLKmode, 0);
    2657                 :      110355 :   y = adjust_address (y, BLKmode, 0);
    2658                 :             : 
    2659                 :      110355 :   if (equality_only
    2660                 :       57073 :       && CONST_INT_P (len)
    2661                 :      146896 :       && can_do_by_pieces (INTVAL (len), align, COMPARE_BY_PIECES))
    2662                 :       33604 :     result = compare_by_pieces (x, y, INTVAL (len), target, align,
    2663                 :             :                                 y_cfn, y_cfndata);
    2664                 :             :   else
    2665                 :       76751 :     result = emit_block_cmp_via_cmpmem (x, y, len, len_type, target, align);
    2666                 :             : 
    2667                 :      110355 :   if (!result && (flag_inline_stringops & ILSOP_MEMCMP))
    2668                 :         361 :     result = emit_block_cmp_via_loop (x, y, len, len_type,
    2669                 :             :                                       target, equality_only,
    2670                 :             :                                       align, ctz_len);
    2671                 :             : 
    2672                 :             :   return result;
    2673                 :             : }
    2674                 :             : 
    2675                 :             : /* Like emit_block_cmp_hints, but with known alignment and no support
    2676                 :             :    for constats.  Always expand to a loop with iterations that compare
    2677                 :             :    blocks of the largest compare-by-pieces size that divides both len
    2678                 :             :    and align, and then, if !EQUALITY_ONLY, identify the word and then
    2679                 :             :    the unit that first differs to return the result.  */
    2680                 :             : 
    2681                 :             : rtx
    2682                 :         403 : emit_block_cmp_via_loop (rtx x, rtx y, rtx len, tree len_type, rtx target,
    2683                 :             :                          bool equality_only, unsigned align, unsigned ctz_len)
    2684                 :             : {
    2685                 :         403 :   unsigned incr = align / BITS_PER_UNIT;
    2686                 :             : 
    2687                 :         403 :   if (CONST_INT_P (len))
    2688                 :         319 :     ctz_len = MAX (ctz_len, (unsigned) wi::ctz (UINTVAL (len)));
    2689                 :             : 
    2690                 :         403 :   if (HOST_WIDE_INT_1U << ctz_len < (unsigned HOST_WIDE_INT) incr)
    2691                 :         148 :     incr = HOST_WIDE_INT_1U << ctz_len;
    2692                 :             : 
    2693                 :             :   while (incr > 1
    2694                 :         407 :          && !can_do_by_pieces (incr, align, COMPARE_BY_PIECES))
    2695                 :           4 :     incr >>= 1;
    2696                 :             : 
    2697                 :         403 :   rtx_code_label *cmp_label, *top_label, *ne_label, *res_label;
    2698                 :         403 :   rtx iter, x_addr, y_addr, tmp;
    2699                 :         403 :   machine_mode x_addr_mode = get_address_mode (x);
    2700                 :         403 :   machine_mode y_addr_mode = get_address_mode (y);
    2701                 :         403 :   machine_mode iter_mode;
    2702                 :             : 
    2703                 :         403 :   iter_mode = GET_MODE (len);
    2704                 :         403 :   if (iter_mode == VOIDmode)
    2705                 :         319 :     iter_mode = word_mode;
    2706                 :             : 
    2707                 :         403 :   rtx iter_init = const0_rtx;
    2708                 :         403 :   rtx_code iter_cond = LTU;
    2709                 :         403 :   rtx_code entry_cond = GEU;
    2710                 :         403 :   rtx iter_limit = len;
    2711                 :         403 :   rtx iter_incr = GEN_INT (incr);
    2712                 :         403 :   machine_mode cmp_mode;
    2713                 :             : 
    2714                 :             :   /* We can drop the loop back edge if we know there's exactly one
    2715                 :             :      iteration.  */
    2716                 :         403 :   top_label = (!rtx_equal_p (len, iter_incr)
    2717                 :         403 :                ? gen_label_rtx ()
    2718                 :             :                : NULL);
    2719                 :             :   /* We need not test before entering the loop if len is known
    2720                 :             :      nonzero.  ??? This could be even stricter, testing whether a
    2721                 :             :      nonconstant LEN could possibly be zero.  */
    2722                 :         319 :   cmp_label = (!CONSTANT_P (len) || rtx_equal_p (len, iter_init)
    2723                 :         403 :                ? gen_label_rtx ()
    2724                 :             :                : NULL);
    2725                 :         403 :   ne_label = gen_label_rtx ();
    2726                 :         403 :   res_label = gen_label_rtx ();
    2727                 :             : 
    2728                 :         403 :   iter = gen_reg_rtx (iter_mode);
    2729                 :         403 :   emit_move_insn (iter, iter_init);
    2730                 :             : 
    2731                 :         403 :   opt_scalar_int_mode int_cmp_mode
    2732                 :         403 :     = int_mode_for_size (incr * BITS_PER_UNIT, 1);
    2733                 :         403 :   if (!int_cmp_mode.exists (&cmp_mode)
    2734                 :        1206 :       || GET_MODE_BITSIZE (int_cmp_mode.require ()) != incr * BITS_PER_UNIT
    2735                 :         402 :       || !can_compare_p (NE, cmp_mode, ccp_jump))
    2736                 :             :     {
    2737                 :           1 :       cmp_mode = BLKmode;
    2738                 :           1 :       gcc_checking_assert (incr != 1);
    2739                 :             :     }
    2740                 :             : 
    2741                 :             :   /* Save the base addresses.  */
    2742                 :         403 :   x_addr = force_operand (XEXP (x, 0), NULL_RTX);
    2743                 :         403 :   y_addr = force_operand (XEXP (y, 0), NULL_RTX);
    2744                 :         403 :   do_pending_stack_adjust ();
    2745                 :             : 
    2746                 :         403 :   if (cmp_label)
    2747                 :             :     {
    2748                 :          84 :       if (top_label)
    2749                 :          84 :         emit_jump (cmp_label);
    2750                 :             :       else
    2751                 :           0 :         emit_cmp_and_jump_insns (iter, iter_limit, entry_cond,
    2752                 :             :                                  NULL_RTX, iter_mode,
    2753                 :             :                                  true, cmp_label,
    2754                 :           0 :                                  profile_probability::guessed_always ()
    2755                 :             :                                  .apply_scale (1, 10));
    2756                 :             :     }
    2757                 :         403 :   if (top_label)
    2758                 :         386 :     emit_label (top_label);
    2759                 :             : 
    2760                 :             :   /* Offset the base addresses by ITER.  */
    2761                 :         403 :   tmp = convert_modes (x_addr_mode, iter_mode, iter, true);
    2762                 :         403 :   x_addr = simplify_gen_binary (PLUS, x_addr_mode, x_addr, tmp);
    2763                 :             : 
    2764                 :         403 :   if (x_addr_mode != y_addr_mode)
    2765                 :           0 :     tmp = convert_modes (y_addr_mode, iter_mode, iter, true);
    2766                 :         403 :   y_addr = simplify_gen_binary (PLUS, y_addr_mode, y_addr, tmp);
    2767                 :             : 
    2768                 :         403 :   x = change_address (x, cmp_mode, x_addr);
    2769                 :         403 :   y = change_address (y, cmp_mode, y_addr);
    2770                 :             : 
    2771                 :             :   /* Compare one block.  */
    2772                 :         403 :   rtx part_res;
    2773                 :         403 :   if (cmp_mode == BLKmode)
    2774                 :           1 :     part_res = compare_by_pieces (x, y, incr, target, align, 0, 0);
    2775                 :             :   else
    2776                 :         402 :     part_res = expand_binop (cmp_mode, sub_optab, x, y, NULL_RTX,
    2777                 :             :                              true, OPTAB_LIB_WIDEN);
    2778                 :             : 
    2779                 :             :   /* Stop if we found a difference.  */
    2780                 :         806 :   emit_cmp_and_jump_insns (part_res, GEN_INT (0), NE, NULL_RTX,
    2781                 :         403 :                            GET_MODE (part_res), true, ne_label,
    2782                 :         403 :                            profile_probability::guessed_always ()
    2783                 :             :                                 .apply_scale (1, 10));
    2784                 :             : 
    2785                 :             :   /* Increment ITER.  */
    2786                 :         403 :   tmp = expand_simple_binop (iter_mode, PLUS, iter, iter_incr, iter,
    2787                 :             :                              true, OPTAB_LIB_WIDEN);
    2788                 :         403 :   if (tmp != iter)
    2789                 :           0 :     emit_move_insn (iter, tmp);
    2790                 :             : 
    2791                 :         403 :   if (cmp_label)
    2792                 :          84 :     emit_label (cmp_label);
    2793                 :             :   /* Loop until we reach the limit.  */
    2794                 :             : 
    2795                 :         403 :   if (top_label)
    2796                 :         386 :     emit_cmp_and_jump_insns (iter, iter_limit, iter_cond, NULL_RTX, iter_mode,
    2797                 :             :                              true, top_label,
    2798                 :         772 :                              profile_probability::guessed_always ()
    2799                 :             :                              .apply_scale (9, 10));
    2800                 :             : 
    2801                 :             :   /* We got to the end without differences, so the result is zero.  */
    2802                 :         403 :   if (target == NULL_RTX
    2803                 :         403 :       || !REG_P (target) || REGNO (target) < FIRST_PSEUDO_REGISTER)
    2804                 :          49 :     target = gen_reg_rtx (TYPE_MODE (integer_type_node));
    2805                 :             : 
    2806                 :         403 :   emit_move_insn (target, const0_rtx);
    2807                 :         403 :   emit_jump (res_label);
    2808                 :             : 
    2809                 :         403 :   emit_label (ne_label);
    2810                 :             : 
    2811                 :             :   /* Return nonzero, or pinpoint the difference to return the expected
    2812                 :             :      result for non-equality tests.  */
    2813                 :         403 :   if (equality_only)
    2814                 :           0 :     emit_move_insn (target, const1_rtx);
    2815                 :             :   else
    2816                 :             :     {
    2817                 :         403 :       if (incr > UNITS_PER_WORD)
    2818                 :             :         /* ??? Re-compare the block found to be different one word at a
    2819                 :             :            time.  */
    2820                 :           5 :         part_res = emit_block_cmp_via_loop (x, y, GEN_INT (incr), len_type,
    2821                 :             :                                             target, equality_only,
    2822                 :             :                                             BITS_PER_WORD, 0);
    2823                 :         398 :       else if (incr > 1)
    2824                 :             :         /* ??? Re-compare the block found to be different one byte at a
    2825                 :             :            time.  We could do better using part_res, and being careful
    2826                 :             :            about endianness.  */
    2827                 :          37 :         part_res = emit_block_cmp_via_loop (x, y, GEN_INT (incr), len_type,
    2828                 :             :                                             target, equality_only,
    2829                 :             :                                             BITS_PER_UNIT, 0);
    2830                 :        1083 :       else if (known_gt (GET_MODE_BITSIZE (GET_MODE (target)),
    2831                 :             :                          GET_MODE_BITSIZE (cmp_mode)))
    2832                 :         361 :         part_res = expand_binop (GET_MODE (target), sub_optab, x, y, target,
    2833                 :             :                                  true, OPTAB_LIB_WIDEN);
    2834                 :             :       else
    2835                 :             :         {
    2836                 :             :           /* In the odd chance target is QImode, we can't count on
    2837                 :             :              widening subtract to capture the result of the unsigned
    2838                 :             :              compares.  */
    2839                 :           0 :           rtx_code_label *ltu_label;
    2840                 :           0 :           ltu_label = gen_label_rtx ();
    2841                 :           0 :           emit_cmp_and_jump_insns (x, y, LTU, NULL_RTX,
    2842                 :             :                                    cmp_mode, true, ltu_label,
    2843                 :           0 :                                    profile_probability::guessed_always ()
    2844                 :             :                                    .apply_scale (5, 10));
    2845                 :             : 
    2846                 :           0 :           emit_move_insn (target, const1_rtx);
    2847                 :           0 :           emit_jump (res_label);
    2848                 :             : 
    2849                 :           0 :           emit_label (ltu_label);
    2850                 :           0 :           emit_move_insn (target, constm1_rtx);
    2851                 :           0 :           part_res = target;
    2852                 :             :         }
    2853                 :             : 
    2854                 :         403 :       if (target != part_res)
    2855                 :           0 :         convert_move (target, part_res, false);
    2856                 :             :     }
    2857                 :             : 
    2858                 :         403 :   emit_label (res_label);
    2859                 :             : 
    2860                 :         403 :   return target;
    2861                 :             : }
    2862                 :             : 
    2863                 :             : 
    2864                 :             : /* Copy all or part of a value X into registers starting at REGNO.
    2865                 :             :    The number of registers to be filled is NREGS.  */
    2866                 :             : 
    2867                 :             : void
    2868                 :         317 : move_block_to_reg (int regno, rtx x, int nregs, machine_mode mode)
    2869                 :             : {
    2870                 :         317 :   if (nregs == 0)
    2871                 :             :     return;
    2872                 :             : 
    2873                 :         303 :   if (CONSTANT_P (x) && !targetm.legitimate_constant_p (mode, x))
    2874                 :           0 :     x = validize_mem (force_const_mem (mode, x));
    2875                 :             : 
    2876                 :             :   /* See if the machine can do this with a load multiple insn.  */
    2877                 :         303 :   if (targetm.have_load_multiple ())
    2878                 :             :     {
    2879                 :           0 :       rtx_insn *last = get_last_insn ();
    2880                 :           0 :       rtx first = gen_rtx_REG (word_mode, regno);
    2881                 :           0 :       if (rtx_insn *pat = targetm.gen_load_multiple (first, x,
    2882                 :             :                                                      GEN_INT (nregs)))
    2883                 :             :         {
    2884                 :           0 :           emit_insn (pat);
    2885                 :           0 :           return;
    2886                 :             :         }
    2887                 :             :       else
    2888                 :           0 :         delete_insns_since (last);
    2889                 :             :     }
    2890                 :             : 
    2891                 :         606 :   for (int i = 0; i < nregs; i++)
    2892                 :         303 :     emit_move_insn (gen_rtx_REG (word_mode, regno + i),
    2893                 :         303 :                     operand_subword_force (x, i, mode));
    2894                 :             : }
    2895                 :             : 
    2896                 :             : /* Copy all or part of a BLKmode value X out of registers starting at REGNO.
    2897                 :             :    The number of registers to be filled is NREGS.  */
    2898                 :             : 
    2899                 :             : void
    2900                 :        1166 : move_block_from_reg (int regno, rtx x, int nregs)
    2901                 :             : {
    2902                 :        1166 :   if (nregs == 0)
    2903                 :             :     return;
    2904                 :             : 
    2905                 :             :   /* See if the machine can do this with a store multiple insn.  */
    2906                 :        1166 :   if (targetm.have_store_multiple ())
    2907                 :             :     {
    2908                 :           0 :       rtx_insn *last = get_last_insn ();
    2909                 :           0 :       rtx first = gen_rtx_REG (word_mode, regno);
    2910                 :           0 :       if (rtx_insn *pat = targetm.gen_store_multiple (x, first,
    2911                 :             :                                                       GEN_INT (nregs)))
    2912                 :             :         {
    2913                 :           0 :           emit_insn (pat);
    2914                 :           0 :           return;
    2915                 :             :         }
    2916                 :             :       else
    2917                 :           0 :         delete_insns_since (last);
    2918                 :             :     }
    2919                 :             : 
    2920                 :        2332 :   for (int i = 0; i < nregs; i++)
    2921                 :             :     {
    2922                 :        1166 :       rtx tem = operand_subword (x, i, 1, BLKmode);
    2923                 :             : 
    2924                 :        1166 :       gcc_assert (tem);
    2925                 :             : 
    2926                 :        1166 :       emit_move_insn (tem, gen_rtx_REG (word_mode, regno + i));
    2927                 :             :     }
    2928                 :             : }
    2929                 :             : 
    2930                 :             : /* Generate a PARALLEL rtx for a new non-consecutive group of registers from
    2931                 :             :    ORIG, where ORIG is a non-consecutive group of registers represented by
    2932                 :             :    a PARALLEL.  The clone is identical to the original except in that the
    2933                 :             :    original set of registers is replaced by a new set of pseudo registers.
    2934                 :             :    The new set has the same modes as the original set.  */
    2935                 :             : 
    2936                 :             : rtx
    2937                 :        2899 : gen_group_rtx (rtx orig)
    2938                 :             : {
    2939                 :        2899 :   int i, length;
    2940                 :        2899 :   rtx *tmps;
    2941                 :             : 
    2942                 :        2899 :   gcc_assert (GET_CODE (orig) == PARALLEL);
    2943                 :             : 
    2944                 :        2899 :   length = XVECLEN (orig, 0);
    2945                 :        2899 :   tmps = XALLOCAVEC (rtx, length);
    2946                 :             : 
    2947                 :             :   /* Skip a NULL entry in first slot.  */
    2948                 :        2899 :   i = XEXP (XVECEXP (orig, 0, 0), 0) ? 0 : 1;
    2949                 :             : 
    2950                 :        2899 :   if (i)
    2951                 :           0 :     tmps[0] = 0;
    2952                 :             : 
    2953                 :        7077 :   for (; i < length; i++)
    2954                 :             :     {
    2955                 :        4178 :       machine_mode mode = GET_MODE (XEXP (XVECEXP (orig, 0, i), 0));
    2956                 :        4178 :       rtx offset = XEXP (XVECEXP (orig, 0, i), 1);
    2957                 :             : 
    2958                 :        4178 :       tmps[i] = gen_rtx_EXPR_LIST (VOIDmode, gen_reg_rtx (mode), offset);
    2959                 :             :     }
    2960                 :             : 
    2961                 :        2899 :   return gen_rtx_PARALLEL (GET_MODE (orig), gen_rtvec_v (length, tmps));
    2962                 :             : }
    2963                 :             : 
    2964                 :             : /* A subroutine of emit_group_load.  Arguments as for emit_group_load,
    2965                 :             :    except that values are placed in TMPS[i], and must later be moved
    2966                 :             :    into corresponding XEXP (XVECEXP (DST, 0, i), 0) element.  */
    2967                 :             : 
    2968                 :             : static void
    2969                 :      269297 : emit_group_load_1 (rtx *tmps, rtx dst, rtx orig_src, tree type,
    2970                 :             :                    poly_int64 ssize)
    2971                 :             : {
    2972                 :      269300 :   rtx src;
    2973                 :      269300 :   int start, i;
    2974                 :      269300 :   machine_mode m = GET_MODE (orig_src);
    2975                 :             : 
    2976                 :      269300 :   gcc_assert (GET_CODE (dst) == PARALLEL);
    2977                 :             : 
    2978                 :      269300 :   if (m != VOIDmode
    2979                 :      256410 :       && !SCALAR_INT_MODE_P (m)
    2980                 :       17213 :       && !MEM_P (orig_src)
    2981                 :        4233 :       && GET_CODE (orig_src) != CONCAT)
    2982                 :             :     {
    2983                 :           3 :       scalar_int_mode imode;
    2984                 :           3 :       if (int_mode_for_mode (GET_MODE (orig_src)).exists (&imode))
    2985                 :             :         {
    2986                 :           3 :           src = gen_reg_rtx (imode);
    2987                 :           3 :           emit_move_insn (gen_lowpart (GET_MODE (orig_src), src), orig_src);
    2988                 :             :         }
    2989                 :             :       else
    2990                 :             :         {
    2991                 :           0 :           src = assign_stack_temp (GET_MODE (orig_src), ssize);
    2992                 :           0 :           emit_move_insn (src, orig_src);
    2993                 :             :         }
    2994                 :           3 :       emit_group_load_1 (tmps, dst, src, type, ssize);
    2995                 :             :       return;
    2996                 :             :     }
    2997                 :             : 
    2998                 :             :   /* Check for a NULL entry, used to indicate that the parameter goes
    2999                 :             :      both on the stack and in registers.  */
    3000                 :      269297 :   if (XEXP (XVECEXP (dst, 0, 0), 0))
    3001                 :             :     start = 0;
    3002                 :             :   else
    3003                 :           0 :     start = 1;
    3004                 :             : 
    3005                 :             :   /* Process the pieces.  */
    3006                 :      797382 :   for (i = start; i < XVECLEN (dst, 0); i++)
    3007                 :             :     {
    3008                 :      528085 :       machine_mode mode = GET_MODE (XEXP (XVECEXP (dst, 0, i), 0));
    3009                 :      528085 :       poly_int64 bytepos = rtx_to_poly_int64 (XEXP (XVECEXP (dst, 0, i), 1));
    3010                 :     1056170 :       poly_int64 bytelen = GET_MODE_SIZE (mode);
    3011                 :      528085 :       poly_int64 shift = 0;
    3012                 :             : 
    3013                 :             :       /* Handle trailing fragments that run over the size of the struct.
    3014                 :             :          It's the target's responsibility to make sure that the fragment
    3015                 :             :          cannot be strictly smaller in some cases and strictly larger
    3016                 :             :          in others.  */
    3017                 :      528085 :       gcc_checking_assert (ordered_p (bytepos + bytelen, ssize));
    3018                 :      528085 :       if (known_size_p (ssize) && maybe_gt (bytepos + bytelen, ssize))
    3019                 :             :         {
    3020                 :             :           /* Arrange to shift the fragment to where it belongs.
    3021                 :             :              extract_bit_field loads to the lsb of the reg.  */
    3022                 :             :           if (
    3023                 :             : #ifdef BLOCK_REG_PADDING
    3024                 :             :               BLOCK_REG_PADDING (GET_MODE (orig_src), type, i == start)
    3025                 :             :               == (BYTES_BIG_ENDIAN ? PAD_UPWARD : PAD_DOWNWARD)
    3026                 :             : #else
    3027                 :             :               BYTES_BIG_ENDIAN
    3028                 :             : #endif
    3029                 :             :               )
    3030                 :             :             shift = (bytelen - (ssize - bytepos)) * BITS_PER_UNIT;
    3031                 :        1768 :           bytelen = ssize - bytepos;
    3032                 :        1768 :           gcc_assert (maybe_gt (bytelen, 0));
    3033                 :             :         }
    3034                 :             : 
    3035                 :             :       /* If we won't be loading directly from memory, protect the real source
    3036                 :             :          from strange tricks we might play; but make sure that the source can
    3037                 :             :          be loaded directly into the destination.  */
    3038                 :      528085 :       src = orig_src;
    3039                 :      528085 :       if (!MEM_P (orig_src)
    3040                 :      440897 :           && (!REG_P (orig_src) || HARD_REGISTER_P (orig_src))
    3041                 :      560312 :           && !CONSTANT_P (orig_src))
    3042                 :             :         {
    3043                 :        6447 :           gcc_assert (GET_MODE (orig_src) != VOIDmode);
    3044                 :        6447 :           src = force_reg (GET_MODE (orig_src), orig_src);
    3045                 :             :         }
    3046                 :             : 
    3047                 :             :       /* Optimize the access just a bit.  */
    3048                 :      528085 :       if (MEM_P (src)
    3049                 :       87188 :           && (! targetm.slow_unaligned_access (mode, MEM_ALIGN (src))
    3050                 :           0 :               || MEM_ALIGN (src) >= GET_MODE_ALIGNMENT (mode))
    3051                 :      174376 :           && multiple_p (bytepos * BITS_PER_UNIT, GET_MODE_ALIGNMENT (mode))
    3052                 :      615273 :           && known_eq (bytelen, GET_MODE_SIZE (mode)))
    3053                 :             :         {
    3054                 :       85439 :           tmps[i] = gen_reg_rtx (mode);
    3055                 :       85439 :           emit_move_insn (tmps[i], adjust_address (src, mode, bytepos));
    3056                 :             :         }
    3057                 :      442646 :       else if (COMPLEX_MODE_P (mode)
    3058                 :           0 :                && GET_MODE (src) == mode
    3059                 :      442646 :                && known_eq (bytelen, GET_MODE_SIZE (mode)))
    3060                 :             :         /* Let emit_move_complex do the bulk of the work.  */
    3061                 :           0 :         tmps[i] = src;
    3062                 :      442646 :       else if (GET_CODE (src) == CONCAT)
    3063                 :             :         {
    3064                 :       12894 :           poly_int64 slen = GET_MODE_SIZE (GET_MODE (src));
    3065                 :       12894 :           poly_int64 slen0 = GET_MODE_SIZE (GET_MODE (XEXP (src, 0)));
    3066                 :        6447 :           unsigned int elt;
    3067                 :        6447 :           poly_int64 subpos;
    3068                 :             : 
    3069                 :        6447 :           if (can_div_trunc_p (bytepos, slen0, &elt, &subpos)
    3070                 :        6447 :               && known_le (subpos + bytelen, slen0))
    3071                 :             :             {
    3072                 :             :               /* The following assumes that the concatenated objects all
    3073                 :             :                  have the same size.  In this case, a simple calculation
    3074                 :             :                  can be used to determine the object and the bit field
    3075                 :             :                  to be extracted.  */
    3076                 :        4434 :               tmps[i] = XEXP (src, elt);
    3077                 :        4434 :               if (maybe_ne (subpos, 0)
    3078                 :        4434 :                   || maybe_ne (subpos + bytelen, slen0)
    3079                 :        8868 :                   || (!CONSTANT_P (tmps[i])
    3080                 :        4434 :                       && (!REG_P (tmps[i]) || GET_MODE (tmps[i]) != mode)))
    3081                 :           0 :                 tmps[i] = extract_bit_field (tmps[i], bytelen * BITS_PER_UNIT,
    3082                 :           0 :                                              subpos * BITS_PER_UNIT,
    3083                 :             :                                              1, NULL_RTX, mode, mode, false,
    3084                 :             :                                              NULL);
    3085                 :             :             }
    3086                 :             :           else
    3087                 :             :             {
    3088                 :        2013 :               rtx mem;
    3089                 :             : 
    3090                 :        2013 :               gcc_assert (known_eq (bytepos, 0));
    3091                 :        2013 :               mem = assign_stack_temp (GET_MODE (src), slen);
    3092                 :        2013 :               emit_move_insn (mem, src);
    3093                 :        2013 :               tmps[i] = extract_bit_field (mem, bytelen * BITS_PER_UNIT,
    3094                 :        2013 :                                            0, 1, NULL_RTX, mode, mode, false,
    3095                 :             :                                            NULL);
    3096                 :             :             }
    3097                 :             :         }
    3098                 :      436199 :       else if (CONSTANT_P (src) && GET_MODE (dst) != BLKmode
    3099                 :       25780 :                && XVECLEN (dst, 0) > 1)
    3100                 :       25780 :         tmps[i] = force_subreg (mode, src, GET_MODE (dst), bytepos);
    3101                 :      410419 :       else if (CONSTANT_P (src))
    3102                 :             :         {
    3103                 :           0 :           if (known_eq (bytelen, ssize))
    3104                 :           0 :             tmps[i] = src;
    3105                 :             :           else
    3106                 :             :             {
    3107                 :             :               rtx first, second;
    3108                 :             : 
    3109                 :             :               /* TODO: const_wide_int can have sizes other than this...  */
    3110                 :           0 :               gcc_assert (known_eq (2 * bytelen, ssize));
    3111                 :           0 :               split_double (src, &first, &second);
    3112                 :           0 :               if (i)
    3113                 :           0 :                 tmps[i] = second;
    3114                 :             :               else
    3115                 :           0 :                 tmps[i] = first;
    3116                 :             :             }
    3117                 :             :         }
    3118                 :      410419 :       else if (REG_P (src) && GET_MODE (src) == mode)
    3119                 :           0 :         tmps[i] = src;
    3120                 :             :       else
    3121                 :      410419 :         tmps[i] = extract_bit_field (src, bytelen * BITS_PER_UNIT,
    3122                 :      410419 :                                      bytepos * BITS_PER_UNIT, 1, NULL_RTX,
    3123                 :             :                                      mode, mode, false, NULL);
    3124                 :             : 
    3125                 :      528085 :       if (maybe_ne (shift, 0))
    3126                 :             :         tmps[i] = expand_shift (LSHIFT_EXPR, mode, tmps[i],
    3127                 :             :                                 shift, tmps[i], 0);
    3128                 :             :     }
    3129                 :             : }
    3130                 :             : 
    3131                 :             : /* Emit code to move a block SRC of type TYPE to a block DST,
    3132                 :             :    where DST is non-consecutive registers represented by a PARALLEL.
    3133                 :             :    SSIZE represents the total size of block ORIG_SRC in bytes, or -1
    3134                 :             :    if not known.  */
    3135                 :             : 
    3136                 :             : void
    3137                 :       10545 : emit_group_load (rtx dst, rtx src, tree type, poly_int64 ssize)
    3138                 :             : {
    3139                 :       10545 :   rtx *tmps;
    3140                 :       10545 :   int i;
    3141                 :             : 
    3142                 :       10545 :   tmps = XALLOCAVEC (rtx, XVECLEN (dst, 0));
    3143                 :       10545 :   emit_group_load_1 (tmps, dst, src, type, ssize);
    3144                 :             : 
    3145                 :             :   /* Copy the extracted pieces into the proper (probable) hard regs.  */
    3146                 :       29700 :   for (i = 0; i < XVECLEN (dst, 0); i++)
    3147                 :             :     {
    3148                 :       19155 :       rtx d = XEXP (XVECEXP (dst, 0, i), 0);
    3149                 :       19155 :       if (d == NULL)
    3150                 :           0 :         continue;
    3151                 :       19155 :       emit_move_insn (d, tmps[i]);
    3152                 :             :     }
    3153                 :       10545 : }
    3154                 :             : 
    3155                 :             : /* Similar, but load SRC into new pseudos in a format that looks like
    3156                 :             :    PARALLEL.  This can later be fed to emit_group_move to get things
    3157                 :             :    in the right place.  */
    3158                 :             : 
    3159                 :             : rtx
    3160                 :      258752 : emit_group_load_into_temps (rtx parallel, rtx src, tree type, poly_int64 ssize)
    3161                 :             : {
    3162                 :      258752 :   rtvec vec;
    3163                 :      258752 :   int i;
    3164                 :             : 
    3165                 :      258752 :   vec = rtvec_alloc (XVECLEN (parallel, 0));
    3166                 :      258752 :   emit_group_load_1 (&RTVEC_ELT (vec, 0), parallel, src, type, ssize);
    3167                 :             : 
    3168                 :             :   /* Convert the vector to look just like the original PARALLEL, except
    3169                 :             :      with the computed values.  */
    3170                 :      767682 :   for (i = 0; i < XVECLEN (parallel, 0); i++)
    3171                 :             :     {
    3172                 :      508930 :       rtx e = XVECEXP (parallel, 0, i);
    3173                 :      508930 :       rtx d = XEXP (e, 0);
    3174                 :             : 
    3175                 :      508930 :       if (d)
    3176                 :             :         {
    3177                 :      508930 :           d = force_reg (GET_MODE (d), RTVEC_ELT (vec, i));
    3178                 :      508930 :           e = alloc_EXPR_LIST (REG_NOTE_KIND (e), d, XEXP (e, 1));
    3179                 :             :         }
    3180                 :      508930 :       RTVEC_ELT (vec, i) = e;
    3181                 :             :     }
    3182                 :             : 
    3183                 :      258752 :   return gen_rtx_PARALLEL (GET_MODE (parallel), vec);
    3184                 :             : }
    3185                 :             : 
    3186                 :             : /* Emit code to move a block SRC to block DST, where SRC and DST are
    3187                 :             :    non-consecutive groups of registers, each represented by a PARALLEL.  */
    3188                 :             : 
    3189                 :             : void
    3190                 :      261651 : emit_group_move (rtx dst, rtx src)
    3191                 :             : {
    3192                 :      261651 :   int i;
    3193                 :             : 
    3194                 :      261651 :   gcc_assert (GET_CODE (src) == PARALLEL
    3195                 :             :               && GET_CODE (dst) == PARALLEL
    3196                 :             :               && XVECLEN (src, 0) == XVECLEN (dst, 0));
    3197                 :             : 
    3198                 :             :   /* Skip first entry if NULL.  */
    3199                 :      774759 :   for (i = XEXP (XVECEXP (src, 0, 0), 0) ? 0 : 1; i < XVECLEN (src, 0); i++)
    3200                 :      513108 :     emit_move_insn (XEXP (XVECEXP (dst, 0, i), 0),
    3201                 :      513108 :                     XEXP (XVECEXP (src, 0, i), 0));
    3202                 :      261651 : }
    3203                 :             : 
    3204                 :             : /* Move a group of registers represented by a PARALLEL into pseudos.  */
    3205                 :             : 
    3206                 :             : rtx
    3207                 :        5415 : emit_group_move_into_temps (rtx src)
    3208                 :             : {
    3209                 :        5415 :   rtvec vec = rtvec_alloc (XVECLEN (src, 0));
    3210                 :        5415 :   int i;
    3211                 :             : 
    3212                 :       12762 :   for (i = 0; i < XVECLEN (src, 0); i++)
    3213                 :             :     {
    3214                 :        7347 :       rtx e = XVECEXP (src, 0, i);
    3215                 :        7347 :       rtx d = XEXP (e, 0);
    3216                 :             : 
    3217                 :        7347 :       if (d)
    3218                 :        7347 :         e = alloc_EXPR_LIST (REG_NOTE_KIND (e), copy_to_reg (d), XEXP (e, 1));
    3219                 :        7347 :       RTVEC_ELT (vec, i) = e;
    3220                 :             :     }
    3221                 :             : 
    3222                 :        5415 :   return gen_rtx_PARALLEL (GET_MODE (src), vec);
    3223                 :             : }
    3224                 :             : 
    3225                 :             : /* Emit code to move a block SRC to a block ORIG_DST of type TYPE,
    3226                 :             :    where SRC is non-consecutive registers represented by a PARALLEL.
    3227                 :             :    SSIZE represents the total size of block ORIG_DST, or -1 if not
    3228                 :             :    known.  */
    3229                 :             : 
    3230                 :             : void
    3231                 :       60292 : emit_group_store (rtx orig_dst, rtx src, tree type ATTRIBUTE_UNUSED,
    3232                 :             :                   poly_int64 ssize)
    3233                 :             : {
    3234                 :       60292 :   rtx *tmps, dst;
    3235                 :       60292 :   int start, finish, i;
    3236                 :       60292 :   machine_mode m = GET_MODE (orig_dst);
    3237                 :             : 
    3238                 :       60292 :   gcc_assert (GET_CODE (src) == PARALLEL);
    3239                 :             : 
    3240                 :       60292 :   if (!SCALAR_INT_MODE_P (m)
    3241                 :       12531 :       && !MEM_P (orig_dst) && GET_CODE (orig_dst) != CONCAT)
    3242                 :             :     {
    3243                 :           0 :       scalar_int_mode imode;
    3244                 :           0 :       if (int_mode_for_mode (GET_MODE (orig_dst)).exists (&imode))
    3245                 :             :         {
    3246                 :           0 :           dst = gen_reg_rtx (imode);
    3247                 :           0 :           emit_group_store (dst, src, type, ssize);
    3248                 :           0 :           dst = gen_lowpart (GET_MODE (orig_dst), dst);
    3249                 :             :         }
    3250                 :             :       else
    3251                 :             :         {
    3252                 :           0 :           dst = assign_stack_temp (GET_MODE (orig_dst), ssize);
    3253                 :           0 :           emit_group_store (dst, src, type, ssize);
    3254                 :             :         }
    3255                 :           0 :       emit_move_insn (orig_dst, dst);
    3256                 :           0 :       return;
    3257                 :             :     }
    3258                 :             : 
    3259                 :             :   /* Check for a NULL entry, used to indicate that the parameter goes
    3260                 :             :      both on the stack and in registers.  */
    3261                 :       60292 :   if (XEXP (XVECEXP (src, 0, 0), 0))
    3262                 :             :     start = 0;
    3263                 :             :   else
    3264                 :           0 :     start = 1;
    3265                 :       60292 :   finish = XVECLEN (src, 0);
    3266                 :             : 
    3267                 :       60292 :   tmps = XALLOCAVEC (rtx, finish);
    3268                 :             : 
    3269                 :             :   /* Copy the (probable) hard regs into pseudos.  */
    3270                 :      173673 :   for (i = start; i < finish; i++)
    3271                 :             :     {
    3272                 :      113381 :       rtx reg = XEXP (XVECEXP (src, 0, i), 0);
    3273                 :      113381 :       if (!REG_P (reg) || REGNO (reg) < FIRST_PSEUDO_REGISTER)
    3274                 :             :         {
    3275                 :      106034 :           tmps[i] = gen_reg_rtx (GET_MODE (reg));
    3276                 :      106034 :           emit_move_insn (tmps[i], reg);
    3277                 :             :         }
    3278                 :             :       else
    3279                 :        7347 :         tmps[i] = reg;
    3280                 :             :     }
    3281                 :             : 
    3282                 :             :   /* If we won't be storing directly into memory, protect the real destination
    3283                 :             :      from strange tricks we might play.  */
    3284                 :       60292 :   dst = orig_dst;
    3285                 :       60292 :   if (GET_CODE (dst) == PARALLEL)
    3286                 :             :     {
    3287                 :           0 :       rtx temp;
    3288                 :             : 
    3289                 :             :       /* We can get a PARALLEL dst if there is a conditional expression in
    3290                 :             :          a return statement.  In that case, the dst and src are the same,
    3291                 :             :          so no action is necessary.  */
    3292                 :           0 :       if (rtx_equal_p (dst, src))
    3293                 :             :         return;
    3294                 :             : 
    3295                 :             :       /* It is unclear if we can ever reach here, but we may as well handle
    3296                 :             :          it.  Allocate a temporary, and split this into a store/load to/from
    3297                 :             :          the temporary.  */
    3298                 :           0 :       temp = assign_stack_temp (GET_MODE (dst), ssize);
    3299                 :           0 :       emit_group_store (temp, src, type, ssize);
    3300                 :           0 :       emit_group_load (dst, temp, type, ssize);
    3301                 :           0 :       return;
    3302                 :             :     }
    3303                 :       60292 :   else if (!MEM_P (dst) && GET_CODE (dst) != CONCAT)
    3304                 :             :     {
    3305                 :       47147 :       machine_mode outer = GET_MODE (dst);
    3306                 :       47147 :       machine_mode inner;
    3307                 :       47147 :       poly_int64 bytepos;
    3308                 :       47147 :       bool done = false;
    3309                 :       47147 :       rtx temp;
    3310                 :             : 
    3311                 :       47147 :       if (!REG_P (dst) || REGNO (dst) < FIRST_PSEUDO_REGISTER)
    3312                 :           0 :         dst = gen_reg_rtx (outer);
    3313                 :             : 
    3314                 :             :       /* Make life a bit easier for combine: if the first element of the
    3315                 :             :          vector is the low part of the destination mode, use a paradoxical
    3316                 :             :          subreg to initialize the destination.  */
    3317                 :       47147 :       if (start < finish)
    3318                 :             :         {
    3319                 :       47147 :           inner = GET_MODE (tmps[start]);
    3320                 :       47147 :           bytepos = subreg_lowpart_offset (inner, outer);
    3321                 :       47147 :           if (known_eq (rtx_to_poly_int64 (XEXP (XVECEXP (src, 0, start), 1)),
    3322                 :             :                         bytepos))
    3323                 :             :             {
    3324                 :       47123 :               temp = force_subreg (outer, tmps[start], inner, 0);
    3325                 :       47123 :               if (temp)
    3326                 :             :                 {
    3327                 :       46472 :                   emit_move_insn (dst, temp);
    3328                 :       46472 :                   done = true;
    3329                 :       46472 :                   start++;
    3330                 :             :                 }
    3331                 :             :             }
    3332                 :             :         }
    3333                 :             : 
    3334                 :             :       /* If the first element wasn't the low part, try the last.  */
    3335                 :       46472 :       if (!done
    3336                 :         675 :           && start < finish - 1)
    3337                 :             :         {
    3338                 :         608 :           inner = GET_MODE (tmps[finish - 1]);
    3339                 :         608 :           bytepos = subreg_lowpart_offset (inner, outer);
    3340                 :         608 :           if (known_eq (rtx_to_poly_int64 (XEXP (XVECEXP (src, 0,
    3341                 :             :                                                           finish - 1), 1)),
    3342                 :             :                         bytepos))
    3343                 :             :             {
    3344                 :           0 :               temp = force_subreg (outer, tmps[finish - 1], inner, 0);
    3345                 :           0 :               if (temp)
    3346                 :             :                 {
    3347                 :           0 :                   emit_move_insn (dst, temp);
    3348                 :           0 :                   done = true;
    3349                 :           0 :                   finish--;
    3350                 :             :                 }
    3351                 :             :             }
    3352                 :             :         }
    3353                 :             : 
    3354                 :             :       /* Otherwise, simply initialize the result to zero.  */
    3355                 :       46472 :       if (!done)
    3356                 :         675 :         emit_move_insn (dst, CONST0_RTX (outer));
    3357                 :             :     }
    3358                 :             : 
    3359                 :             :   /* Process the pieces.  */
    3360                 :      124489 :   for (i = start; i < finish; i++)
    3361                 :             :     {
    3362                 :       66909 :       poly_int64 bytepos = rtx_to_poly_int64 (XEXP (XVECEXP (src, 0, i), 1));
    3363                 :       66909 :       machine_mode mode = GET_MODE (tmps[i]);
    3364                 :      133818 :       poly_int64 bytelen = GET_MODE_SIZE (mode);
    3365                 :       66909 :       poly_uint64 adj_bytelen;
    3366                 :       66909 :       rtx dest = dst;
    3367                 :             : 
    3368                 :             :       /* Handle trailing fragments that run over the size of the struct.
    3369                 :             :          It's the target's responsibility to make sure that the fragment
    3370                 :             :          cannot be strictly smaller in some cases and strictly larger
    3371                 :             :          in others.  */
    3372                 :       66909 :       gcc_checking_assert (ordered_p (bytepos + bytelen, ssize));
    3373                 :      133007 :       if (known_size_p (ssize) && maybe_gt (bytepos + bytelen, ssize))
    3374                 :         811 :         adj_bytelen = ssize - bytepos;
    3375                 :             :       else
    3376                 :       66909 :         adj_bytelen = bytelen;
    3377                 :             : 
    3378                 :             :       /* Deal with destination CONCATs by either storing into one of the parts
    3379                 :             :          or doing a copy after storing into a register or stack temporary.  */
    3380                 :       66909 :       if (GET_CODE (dst) == CONCAT)
    3381                 :             :         {
    3382                 :       24052 :           if (known_le (bytepos + adj_bytelen,
    3383                 :             :                         GET_MODE_SIZE (GET_MODE (XEXP (dst, 0)))))
    3384                 :             :             dest = XEXP (dst, 0);
    3385                 :             : 
    3386                 :       14738 :           else if (known_ge (bytepos, GET_MODE_SIZE (GET_MODE (XEXP (dst, 0)))))
    3387                 :             :             {
    3388                 :        9314 :               bytepos -= GET_MODE_SIZE (GET_MODE (XEXP (dst, 0)));
    3389                 :        4657 :               dest = XEXP (dst, 1);
    3390                 :             :             }
    3391                 :             : 
    3392                 :             :           else
    3393                 :             :             {
    3394                 :        2712 :               machine_mode dest_mode = GET_MODE (dest);
    3395                 :        2712 :               machine_mode tmp_mode = GET_MODE (tmps[i]);
    3396                 :        2712 :               scalar_int_mode dest_imode;
    3397                 :             : 
    3398                 :        2712 :               gcc_assert (known_eq (bytepos, 0) && XVECLEN (src, 0));
    3399                 :             : 
    3400                 :             :               /* If the source is a single scalar integer register, and the
    3401                 :             :                  destination has a complex mode for which a same-sized integer
    3402                 :             :                  mode exists, then we can take the left-justified part of the
    3403                 :             :                  source in the complex mode.  */
    3404                 :        2712 :               if (finish == start + 1
    3405                 :        2712 :                   && REG_P (tmps[i])
    3406                 :        2712 :                   && SCALAR_INT_MODE_P (tmp_mode)
    3407                 :        2712 :                   && COMPLEX_MODE_P (dest_mode)
    3408                 :        5424 :                   && int_mode_for_mode (dest_mode).exists (&dest_imode))
    3409                 :             :                 {
    3410                 :        2712 :                   const scalar_int_mode tmp_imode
    3411                 :        2712 :                     = as_a <scalar_int_mode> (tmp_mode);
    3412                 :             : 
    3413                 :        5424 :                   if (GET_MODE_BITSIZE (dest_imode)
    3414                 :        2712 :                       < GET_MODE_BITSIZE (tmp_imode))
    3415                 :             :                     {
    3416                 :          59 :                       dest = gen_reg_rtx (dest_imode);
    3417                 :          59 :                       if (BYTES_BIG_ENDIAN)
    3418                 :             :                         tmps[i] = expand_shift (RSHIFT_EXPR, tmp_mode, tmps[i],
    3419                 :             :                                                 GET_MODE_BITSIZE (tmp_imode)
    3420                 :             :                                                 - GET_MODE_BITSIZE (dest_imode),
    3421                 :             :                                                 NULL_RTX, 1);
    3422                 :          59 :                       emit_move_insn (dest, gen_lowpart (dest_imode, tmps[i]));
    3423                 :          59 :                       dst = gen_lowpart (dest_mode, dest);
    3424                 :             :                     }
    3425                 :             :                   else
    3426                 :        2653 :                     dst = gen_lowpart (dest_mode, tmps[i]);
    3427                 :             :                 }
    3428                 :             : 
    3429                 :             :               /* Otherwise spill the source onto the stack using the more
    3430                 :             :                  aligned of the two modes.  */
    3431                 :           0 :               else if (GET_MODE_ALIGNMENT (dest_mode)
    3432                 :           0 :                        >= GET_MODE_ALIGNMENT (tmp_mode))
    3433                 :             :                 {
    3434                 :           0 :                   dest = assign_stack_temp (dest_mode,
    3435                 :           0 :                                             GET_MODE_SIZE (dest_mode));
    3436                 :           0 :                   emit_move_insn (adjust_address (dest, tmp_mode, bytepos),
    3437                 :             :                                   tmps[i]);
    3438                 :           0 :                   dst = dest;
    3439                 :             :                 }
    3440                 :             : 
    3441                 :             :               else
    3442                 :             :                 {
    3443                 :           0 :                   dest = assign_stack_temp (tmp_mode,
    3444                 :           0 :                                             GET_MODE_SIZE (tmp_mode));
    3445                 :           0 :                   emit_move_insn (dest, tmps[i]);
    3446                 :           0 :                   dst = adjust_address (dest, dest_mode, bytepos);
    3447                 :             :                 }
    3448                 :             : 
    3449                 :             :               break;
    3450                 :             :             }
    3451                 :             :         }
    3452                 :             : 
    3453                 :             :       /* Handle trailing fragments that run over the size of the struct.  */
    3454                 :       64197 :       if (known_size_p (ssize) && maybe_gt (bytepos + bytelen, ssize))
    3455                 :             :         {
    3456                 :             :           /* store_bit_field always takes its value from the lsb.
    3457                 :             :              Move the fragment to the lsb if it's not already there.  */
    3458                 :         752 :           if (
    3459                 :             : #ifdef BLOCK_REG_PADDING
    3460                 :             :               BLOCK_REG_PADDING (GET_MODE (orig_dst), type, i == start)
    3461                 :             :               == (BYTES_BIG_ENDIAN ? PAD_UPWARD : PAD_DOWNWARD)
    3462                 :             : #else
    3463                 :             :               BYTES_BIG_ENDIAN
    3464                 :             : #endif
    3465                 :             :               )
    3466                 :             :             {
    3467                 :             :               poly_int64 shift = (bytelen - (ssize - bytepos)) * BITS_PER_UNIT;
    3468                 :             :               tmps[i] = expand_shift (RSHIFT_EXPR, mode, tmps[i],
    3469                 :             :                                       shift, tmps[i], 0);
    3470                 :             :             }
    3471                 :             : 
    3472                 :             :           /* Make sure not to write past the end of the struct.  */
    3473                 :        2256 :           store_bit_field (dest,
    3474                 :         752 :                            adj_bytelen * BITS_PER_UNIT, bytepos * BITS_PER_UNIT,
    3475                 :        1504 :                            bytepos * BITS_PER_UNIT, ssize * BITS_PER_UNIT - 1,
    3476                 :             :                            VOIDmode, tmps[i], false, false);
    3477                 :             :         }
    3478                 :             : 
    3479                 :             :       /* Optimize the access just a bit.  */
    3480                 :       63445 :       else if (MEM_P (dest)
    3481                 :        7205 :                && (!targetm.slow_unaligned_access (mode, MEM_ALIGN (dest))
    3482                 :           0 :                    || MEM_ALIGN (dest) >= GET_MODE_ALIGNMENT (mode))
    3483                 :       14410 :                && multiple_p (bytepos * BITS_PER_UNIT,
    3484                 :             :                               GET_MODE_ALIGNMENT (mode))
    3485                 :       70650 :                && known_eq (bytelen, GET_MODE_SIZE (mode)))
    3486                 :        7205 :         emit_move_insn (adjust_address (dest, mode, bytepos), tmps[i]);
    3487                 :             : 
    3488                 :             :       else
    3489                 :       56240 :         store_bit_field (dest, bytelen * BITS_PER_UNIT, bytepos * BITS_PER_UNIT,
    3490                 :       56240 :                          0, 0, mode, tmps[i], false, false);
    3491                 :             :     }
    3492                 :             : 
    3493                 :             :   /* Copy from the pseudo into the (probable) hard reg.  */
    3494                 :       60292 :   if (orig_dst != dst)
    3495                 :        2712 :     emit_move_insn (orig_dst, dst);
    3496                 :             : }
    3497                 :             : 
    3498                 :             : /* Return a form of X that does not use a PARALLEL.  TYPE is the type
    3499                 :             :    of the value stored in X.  */
    3500                 :             : 
    3501                 :             : rtx
    3502                 :      327354 : maybe_emit_group_store (rtx x, tree type)
    3503                 :             : {
    3504                 :      327354 :   machine_mode mode = TYPE_MODE (type);
    3505                 :      327354 :   gcc_checking_assert (GET_MODE (x) == VOIDmode || GET_MODE (x) == mode);
    3506                 :      327354 :   if (GET_CODE (x) == PARALLEL)
    3507                 :             :     {
    3508                 :           0 :       rtx result = gen_reg_rtx (mode);
    3509                 :           0 :       emit_group_store (result, x, type, int_size_in_bytes (type));
    3510                 :           0 :       return result;
    3511                 :             :     }
    3512                 :             :   return x;
    3513                 :             : }
    3514                 :             : 
    3515                 :             : /* Copy a BLKmode object of TYPE out of a register SRCREG into TARGET.
    3516                 :             : 
    3517                 :             :    This is used on targets that return BLKmode values in registers.  */
    3518                 :             : 
    3519                 :             : static void
    3520                 :         251 : copy_blkmode_from_reg (rtx target, rtx srcreg, tree type)
    3521                 :             : {
    3522                 :         251 :   unsigned HOST_WIDE_INT bytes = int_size_in_bytes (type);
    3523                 :         251 :   rtx src = NULL, dst = NULL;
    3524                 :         251 :   unsigned HOST_WIDE_INT bitsize = MIN (TYPE_ALIGN (type), BITS_PER_WORD);
    3525                 :         251 :   unsigned HOST_WIDE_INT bitpos, xbitpos, padding_correction = 0;
    3526                 :             :   /* No current ABI uses variable-sized modes to pass a BLKmnode type.  */
    3527                 :         251 :   fixed_size_mode mode = as_a <fixed_size_mode> (GET_MODE (srcreg));
    3528                 :         251 :   fixed_size_mode tmode = as_a <fixed_size_mode> (GET_MODE (target));
    3529                 :         251 :   fixed_size_mode copy_mode;
    3530                 :             : 
    3531                 :             :   /* BLKmode registers created in the back-end shouldn't have survived.  */
    3532                 :         251 :   gcc_assert (mode != BLKmode);
    3533                 :             : 
    3534                 :             :   /* If the structure doesn't take up a whole number of words, see whether
    3535                 :             :      SRCREG is padded on the left or on the right.  If it's on the left,
    3536                 :             :      set PADDING_CORRECTION to the number of bits to skip.
    3537                 :             : 
    3538                 :             :      In most ABIs, the structure will be returned at the least end of
    3539                 :             :      the register, which translates to right padding on little-endian
    3540                 :             :      targets and left padding on big-endian targets.  The opposite
    3541                 :             :      holds if the structure is returned at the most significant
    3542                 :             :      end of the register.  */
    3543                 :         251 :   if (bytes % UNITS_PER_WORD != 0
    3544                 :         251 :       && (targetm.calls.return_in_msb (type)
    3545                 :         217 :           ? !BYTES_BIG_ENDIAN
    3546                 :             :           : BYTES_BIG_ENDIAN))
    3547                 :           0 :     padding_correction
    3548                 :           0 :       = (BITS_PER_WORD - ((bytes % UNITS_PER_WORD) * BITS_PER_UNIT));
    3549                 :             : 
    3550                 :             :   /* We can use a single move if we have an exact mode for the size.  */
    3551                 :         251 :   else if (MEM_P (target)
    3552                 :         251 :            && (!targetm.slow_unaligned_access (mode, MEM_ALIGN (target))
    3553                 :           0 :                || MEM_ALIGN (target) >= GET_MODE_ALIGNMENT (mode))
    3554                 :         502 :            && bytes == GET_MODE_SIZE (mode))
    3555                 :             :   {
    3556                 :          41 :     emit_move_insn (adjust_address (target, mode, 0), srcreg);
    3557                 :          41 :     return;
    3558                 :             :   }
    3559                 :             : 
    3560                 :             :   /* And if we additionally have the same mode for a register.  */
    3561                 :         210 :   else if (REG_P (target)
    3562                 :           0 :            && GET_MODE (target) == mode
    3563                 :         210 :            && bytes == GET_MODE_SIZE (mode))
    3564                 :             :   {
    3565                 :           0 :     emit_move_insn (target, srcreg);
    3566                 :           0 :     return;
    3567                 :             :   }
    3568                 :             : 
    3569                 :             :   /* This code assumes srcreg is at least a full word.  If it isn't, copy it
    3570                 :             :      into a new pseudo which is a full word.  */
    3571                 :         420 :   if (GET_MODE_SIZE (mode) < UNITS_PER_WORD)
    3572                 :             :     {
    3573                 :          77 :       srcreg = convert_to_mode (word_mode, srcreg, TYPE_UNSIGNED (type));
    3574                 :          77 :       mode = word_mode;
    3575                 :             :     }
    3576                 :             : 
    3577                 :             :   /* Copy the structure BITSIZE bits at a time.  If the target lives in
    3578                 :             :      memory, take care of not reading/writing past its end by selecting
    3579                 :             :      a copy mode suited to BITSIZE.  This should always be possible given
    3580                 :             :      how it is computed.
    3581                 :             : 
    3582                 :             :      If the target lives in register, make sure not to select a copy mode
    3583                 :             :      larger than the mode of the register.
    3584                 :             : 
    3585                 :             :      We could probably emit more efficient code for machines which do not use
    3586                 :             :      strict alignment, but it doesn't seem worth the effort at the current
    3587                 :             :      time.  */
    3588                 :             : 
    3589                 :         210 :   copy_mode = word_mode;
    3590                 :         210 :   if (MEM_P (target))
    3591                 :             :     {
    3592                 :         210 :       opt_scalar_int_mode mem_mode = int_mode_for_size (bitsize, 1);
    3593                 :         210 :       if (mem_mode.exists ())
    3594                 :         210 :         copy_mode = mem_mode.require ();
    3595                 :             :     }
    3596                 :           0 :   else if (REG_P (target) && GET_MODE_BITSIZE (tmode) < BITS_PER_WORD)
    3597                 :             :     copy_mode = tmode;
    3598                 :             : 
    3599                 :         210 :   for (bitpos = 0, xbitpos = padding_correction;
    3600                 :        1029 :        bitpos < bytes * BITS_PER_UNIT;
    3601                 :         819 :        bitpos += bitsize, xbitpos += bitsize)
    3602                 :             :     {
    3603                 :             :       /* We need a new source operand each time xbitpos is on a
    3604                 :             :          word boundary and when xbitpos == padding_correction
    3605                 :             :          (the first time through).  */
    3606                 :         819 :       if (xbitpos % BITS_PER_WORD == 0 || xbitpos == padding_correction)
    3607                 :         210 :         src = operand_subword_force (srcreg, xbitpos / BITS_PER_WORD, mode);
    3608                 :             : 
    3609                 :             :       /* We need a new destination operand each time bitpos is on
    3610                 :             :          a word boundary.  */
    3611                 :         819 :       if (REG_P (target) && GET_MODE_BITSIZE (tmode) < BITS_PER_WORD)
    3612                 :             :         dst = target;
    3613                 :         819 :       else if (bitpos % BITS_PER_WORD == 0)
    3614                 :         210 :         dst = operand_subword (target, bitpos / BITS_PER_WORD, 1, tmode);
    3615                 :             : 
    3616                 :             :       /* Use xbitpos for the source extraction (right justified) and
    3617                 :             :          bitpos for the destination store (left justified).  */
    3618                 :         819 :       store_bit_field (dst, bitsize, bitpos % BITS_PER_WORD, 0, 0, copy_mode,
    3619                 :         819 :                        extract_bit_field (src, bitsize,
    3620                 :         819 :                                           xbitpos % BITS_PER_WORD, 1,
    3621                 :             :                                           NULL_RTX, copy_mode, copy_mode,
    3622                 :             :                                           false, NULL),
    3623                 :             :                        false, false);
    3624                 :             :     }
    3625                 :             : }
    3626                 :             : 
    3627                 :             : /* Copy BLKmode value SRC into a register of mode MODE_IN.  Return the
    3628                 :             :    register if it contains any data, otherwise return null.
    3629                 :             : 
    3630                 :             :    This is used on targets that return BLKmode values in registers.  */
    3631                 :             : 
    3632                 :             : rtx
    3633                 :        3225 : copy_blkmode_to_reg (machine_mode mode_in, tree src)
    3634                 :             : {
    3635                 :        3225 :   int i, n_regs;
    3636                 :        3225 :   unsigned HOST_WIDE_INT bitpos, xbitpos, padding_correction = 0, bytes;
    3637                 :        3225 :   unsigned int bitsize;
    3638                 :        3225 :   rtx *dst_words, dst, x, src_word = NULL_RTX, dst_word = NULL_RTX;
    3639                 :             :   /* No current ABI uses variable-sized modes to pass a BLKmnode type.  */
    3640                 :        3225 :   fixed_size_mode mode = as_a <fixed_size_mode> (mode_in);
    3641                 :        3225 :   fixed_size_mode dst_mode;
    3642                 :        3225 :   scalar_int_mode min_mode;
    3643                 :             : 
    3644                 :        3225 :   gcc_assert (TYPE_MODE (TREE_TYPE (src)) == BLKmode);
    3645                 :             : 
    3646                 :        3225 :   x = expand_normal (src);
    3647                 :             : 
    3648                 :        3225 :   bytes = arg_int_size_in_bytes (TREE_TYPE (src));
    3649                 :        3225 :   if (bytes == 0)
    3650                 :             :     return NULL_RTX;
    3651                 :             : 
    3652                 :             :   /* If the structure doesn't take up a whole number of words, see
    3653                 :             :      whether the register value should be padded on the left or on
    3654                 :             :      the right.  Set PADDING_CORRECTION to the number of padding
    3655                 :             :      bits needed on the left side.
    3656                 :             : 
    3657                 :             :      In most ABIs, the structure will be returned at the least end of
    3658                 :             :      the register, which translates to right padding on little-endian
    3659                 :             :      targets and left padding on big-endian targets.  The opposite
    3660                 :             :      holds if the structure is returned at the most significant
    3661                 :             :      end of the register.  */
    3662                 :        1220 :   if (bytes % UNITS_PER_WORD != 0
    3663                 :        1220 :       && (targetm.calls.return_in_msb (TREE_TYPE (src))
    3664                 :        1185 :           ? !BYTES_BIG_ENDIAN
    3665                 :             :           : BYTES_BIG_ENDIAN))
    3666                 :           0 :     padding_correction = (BITS_PER_WORD - ((bytes % UNITS_PER_WORD)
    3667                 :           0 :                                            * BITS_PER_UNIT));
    3668                 :             : 
    3669                 :        1220 :   n_regs = (bytes + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
    3670                 :        1220 :   dst_words = XALLOCAVEC (rtx, n_regs);
    3671                 :        1220 :   bitsize = MIN (TYPE_ALIGN (TREE_TYPE (src)), BITS_PER_WORD);
    3672                 :        1220 :   min_mode = smallest_int_mode_for_size (bitsize).require ();
    3673                 :             : 
    3674                 :             :   /* Copy the structure BITSIZE bits at a time.  */
    3675                 :        1220 :   for (bitpos = 0, xbitpos = padding_correction;
    3676                 :        3963 :        bitpos < bytes * BITS_PER_UNIT;
    3677                 :        2743 :        bitpos += bitsize, xbitpos += bitsize)
    3678                 :             :     {
    3679                 :             :       /* We need a new destination pseudo each time xbitpos is
    3680                 :             :          on a word boundary and when xbitpos == padding_correction
    3681                 :             :          (the first time through).  */
    3682                 :        2743 :       if (xbitpos % BITS_PER_WORD == 0
    3683                 :        1520 :           || xbitpos == padding_correction)
    3684                 :             :         {
    3685                 :             :           /* Generate an appropriate register.  */
    3686                 :        1223 :           dst_word = gen_reg_rtx (word_mode);
    3687                 :        1223 :           dst_words[xbitpos / BITS_PER_WORD] = dst_word;
    3688                 :             : 
    3689                 :             :           /* Clear the destination before we move anything into it.  */
    3690                 :        1223 :           emit_move_insn (dst_word, CONST0_RTX (word_mode));
    3691                 :             :         }
    3692                 :             : 
    3693                 :             :       /* Find the largest integer mode that can be used to copy all or as
    3694                 :             :          many bits as possible of the structure if the target supports larger
    3695                 :             :          copies.  There are too many corner cases here w.r.t to alignments on
    3696                 :             :          the read/writes.  So if there is any padding just use single byte
    3697                 :             :          operations.  */
    3698                 :        2743 :       opt_scalar_int_mode mode_iter;
    3699                 :        2743 :       if (padding_correction == 0 && !STRICT_ALIGNMENT)
    3700                 :             :         {
    3701                 :        7467 :           FOR_EACH_MODE_FROM (mode_iter, min_mode)
    3702                 :             :             {
    3703                 :        7467 :               unsigned int msize = GET_MODE_BITSIZE (mode_iter.require ());
    3704                 :        7467 :               if (msize <= ((bytes * BITS_PER_UNIT) - bitpos)
    3705                 :        4727 :                   && msize <= BITS_PER_WORD)
    3706                 :        4724 :                 bitsize = msize;
    3707                 :             :               else
    3708                 :             :                 break;
    3709                 :             :             }
    3710                 :             :         }
    3711                 :             : 
    3712                 :             :       /* We need a new source operand each time bitpos is on a word
    3713                 :             :          boundary.  */
    3714                 :        2743 :       if (bitpos % BITS_PER_WORD == 0)
    3715                 :        1223 :         src_word = operand_subword_force (x, bitpos / BITS_PER_WORD, BLKmode);
    3716                 :             : 
    3717                 :             :       /* Use bitpos for the source extraction (left justified) and
    3718                 :             :          xbitpos for the destination store (right justified).  */
    3719                 :        2743 :       store_bit_field (dst_word, bitsize, xbitpos % BITS_PER_WORD,
    3720                 :        2743 :                        0, 0, word_mode,
    3721                 :        2743 :                        extract_bit_field (src_word, bitsize,
    3722                 :        2743 :                                           bitpos % BITS_PER_WORD, 1,
    3723                 :             :                                           NULL_RTX, word_mode, word_mode,
    3724                 :             :                                           false, NULL),
    3725                 :             :                        false, false);
    3726                 :             :     }
    3727                 :             : 
    3728                 :        1220 :   if (mode == BLKmode)
    3729                 :             :     {
    3730                 :             :       /* Find the smallest integer mode large enough to hold the
    3731                 :             :          entire structure.  */
    3732                 :           0 :       opt_scalar_int_mode mode_iter;
    3733                 :           0 :       FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
    3734                 :           0 :         if (GET_MODE_SIZE (mode_iter.require ()) >= bytes)
    3735                 :             :           break;
    3736                 :             : 
    3737                 :             :       /* A suitable mode should have been found.  */
    3738                 :           0 :       mode = mode_iter.require ();
    3739                 :             :     }
    3740                 :             : 
    3741                 :        3660 :   if (GET_MODE_SIZE (mode) < GET_MODE_SIZE (word_mode))
    3742                 :             :     dst_mode = word_mode;
    3743                 :             :   else
    3744                 :         494 :     dst_mode = mode;
    3745                 :        1220 :   dst = gen_reg_rtx (dst_mode);
    3746                 :             : 
    3747                 :        3663 :   for (i = 0; i < n_regs; i++)
    3748                 :        1223 :     emit_move_insn (operand_subword (dst, i, 0, dst_mode), dst_words[i]);
    3749                 :             : 
    3750                 :        1220 :   if (mode != dst_mode)
    3751                 :         726 :     dst = gen_lowpart (mode, dst);
    3752                 :             : 
    3753                 :             :   return dst;
    3754                 :             : }
    3755                 :             : 
    3756                 :             : /* Add a USE expression for REG to the (possibly empty) list pointed
    3757                 :             :    to by CALL_FUSAGE.  REG must denote a hard register.  */
    3758                 :             : 
    3759                 :             : void
    3760                 :    10798537 : use_reg_mode (rtx *call_fusage, rtx reg, machine_mode mode)
    3761                 :             : {
    3762                 :    10798537 :   gcc_assert (REG_P (reg));
    3763                 :             : 
    3764                 :    10798537 :   if (!HARD_REGISTER_P (reg))
    3765                 :             :     return;
    3766                 :             : 
    3767                 :    10798537 :   *call_fusage
    3768                 :    10798537 :     = gen_rtx_EXPR_LIST (mode, gen_rtx_USE (VOIDmode, reg), *call_fusage);
    3769                 :             : }
    3770                 :             : 
    3771                 :             : /* Add a CLOBBER expression for REG to the (possibly empty) list pointed
    3772                 :             :    to by CALL_FUSAGE.  REG must denote a hard register.  */
    3773                 :             : 
    3774                 :             : void
    3775                 :      797463 : clobber_reg_mode (rtx *call_fusage, rtx reg, machine_mode mode)
    3776                 :             : {
    3777                 :      797463 :   gcc_assert (REG_P (reg) && REGNO (reg) < FIRST_PSEUDO_REGISTER);
    3778                 :             : 
    3779                 :      797463 :   *call_fusage
    3780                 :      797463 :     = gen_rtx_EXPR_LIST (mode, gen_rtx_CLOBBER (VOIDmode, reg), *call_fusage);
    3781                 :      797463 : }
    3782                 :             : 
    3783                 :             : /* Add USE expressions to *CALL_FUSAGE for each of NREGS consecutive regs,
    3784                 :             :    starting at REGNO.  All of these registers must be hard registers.  */
    3785                 :             : 
    3786                 :             : void
    3787                 :        1574 : use_regs (rtx *call_fusage, int regno, int nregs)
    3788                 :             : {
    3789                 :        1574 :   int i;
    3790                 :             : 
    3791                 :        1574 :   gcc_assert (regno + nregs <= FIRST_PSEUDO_REGISTER);
    3792                 :             : 
    3793                 :        3148 :   for (i = 0; i < nregs; i++)
    3794                 :        1574 :     use_reg (call_fusage, regno_reg_rtx[regno + i]);
    3795                 :        1574 : }
    3796                 :             : 
    3797                 :             : /* Add USE expressions to *CALL_FUSAGE for each REG contained in the
    3798                 :             :    PARALLEL REGS.  This is for calls that pass values in multiple
    3799                 :             :    non-contiguous locations.  The Irix 6 ABI has examples of this.  */
    3800                 :             : 
    3801                 :             : void
    3802                 :      265770 : use_group_regs (rtx *call_fusage, rtx regs)
    3803                 :             : {
    3804                 :      265770 :   int i;
    3805                 :             : 
    3806                 :      788736 :   for (i = 0; i < XVECLEN (regs, 0); i++)
    3807                 :             :     {
    3808                 :      522966 :       rtx reg = XEXP (XVECEXP (regs, 0, i), 0);
    3809                 :             : 
    3810                 :             :       /* A NULL entry means the parameter goes both on the stack and in
    3811                 :             :          registers.  This can also be a MEM for targets that pass values
    3812                 :             :          partially on the stack and partially in registers.  */
    3813                 :      522966 :       if (reg != 0 && REG_P (reg))
    3814                 :      522966 :         use_reg (call_fusage, reg);
    3815                 :             :     }
    3816                 :      265770 : }
    3817                 :             : 
    3818                 :             : /* Return the defining gimple statement for SSA_NAME NAME if it is an
    3819                 :             :    assigment and the code of the expresion on the RHS is CODE.  Return
    3820                 :             :    NULL otherwise.  */
    3821                 :             : 
    3822                 :             : static gimple *
    3823                 :    10651851 : get_def_for_expr (tree name, enum tree_code code)
    3824                 :             : {
    3825                 :    10651851 :   gimple *def_stmt;
    3826                 :             : 
    3827                 :    10651851 :   if (TREE_CODE (name) != SSA_NAME)
    3828                 :             :     return NULL;
    3829                 :             : 
    3830                 :     8464238 :   def_stmt = get_gimple_for_ssa_name (name);
    3831                 :     8464238 :   if (!def_stmt
    3832                 :     1833727 :       || !is_gimple_assign (def_stmt)
    3833                 :    10296694 :       || gimple_assign_rhs_code (def_stmt) != code)
    3834                 :             :     return NULL;
    3835                 :             : 
    3836                 :             :   return def_stmt;
    3837                 :             : }
    3838                 :             : 
    3839                 :             : /* Return the defining gimple statement for SSA_NAME NAME if it is an
    3840                 :             :    assigment and the class of the expresion on the RHS is CLASS.  Return
    3841                 :             :    NULL otherwise.  */
    3842                 :             : 
    3843                 :             : static gimple *
    3844                 :       15801 : get_def_for_expr_class (tree name, enum tree_code_class tclass)
    3845                 :             : {
    3846                 :       15801 :   gimple *def_stmt;
    3847                 :             : 
    3848                 :       15801 :   if (TREE_CODE (name) != SSA_NAME)
    3849                 :             :     return NULL;
    3850                 :             : 
    3851                 :       15801 :   def_stmt = get_gimple_for_ssa_name (name);
    3852                 :       15801 :   if (!def_stmt
    3853                 :       13682 :       || !is_gimple_assign (def_stmt)
    3854                 :       29483 :       || TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)) != tclass)
    3855                 :             :     return NULL;
    3856                 :             : 
    3857                 :             :   return def_stmt;
    3858                 :             : }
    3859                 :             : 
    3860                 :             : /* Write zeros through the storage of OBJECT.  If OBJECT has BLKmode, SIZE is
    3861                 :             :    its length in bytes.  */
    3862                 :             : 
    3863                 :             : rtx
    3864                 :      124088 : clear_storage_hints (rtx object, rtx size, enum block_op_methods method,
    3865                 :             :                      unsigned int expected_align, HOST_WIDE_INT expected_size,
    3866                 :             :                      unsigned HOST_WIDE_INT min_size,
    3867                 :             :                      unsigned HOST_WIDE_INT max_size,
    3868                 :             :                      unsigned HOST_WIDE_INT probable_max_size,
    3869                 :             :                      unsigned ctz_size)
    3870                 :             : {
    3871                 :      124088 :   machine_mode mode = GET_MODE (object);
    3872                 :      124088 :   unsigned int align;
    3873                 :             : 
    3874                 :      124088 :   gcc_assert (method == BLOCK_OP_NORMAL || method == BLOCK_OP_TAILCALL);
    3875                 :             : 
    3876                 :             :   /* If OBJECT is not BLKmode and SIZE is the same size as its mode,
    3877                 :             :      just move a zero.  Otherwise, do this a piece at a time.  */
    3878                 :      124088 :   poly_int64 size_val;
    3879                 :      124088 :   if (mode != BLKmode
    3880                 :       53989 :       && poly_int_rtx_p (size, &size_val)
    3881                 :      178077 :       && known_eq (size_val, GET_MODE_SIZE (mode)))
    3882                 :             :     {
    3883                 :       53989 :       rtx zero = CONST0_RTX (mode);
    3884                 :       53989 :       if (zero != NULL)
    3885                 :             :         {
    3886                 :       53989 :           emit_move_insn (object, zero);
    3887                 :       53989 :           return NULL;
    3888                 :             :         }
    3889                 :             : 
    3890                 :           0 :       if (COMPLEX_MODE_P (mode))
    3891                 :             :         {
    3892                 :           0 :           zero = CONST0_RTX (GET_MODE_INNER (mode));
    3893                 :           0 :           if (zero != NULL)
    3894                 :             :             {
    3895                 :           0 :               write_complex_part (object, zero, 0, true);
    3896                 :           0 :               write_complex_part (object, zero, 1, false);
    3897                 :           0 :               return NULL;
    3898                 :             :             }
    3899                 :             :         }
    3900                 :             :     }
    3901                 :             : 
    3902                 :       70099 :   if (size == const0_rtx)
    3903                 :             :     return NULL;
    3904                 :             : 
    3905                 :       70099 :   align = MEM_ALIGN (object);
    3906                 :             : 
    3907                 :       70099 :   if (CONST_INT_P (size)
    3908                 :      133732 :       && targetm.use_by_pieces_infrastructure_p (INTVAL (size), align,
    3909                 :             :                                                  CLEAR_BY_PIECES,
    3910                 :       63633 :                                                  optimize_insn_for_speed_p ()))
    3911                 :       44792 :     clear_by_pieces (object, INTVAL (size), align);
    3912                 :       25307 :   else if (set_storage_via_setmem (object, size, const0_rtx, align,
    3913                 :             :                                    expected_align, expected_size,
    3914                 :             :                                    min_size, max_size, probable_max_size))
    3915                 :             :     ;
    3916                 :        5305 :   else if (try_store_by_multiple_pieces (object, size, ctz_size,
    3917                 :             :                                          min_size, max_size,
    3918                 :             :                                          NULL_RTX, 0, align))
    3919                 :             :     ;
    3920                 :        5250 :   else if (ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (object)))
    3921                 :        5250 :     return set_storage_via_libcall (object, size, const0_rtx,
    3922                 :        5250 :                                     method == BLOCK_OP_TAILCALL);
    3923                 :             :   else
    3924                 :           0 :     gcc_unreachable ();
    3925                 :             : 
    3926                 :             :   return NULL;
    3927                 :             : }
    3928                 :             : 
    3929                 :             : rtx
    3930                 :      103700 : clear_storage (rtx object, rtx size, enum block_op_methods method)
    3931                 :             : {
    3932                 :      103700 :   unsigned HOST_WIDE_INT max, min = 0;
    3933                 :      103700 :   if (GET_CODE (size) == CONST_INT)
    3934                 :      103700 :     min = max = UINTVAL (size);
    3935                 :             :   else
    3936                 :           0 :     max = GET_MODE_MASK (GET_MODE (size));
    3937                 :      103700 :   return clear_storage_hints (object, size, method, 0, -1, min, max, max, 0);
    3938                 :             : }
    3939                 :             : 
    3940                 :             : 
    3941                 :             : /* A subroutine of clear_storage.  Expand a call to memset.
    3942                 :             :    Return the return value of memset, 0 otherwise.  */
    3943                 :             : 
    3944                 :             : rtx
    3945                 :        5254 : set_storage_via_libcall (rtx object, rtx size, rtx val, bool tailcall)
    3946                 :             : {
    3947                 :        5254 :   tree call_expr, fn, object_tree, size_tree, val_tree;
    3948                 :        5254 :   machine_mode size_mode;
    3949                 :             : 
    3950                 :        5254 :   object = copy_addr_to_reg (XEXP (object, 0));
    3951                 :        5254 :   object_tree = make_tree (ptr_type_node, object);
    3952                 :             : 
    3953                 :        5254 :   if (!CONST_INT_P (val))
    3954                 :           3 :     val = convert_to_mode (TYPE_MODE (integer_type_node), val, 1);
    3955                 :        5254 :   val_tree = make_tree (integer_type_node, val);
    3956                 :             : 
    3957                 :        5254 :   size_mode = TYPE_MODE (sizetype);
    3958                 :        5254 :   size = convert_to_mode (size_mode, size, 1);
    3959                 :        5254 :   size = copy_to_mode_reg (size_mode, size);
    3960                 :        5254 :   size_tree = make_tree (sizetype, size);
    3961                 :             : 
    3962                 :             :   /* It is incorrect to use the libcall calling conventions for calls to
    3963                 :             :      memset because it can be provided by the user.  */
    3964                 :        5254 :   fn = builtin_decl_implicit (BUILT_IN_MEMSET);
    3965                 :        5254 :   call_expr = build_call_expr (fn, 3, object_tree, val_tree, size_tree);
    3966                 :        5254 :   CALL_EXPR_TAILCALL (call_expr) = tailcall;
    3967                 :             : 
    3968                 :        5254 :   return expand_call (call_expr, NULL_RTX, false);
    3969                 :             : }
    3970                 :             : 
    3971                 :             : /* Expand a setmem pattern; return true if successful.  */
    3972                 :             : 
    3973                 :             : bool
    3974                 :       33098 : set_storage_via_setmem (rtx object, rtx size, rtx val, unsigned int align,
    3975                 :             :                         unsigned int expected_align, HOST_WIDE_INT expected_size,
    3976                 :             :                         unsigned HOST_WIDE_INT min_size,
    3977                 :             :                         unsigned HOST_WIDE_INT max_size,
    3978                 :             :                         unsigned HOST_WIDE_INT probable_max_size)
    3979                 :             : {
    3980                 :             :   /* Try the most limited insn first, because there's no point
    3981                 :             :      including more than one in the machine description unless
    3982                 :             :      the more limited one has some advantage.  */
    3983                 :             : 
    3984                 :       33098 :   if (expected_align < align)
    3985                 :             :     expected_align = align;
    3986                 :       33098 :   if (expected_size != -1)
    3987                 :             :     {
    3988                 :           5 :       if ((unsigned HOST_WIDE_INT)expected_size > max_size)
    3989                 :           0 :         expected_size = max_size;
    3990                 :           5 :       if ((unsigned HOST_WIDE_INT)expected_size < min_size)
    3991                 :           0 :         expected_size = min_size;
    3992                 :             :     }
    3993                 :             : 
    3994                 :       33098 :   opt_scalar_int_mode mode_iter;
    3995                 :      156031 :   FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
    3996                 :             :     {
    3997                 :      144821 :       scalar_int_mode mode = mode_iter.require ();
    3998                 :      144821 :       enum insn_code code = direct_optab_handler (setmem_optab, mode);
    3999                 :             : 
    4000                 :      144821 :       if (code != CODE_FOR_nothing
    4001                 :             :           /* We don't need MODE to be narrower than BITS_PER_HOST_WIDE_INT
    4002                 :             :              here because if SIZE is less than the mode mask, as it is
    4003                 :             :              returned by the macro, it will definitely be less than the
    4004                 :             :              actual mode mask.  Since SIZE is within the Pmode address
    4005                 :             :              space, we limit MODE to Pmode.  */
    4006                 :      144821 :           && ((CONST_INT_P (size)
    4007                 :       20109 :                && ((unsigned HOST_WIDE_INT) INTVAL (size)
    4008                 :       20109 :                    <= (GET_MODE_MASK (mode) >> 1)))
    4009                 :       23965 :               || max_size <= (GET_MODE_MASK (mode) >> 1)
    4010                 :       31008 :               || GET_MODE_BITSIZE (mode) >= GET_MODE_BITSIZE (Pmode)))
    4011                 :             :         {
    4012                 :       34216 :           class expand_operand ops[9];
    4013                 :       34216 :           unsigned int nops;
    4014                 :             : 
    4015                 :       34216 :           nops = insn_data[(int) code].n_generator_args;
    4016                 :       34216 :           gcc_assert (nops == 4 || nops == 6 || nops == 8 || nops == 9);
    4017                 :             : 
    4018                 :       34216 :           create_fixed_operand (&ops[0], object);
    4019                 :             :           /* The check above guarantees that this size conversion is valid.  */
    4020                 :       34216 :           create_convert_operand_to (&ops[1], size, mode, true);
    4021                 :       34216 :           create_convert_operand_from (&ops[2], val, byte_mode, true);
    4022                 :       34216 :           create_integer_operand (&ops[3], align / BITS_PER_UNIT);
    4023                 :       34216 :           if (nops >= 6)
    4024                 :             :             {
    4025                 :       34216 :               create_integer_operand (&ops[4], expected_align / BITS_PER_UNIT);
    4026                 :       34216 :               create_integer_operand (&ops[5], expected_size);
    4027                 :             :             }
    4028                 :       34216 :           if (nops >= 8)
    4029                 :             :             {
    4030                 :       34216 :               create_integer_operand (&ops[6], min_size);
    4031                 :             :               /* If we cannot represent the maximal size,
    4032                 :             :                  make parameter NULL.  */
    4033                 :       34216 :               if ((HOST_WIDE_INT) max_size != -1)
    4034                 :       29599 :                 create_integer_operand (&ops[7], max_size);
    4035                 :             :               else
    4036                 :        4617 :                 create_fixed_operand (&ops[7], NULL);
    4037                 :             :             }
    4038                 :       34216 :           if (nops == 9)
    4039                 :             :             {
    4040                 :             :               /* If we cannot represent the maximal size,
    4041                 :             :                  make parameter NULL.  */
    4042                 :       34216 :               if ((HOST_WIDE_INT) probable_max_size != -1)
    4043                 :       29758 :                 create_integer_operand (&ops[8], probable_max_size);
    4044                 :             :               else
    4045                 :        4458 :                 create_fixed_operand (&ops[8], NULL);
    4046                 :             :             }
    4047                 :       34216 :           if (maybe_expand_insn (code, nops, ops))
    4048                 :       21888 :             return true;
    4049                 :             :         }
    4050                 :             :     }
    4051                 :             : 
    4052                 :             :   return false;
    4053                 :             : }
    4054                 :             : 
    4055                 :             : 
    4056                 :             : /* Write to one of the components of the complex value CPLX.  Write VAL to
    4057                 :             :    the real part if IMAG_P is false, and the imaginary part if its true.
    4058                 :             :    If UNDEFINED_P then the value in CPLX is currently undefined.  */
    4059                 :             : 
    4060                 :             : void
    4061                 :      484453 : write_complex_part (rtx cplx, rtx val, bool imag_p, bool undefined_p)
    4062                 :             : {
    4063                 :      484453 :   machine_mode cmode;
    4064                 :      484453 :   scalar_mode imode;
    4065                 :      484453 :   unsigned ibitsize;
    4066                 :             : 
    4067                 :      484453 :   if (GET_CODE (cplx) == CONCAT)
    4068                 :             :     {
    4069                 :      429007 :       emit_move_insn (XEXP (cplx, imag_p), val);
    4070                 :      429007 :       return;
    4071                 :             :     }
    4072                 :             : 
    4073                 :       55446 :   cmode = GET_MODE (cplx);
    4074                 :       55446 :   imode = GET_MODE_INNER (cmode);
    4075                 :       55446 :   ibitsize = GET_MODE_BITSIZE (imode);
    4076                 :             : 
    4077                 :             :   /* For MEMs simplify_gen_subreg may generate an invalid new address
    4078                 :             :      because, e.g., the original address is considered mode-dependent
    4079                 :             :      by the target, which restricts simplify_subreg from invoking
    4080                 :             :      adjust_address_nv.  Instead of preparing fallback support for an
    4081                 :             :      invalid address, we call adjust_address_nv directly.  */
    4082                 :       55446 :   if (MEM_P (cplx))
    4083                 :             :     {
    4084                 :       66372 :       emit_move_insn (adjust_address_nv (cplx, imode,
    4085                 :             :                                          imag_p ? GET_MODE_SIZE (imode) : 0),
    4086                 :             :                       val);
    4087                 :       44248 :       return;
    4088                 :             :     }
    4089                 :             : 
    4090                 :             :   /* If the sub-object is at least word sized, then we know that subregging
    4091                 :             :      will work.  This special case is important, since store_bit_field
    4092                 :             :      wants to operate on integer modes, and there's rarely an OImode to
    4093                 :             :      correspond to TCmode.  */
    4094                 :       11198 :   if (ibitsize >= BITS_PER_WORD
    4095                 :             :       /* For hard regs we have exact predicates.  Assume we can split
    4096                 :             :          the original object if it spans an even number of hard regs.
    4097                 :             :          This special case is important for SCmode on 64-bit platforms
    4098                 :             :          where the natural size of floating-point regs is 32-bit.  */
    4099                 :       11198 :       || (REG_P (cplx)
    4100                 :        7304 :           && REGNO (cplx) < FIRST_PSEUDO_REGISTER
    4101                 :        7120 :           && REG_NREGS (cplx) % 2 == 0))
    4102                 :             :     {
    4103                 :        3910 :       rtx part = simplify_gen_subreg (imode, cplx, cmode,
    4104                 :        5865 :                                       imag_p ? GET_MODE_SIZE (imode) : 0);
    4105                 :        3910 :       if (part)
    4106                 :             :         {
    4107                 :        3910 :           emit_move_insn (part, val);
    4108                 :        3910 :           return;
    4109                 :             :         }
    4110                 :             :       else
    4111                 :             :         /* simplify_gen_subreg may fail for sub-word MEMs.  */
    4112                 :           0 :         gcc_assert (MEM_P (cplx) && ibitsize < BITS_PER_WORD);
    4113                 :             :     }
    4114                 :             : 
    4115                 :       10932 :   store_bit_field (cplx, ibitsize, imag_p ? ibitsize : 0, 0, 0, imode, val,
    4116                 :             :                    false, undefined_p);
    4117                 :             : }
    4118                 :             : 
    4119                 :             : /* Extract one of the components of the complex value CPLX.  Extract the
    4120                 :             :    real part if IMAG_P is false, and the imaginary part if it's true.  */
    4121                 :             : 
    4122                 :             : rtx
    4123                 :      491002 : read_complex_part (rtx cplx, bool imag_p)
    4124                 :             : {
    4125                 :      491002 :   machine_mode cmode;
    4126                 :      491002 :   scalar_mode imode;
    4127                 :      491002 :   unsigned ibitsize;
    4128                 :             : 
    4129                 :      491002 :   if (GET_CODE (cplx) == CONCAT)
    4130                 :      315108 :     return XEXP (cplx, imag_p);
    4131                 :             : 
    4132                 :      175894 :   cmode = GET_MODE (cplx);
    4133                 :      175894 :   imode = GET_MODE_INNER (cmode);
    4134                 :      175894 :   ibitsize = GET_MODE_BITSIZE (imode);
    4135                 :             : 
    4136                 :             :   /* Special case reads from complex constants that got spilled to memory.  */
    4137                 :      175894 :   if (MEM_P (cplx) && GET_CODE (XEXP (cplx, 0)) == SYMBOL_REF)
    4138                 :             :     {
    4139                 :       37829 :       tree decl = SYMBOL_REF_DECL (XEXP (cplx, 0));
    4140                 :       37829 :       if (decl && TREE_CODE (decl) == COMPLEX_CST)
    4141                 :             :         {
    4142                 :           0 :           tree part = imag_p ? TREE_IMAGPART (decl) : TREE_REALPART (decl);
    4143                 :           0 :           if (CONSTANT_CLASS_P (part))
    4144                 :           0 :             return expand_expr (part, NULL_RTX, imode, EXPAND_NORMAL);
    4145                 :             :         }
    4146                 :             :     }
    4147                 :             : 
    4148                 :             :   /* For MEMs simplify_gen_subreg may generate an invalid new address
    4149                 :             :      because, e.g., the original address is considered mode-dependent
    4150                 :             :      by the target, which restricts simplify_subreg from invoking
    4151                 :             :      adjust_address_nv.  Instead of preparing fallback support for an
    4152                 :             :      invalid address, we call adjust_address_nv directly.  */
    4153                 :      175894 :   if (MEM_P (cplx))
    4154                 :      235974 :     return adjust_address_nv (cplx, imode,
    4155                 :             :                               imag_p ? GET_MODE_SIZE (imode) : 0);
    4156                 :             : 
    4157                 :             :   /* If the sub-object is at least word sized, then we know that subregging
    4158                 :             :      will work.  This special case is important, since extract_bit_field
    4159                 :             :      wants to operate on integer modes, and there's rarely an OImode to
    4160                 :             :      correspond to TCmode.  */
    4161                 :       18427 :   if (ibitsize >= BITS_PER_WORD
    4162                 :             :       /* For hard regs we have exact predicates.  Assume we can split
    4163                 :             :          the original object if it spans an even number of hard regs.
    4164                 :             :          This special case is important for SCmode on 64-bit platforms
    4165                 :             :          where the natural size of floating-point regs is 32-bit.  */
    4166                 :       18427 :       || (REG_P (cplx)
    4167                 :         338 :           && REGNO (cplx) < FIRST_PSEUDO_REGISTER
    4168                 :         292 :           && REG_NREGS (cplx) % 2 == 0))
    4169                 :             :     {
    4170                 :        9173 :       rtx ret = simplify_gen_subreg (imode, cplx, cmode,
    4171                 :       13759 :                                      imag_p ? GET_MODE_SIZE (imode) : 0);
    4172                 :        9173 :       if (ret)
    4173                 :             :         return ret;
    4174                 :             :       else
    4175                 :             :         /* simplify_gen_subreg may fail for sub-word MEMs.  */
    4176                 :           0 :         gcc_assert (MEM_P (cplx) && ibitsize < BITS_PER_WORD);
    4177                 :             :     }
    4178                 :             : 
    4179                 :       13881 :   return extract_bit_field (cplx, ibitsize, imag_p ? ibitsize : 0,
    4180                 :             :                             true, NULL_RTX, imode, imode, false, NULL);
    4181                 :             : }
    4182                 :             : 
    4183                 :             : /* A subroutine of emit_move_insn_1.  Yet another lowpart generator.
    4184                 :             :    NEW_MODE and OLD_MODE are the same size.  Return NULL if X cannot be
    4185                 :             :    represented in NEW_MODE.  If FORCE is true, this will never happen, as
    4186                 :             :    we'll force-create a SUBREG if needed.  */
    4187                 :             : 
    4188                 :             : static rtx
    4189                 :      242242 : emit_move_change_mode (machine_mode new_mode,
    4190                 :             :                        machine_mode old_mode, rtx x, bool force)
    4191                 :             : {
    4192                 :      242242 :   rtx ret;
    4193                 :             : 
    4194                 :      242242 :   if (push_operand (x, GET_MODE (x)))
    4195                 :             :     {
    4196                 :        1318 :       ret = gen_rtx_MEM (new_mode, XEXP (x, 0));
    4197                 :        1318 :       MEM_COPY_ATTRIBUTES (ret, x);
    4198                 :             :     }
    4199                 :      240924 :   else if (MEM_P (x))
    4200                 :             :     {
    4201                 :             :       /* We don't have to worry about changing the address since the
    4202                 :             :          size in bytes is supposed to be the same.  */
    4203                 :       52889 :       if (reload_in_progress)
    4204                 :             :         {
    4205                 :             :           /* Copy the MEM to change the mode and move any
    4206                 :             :              substitutions from the old MEM to the new one.  */
    4207                 :           0 :           ret = adjust_address_nv (x, new_mode, 0);
    4208                 :           0 :           copy_replacements (x, ret);
    4209                 :             :         }
    4210                 :             :       else
    4211                 :       52889 :         ret = adjust_address (x, new_mode, 0);
    4212                 :             :     }
    4213                 :             :   else
    4214                 :             :     {
    4215                 :             :       /* Note that we do want simplify_subreg's behavior of validating
    4216                 :             :          that the new mode is ok for a hard register.  If we were to use
    4217                 :             :          simplify_gen_subreg, we would create the subreg, but would
    4218                 :             :          probably run into the target not being able to implement it.  */
    4219                 :             :       /* Except, of course, when FORCE is true, when this is exactly what
    4220                 :             :          we want.  Which is needed for CCmodes on some targets.  */
    4221                 :      188035 :       if (force)
    4222                 :      188035 :         ret = simplify_gen_subreg (new_mode, x, old_mode, 0);
    4223                 :             :       else
    4224                 :           0 :         ret = simplify_subreg (new_mode, x, old_mode, 0);
    4225                 :             :     }
    4226                 :             : 
    4227                 :      242242 :   return ret;
    4228                 :             : }
    4229                 :             : 
    4230                 :             : /* A subroutine of emit_move_insn_1.  Generate a move from Y into X using
    4231                 :             :    an integer mode of the same size as MODE.  Returns the instruction
    4232                 :             :    emitted, or NULL if such a move could not be generated.  */
    4233                 :             : 
    4234                 :             : static rtx_insn *
    4235                 :      121121 : emit_move_via_integer (machine_mode mode, rtx x, rtx y, bool force)
    4236                 :             : {
    4237                 :      121121 :   scalar_int_mode imode;
    4238                 :      121121 :   enum insn_code code;
    4239                 :             : 
    4240                 :             :   /* There must exist a mode of the exact size we require.  */
    4241                 :      121121 :   if (!int_mode_for_mode (mode).exists (&imode))
    4242                 :           0 :     return NULL;
    4243                 :             : 
    4244                 :             :   /* The target must support moves in this mode.  */
    4245                 :      121121 :   code = optab_handler (mov_optab, imode);
    4246                 :      121121 :   if (code == CODE_FOR_nothing)
    4247                 :             :     return NULL;
    4248                 :             : 
    4249                 :      121121 :   x = emit_move_change_mode (imode, mode, x, force);
    4250                 :      121121 :   if (x == NULL_RTX)
    4251                 :             :     return NULL;
    4252                 :      121121 :   y = emit_move_change_mode (imode, mode, y, force);
    4253                 :      121121 :   if (y == NULL_RTX)
    4254                 :             :     return NULL;
    4255                 :      121121 :   return emit_insn (GEN_FCN (code) (x, y));
    4256                 :             : }
    4257                 :             : 
    4258                 :             : /* A subroutine of emit_move_insn_1.  X is a push_operand in MODE.
    4259                 :             :    Return an equivalent MEM that does not use an auto-increment.  */
    4260                 :             : 
    4261                 :             : rtx
    4262                 :        3593 : emit_move_resolve_push (machine_mode mode, rtx x)
    4263                 :             : {
    4264                 :        3593 :   enum rtx_code code = GET_CODE (XEXP (x, 0));
    4265                 :        3593 :   rtx temp;
    4266                 :             : 
    4267                 :        7186 :   poly_int64 adjust = GET_MODE_SIZE (mode);
    4268                 :             : #ifdef PUSH_ROUNDING
    4269                 :        3593 :   adjust = PUSH_ROUNDING (adjust);
    4270                 :             : #endif
    4271                 :        3593 :   if (code == PRE_DEC || code == POST_DEC)
    4272                 :        3197 :     adjust = -adjust;
    4273                 :         396 :   else if (code == PRE_MODIFY || code == POST_MODIFY)
    4274                 :             :     {
    4275                 :         396 :       rtx expr = XEXP (XEXP (x, 0), 1);
    4276                 :             : 
    4277                 :         396 :       gcc_assert (GET_CODE (expr) == PLUS || GET_CODE (expr) == MINUS);
    4278                 :         396 :       poly_int64 val = rtx_to_poly_int64 (XEXP (expr, 1));
    4279                 :         396 :       if (GET_CODE (expr) == MINUS)
    4280                 :           0 :         val = -val;
    4281                 :         396 :       gcc_assert (known_eq (adjust, val) || known_eq (adjust, -val));
    4282                 :             :       adjust = val;
    4283                 :             :     }
    4284                 :             : 
    4285                 :             :   /* Do not use anti_adjust_stack, since we don't want to update
    4286                 :             :      stack_pointer_delta.  */
    4287                 :        3593 :   temp = expand_simple_binop (Pmode, PLUS, stack_pointer_rtx,
    4288                 :        3593 :                               gen_int_mode (adjust, Pmode), stack_pointer_rtx,
    4289                 :             :                               0, OPTAB_LIB_WIDEN);
    4290                 :        3593 :   if (temp != stack_pointer_rtx)
    4291                 :           0 :     emit_move_insn (stack_pointer_rtx, temp);
    4292                 :             : 
    4293                 :        3593 :   switch (code)
    4294                 :             :     {
    4295                 :        3593 :     case PRE_INC:
    4296                 :        3593 :     case PRE_DEC:
    4297                 :        3593 :     case PRE_MODIFY:
    4298                 :        3593 :       temp = stack_pointer_rtx;
    4299                 :        3593 :       break;
    4300                 :             :     case POST_INC:
    4301                 :             :     case POST_DEC:
    4302                 :             :     case POST_MODIFY:
    4303                 :           0 :       temp = plus_constant (Pmode, stack_pointer_rtx, -adjust);
    4304                 :           0 :       break;
    4305                 :           0 :     default:
    4306                 :           0 :       gcc_unreachable ();
    4307                 :             :     }
    4308                 :             : 
    4309                 :        3593 :   return replace_equiv_address (x, temp);
    4310                 :             : }
    4311                 :             : 
    4312                 :             : /* A subroutine of emit_move_complex.  Generate a move from Y into X.
    4313                 :             :    X is known to satisfy push_operand, and MODE is known to be complex.
    4314                 :             :    Returns the last instruction emitted.  */
    4315                 :             : 
    4316                 :             : rtx_insn *
    4317                 :        5238 : emit_move_complex_push (machine_mode mode, rtx x, rtx y)
    4318                 :             : {
    4319                 :        5238 :   scalar_mode submode = GET_MODE_INNER (mode);
    4320                 :        5238 :   bool imag_first;
    4321                 :             : 
    4322                 :             : #ifdef PUSH_ROUNDING
    4323                 :       10476 :   poly_int64 submodesize = GET_MODE_SIZE (submode);
    4324                 :             : 
    4325                 :             :   /* In case we output to the stack, but the size is smaller than the
    4326                 :             :      machine can push exactly, we need to use move instructions.  */
    4327                 :        5238 :   if (maybe_ne (PUSH_ROUNDING (submodesize), submodesize))
    4328                 :             :     {
    4329                 :         718 :       x = emit_move_resolve_push (mode, x);
    4330                 :         718 :       return emit_move_insn (x, y);
    4331                 :             :     }
    4332                 :             : #endif
    4333                 :             : 
    4334                 :             :   /* Note that the real part always precedes the imag part in memory
    4335                 :             :      regardless of machine's endianness.  */
    4336                 :        4520 :   switch (GET_CODE (XEXP (x, 0)))
    4337                 :             :     {
    4338                 :             :     case PRE_DEC:
    4339                 :             :     case POST_DEC:
    4340                 :             :       imag_first = true;
    4341                 :             :       break;
    4342                 :           0 :     case PRE_INC:
    4343                 :           0 :     case POST_INC:
    4344                 :           0 :       imag_first = false;
    4345                 :           0 :       break;
    4346                 :           0 :     default:
    4347                 :           0 :       gcc_unreachable ();
    4348                 :             :     }
    4349                 :             : 
    4350                 :        4520 :   emit_move_insn (gen_rtx_MEM (submode, XEXP (x, 0)),
    4351                 :             :                   read_complex_part (y, imag_first));
    4352                 :        4520 :   return emit_move_insn (gen_rtx_MEM (submode, XEXP (x, 0)),
    4353                 :        9040 :                          read_complex_part (y, !imag_first));
    4354                 :             : }
    4355                 :             : 
    4356                 :             : /* A subroutine of emit_move_complex.  Perform the move from Y to X
    4357                 :             :    via two moves of the parts.  Returns the last instruction emitted.  */
    4358                 :             : 
    4359                 :             : rtx_insn *
    4360                 :       76437 : emit_move_complex_parts (rtx x, rtx y)
    4361                 :             : {
    4362                 :             :   /* Show the output dies here.  This is necessary for SUBREGs
    4363                 :             :      of pseudos since we cannot track their lifetimes correctly;
    4364                 :             :      hard regs shouldn't appear here except as return values.  */
    4365                 :       76437 :   if (!reload_completed && !reload_in_progress
    4366                 :      152874 :       && REG_P (x) && !reg_overlap_mentioned_p (x, y))
    4367                 :        5592 :     emit_clobber (x);
    4368                 :             : 
    4369                 :       76437 :   write_complex_part (x, read_complex_part (y, false), false, true);
    4370                 :       76437 :   write_complex_part (x, read_complex_part (y, true), true, false);
    4371                 :             : 
    4372                 :       76437 :   return get_last_insn ();
    4373                 :             : }
    4374                 :             : 
    4375                 :             : /* A subroutine of emit_move_insn_1.  Generate a move from Y into X.
    4376                 :             :    MODE is known to be complex.  Returns the last instruction emitted.  */
    4377                 :             : 
    4378                 :             : static rtx_insn *
    4379                 :       80672 : emit_move_complex (machine_mode mode, rtx x, rtx y)
    4380                 :             : {
    4381                 :       80672 :   bool try_int;
    4382                 :             : 
    4383                 :             :   /* Need to take special care for pushes, to maintain proper ordering
    4384                 :             :      of the data, and possibly extra padding.  */
    4385                 :       80672 :   if (push_operand (x, mode))
    4386                 :        4630 :     return emit_move_complex_push (mode, x, y);
    4387                 :             : 
    4388                 :             :   /* See if we can coerce the target into moving both values at once, except
    4389                 :             :      for floating point where we favor moving as parts if this is easy.  */
    4390                 :       76042 :   if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
    4391                 :       67842 :       && optab_handler (mov_optab, GET_MODE_INNER (mode)) != CODE_FOR_nothing
    4392                 :       67842 :       && !(REG_P (x)
    4393                 :        1687 :            && HARD_REGISTER_P (x)
    4394                 :         300 :            && REG_NREGS (x) == 1)
    4395                 :      143884 :       && !(REG_P (y)
    4396                 :        2778 :            && HARD_REGISTER_P (y)
    4397                 :        1389 :            && REG_NREGS (y) == 1))
    4398                 :             :     try_int = false;
    4399                 :             :   /* Not possible if the values are inherently not adjacent.  */
    4400                 :        8200 :   else if (GET_CODE (x) == CONCAT || GET_CODE (y) == CONCAT)
    4401                 :             :     try_int = false;
    4402                 :             :   /* Is possible if both are registers (or subregs of registers).  */
    4403                 :         754 :   else if (register_operand (x, mode) && register_operand (y, mode))
    4404                 :             :     try_int = true;
    4405                 :             :   /* If one of the operands is a memory, and alignment constraints
    4406                 :             :      are friendly enough, we may be able to do combined memory operations.
    4407                 :             :      We do not attempt this if Y is a constant because that combination is
    4408                 :             :      usually better with the by-parts thing below.  */
    4409                 :         633 :   else if ((MEM_P (x) ? !CONSTANT_P (y) : MEM_P (y))
    4410                 :             :            && (!STRICT_ALIGNMENT
    4411                 :             :                || get_mode_alignment (mode) == BIGGEST_ALIGNMENT))
    4412                 :             :     try_int = true;
    4413                 :             :   else
    4414                 :             :     try_int = false;
    4415                 :             : 
    4416                 :             :   if (try_int)
    4417                 :             :     {
    4418                 :         754 :       rtx_insn *ret;
    4419                 :             : 
    4420                 :             :       /* For memory to memory moves, optimal behavior can be had with the
    4421                 :             :          existing block move logic.  But use normal expansion if optimizing
    4422                 :             :          for size.  */
    4423                 :         754 :       if (MEM_P (x) && MEM_P (y))
    4424                 :             :         {
    4425                 :         724 :           emit_block_move (x, y, gen_int_mode (GET_MODE_SIZE (mode), Pmode),
    4426                 :         359 :                            (optimize_insn_for_speed_p()
    4427                 :             :                             ? BLOCK_OP_NO_LIBCALL : BLOCK_OP_NORMAL));
    4428                 :         359 :           return get_last_insn ();
    4429                 :             :         }
    4430                 :             : 
    4431                 :         395 :       ret = emit_move_via_integer (mode, x, y, true);
    4432                 :         395 :       if (ret)
    4433                 :             :         return ret;
    4434                 :             :     }
    4435                 :             : 
    4436                 :       75288 :   return emit_move_complex_parts (x, y);
    4437                 :             : }
    4438                 :             : 
    4439                 :             : /* A subroutine of emit_move_insn_1.  Generate a move from Y into X.
    4440                 :             :    MODE is known to be MODE_CC.  Returns the last instruction emitted.  */
    4441                 :             : 
    4442                 :             : static rtx_insn *
    4443                 :           0 : emit_move_ccmode (machine_mode mode, rtx x, rtx y)
    4444                 :             : {
    4445                 :           0 :   rtx_insn *ret;
    4446                 :             : 
    4447                 :             :   /* Assume all MODE_CC modes are equivalent; if we have movcc, use it.  */
    4448                 :           0 :   if (mode != CCmode)
    4449                 :             :     {
    4450                 :           0 :       enum insn_code code = optab_handler (mov_optab, CCmode);
    4451                 :           0 :       if (code != CODE_FOR_nothing)
    4452                 :             :         {
    4453                 :           0 :           x = emit_move_change_mode (CCmode, mode, x, true);
    4454                 :           0 :           y = emit_move_change_mode (CCmode, mode, y, true);
    4455                 :           0 :           return emit_insn (GEN_FCN (code) (x, y));
    4456                 :             :         }
    4457                 :             :     }
    4458                 :             : 
    4459                 :             :   /* Otherwise, find the MODE_INT mode of the same width.  */
    4460                 :           0 :   ret = emit_move_via_integer (mode, x, y, false);
    4461                 :           0 :   gcc_assert (ret != NULL);
    4462                 :             :   return ret;
    4463                 :             : }
    4464                 :             : 
    4465                 :             : /* Return true if word I of OP lies entirely in the
    4466                 :             :    undefined bits of a paradoxical subreg.  */
    4467                 :             : 
    4468                 :             : static bool
    4469                 :           0 : undefined_operand_subword_p (const_rtx op, int i)
    4470                 :             : {
    4471                 :           0 :   if (GET_CODE (op) != SUBREG)
    4472                 :             :     return false;
    4473                 :           0 :   machine_mode innermostmode = GET_MODE (SUBREG_REG (op));
    4474                 :           0 :   poly_int64 offset = i * UNITS_PER_WORD + subreg_memory_offset (op);
    4475                 :           0 :   return (known_ge (offset, GET_MODE_SIZE (innermostmode))
    4476                 :           0 :           || known_le (offset, -UNITS_PER_WORD));
    4477                 :             : }
    4478                 :             : 
    4479                 :             : /* A subroutine of emit_move_insn_1.  Generate a move from Y into X.
    4480                 :             :    MODE is any multi-word or full-word mode that lacks a move_insn
    4481                 :             :    pattern.  Note that you will get better code if you define such
    4482                 :             :    patterns, even if they must turn into multiple assembler instructions.  */
    4483                 :             : 
    4484                 :             : static rtx_insn *
    4485                 :           0 : emit_move_multi_word (machine_mode mode, rtx x, rtx y)
    4486                 :             : {
    4487                 :           0 :   rtx_insn *last_insn = 0;
    4488                 :           0 :   rtx_insn *seq;
    4489                 :           0 :   rtx inner;
    4490                 :           0 :   bool need_clobber;
    4491                 :           0 :   int i, mode_size;
    4492                 :             : 
    4493                 :             :   /* This function can only handle cases where the number of words is
    4494                 :             :      known at compile time.  */
    4495                 :           0 :   mode_size = GET_MODE_SIZE (mode).to_constant ();
    4496                 :           0 :   gcc_assert (mode_size >= UNITS_PER_WORD);
    4497                 :             : 
    4498                 :             :   /* If X is a push on the stack, do the push now and replace
    4499                 :             :      X with a reference to the stack pointer.  */
    4500                 :           0 :   if (push_operand (x, mode))
    4501                 :           0 :     x = emit_move_resolve_push (mode, x);
    4502                 :             : 
    4503                 :             :   /* If we are in reload, see if either operand is a MEM whose address
    4504                 :             :      is scheduled for replacement.  */
    4505                 :           0 :   if (reload_in_progress && MEM_P (x)
    4506                 :           0 :       && (inner = find_replacement (&XEXP (x, 0))) != XEXP (x, 0))
    4507                 :           0 :     x = replace_equiv_address_nv (x, inner);
    4508                 :           0 :   if (reload_in_progress && MEM_P (y)
    4509                 :           0 :       && (inner = find_replacement (&XEXP (y, 0))) != XEXP (y, 0))
    4510                 :           0 :     y = replace_equiv_address_nv (y, inner);
    4511                 :             : 
    4512                 :           0 :   start_sequence ();
    4513                 :             : 
    4514                 :           0 :   need_clobber = false;
    4515                 :           0 :   for (i = 0; i < CEIL (mode_size, UNITS_PER_WORD); i++)
    4516                 :             :     {
    4517                 :             :       /* Do not generate code for a move if it would go entirely
    4518                 :             :          to the non-existing bits of a paradoxical subreg.  */
    4519                 :           0 :       if (undefined_operand_subword_p (x, i))
    4520                 :           0 :         continue;
    4521                 :             : 
    4522                 :           0 :       rtx xpart = operand_subword (x, i, 1, mode);
    4523                 :           0 :       rtx ypart;
    4524                 :             : 
    4525                 :             :       /* Do not generate code for a move if it would come entirely
    4526                 :             :          from the undefined bits of a paradoxical subreg.  */
    4527                 :           0 :       if (undefined_operand_subword_p (y, i))
    4528                 :           0 :         continue;
    4529                 :             : 
    4530                 :           0 :       ypart = operand_subword (y, i, 1, mode);
    4531                 :             : 
    4532                 :             :       /* If we can't get a part of Y, put Y into memory if it is a
    4533                 :             :          constant.  Otherwise, force it into a register.  Then we must
    4534                 :             :          be able to get a part of Y.  */
    4535                 :           0 :       if (ypart == 0 && CONSTANT_P (y))
    4536                 :             :         {
    4537                 :           0 :           y = use_anchored_address (force_const_mem (mode, y));
    4538                 :           0 :           ypart = operand_subword (y, i, 1, mode);
    4539                 :             :         }
    4540                 :           0 :       else if (ypart == 0)
    4541                 :           0 :         ypart = operand_subword_force (y, i, mode);
    4542                 :             : 
    4543                 :           0 :       gcc_assert (xpart && ypart);
    4544                 :             : 
    4545                 :           0 :       need_clobber |= (GET_CODE (xpart) == SUBREG);
    4546                 :             : 
    4547                 :           0 :       last_insn = emit_move_insn (xpart, ypart);
    4548                 :             :     }
    4549                 :             : 
    4550                 :           0 :   seq = get_insns ();
    4551                 :           0 :   end_sequence ();
    4552                 :             : 
    4553                 :             :   /* Show the output dies here.  This is necessary for SUBREGs
    4554                 :             :      of pseudos since we cannot track their lifetimes correctly;
    4555                 :             :      hard regs shouldn't appear here except as return values.
    4556                 :             :      We never want to emit such a clobber after reload.  */
    4557                 :           0 :   if (x != y
    4558                 :           0 :       && ! (reload_in_progress || reload_completed)
    4559                 :           0 :       && need_clobber != 0)
    4560                 :           0 :     emit_clobber (x);
    4561                 :             : 
    4562                 :           0 :   emit_insn (seq);
    4563                 :             : 
    4564                 :           0 :   return last_insn;
    4565                 :             : }
    4566                 :             : 
    4567                 :             : /* Low level part of emit_move_insn.
    4568                 :             :    Called just like emit_move_insn, but assumes X and Y
    4569                 :             :    are basically valid.  */
    4570                 :             : 
    4571                 :             : rtx_insn *
    4572                 :    74196361 : emit_move_insn_1 (rtx x, rtx y)
    4573                 :             : {
    4574                 :    74196361 :   machine_mode mode = GET_MODE (x);
    4575                 :    74196361 :   enum insn_code code;
    4576                 :             : 
    4577                 :    74196361 :   gcc_assert ((unsigned int) mode < (unsigned int) MAX_MACHINE_MODE);
    4578                 :             : 
    4579                 :    74196361 :   code = optab_handler (mov_optab, mode);
    4580                 :    74196361 :   if (code != CODE_FOR_nothing)
    4581                 :    73994963 :     return emit_insn (GEN_FCN (code) (x, y));
    4582                 :             : 
    4583                 :             :   /* Expand complex moves by moving real part and imag part.  */
    4584                 :      201398 :   if (COMPLEX_MODE_P (mode))
    4585                 :       80672 :     return emit_move_complex (mode, x, y);
    4586                 :             : 
    4587                 :             :   if (GET_MODE_CLASS (mode) == MODE_DECIMAL_FLOAT
    4588                 :             :       || ALL_FIXED_POINT_MODE_P (mode))
    4589                 :             :     {
    4590                 :      120726 :       rtx_insn *result = emit_move_via_integer (mode, x, y, true);
    4591                 :             : 
    4592                 :             :       /* If we can't find an integer mode, use multi words.  */
    4593                 :      120726 :       if (result)
    4594                 :             :         return result;
    4595                 :             :       else
    4596                 :           0 :         return emit_move_multi_word (mode, x, y);
    4597                 :             :     }
    4598                 :             : 
    4599                 :             :   if (GET_MODE_CLASS (mode) == MODE_CC)
    4600                 :           0 :     return emit_move_ccmode (mode, x, y);
    4601                 :             : 
    4602                 :             :   /* Try using a move pattern for the corresponding integer mode.  This is
    4603                 :             :      only safe when simplify_subreg can convert MODE constants into integer
    4604                 :             :      constants.  At present, it can only do this reliably if the value
    4605                 :             :      fits within a HOST_WIDE_INT.  */
    4606                 :           0 :   if (!CONSTANT_P (y)
    4607                 :           0 :       || known_le (GET_MODE_BITSIZE (mode), HOST_BITS_PER_WIDE_INT))
    4608                 :             :     {
    4609                 :           0 :       rtx_insn *ret = emit_move_via_integer (mode, x, y, lra_in_progress);
    4610                 :             : 
    4611                 :           0 :       if (ret)
    4612                 :             :         {
    4613                 :           0 :           if (! lra_in_progress || recog (PATTERN (ret), ret, 0) >= 0)
    4614                 :           0 :             return ret;
    4615                 :             :         }
    4616                 :             :     }
    4617                 :             : 
    4618                 :           0 :   return emit_move_multi_word (mode, x, y);
    4619                 :             : }
    4620                 :             : 
    4621                 :             : /* Generate code to copy Y into X.
    4622                 :             :    Both Y and X must have the same mode, except that
    4623                 :             :    Y can be a constant with VOIDmode.
    4624                 :             :    This mode cannot be BLKmode; use emit_block_move for that.
    4625                 :             : 
    4626                 :             :    Return the last instruction emitted.  */
    4627                 :             : 
    4628                 :             : rtx_insn *
    4629                 :    66916881 : emit_move_insn (rtx x, rtx y)
    4630                 :             : {
    4631                 :    66916881 :   machine_mode mode = GET_MODE (x);
    4632                 :    66916881 :   rtx y_cst = NULL_RTX;
    4633                 :    66916881 :   rtx_insn *last_insn;
    4634                 :    66916881 :   rtx set;
    4635                 :             : 
    4636                 :    66916881 :   gcc_assert (mode != BLKmode
    4637                 :             :               && (GET_MODE (y) == mode || GET_MODE (y) == VOIDmode));
    4638                 :             : 
    4639                 :             :   /* If we have a copy that looks like one of the following patterns:
    4640                 :             :        (set (subreg:M1 (reg:M2 ...)) (subreg:M1 (reg:M2 ...)))
    4641                 :             :        (set (subreg:M1 (reg:M2 ...)) (mem:M1 ADDR))
    4642                 :             :        (set (mem:M1 ADDR) (subreg:M1 (reg:M2 ...)))
    4643                 :             :        (set (subreg:M1 (reg:M2 ...)) (constant C))
    4644                 :             :      where mode M1 is equal in size to M2, try to detect whether the
    4645                 :             :      mode change involves an implicit round trip through memory.
    4646                 :             :      If so, see if we can avoid that by removing the subregs and
    4647                 :             :      doing the move in mode M2 instead.  */
    4648                 :             : 
    4649                 :    66916881 :   rtx x_inner = NULL_RTX;
    4650                 :    66916881 :   rtx y_inner = NULL_RTX;
    4651                 :             : 
    4652                 :    69665352 :   auto candidate_subreg_p = [&](rtx subreg) {
    4653                 :     2748471 :     return (REG_P (SUBREG_REG (subreg))
    4654                 :     8243700 :             && known_eq (GET_MODE_SIZE (GET_MODE (SUBREG_REG (subreg))),
    4655                 :             :                          GET_MODE_SIZE (GET_MODE (subreg)))
    4656                 :     3048549 :             && optab_handler (mov_optab, GET_MODE (SUBREG_REG (subreg)))
    4657                 :     2748471 :                != CODE_FOR_nothing);
    4658                 :             :   };
    4659                 :             : 
    4660                 :    66922758 :   auto candidate_mem_p = [&](machine_mode innermode, rtx mem) {
    4661                 :        5877 :     return (!targetm.can_change_mode_class (innermode, GET_MODE (mem), ALL_REGS)
    4662                 :        5877 :             && !push_operand (mem, GET_MODE (mem))
    4663                 :             :             /* Not a candiate if innermode requires too much alignment.  */
    4664                 :       11694 :             && (MEM_ALIGN (mem) >= GET_MODE_ALIGNMENT (innermode)
    4665                 :         246 :                 || targetm.slow_unaligned_access (GET_MODE (mem),
    4666                 :         123 :                                                   MEM_ALIGN (mem))
    4667                 :         246 :                 || !targetm.slow_unaligned_access (innermode,
    4668                 :         123 :                                                    MEM_ALIGN (mem))));
    4669                 :             :   };
    4670                 :             : 
    4671                 :    66916881 :   if (SUBREG_P (x) && candidate_subreg_p (x))
    4672                 :        9397 :     x_inner = SUBREG_REG (x);
    4673                 :             : 
    4674                 :    66916881 :   if (SUBREG_P (y) && candidate_subreg_p (y))
    4675                 :      289508 :     y_inner = SUBREG_REG (y);
    4676                 :             : 
    4677                 :    66916881 :   if (x_inner != NULL_RTX
    4678                 :    66916881 :       && y_inner != NULL_RTX
    4679                 :        1086 :       && GET_MODE (x_inner) == GET_MODE (y_inner)
    4680                 :    66917562 :       && !targetm.can_change_mode_class (GET_MODE (x_inner), mode, ALL_REGS))
    4681                 :             :     {
    4682                 :         681 :       x = x_inner;
    4683                 :         681 :       y = y_inner;
    4684                 :         681 :       mode = GET_MODE (x_inner);
    4685                 :             :     }
    4686                 :    66916200 :   else if (x_inner != NULL_RTX
    4687                 :        8716 :            && MEM_P (y)
    4688                 :    66916564 :            && candidate_mem_p (GET_MODE (x_inner), y))
    4689                 :             :     {
    4690                 :         364 :       x = x_inner;
    4691                 :         364 :       y = adjust_address (y, GET_MODE (x_inner), 0);
    4692                 :         364 :       mode = GET_MODE (x_inner);
    4693                 :             :     }
    4694                 :    66915836 :   else if (y_inner != NULL_RTX
    4695                 :      288827 :            && MEM_P (x)
    4696                 :    66921349 :            && candidate_mem_p (GET_MODE (y_inner), x))
    4697                 :             :     {
    4698                 :        5453 :       x = adjust_address (x, GET_MODE (y_inner), 0);
    4699                 :        5453 :       y = y_inner;
    4700                 :        5453 :       mode = GET_MODE (y_inner);
    4701                 :             :     }
    4702                 :    66910383 :   else if (x_inner != NULL_RTX
    4703                 :        8352 :            && CONSTANT_P (y)
    4704                 :         433 :            && !targetm.can_change_mode_class (GET_MODE (x_inner),
    4705                 :             :                                               mode, ALL_REGS)
    4706                 :    66910816 :            && (y_inner = simplify_subreg (GET_MODE (x_inner), y, mode, 0)))
    4707                 :             :     {
    4708                 :         433 :       x = x_inner;
    4709                 :         433 :       y = y_inner;
    4710                 :         433 :       mode = GET_MODE (x_inner);
    4711                 :             :     }
    4712                 :             : 
    4713                 :    66916881 :   if (CONSTANT_P (y))
    4714                 :             :     {
    4715                 :    15669248 :       if (optimize
    4716                 :    12246896 :           && SCALAR_FLOAT_MODE_P (GET_MODE (x))
    4717                 :    16429124 :           && (last_insn = compress_float_constant (x, y)))
    4718                 :             :         return last_insn;
    4719                 :             : 
    4720                 :    15600490 :       y_cst = y;
    4721                 :             : 
    4722                 :    15600490 :       if (!targetm.legitimate_constant_p (mode, y))
    4723                 :             :         {
    4724                 :      478998 :           y = force_const_mem (mode, y);
    4725                 :             : 
    4726                 :             :           /* If the target's cannot_force_const_mem prevented the spill,
    4727                 :             :              assume that the target's move expanders will also take care
    4728                 :             :              of the non-legitimate constant.  */
    4729                 :      478998 :           if (!y)
    4730                 :             :             y = y_cst;
    4731                 :             :           else
    4732                 :      459325 :             y = use_anchored_address (y);
    4733                 :             :         }
    4734                 :             :     }
    4735                 :             : 
    4736                 :             :   /* If X or Y are memory references, verify that their addresses are valid
    4737                 :             :      for the machine.  */
    4738                 :    66848123 :   if (MEM_P (x)
    4739                 :    82031640 :       && (! memory_address_addr_space_p (GET_MODE (x), XEXP (x, 0),
    4740                 :    12957494 :                                          MEM_ADDR_SPACE (x))
    4741                 :     2226190 :           && ! push_operand (x, GET_MODE (x))))
    4742                 :         167 :     x = validize_mem (x);
    4743                 :             : 
    4744                 :    66848123 :   if (MEM_P (y)
    4745                 :    83478569 :       && ! memory_address_addr_space_p (GET_MODE (y), XEXP (y, 0),
    4746                 :    16630446 :                                         MEM_ADDR_SPACE (y)))
    4747                 :        9196 :     y = validize_mem (y);
    4748                 :             : 
    4749                 :    66848123 :   gcc_assert (mode != BLKmode);
    4750                 :             : 
    4751                 :    66848123 :   last_insn = emit_move_insn_1 (x, y);
    4752                 :             : 
    4753                 :    15600490 :   if (y_cst && REG_P (x)
    4754                 :    11567910 :       && (set = single_set (last_insn)) != NULL_RTX
    4755                 :    11567910 :       && SET_DEST (set) == x
    4756                 :    78401663 :       && ! rtx_equal_p (y_cst, SET_SRC (set)))
    4757                 :     1200503 :     set_unique_reg_note (last_insn, REG_EQUAL, copy_rtx (y_cst));
    4758                 :             : 
    4759                 :             :   return last_insn;
    4760                 :             : }
    4761                 :             : 
    4762                 :             : /* Generate the body of an instruction to copy Y into X.
    4763                 :             :    It may be a list of insns, if one insn isn't enough.  */
    4764                 :             : 
    4765                 :             : rtx_insn *
    4766                 :     7348158 : gen_move_insn (rtx x, rtx y)
    4767                 :             : {
    4768                 :     7348158 :   rtx_insn *seq;
    4769                 :             : 
    4770                 :     7348158 :   start_sequence ();
    4771                 :     7348158 :   emit_move_insn_1 (x, y);
    4772                 :     7348158 :   seq = get_insns ();
    4773                 :     7348158 :   end_sequence ();
    4774                 :     7348158 :   return seq;
    4775                 :             : }
    4776                 :             : 
    4777                 :             : /* If Y is representable exactly in a narrower mode, and the target can
    4778                 :             :    perform the extension directly from constant or memory, then emit the
    4779                 :             :    move as an extension.  */
    4780                 :             : 
    4781                 :             : static rtx_insn *
    4782                 :      759876 : compress_float_constant (rtx x, rtx y)
    4783                 :             : {
    4784                 :      759876 :   machine_mode dstmode = GET_MODE (x);
    4785                 :      759876 :   machine_mode orig_srcmode = GET_MODE (y);
    4786                 :      759876 :   machine_mode srcmode;
    4787                 :      759876 :   const REAL_VALUE_TYPE *r;
    4788                 :      759876 :   int oldcost, newcost;
    4789                 :      759876 :   bool speed = optimize_insn_for_speed_p ();
    4790                 :             : 
    4791                 :      759876 :   r = CONST_DOUBLE_REAL_VALUE (y);
    4792                 :             : 
    4793                 :      759876 :   if (targetm.legitimate_constant_p (dstmode, y))
    4794                 :      758543 :     oldcost = set_src_cost (y, orig_srcmode, speed);
    4795                 :             :   else
    4796                 :        1333 :     oldcost = set_src_cost (force_const_mem (dstmode, y), dstmode, speed);
    4797                 :             : 
    4798                 :     2682289 :   FOR_EACH_MODE_UNTIL (srcmode, orig_srcmode)
    4799                 :             :     {
    4800                 :     1991171 :       enum insn_code ic;
    4801                 :     1991171 :       rtx trunc_y;
    4802                 :     1991171 :       rtx_insn *last_insn;
    4803                 :             : 
    4804                 :             :       /* Skip if the target can't extend this way.  */
    4805                 :     1991171 :       ic = can_extend_p (dstmode, srcmode, 0);
    4806                 :     1991171 :       if (ic == CODE_FOR_nothing)
    4807                 :     1585268 :         continue;
    4808                 :             : 
    4809                 :             :       /* Skip if the narrowed value isn't exact.  */
    4810                 :      405903 :       if (! exact_real_truncate (srcmode, r))
    4811                 :       50936 :         continue;
    4812                 :             : 
    4813                 :      354967 :       trunc_y = const_double_from_real_value (*r, srcmode);
    4814                 :             : 
    4815                 :      354967 :       if (targetm.legitimate_constant_p (srcmode, trunc_y))
    4816                 :             :         {
    4817                 :             :           /* Skip if the target needs extra instructions to perform
    4818                 :             :              the extension.  */
    4819                 :      351171 :           if (!insn_operand_matches (ic, 1, trunc_y))
    4820                 :        3425 :             continue;
    4821                 :             :           /* This is valid, but may not be cheaper than the original. */
    4822                 :      347746 :           newcost = set_src_cost (gen_rtx_FLOAT_EXTEND (dstmode, trunc_y),
    4823                 :             :                                   dstmode, speed);
    4824                 :      347746 :           if (oldcost < newcost)
    4825                 :      278988 :             continue;
    4826                 :             :         }
    4827                 :        3796 :       else if (float_extend_from_mem[dstmode][srcmode])
    4828                 :             :         {
    4829                 :           0 :           trunc_y = force_const_mem (srcmode, trunc_y);
    4830                 :             :           /* This is valid, but may not be cheaper than the original. */
    4831                 :           0 :           newcost = set_src_cost (gen_rtx_FLOAT_EXTEND (dstmode, trunc_y),
    4832                 :             :                                   dstmode, speed);
    4833                 :           0 :           if (oldcost < newcost)
    4834                 :           0 :             continue;
    4835                 :           0 :           trunc_y = validize_mem (trunc_y);
    4836                 :             :         }
    4837                 :             :       else
    4838                 :        3796 :         continue;
    4839                 :             : 
    4840                 :             :       /* For CSE's benefit, force the compressed constant pool entry
    4841                 :             :          into a new pseudo.  This constant may be used in different modes,
    4842                 :             :          and if not, combine will put things back together for us.  */
    4843                 :       68758 :       trunc_y = force_reg (srcmode, trunc_y);
    4844                 :             : 
    4845                 :             :       /* If x is a hard register, perform the extension into a pseudo,
    4846                 :             :          so that e.g. stack realignment code is aware of it.  */
    4847                 :       68758 :       rtx target = x;
    4848                 :       68758 :       if (REG_P (x) && HARD_REGISTER_P (x))
    4849                 :           1 :         target = gen_reg_rtx (dstmode);
    4850                 :             : 
    4851                 :       68758 :       emit_unop_insn (ic, target, trunc_y, UNKNOWN);
    4852                 :       68758 :       last_insn = get_last_insn ();
    4853                 :             : 
    4854                 :       68758 :       if (REG_P (target))
    4855                 :       58142 :         set_unique_reg_note (last_insn, REG_EQUAL, y);
    4856                 :             : 
    4857                 :       68758 :       if (target != x)
    4858                 :           1 :         return emit_move_insn (x, target);
    4859                 :             :       return last_insn;
    4860                 :             :     }
    4861                 :             : 
    4862                 :             :   return NULL;
    4863                 :             : }
    4864                 :             : 
    4865                 :             : /* Pushing data onto the stack.  */
    4866                 :             : 
    4867                 :             : /* Push a block of length SIZE (perhaps variable)
    4868                 :             :    and return an rtx to address the beginning of the block.
    4869                 :             :    The value may be virtual_outgoing_args_rtx.
    4870                 :             : 
    4871                 :             :    EXTRA is the number of bytes of padding to push in addition to SIZE.
    4872                 :             :    BELOW nonzero means this padding comes at low addresses;
    4873                 :             :    otherwise, the padding comes at high addresses.  */
    4874                 :             : 
    4875                 :             : rtx
    4876                 :      266128 : push_block (rtx size, poly_int64 extra, int below)
    4877                 :             : {
    4878                 :      266128 :   rtx temp;
    4879                 :             : 
    4880                 :      266128 :   size = convert_modes (Pmode, ptr_mode, size, 1);
    4881                 :      266128 :   if (CONSTANT_P (size))
    4882                 :      266128 :     anti_adjust_stack (plus_constant (Pmode, size, extra));
    4883                 :           0 :   else if (REG_P (size) && known_eq (extra, 0))
    4884                 :           0 :     anti_adjust_stack (size);
    4885                 :             :   else
    4886                 :             :     {
    4887                 :           0 :       temp = copy_to_mode_reg (Pmode, size);
    4888                 :           0 :       if (maybe_ne (extra, 0))
    4889                 :           0 :         temp = expand_binop (Pmode, add_optab, temp,
    4890                 :           0 :                              gen_int_mode (extra, Pmode),
    4891                 :             :                              temp, 0, OPTAB_LIB_WIDEN);
    4892                 :           0 :       anti_adjust_stack (temp);
    4893                 :             :     }
    4894                 :             : 
    4895                 :      266128 :   if (STACK_GROWS_DOWNWARD)
    4896                 :             :     {
    4897                 :      266128 :       temp = virtual_outgoing_args_rtx;
    4898                 :      266128 :       if (maybe_ne (extra, 0) && below)
    4899                 :           0 :         temp = plus_constant (Pmode, temp, extra);
    4900                 :             :     }
    4901                 :             :   else
    4902                 :             :     {
    4903                 :             :       poly_int64 csize;
    4904                 :             :       if (poly_int_rtx_p (size, &csize))
    4905                 :             :         temp = plus_constant (Pmode, virtual_outgoing_args_rtx,
    4906                 :             :                               -csize - (below ? 0 : extra));
    4907                 :             :       else if (maybe_ne (extra, 0) && !below)
    4908                 :             :         temp = gen_rtx_PLUS (Pmode, virtual_outgoing_args_rtx,
    4909                 :             :                              negate_rtx (Pmode, plus_constant (Pmode, size,
    4910                 :             :                                                                extra)));
    4911                 :             :       else
    4912                 :             :         temp = gen_rtx_PLUS (Pmode, virtual_outgoing_args_rtx,
    4913                 :             :                              negate_rtx (Pmode, size));
    4914                 :             :     }
    4915                 :             : 
    4916                 :      266128 :   return memory_address (NARROWEST_INT_MODE, temp);
    4917                 :             : }
    4918                 :             : 
    4919                 :             : /* A utility routine that returns the base of an auto-inc memory, or NULL.  */
    4920                 :             : 
    4921                 :             : static rtx
    4922                 :     2560070 : mem_autoinc_base (rtx mem)
    4923                 :             : {
    4924                 :           0 :   if (MEM_P (mem))
    4925                 :             :     {
    4926                 :     1554073 :       rtx addr = XEXP (mem, 0);
    4927                 :     1554073 :       if (GET_RTX_CLASS (GET_CODE (addr)) == RTX_AUTOINC)
    4928                 :     1021889 :         return XEXP (addr, 0);
    4929                 :             :     }
    4930                 :             :   return NULL;
    4931                 :             : }
    4932                 :             : 
    4933                 :             : /* A utility routine used here, in reload, and in try_split.  The insns
    4934                 :             :    after PREV up to and including LAST are known to adjust the stack,
    4935                 :             :    with a final value of END_ARGS_SIZE.  Iterate backward from LAST
    4936                 :             :    placing notes as appropriate.  PREV may be NULL, indicating the
    4937                 :             :    entire insn sequence prior to LAST should be scanned.
    4938                 :             : 
    4939                 :             :    The set of allowed stack pointer modifications is small:
    4940                 :             :      (1) One or more auto-inc style memory references (aka pushes),
    4941                 :             :      (2) One or more addition/subtraction with the SP as destination,
    4942                 :             :      (3) A single move insn with the SP as destination,
    4943                 :             :      (4) A call_pop insn,
    4944                 :             :      (5) Noreturn call insns if !ACCUMULATE_OUTGOING_ARGS.
    4945                 :             : 
    4946                 :             :    Insns in the sequence that do not modify the SP are ignored,
    4947                 :             :    except for noreturn calls.
    4948                 :             : 
    4949                 :             :    The return value is the amount of adjustment that can be trivially
    4950                 :             :    verified, via immediate operand or auto-inc.  If the adjustment
    4951                 :             :    cannot be trivially extracted, the return value is HOST_WIDE_INT_MIN.  */
    4952                 :             : 
    4953                 :             : poly_int64
    4954                 :     4302570 : find_args_size_adjust (rtx_insn *insn)
    4955                 :             : {
    4956                 :     4302570 :   rtx dest, set, pat;
    4957                 :     4302570 :   int i;
    4958                 :             : 
    4959                 :     4302570 :   pat = PATTERN (insn);
    4960                 :     4302570 :   set = NULL;
    4961                 :             : 
    4962                 :             :   /* Look for a call_pop pattern.  */
    4963                 :     4302570 :   if (CALL_P (insn))
    4964                 :             :     {
    4965                 :             :       /* We have to allow non-call_pop patterns for the case
    4966                 :             :          of emit_single_push_insn of a TLS address.  */
    4967                 :     2677860 :       if (GET_CODE (pat) != PARALLEL)
    4968                 :     2664315 :         return 0;
    4969                 :             : 
    4970                 :             :       /* All call_pop have a stack pointer adjust in the parallel.
    4971                 :             :          The call itself is always first, and the stack adjust is
    4972                 :             :          usually last, so search from the end.  */
    4973                 :       13545 :       for (i = XVECLEN (pat, 0) - 1; i > 0; --i)
    4974                 :             :         {
    4975                 :       13545 :           set = XVECEXP (pat, 0, i);
    4976                 :       13545 :           if (GET_CODE (set) != SET)
    4977                 :           0 :             continue;
    4978                 :       13545 :           dest = SET_DEST (set);
    4979                 :       13545 :           if (dest == stack_pointer_rtx)
    4980                 :             :             break;
    4981                 :             :         }
    4982                 :             :       /* We'd better have found the stack pointer adjust.  */
    4983                 :       13545 :       if (i == 0)
    4984                 :           0 :         return 0;
    4985                 :             :       /* Fall through to process the extracted SET and DEST
    4986                 :             :          as if it was a standalone insn.  */
    4987                 :             :     }
    4988                 :     1624710 :   else if (GET_CODE (pat) == SET)
    4989                 :             :     set = pat;
    4990                 :      243154 :   else if ((set = single_set (insn)) != NULL)
    4991                 :             :     ;
    4992                 :       47305 :   else if (GET_CODE (pat) == PARALLEL)
    4993                 :             :     {
    4994                 :             :       /* ??? Some older ports use a parallel with a stack adjust
    4995                 :             :          and a store for a PUSH_ROUNDING pattern, rather than a
    4996                 :             :          PRE/POST_MODIFY rtx.  Don't force them to update yet...  */
    4997                 :             :       /* ??? See h8300 and m68k, pushqi1.  */
    4998                 :           0 :       for (i = XVECLEN (pat, 0) - 1; i >= 0; --i)
    4999                 :             :         {
    5000                 :           0 :           set = XVECEXP (pat, 0, i);
    5001                 :           0 :           if (GET_CODE (set) != SET)
    5002                 :           0 :             continue;
    5003                 :           0 :           dest = SET_DEST (set);
    5004                 :           0 :           if (dest == stack_pointer_rtx)
    5005                 :             :             break;
    5006                 :             : 
    5007                 :             :           /* We do not expect an auto-inc of the sp in the parallel.  */
    5008                 :           0 :           gcc_checking_assert (mem_autoinc_base (dest) != stack_pointer_rtx);
    5009                 :           0 :           gcc_checking_assert (mem_autoinc_base (SET_SRC (set))
    5010                 :             :                                != stack_pointer_rtx);
    5011                 :             :         }
    5012                 :           0 :       if (i < 0)
    5013                 :           0 :         return 0;
    5014                 :             :     }
    5015                 :             :   else
    5016                 :       47305 :     return 0;
    5017                 :             : 
    5018                 :     1590950 :   dest = SET_DEST (set);
    5019                 :             : 
    5020                 :             :   /* Look for direct modifications of the stack pointer.  */
    5021                 :     1590950 :   if (REG_P (dest) && REGNO (dest) == STACK_POINTER_REGNUM)
    5022                 :             :     {
    5023                 :             :       /* Look for a trivial adjustment, otherwise assume nothing.  */
    5024                 :             :       /* Note that the SPU restore_stack_block pattern refers to
    5025                 :             :          the stack pointer in V4SImode.  Consider that non-trivial.  */
    5026                 :      310915 :       poly_int64 offset;
    5027                 :      310915 :       if (SCALAR_INT_MODE_P (GET_MODE (dest))
    5028                 :      310915 :           && strip_offset (SET_SRC (set), &offset) == stack_pointer_rtx)
    5029                 :      308584 :         return offset;
    5030                 :             :       /* ??? Reload can generate no-op moves, which will be cleaned
    5031                 :             :          up later.  Recognize it and continue searching.  */
    5032                 :        2331 :       else if (rtx_equal_p (dest, SET_SRC (set)))
    5033                 :           0 :         return 0;
    5034                 :             :       else
    5035                 :        2331 :         return HOST_WIDE_INT_MIN;
    5036                 :             :     }
    5037                 :             :   else
    5038                 :             :     {
    5039                 :     1280035 :       rtx mem, addr;
    5040                 :             : 
    5041                 :             :       /* Otherwise only think about autoinc patterns.  */
    5042                 :     2316474 :       if (mem_autoinc_base (dest) == stack_pointer_rtx)
    5043                 :             :         {
    5044                 :      915322 :           mem = dest;
    5045                 :     1258278 :           gcc_checking_assert (mem_autoinc_base (SET_SRC (set))
    5046                 :             :                                != stack_pointer_rtx);
    5047                 :             :         }
    5048                 :      539391 :       else if (mem_autoinc_base (SET_SRC (set)) == stack_pointer_rtx)
    5049                 :             :         mem = SET_SRC (set);
    5050                 :             :       else
    5051                 :      258146 :         return 0;
    5052                 :             : 
    5053                 :     1021889 :       addr = XEXP (mem, 0);
    5054                 :     1021889 :       switch (GET_CODE (addr))
    5055                 :             :         {
    5056                 :      106567 :         case PRE_INC:
    5057                 :      106567 :         case POST_INC:
    5058                 :      213134 :           return GET_MODE_SIZE (GET_MODE (mem));
    5059                 :      895747 :         case PRE_DEC:
    5060                 :      895747 :         case POST_DEC:
    5061                 :     1791494 :           return -GET_MODE_SIZE (GET_MODE (mem));
    5062                 :       19575 :         case PRE_MODIFY:
    5063                 :       19575 :         case POST_MODIFY:
    5064                 :       19575 :           addr = XEXP (addr, 1);
    5065                 :       19575 :           gcc_assert (GET_CODE (addr) == PLUS);
    5066                 :       19575 :           gcc_assert (XEXP (addr, 0) == stack_pointer_rtx);
    5067                 :       19575 :           return rtx_to_poly_int64 (XEXP (addr, 1));
    5068                 :           0 :         default:
    5069                 :           0 :           gcc_unreachable ();
    5070                 :             :         }
    5071                 :             :     }
    5072                 :             : }
    5073                 :             : 
    5074                 :             : poly_int64
    5075                 :      661090 : fixup_args_size_notes (rtx_insn *prev, rtx_insn *last,
    5076                 :             :                        poly_int64 end_args_size)
    5077                 :             : {
    5078                 :      661090 :   poly_int64 args_size = end_args_size;
    5079                 :      661090 :   bool saw_unknown = false;
    5080                 :      661090 :   rtx_insn *insn;
    5081                 :             : 
    5082                 :     1889965 :   for (insn = last; insn != prev; insn = PREV_INSN (insn))
    5083                 :             :     {
    5084                 :     1228875 :       if (!NONDEBUG_INSN_P (insn))
    5085                 :           0 :         continue;
    5086                 :             : 
    5087                 :             :       /* We might have existing REG_ARGS_SIZE notes, e.g. when pushing
    5088                 :             :          a call argument containing a TLS address that itself requires
    5089                 :             :          a call to __tls_get_addr.  The handling of stack_pointer_delta
    5090                 :             :          in emit_single_push_insn is supposed to ensure that any such
    5091                 :             :          notes are already correct.  */
    5092                 :     1228875 :       rtx note = find_reg_note (insn, REG_ARGS_SIZE, NULL_RTX);
    5093                 :     1228875 :       gcc_assert (!note || known_eq (args_size, get_args_size (note)));
    5094                 :             : 
    5095                 :     1228875 :       poly_int64 this_delta = find_args_size_adjust (insn);
    5096                 :     1228875 :       if (known_eq (this_delta, 0))
    5097                 :             :         {
    5098                 :      607813 :           if (!CALL_P (insn)
    5099                 :           5 :               || ACCUMULATE_OUTGOING_ARGS
    5100                 :      303914 :               || find_reg_note (insn, REG_NORETURN, NULL_RTX) == NULL_RTX)
    5101                 :      303904 :             continue;
    5102                 :             :         }
    5103                 :             : 
    5104                 :      924971 :       gcc_assert (!saw_unknown);
    5105                 :      924971 :       if (known_eq (this_delta, HOST_WIDE_INT_MIN))
    5106                 :        2308 :         saw_unknown = true;
    5107                 :             : 
    5108                 :      924971 :       if (!note)
    5109                 :      924971 :         add_args_size_note (insn, args_size);
    5110                 :             :       if (STACK_GROWS_DOWNWARD)
    5111                 :      924971 :         this_delta = -poly_uint64 (this_delta);
    5112                 :             : 
    5113                 :      924971 :       if (saw_unknown)
    5114                 :             :         args_size = HOST_WIDE_INT_MIN;
    5115                 :             :       else
    5116                 :     1228875 :         args_size -= this_delta;
    5117                 :             :     }
    5118                 :             : 
    5119                 :      661090 :   return args_size;
    5120                 :             : }
    5121                 :             : 
    5122                 :             : #ifdef PUSH_ROUNDING
    5123                 :             : /* Emit single push insn.  */
    5124                 :             : 
    5125                 :             : static void
    5126                 :     1812943 : emit_single_push_insn_1 (machine_mode mode, rtx x, tree type)
    5127                 :             : {
    5128                 :     1812943 :   rtx dest_addr;
    5129                 :     3625886 :   poly_int64 rounded_size = PUSH_ROUNDING (GET_MODE_SIZE (mode));
    5130                 :     1812943 :   rtx dest;
    5131                 :     1812943 :   enum insn_code icode;
    5132                 :             : 
    5133                 :             :   /* If there is push pattern, use it.  Otherwise try old way of throwing
    5134                 :             :      MEM representing push operation to move expander.  */
    5135                 :     1812943 :   icode = optab_handler (push_optab, mode);
    5136                 :     1812943 :   if (icode != CODE_FOR_nothing)
    5137                 :             :     {
    5138                 :           0 :       class expand_operand ops[1];
    5139                 :             : 
    5140                 :           0 :       create_input_operand (&ops[0], x, mode);
    5141                 :           0 :       if (maybe_expand_insn (icode, 1, ops))
    5142                 :           0 :         return;
    5143                 :             :     }
    5144                 :     3625886 :   if (known_eq (GET_MODE_SIZE (mode), rounded_size))
    5145                 :     1696659 :     dest_addr = gen_rtx_fmt_e (STACK_PUSH_CODE, Pmode, stack_pointer_rtx);
    5146                 :             :   /* If we are to pad downward, adjust the stack pointer first and
    5147                 :             :      then store X into the stack location using an offset.  This is
    5148                 :             :      because emit_move_insn does not know how to pad; it does not have
    5149                 :             :      access to type.  */
    5150                 :      116284 :   else if (targetm.calls.function_arg_padding (mode, type) == PAD_DOWNWARD)
    5151                 :             :     {
    5152                 :           0 :       emit_move_insn (stack_pointer_rtx,
    5153                 :           0 :                       expand_binop (Pmode,
    5154                 :             :                                     STACK_GROWS_DOWNWARD ? sub_optab
    5155                 :             :                                     : add_optab,
    5156                 :             :                                     stack_pointer_rtx,
    5157                 :           0 :                                     gen_int_mode (rounded_size, Pmode),
    5158                 :             :                                     NULL_RTX, 0, OPTAB_LIB_WIDEN));
    5159                 :             : 
    5160                 :           0 :       poly_int64 offset = rounded_size - GET_MODE_SIZE (mode);
    5161                 :           0 :       if (STACK_GROWS_DOWNWARD && STACK_PUSH_CODE == POST_DEC)
    5162                 :             :         /* We have already decremented the stack pointer, so get the
    5163                 :             :            previous value.  */
    5164                 :             :         offset += rounded_size;
    5165                 :             : 
    5166                 :           0 :       if (!STACK_GROWS_DOWNWARD && STACK_PUSH_CODE == POST_INC)
    5167                 :             :         /* We have already incremented the stack pointer, so get the
    5168                 :             :            previous value.  */
    5169                 :             :         offset -= rounded_size;
    5170                 :             : 
    5171                 :           0 :       dest_addr = plus_constant (Pmode, stack_pointer_rtx, offset);
    5172                 :             :     }
    5173                 :             :   else
    5174                 :             :     {
    5175                 :             :       if (STACK_GROWS_DOWNWARD)
    5176                 :             :         /* ??? This seems wrong if STACK_PUSH_CODE == POST_DEC.  */
    5177                 :      116284 :         dest_addr = plus_constant (Pmode, stack_pointer_rtx, -rounded_size);
    5178                 :             :       else
    5179                 :             :         /* ??? This seems wrong if STACK_PUSH_CODE == POST_INC.  */
    5180                 :             :         dest_addr = plus_constant (Pmode, stack_pointer_rtx, rounded_size);
    5181                 :             : 
    5182                 :      116284 :       dest_addr = gen_rtx_PRE_MODIFY (Pmode, stack_pointer_rtx, dest_addr);
    5183                 :             :     }
    5184                 :             : 
    5185                 :     1812943 :   dest = gen_rtx_MEM (mode, dest_addr);
    5186                 :             : 
    5187                 :     1812943 :   if (type != 0)
    5188                 :             :     {
    5189                 :     1812896 :       set_mem_attributes (dest, type, 1);
    5190                 :             : 
    5191                 :     1812896 :       if (cfun->tail_call_marked)
    5192                 :             :         /* Function incoming arguments may overlap with sibling call
    5193                 :             :            outgoing arguments and we cannot allow reordering of reads
    5194                 :             :            from function arguments with stores to outgoing arguments
    5195                 :             :            of sibling calls.  */
    5196                 :      137310 :         set_mem_alias_set (dest, 0);
    5197                 :             :     }
    5198                 :     1812943 :   emit_move_insn (dest, x);
    5199                 :             : }
    5200                 :             : 
    5201                 :             : /* Emit and annotate a single push insn.  */
    5202                 :             : 
    5203                 :             : static void
    5204                 :     1812943 : emit_single_push_insn (machine_mode mode, rtx x, tree type)
    5205                 :             : {
    5206                 :     1812943 :   poly_int64 delta, old_delta = stack_pointer_delta;
    5207                 :     1812943 :   rtx_insn *prev = get_last_insn ();
    5208                 :     1812943 :   rtx_insn *last;
    5209                 :             : 
    5210                 :     1812943 :   emit_single_push_insn_1 (mode, x, type);
    5211                 :             : 
    5212                 :             :   /* Adjust stack_pointer_delta to describe the situation after the push
    5213                 :             :      we just performed.  Note that we must do this after the push rather
    5214                 :             :      than before the push in case calculating X needs pushes and pops of
    5215                 :             :      its own (e.g. if calling __tls_get_addr).  The REG_ARGS_SIZE notes
    5216                 :             :      for such pushes and pops must not include the effect of the future
    5217                 :             :      push of X.  */
    5218                 :     3625886 :   stack_pointer_delta += PUSH_ROUNDING (GET_MODE_SIZE (mode));
    5219                 :             : 
    5220                 :     1812943 :   last = get_last_insn ();
    5221                 :             : 
    5222                 :             :   /* Notice the common case where we emitted exactly one insn.  */
    5223                 :     1812943 :   if (PREV_INSN (last) == prev)
    5224                 :             :     {
    5225                 :     1704313 :       add_args_size_note (last, stack_pointer_delta);
    5226                 :     1704313 :       return;
    5227                 :             :     }
    5228                 :             : 
    5229                 :      108630 :   delta = fixup_args_size_notes (prev, last, stack_pointer_delta);
    5230                 :      108630 :   gcc_assert (known_eq (delta, HOST_WIDE_INT_MIN)
    5231                 :             :               || known_eq (delta, old_delta));
    5232                 :             : }
    5233                 :             : #endif
    5234                 :             : 
    5235                 :             : /* If reading SIZE bytes from X will end up reading from
    5236                 :             :    Y return the number of bytes that overlap.  Return -1
    5237                 :             :    if there is no overlap or -2 if we can't determine
    5238                 :             :    (for example when X and Y have different base registers).  */
    5239                 :             : 
    5240                 :             : static int
    5241                 :           0 : memory_load_overlap (rtx x, rtx y, HOST_WIDE_INT size)
    5242                 :             : {
    5243                 :           0 :   rtx tmp = plus_constant (Pmode, x, size);
    5244                 :           0 :   rtx sub = simplify_gen_binary (MINUS, Pmode, tmp, y);
    5245                 :             : 
    5246                 :           0 :   if (!CONST_INT_P (sub))
    5247                 :             :     return -2;
    5248                 :             : 
    5249                 :           0 :   HOST_WIDE_INT val = INTVAL (sub);
    5250                 :             : 
    5251                 :           0 :   return IN_RANGE (val, 1, size) ? val : -1;
    5252                 :             : }
    5253                 :             : 
    5254                 :             : /* Generate code to push X onto the stack, assuming it has mode MODE and
    5255                 :             :    type TYPE.
    5256                 :             :    MODE is redundant except when X is a CONST_INT (since they don't
    5257                 :             :    carry mode info).
    5258                 :             :    SIZE is an rtx for the size of data to be copied (in bytes),
    5259                 :             :    needed only if X is BLKmode.
    5260                 :             :    Return true if successful.  May return false if asked to push a
    5261                 :             :    partial argument during a sibcall optimization (as specified by
    5262                 :             :    SIBCALL_P) and the incoming and outgoing pointers cannot be shown
    5263                 :             :    to not overlap.
    5264                 :             : 
    5265                 :             :    ALIGN (in bits) is maximum alignment we can assume.
    5266                 :             : 
    5267                 :             :    If PARTIAL and REG are both nonzero, then copy that many of the first
    5268                 :             :    bytes of X into registers starting with REG, and push the rest of X.
    5269                 :             :    The amount of space pushed is decreased by PARTIAL bytes.
    5270                 :             :    REG must be a hard register in this case.
    5271                 :             :    If REG is zero but PARTIAL is not, take any all others actions for an
    5272                 :             :    argument partially in registers, but do not actually load any
    5273                 :             :    registers.
    5274                 :             : 
    5275                 :             :    EXTRA is the amount in bytes of extra space to leave next to this arg.
    5276                 :             :    This is ignored if an argument block has already been allocated.
    5277                 :             : 
    5278                 :             :    On a machine that lacks real push insns, ARGS_ADDR is the address of
    5279                 :             :    the bottom of the argument block for this call.  We use indexing off there
    5280                 :             :    to store the arg.  On machines with push insns, ARGS_ADDR is 0 when a
    5281                 :             :    argument block has not been preallocated.
    5282                 :             : 
    5283                 :             :    ARGS_SO_FAR is the size of args previously pushed for this call.
    5284                 :             : 
    5285                 :             :    REG_PARM_STACK_SPACE is nonzero if functions require stack space
    5286                 :             :    for arguments passed in registers.  If nonzero, it will be the number
    5287                 :             :    of bytes required.  */
    5288                 :             : 
    5289                 :             : bool
    5290                 :     2133763 : emit_push_insn (rtx x, machine_mode mode, tree type, rtx size,
    5291                 :             :                 unsigned int align, int partial, rtx reg, poly_int64 extra,
    5292                 :             :                 rtx args_addr, rtx args_so_far, int reg_parm_stack_space,
    5293                 :             :                 rtx alignment_pad, bool sibcall_p)
    5294                 :             : {
    5295                 :     2133763 :   rtx xinner;
    5296                 :     2133763 :   pad_direction stack_direction
    5297                 :             :     = STACK_GROWS_DOWNWARD ? PAD_DOWNWARD : PAD_UPWARD;
    5298                 :             : 
    5299                 :             :   /* Decide where to pad the argument: PAD_DOWNWARD for below,
    5300                 :             :      PAD_UPWARD for above, or PAD_NONE for don't pad it.
    5301                 :             :      Default is below for small data on big-endian machines; else above.  */
    5302                 :     2133763 :   pad_direction where_pad = targetm.calls.function_arg_padding (mode, type);
    5303                 :             : 
    5304                 :             :   /* Invert direction if stack is post-decrement.
    5305                 :             :      FIXME: why?  */
    5306                 :     2133763 :   if (STACK_PUSH_CODE == POST_DEC)
    5307                 :             :     if (where_pad != PAD_NONE)
    5308                 :             :       where_pad = (where_pad == PAD_DOWNWARD ? PAD_UPWARD : PAD_DOWNWARD);
    5309                 :             : 
    5310                 :     2133763 :   xinner = x;
    5311                 :             : 
    5312                 :     2133763 :   int nregs = partial / UNITS_PER_WORD;
    5313                 :     2133763 :   rtx *tmp_regs = NULL;
    5314                 :     2133763 :   int overlapping = 0;
    5315                 :             : 
    5316                 :     2133763 :   if (mode == BLKmode
    5317                 :             :       || (STRICT_ALIGNMENT && align < GET_MODE_ALIGNMENT (mode)))
    5318                 :             :     {
    5319                 :             :       /* Copy a block into the stack, entirely or partially.  */
    5320                 :             : 
    5321                 :      266219 :       rtx temp;
    5322                 :      266219 :       int used;
    5323                 :      266219 :       int offset;
    5324                 :      266219 :       int skip;
    5325                 :             : 
    5326                 :      266219 :       offset = partial % (PARM_BOUNDARY / BITS_PER_UNIT);
    5327                 :      266219 :       used = partial - offset;
    5328                 :             : 
    5329                 :      266219 :       if (mode != BLKmode)
    5330                 :             :         {
    5331                 :             :           /* A value is to be stored in an insufficiently aligned
    5332                 :             :              stack slot; copy via a suitably aligned slot if
    5333                 :             :              necessary.  */
    5334                 :             :           size = gen_int_mode (GET_MODE_SIZE (mode), Pmode);
    5335                 :             :           if (!MEM_P (xinner))
    5336                 :             :             {
    5337                 :             :               temp = assign_temp (type, 1, 1);
    5338                 :             :               emit_move_insn (temp, xinner);
    5339                 :             :               xinner = temp;
    5340                 :             :             }
    5341                 :             :         }
    5342                 :             : 
    5343                 :      266219 :       gcc_assert (size);
    5344                 :             : 
    5345                 :             :       /* USED is now the # of bytes we need not copy to the stack
    5346                 :             :          because registers will take care of them.  */
    5347                 :             : 
    5348                 :      266219 :       if (partial != 0)
    5349                 :           0 :         xinner = adjust_address (xinner, BLKmode, used);
    5350                 :             : 
    5351                 :             :       /* If the partial register-part of the arg counts in its stack size,
    5352                 :             :          skip the part of stack space corresponding to the registers.
    5353                 :             :          Otherwise, start copying to the beginning of the stack space,
    5354                 :             :          by setting SKIP to 0.  */
    5355                 :      266219 :       skip = (reg_parm_stack_space == 0) ? 0 : used;
    5356                 :             : 
    5357                 :             : #ifdef PUSH_ROUNDING
    5358                 :             :       /* NB: Let the backend known the number of bytes to push and
    5359                 :             :          decide if push insns should be generated.  */
    5360                 :      266219 :       unsigned int push_size;
    5361                 :      266219 :       if (CONST_INT_P (size))
    5362                 :      266219 :         push_size = INTVAL (size);
    5363                 :             :       else
    5364                 :             :         push_size = 0;
    5365                 :             : 
    5366                 :             :       /* Do it with several push insns if that doesn't take lots of insns
    5367                 :             :          and if there is no difficulty with push insns that skip bytes
    5368                 :             :          on the stack for alignment purposes.  */
    5369                 :      266219 :       if (args_addr == 0
    5370                 :      266171 :           && targetm.calls.push_argument (push_size)
    5371                 :        3790 :           && CONST_INT_P (size)
    5372                 :        3790 :           && skip == 0
    5373                 :        3790 :           && MEM_ALIGN (xinner) >= align
    5374                 :        2886 :           && can_move_by_pieces ((unsigned) INTVAL (size) - used, align)
    5375                 :             :           /* Here we avoid the case of a structure whose weak alignment
    5376                 :             :              forces many pushes of a small amount of data,
    5377                 :             :              and such small pushes do rounding that causes trouble.  */
    5378                 :        2886 :           && ((!targetm.slow_unaligned_access (word_mode, align))
    5379                 :           0 :               || align >= BIGGEST_ALIGNMENT
    5380                 :           0 :               || known_eq (PUSH_ROUNDING (align / BITS_PER_UNIT),
    5381                 :             :                            align / BITS_PER_UNIT))
    5382                 :      269105 :           && known_eq (PUSH_ROUNDING (INTVAL (size)), INTVAL (size)))
    5383                 :             :         {
    5384                 :             :           /* Push padding now if padding above and stack grows down,
    5385                 :             :              or if padding below and stack grows up.
    5386                 :             :              But if space already allocated, this has already been done.  */
    5387                 :          45 :           if (maybe_ne (extra, 0)
    5388                 :             :               && args_addr == 0
    5389                 :           0 :               && where_pad != PAD_NONE
    5390                 :          45 :               && where_pad != stack_direction)
    5391                 :           0 :             anti_adjust_stack (gen_int_mode (extra, Pmode));
    5392                 :             : 
    5393                 :          45 :           move_by_pieces (NULL, xinner, INTVAL (size) - used, align,
    5394                 :             :                           RETURN_BEGIN);
    5395                 :             :         }
    5396                 :             :       else
    5397                 :             : #endif /* PUSH_ROUNDING  */
    5398                 :             :         {
    5399                 :      266174 :           rtx target;
    5400                 :             : 
    5401                 :             :           /* Otherwise make space on the stack and copy the data
    5402                 :             :              to the address of that space.  */
    5403                 :             : 
    5404                 :             :           /* Deduct words put into registers from the size we must copy.  */
    5405                 :      266174 :           if (partial != 0)
    5406                 :             :             {
    5407                 :           0 :               if (CONST_INT_P (size))
    5408                 :           0 :                 size = GEN_INT (INTVAL (size) - used);
    5409                 :             :               else
    5410                 :           0 :                 size = expand_binop (GET_MODE (size), sub_optab, size,
    5411                 :           0 :                                      gen_int_mode (used, GET_MODE (size)),
    5412                 :             :                                      NULL_RTX, 0, OPTAB_LIB_WIDEN);
    5413                 :             :             }
    5414                 :             : 
    5415                 :             :           /* Get the address of the stack space.
    5416                 :             :              In this case, we do not deal with EXTRA separately.
    5417                 :             :              A single stack adjust will do.  */
    5418                 :      266174 :           poly_int64 const_args_so_far;
    5419                 :      266174 :           if (! args_addr)
    5420                 :             :             {
    5421                 :      266126 :               temp = push_block (size, extra, where_pad == PAD_DOWNWARD);
    5422                 :      266126 :               extra = 0;
    5423                 :             :             }
    5424                 :          48 :           else if (poly_int_rtx_p (args_so_far, &const_args_so_far))
    5425                 :          48 :             temp = memory_address (BLKmode,
    5426                 :             :                                    plus_constant (Pmode, args_addr,
    5427                 :             :                                                   skip + const_args_so_far));
    5428                 :             :           else
    5429                 :           0 :             temp = memory_address (BLKmode,
    5430                 :             :                                    plus_constant (Pmode,
    5431                 :             :                                                   gen_rtx_PLUS (Pmode,
    5432                 :             :                                                                 args_addr,
    5433                 :             :                                                                 args_so_far),
    5434                 :             :                                                   skip));
    5435                 :             : 
    5436                 :      266174 :           if (!ACCUMULATE_OUTGOING_ARGS)
    5437                 :             :             {
    5438                 :             :               /* If the source is referenced relative to the stack pointer,
    5439                 :             :                  copy it to another register to stabilize it.  We do not need
    5440                 :             :                  to do this if we know that we won't be changing sp.  */
    5441                 :             : 
    5442                 :      266174 :               if (reg_mentioned_p (virtual_stack_dynamic_rtx, temp)
    5443                 :      266174 :                   || reg_mentioned_p (virtual_outgoing_args_rtx, temp))
    5444                 :      266126 :                 temp = copy_to_reg (temp);
    5445                 :             :             }
    5446                 :             : 
    5447                 :      266174 :           target = gen_rtx_MEM (BLKmode, temp);
    5448                 :             : 
    5449                 :             :           /* We do *not* set_mem_attributes here, because incoming arguments
    5450                 :             :              may overlap with sibling call outgoing arguments and we cannot
    5451                 :             :              allow reordering of reads from function arguments with stores
    5452                 :             :              to outgoing arguments of sibling calls.  We do, however, want
    5453                 :             :              to record the alignment of the stack slot.  */
    5454                 :             :           /* ALIGN may well be better aligned than TYPE, e.g. due to
    5455                 :             :              PARM_BOUNDARY.  Assume the caller isn't lying.  */
    5456                 :      266174 :           set_mem_align (target, align);
    5457                 :             : 
    5458                 :             :           /* If part should go in registers and pushing to that part would
    5459                 :             :              overwrite some of the values that need to go into regs, load the
    5460                 :             :              overlapping values into temporary pseudos to be moved into the hard
    5461                 :             :              regs at the end after the stack pushing has completed.
    5462                 :             :              We cannot load them directly into the hard regs here because
    5463                 :             :              they can be clobbered by the block move expansions.
    5464                 :             :              See PR 65358.  */
    5465                 :             : 
    5466                 :      266174 :           if (partial > 0 && reg != 0 && mode == BLKmode
    5467                 :           0 :               && GET_CODE (reg) != PARALLEL)
    5468                 :             :             {
    5469                 :           0 :               overlapping = memory_load_overlap (XEXP (x, 0), temp, partial);
    5470                 :           0 :               if (overlapping > 0)
    5471                 :             :                 {
    5472                 :           0 :                   gcc_assert (overlapping % UNITS_PER_WORD == 0);
    5473                 :           0 :                   overlapping /= UNITS_PER_WORD;
    5474                 :             : 
    5475                 :           0 :                   tmp_regs = XALLOCAVEC (rtx, overlapping);
    5476                 :             : 
    5477                 :           0 :                   for (int i = 0; i < overlapping; i++)
    5478                 :           0 :                     tmp_regs[i] = gen_reg_rtx (word_mode);
    5479                 :             : 
    5480                 :           0 :                   for (int i = 0; i < overlapping; i++)
    5481                 :           0 :                     emit_move_insn (tmp_regs[i],
    5482                 :           0 :                                     operand_subword_force (target, i, mode));
    5483                 :             :                 }
    5484                 :           0 :               else if (overlapping == -1)
    5485                 :             :                 overlapping = 0;
    5486                 :             :               /* Could not determine whether there is overlap.
    5487                 :             :                  Fail the sibcall.  */
    5488                 :             :               else
    5489                 :             :                 {
    5490                 :           0 :                   overlapping = 0;
    5491                 :           0 :                   if (sibcall_p)
    5492                 :           0 :                     return false;
    5493                 :             :                 }
    5494                 :             :             }
    5495                 :             : 
    5496                 :             :           /* If source is a constant VAR_DECL with a simple constructor,
    5497                 :             :              store the constructor to the stack instead of moving it.  */
    5498                 :      266174 :           const_tree decl;
    5499                 :      266174 :           HOST_WIDE_INT sz;
    5500                 :      266174 :           if (partial == 0
    5501                 :      266174 :               && MEM_P (xinner)
    5502                 :      266174 :               && SYMBOL_REF_P (XEXP (xinner, 0))
    5503                 :       81586 :               && (decl = SYMBOL_REF_DECL (XEXP (xinner, 0))) != NULL_TREE
    5504                 :       81586 :               && VAR_P (decl)
    5505                 :       81586 :               && TREE_READONLY (decl)
    5506                 :        4341 :               && !TREE_SIDE_EFFECTS (decl)
    5507                 :        4341 :               && immediate_const_ctor_p (DECL_INITIAL (decl), 2)
    5508                 :           6 :               && (sz = int_expr_size (DECL_INITIAL (decl))) > 0
    5509                 :           6 :               && CONST_INT_P (size)
    5510                 :      266180 :               && INTVAL (size) == sz)
    5511                 :           0 :             store_constructor (DECL_INITIAL (decl), target, 0, sz, false);
    5512                 :             :           else
    5513                 :      266174 :             emit_block_move (target, xinner, size, BLOCK_OP_CALL_PARM);
    5514                 :             :         }
    5515                 :             :     }
    5516                 :     1867544 :   else if (partial > 0)
    5517                 :             :     {
    5518                 :             :       /* Scalar partly in registers.  This case is only supported
    5519                 :             :          for fixed-wdth modes.  */
    5520                 :           0 :       int num_words = GET_MODE_SIZE (mode).to_constant ();
    5521                 :           0 :       num_words /= UNITS_PER_WORD;
    5522                 :           0 :       int i;
    5523                 :           0 :       int not_stack;
    5524                 :             :       /* # bytes of start of argument
    5525                 :             :          that we must make space for but need not store.  */
    5526                 :           0 :       int offset = partial % (PARM_BOUNDARY / BITS_PER_UNIT);
    5527                 :           0 :       int args_offset = INTVAL (args_so_far);
    5528                 :           0 :       int skip;
    5529                 :             : 
    5530                 :             :       /* Push padding now if padding above and stack grows down,
    5531                 :             :          or if padding below and stack grows up.
    5532                 :             :          But if space already allocated, this has already been done.  */
    5533                 :           0 :       if (maybe_ne (extra, 0)
    5534                 :           0 :           && args_addr == 0
    5535                 :           0 :           && where_pad != PAD_NONE
    5536                 :           0 :           && where_pad != stack_direction)
    5537                 :           0 :         anti_adjust_stack (gen_int_mode (extra, Pmode));
    5538                 :             : 
    5539                 :             :       /* If we make space by pushing it, we might as well push
    5540                 :             :          the real data.  Otherwise, we can leave OFFSET nonzero
    5541                 :             :          and leave the space uninitialized.  */
    5542                 :           0 :       if (args_addr == 0)
    5543                 :           0 :         offset = 0;
    5544                 :             : 
    5545                 :             :       /* Now NOT_STACK gets the number of words that we don't need to
    5546                 :             :          allocate on the stack.  Convert OFFSET to words too.  */
    5547                 :           0 :       not_stack = (partial - offset) / UNITS_PER_WORD;
    5548                 :           0 :       offset /= UNITS_PER_WORD;
    5549                 :             : 
    5550                 :             :       /* If the partial register-part of the arg counts in its stack size,
    5551                 :             :          skip the part of stack space corresponding to the registers.
    5552                 :             :          Otherwise, start copying to the beginning of the stack space,
    5553                 :             :          by setting SKIP to 0.  */
    5554                 :           0 :       skip = (reg_parm_stack_space == 0) ? 0 : not_stack;
    5555                 :             : 
    5556                 :           0 :       if (CONSTANT_P (x) && !targetm.legitimate_constant_p (mode, x))
    5557                 :           0 :         x = validize_mem (force_const_mem (mode, x));
    5558                 :             : 
    5559                 :             :       /* If X is a hard register in a non-integer mode, copy it into a pseudo;
    5560                 :             :          SUBREGs of such registers are not allowed.  */
    5561                 :           0 :       if ((REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER
    5562                 :           0 :            && GET_MODE_CLASS (GET_MODE (x)) != MODE_INT))
    5563                 :           0 :         x = copy_to_reg (x);
    5564                 :             : 
    5565                 :             :       /* Loop over all the words allocated on the stack for this arg.  */
    5566                 :             :       /* We can do it by words, because any scalar bigger than a word
    5567                 :             :          has a size a multiple of a word.  */
    5568                 :           0 :       tree word_mode_type = lang_hooks.types.type_for_mode (word_mode, 1);
    5569                 :           0 :       for (i = num_words - 1; i >= not_stack; i--)
    5570                 :           0 :         if (i >= not_stack + offset)
    5571                 :           0 :           if (!emit_push_insn (operand_subword_force (x, i, mode),
    5572                 :             :                           word_mode, word_mode_type, NULL_RTX, align, 0,
    5573                 :           0 :                           NULL_RTX, 0, args_addr,
    5574                 :           0 :                           GEN_INT (args_offset + ((i - not_stack + skip)
    5575                 :             :                                                   * UNITS_PER_WORD)),
    5576                 :             :                           reg_parm_stack_space, alignment_pad, sibcall_p))
    5577                 :           0 :             return false;
    5578                 :             :     }
    5579                 :             :   else
    5580                 :             :     {
    5581                 :     1867544 :       rtx addr;
    5582                 :     1867544 :       rtx dest;
    5583                 :             : 
    5584                 :             :       /* Push padding now if padding above and stack grows down,
    5585                 :             :          or if padding below and stack grows up.
    5586                 :             :          But if space already allocated, this has already been done.  */
    5587                 :     1867544 :       if (maybe_ne (extra, 0)
    5588                 :           0 :           && args_addr == 0
    5589                 :           0 :           && where_pad != PAD_NONE
    5590                 :     1867544 :           && where_pad != stack_direction)
    5591                 :           0 :         anti_adjust_stack (gen_int_mode (extra, Pmode));
    5592                 :             : 
    5593                 :             : #ifdef PUSH_ROUNDING
    5594                 :     1867544 :       if (args_addr == 0 && targetm.calls.push_argument (0))
    5595                 :     1812896 :         emit_single_push_insn (mode, x, type);
    5596                 :             :       else
    5597                 :             : #endif
    5598                 :             :         {
    5599                 :       54648 :           addr = simplify_gen_binary (PLUS, Pmode, args_addr, args_so_far);
    5600                 :       54648 :           dest = gen_rtx_MEM (mode, memory_address (mode, addr));
    5601                 :             : 
    5602                 :             :           /* We do *not* set_mem_attributes here, because incoming arguments
    5603                 :             :              may overlap with sibling call outgoing arguments and we cannot
    5604                 :             :              allow reordering of reads from function arguments with stores
    5605                 :             :              to outgoing arguments of sibling calls.  We do, however, want
    5606                 :             :              to record the alignment of the stack slot.  */
    5607                 :             :           /* ALIGN may well be better aligned than TYPE, e.g. due to
    5608                 :             :              PARM_BOUNDARY.  Assume the caller isn't lying.  */
    5609                 :       54648 :           set_mem_align (dest, align);
    5610                 :             : 
    5611                 :       54648 :           emit_move_insn (dest, x);
    5612                 :             :         }
    5613                 :             :     }
    5614                 :             : 
    5615                 :             :   /* Move the partial arguments into the registers and any overlapping
    5616                 :             :      values that we moved into the pseudos in tmp_regs.  */
    5617                 :     2133763 :   if (partial > 0 && reg != 0)
    5618                 :             :     {
    5619                 :             :       /* Handle calls that pass values in multiple non-contiguous locations.
    5620                 :             :          The Irix 6 ABI has examples of this.  */
    5621                 :           0 :       if (GET_CODE (reg) == PARALLEL)
    5622                 :           0 :         emit_group_load (reg, x, type, -1);
    5623                 :             :       else
    5624                 :             :         {
    5625                 :           0 :           gcc_assert (partial % UNITS_PER_WORD == 0);
    5626                 :           0 :           move_block_to_reg (REGNO (reg), x, nregs - overlapping, mode);
    5627                 :             : 
    5628                 :           0 :           for (int i = 0; i < overlapping; i++)
    5629                 :           0 :             emit_move_insn (gen_rtx_REG (word_mode, REGNO (reg)
    5630                 :           0 :                                                     + nregs - overlapping + i),
    5631                 :           0 :                             tmp_regs[i]);
    5632                 :             : 
    5633                 :             :         }
    5634                 :             :     }
    5635                 :             : 
    5636                 :     2133763 :   if (maybe_ne (extra, 0) && args_addr == 0 && where_pad == stack_direction)
    5637                 :           0 :     anti_adjust_stack (gen_int_mode (extra, Pmode));
    5638                 :             : 
    5639                 :     2133763 :   if (alignment_pad && args_addr == 0)
    5640                 :     2079067 :     anti_adjust_stack (alignment_pad);
    5641                 :             : 
    5642                 :             :   return true;
    5643                 :             : }
    5644                 :             : 
    5645                 :             : /* Return X if X can be used as a subtarget in a sequence of arithmetic
    5646                 :             :    operations.  */
    5647                 :             : 
    5648                 :             : static rtx
    5649                 :   188932577 : get_subtarget (rtx x)
    5650                 :             : {
    5651                 :   188932577 :   return (optimize
    5652                 :    50378696 :           || x == 0
    5653                 :             :            /* Only registers can be subtargets.  */
    5654                 :    16889971 :            || !REG_P (x)
    5655                 :             :            /* Don't use hard regs to avoid extending their life.  */
    5656                 :    11549537 :            || REGNO (x) < FIRST_PSEUDO_REGISTER
    5657                 :   188932577 :           ? 0 : x);
    5658                 :             : }
    5659                 :             : 
    5660                 :             : /* A subroutine of expand_assignment.  Optimize FIELD op= VAL, where
    5661                 :             :    FIELD is a bitfield.  Returns true if the optimization was successful,
    5662                 :             :    and there's nothing else to do.  */
    5663                 :             : 
    5664                 :             : static bool
    5665                 :     4553147 : optimize_bitfield_assignment_op (poly_uint64 pbitsize,
    5666                 :             :                                  poly_uint64 pbitpos,
    5667                 :             :                                  poly_uint64 pbitregion_start,
    5668                 :             :                                  poly_uint64 pbitregion_end,
    5669                 :             :                                  machine_mode mode1, rtx str_rtx,
    5670                 :             :                                  tree to, tree src, bool reverse)
    5671                 :             : {
    5672                 :             :   /* str_mode is not guaranteed to be a scalar type.  */
    5673                 :     4553147 :   machine_mode str_mode = GET_MODE (str_rtx);
    5674                 :     4553147 :   unsigned int str_bitsize;
    5675                 :     4553147 :   tree op0, op1;
    5676                 :     4553147 :   rtx value, result;
    5677                 :     4553147 :   optab binop;
    5678                 :     4553147 :   gimple *srcstmt;
    5679                 :     4553147 :   enum tree_code code;
    5680                 :             : 
    5681                 :     4553147 :   unsigned HOST_WIDE_INT bitsize, bitpos, bitregion_start, bitregion_end;
    5682                 :     4553147 :   if (mode1 != VOIDmode
    5683                 :       69392 :       || !pbitsize.is_constant (&bitsize)
    5684                 :       69392 :       || !pbitpos.is_constant (&bitpos)
    5685                 :       69392 :       || !pbitregion_start.is_constant (&bitregion_start)
    5686                 :       69392 :       || !pbitregion_end.is_constant (&bitregion_end)
    5687                 :       69958 :       || bitsize >= BITS_PER_WORD
    5688                 :       69123 :       || !GET_MODE_BITSIZE (str_mode).is_constant (&str_bitsize)
    5689                 :       69689 :       || str_bitsize > BITS_PER_WORD
    5690                 :       63462 :       || TREE_SIDE_EFFECTS (to)
    5691                 :     4616497 :       || TREE_THIS_VOLATILE (to))
    5692                 :             :     return false;
    5693                 :             : 
    5694                 :       63350 :   STRIP_NOPS (src);
    5695                 :       63350 :   if (TREE_CODE (src) != SSA_NAME)
    5696                 :             :     return false;
    5697                 :       21793 :   if (TREE_CODE (TREE_TYPE (src)) != INTEGER_TYPE)
    5698                 :             :     return false;
    5699                 :             : 
    5700                 :       20668 :   srcstmt = get_gimple_for_ssa_name (src);
    5701                 :       20668 :   if (!srcstmt
    5702                 :        4203 :       || !is_gimple_assign (srcstmt)
    5703                 :       24871 :       || TREE_CODE_CLASS (gimple_assign_rhs_code (srcstmt)) != tcc_binary)
    5704                 :             :     return false;
    5705                 :             : 
    5706                 :         419 :   code = gimple_assign_rhs_code (srcstmt);
    5707                 :             : 
    5708                 :         419 :   op0 = gimple_assign_rhs1 (srcstmt);
    5709                 :             : 
    5710                 :             :   /* If OP0 is an SSA_NAME, then we want to walk the use-def chain
    5711                 :             :      to find its initialization.  Hopefully the initialization will
    5712                 :             :      be from a bitfield load.  */
    5713                 :         419 :   if (TREE_CODE (op0) == SSA_NAME)
    5714                 :             :     {
    5715                 :         419 :       gimple *op0stmt = get_gimple_for_ssa_name (op0);
    5716                 :             : 
    5717                 :             :       /* We want to eventually have OP0 be the same as TO, which
    5718                 :             :          should be a bitfield.  */
    5719                 :         419 :       if (!op0stmt
    5720                 :         389 :           || !is_gimple_assign (op0stmt)
    5721                 :         808 :           || gimple_assign_rhs_code (op0stmt) != TREE_CODE (to))
    5722                 :             :         return false;
    5723                 :         299 :       op0 = gimple_assign_rhs1 (op0stmt);
    5724                 :             :     }
    5725                 :             : 
    5726                 :         299 :   op1 = gimple_assign_rhs2 (srcstmt);
    5727                 :             : 
    5728                 :         299 :   if (!operand_equal_p (to, op0, 0))
    5729                 :             :     return false;
    5730                 :             : 
    5731                 :         229 :   if (MEM_P (str_rtx))
    5732                 :             :     {
    5733                 :         224 :       unsigned HOST_WIDE_INT offset1;
    5734                 :             : 
    5735                 :         224 :       if (str_bitsize == 0 || str_bitsize > BITS_PER_WORD)
    5736                 :           4 :         str_bitsize = BITS_PER_WORD;
    5737                 :             : 
    5738                 :         224 :       scalar_int_mode best_mode;
    5739                 :         224 :       if (!get_best_mode (bitsize, bitpos, bitregion_start, bitregion_end,
    5740                 :         224 :                           MEM_ALIGN (str_rtx), str_bitsize, false, &best_mode))
    5741                 :           0 :         return false;
    5742                 :         224 :       str_mode = best_mode;
    5743                 :         224 :       str_bitsize = GET_MODE_BITSIZE (best_mode);
    5744                 :             : 
    5745                 :         224 :       offset1 = bitpos;
    5746                 :         224 :       bitpos %= str_bitsize;
    5747                 :         224 :       offset1 = (offset1 - bitpos) / BITS_PER_UNIT;
    5748                 :         224 :       str_rtx = adjust_address (str_rtx, str_mode, offset1);
    5749                 :             :     }
    5750                 :           5 :   else if (!REG_P (str_rtx) && GET_CODE (str_rtx) != SUBREG)
    5751                 :             :     return false;
    5752                 :             : 
    5753                 :             :   /* If the bit field covers the whole REG/MEM, store_field
    5754                 :             :      will likely generate better code.  */
    5755                 :         229 :   if (bitsize >= str_bitsize)
    5756                 :             :     return false;
    5757                 :             : 
    5758                 :             :   /* We can't handle fields split across multiple entities.  */
    5759                 :         229 :   if (bitpos + bitsize > str_bitsize)
    5760                 :             :     return false;
    5761                 :             : 
    5762                 :         229 :   if (reverse ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN)
    5763                 :           0 :     bitpos = str_bitsize - bitpos - bitsize;
    5764                 :             : 
    5765                 :         229 :   switch (code)
    5766                 :             :     {
    5767                 :         141 :     case PLUS_EXPR:
    5768                 :         141 :     case MINUS_EXPR:
    5769                 :             :       /* For now, just optimize the case of the topmost bitfield
    5770                 :             :          where we don't need to do any masking and also
    5771                 :             :          1 bit bitfields where xor can be used.
    5772                 :             :          We might win by one instruction for the other bitfields
    5773                 :             :          too if insv/extv instructions aren't used, so that
    5774                 :             :          can be added later.  */
    5775                 :         141 :       if ((reverse || bitpos + bitsize != str_bitsize)
    5776                 :          97 :           && (bitsize != 1 || TREE_CODE (op1) != INTEGER_CST))
    5777                 :             :         break;
    5778                 :             : 
    5779                 :          70 :       value = expand_expr (op1, NULL_RTX, str_mode, EXPAND_NORMAL);
    5780                 :          70 :       value = convert_modes (str_mode,
    5781                 :          70 :                              TYPE_MODE (TREE_TYPE (op1)), value,
    5782                 :          70 :                              TYPE_UNSIGNED (TREE_TYPE (op1)));
    5783                 :             : 
    5784                 :             :       /* We may be accessing data outside the field, which means
    5785                 :             :          we can alias adjacent data.  */
    5786                 :          70 :       if (MEM_P (str_rtx))
    5787                 :             :         {
    5788                 :          70 :           str_rtx = shallow_copy_rtx (str_rtx);
    5789                 :          70 :           set_mem_alias_set (str_rtx, 0);
    5790                 :          70 :           set_mem_expr (str_rtx, 0);
    5791                 :             :         }
    5792                 :             : 
    5793                 :          70 :       if (bitsize == 1 && (reverse || bitpos + bitsize != str_bitsize))
    5794                 :             :         {
    5795                 :          26 :           value = expand_and (str_mode, value, const1_rtx, NULL);
    5796                 :          26 :           binop = xor_optab;
    5797                 :             :         }
    5798                 :             :       else
    5799                 :          44 :         binop = code == PLUS_EXPR ? add_optab : sub_optab;
    5800                 :             : 
    5801                 :          70 :       value = expand_shift (LSHIFT_EXPR, str_mode, value, bitpos, NULL_RTX, 1);
    5802                 :          70 :       if (reverse)
    5803                 :           0 :         value = flip_storage_order (str_mode, value);
    5804                 :          70 :       result = expand_binop (str_mode, binop, str_rtx,
    5805                 :             :                              value, str_rtx, 1, OPTAB_WIDEN);
    5806                 :          70 :       if (result != str_rtx)
    5807                 :           0 :         emit_move_insn (str_rtx, result);
    5808                 :             :       return true;
    5809                 :             : 
    5810                 :          58 :     case BIT_IOR_EXPR:
    5811                 :          58 :     case BIT_XOR_EXPR:
    5812                 :          58 :       if (TREE_CODE (op1) != INTEGER_CST)
    5813                 :             :         break;
    5814                 :          55 :       value = expand_expr (op1, NULL_RTX, str_mode, EXPAND_NORMAL);
    5815                 :          55 :       value = convert_modes (str_mode,
    5816                 :          55 :                              TYPE_MODE (TREE_TYPE (op1)), value,
    5817                 :          55 :                              TYPE_UNSIGNED (TREE_TYPE (op1)));
    5818                 :             : 
    5819                 :             :       /* We may be accessing data outside the field, which means
    5820                 :             :          we can alias adjacent data.  */
    5821                 :          55 :       if (MEM_P (str_rtx))
    5822                 :             :         {
    5823                 :          55 :           str_rtx = shallow_copy_rtx (str_rtx);
    5824                 :          55 :           set_mem_alias_set (str_rtx, 0);
    5825                 :          55 :           set_mem_expr (str_rtx, 0);
    5826                 :             :         }
    5827                 :             : 
    5828                 :          55 :       binop = code == BIT_IOR_EXPR ? ior_optab : xor_optab;
    5829                 :          55 :       if (bitpos + bitsize != str_bitsize)
    5830                 :             :         {
    5831                 :          31 :           rtx mask = gen_int_mode ((HOST_WIDE_INT_1U << bitsize) - 1,
    5832                 :             :                                    str_mode);
    5833                 :          31 :           value = expand_and (str_mode, value, mask, NULL_RTX);
    5834                 :             :         }
    5835                 :          55 :       value = expand_shift (LSHIFT_EXPR, str_mode, value, bitpos, NULL_RTX, 1);
    5836                 :          55 :       if (reverse)
    5837                 :           0 :         value = flip_storage_order (str_mode, value);
    5838                 :          55 :       result = expand_binop (str_mode, binop, str_rtx,
    5839                 :             :                              value, str_rtx, 1, OPTAB_WIDEN);
    5840                 :          55 :       if (result != str_rtx)
    5841                 :           0 :         emit_move_insn (str_rtx, result);
    5842                 :             :       return true;
    5843                 :             : 
    5844                 :             :     default:
    5845                 :             :       break;
    5846                 :             :     }
    5847                 :             : 
    5848                 :             :   return false;
    5849                 :             : }
    5850                 :             : 
    5851                 :             : /* In the C++ memory model, consecutive bit fields in a structure are
    5852                 :             :    considered one memory location.
    5853                 :             : 
    5854                 :             :    Given a COMPONENT_REF EXP at position (BITPOS, OFFSET), this function
    5855                 :             :    returns the bit range of consecutive bits in which this COMPONENT_REF
    5856                 :             :    belongs.  The values are returned in *BITSTART and *BITEND.  *BITPOS
    5857                 :             :    and *OFFSET may be adjusted in the process.
    5858                 :             : 
    5859                 :             :    If the access does not need to be restricted, 0 is returned in both
    5860                 :             :    *BITSTART and *BITEND.  */
    5861                 :             : 
    5862                 :             : void
    5863                 :      752978 : get_bit_range (poly_uint64 *bitstart, poly_uint64 *bitend, tree exp,
    5864                 :             :                poly_int64 *bitpos, tree *offset)
    5865                 :             : {
    5866                 :      752978 :   poly_int64 bitoffset;
    5867                 :      752978 :   tree field, repr;
    5868                 :             : 
    5869                 :      752978 :   gcc_assert (TREE_CODE (exp) == COMPONENT_REF);
    5870                 :             : 
    5871                 :      752978 :   field = TREE_OPERAND (exp, 1);
    5872                 :      752978 :   repr = DECL_BIT_FIELD_REPRESENTATIVE (field);
    5873                 :             :   /* If we do not have a DECL_BIT_FIELD_REPRESENTATIVE there is no
    5874                 :             :      need to limit the range we can access.  */
    5875                 :      752978 :   if (!repr)
    5876                 :             :     {
    5877                 :       11617 :       *bitstart = *bitend = 0;
    5878                 :       11617 :       return;
    5879                 :             :     }
    5880                 :             : 
    5881                 :             :   /* If we have a DECL_BIT_FIELD_REPRESENTATIVE but the enclosing record is
    5882                 :             :      part of a larger bit field, then the representative does not serve any
    5883                 :             :      useful purpose.  This can occur in Ada.  */
    5884                 :      741361 :   if (handled_component_p (TREE_OPERAND (exp, 0)))
    5885                 :             :     {
    5886                 :      547932 :       machine_mode rmode;
    5887                 :      547932 :       poly_int64 rbitsize, rbitpos;
    5888                 :      547932 :       tree roffset;
    5889                 :      547932 :       int unsignedp, reversep, volatilep = 0;
    5890                 :      547932 :       get_inner_reference (TREE_OPERAND (exp, 0), &rbitsize, &rbitpos,
    5891                 :             :                            &roffset, &rmode, &unsignedp, &reversep,
    5892                 :             :                            &volatilep);
    5893                 :     1095864 :       if (!multiple_p (rbitpos, BITS_PER_UNIT))
    5894                 :             :         {
    5895                 :           0 :           *bitstart = *bitend = 0;
    5896                 :           0 :           return;
    5897                 :             :         }
    5898                 :             :     }
    5899                 :             : 
    5900                 :             :   /* Compute the adjustment to bitpos from the offset of the field
    5901                 :             :      relative to the representative.  DECL_FIELD_OFFSET of field and
    5902                 :             :      repr are the same by construction if they are not constants,
    5903                 :             :      see finish_bitfield_layout.  */
    5904                 :      741361 :   poly_uint64 field_offset, repr_offset;
    5905                 :      741361 :   if (poly_int_tree_p (DECL_FIELD_OFFSET (field), &field_offset)
    5906                 :     1482717 :       && poly_int_tree_p (DECL_FIELD_OFFSET (repr), &repr_offset))
    5907                 :      741356 :     bitoffset = (field_offset - repr_offset) * BITS_PER_UNIT;
    5908                 :             :   else
    5909                 :             :     bitoffset = 0;
    5910                 :      741361 :   bitoffset += (tree_to_uhwi (DECL_FIELD_BIT_OFFSET (field))
    5911                 :      741361 :                 - tree_to_uhwi (DECL_FIELD_BIT_OFFSET (repr)));
    5912                 :             : 
    5913                 :             :   /* If the adjustment is larger than bitpos, we would have a negative bit
    5914                 :             :      position for the lower bound and this may wreak havoc later.  Adjust
    5915                 :             :      offset and bitpos to make the lower bound non-negative in that case.  */
    5916                 :      741361 :   if (maybe_gt (bitoffset, *bitpos))
    5917                 :             :     {
    5918                 :          11 :       poly_int64 adjust_bits = upper_bound (bitoffset, *bitpos) - *bitpos;
    5919                 :          11 :       poly_int64 adjust_bytes = exact_div (adjust_bits, BITS_PER_UNIT);
    5920                 :             : 
    5921                 :          11 :       *bitpos += adjust_bits;
    5922                 :          11 :       if (*offset == NULL_TREE)
    5923                 :           5 :         *offset = size_int (-adjust_bytes);
    5924                 :             :       else
    5925                 :           6 :         *offset = size_binop (MINUS_EXPR, *offset, size_int (adjust_bytes));
    5926                 :          11 :       *bitstart = 0;
    5927                 :             :     }
    5928                 :             :   else
    5929                 :      741350 :     *bitstart = *bitpos - bitoffset;
    5930                 :             : 
    5931                 :      741361 :   *bitend = *bitstart + tree_to_poly_uint64 (DECL_SIZE (repr)) - 1;
    5932                 :             : }
    5933                 :             : 
    5934                 :             : /* Returns true if BASE is a DECL that does not reside in memory and
    5935                 :             :    has non-BLKmode.  DECL_RTL must not be a MEM; if
    5936                 :             :    DECL_RTL was not set yet, return false.  */
    5937                 :             : 
    5938                 :             : bool
    5939                 :     4514877 : non_mem_decl_p (tree base)
    5940                 :             : {
    5941                 :     4514877 :   if (!DECL_P (base)
    5942                 :     4514576 :       || TREE_ADDRESSABLE (base)
    5943                 :     6728597 :       || DECL_MODE (base) == BLKmode)
    5944                 :             :     return false;
    5945                 :             : 
    5946                 :     1464945 :   if (!DECL_RTL_SET_P (base))
    5947                 :             :     return false;
    5948                 :             : 
    5949                 :     1349144 :   return (!MEM_P (DECL_RTL (base)));
    5950                 :             : }
    5951                 :             : 
    5952                 :             : /* Returns true if REF refers to an object that does not
    5953                 :             :    reside in memory and has non-BLKmode.  */
    5954                 :             : 
    5955                 :             : bool
    5956                 :    10339033 : mem_ref_refers_to_non_mem_p (tree ref)
    5957                 :             : {
    5958                 :    10339033 :   tree base;
    5959                 :             : 
    5960                 :    10339033 :   if (TREE_CODE (ref) == MEM_REF
    5961                 :    10339033 :       || TREE_CODE (ref) == TARGET_MEM_REF)
    5962                 :             :     {
    5963                 :     8802588 :       tree addr = TREE_OPERAND (ref, 0);
    5964                 :             : 
    5965                 :     8802588 :       if (TREE_CODE (addr) != ADDR_EXPR)
    5966                 :             :         return false;
    5967                 :             : 
    5968                 :     2978248 :       base = TREE_OPERAND (addr, 0);
    5969                 :             :     }
    5970                 :             :   else
    5971                 :             :     base = ref;
    5972                 :             : 
    5973                 :     4514693 :   return non_mem_decl_p (base);
    5974                 :             : }
    5975                 :             : 
    5976                 :             : /* Expand an assignment that stores the value of FROM into TO.  If NONTEMPORAL
    5977                 :             :    is true, try generating a nontemporal store.  */
    5978                 :             : 
    5979                 :             : void
    5980                 :    17501732 : expand_assignment (tree to, tree from, bool nontemporal)
    5981                 :             : {
    5982                 :    17501732 :   rtx to_rtx = 0;
    5983                 :    17501732 :   rtx result;
    5984                 :    17501732 :   machine_mode mode;
    5985                 :    17501732 :   unsigned int align;
    5986                 :    17501732 :   enum insn_code icode;
    5987                 :             : 
    5988                 :             :   /* Don't crash if the lhs of the assignment was erroneous.  */
    5989                 :    17501732 :   if (TREE_CODE (to) == ERROR_MARK)
    5990                 :             :     {
    5991                 :           0 :       expand_normal (from);
    5992                 :           0 :       return;
    5993                 :             :     }
    5994                 :             : 
    5995                 :             :   /* Optimize away no-op moves without side-effects.  */
    5996                 :    17501732 :   if (operand_equal_p (to, from, 0))
    5997                 :             :     return;
    5998                 :             : 
    5999                 :             :   /* Handle misaligned stores.  */
    6000                 :    17501659 :   mode = TYPE_MODE (TREE_TYPE (to));
    6001                 :    17501659 :   if ((TREE_CODE (to) == MEM_REF
    6002                 :    17501659 :        || TREE_CODE (to) == TARGET_MEM_REF
    6003                 :    15711194 :        || DECL_P (to))
    6004                 :     3673699 :       && mode != BLKmode
    6005                 :     3215093 :       && !mem_ref_refers_to_non_mem_p (to)
    6006                 :     5654224 :       && ((align = get_object_alignment (to))
    6007                 :     2827112 :           < GET_MODE_ALIGNMENT (mode))
    6008                 :    17924571 :       && (((icode = optab_handler (movmisalign_optab, mode))
    6009                 :             :            != CODE_FOR_nothing)
    6010                 :       95970 :           || targetm.slow_unaligned_access (mode, align)))
    6011                 :             :     {
    6012                 :      326942 :       rtx reg, mem;
    6013                 :             : 
    6014                 :      326942 :       reg = expand_expr (from, NULL_RTX, VOIDmode, EXPAND_NORMAL);
    6015                 :             :       /* Handle PARALLEL.  */
    6016                 :      326942 :       reg = maybe_emit_group_store (reg, TREE_TYPE (from));
    6017                 :      326942 :       reg = force_not_mem (reg);
    6018                 :      326942 :       mem = expand_expr (to, NULL_RTX, VOIDmode, EXPAND_WRITE);
    6019                 :      326942 :       if (TREE_CODE (to) == MEM_REF && REF_REVERSE_STORAGE_ORDER (to))
    6020                 :           0 :         reg = flip_storage_order (mode, reg);
    6021                 :             : 
    6022                 :      326942 :       if (icode != CODE_FOR_nothing)
    6023                 :             :         {
    6024                 :      326942 :           class expand_operand ops[2];
    6025                 :             : 
    6026                 :      326942 :           create_fixed_operand (&ops[0], mem);
    6027                 :      326942 :           create_input_operand (&ops[1], reg, mode);
    6028                 :             :           /* The movmisalign<mode> pattern cannot fail, else the assignment
    6029                 :             :              would silently be omitted.  */
    6030                 :      326942 :           expand_insn (icode, 2, ops);
    6031                 :             :         }
    6032                 :             :       else
    6033                 :           0 :         store_bit_field (mem, GET_MODE_BITSIZE (mode), 0, 0, 0, mode, reg,
    6034                 :             :                          false, false);
    6035                 :      326942 :       return;
    6036                 :             :     }
    6037                 :             : 
    6038                 :             :   /* Assignment of a structure component needs special treatment
    6039                 :             :      if the structure component's rtx is not simply a MEM.
    6040                 :             :      Assignment of an array element at a constant index, and assignment of
    6041                 :             :      an array element in an unaligned packed structure field, has the same
    6042                 :             :      problem.  Same for (partially) storing into a non-memory object.  */
    6043                 :    17174717 :   if (handled_component_p (to)
    6044                 :    12793748 :       || (TREE_CODE (to) == MEM_REF
    6045                 :     1254847 :           && (REF_REVERSE_STORAGE_ORDER (to)
    6046                 :     1254847 :               || mem_ref_refers_to_non_mem_p (to)))
    6047                 :    12740072 :       || TREE_CODE (TREE_TYPE (to)) == ARRAY_TYPE)
    6048                 :             :     {
    6049                 :     4553286 :       machine_mode mode1;
    6050                 :     4553286 :       poly_int64 bitsize, bitpos;
    6051                 :     4553286 :       poly_uint64 bitregion_start = 0;
    6052                 :     4553286 :       poly_uint64 bitregion_end = 0;
    6053                 :     4553286 :       tree offset;
    6054                 :     4553286 :       int unsignedp, reversep, volatilep = 0;
    6055                 :     4553286 :       tree tem;
    6056                 :             : 
    6057                 :     4553286 :       push_temp_slots ();
    6058                 :     4553286 :       tem = get_inner_reference (to, &bitsize, &bitpos, &offset, &mode1,
    6059                 :             :                                  &unsignedp, &reversep, &volatilep);
    6060                 :             : 
    6061                 :             :       /* Make sure bitpos is not negative, it can wreak havoc later.  */
    6062                 :     4553286 :       if (maybe_lt (bitpos, 0))
    6063                 :             :         {
    6064                 :         266 :           gcc_assert (offset == NULL_TREE);
    6065                 :         266 :           offset = size_int (bits_to_bytes_round_down (bitpos));
    6066                 :         266 :           bitpos = num_trailing_bits (bitpos);
    6067                 :             :         }
    6068                 :             : 
    6069                 :     4553286 :       if (TREE_CODE (to) == COMPONENT_REF
    6070                 :     4553286 :           && DECL_BIT_FIELD_TYPE (TREE_OPERAND (to, 1)))
    6071                 :       86074 :         get_bit_range (&bitregion_start, &bitregion_end, to, &bitpos, &offset);
    6072                 :             :       /* The C++ memory model naturally applies to byte-aligned fields.
    6073                 :             :          However, if we do not have a DECL_BIT_FIELD_TYPE but BITPOS or
    6074                 :             :          BITSIZE are not byte-aligned, there is no need to limit the range
    6075                 :             :          we can access.  This can occur with packed structures in Ada.  */
    6076                 :     4467212 :       else if (maybe_gt (bitsize, 0)
    6077                 :     4467197 :                && multiple_p (bitsize, BITS_PER_UNIT)
    6078                 :     8934261 :                && multiple_p (bitpos, BITS_PER_UNIT))
    6079                 :             :         {
    6080                 :     4467049 :           bitregion_start = bitpos;
    6081                 :     4467049 :           bitregion_end = bitpos + bitsize - 1;
    6082                 :             :         }
    6083                 :             : 
    6084                 :     4553286 :       to_rtx = expand_expr (tem, NULL_RTX, VOIDmode, EXPAND_WRITE);
    6085                 :             : 
    6086                 :             :       /* If the field has a mode, we want to access it in the
    6087                 :             :          field's mode, not the computed mode.
    6088                 :             :          If a MEM has VOIDmode (external with incomplete type),
    6089                 :             :          use BLKmode for it instead.  */
    6090                 :     4553286 :       if (MEM_P (to_rtx))
    6091                 :             :         {
    6092                 :     3882918 :           if (mode1 != VOIDmode)
    6093                 :     3814234 :             to_rtx = adjust_address (to_rtx, mode1, 0);
    6094                 :       68684 :           else if (GET_MODE (to_rtx) == VOIDmode)
    6095                 :           0 :             to_rtx = adjust_address (to_rtx, BLKmode, 0);
    6096                 :             :         }
    6097                 :             : 
    6098                 :     4553286 :       rtx stemp = NULL_RTX, old_to_rtx = NULL_RTX;
    6099                 :     4553286 :       if (offset != 0)
    6100                 :             :         {
    6101                 :      174256 :           machine_mode address_mode;
    6102                 :      174256 :           rtx offset_rtx;
    6103                 :             : 
    6104                 :      174256 :           if (!MEM_P (to_rtx))
    6105                 :             :             {
    6106                 :             :               /* We can get constant negative offsets into arrays with broken
    6107                 :             :                  user code.  Translate this to a trap instead of ICEing.  */
    6108                 :           4 :               if (TREE_CODE (offset) == INTEGER_CST)
    6109                 :             :                 {
    6110                 :           1 :                   expand_builtin_trap ();
    6111                 :           1 :                   to_rtx = gen_rtx_MEM (BLKmode, const0_rtx);
    6112                 :             :                 }
    6113                 :             :               /* Else spill for variable offset to the destination.  We expect
    6114                 :             :                  to run into this only for hard registers.  */
    6115                 :             :               else
    6116                 :             :                 {
    6117                 :           3 :                   gcc_assert (VAR_P (tem) && DECL_HARD_REGISTER (tem));
    6118                 :           3 :                   stemp = assign_stack_temp (GET_MODE (to_rtx),
    6119                 :           6 :                                              GET_MODE_SIZE (GET_MODE (to_rtx)));
    6120                 :           3 :                   emit_move_insn (stemp, to_rtx);
    6121                 :           3 :                   old_to_rtx = to_rtx;
    6122                 :           3 :                   to_rtx = stemp;
    6123                 :             :                 }
    6124                 :             :             }
    6125                 :             : 
    6126                 :      174256 :           offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, EXPAND_SUM);
    6127                 :      174256 :           address_mode = get_address_mode (to_rtx);
    6128                 :      174256 :           if (GET_MODE (offset_rtx) != address_mode)
    6129                 :             :             {
    6130                 :             :                 /* We cannot be sure that the RTL in offset_rtx is valid outside
    6131                 :             :                    of a memory address context, so force it into a register
    6132                 :             :                    before attempting to convert it to the desired mode.  */
    6133                 :         290 :               offset_rtx = force_operand (offset_rtx, NULL_RTX);
    6134                 :         290 :               offset_rtx = convert_to_mode (address_mode, offset_rtx, 0);
    6135                 :             :             }
    6136                 :             : 
    6137                 :             :           /* If we have an expression in OFFSET_RTX and a non-zero
    6138                 :             :              byte offset in BITPOS, adding the byte offset before the
    6139                 :             :              OFFSET_RTX results in better intermediate code, which makes
    6140                 :             :              later rtl optimization passes perform better.
    6141                 :             : 
    6142                 :             :              We prefer intermediate code like this:
    6143                 :             : 
    6144                 :             :              r124:DI=r123:DI+0x18
    6145                 :             :              [r124:DI]=r121:DI
    6146                 :             : 
    6147                 :             :              ... instead of ...
    6148                 :             : 
    6149                 :             :              r124:DI=r123:DI+0x10
    6150                 :             :              [r124:DI+0x8]=r121:DI
    6151                 :             : 
    6152                 :             :              This is only done for aligned data values, as these can
    6153                 :             :              be expected to result in single move instructions.  */
    6154                 :      174256 :           poly_int64 bytepos;
    6155                 :      174256 :           if (mode1 != VOIDmode
    6156                 :      174150 :               && maybe_ne (bitpos, 0)
    6157                 :       49094 :               && maybe_gt (bitsize, 0)
    6158                 :      223350 :               && multiple_p (bitpos, BITS_PER_UNIT, &bytepos)
    6159                 :      223290 :               && multiple_p (bitpos, bitsize)
    6160                 :       98068 :               && multiple_p (bitsize, GET_MODE_ALIGNMENT (mode1))
    6161                 :      223290 :               && MEM_ALIGN (to_rtx) >= GET_MODE_ALIGNMENT (mode1))
    6162                 :             :             {
    6163                 :       49019 :               to_rtx = adjust_address (to_rtx, mode1, bytepos);
    6164                 :       49019 :               bitregion_start = 0;
    6165                 :       49019 :               if (known_ge (bitregion_end, poly_uint64 (bitpos)))
    6166                 :       49019 :                 bitregion_end -= bitpos;
    6167                 :       49019 :               bitpos = 0;
    6168                 :             :             }
    6169                 :             : 
    6170                 :      174256 :           to_rtx = offset_address (to_rtx, offset_rtx,
    6171                 :             :                                    highest_pow2_factor_for_target (to,
    6172                 :             :                                                                    offset));
    6173                 :             :         }
    6174                 :             : 
    6175                 :             :       /* No action is needed if the target is not a memory and the field
    6176                 :             :          lies completely outside that target.  This can occur if the source
    6177                 :             :          code contains an out-of-bounds access to a small array.  */
    6178                 :     4553286 :       if (!MEM_P (to_rtx)
    6179                 :      670364 :           && GET_MODE (to_rtx) != BLKmode
    6180                 :     5223650 :           && known_ge (bitpos, GET_MODE_PRECISION (GET_MODE (to_rtx))))
    6181                 :             :         {
    6182                 :           3 :           expand_normal (from);
    6183                 :           3 :           result = NULL;
    6184                 :             :         }
    6185                 :             :       /* Handle expand_expr of a complex value returning a CONCAT.  */
    6186                 :     4553283 :       else if (GET_CODE (to_rtx) == CONCAT)
    6187                 :             :         {
    6188                 :         130 :           machine_mode to_mode = GET_MODE (to_rtx);
    6189                 :         130 :           gcc_checking_assert (COMPLEX_MODE_P (to_mode));
    6190                 :         260 :           poly_int64 mode_bitsize = GET_MODE_BITSIZE (to_mode);
    6191                 :         130 :           unsigned short inner_bitsize = GET_MODE_UNIT_BITSIZE (to_mode);
    6192                 :         130 :           if (TYPE_MODE (TREE_TYPE (from)) == to_mode
    6193                 :           6 :               && known_eq (bitpos, 0)
    6194                 :         136 :               && known_eq (bitsize, mode_bitsize))
    6195                 :           6 :             result = store_expr (from, to_rtx, false, nontemporal, reversep);
    6196                 :         124 :           else if (TYPE_MODE (TREE_TYPE (from)) == GET_MODE_INNER (to_mode)
    6197                 :          76 :                    && known_eq (bitsize, inner_bitsize)
    6198                 :         200 :                    && (known_eq (bitpos, 0)
    6199                 :          34 :                        || known_eq (bitpos, inner_bitsize)))
    6200                 :          76 :             result = store_expr (from, XEXP (to_rtx, maybe_ne (bitpos, 0)),
    6201                 :             :                                  false, nontemporal, reversep);
    6202                 :          48 :           else if (known_le (bitpos + bitsize, inner_bitsize))
    6203                 :           5 :             result = store_field (XEXP (to_rtx, 0), bitsize, bitpos,
    6204                 :             :                                   bitregion_start, bitregion_end,
    6205                 :             :                                   mode1, from, get_alias_set (to),
    6206                 :             :                                   nontemporal, reversep);
    6207                 :          43 :           else if (known_ge (bitpos, inner_bitsize))
    6208                 :           3 :             result = store_field (XEXP (to_rtx, 1), bitsize,
    6209                 :             :                                   bitpos - inner_bitsize,
    6210                 :             :                                   bitregion_start, bitregion_end,
    6211                 :             :                                   mode1, from, get_alias_set (to),
    6212                 :             :                                   nontemporal, reversep);
    6213                 :          40 :           else if (known_eq (bitpos, 0) && known_eq (bitsize, mode_bitsize))
    6214                 :             :             {
    6215                 :          33 :               result = expand_normal (from);
    6216                 :          33 :               if (GET_CODE (result) == CONCAT)
    6217                 :             :                 {
    6218                 :           0 :                   to_mode = GET_MODE_INNER (to_mode);
    6219                 :           0 :                   machine_mode from_mode = GET_MODE_INNER (GET_MODE (result));
    6220                 :           0 :                   rtx from_real
    6221                 :           0 :                     = force_subreg (to_mode, XEXP (result, 0), from_mode, 0);
    6222                 :           0 :                   rtx from_imag
    6223                 :           0 :                     = force_subreg (to_mode, XEXP (result, 1), from_mode, 0);
    6224                 :           0 :                   if (!from_real || !from_imag)
    6225                 :           0 :                     goto concat_store_slow;
    6226                 :           0 :                   emit_move_insn (XEXP (to_rtx, 0), from_real);
    6227                 :           0 :                   emit_move_insn (XEXP (to_rtx, 1), from_imag);
    6228                 :             :                 }
    6229                 :             :               else
    6230                 :             :                 {
    6231                 :          33 :                   machine_mode from_mode
    6232                 :          33 :                     = GET_MODE (result) == VOIDmode
    6233                 :          33 :                       ? TYPE_MODE (TREE_TYPE (from))
    6234                 :          33 :                       : GET_MODE (result);
    6235                 :          33 :                   rtx from_rtx;
    6236                 :          33 :                   if (MEM_P (result))
    6237                 :           1 :                     from_rtx = change_address (result, to_mode, NULL_RTX);
    6238                 :             :                   else
    6239                 :          32 :                     from_rtx = force_subreg (to_mode, result, from_mode, 0);
    6240                 :          33 :                   if (from_rtx)
    6241                 :             :                     {
    6242                 :          33 :                       emit_move_insn (XEXP (to_rtx, 0),
    6243                 :             :                                       read_complex_part (from_rtx, false));
    6244                 :          33 :                       emit_move_insn (XEXP (to_rtx, 1),
    6245                 :             :                                       read_complex_part (from_rtx, true));
    6246                 :             :                     }
    6247                 :             :                   else
    6248                 :             :                     {
    6249                 :           0 :                       to_mode = GET_MODE_INNER (to_mode);
    6250                 :           0 :                       rtx from_real
    6251                 :           0 :                         = force_subreg (to_mode, result, from_mode, 0);
    6252                 :           0 :                       rtx from_imag
    6253                 :           0 :                         = force_subreg (to_mode, result, from_mode,
    6254                 :           0 :                                         GET_MODE_SIZE (to_mode));
    6255                 :           0 :                       if (!from_real || !from_imag)
    6256                 :           0 :                         goto concat_store_slow;
    6257                 :           0 :                       emit_move_insn (XEXP (to_rtx, 0), from_real);
    6258                 :           0 :                       emit_move_insn (XEXP (to_rtx, 1), from_imag);
    6259                 :             :                     }
    6260                 :             :                 }
    6261                 :             :             }
    6262                 :             :           else
    6263                 :             :             {
    6264                 :           7 :             concat_store_slow:;
    6265                 :           7 :               rtx temp = assign_stack_temp (GET_MODE (to_rtx),
    6266                 :          14 :                                             GET_MODE_SIZE (GET_MODE (to_rtx)));
    6267                 :           7 :               write_complex_part (temp, XEXP (to_rtx, 0), false, true);
    6268                 :           7 :               write_complex_part (temp, XEXP (to_rtx, 1), true, false);
    6269                 :           7 :               result = store_field (temp, bitsize, bitpos,
    6270                 :             :                                     bitregion_start, bitregion_end,
    6271                 :             :                                     mode1, from, get_alias_set (to),
    6272                 :             :                                     nontemporal, reversep);
    6273                 :           7 :               emit_move_insn (XEXP (to_rtx, 0), read_complex_part (temp, false));
    6274                 :           7 :               emit_move_insn (XEXP (to_rtx, 1), read_complex_part (temp, true));
    6275                 :             :             }
    6276                 :             :         }
    6277                 :             :       /* For calls to functions returning variable length structures, if TO_RTX
    6278                 :             :          is not a MEM, go through a MEM because we must not create temporaries
    6279                 :             :          of the VLA type.  */
    6280                 :     4553153 :       else if (!MEM_P (to_rtx)
    6281                 :      670231 :                && TREE_CODE (from) == CALL_EXPR
    6282                 :         757 :                && COMPLETE_TYPE_P (TREE_TYPE (from))
    6283                 :     4553910 :                && TREE_CODE (TYPE_SIZE (TREE_TYPE (from))) != INTEGER_CST)
    6284                 :             :         {
    6285                 :           6 :           rtx temp = assign_stack_temp (GET_MODE (to_rtx),
    6286                 :          12 :                                         GET_MODE_SIZE (GET_MODE (to_rtx)));
    6287                 :           6 :           result = store_field (temp, bitsize, bitpos, bitregion_start,
    6288                 :             :                                 bitregion_end, mode1, from, get_alias_set (to),
    6289                 :             :                                 nontemporal, reversep);
    6290                 :           6 :           emit_move_insn (to_rtx, temp);
    6291                 :             :         }
    6292                 :             :       else
    6293                 :             :         {
    6294                 :     4553147 :           if (MEM_P (to_rtx))
    6295                 :             :             {
    6296                 :             :               /* If the field is at offset zero, we could have been given the
    6297                 :             :                  DECL_RTX of the parent struct.  Don't munge it.  */
    6298                 :     3882922 :               to_rtx = shallow_copy_rtx (to_rtx);
    6299                 :     3882922 :               set_mem_attributes_minus_bitpos (to_rtx, to, 0, bitpos);
    6300                 :     3882922 :               if (volatilep)
    6301                 :        6754 :                 MEM_VOLATILE_P (to_rtx) = 1;
    6302                 :             :             }
    6303                 :             : 
    6304                 :     4553147 :           gcc_checking_assert (known_ge (bitpos, 0));
    6305                 :     4553147 :           if (optimize_bitfield_assignment_op (bitsize, bitpos,
    6306                 :             :                                                bitregion_start, bitregion_end,
    6307                 :             :                                                mode1, to_rtx, to, from,
    6308                 :             :                                                reversep))
    6309                 :             :             result = NULL;
    6310                 :     4553022 :           else if (SUBREG_P (to_rtx)
    6311                 :     4553022 :                    && SUBREG_PROMOTED_VAR_P (to_rtx))
    6312                 :             :             {
    6313                 :             :               /* If to_rtx is a promoted subreg, we need to zero or sign
    6314                 :             :                  extend the value afterwards.  */
    6315                 :           0 :               if (TREE_CODE (to) == MEM_REF
    6316                 :           0 :                   && TYPE_MODE (TREE_TYPE (from)) != BLKmode
    6317                 :           0 :                   && !REF_REVERSE_STORAGE_ORDER (to)
    6318                 :           0 :                   && known_eq (bitpos, 0)
    6319                 :           0 :                   && known_eq (bitsize, GET_MODE_BITSIZE (GET_MODE (to_rtx))))
    6320                 :           0 :                 result = store_expr (from, to_rtx, 0, nontemporal, false);
    6321                 :             :               /* Check if the field overlaps the MSB, requiring extension.  */
    6322                 :           0 :               else if (maybe_eq (bitpos + bitsize,
    6323                 :           0 :                                  GET_MODE_BITSIZE (GET_MODE (to_rtx))))
    6324                 :             :                 {
    6325                 :           0 :                   scalar_int_mode imode = subreg_unpromoted_mode (to_rtx);
    6326                 :           0 :                   scalar_int_mode omode = subreg_promoted_mode (to_rtx);
    6327                 :           0 :                   rtx to_rtx1 = lowpart_subreg (imode, SUBREG_REG (to_rtx),
    6328                 :             :                                                 omode);
    6329                 :           0 :                   result = store_field (to_rtx1, bitsize, bitpos,
    6330                 :             :                                         bitregion_start, bitregion_end,
    6331                 :             :                                         mode1, from, get_alias_set (to),
    6332                 :             :                                         nontemporal, reversep);
    6333                 :             :                   /* If the target usually keeps IMODE appropriately
    6334                 :             :                      extended in OMODE it's unsafe to refer to it using
    6335                 :             :                      a SUBREG whilst this invariant doesn't hold.  */
    6336                 :           0 :                   if (targetm.mode_rep_extended (imode, omode) != UNKNOWN)
    6337                 :           0 :                     to_rtx1 = simplify_gen_unary (TRUNCATE, imode,
    6338                 :             :                                                   SUBREG_REG (to_rtx), omode);
    6339                 :           0 :                   convert_move (SUBREG_REG (to_rtx), to_rtx1,
    6340                 :           0 :                                 SUBREG_PROMOTED_SIGN (to_rtx));
    6341                 :             :                 }
    6342                 :             :               else
    6343                 :           0 :                 result = store_field (to_rtx, bitsize, bitpos,
    6344                 :             :                                       bitregion_start, bitregion_end,
    6345                 :             :                                       mode1, from, get_alias_set (to),
    6346                 :             :                                       nontemporal, reversep);
    6347                 :             :             }
    6348                 :             :           else
    6349                 :     4553022 :             result = store_field (to_rtx, bitsize, bitpos,
    6350                 :             :                                   bitregion_start, bitregion_end,
    6351                 :             :                                   mode1, from, get_alias_set (to),
    6352                 :             :                                   nontemporal, reversep);
    6353                 :             :           /* Move the temporary storage back to the non-MEM_P.  */
    6354                 :     4553147 :           if (stemp)
    6355                 :           3 :             emit_move_insn (old_to_rtx, stemp);
    6356                 :             :         }
    6357                 :             : 
    6358                 :     4553286 :       if (result)
    6359                 :      812218 :         preserve_temp_slots (result);
    6360                 :     4553286 :       pop_temp_slots ();
    6361                 :     4553286 :       return;
    6362                 :             :     }
    6363                 :             : 
    6364                 :             :   /* If the rhs is a function call and its value is not an aggregate,
    6365                 :             :      call the function before we start to compute the lhs.
    6366                 :             :      This is needed for correct code for cases such as
    6367                 :             :      val = setjmp (buf) on machines where reference to val
    6368                 :             :      requires loading up part of an address in a separate insn.
    6369                 :             : 
    6370                 :             :      Don't do this if TO is a VAR_DECL or PARM_DECL whose DECL_RTL is REG
    6371                 :             :      since it might be a promoted variable where the zero- or sign- extension
    6372                 :             :      needs to be done.  Handling this in the normal way is safe because no
    6373                 :             :      computation is done before the call.  The same is true for SSA names.  */
    6374                 :     2211058 :   if (TREE_CODE (from) == CALL_EXPR && ! aggregate_value_p (from, from)
    6375                 :     2014506 :       && COMPLETE_TYPE_P (TREE_TYPE (from))
    6376                 :     2014506 :       && TREE_CODE (TYPE_SIZE (TREE_TYPE (from))) == INTEGER_CST
    6377                 :    14635937 :       && ! (((VAR_P (to)
    6378                 :             :               || TREE_CODE (to) == PARM_DECL
    6379                 :             :               || TREE_CODE (to) == RESULT_DECL)
    6380                 :      123583 :              && REG_P (DECL_RTL (to)))
    6381                 :     1898343 :             || TREE_CODE (to) == SSA_NAME))
    6382                 :             :     {
    6383                 :        7644 :       rtx value;
    6384                 :             : 
    6385                 :        7644 :       push_temp_slots ();
    6386                 :        7644 :       value = expand_normal (from);
    6387                 :             : 
    6388                 :        7644 :       if (to_rtx == 0)
    6389                 :        7644 :         to_rtx = expand_expr (to, NULL_RTX, VOIDmode, EXPAND_WRITE);
    6390                 :             : 
    6391                 :             :       /* Handle calls that return values in multiple non-contiguous locations.
    6392                 :             :          The Irix 6 ABI has examples of this.  */
    6393                 :        7644 :       if (GET_CODE (to_rtx) == PARALLEL)
    6394                 :             :         {
    6395                 :           0 :           if (GET_CODE (value) == PARALLEL)
    6396                 :           0 :             emit_group_move (to_rtx, value);
    6397                 :             :           else
    6398                 :           0 :             emit_group_load (to_rtx, value, TREE_TYPE (from),
    6399                 :           0 :                              int_size_in_bytes (TREE_TYPE (from)));
    6400                 :             :         }
    6401                 :        7644 :       else if (GET_CODE (value) == PARALLEL)
    6402                 :        1664 :         emit_group_store (to_rtx, value, TREE_TYPE (from),
    6403                 :        1664 :                           int_size_in_bytes (TREE_TYPE (from)));
    6404                 :        5980 :       else if (GET_MODE (to_rtx) == BLKmode)
    6405                 :             :         {
    6406                 :             :           /* Handle calls that return BLKmode values in registers.  */
    6407                 :         249 :           if (REG_P (value))
    6408                 :         249 :             copy_blkmode_from_reg (to_rtx, value, TREE_TYPE (from));
    6409                 :             :           else
    6410                 :           0 :             emit_block_move (to_rtx, value, expr_size (from), BLOCK_OP_NORMAL);
    6411                 :             :         }
    6412                 :             :       else
    6413                 :             :         {
    6414                 :        5731 :           if (POINTER_TYPE_P (TREE_TYPE (to)))
    6415                 :           0 :             value = convert_memory_address_addr_space
    6416                 :           0 :               (as_a <scalar_int_mode> (GET_MODE (to_rtx)), value,
    6417                 :           0 :                TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (to))));
    6418                 :             : 
    6419                 :        5731 :           emit_move_insn (to_rtx, value);
    6420                 :             :         }
    6421                 :             : 
    6422                 :        7644 :       preserve_temp_slots (to_rtx);
    6423                 :        7644 :       pop_temp_slots ();
    6424                 :        7644 :       return;
    6425                 :             :     }
    6426                 :             : 
    6427                 :             :   /* Ordinary treatment.  Expand TO to get a REG or MEM rtx.  */
    6428                 :    12613787 :   to_rtx = expand_expr (to, NULL_RTX, VOIDmode, EXPAND_WRITE);
    6429                 :             : 
    6430                 :             :   /* Don't move directly into a return register.  */
    6431                 :    12613787 :   if (TREE_CODE (to) == RESULT_DECL
    6432                 :       16119 :       && (REG_P (to_rtx) || GET_CODE (to_rtx) == PARALLEL))
    6433                 :             :     {
    6434                 :          43 :       rtx temp;
    6435                 :             : 
    6436                 :          43 :       push_temp_slots ();
    6437                 :             : 
    6438                 :             :       /* If the source is itself a return value, it still is in a pseudo at
    6439                 :             :          this point so we can move it back to the return register directly.  */
    6440                 :          43 :       if (REG_P (to_rtx)
    6441                 :          43 :           && TYPE_MODE (TREE_TYPE (from)) == BLKmode
    6442                 :          43 :           && TREE_CODE (from) != CALL_EXPR)
    6443                 :           0 :         temp = copy_blkmode_to_reg (GET_MODE (to_rtx), from);
    6444                 :             :       else
    6445                 :          43 :         temp = expand_expr (from, NULL_RTX, GET_MODE (to_rtx), EXPAND_NORMAL);
    6446                 :             : 
    6447                 :             :       /* Handle calls that return values in multiple non-contiguous locations.
    6448                 :             :          The Irix 6 ABI has examples of this.  */
    6449                 :          43 :       if (GET_CODE (to_rtx) == PARALLEL)
    6450                 :             :         {
    6451                 :           0 :           if (GET_CODE (temp) == PARALLEL)
    6452                 :           0 :             emit_group_move (to_rtx, temp);
    6453                 :             :           else
    6454                 :           0 :             emit_group_load (to_rtx, temp, TREE_TYPE (from),
    6455                 :           0 :                              int_size_in_bytes (TREE_TYPE (from)));
    6456                 :             :         }
    6457                 :          43 :       else if (temp)
    6458                 :          43 :         emit_move_insn (to_rtx, temp);
    6459                 :             : 
    6460                 :          43 :       preserve_temp_slots (to_rtx);
    6461                 :          43 :       pop_temp_slots ();
    6462                 :          43 :       return;
    6463                 :             :     }
    6464                 :             : 
    6465                 :             :   /* In case we are returning the contents of an object which overlaps
    6466                 :             :      the place the value is being stored, use a safe function when copying
    6467                 :             :      a value through a pointer into a structure value return block.  */
    6468                 :    12613744 :   if (TREE_CODE (to) == RESULT_DECL
    6469                 :       16076 :       && TREE_CODE (from) == INDIRECT_REF
    6470                 :           0 :       && ADDR_SPACE_GENERIC_P
    6471                 :             :            (TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (from, 0)))))
    6472                 :           0 :       && refs_may_alias_p (to, from)
    6473                 :           0 :       && cfun->returns_struct
    6474                 :    12613744 :       && !cfun->returns_pcc_struct)
    6475                 :             :     {
    6476                 :           0 :       rtx from_rtx, size;
    6477                 :             : 
    6478                 :           0 :       push_temp_slots ();
    6479                 :           0 :       size = expr_size (from);
    6480                 :           0 :       from_rtx = expand_normal (from);
    6481                 :             : 
    6482                 :           0 :       emit_block_move_via_libcall (XEXP (to_rtx, 0), XEXP (from_rtx, 0), size);
    6483                 :             : 
    6484                 :           0 :       preserve_temp_slots (to_rtx);
    6485                 :           0 :       pop_temp_slots ();
    6486                 :           0 :       return;
    6487                 :             :     }
    6488                 :             : 
    6489                 :             :   /* Compute FROM and store the value in the rtx we got.  */
    6490                 :             : 
    6491                 :    12613744 :   push_temp_slots ();
    6492                 :    12613744 :   result = store_expr (from, to_rtx, 0, nontemporal, false);
    6493                 :    12613744 :   preserve_temp_slots (result);
    6494                 :    12613744 :   pop_temp_slots ();
    6495                 :    12613744 :   return;
    6496                 :             : }
    6497                 :             : 
    6498                 :             : /* Emits nontemporal store insn that moves FROM to TO.  Returns true if this
    6499                 :             :    succeeded, false otherwise.  */
    6500                 :             : 
    6501                 :             : bool
    6502                 :          17 : emit_storent_insn (rtx to, rtx from)
    6503                 :             : {
    6504                 :          17 :   class expand_operand ops[2];
    6505                 :          17 :   machine_mode mode = GET_MODE (to);
    6506                 :          17 :   enum insn_code code = optab_handler (storent_optab, mode);
    6507                 :             : 
    6508                 :          17 :   if (code == CODE_FOR_nothing)
    6509                 :             :     return false;
    6510                 :             : 
    6511                 :          17 :   create_fixed_operand (&ops[0], to);
    6512                 :          17 :   create_input_operand (&ops[1], from, mode);
    6513                 :          17 :   return maybe_expand_insn (code, 2, ops);
    6514                 :             : }
    6515                 :             : 
    6516                 :             : /* Helper function for store_expr storing of STRING_CST.  */
    6517                 :             : 
    6518                 :             : static rtx
    6519                 :       84278 : string_cst_read_str (void *data, void *, HOST_WIDE_INT offset,
    6520                 :             :                      fixed_size_mode mode)
    6521                 :             : {
    6522                 :       84278 :   tree str = (tree) data;
    6523                 :             : 
    6524                 :       84278 :   gcc_assert (offset >= 0);
    6525                 :       84278 :   if (offset >= TREE_STRING_LENGTH (str))
    6526                 :        3498 :     return const0_rtx;
    6527                 :             : 
    6528                 :       80780 :   if ((unsigned HOST_WIDE_INT) offset + GET_MODE_SIZE (mode)
    6529                 :       80780 :       > (unsigned HOST_WIDE_INT) TREE_STRING_LENGTH (str))
    6530                 :             :     {
    6531                 :        2499 :       char *p = XALLOCAVEC (char, GET_MODE_SIZE (mode));
    6532                 :        2499 :       size_t l = TREE_STRING_LENGTH (str) - offset;
    6533                 :        2499 :       memcpy (p, TREE_STRING_POINTER (str) + offset, l);
    6534                 :        2499 :       memset (p + l, '\0', GET_MODE_SIZE (mode) - l);
    6535                 :        2499 :       return c_readstr (p, mode, false);
    6536                 :             :     }
    6537                 :             : 
    6538                 :       78281 :   return c_readstr (TREE_STRING_POINTER (str) + offset, mode, false);
    6539                 :             : }
    6540                 :             : 
    6541                 :             : /* Generate code for computing expression EXP,
    6542                 :             :    and storing the value into TARGET.
    6543                 :             : 
    6544                 :             :    If the mode is BLKmode then we may return TARGET itself.
    6545                 :             :    It turns out that in BLKmode it doesn't cause a problem.
    6546                 :             :    because C has no operators that could combine two different
    6547                 :             :    assignments into the same BLKmode object with different values
    6548                 :             :    with no sequence point.  Will other languages need this to
    6549                 :             :    be more thorough?
    6550                 :             : 
    6551                 :             :    If CALL_PARAM_P is nonzero, this is a store into a call param on the
    6552                 :             :    stack, and block moves may need to be treated specially.
    6553                 :             : 
    6554                 :             :    If NONTEMPORAL is true, try using a nontemporal store instruction.
    6555                 :             : 
    6556                 :             :    If REVERSE is true, the store is to be done in reverse order.  */
    6557                 :             : 
    6558                 :             : rtx
    6559                 :    16391781 : store_expr (tree exp, rtx target, int call_param_p,
    6560                 :             :             bool nontemporal, bool reverse)
    6561                 :             : {
    6562                 :    16391781 :   rtx temp;
    6563                 :    16391781 :   rtx alt_rtl = NULL_RTX;
    6564                 :    16391781 :   location_t loc = curr_insn_location ();
    6565                 :    16391781 :   bool shortened_string_cst = false;
    6566                 :             : 
    6567                 :    16391781 :   if (VOID_TYPE_P (TREE_TYPE (exp)))
    6568                 :             :     {
    6569                 :             :       /* C++ can generate ?: expressions with a throw expression in one
    6570                 :             :          branch and an rvalue in the other. Here, we resolve attempts to
    6571                 :             :          store the throw expression's nonexistent result.  */
    6572                 :           0 :       gcc_assert (!call_param_p);
    6573                 :           0 :       expand_expr (exp, const0_rtx, VOIDmode, EXPAND_NORMAL);
    6574                 :           0 :       return NULL_RTX;
    6575                 :             :     }
    6576                 :    16391781 :   if (TREE_CODE (exp) == COMPOUND_EXPR)
    6577                 :             :     {
    6578                 :             :       /* Perform first part of compound expression, then assign from second
    6579                 :             :          part.  */
    6580                 :           0 :       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode,
    6581                 :             :                    call_param_p ? EXPAND_STACK_PARM : EXPAND_NORMAL);
    6582                 :           0 :       return store_expr (TREE_OPERAND (exp, 1), target,
    6583                 :           0 :                                      call_param_p, nontemporal, reverse);
    6584                 :             :     }
    6585                 :    16391781 :   else if (TREE_CODE (exp) == COND_EXPR && GET_MODE (target) == BLKmode)
    6586                 :             :     {
    6587                 :             :       /* For conditional expression, get safe form of the target.  Then
    6588                 :             :          test the condition, doing the appropriate assignment on either
    6589                 :             :          side.  This avoids the creation of unnecessary temporaries.
    6590                 :             :          For non-BLKmode, it is more efficient not to do this.  */
    6591                 :             : 
    6592                 :           0 :       rtx_code_label *lab1 = gen_label_rtx (), *lab2 = gen_label_rtx ();
    6593                 :             : 
    6594                 :           0 :       do_pending_stack_adjust ();
    6595                 :           0 :       NO_DEFER_POP;
    6596                 :           0 :       jumpifnot (TREE_OPERAND (exp, 0), lab1,
    6597                 :             :                  profile_probability::uninitialized ());
    6598                 :           0 :       store_expr (TREE_OPERAND (exp, 1), target, call_param_p,
    6599                 :             :                   nontemporal, reverse);
    6600                 :           0 :       emit_jump_insn (targetm.gen_jump (lab2));
    6601                 :           0 :       emit_barrier ();
    6602                 :           0 :       emit_label (lab1);
    6603                 :           0 :       store_expr (TREE_OPERAND (exp, 2), target, call_param_p,
    6604                 :             :                   nontemporal, reverse);
    6605                 :           0 :       emit_label (lab2);
    6606                 :           0 :       OK_DEFER_POP;
    6607                 :             : 
    6608                 :           0 :       return NULL_RTX;
    6609                 :             :     }
    6610                 :    16391781 :   else if (GET_CODE (target) == SUBREG && SUBREG_PROMOTED_VAR_P (target))
    6611                 :             :     /* If this is a scalar in a register that is stored in a wider mode
    6612                 :             :        than the declared mode, compute the result into its declared mode
    6613                 :             :        and then convert to the wider mode.  Our value is the computed
    6614                 :             :        expression.  */
    6615                 :             :     {
    6616                 :           7 :       rtx inner_target = 0;
    6617                 :           7 :       scalar_int_mode outer_mode = subreg_unpromoted_mode (target);
    6618                 :           7 :       scalar_int_mode inner_mode = subreg_promoted_mode (target);
    6619                 :             : 
    6620                 :             :       /* We can do the conversion inside EXP, which will often result
    6621                 :             :          in some optimizations.  Do the conversion in two steps: first
    6622                 :             :          change the signedness, if needed, then the extend.  But don't
    6623                 :             :          do this if the type of EXP is a subtype of something else
    6624                 :             :          since then the conversion might involve more than just
    6625                 :             :          converting modes.  */
    6626                 :          14 :       if (INTEGRAL_TYPE_P (TREE_TYPE (exp))
    6627                 :           0 :           && TREE_TYPE (TREE_TYPE (exp)) == 0
    6628                 :           7 :           && GET_MODE_PRECISION (outer_mode)
    6629                 :           0 :              == TYPE_PRECISION (TREE_TYPE (exp)))
    6630                 :             :         {
    6631                 :           0 :           if (!SUBREG_CHECK_PROMOTED_SIGN (target,
    6632                 :             :                                           TYPE_UNSIGNED (TREE_TYPE (exp))))
    6633                 :             :             {
    6634                 :             :               /* Some types, e.g. Fortran's logical*4, won't have a signed
    6635                 :             :                  version, so use the mode instead.  */
    6636                 :           0 :               tree ntype
    6637                 :             :                 = (signed_or_unsigned_type_for
    6638                 :           0 :                    (SUBREG_PROMOTED_SIGN (target), TREE_TYPE (exp)));
    6639                 :           0 :               if (ntype == NULL)
    6640                 :           0 :                 ntype = lang_hooks.types.type_for_mode
    6641                 :           0 :                   (TYPE_MODE (TREE_TYPE (exp)),
    6642                 :           0 :                    SUBREG_PROMOTED_SIGN (target));
    6643                 :             : 
    6644                 :           0 :               exp = fold_convert_loc (loc, ntype, exp);
    6645                 :             :             }
    6646                 :             : 
    6647                 :           0 :           exp = fold_convert_loc (loc, lang_hooks.types.type_for_mode
    6648                 :           0 :                                   (inner_mode, SUBREG_PROMOTED_SIGN (target)),
    6649                 :             :                                   exp);
    6650                 :             : 
    6651                 :           0 :           inner_target = SUBREG_REG (target);
    6652                 :             :         }
    6653                 :             : 
    6654                 :           7 :       temp = expand_expr (exp, inner_target, VOIDmode,
    6655                 :             :                           call_param_p ? EXPAND_STACK_PARM : EXPAND_NORMAL);
    6656                 :             : 
    6657                 :             : 
    6658                 :             :       /* If TEMP is a VOIDmode constant, use convert_modes to make
    6659                 :             :          sure that we properly convert it.  */
    6660                 :           7 :       if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode)
    6661                 :             :         {
    6662                 :           0 :           temp = convert_modes (outer_mode, TYPE_MODE (TREE_TYPE (exp)),
    6663                 :           0 :                                 temp, SUBREG_PROMOTED_SIGN (target));
    6664                 :           0 :           temp = convert_modes (inner_mode, outer_mode, temp,
    6665                 :           0 :                                 SUBREG_PROMOTED_SIGN (target));
    6666                 :           0 :         }
    6667                 :           7 :       else if (!SCALAR_INT_MODE_P (GET_MODE (temp)))
    6668                 :           0 :         temp = convert_modes (outer_mode, TYPE_MODE (TREE_TYPE (exp)),
    6669                 :           0 :                               temp, SUBREG_PROMOTED_SIGN (target));
    6670                 :             : 
    6671                 :          21 :       convert_move (SUBREG_REG (target), temp,
    6672                 :           7 :                     SUBREG_PROMOTED_SIGN (target));
    6673                 :             : 
    6674                 :           7 :       return NULL_RTX;
    6675                 :             :     }
    6676                 :    16391774 :   else if ((TREE_CODE (exp) == STRING_CST
    6677                 :    16382995 :             || (TREE_CODE (exp) == MEM_REF
    6678                 :     1127833 :                 && TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
    6679                 :      326857 :                 && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
    6680                 :             :                    == STRING_CST
    6681                 :        4282 :                 && integer_zerop (TREE_OPERAND (exp, 1))))
    6682                 :       13061 :            && !nontemporal && !call_param_p
    6683                 :    16404835 :            && MEM_P (target))
    6684                 :             :     {
    6685                 :             :       /* Optimize initialization of an array with a STRING_CST.  */
    6686                 :       13055 :       HOST_WIDE_INT exp_len, str_copy_len;
    6687                 :       13055 :       rtx dest_mem;
    6688                 :       13055 :       tree str = TREE_CODE (exp) == STRING_CST
    6689                 :       13055 :                  ? exp : TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    6690                 :             : 
    6691                 :       13055 :       exp_len = int_expr_size (exp);
    6692                 :       13055 :       if (exp_len <= 0)
    6693                 :           0 :         goto normal_expr;
    6694                 :             : 
    6695                 :       13055 :       if (TREE_STRING_LENGTH (str) <= 0)
    6696                 :           0 :         goto normal_expr;
    6697                 :             : 
    6698                 :       26110 :       if (can_store_by_pieces (exp_len, string_cst_read_str, (void *) str,
    6699                 :       13055 :                                MEM_ALIGN (target), false))
    6700                 :             :         {
    6701                 :       12881 :           store_by_pieces (target, exp_len, string_cst_read_str, (void *) str,
    6702                 :       12881 :                            MEM_ALIGN (target), false, RETURN_BEGIN);
    6703                 :       12881 :           return NULL_RTX;
    6704                 :             :         }
    6705                 :             : 
    6706                 :         174 :       str_copy_len = TREE_STRING_LENGTH (str);
    6707                 :             : 
    6708                 :             :       /* Trailing NUL bytes in EXP will be handled by the call to
    6709                 :             :          clear_storage, which is more efficient than copying them from
    6710                 :             :          the STRING_CST, so trim those from STR_COPY_LEN.  */
    6711                 :         296 :       while (str_copy_len)
    6712                 :             :         {
    6713                 :         253 :           if (TREE_STRING_POINTER (str)[str_copy_len - 1])
    6714                 :             :             break;
    6715                 :         122 :           str_copy_len--;
    6716                 :             :         }
    6717                 :             : 
    6718                 :         174 :       if ((STORE_MAX_PIECES & (STORE_MAX_PIECES - 1)) == 0)
    6719                 :             :         {
    6720                 :         174 :           str_copy_len += STORE_MAX_PIECES - 1;
    6721                 :         174 :           str_copy_len &= ~(STORE_MAX_PIECES - 1);
    6722                 :             :         }
    6723                 :         174 :       if (str_copy_len >= exp_len)
    6724                 :         123 :         goto normal_expr;
    6725                 :             : 
    6726                 :         102 :       if (!can_store_by_pieces (str_copy_len, string_cst_read_str,
    6727                 :          51 :                                 (void *) str, MEM_ALIGN (target), false))
    6728                 :           2 :         goto normal_expr;
    6729                 :             : 
    6730                 :          49 :       dest_mem = store_by_pieces (target, str_copy_len, string_cst_read_str,
    6731                 :          49 :                                   (void *) str, MEM_ALIGN (target), false,
    6732                 :             :                                   RETURN_END);
    6733                 :          49 :       clear_storage (adjust_address_1 (dest_mem, BLKmode, 0, 1, 1, 0,
    6734                 :          49 :                                        exp_len - str_copy_len),
    6735                 :             :                      GEN_INT (exp_len - str_copy_len), BLOCK_OP_NORMAL);
    6736                 :          49 :       return NULL_RTX;
    6737                 :             :     }
    6738                 :             :   else
    6739                 :             :     {
    6740                 :    16378844 :       rtx tmp_target;
    6741                 :             : 
    6742                 :    16378844 :   normal_expr:
    6743                 :             :       /* If we want to use a nontemporal or a reverse order store, force the
    6744                 :             :          value into a register first.  */
    6745                 :    16378844 :       tmp_target = nontemporal || reverse ? NULL_RTX : target;
    6746                 :    16378844 :       tree rexp = exp;
    6747                 :    16378844 :       if (TREE_CODE (exp) == STRING_CST
    6748                 :          41 :           && tmp_target == target
    6749                 :          41 :           && GET_MODE (target) == BLKmode
    6750                 :    16378885 :           && TYPE_MODE (TREE_TYPE (exp)) == BLKmode)
    6751                 :             :         {
    6752                 :          41 :           rtx size = expr_size (exp);
    6753                 :          41 :           if (CONST_INT_P (size)
    6754                 :          41 :               && size != const0_rtx
    6755                 :          82 :               && (UINTVAL (size)
    6756                 :          41 :                   > ((unsigned HOST_WIDE_INT) TREE_STRING_LENGTH (exp) + 32)))
    6757                 :             :             {
    6758                 :             :               /* If the STRING_CST has much larger array type than
    6759                 :             :                  TREE_STRING_LENGTH, only emit the TREE_STRING_LENGTH part of
    6760                 :             :                  it into the rodata section as the code later on will use
    6761                 :             :                  memset zero for the remainder anyway.  See PR95052.  */
    6762                 :           2 :               tmp_target = NULL_RTX;
    6763                 :           2 :               rexp = copy_node (exp);
    6764                 :           2 :               tree index
    6765                 :           2 :                 = build_index_type (size_int (TREE_STRING_LENGTH (exp) - 1));
    6766                 :           2 :               TREE_TYPE (rexp) = build_array_type (TREE_TYPE (TREE_TYPE (exp)),
    6767                 :             :                                                    index);
    6768                 :           2 :               shortened_string_cst = true;
    6769                 :             :             }
    6770                 :             :         }
    6771                 :    32757688 :       temp = expand_expr_real (rexp, tmp_target, GET_MODE (target),
    6772                 :             :                                (call_param_p
    6773                 :             :                                 ? EXPAND_STACK_PARM : EXPAND_NORMAL),
    6774                 :             :                                &alt_rtl, false);
    6775                 :    16378844 :       if (shortened_string_cst)
    6776                 :             :         {
    6777                 :           2 :           gcc_assert (MEM_P (temp));
    6778                 :           2 :           temp = change_address (temp, BLKmode, NULL_RTX);
    6779                 :             :         }
    6780                 :             :     }
    6781                 :             : 
    6782                 :             :   /* If TEMP is a VOIDmode constant and the mode of the type of EXP is not
    6783                 :             :      the same as that of TARGET, adjust the constant.  This is needed, for
    6784                 :             :      example, in case it is a CONST_DOUBLE or CONST_WIDE_INT and we want
    6785                 :             :      only a word-sized value.  */
    6786                 :     3251261 :   if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode
    6787                 :     2325512 :       && TREE_CODE (exp) != ERROR_MARK
    6788                 :    18704356 :       && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
    6789                 :             :     {
    6790                 :           0 :       gcc_assert (!shortened_string_cst);
    6791                 :           0 :       if (GET_MODE_CLASS (GET_MODE (target))
    6792                 :           0 :           != GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (exp)))
    6793                 :           0 :           && known_eq (GET_MODE_BITSIZE (GET_MODE (target)),
    6794                 :             :                        GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (exp)))))
    6795                 :             :         {
    6796                 :           0 :           rtx t = simplify_gen_subreg (GET_MODE (target), temp,
    6797                 :           0 :                                        TYPE_MODE (TREE_TYPE (exp)), 0);
    6798                 :           0 :           if (t)
    6799                 :           0 :             temp = t;
    6800                 :             :         }
    6801                 :           0 :       if (GET_MODE (temp) == VOIDmode)
    6802                 :           0 :         temp = convert_modes (GET_MODE (target), TYPE_MODE (TREE_TYPE (exp)),
    6803                 :           0 :                               temp, TYPE_UNSIGNED (TREE_TYPE (exp)));
    6804                 :             :     }
    6805                 :             : 
    6806                 :             :   /* If value was not generated in the target, store it there.
    6807                 :             :      Convert the value to TARGET's type first if necessary and emit the
    6808                 :             :      pending incrementations that have been queued when expanding EXP.
    6809                 :             :      Note that we cannot emit the whole queue blindly because this will
    6810                 :             :      effectively disable the POST_INC optimization later.
    6811                 :             : 
    6812                 :             :      If TEMP and TARGET compare equal according to rtx_equal_p, but
    6813                 :             :      one or both of them are volatile memory refs, we have to distinguish
    6814                 :             :      two cases:
    6815                 :             :      - expand_expr has used TARGET.  In this case, we must not generate
    6816                 :             :        another copy.  This can be detected by TARGET being equal according
    6817                 :             :        to == .
    6818                 :             :      - expand_expr has not used TARGET - that means that the source just
    6819                 :             :        happens to have the same RTX form.  Since temp will have been created
    6820                 :             :        by expand_expr, it will compare unequal according to == .
    6821                 :             :        We must generate a copy in this case, to reach the correct number
    6822                 :             :        of volatile memory references.  */
    6823                 :             : 
    6824                 :    16378844 :   if ((! rtx_equal_p (temp, target)
    6825                 :     2890530 :        || (temp != target && (side_effects_p (temp)
    6826                 :       46742 :                               || side_effects_p (target)
    6827                 :       46742 :                               || (MEM_P (temp)
    6828                 :       46527 :                                   && !mems_same_for_tbaa_p (temp, target)))))
    6829                 :    13488318 :       && TREE_CODE (exp) != ERROR_MARK
    6830                 :             :       /* If store_expr stores a DECL whose DECL_RTL(exp) == TARGET,
    6831                 :             :          but TARGET is not valid memory reference, TEMP will differ
    6832                 :             :          from TARGET although it is really the same location.  */
    6833                 :    13488318 :       && !(alt_rtl
    6834                 :     1989559 :            && rtx_equal_p (alt_rtl, target)
    6835                 :           1 :            && !side_effects_p (alt_rtl)
    6836                 :           0 :            && !side_effects_p (target))
    6837                 :             :       /* If there's nothing to copy, don't bother.  Don't call
    6838                 :             :          expr_size unless necessary, because some front-ends (C++)
    6839                 :             :          expr_size-hook must not be given objects that are not
    6840                 :             :          supposed to be bit-copied or bit-initialized.  */
    6841                 :    29867162 :       && expr_size (exp) != const0_rtx)
    6842                 :             :     {
    6843                 :    13488318 :       if (GET_MODE (temp) != GET_MODE (target) && GET_MODE (temp) != VOIDmode)
    6844                 :             :         {
    6845                 :        1538 :           gcc_assert (!shortened_string_cst);
    6846                 :        1538 :           if (GET_MODE (target) == BLKmode)
    6847                 :             :             {
    6848                 :             :               /* Handle calls that return BLKmode values in registers.  */
    6849                 :           2 :               if (REG_P (temp) && TREE_CODE (exp) == CALL_EXPR)
    6850                 :           2 :                 copy_blkmode_from_reg (target, temp, TREE_TYPE (exp));
    6851                 :             :               else
    6852                 :           0 :                 store_bit_field (target,
    6853                 :           0 :                                  rtx_to_poly_int64 (expr_size (exp))
    6854                 :           0 :                                  * BITS_PER_UNIT,
    6855                 :           0 :                                  0, 0, 0, GET_MODE (temp), temp, reverse,
    6856                 :             :                                  false);
    6857                 :             :             }
    6858                 :             :           else
    6859                 :        1536 :             convert_move (target, temp, TYPE_UNSIGNED (TREE_TYPE (exp)));
    6860                 :             :         }
    6861                 :             : 
    6862                 :    13486780 :       else if (GET_MODE (temp) == BLKmode && TREE_CODE (exp) == STRING_CST)
    6863                 :             :         {
    6864                 :             :           /* Handle copying a string constant into an array.  The string
    6865                 :             :              constant may be shorter than the array.  So copy just the string's
    6866                 :             :              actual length, and clear the rest.  First get the size of the data
    6867                 :             :              type of the string, which is actually the size of the target.  */
    6868                 :          41 :           rtx size = expr_size (exp);
    6869                 :             : 
    6870                 :          41 :           if (CONST_INT_P (size)
    6871                 :          41 :               && INTVAL (size) < TREE_STRING_LENGTH (exp))
    6872                 :           0 :             emit_block_move (target, temp, size,
    6873                 :             :                              (call_param_p
    6874                 :             :                               ? BLOCK_OP_CALL_PARM : BLOCK_OP_NORMAL));
    6875                 :             :           else
    6876                 :             :             {
    6877                 :          41 :               machine_mode pointer_mode
    6878                 :          41 :                 = targetm.addr_space.pointer_mode (MEM_ADDR_SPACE (target));
    6879                 :          41 :               machine_mode address_mode = get_address_mode (target);
    6880                 :             : 
    6881                 :             :               /* Compute the size of the data to copy from the string.  */
    6882                 :          41 :               tree copy_size
    6883                 :          41 :                 = size_binop_loc (loc, MIN_EXPR,
    6884                 :             :                                   make_tree (sizetype, size),
    6885                 :          41 :                                   size_int (TREE_STRING_LENGTH (exp)));
    6886                 :          41 :               rtx copy_size_rtx
    6887                 :          41 :                 = expand_expr (copy_size, NULL_RTX, VOIDmode,
    6888                 :             :                                (call_param_p
    6889                 :             :                                 ? EXPAND_STACK_PARM : EXPAND_NORMAL));
    6890                 :          41 :               rtx_code_label *label = 0;
    6891                 :             : 
    6892                 :             :               /* Copy that much.  */
    6893                 :         123 :               copy_size_rtx = convert_to_mode (pointer_mode, copy_size_rtx,
    6894                 :          41 :                                                TYPE_UNSIGNED (sizetype));
    6895                 :          82 :               emit_block_move (target, temp, copy_size_rtx,
    6896                 :             :                                (call_param_p
    6897                 :             :                                 ? BLOCK_OP_CALL_PARM : BLOCK_OP_NORMAL));
    6898                 :             : 
    6899                 :             :               /* Figure out how much is left in TARGET that we have to clear.
    6900                 :             :                  Do all calculations in pointer_mode.  */
    6901                 :          41 :               poly_int64 const_copy_size;
    6902                 :          41 :               if (poly_int_rtx_p (copy_size_rtx, &const_copy_size))
    6903                 :             :                 {
    6904                 :          41 :                   size = plus_constant (address_mode, size, -const_copy_size);
    6905                 :          41 :                   target = adjust_address (target, BLKmode, const_copy_size);
    6906                 :             :                 }
    6907                 :             :               else
    6908                 :             :                 {
    6909                 :           0 :                   size = expand_binop (TYPE_MODE (sizetype), sub_optab, size,
    6910                 :             :                                        copy_size_rtx, NULL_RTX, 0,
    6911                 :             :                                        OPTAB_LIB_WIDEN);
    6912                 :             : 
    6913                 :           0 :                   if (GET_MODE (copy_size_rtx) != address_mode)
    6914                 :           0 :                     copy_size_rtx = convert_to_mode (address_mode,
    6915                 :             :                                                      copy_size_rtx,
    6916                 :           0 :                                                      TYPE_UNSIGNED (sizetype));
    6917                 :             : 
    6918                 :           0 :                   target = offset_address (target, copy_size_rtx,
    6919                 :             :                                            highest_pow2_factor (copy_size));
    6920                 :           0 :                   label = gen_label_rtx ();
    6921                 :           0 :                   emit_cmp_and_jump_insns (size, const0_rtx, LT, NULL_RTX,
    6922                 :           0 :                                            GET_MODE (size), 0, label);
    6923                 :             :                 }
    6924                 :             : 
    6925                 :          41 :               if (size != const0_rtx)
    6926                 :           2 :                 clear_storage (target, size, BLOCK_OP_NORMAL);
    6927                 :             : 
    6928                 :          41 :               if (label)
    6929                 :           0 :                 emit_label (label);
    6930                 :             :             }
    6931                 :             :         }
    6932                 :    13486739 :       else if (shortened_string_cst)
    6933                 :           0 :         gcc_unreachable ();
    6934                 :             :       /* Handle calls that return values in multiple non-contiguous locations.
    6935                 :             :          The Irix 6 ABI has examples of this.  */
    6936                 :    13486739 :       else if (GET_CODE (target) == PARALLEL)
    6937                 :             :         {
    6938                 :           0 :           if (GET_CODE (temp) == PARALLEL)
    6939                 :           0 :             emit_group_move (target, temp);
    6940                 :             :           else
    6941                 :           0 :             emit_group_load (target, temp, TREE_TYPE (exp),
    6942                 :           0 :                              int_size_in_bytes (TREE_TYPE (exp)));
    6943                 :             :         }
    6944                 :    13486739 :       else if (GET_CODE (temp) == PARALLEL)
    6945                 :           0 :         emit_group_store (target, temp, TREE_TYPE (exp),
    6946                 :           0 :                           int_size_in_bytes (TREE_TYPE (exp)));
    6947                 :    13486739 :       else if (GET_MODE (temp) == BLKmode)
    6948                 :      598026 :         emit_block_move (target, temp, expr_size (exp),
    6949                 :             :                          (call_param_p
    6950                 :             :                           ? BLOCK_OP_CALL_PARM : BLOCK_OP_NORMAL));
    6951                 :             :       /* If we emit a nontemporal store, there is nothing else to do.  */
    6952                 :    13187726 :       else if (nontemporal && emit_storent_insn (target, temp))
    6953                 :             :         ;
    6954                 :             :       else
    6955                 :             :         {
    6956                 :    13187709 :           if (reverse)
    6957                 :         712 :             temp = flip_storage_order (GET_MODE (target), temp);
    6958                 :    13187709 :           temp = force_operand (temp, target);
    6959                 :    13187709 :           if (temp != target)
    6960                 :    13186156 :             emit_move_insn (target, temp);
    6961                 :             :         }
    6962                 :             :     }
    6963                 :             :   else
    6964                 :     2890526 :     gcc_assert (!shortened_string_cst);
    6965                 :             : 
    6966                 :             :   return NULL_RTX;
    6967                 :             : }
    6968                 :             : 
    6969                 :             : /* Return true if field F of structure TYPE is a flexible array.  */
    6970                 :             : 
    6971                 :             : static bool
    6972                 :     3636444 : flexible_array_member_p (const_tree f, const_tree type)
    6973                 :             : {
    6974                 :     3636444 :   const_tree tf;
    6975                 :             : 
    6976                 :     3636444 :   tf = TREE_TYPE (f);
    6977                 :     3636444 :   return (DECL_CHAIN (f) == NULL
    6978                 :     1069436 :           && TREE_CODE (tf) == ARRAY_TYPE
    6979                 :        2490 :           && TYPE_DOMAIN (tf)
    6980                 :        2490 :           && TYPE_MIN_VALUE (TYPE_DOMAIN (tf))
    6981                 :        2490 :           && integer_zerop (TYPE_MIN_VALUE (TYPE_DOMAIN (tf)))
    6982                 :        2490 :           && !TYPE_MAX_VALUE (TYPE_DOMAIN (tf))
    6983                 :     3636487 :           && int_size_in_bytes (type) >= 0);
    6984                 :             : }
    6985                 :             : 
    6986                 :             : /* If FOR_CTOR_P, return the number of top-level elements that a constructor
    6987                 :             :    must have in order for it to completely initialize a value of type TYPE.
    6988                 :             :    Return -1 if the number isn't known.
    6989                 :             : 
    6990                 :             :    If !FOR_CTOR_P, return an estimate of the number of scalars in TYPE.  */
    6991                 :             : 
    6992                 :             : static HOST_WIDE_INT
    6993                 :     3355933 : count_type_elements (const_tree type, bool for_ctor_p)
    6994                 :             : {
    6995                 :     3355933 :   switch (TREE_CODE (type))
    6996                 :             :     {
    6997                 :      141550 :     case ARRAY_TYPE:
    6998                 :      141550 :       {
    6999                 :      141550 :         tree nelts_minus_one;
    7000                 :             : 
    7001                 :      141550 :         nelts_minus_one = array_type_nelts_minus_one (type);
    7002                 :      141550 :         if (nelts_minus_one && tree_fits_uhwi_p (nelts_minus_one))
    7003                 :             :           {
    7004                 :      141541 :             unsigned HOST_WIDE_INT n;
    7005                 :             : 
    7006                 :      141541 :             n = tree_to_uhwi (nelts_minus_one) + 1;
    7007                 :      141541 :             if (n == 0 || for_ctor_p)
    7008                 :      140776 :               return n;
    7009                 :             :             else
    7010                 :         765 :               return n * count_type_elements (TREE_TYPE (type), false);
    7011                 :             :           }
    7012                 :           9 :         return for_ctor_p ? -1 : 1;
    7013                 :             :       }
    7014                 :             : 
    7015                 :     1620701 :     case RECORD_TYPE:
    7016                 :     1620701 :       {
    7017                 :     1620701 :         unsigned HOST_WIDE_INT n;
    7018                 :     1620701 :         tree f;
    7019                 :             : 
    7020                 :     1620701 :         n = 0;
    7021                 :    11706219 :         for (f = TYPE_FIELDS (type); f ; f = DECL_CHAIN (f))
    7022                 :    10085518 :           if (TREE_CODE (f) == FIELD_DECL)
    7023                 :             :             {
    7024                 :     4083814 :               if (!for_ctor_p)
    7025                 :      447370 :                 n += count_type_elements (TREE_TYPE (f), false);
    7026                 :     3636444 :               else if (!flexible_array_member_p (f, type))
    7027                 :             :                 /* Don't count flexible arrays, which are not supposed
    7028                 :             :                    to be initialized.  */
    7029                 :     3636401 :                 n += 1;
    7030                 :             :             }
    7031                 :             : 
    7032                 :     1620701 :         return n;
    7033                 :             :       }
    7034                 :             : 
    7035                 :        1692 :     case UNION_TYPE:
    7036                 :        1692 :     case QUAL_UNION_TYPE:
    7037                 :        1692 :       {
    7038                 :        1692 :         tree f;
    7039                 :        1692 :         HOST_WIDE_INT n, m;
    7040                 :             : 
    7041                 :        1692 :         gcc_assert (!for_ctor_p);
    7042                 :             :         /* Estimate the number of scalars in each field and pick the
    7043                 :             :            maximum.  Other estimates would do instead; the idea is simply
    7044                 :             :            to make sure that the estimate is not sensitive to the ordering
    7045                 :             :            of the fields.  */
    7046                 :        1692 :         n = 1;
    7047                 :       31727 :         for (f = TYPE_FIELDS (type); f ; f = DECL_CHAIN (f))
    7048                 :       30035 :           if (TREE_CODE (f) == FIELD_DECL)
    7049                 :             :             {
    7050                 :       27211 :               m = count_type_elements (TREE_TYPE (f), false);
    7051                 :             :               /* If the field doesn't span the whole union, add an extra
    7052                 :             :                  scalar for the rest.  */
    7053                 :       27211 :               if (simple_cst_equal (TYPE_SIZE (TREE_TYPE (f)),
    7054                 :       27211 :                                     TYPE_SIZE (type)) != 1)
    7055                 :       17517 :                 m++;
    7056                 :       27211 :               if (n < m)
    7057                 :       30035 :                 n = m;
    7058                 :             :             }
    7059                 :             :         return n;
    7060                 :             :       }
    7061                 :             : 
    7062                 :             :     case COMPLEX_TYPE:
    7063                 :             :       return 2;
    7064                 :             : 
    7065                 :         300 :     case VECTOR_TYPE:
    7066                 :         300 :       {
    7067                 :         300 :         unsigned HOST_WIDE_INT nelts;
    7068                 :         300 :         if (TYPE_VECTOR_SUBPARTS (type).is_constant (&nelts))
    7069                 :         300 :           return nelts;
    7070                 :             :         else
    7071                 :             :           return -1;
    7072                 :             :       }
    7073                 :             : 
    7074                 :             :     case INTEGER_TYPE:
    7075                 :             :     case REAL_TYPE:
    7076                 :             :     case FIXED_POINT_TYPE:
    7077                 :             :     case ENUMERAL_TYPE:
    7078                 :             :     case BOOLEAN_TYPE:
    7079                 :             :     case POINTER_TYPE:
    7080                 :             :     case OFFSET_TYPE:
    7081                 :             :     case REFERENCE_TYPE:
    7082                 :             :     case NULLPTR_TYPE:
    7083                 :             :     case OPAQUE_TYPE:
    7084                 :             :     case BITINT_TYPE:
    7085                 :             :       return 1;
    7086                 :             : 
    7087                 :           0 :     case ERROR_MARK:
    7088                 :           0 :       return 0;
    7089                 :             : 
    7090                 :           0 :     case VOID_TYPE:
    7091                 :           0 :     case METHOD_TYPE:
    7092                 :           0 :     case FUNCTION_TYPE:
    7093                 :           0 :     case LANG_TYPE:
    7094                 :           0 :     default:
    7095                 :           0 :       gcc_unreachable ();
    7096                 :             :     }
    7097                 :             : }
    7098                 :             : 
    7099                 :             : /* Helper for categorize_ctor_elements.  Identical interface.  */
    7100                 :             : 
    7101                 :             : static bool
    7102                 :     1392424 : categorize_ctor_elements_1 (const_tree ctor, HOST_WIDE_INT *p_nz_elts,
    7103                 :             :                             HOST_WIDE_INT *p_unique_nz_elts,
    7104                 :             :                             HOST_WIDE_INT *p_init_elts, int *p_complete)
    7105                 :             : {
    7106                 :     1392424 :   unsigned HOST_WIDE_INT idx;
    7107                 :     1392424 :   HOST_WIDE_INT nz_elts, unique_nz_elts, init_elts, num_fields;
    7108                 :     1392424 :   tree value, purpose, elt_type;
    7109                 :             : 
    7110                 :             :   /* Whether CTOR is a valid constant initializer, in accordance with what
    7111                 :             :      initializer_constant_valid_p does.  If inferred from the constructor
    7112                 :             :      elements, true until proven otherwise.  */
    7113                 :     1392424 :   bool const_from_elts_p = constructor_static_from_elts_p (ctor);
    7114                 :     1392424 :   bool const_p = const_from_elts_p ? true : TREE_STATIC (ctor);
    7115                 :             : 
    7116                 :     1392424 :   nz_elts = 0;
    7117                 :     1392424 :   unique_nz_elts = 0;
    7118                 :     1392424 :   init_elts = 0;
    7119                 :     1392424 :   num_fields = 0;
    7120                 :     1392424 :   elt_type = NULL_TREE;
    7121                 :             : 
    7122                 :     5313650 :   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), idx, purpose, value)
    7123                 :             :     {
    7124                 :     3921226 :       HOST_WIDE_INT mult = 1;
    7125                 :             : 
    7126                 :     3921226 :       if (purpose && TREE_CODE (purpose) == RANGE_EXPR)
    7127                 :             :         {
    7128                 :         584 :           tree lo_index = TREE_OPERAND (purpose, 0);
    7129                 :         584 :           tree hi_index = TREE_OPERAND (purpose, 1);
    7130                 :             : 
    7131                 :         584 :           if (tree_fits_uhwi_p (lo_index) && tree_fits_uhwi_p (hi_index))
    7132                 :         584 :             mult = (tree_to_uhwi (hi_index)
    7133                 :         584 :                     - tree_to_uhwi (lo_index) + 1);
    7134                 :             :         }
    7135                 :     3921226 :       num_fields += mult;
    7136                 :     3921226 :       elt_type = TREE_TYPE (value);
    7137                 :             : 
    7138                 :     3921226 :       switch (TREE_CODE (value))
    7139                 :             :         {
    7140                 :      463206 :         case CONSTRUCTOR:
    7141                 :      463206 :           {
    7142                 :      463206 :             HOST_WIDE_INT nz = 0, unz = 0, ic = 0;
    7143                 :             : 
    7144                 :      463206 :             bool const_elt_p = categorize_ctor_elements_1 (value, &nz, &unz,
    7145                 :             :                                                            &ic, p_complete);
    7146                 :             : 
    7147                 :      463206 :             nz_elts += mult * nz;
    7148                 :      463206 :             unique_nz_elts += unz;
    7149                 :      463206 :             init_elts += mult * ic;
    7150                 :             : 
    7151                 :      463206 :             if (const_from_elts_p && const_p)
    7152                 :      251100 :               const_p = const_elt_p;
    7153                 :             :           }
    7154                 :      463206 :           break;
    7155                 :             : 
    7156                 :     2107553 :         case INTEGER_CST:
    7157                 :     2107553 :         case REAL_CST:
    7158                 :     2107553 :         case FIXED_CST:
    7159                 :     2107553 :           if (!initializer_zerop (value))
    7160                 :             :             {
    7161                 :     1565683 :               nz_elts += mult;
    7162                 :     1565683 :               unique_nz_elts++;
    7163                 :             :             }
    7164                 :     2107553 :           init_elts += mult;
    7165                 :     2107553 :           break;
    7166                 :             : 
    7167                 :        6368 :         case STRING_CST:
    7168                 :        6368 :           nz_elts += mult * TREE_STRING_LENGTH (value);
    7169                 :        6368 :           unique_nz_elts += TREE_STRING_LENGTH (value);
    7170                 :        6368 :           init_elts += mult * TREE_STRING_LENGTH (value);
    7171                 :        6368 :           break;
    7172                 :             : 
    7173                 :         108 :         case RAW_DATA_CST:
    7174                 :         108 :           nz_elts += mult * RAW_DATA_LENGTH (value);
    7175                 :         108 :           unique_nz_elts += RAW_DATA_LENGTH (value);
    7176                 :         108 :           init_elts += mult * RAW_DATA_LENGTH (value);
    7177                 :         108 :           num_fields += mult * (RAW_DATA_LENGTH (value) - 1);
    7178                 :         108 :           break;
    7179                 :             : 
    7180                 :        2861 :         case COMPLEX_CST:
    7181                 :        2861 :           if (!initializer_zerop (TREE_REALPART (value)))
    7182                 :             :             {
    7183                 :        2434 :               nz_elts += mult;
    7184                 :        2434 :               unique_nz_elts++;
    7185                 :             :             }
    7186                 :        2861 :           if (!initializer_zerop (TREE_IMAGPART (value)))
    7187                 :             :             {
    7188                 :        2300 :               nz_elts += mult;
    7189                 :        2300 :               unique_nz_elts++;
    7190                 :             :             }
    7191                 :        2861 :           init_elts += 2 * mult;
    7192                 :        2861 :           break;
    7193                 :             : 
    7194                 :         778 :         case VECTOR_CST:
    7195                 :         778 :           {
    7196                 :             :             /* We can only construct constant-length vectors using
    7197                 :             :                CONSTRUCTOR.  */
    7198                 :         778 :             unsigned int nunits = VECTOR_CST_NELTS (value).to_constant ();
    7199                 :        5269 :             for (unsigned int i = 0; i < nunits; ++i)
    7200                 :             :               {
    7201                 :        4491 :                 tree v = VECTOR_CST_ELT (value, i);
    7202                 :        4491 :                 if (!initializer_zerop (v))
    7203                 :             :                   {
    7204                 :        1993 :                     nz_elts += mult;
    7205                 :        1993 :                     unique_nz_elts++;
    7206                 :             :                   }
    7207                 :        4491 :                 init_elts += mult;
    7208                 :             :               }
    7209                 :             :           }
    7210                 :             :           break;
    7211                 :             : 
    7212                 :     1340352 :         default:
    7213                 :     1340352 :           {
    7214                 :     1340352 :             HOST_WIDE_INT tc = count_type_elements (elt_type, false);
    7215                 :     1340352 :             nz_elts += mult * tc;
    7216                 :     1340352 :             unique_nz_elts += tc;
    7217                 :     1340352 :             init_elts += mult * tc;
    7218                 :             : 
    7219                 :     1340352 :             if (const_from_elts_p && const_p)
    7220                 :      505924 :               const_p
    7221                 :      505924 :                 = initializer_constant_valid_p (value,
    7222                 :             :                                                 elt_type,
    7223                 :      505924 :                                                 TYPE_REVERSE_STORAGE_ORDER
    7224                 :             :                                                 (TREE_TYPE (ctor)))
    7225                 :             :                   != NULL_TREE;
    7226                 :             :           }
    7227                 :             :           break;
    7228                 :             :         }
    7229                 :             :     }
    7230                 :             : 
    7231                 :     1392424 :   if (*p_complete && !complete_ctor_at_level_p (TREE_TYPE (ctor),
    7232                 :             :                                                 num_fields, elt_type))
    7233                 :      161629 :     *p_complete = 0;
    7234                 :     1230795 :   else if (TREE_CODE (TREE_TYPE (ctor)) == UNION_TYPE
    7235                 :     1230795 :            || TREE_CODE (TREE_TYPE (ctor)) == QUAL_UNION_TYPE)
    7236                 :             :     {
    7237                 :       10826 :       if (*p_complete
    7238                 :        6950 :           && CONSTRUCTOR_ZERO_PADDING_BITS (ctor)
    7239                 :       19911 :           && (num_fields
    7240                 :        4544 :               ? simple_cst_equal (TYPE_SIZE (TREE_TYPE (ctor)),
    7241                 :        4541 :                                   TYPE_SIZE (elt_type)) != 1
    7242                 :           3 :               : type_has_padding_at_level_p (TREE_TYPE (ctor))))
    7243                 :        3365 :         *p_complete = 0;
    7244                 :        7461 :       else if (*p_complete > 0
    7245                 :       10626 :                && (num_fields
    7246                 :        3165 :                    ? simple_cst_equal (TYPE_SIZE (TREE_TYPE (ctor)),
    7247                 :        3165 :                                        TYPE_SIZE (elt_type)) != 1
    7248                 :           0 :                    : type_has_padding_at_level_p (TREE_TYPE (ctor))))
    7249                 :         317 :         *p_complete = -1;
    7250                 :             :     }
    7251                 :     1219969 :   else if (*p_complete
    7252                 :     1146448 :            && (CONSTRUCTOR_ZERO_PADDING_BITS (ctor)
    7253                 :     1133975 :                || flag_zero_init_padding_bits == ZERO_INIT_PADDING_BITS_ALL)
    7254                 :     1232447 :            && type_has_padding_at_level_p (TREE_TYPE (ctor)))
    7255                 :        1956 :     *p_complete = 0;
    7256                 :     1218013 :   else if (*p_complete > 0
    7257                 :     1218013 :            && type_has_padding_at_level_p (TREE_TYPE (ctor)))
    7258                 :       13524 :     *p_complete = -1;
    7259                 :             : 
    7260                 :     1392424 :   *p_nz_elts += nz_elts;
    7261                 :     1392424 :   *p_unique_nz_elts += unique_nz_elts;
    7262                 :     1392424 :   *p_init_elts += init_elts;
    7263                 :             : 
    7264                 :     1392424 :   return const_p;
    7265                 :             : }
    7266                 :             : 
    7267                 :             : /* Examine CTOR to discover:
    7268                 :             :    * how many scalar fields are set to nonzero values,
    7269                 :             :      and place it in *P_NZ_ELTS;
    7270                 :             :    * the same, but counting RANGE_EXPRs as multiplier of 1 instead of
    7271                 :             :      high - low + 1 (this can be useful for callers to determine ctors
    7272                 :             :      that could be cheaply initialized with - perhaps nested - loops
    7273                 :             :      compared to copied from huge read-only data),
    7274                 :             :      and place it in *P_UNIQUE_NZ_ELTS;
    7275                 :             :    * how many scalar fields in total are in CTOR,
    7276                 :             :      and place it in *P_ELT_COUNT.
    7277                 :             :    * whether the constructor is complete -- in the sense that every
    7278                 :             :      meaningful byte is explicitly given a value --
    7279                 :             :      and place it in *P_COMPLETE:
    7280                 :             :      -  0 if any field is missing
    7281                 :             :      -  1 if all fields are initialized, and there's no padding
    7282                 :             :      - -1 if all fields are initialized, but there's padding
    7283                 :             : 
    7284                 :             :    Return whether or not CTOR is a valid static constant initializer, the same
    7285                 :             :    as "initializer_constant_valid_p (CTOR, TREE_TYPE (CTOR)) != 0".  */
    7286                 :             : 
    7287                 :             : bool
    7288                 :      929218 : categorize_ctor_elements (const_tree ctor, HOST_WIDE_INT *p_nz_elts,
    7289                 :             :                           HOST_WIDE_INT *p_unique_nz_elts,
    7290                 :             :                           HOST_WIDE_INT *p_init_elts, int *p_complete)
    7291                 :             : {
    7292                 :      929218 :   *p_nz_elts = 0;
    7293                 :      929218 :   *p_unique_nz_elts = 0;
    7294                 :      929218 :   *p_init_elts = 0;
    7295                 :      929218 :   *p_complete = 1;
    7296                 :             : 
    7297                 :      929218 :   return categorize_ctor_elements_1 (ctor, p_nz_elts, p_unique_nz_elts,
    7298                 :      929218 :                                      p_init_elts, p_complete);
    7299                 :             : }
    7300                 :             : 
    7301                 :             : /* Return true if constructor CTOR is simple enough to be materialized
    7302                 :             :    in an integer mode register.  Limit the size to WORDS words, which
    7303                 :             :    is 1 by default.  */
    7304                 :             : 
    7305                 :             : bool
    7306                 :       19361 : immediate_const_ctor_p (const_tree ctor, unsigned int words)
    7307                 :             : {
    7308                 :             :   /* Allow function to be called with a VAR_DECL's DECL_INITIAL.  */
    7309                 :       19361 :   if (!ctor || TREE_CODE (ctor) != CONSTRUCTOR)
    7310                 :             :     return false;
    7311                 :             : 
    7312                 :        2030 :   return TREE_CONSTANT (ctor)
    7313                 :        2030 :          && !TREE_ADDRESSABLE (ctor)
    7314                 :        2030 :          && CONSTRUCTOR_NELTS (ctor)
    7315                 :        2015 :          && TREE_CODE (TREE_TYPE (ctor)) != ARRAY_TYPE
    7316                 :         637 :          && int_expr_size (ctor) <= words * UNITS_PER_WORD
    7317                 :        2183 :          && initializer_constant_valid_for_bitfield_p (ctor);
    7318                 :             : }
    7319                 :             : 
    7320                 :             : /* TYPE is initialized by a constructor with NUM_ELTS elements, the last
    7321                 :             :    of which had type LAST_TYPE.  Each element was itself a complete
    7322                 :             :    initializer, in the sense that every meaningful byte was explicitly
    7323                 :             :    given a value.  Return true if the same is true for the constructor
    7324                 :             :    as a whole.  */
    7325                 :             : 
    7326                 :             : bool
    7327                 :     1548149 : complete_ctor_at_level_p (const_tree type, HOST_WIDE_INT num_elts,
    7328                 :             :                           const_tree last_type)
    7329                 :             : {
    7330                 :     1548149 :   if (TREE_CODE (type) == UNION_TYPE || TREE_CODE (type) == QUAL_UNION_TYPE)
    7331                 :             :     {
    7332                 :        7914 :       if (num_elts == 0)
    7333                 :             :         {
    7334                 :          24 :           if (flag_zero_init_padding_bits >= ZERO_INIT_PADDING_BITS_UNIONS)
    7335                 :             :             return false;
    7336                 :             : 
    7