LCOV - code coverage report
Current view: top level - gcc - expr.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 82.0 % 6972 5716
Test Date: 2026-12-05 16:10:02 Functions: 94.9 % 178 169
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Convert tree expression to rtl instructions, for GNU compiler.
       2              :    Copyright (C) 1988-2026 Free Software Foundation, Inc.
       3              : 
       4              : This file is part of GCC.
       5              : 
       6              : GCC is free software; you can redistribute it and/or modify it under
       7              : the terms of the GNU General Public License as published by the Free
       8              : Software Foundation; either version 3, or (at your option) any later
       9              : version.
      10              : 
      11              : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12              : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13              : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14              : for more details.
      15              : 
      16              : You should have received a copy of the GNU General Public License
      17              : along with GCC; see the file COPYING3.  If not see
      18              : <http://www.gnu.org/licenses/>.  */
      19              : 
      20              : #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 "tree-eh.h"
      68              : #include "flags.h"
      69              : #include "internal-fn.h"
      70              : #include "gimple-range.h"
      71              : 
      72              : 
      73              : /* If this is nonzero, we do not bother generating VOLATILE
      74              :    around volatile memory references, and we are willing to
      75              :    output indirect addresses.  If cse is to follow, we reject
      76              :    indirect addresses so a useful potential cse is generated;
      77              :    if it is used only once, instruction combination will produce
      78              :    the same indirect address eventually.  */
      79              : int cse_not_expected;
      80              : 
      81              : /* Cache of the "extended" flag in the target's _BitInt description
      82              :    for use during expand.  */
      83              : int bitint_extended = -1;
      84              : 
      85              : static bool block_move_libcall_safe_for_call_parm (void);
      86              : static bool emit_block_move_via_pattern (rtx, rtx, rtx, unsigned, unsigned,
      87              :                                          HOST_WIDE_INT, unsigned HOST_WIDE_INT,
      88              :                                          unsigned HOST_WIDE_INT,
      89              :                                          unsigned HOST_WIDE_INT, bool);
      90              : static void emit_block_move_via_loop (rtx, rtx, rtx, unsigned, int);
      91              : static void emit_block_move_via_sized_loop (rtx, rtx, rtx, unsigned, unsigned);
      92              : static void emit_block_move_via_oriented_loop (rtx, rtx, rtx, unsigned, unsigned);
      93              : static rtx emit_block_cmp_via_loop (rtx, rtx, rtx, tree, rtx, bool,
      94              :                                     unsigned, unsigned);
      95              : static rtx_insn *compress_float_constant (rtx, rtx);
      96              : static rtx get_subtarget (rtx);
      97              : static rtx store_field (rtx, poly_int64, poly_int64, poly_uint64, poly_uint64,
      98              :                         machine_mode, tree, alias_set_type, bool, bool);
      99              : 
     100              : static unsigned HOST_WIDE_INT highest_pow2_factor_for_target (const_tree, const_tree);
     101              : 
     102              : static bool is_aligning_offset (const_tree, const_tree);
     103              : static rtx reduce_to_bit_field_precision (rtx, rtx, tree);
     104              : static rtx do_store_flag (const_sepops, rtx, machine_mode);
     105              : #ifdef PUSH_ROUNDING
     106              : static void emit_single_push_insn (machine_mode, rtx, tree);
     107              : #endif
     108              : static void do_tablejump (rtx, machine_mode, rtx, rtx_code_label *,
     109              :                           rtx_code_label *, profile_probability);
     110              : static rtx const_vector_from_tree (tree);
     111              : static tree tree_expr_size (const_tree);
     112              : static void convert_mode_scalar (rtx, rtx, int);
     113              : 
     114              : 
     115              : /* This is run to set up which modes can be used
     116              :    directly in memory and to initialize the block move optab.  It is run
     117              :    at the beginning of compilation and when the target is reinitialized.  */
     118              : 
     119              : void
     120       226150 : init_expr_target (void)
     121              : {
     122       226150 :   rtx pat;
     123       226150 :   int num_clobbers;
     124       226150 :   rtx mem, mem1;
     125       226150 :   rtx reg;
     126              : 
     127              :   /* Try indexing by frame ptr and try by stack ptr.
     128              :      It is known that on the Convex the stack ptr isn't a valid index.
     129              :      With luck, one or the other is valid on any machine.  */
     130       226150 :   mem = gen_rtx_MEM (word_mode, stack_pointer_rtx);
     131       226150 :   mem1 = gen_rtx_MEM (word_mode, frame_pointer_rtx);
     132              : 
     133              :   /* A scratch register we can modify in-place below to avoid
     134              :      useless RTL allocations.  */
     135       226150 :   reg = gen_rtx_REG (word_mode, LAST_VIRTUAL_REGISTER + 1);
     136              : 
     137       226150 :   rtx_insn *insn = as_a<rtx_insn *> (rtx_alloc (INSN));
     138       226150 :   pat = gen_rtx_SET (NULL_RTX, NULL_RTX);
     139       226150 :   PATTERN (insn) = pat;
     140              : 
     141     28268750 :   for (machine_mode mode = VOIDmode; (int) mode < NUM_MACHINE_MODES;
     142     28042600 :        mode = (machine_mode) ((int) mode + 1))
     143              :     {
     144     28042600 :       int regno;
     145              : 
     146     28042600 :       direct_load[(int) mode] = direct_store[(int) mode] = 0;
     147     28042600 :       PUT_MODE (mem, mode);
     148     28042600 :       PUT_MODE (mem1, mode);
     149              : 
     150              :       /* See if there is some register that can be used in this mode and
     151              :          directly loaded or stored from memory.  */
     152              : 
     153     28042600 :       if (mode != VOIDmode && mode != BLKmode)
     154   1930236197 :         for (regno = 0; regno < FIRST_PSEUDO_REGISTER
     155   1957826497 :              && (direct_load[(int) mode] == 0 || direct_store[(int) mode] == 0);
     156              :              regno++)
     157              :           {
     158   1930236197 :             if (!targetm.hard_regno_mode_ok (regno, mode))
     159   1800599916 :               continue;
     160              : 
     161    129636281 :             set_mode_and_regno (reg, mode, regno);
     162              : 
     163    129636281 :             SET_SRC (pat) = mem;
     164    129636281 :             SET_DEST (pat) = reg;
     165    129636281 :             if (recog (pat, insn, &num_clobbers) >= 0)
     166      7602863 :               direct_load[(int) mode] = 1;
     167              : 
     168    129636281 :             SET_SRC (pat) = mem1;
     169    129636281 :             SET_DEST (pat) = reg;
     170    129636281 :             if (recog (pat, insn, &num_clobbers) >= 0)
     171      7602863 :               direct_load[(int) mode] = 1;
     172              : 
     173    129636281 :             SET_SRC (pat) = reg;
     174    129636281 :             SET_DEST (pat) = mem;
     175    129636281 :             if (recog (pat, insn, &num_clobbers) >= 0)
     176      7602863 :               direct_store[(int) mode] = 1;
     177              : 
     178    129636281 :             SET_SRC (pat) = reg;
     179    129636281 :             SET_DEST (pat) = mem1;
     180    129636281 :             if (recog (pat, insn, &num_clobbers) >= 0)
     181      7602863 :               direct_store[(int) mode] = 1;
     182              :           }
     183              :     }
     184              : 
     185       231869 :   mem = gen_rtx_MEM (VOIDmode, gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 1));
     186              : 
     187       226150 :   opt_scalar_float_mode mode_iter;
     188      1583050 :   FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_FLOAT)
     189              :     {
     190      1356900 :       scalar_float_mode mode = mode_iter.require ();
     191      1356900 :       scalar_float_mode srcmode;
     192      4749150 :       FOR_EACH_MODE_UNTIL (srcmode, mode)
     193              :         {
     194      3392250 :           enum insn_code ic;
     195              : 
     196      3392250 :           ic = can_extend_p (mode, srcmode, 0);
     197      3392250 :           if (ic == CODE_FOR_nothing)
     198      2706625 :             continue;
     199              : 
     200       685625 :           PUT_MODE (mem, srcmode);
     201              : 
     202       685625 :           if (insn_operand_matches (ic, 1, mem))
     203       683413 :             float_extend_from_mem[mode][srcmode] = true;
     204              :         }
     205              :     }
     206       226150 : }
     207              : 
     208              : /* This is run at the start of compiling a function.  */
     209              : 
     210              : void
     211      1763884 : init_expr (void)
     212              : {
     213      1763884 :   memset (&crtl->expr, 0, sizeof (crtl->expr));
     214      1763884 : }
     215              : 
     216              : /* Copy data from FROM to TO, where the machine modes are not the same.
     217              :    Both modes may be integer, or both may be floating, or both may be
     218              :    fixed-point.
     219              :    UNSIGNEDP should be nonzero if FROM is an unsigned type.
     220              :    This causes zero-extension instead of sign-extension.  */
     221              : 
     222              : void
     223      2224067 : convert_move (rtx to, rtx from, int unsignedp)
     224              : {
     225      2224067 :   machine_mode to_mode = GET_MODE (to);
     226      2224067 :   machine_mode from_mode = GET_MODE (from);
     227              : 
     228      2224067 :   gcc_assert (to_mode != BLKmode);
     229      2224067 :   gcc_assert (from_mode != BLKmode);
     230              : 
     231              :   /* If the source and destination are already the same, then there's
     232              :      nothing to do.  */
     233      2224067 :   if (to == from)
     234      2224067 :     return;
     235              : 
     236              :   /* If FROM is a SUBREG that indicates that we have already done at least
     237              :      the required extension, strip it.  We don't handle such SUBREGs as
     238              :      TO here.  */
     239              : 
     240      2224067 :   scalar_int_mode to_int_mode;
     241      2224067 :   if (GET_CODE (from) == SUBREG
     242       184383 :       && SUBREG_PROMOTED_VAR_P (from)
     243      2224074 :       && is_a <scalar_int_mode> (to_mode, &to_int_mode)
     244      2224074 :       && (GET_MODE_PRECISION (subreg_promoted_mode (from))
     245            7 :           >= GET_MODE_PRECISION (to_int_mode))
     246      2224074 :       && SUBREG_CHECK_PROMOTED_SIGN (from, unsignedp))
     247              :     {
     248            0 :       scalar_int_mode int_orig_mode;
     249            0 :       scalar_int_mode int_inner_mode;
     250            0 :       machine_mode orig_mode = GET_MODE (from);
     251              : 
     252            0 :       from = gen_lowpart (to_int_mode, SUBREG_REG (from));
     253            0 :       from_mode = to_int_mode;
     254              : 
     255              :       /* Preserve SUBREG_PROMOTED_VAR_P if the new mode is wider than
     256              :          the original mode, but narrower than the inner mode.  */
     257            0 :       if (GET_CODE (from) == SUBREG
     258            0 :           && is_a <scalar_int_mode> (orig_mode, &int_orig_mode)
     259            0 :           && GET_MODE_PRECISION (to_int_mode)
     260            0 :              > GET_MODE_PRECISION (int_orig_mode)
     261            0 :           && is_a <scalar_int_mode> (GET_MODE (SUBREG_REG (from)),
     262              :                                      &int_inner_mode)
     263            0 :           && GET_MODE_PRECISION (int_inner_mode)
     264            0 :              > GET_MODE_PRECISION (to_int_mode))
     265              :         {
     266            0 :           SUBREG_PROMOTED_VAR_P (from) = 1;
     267            0 :           SUBREG_PROMOTED_SET (from, unsignedp);
     268              :         }
     269              :     }
     270              : 
     271      2224067 :   gcc_assert (GET_CODE (to) != SUBREG || !SUBREG_PROMOTED_VAR_P (to));
     272              : 
     273      2224067 :   if (to_mode == from_mode
     274      2167468 :       || (from_mode == VOIDmode && CONSTANT_P (from)))
     275              :     {
     276        56849 :       emit_move_insn (to, from);
     277        56849 :       return;
     278              :     }
     279              : 
     280      2167218 :   if (VECTOR_MODE_P (to_mode) || VECTOR_MODE_P (from_mode))
     281              :     {
     282        31024 :       if (GET_MODE_UNIT_PRECISION (to_mode)
     283        15512 :           > GET_MODE_UNIT_PRECISION (from_mode))
     284              :         {
     285         5019 :           optab op = unsignedp ? zext_optab : sext_optab;
     286         5019 :           insn_code icode = convert_optab_handler (op, to_mode, from_mode);
     287         5019 :           if (icode != CODE_FOR_nothing)
     288              :             {
     289         1151 :               emit_unop_insn (icode, to, from,
     290              :                               unsignedp ? ZERO_EXTEND : SIGN_EXTEND);
     291         1151 :               return;
     292              :             }
     293              :         }
     294              : 
     295        28722 :       if (GET_MODE_UNIT_PRECISION (to_mode)
     296        14361 :           < GET_MODE_UNIT_PRECISION (from_mode))
     297              :         {
     298         2242 :           insn_code icode = convert_optab_handler (trunc_optab,
     299              :                                                    to_mode, from_mode);
     300         2242 :           if (icode != CODE_FOR_nothing)
     301              :             {
     302          946 :               emit_unop_insn (icode, to, from, TRUNCATE);
     303          946 :               return;
     304              :             }
     305              :         }
     306              : 
     307        40245 :       gcc_assert (known_eq (GET_MODE_BITSIZE (from_mode),
     308              :                             GET_MODE_BITSIZE (to_mode)));
     309              : 
     310        13415 :       if (VECTOR_MODE_P (to_mode))
     311        13415 :         from = force_subreg (to_mode, from, GET_MODE (from), 0);
     312              :       else
     313            0 :         to = simplify_gen_subreg (from_mode, to, GET_MODE (to), 0);
     314              : 
     315        13415 :       emit_move_insn (to, from);
     316        13415 :       return;
     317              :     }
     318              : 
     319      2151706 :   if (GET_CODE (to) == CONCAT && GET_CODE (from) == CONCAT)
     320              :     {
     321            0 :       convert_move (XEXP (to, 0), XEXP (from, 0), unsignedp);
     322            0 :       convert_move (XEXP (to, 1), XEXP (from, 1), unsignedp);
     323            0 :       return;
     324              :     }
     325              : 
     326      2151706 :   convert_mode_scalar (to, from, unsignedp);
     327              : }
     328              : 
     329              : /* Like convert_move, but deals only with scalar modes.  */
     330              : 
     331              : static void
     332      2151892 : convert_mode_scalar (rtx to, rtx from, int unsignedp)
     333              : {
     334              :   /* Both modes should be scalar types.  */
     335      2151965 :   scalar_mode from_mode = as_a <scalar_mode> (GET_MODE (from));
     336      2151965 :   scalar_mode to_mode = as_a <scalar_mode> (GET_MODE (to));
     337      2151965 :   bool to_real = SCALAR_FLOAT_MODE_P (to_mode);
     338      2151965 :   bool from_real = SCALAR_FLOAT_MODE_P (from_mode);
     339      2151965 :   enum insn_code code;
     340      2151965 :   rtx libcall;
     341              : 
     342      2151965 :   gcc_assert (to_real == from_real);
     343              : 
     344              :   /* rtx code for making an equivalent value.  */
     345      3275894 :   enum rtx_code equiv_code = (unsignedp < 0 ? UNKNOWN
     346      2151965 :                               : (unsignedp ? ZERO_EXTEND : SIGN_EXTEND));
     347              : 
     348      2151965 :   auto acceptable_same_precision_modes
     349          706 :     = [] (scalar_mode from_mode, scalar_mode to_mode) -> bool
     350              :     {
     351          706 :       if (DECIMAL_FLOAT_MODE_P (from_mode) != DECIMAL_FLOAT_MODE_P (to_mode))
     352              :         return true;
     353              : 
     354              :       /* arm_bfloat_half_format <-> ieee_half_format */
     355          114 :       if ((REAL_MODE_FORMAT (from_mode) == &arm_bfloat_half_format
     356           65 :            && REAL_MODE_FORMAT (to_mode) == &ieee_half_format)
     357          114 :           || (REAL_MODE_FORMAT (to_mode) == &arm_bfloat_half_format
     358           49 :               && REAL_MODE_FORMAT (from_mode) == &ieee_half_format))
     359              :         return true;
     360              : 
     361              :       /* ibm_extended_format <-> ieee_quad_format */
     362            0 :       if ((REAL_MODE_FORMAT (from_mode) == &ibm_extended_format
     363            0 :            && REAL_MODE_FORMAT (to_mode) == &ieee_quad_format)
     364            0 :           || (REAL_MODE_FORMAT (from_mode) == &ieee_quad_format
     365            0 :               && REAL_MODE_FORMAT (to_mode) == &ibm_extended_format))
     366            0 :         return true;
     367              : 
     368              :       return false;
     369              :     };
     370              : 
     371      2151965 :   if (to_real)
     372              :     {
     373       190369 :       rtx value;
     374       190369 :       rtx_insn *insns;
     375       190369 :       convert_optab tab;
     376              : 
     377       190369 :       gcc_assert ((GET_MODE_PRECISION (from_mode)
     378              :                    != GET_MODE_PRECISION (to_mode))
     379              :                   || acceptable_same_precision_modes (from_mode, to_mode));
     380              : 
     381       190369 :       if (GET_MODE_PRECISION (from_mode) == GET_MODE_PRECISION (to_mode))
     382              :         {
     383          706 :           if ((REAL_MODE_FORMAT (to_mode) == &arm_bfloat_half_format
     384           49 :                && REAL_MODE_FORMAT (from_mode) == &ieee_half_format)
     385          706 :               || (REAL_MODE_FORMAT (to_mode) == &ieee_quad_format
     386            0 :                   && REAL_MODE_FORMAT (from_mode) == &ibm_extended_format))
     387              :             /* libgcc implements just __trunchfbf2, not __extendhfbf2;
     388              :                and __trunctfkf2, not __extendtfkf2.  */
     389              :             tab = trunc_optab;
     390              :           else
     391              :             /* Conversion between decimal float and binary float, same
     392              :                size.  */
     393          657 :             tab = DECIMAL_FLOAT_MODE_P (from_mode) ? trunc_optab : sext_optab;
     394              :         }
     395       189663 :       else if (GET_MODE_PRECISION (from_mode) < GET_MODE_PRECISION (to_mode))
     396              :         tab = sext_optab;
     397              :       else
     398        19083 :         tab = trunc_optab;
     399              : 
     400              :       /* Try converting directly if the insn is supported.  */
     401              : 
     402       190369 :       code = convert_optab_handler (tab, to_mode, from_mode);
     403       190369 :       if (code != CODE_FOR_nothing)
     404              :         {
     405       161978 :           emit_unop_insn (code, to, from,
     406              :                           tab == sext_optab ? FLOAT_EXTEND : FLOAT_TRUNCATE);
     407       161978 :           return;
     408              :         }
     409              : 
     410              : #ifdef HAVE_SFmode
     411        28391 :       if (REAL_MODE_FORMAT (from_mode) == &arm_bfloat_half_format
     412        28391 :           && REAL_MODE_FORMAT (SFmode) == &ieee_single_format)
     413              :         {
     414         3441 :           if (GET_MODE_PRECISION (to_mode) > GET_MODE_PRECISION (SFmode))
     415              :             {
     416              :               /* To cut down on libgcc size, implement
     417              :                  BFmode -> {DF,XF,TF}mode conversions by
     418              :                  BFmode -> SFmode -> {DF,XF,TF}mode conversions.  */
     419            8 :               rtx temp = gen_reg_rtx (SFmode);
     420            8 :               convert_mode_scalar (temp, from, unsignedp);
     421            8 :               convert_mode_scalar (to, temp, unsignedp);
     422            8 :               return;
     423              :             }
     424         3433 :           if (REAL_MODE_FORMAT (to_mode) == &ieee_half_format)
     425              :             {
     426              :               /* Similarly, implement BFmode -> HFmode as
     427              :                  BFmode -> SFmode -> HFmode conversion where SFmode
     428              :                  has superset of BFmode values.  We don't need
     429              :                  to handle sNaNs by raising exception and turning
     430              :                  it into qNaN though, as that can be done in the
     431              :                  SFmode -> HFmode conversion too.  */
     432           65 :               rtx temp = gen_reg_rtx (SFmode);
     433           65 :               int save_flag_finite_math_only = flag_finite_math_only;
     434           65 :               flag_finite_math_only = true;
     435           65 :               convert_mode_scalar (temp, from, unsignedp);
     436           65 :               flag_finite_math_only = save_flag_finite_math_only;
     437           65 :               convert_mode_scalar (to, temp, unsignedp);
     438           65 :               return;
     439              :             }
     440         3368 :           if (to_mode == SFmode
     441         3368 :               && !HONOR_NANS (from_mode)
     442          122 :               && !HONOR_NANS (to_mode)
     443         3490 :               && optimize_insn_for_speed_p ())
     444              :             {
     445              :               /* If we don't expect sNaNs, for BFmode -> SFmode we can just
     446              :                  shift the bits up.  */
     447          113 :               machine_mode fromi_mode, toi_mode;
     448          226 :               if (int_mode_for_size (GET_MODE_BITSIZE (from_mode),
     449          113 :                                      0).exists (&fromi_mode)
     450          113 :                   && int_mode_for_size (GET_MODE_BITSIZE (to_mode),
     451            0 :                                         0).exists (&toi_mode))
     452              :                 {
     453          113 :                   start_sequence ();
     454          113 :                   rtx fromi = force_lowpart_subreg (fromi_mode, from,
     455              :                                                     from_mode);
     456          113 :                   rtx tof = NULL_RTX;
     457          113 :                   if (fromi)
     458              :                     {
     459          113 :                       rtx toi;
     460          113 :                       if (GET_MODE (fromi) == VOIDmode)
     461            0 :                         toi = simplify_unary_operation (ZERO_EXTEND, toi_mode,
     462              :                                                         fromi, fromi_mode);
     463              :                       else
     464              :                         {
     465          113 :                           toi = gen_reg_rtx (toi_mode);
     466          113 :                           convert_mode_scalar (toi, fromi, 1);
     467              :                         }
     468          113 :                       toi
     469          226 :                         = maybe_expand_shift (LSHIFT_EXPR, toi_mode, toi,
     470          113 :                                               GET_MODE_PRECISION (to_mode)
     471          113 :                                               - GET_MODE_PRECISION (from_mode),
     472              :                                               NULL_RTX, 1);
     473          113 :                       if (toi)
     474              :                         {
     475          113 :                           tof = force_lowpart_subreg (to_mode, toi, toi_mode);
     476          113 :                           if (tof)
     477          113 :                             emit_move_insn (to, tof);
     478              :                         }
     479              :                     }
     480          113 :                   insns = end_sequence ();
     481          113 :                   if (tof)
     482              :                     {
     483          113 :                       emit_insn (insns);
     484          113 :                       return;
     485              :                     }
     486              :                 }
     487              :             }
     488              :         }
     489        28205 :       if (REAL_MODE_FORMAT (from_mode) == &ieee_single_format
     490         4382 :           && REAL_MODE_FORMAT (to_mode) == &arm_bfloat_half_format
     491         1596 :           && !HONOR_NANS (from_mode)
     492            0 :           && !HONOR_NANS (to_mode)
     493            0 :           && !flag_rounding_math
     494        28205 :           && optimize_insn_for_speed_p ())
     495              :         {
     496              :           /* If we don't expect qNaNs nor sNaNs and can assume rounding
     497              :              to nearest, we can expand the conversion inline as
     498              :              (fromi + 0x7fff + ((fromi >> 16) & 1)) >> 16.  */
     499            0 :           machine_mode fromi_mode, toi_mode;
     500            0 :           if (int_mode_for_size (GET_MODE_BITSIZE (from_mode),
     501            0 :                                  0).exists (&fromi_mode)
     502            0 :               && int_mode_for_size (GET_MODE_BITSIZE (to_mode),
     503            0 :                                     0).exists (&toi_mode))
     504              :             {
     505            0 :               start_sequence ();
     506            0 :               rtx fromi = force_lowpart_subreg (fromi_mode, from, from_mode);
     507            0 :               rtx tof = NULL_RTX;
     508            0 :               do
     509              :                 {
     510            0 :                   if (!fromi)
     511              :                     break;
     512            0 :                   int shift = (GET_MODE_PRECISION (from_mode)
     513            0 :                                - GET_MODE_PRECISION (to_mode));
     514            0 :                   rtx temp1
     515            0 :                     = maybe_expand_shift (RSHIFT_EXPR, fromi_mode, fromi,
     516              :                                           shift, NULL_RTX, 1);
     517            0 :                   if (!temp1)
     518              :                     break;
     519            0 :                   rtx temp2
     520            0 :                     = expand_binop (fromi_mode, and_optab, temp1, const1_rtx,
     521              :                                     NULL_RTX, 1, OPTAB_DIRECT);
     522            0 :                   if (!temp2)
     523              :                     break;
     524            0 :                   rtx temp3
     525            0 :                     = expand_binop (fromi_mode, add_optab, fromi,
     526              :                                     gen_int_mode ((HOST_WIDE_INT_1U
     527            0 :                                                    << (shift - 1)) - 1,
     528              :                                                   fromi_mode), NULL_RTX,
     529              :                                     1, OPTAB_DIRECT);
     530            0 :                   if (!temp3)
     531              :                     break;
     532            0 :                   rtx temp4
     533            0 :                     = expand_binop (fromi_mode, add_optab, temp3, temp2,
     534              :                                     NULL_RTX, 1, OPTAB_DIRECT);
     535            0 :                   if (!temp4)
     536              :                     break;
     537            0 :                   rtx temp5 = maybe_expand_shift (RSHIFT_EXPR, fromi_mode,
     538              :                                                   temp4, shift, NULL_RTX, 1);
     539            0 :                   if (!temp5)
     540              :                     break;
     541            0 :                   rtx temp6 = force_lowpart_subreg (toi_mode, temp5,
     542              :                                                     fromi_mode);
     543            0 :                   if (!temp6)
     544              :                     break;
     545            0 :                   tof = force_lowpart_subreg (to_mode, temp6, toi_mode);
     546            0 :                   if (tof)
     547            0 :                     emit_move_insn (to, tof);
     548              :                 }
     549              :               while (0);
     550            0 :               insns = end_sequence ();
     551            0 :               if (tof)
     552              :                 {
     553            0 :                   emit_insn (insns);
     554            0 :                   return;
     555              :                 }
     556              :             }
     557              :         }
     558              : #endif
     559              : 
     560              :       /* Otherwise use a libcall.  */
     561        28205 :       libcall = convert_optab_libfunc (tab, to_mode, from_mode);
     562              : 
     563              :       /* Is this conversion implemented yet?  */
     564        28205 :       gcc_assert (libcall);
     565              : 
     566        28205 :       start_sequence ();
     567        28205 :       value = emit_library_call_value (libcall, NULL_RTX, LCT_CONST, to_mode,
     568              :                                        from, from_mode);
     569        28205 :       insns = end_sequence ();
     570        28205 :       emit_libcall_block (insns, to, value,
     571         6946 :                           tab == trunc_optab ? gen_rtx_FLOAT_TRUNCATE (to_mode,
     572              :                                                                        from)
     573        21259 :                           : gen_rtx_FLOAT_EXTEND (to_mode, from));
     574        28205 :       return;
     575              :     }
     576              : 
     577              :   /* Handle pointer conversion.  */                     /* SPEE 900220.  */
     578              :   /* If the target has a converter from FROM_MODE to TO_MODE, use it.  */
     579      1961596 :   {
     580      1961596 :     convert_optab ctab;
     581              : 
     582      1961596 :     if (GET_MODE_PRECISION (from_mode) > GET_MODE_PRECISION (to_mode))
     583              :       ctab = trunc_optab;
     584      1754892 :     else if (unsignedp)
     585              :       ctab = zext_optab;
     586              :     else
     587       845249 :       ctab = sext_optab;
     588              : 
     589      1961596 :     if (convert_optab_handler (ctab, to_mode, from_mode)
     590              :         != CODE_FOR_nothing)
     591              :       {
     592      1684234 :         emit_unop_insn (convert_optab_handler (ctab, to_mode, from_mode),
     593              :                         to, from, UNKNOWN);
     594      1684234 :         return;
     595              :       }
     596              :   }
     597              : 
     598              :   /* Targets are expected to provide conversion insns between PxImode and
     599              :      xImode for all MODE_PARTIAL_INT modes they use, but no others.  */
     600       277362 :   if (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT)
     601              :     {
     602            0 :       scalar_int_mode full_mode
     603            0 :         = smallest_int_mode_for_size (GET_MODE_BITSIZE (to_mode)).require ();
     604              : 
     605            0 :       gcc_assert (convert_optab_handler (trunc_optab, to_mode, full_mode)
     606              :                   != CODE_FOR_nothing);
     607              : 
     608            0 :       if (full_mode != from_mode)
     609            0 :         from = convert_to_mode (full_mode, from, unsignedp);
     610            0 :       emit_unop_insn (convert_optab_handler (trunc_optab, to_mode, full_mode),
     611              :                       to, from, UNKNOWN);
     612            0 :       return;
     613              :     }
     614       277362 :   if (GET_MODE_CLASS (from_mode) == MODE_PARTIAL_INT)
     615              :     {
     616            0 :       rtx new_from;
     617            0 :       scalar_int_mode full_mode
     618            0 :         = smallest_int_mode_for_size (GET_MODE_BITSIZE (from_mode)).require ();
     619            0 :       convert_optab ctab = unsignedp ? zext_optab : sext_optab;
     620            0 :       enum insn_code icode;
     621              : 
     622            0 :       icode = convert_optab_handler (ctab, full_mode, from_mode);
     623            0 :       gcc_assert (icode != CODE_FOR_nothing);
     624              : 
     625            0 :       if (to_mode == full_mode)
     626              :         {
     627            0 :           emit_unop_insn (icode, to, from, UNKNOWN);
     628            0 :           return;
     629              :         }
     630              : 
     631            0 :       new_from = gen_reg_rtx (full_mode);
     632            0 :       emit_unop_insn (icode, new_from, from, UNKNOWN);
     633              : 
     634              :       /* else proceed to integer conversions below.  */
     635            0 :       from_mode = full_mode;
     636            0 :       from = new_from;
     637              :     }
     638              : 
     639              :    /* Make sure both are fixed-point modes or both are not.  */
     640       277362 :    gcc_assert (ALL_SCALAR_FIXED_POINT_MODE_P (from_mode) ==
     641              :                ALL_SCALAR_FIXED_POINT_MODE_P (to_mode));
     642       277362 :    if (ALL_SCALAR_FIXED_POINT_MODE_P (from_mode))
     643              :     {
     644              :       /* If we widen from_mode to to_mode and they are in the same class,
     645              :          we won't saturate the result.
     646              :          Otherwise, always saturate the result to play safe.  */
     647            0 :       if (GET_MODE_CLASS (from_mode) == GET_MODE_CLASS (to_mode)
     648            0 :           && GET_MODE_SIZE (from_mode) < GET_MODE_SIZE (to_mode))
     649            0 :         expand_fixed_convert (to, from, 0, 0);
     650              :       else
     651            0 :         expand_fixed_convert (to, from, 0, 1);
     652              :       return;
     653              :     }
     654              : 
     655              :   /* Now both modes are integers.  */
     656              : 
     657              :   /* Handle expanding beyond a word.  */
     658       277362 :   if (GET_MODE_PRECISION (from_mode) < GET_MODE_PRECISION (to_mode)
     659       279820 :       && GET_MODE_PRECISION (to_mode) > BITS_PER_WORD)
     660              :     {
     661        70658 :       rtx_insn *insns;
     662        70658 :       rtx lowpart;
     663        70658 :       rtx fill_value;
     664        70658 :       rtx lowfrom;
     665        70658 :       int i;
     666        70658 :       scalar_mode lowpart_mode;
     667       141316 :       int nwords = CEIL (GET_MODE_SIZE (to_mode), UNITS_PER_WORD);
     668              : 
     669              :       /* Try converting directly if the insn is supported.  */
     670        70658 :       if ((code = can_extend_p (to_mode, from_mode, unsignedp))
     671              :           != CODE_FOR_nothing)
     672              :         {
     673              :           /* If FROM is a SUBREG, put it into a register.  Do this
     674              :              so that we always generate the same set of insns for
     675              :              better cse'ing; if an intermediate assignment occurred,
     676              :              we won't be doing the operation directly on the SUBREG.  */
     677            0 :           if (optimize > 0 && GET_CODE (from) == SUBREG)
     678            0 :             from = force_reg (from_mode, from);
     679            0 :           emit_unop_insn (code, to, from, equiv_code);
     680            0 :           return;
     681              :         }
     682              :       /* Next, try converting via full word.  */
     683        70658 :       else if (GET_MODE_PRECISION (from_mode) < BITS_PER_WORD
     684        70658 :                && ((code = can_extend_p (to_mode, word_mode, unsignedp))
     685              :                    != CODE_FOR_nothing))
     686              :         {
     687        70564 :           rtx word_to = gen_reg_rtx (word_mode);
     688        70564 :           if (REG_P (to))
     689              :             {
     690        70491 :               if (reg_overlap_mentioned_p (to, from))
     691            0 :                 from = force_reg (from_mode, from);
     692        70491 :               emit_clobber (to);
     693              :             }
     694        70564 :           convert_move (word_to, from, unsignedp);
     695        70564 :           emit_unop_insn (code, to, word_to, equiv_code);
     696        70564 :           return;
     697              :         }
     698              : 
     699              :       /* No special multiword conversion insn; do it by hand.  */
     700           94 :       start_sequence ();
     701              : 
     702              :       /* Since we will turn this into a no conflict block, we must ensure
     703              :          the source does not overlap the target so force it into an isolated
     704              :          register when maybe so.  Likewise for any MEM input, since the
     705              :          conversion sequence might require several references to it and we
     706              :          must ensure we're getting the same value every time.  */
     707              : 
     708           94 :       if (MEM_P (from) || reg_overlap_mentioned_p (to, from))
     709            0 :         from = force_reg (from_mode, from);
     710              : 
     711              :       /* Get a copy of FROM widened to a word, if necessary.  */
     712          188 :       if (GET_MODE_PRECISION (from_mode) < BITS_PER_WORD)
     713            0 :         lowpart_mode = word_mode;
     714              :       else
     715              :         lowpart_mode = from_mode;
     716              : 
     717           94 :       lowfrom = convert_to_mode (lowpart_mode, from, unsignedp);
     718              : 
     719           94 :       lowpart = gen_lowpart (lowpart_mode, to);
     720           94 :       emit_move_insn (lowpart, lowfrom);
     721              : 
     722              :       /* Compute the value to put in each remaining word.  */
     723           94 :       if (unsignedp)
     724           84 :         fill_value = const0_rtx;
     725              :       else
     726           10 :         fill_value = emit_store_flag_force (gen_reg_rtx (word_mode),
     727              :                                             LT, lowfrom, const0_rtx,
     728              :                                             lowpart_mode, 0, -1);
     729              : 
     730              :       /* Fill the remaining words.  */
     731          470 :       for (i = GET_MODE_SIZE (lowpart_mode) / UNITS_PER_WORD; i < nwords; i++)
     732              :         {
     733          188 :           int index = (WORDS_BIG_ENDIAN ? nwords - i - 1 : i);
     734          188 :           rtx subword = operand_subword (to, index, 1, to_mode);
     735              : 
     736          188 :           gcc_assert (subword);
     737              : 
     738          188 :           if (fill_value != subword)
     739          188 :             emit_move_insn (subword, fill_value);
     740              :         }
     741              : 
     742           94 :       insns = end_sequence ();
     743              : 
     744           94 :       emit_insn (insns);
     745           94 :       return;
     746              :     }
     747              : 
     748              :   /* Truncating multi-word to a word or less.  */
     749       206704 :   if (GET_MODE_PRECISION (from_mode) > BITS_PER_WORD
     750       206704 :       && GET_MODE_PRECISION (to_mode) <= BITS_PER_WORD)
     751              :     {
     752        76453 :       if (!((MEM_P (from)
     753          574 :              && ! MEM_VOLATILE_P (from)
     754          574 :              && direct_load[(int) to_mode]
     755          574 :              && ! mode_dependent_address_p (XEXP (from, 0),
     756          574 :                                             MEM_ADDR_SPACE (from)))
     757        47301 :             || REG_P (from)
     758              :             || GET_CODE (from) == SUBREG))
     759            0 :         from = force_reg (from_mode, from);
     760        47875 :       convert_move (to, gen_lowpart (word_mode, from), 0);
     761        47875 :       return;
     762              :     }
     763              : 
     764              :   /* Now follow all the conversions between integers
     765              :      no more than a word long.  */
     766              : 
     767              :   /* For truncation, usually we can just refer to FROM in a narrower mode.  */
     768       317658 :   if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode)
     769       158829 :       && TRULY_NOOP_TRUNCATION_MODES_P (to_mode, from_mode))
     770              :     {
     771       171354 :       if (!((MEM_P (from)
     772        14576 :              && ! MEM_VOLATILE_P (from)
     773        14517 :              && direct_load[(int) to_mode]
     774        14517 :              && ! mode_dependent_address_p (XEXP (from, 0),
     775        14517 :                                             MEM_ADDR_SPACE (from)))
     776       144312 :             || REG_P (from)
     777              :             || GET_CODE (from) == SUBREG))
     778          923 :         from = force_reg (from_mode, from);
     779       132710 :       if (REG_P (from) && REGNO (from) < FIRST_PSEUDO_REGISTER
     780       158830 :           && !targetm.hard_regno_mode_ok (REGNO (from), to_mode))
     781            0 :         from = copy_to_reg (from);
     782       158829 :       emit_move_insn (to, gen_lowpart (to_mode, from));
     783       158829 :       return;
     784              :     }
     785              : 
     786              :   /* Handle extension.  */
     787            0 :   if (GET_MODE_PRECISION (to_mode) > GET_MODE_PRECISION (from_mode))
     788              :     {
     789              :       /* Convert directly if that works.  */
     790            0 :       if ((code = can_extend_p (to_mode, from_mode, unsignedp))
     791              :           != CODE_FOR_nothing)
     792              :         {
     793            0 :           emit_unop_insn (code, to, from, equiv_code);
     794            0 :           return;
     795              :         }
     796              :       else
     797              :         {
     798            0 :           rtx tmp;
     799            0 :           int shift_amount;
     800              : 
     801              :           /* Search for a mode to convert via.  */
     802            0 :           opt_scalar_mode intermediate_iter;
     803            0 :           FOR_EACH_MODE_FROM (intermediate_iter, from_mode)
     804              :             {
     805            0 :               scalar_mode intermediate = intermediate_iter.require ();
     806            0 :               if (((can_extend_p (to_mode, intermediate, unsignedp)
     807              :                     != CODE_FOR_nothing)
     808            0 :                    || (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (intermediate)
     809            0 :                        && TRULY_NOOP_TRUNCATION_MODES_P (to_mode,
     810              :                                                          intermediate)))
     811            0 :                   && (can_extend_p (intermediate, from_mode, unsignedp)
     812              :                       != CODE_FOR_nothing))
     813              :                 {
     814            0 :                   convert_move (to, convert_to_mode (intermediate, from,
     815              :                                                      unsignedp), unsignedp);
     816            0 :                   return;
     817              :                 }
     818              :             }
     819              : 
     820              :           /* No suitable intermediate mode.
     821              :              Generate what we need with shifts.  */
     822            0 :           shift_amount = (GET_MODE_PRECISION (to_mode)
     823            0 :                           - GET_MODE_PRECISION (from_mode));
     824            0 :           from = gen_lowpart (to_mode, force_reg (from_mode, from));
     825            0 :           tmp = expand_shift (LSHIFT_EXPR, to_mode, from, shift_amount,
     826              :                               to, unsignedp);
     827            0 :           tmp = expand_shift (RSHIFT_EXPR, to_mode, tmp, shift_amount,
     828              :                               to, unsignedp);
     829            0 :           if (tmp != to)
     830            0 :             emit_move_insn (to, tmp);
     831              :           return;
     832              :         }
     833              :     }
     834              : 
     835              :   /* Support special truncate insns for certain modes.  */
     836            0 :   if (convert_optab_handler (trunc_optab, to_mode,
     837              :                              from_mode) != CODE_FOR_nothing)
     838              :     {
     839            0 :       emit_unop_insn (convert_optab_handler (trunc_optab, to_mode, from_mode),
     840              :                       to, from, UNKNOWN);
     841            0 :       return;
     842              :     }
     843              : 
     844              :   /* Handle truncation of volatile memrefs, and so on;
     845              :      the things that couldn't be truncated directly,
     846              :      and for which there was no special instruction.
     847              : 
     848              :      ??? Code above formerly short-circuited this, for most integer
     849              :      mode pairs, with a force_reg in from_mode followed by a recursive
     850              :      call to this routine.  Appears always to have been wrong.  */
     851            0 :   if (GET_MODE_PRECISION (to_mode) < GET_MODE_PRECISION (from_mode))
     852              :     {
     853            0 :       rtx temp = force_reg (to_mode, gen_lowpart (to_mode, from));
     854            0 :       emit_move_insn (to, temp);
     855            0 :       return;
     856              :     }
     857              : 
     858              :   /* Mode combination is not recognized.  */
     859            0 :   gcc_unreachable ();
     860              : }
     861              : 
     862              : /* Return an rtx for a value that would result
     863              :    from converting X to mode MODE.
     864              :    Both X and MODE may be floating, or both integer.
     865              :    UNSIGNEDP is nonzero if X is an unsigned value.
     866              :    This can be done by referring to a part of X in place
     867              :    or by copying to a new temporary with conversion.  */
     868              : 
     869              : rtx
     870      2429298 : convert_to_mode (machine_mode mode, rtx x, int unsignedp)
     871              : {
     872      2429298 :   return convert_modes (mode, VOIDmode, x, unsignedp);
     873              : }
     874              : 
     875              : /* Return an rtx for a value that would result
     876              :    from converting X from mode OLDMODE to mode MODE.
     877              :    Both modes may be floating, or both integer.
     878              :    UNSIGNEDP is nonzero if X is an unsigned value.
     879              : 
     880              :    This can be done by referring to a part of X in place
     881              :    or by copying to a new temporary with conversion.
     882              : 
     883              :    You can give VOIDmode for OLDMODE, if you are sure X has a nonvoid mode.  */
     884              : 
     885              : rtx
     886      5323627 : convert_modes (machine_mode mode, machine_mode oldmode, rtx x, int unsignedp)
     887              : {
     888      5323627 :   rtx temp;
     889      5323627 :   scalar_int_mode int_mode;
     890              : 
     891              :   /* If FROM is a SUBREG that indicates that we have already done at least
     892              :      the required extension, strip it.  */
     893              : 
     894      5323627 :   if (GET_CODE (x) == SUBREG
     895       138482 :       && SUBREG_PROMOTED_VAR_P (x)
     896      5323634 :       && is_a <scalar_int_mode> (mode, &int_mode)
     897      5323634 :       && (GET_MODE_PRECISION (subreg_promoted_mode (x))
     898           14 :           >= GET_MODE_PRECISION (int_mode))
     899      5323641 :       && SUBREG_CHECK_PROMOTED_SIGN (x, unsignedp))
     900              :     {
     901            7 :       scalar_int_mode int_orig_mode;
     902            7 :       scalar_int_mode int_inner_mode;
     903            7 :       machine_mode orig_mode = GET_MODE (x);
     904            7 :       x = gen_lowpart (int_mode, SUBREG_REG (x));
     905              : 
     906              :       /* Preserve SUBREG_PROMOTED_VAR_P if the new mode is wider than
     907              :          the original mode, but narrower than the inner mode.  */
     908            7 :       if (GET_CODE (x) == SUBREG
     909            0 :           && is_a <scalar_int_mode> (orig_mode, &int_orig_mode)
     910            0 :           && GET_MODE_PRECISION (int_mode)
     911            0 :              > GET_MODE_PRECISION (int_orig_mode)
     912            0 :           && is_a <scalar_int_mode> (GET_MODE (SUBREG_REG (x)),
     913              :                                      &int_inner_mode)
     914            7 :           && GET_MODE_PRECISION (int_inner_mode)
     915            0 :              > GET_MODE_PRECISION (int_mode))
     916              :         {
     917            0 :           SUBREG_PROMOTED_VAR_P (x) = 1;
     918            0 :           SUBREG_PROMOTED_SET (x, unsignedp);
     919              :         }
     920              :     }
     921              : 
     922      5323627 :   if (GET_MODE (x) != VOIDmode)
     923      2919266 :     oldmode = GET_MODE (x);
     924              : 
     925      5323627 :   if (mode == oldmode)
     926              :     return x;
     927              : 
     928      3870707 :   if (CONST_SCALAR_INT_P (x)
     929      3870707 :       && is_a <scalar_int_mode> (mode, &int_mode))
     930              :     {
     931              :       /* If the caller did not tell us the old mode, then there is not
     932              :          much to do with respect to canonicalization.  We have to
     933              :          assume that all the bits are significant.  */
     934      2081415 :       if (!is_a <scalar_int_mode> (oldmode))
     935      1746951 :         oldmode = MAX_MODE_INT;
     936      2081415 :       wide_int w = wide_int::from (rtx_mode_t (x, oldmode),
     937      2081415 :                                    GET_MODE_PRECISION (int_mode),
     938      2742824 :                                    unsignedp ? UNSIGNED : SIGNED);
     939      2081415 :       return immed_wide_int_const (w, int_mode);
     940      2081415 :     }
     941              : 
     942              :   /* We can do this with a gen_lowpart if both desired and current modes
     943              :      are integer, and this is either a constant integer, a register, or a
     944              :      non-volatile MEM. */
     945      1789292 :   scalar_int_mode int_oldmode;
     946      1789292 :   if (is_int_mode (mode, &int_mode)
     947      1694212 :       && is_int_mode (oldmode, &int_oldmode)
     948      1694212 :       && GET_MODE_PRECISION (int_mode) <= GET_MODE_PRECISION (int_oldmode)
     949       464958 :       && ((MEM_P (x) && !MEM_VOLATILE_P (x) && direct_load[(int) int_mode])
     950        13173 :           || CONST_POLY_INT_P (x)
     951       451785 :           || (REG_P (x)
     952       416980 :               && (!HARD_REGISTER_P (x)
     953         1074 :                   || targetm.hard_regno_mode_ok (REGNO (x), int_mode))
     954       430153 :               && TRULY_NOOP_TRUNCATION_MODES_P (int_mode, GET_MODE (x)))))
     955       430153 :    return gen_lowpart (int_mode, x);
     956              : 
     957              :   /* Converting from integer constant into mode is always equivalent to an
     958              :      subreg operation.  */
     959      1359139 :   if (VECTOR_MODE_P (mode) && GET_MODE (x) == VOIDmode)
     960              :     {
     961            0 :       gcc_assert (known_eq (GET_MODE_BITSIZE (mode),
     962              :                             GET_MODE_BITSIZE (oldmode)));
     963            0 :       return force_subreg (mode, x, oldmode, 0);
     964              :     }
     965              : 
     966      1359139 :   temp = gen_reg_rtx (mode);
     967      1359139 :   convert_move (temp, x, unsignedp);
     968      1359139 :   return temp;
     969              : }
     970              : 
     971              : /* Variant of convert_modes for ABI parameter passing/return.
     972              :    Return an rtx for a value that would result from converting X from
     973              :    a floating point mode FMODE to wider integer mode MODE.  */
     974              : 
     975              : rtx
     976            0 : convert_float_to_wider_int (machine_mode mode, machine_mode fmode, rtx x)
     977              : {
     978            0 :   gcc_assert (SCALAR_INT_MODE_P (mode) && SCALAR_FLOAT_MODE_P (fmode));
     979            0 :   scalar_int_mode tmp_mode = int_mode_for_mode (fmode).require ();
     980            0 :   rtx tmp = force_reg (tmp_mode, gen_lowpart (tmp_mode, x));
     981            0 :   return convert_modes (mode, tmp_mode, tmp, 1);
     982              : }
     983              : 
     984              : /* Variant of convert_modes for ABI parameter passing/return.
     985              :    Return an rtx for a value that would result from converting X from
     986              :    an integer mode IMODE to a narrower floating point mode MODE.  */
     987              : 
     988              : rtx
     989            0 : convert_wider_int_to_float (machine_mode mode, machine_mode imode, rtx x)
     990              : {
     991            0 :   gcc_assert (SCALAR_FLOAT_MODE_P (mode) && SCALAR_INT_MODE_P (imode));
     992            0 :   scalar_int_mode tmp_mode = int_mode_for_mode (mode).require ();
     993            0 :   rtx tmp = force_reg (tmp_mode, gen_lowpart (tmp_mode, x));
     994            0 :   return gen_lowpart_SUBREG (mode, tmp);
     995              : }
     996              : 
     997              : /* Return the largest alignment we can use for doing a move (or store)
     998              :    of MAX_PIECES.  ALIGN is the largest alignment we could use.  */
     999              : 
    1000              : static unsigned int
    1001      2808069 : alignment_for_piecewise_move (unsigned int max_pieces, unsigned int align)
    1002              : {
    1003      2808069 :   scalar_int_mode tmode
    1004      2808069 :     = int_mode_for_size (max_pieces * BITS_PER_UNIT, 0).require ();
    1005              : 
    1006      2808069 :   if (align >= GET_MODE_ALIGNMENT (tmode))
    1007      2213177 :     align = GET_MODE_ALIGNMENT (tmode);
    1008              :   else
    1009              :     {
    1010       594892 :       scalar_int_mode xmode = NARROWEST_INT_MODE;
    1011       594892 :       opt_scalar_int_mode mode_iter;
    1012      3585887 :       FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
    1013              :         {
    1014      3580109 :           tmode = mode_iter.require ();
    1015      3580109 :           if (GET_MODE_SIZE (tmode) > max_pieces
    1016      3580109 :               || targetm.slow_unaligned_access (tmode, align))
    1017              :             break;
    1018      2990995 :           xmode = tmode;
    1019              :         }
    1020              : 
    1021       594892 :       align = MAX (align, GET_MODE_ALIGNMENT (xmode));
    1022              :     }
    1023              : 
    1024      2808069 :   return align;
    1025              : }
    1026              : 
    1027              : /* Return true if we know how to implement OP using vectors of bytes.  */
    1028              : static bool
    1029      5942291 : can_use_qi_vectors (by_pieces_operation op)
    1030              : {
    1031      5942291 :   return (op == COMPARE_BY_PIECES
    1032            0 :           || op == SET_BY_PIECES
    1033            0 :           || op == CLEAR_BY_PIECES);
    1034              : }
    1035              : 
    1036              : /* Return true if optabs exists for the mode and certain by pieces
    1037              :    operations.  */
    1038              : static bool
    1039     26279799 : by_pieces_mode_supported_p (fixed_size_mode mode, by_pieces_operation op)
    1040              : {
    1041     26279799 :   if (optab_handler (mov_optab, mode) == CODE_FOR_nothing)
    1042              :     return false;
    1043              : 
    1044     24881332 :   if ((op == SET_BY_PIECES || op == CLEAR_BY_PIECES)
    1045       714839 :       && VECTOR_MODE_P (mode)
    1046     25395638 :       && optab_handler (vec_duplicate_optab, mode) == CODE_FOR_nothing)
    1047              :     return false;
    1048              : 
    1049     24832334 :   if (op == COMPARE_BY_PIECES
    1050     24832334 :       && !can_compare_p (EQ, mode, ccp_jump))
    1051              :     return false;
    1052              : 
    1053              :   return true;
    1054              : }
    1055              : 
    1056              : /* Return the widest mode that can be used to perform part of an
    1057              :    operation OP on SIZE bytes.  Try to use QI vector modes where
    1058              :    possible.  */
    1059              : static fixed_size_mode
    1060      5444992 : widest_fixed_size_mode_for_size (unsigned int size, by_pieces_operation op)
    1061              : {
    1062      5444992 :   fixed_size_mode result = NARROWEST_INT_MODE;
    1063              : 
    1064      5444992 :   gcc_checking_assert (size > 1);
    1065              : 
    1066              :   /* Use QI vector only if size is wider than a WORD.  */
    1067      5444992 :   if (can_use_qi_vectors (op))
    1068              :     {
    1069       748547 :       machine_mode mode;
    1070       748547 :       fixed_size_mode candidate;
    1071     12365343 :       FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_INT)
    1072     12365343 :         if (is_a<fixed_size_mode> (mode, &candidate)
    1073     13476523 :             && GET_MODE_SIZE (candidate) > UNITS_PER_WORD
    1074     13305342 :             && GET_MODE_INNER (candidate) == QImode)
    1075              :           {
    1076      5823146 :             if (GET_MODE_SIZE (candidate) >= size)
    1077              :               break;
    1078      2163026 :             if (by_pieces_mode_supported_p (candidate, op))
    1079     11616796 :               result = candidate;
    1080              :           }
    1081              : 
    1082       748547 :       if (result != NARROWEST_INT_MODE)
    1083       492059 :         return result;
    1084              :     }
    1085              : 
    1086      4952933 :   opt_scalar_int_mode tmode;
    1087      4952933 :   scalar_int_mode mode;
    1088     39623464 :   FOR_EACH_MODE_IN_CLASS (tmode, MODE_INT)
    1089              :     {
    1090     34670531 :       mode = tmode.require ();
    1091     34670531 :       if (GET_MODE_SIZE (mode) < size
    1092     34670531 :           && by_pieces_mode_supported_p (mode, op))
    1093     24074928 :       result = mode;
    1094              :     }
    1095              : 
    1096      4952933 :   return result;
    1097              : }
    1098              : 
    1099              : /* Determine whether an operation OP on LEN bytes with alignment ALIGN can
    1100              :    and should be performed piecewise.  */
    1101              : 
    1102              : static bool
    1103       972660 : can_do_by_pieces (unsigned HOST_WIDE_INT len, unsigned int align,
    1104              :                   enum by_pieces_operation op)
    1105              : {
    1106       972660 :   return targetm.use_by_pieces_infrastructure_p (len, align, op,
    1107       972660 :                                                  optimize_insn_for_speed_p ());
    1108              : }
    1109              : 
    1110              : /* Determine whether the LEN bytes can be moved by using several move
    1111              :    instructions.  Return nonzero if a call to move_by_pieces should
    1112              :    succeed.  */
    1113              : 
    1114              : bool
    1115       903419 : can_move_by_pieces (unsigned HOST_WIDE_INT len, unsigned int align)
    1116              : {
    1117       903419 :   return can_do_by_pieces (len, align, MOVE_BY_PIECES);
    1118              : }
    1119              : 
    1120              : /* Return number of insns required to perform operation OP by pieces
    1121              :    for L bytes.  ALIGN (in bits) is maximum alignment we can assume.  */
    1122              : 
    1123              : unsigned HOST_WIDE_INT
    1124      1985794 : by_pieces_ninsns (unsigned HOST_WIDE_INT l, unsigned int align,
    1125              :                   unsigned int max_size, by_pieces_operation op)
    1126              : {
    1127      1985794 :   unsigned HOST_WIDE_INT n_insns = 0;
    1128      1985794 :   fixed_size_mode mode;
    1129              : 
    1130      1985794 :   if (targetm.overlap_op_by_pieces_p ())
    1131              :     {
    1132              :       /* NB: Round up L and ALIGN to the widest integer mode for
    1133              :          MAX_SIZE.  */
    1134      1985794 :       mode = widest_fixed_size_mode_for_size (max_size, op);
    1135      1985794 :       gcc_assert (optab_handler (mov_optab, mode) != CODE_FOR_nothing);
    1136      3971588 :       unsigned HOST_WIDE_INT up = ROUND_UP (l, GET_MODE_SIZE (mode));
    1137      1985794 :       if (up > l)
    1138              :         l = up;
    1139      1985794 :       align = GET_MODE_ALIGNMENT (mode);
    1140              :     }
    1141              : 
    1142      1985794 :   align = alignment_for_piecewise_move (MOVE_MAX_PIECES, align);
    1143              : 
    1144      5965981 :   while (max_size > 1 && l > 0)
    1145              :     {
    1146      1994393 :       mode = widest_fixed_size_mode_for_size (max_size, op);
    1147      1994393 :       gcc_assert (optab_handler (mov_optab, mode) != CODE_FOR_nothing);
    1148              : 
    1149      1994393 :       unsigned int modesize = GET_MODE_SIZE (mode);
    1150              : 
    1151      1994393 :       if (align >= GET_MODE_ALIGNMENT (mode))
    1152              :         {
    1153      1994393 :           unsigned HOST_WIDE_INT n_pieces = l / modesize;
    1154      1994393 :           l %= modesize;
    1155      1994393 :           switch (op)
    1156              :             {
    1157      1925152 :             default:
    1158      1925152 :               n_insns += n_pieces;
    1159      1925152 :               break;
    1160              : 
    1161        69241 :             case COMPARE_BY_PIECES:
    1162        69241 :               int batch = targetm.compare_by_pieces_branch_ratio (mode);
    1163        69241 :               int batch_ops = 4 * batch - 1;
    1164        69241 :               unsigned HOST_WIDE_INT full = n_pieces / batch;
    1165        69241 :               n_insns += full * batch_ops;
    1166        69241 :               if (n_pieces % batch != 0)
    1167            4 :                 n_insns++;
    1168              :               break;
    1169              : 
    1170              :             }
    1171              :         }
    1172      1994393 :       max_size = modesize;
    1173              :     }
    1174              : 
    1175      1985794 :   gcc_assert (!l);
    1176      1985794 :   return n_insns;
    1177              : }
    1178              : 
    1179              : /* Used when performing piecewise block operations, holds information
    1180              :    about one of the memory objects involved.  The member functions
    1181              :    can be used to generate code for loading from the object and
    1182              :    updating the address when iterating.  */
    1183              : 
    1184              : class pieces_addr
    1185              : {
    1186              :   /* The object being referenced, a MEM.  Can be NULL_RTX to indicate
    1187              :      stack pushes.  */
    1188              :   rtx m_obj;
    1189              :   /* The address of the object.  Can differ from that seen in the
    1190              :      MEM rtx if we copied the address to a register.  */
    1191              :   rtx m_addr;
    1192              :   /* Nonzero if the address on the object has an autoincrement already,
    1193              :      signifies whether that was an increment or decrement.  */
    1194              :   signed char m_addr_inc;
    1195              :   /* Nonzero if we intend to use autoinc without the address already
    1196              :      having autoinc form.  We will insert add insns around each memory
    1197              :      reference, expecting later passes to form autoinc addressing modes.
    1198              :      The only supported options are predecrement and postincrement.  */
    1199              :   signed char m_explicit_inc;
    1200              :   /* True if we have either of the two possible cases of using
    1201              :      autoincrement.  */
    1202              :   bool m_auto;
    1203              :   /* True if this is an address to be used for load operations rather
    1204              :      than stores.  */
    1205              :   bool m_is_load;
    1206              : 
    1207              :   /* Optionally, a function to obtain constants for any given offset into
    1208              :      the objects, and data associated with it.  */
    1209              :   by_pieces_constfn m_constfn;
    1210              :   void *m_cfndata;
    1211              : public:
    1212              :   pieces_addr (rtx, bool, by_pieces_constfn, void *);
    1213              :   rtx adjust (fixed_size_mode, HOST_WIDE_INT, by_pieces_prev * = nullptr);
    1214              :   void increment_address (HOST_WIDE_INT);
    1215              :   void maybe_predec (HOST_WIDE_INT);
    1216              :   void maybe_postinc (HOST_WIDE_INT);
    1217              :   void decide_autoinc (machine_mode, bool, HOST_WIDE_INT);
    1218       766254 :   int get_addr_inc ()
    1219              :   {
    1220       766254 :     return m_addr_inc;
    1221              :   }
    1222              : };
    1223              : 
    1224              : /* Initialize a pieces_addr structure from an object OBJ.  IS_LOAD is
    1225              :    true if the operation to be performed on this object is a load
    1226              :    rather than a store.  For stores, OBJ can be NULL, in which case we
    1227              :    assume the operation is a stack push.  For loads, the optional
    1228              :    CONSTFN and its associated CFNDATA can be used in place of the
    1229              :    memory load.  */
    1230              : 
    1231      1532508 : pieces_addr::pieces_addr (rtx obj, bool is_load, by_pieces_constfn constfn,
    1232              :                           void *cfndata)
    1233      1532508 :   : m_obj (obj), m_is_load (is_load), m_constfn (constfn), m_cfndata (cfndata)
    1234              : {
    1235      1532508 :   m_addr_inc = 0;
    1236      1532508 :   m_auto = false;
    1237      1532508 :   if (obj)
    1238              :     {
    1239      1403027 :       rtx addr = XEXP (obj, 0);
    1240      1403027 :       rtx_code code = GET_CODE (addr);
    1241      1403027 :       m_addr = addr;
    1242      1403027 :       bool dec = code == PRE_DEC || code == POST_DEC;
    1243      1403027 :       bool inc = code == PRE_INC || code == POST_INC;
    1244      1403027 :       m_auto = inc || dec;
    1245      1403027 :       if (m_auto)
    1246            0 :         m_addr_inc = dec ? -1 : 1;
    1247              : 
    1248              :       /* While we have always looked for these codes here, the code
    1249              :          implementing the memory operation has never handled them.
    1250              :          Support could be added later if necessary or beneficial.  */
    1251      1403027 :       gcc_assert (code != PRE_INC && code != POST_DEC);
    1252              :     }
    1253              :   else
    1254              :     {
    1255       129481 :       m_addr = NULL_RTX;
    1256       129481 :       if (!is_load)
    1257              :         {
    1258           54 :           m_auto = true;
    1259           54 :           if (STACK_GROWS_DOWNWARD)
    1260           54 :             m_addr_inc = -1;
    1261              :           else
    1262              :             m_addr_inc = 1;
    1263              :         }
    1264              :       else
    1265       129427 :         gcc_assert (constfn != NULL);
    1266              :     }
    1267      1532508 :   m_explicit_inc = 0;
    1268      1532508 :   if (constfn)
    1269       154732 :     gcc_assert (is_load);
    1270      1532508 : }
    1271              : 
    1272              : /* Decide whether to use autoinc for an address involved in a memory op.
    1273              :    MODE is the mode of the accesses, REVERSE is true if we've decided to
    1274              :    perform the operation starting from the end, and LEN is the length of
    1275              :    the operation.  Don't override an earlier decision to set m_auto.  */
    1276              : 
    1277              : void
    1278       386786 : pieces_addr::decide_autoinc (machine_mode ARG_UNUSED (mode), bool reverse,
    1279              :                              HOST_WIDE_INT len)
    1280              : {
    1281       386786 :   if (m_auto || m_obj == NULL_RTX)
    1282              :     return;
    1283              : 
    1284       352229 :   bool use_predec = (m_is_load
    1285              :                      ? USE_LOAD_PRE_DECREMENT (mode)
    1286              :                      : USE_STORE_PRE_DECREMENT (mode));
    1287       352229 :   bool use_postinc = (m_is_load
    1288              :                       ? USE_LOAD_POST_INCREMENT (mode)
    1289              :                       : USE_STORE_POST_INCREMENT (mode));
    1290       352229 :   machine_mode addr_mode = get_address_mode (m_obj);
    1291              : 
    1292       352229 :   if (use_predec && reverse)
    1293              :     {
    1294              :       m_addr = copy_to_mode_reg (addr_mode,
    1295              :                                  plus_constant (addr_mode,
    1296              :                                                 m_addr, len));
    1297              :       m_auto = true;
    1298              :       m_explicit_inc = -1;
    1299              :     }
    1300       352229 :   else if (use_postinc && !reverse)
    1301              :     {
    1302              :       m_addr = copy_to_mode_reg (addr_mode, m_addr);
    1303              :       m_auto = true;
    1304              :       m_explicit_inc = 1;
    1305              :     }
    1306       352229 :   else if (CONSTANT_P (m_addr))
    1307        72431 :     m_addr = copy_to_mode_reg (addr_mode, m_addr);
    1308              : }
    1309              : 
    1310              : /* Adjust the address to refer to the data at OFFSET in MODE.  If we
    1311              :    are using autoincrement for this address, we don't add the offset,
    1312              :    but we still modify the MEM's properties.  */
    1313              : 
    1314              : rtx
    1315      4203398 : pieces_addr::adjust (fixed_size_mode mode, HOST_WIDE_INT offset,
    1316              :                      by_pieces_prev *prev)
    1317              : {
    1318      4203398 :   if (m_constfn)
    1319              :     /* Pass the previous data to m_constfn.  */
    1320       389201 :     return m_constfn (m_cfndata, prev, offset, mode);
    1321      3814197 :   if (m_obj == NULL_RTX)
    1322              :     return NULL_RTX;
    1323      3814110 :   if (m_auto)
    1324            0 :     return adjust_automodify_address (m_obj, mode, m_addr, offset);
    1325              :   else
    1326      3814110 :     return adjust_address (m_obj, mode, offset);
    1327              : }
    1328              : 
    1329              : /* Emit an add instruction to increment the address by SIZE.  */
    1330              : 
    1331              : void
    1332            0 : pieces_addr::increment_address (HOST_WIDE_INT size)
    1333              : {
    1334            0 :   rtx amount = gen_int_mode (size, GET_MODE (m_addr));
    1335            0 :   emit_insn (gen_add2_insn (m_addr, amount));
    1336            0 : }
    1337              : 
    1338              : /* If we are supposed to decrement the address after each access, emit code
    1339              :    to do so now.  Increment by SIZE (which has should have the correct sign
    1340              :    already).  */
    1341              : 
    1342              : void
    1343      4202530 : pieces_addr::maybe_predec (HOST_WIDE_INT size)
    1344              : {
    1345      4202530 :   if (m_explicit_inc >= 0)
    1346      4202530 :     return;
    1347            0 :   gcc_assert (HAVE_PRE_DECREMENT);
    1348              :   increment_address (size);
    1349              : }
    1350              : 
    1351              : /* If we are supposed to decrement the address after each access, emit code
    1352              :    to do so now.  Increment by SIZE.  */
    1353              : 
    1354              : void
    1355      4202553 : pieces_addr::maybe_postinc (HOST_WIDE_INT size)
    1356              : {
    1357      4202553 :   if (m_explicit_inc <= 0)
    1358      4202553 :     return;
    1359            0 :   gcc_assert (HAVE_POST_INCREMENT);
    1360              :   increment_address (size);
    1361              : }
    1362              : 
    1363              : /* This structure is used by do_op_by_pieces to describe the operation
    1364              :    to be performed.  */
    1365              : 
    1366              : class op_by_pieces_d
    1367              : {
    1368              :  private:
    1369              :   fixed_size_mode get_usable_mode (fixed_size_mode, unsigned int);
    1370              :   fixed_size_mode smallest_fixed_size_mode_for_size (unsigned int);
    1371              : 
    1372              :  protected:
    1373              :   pieces_addr m_to, m_from;
    1374              :   /* Make m_len read-only so that smallest_fixed_size_mode_for_size can
    1375              :      use it to check the valid mode size.  */
    1376              :   const unsigned HOST_WIDE_INT m_len;
    1377              :   HOST_WIDE_INT m_offset;
    1378              :   unsigned int m_align;
    1379              :   unsigned int m_max_size;
    1380              :   bool m_reverse;
    1381              :   /* True if this is a stack push.  */
    1382              :   bool m_push;
    1383              :   /* True if targetm.overlap_op_by_pieces_p () returns true.  */
    1384              :   bool m_overlap_op_by_pieces;
    1385              :   /* The type of operation that we're performing.  */
    1386              :   by_pieces_operation m_op;
    1387              : 
    1388              :   /* Virtual functions, overridden by derived classes for the specific
    1389              :      operation.  */
    1390              :   virtual void generate (rtx, rtx, machine_mode) = 0;
    1391              :   virtual bool prepare_mode (machine_mode, unsigned int) = 0;
    1392      1163655 :   virtual void finish_mode (machine_mode)
    1393              :   {
    1394      1163655 :   }
    1395              : 
    1396              :  public:
    1397              :   op_by_pieces_d (unsigned int, rtx, bool, rtx, bool, by_pieces_constfn,
    1398              :                   void *, unsigned HOST_WIDE_INT, unsigned int, bool,
    1399              :                   by_pieces_operation);
    1400              :   void run ();
    1401              : };
    1402              : 
    1403              : /* The constructor for an op_by_pieces_d structure.  We require two
    1404              :    objects named TO and FROM, which are identified as loads or stores
    1405              :    by TO_LOAD and FROM_LOAD.  If FROM is a load, the optional FROM_CFN
    1406              :    and its associated FROM_CFN_DATA can be used to replace loads with
    1407              :    constant values.  MAX_PIECES describes the maximum number of bytes
    1408              :    at a time which can be moved efficiently.  LEN describes the length
    1409              :    of the operation.  */
    1410              : 
    1411       766254 : op_by_pieces_d::op_by_pieces_d (unsigned int max_pieces, rtx to,
    1412              :                                 bool to_load, rtx from, bool from_load,
    1413              :                                 by_pieces_constfn from_cfn,
    1414              :                                 void *from_cfn_data,
    1415              :                                 unsigned HOST_WIDE_INT len,
    1416              :                                 unsigned int align, bool push,
    1417              :                                 by_pieces_operation op)
    1418       766254 :   : m_to (to, to_load, NULL, NULL),
    1419       766254 :     m_from (from, from_load, from_cfn, from_cfn_data),
    1420       766254 :     m_len (len), m_max_size (max_pieces + 1),
    1421       766254 :     m_push (push), m_op (op)
    1422              : {
    1423       766254 :   int toi = m_to.get_addr_inc ();
    1424       766254 :   int fromi = m_from.get_addr_inc ();
    1425       766254 :   if (toi >= 0 && fromi >= 0)
    1426       766200 :     m_reverse = false;
    1427           54 :   else if (toi <= 0 && fromi <= 0)
    1428           54 :     m_reverse = true;
    1429              :   else
    1430            0 :     gcc_unreachable ();
    1431              : 
    1432       766254 :   m_offset = m_reverse ? len : 0;
    1433      2806118 :   align = MIN (to ? MEM_ALIGN (to) : align,
    1434              :                from ? MEM_ALIGN (from) : align);
    1435              : 
    1436              :   /* If copying requires more than two move insns,
    1437              :      copy addresses to registers (to make displacements shorter)
    1438              :      and use post-increment if available.  */
    1439       766254 :   if (by_pieces_ninsns (len, align, m_max_size, MOVE_BY_PIECES) > 2)
    1440              :     {
    1441              :       /* Find the mode of the largest comparison.  */
    1442       193393 :       fixed_size_mode mode
    1443       193393 :         = widest_fixed_size_mode_for_size (m_max_size, m_op);
    1444              : 
    1445       193393 :       m_from.decide_autoinc (mode, m_reverse, len);
    1446       193393 :       m_to.decide_autoinc (mode, m_reverse, len);
    1447              :     }
    1448              : 
    1449       766264 :   align = alignment_for_piecewise_move (MOVE_MAX_PIECES, align);
    1450       766254 :   m_align = align;
    1451              : 
    1452       766254 :   m_overlap_op_by_pieces = targetm.overlap_op_by_pieces_p ();
    1453       766254 : }
    1454              : 
    1455              : /* This function returns the largest usable integer mode for LEN bytes
    1456              :    whose size is no bigger than size of MODE.  */
    1457              : 
    1458              : fixed_size_mode
    1459      1256731 : op_by_pieces_d::get_usable_mode (fixed_size_mode mode, unsigned int len)
    1460              : {
    1461      1557668 :   unsigned int size;
    1462      1858605 :   do
    1463              :     {
    1464      1557668 :       size = GET_MODE_SIZE (mode);
    1465      1557668 :       if (len >= size && prepare_mode (mode, m_align))
    1466              :         break;
    1467              :       /* widest_fixed_size_mode_for_size checks SIZE > 1.  */
    1468       300937 :       mode = widest_fixed_size_mode_for_size (size, m_op);
    1469              :     }
    1470              :   while (1);
    1471      1256731 :   return mode;
    1472              : }
    1473              : 
    1474              : /* Return the smallest integer or QI vector mode that is not narrower
    1475              :    than SIZE bytes.  */
    1476              : 
    1477              : fixed_size_mode
    1478       497299 : op_by_pieces_d::smallest_fixed_size_mode_for_size (unsigned int size)
    1479              : {
    1480              :   /* Use QI vector only for > size of WORD.  */
    1481       509522 :   if (can_use_qi_vectors (m_op) && size > UNITS_PER_WORD)
    1482              :     {
    1483         8285 :       machine_mode mode;
    1484         8285 :       fixed_size_mode candidate;
    1485       112042 :       FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_INT)
    1486       112042 :         if (is_a<fixed_size_mode> (mode, &candidate)
    1487       224084 :             && GET_MODE_INNER (candidate) == QImode)
    1488              :           {
    1489              :             /* Don't return a mode wider than M_LEN.  */
    1490       104216 :             if (GET_MODE_SIZE (candidate) > m_len)
    1491              :               break;
    1492              : 
    1493        50169 :             if (GET_MODE_SIZE (candidate) >= size
    1494        50169 :                 && by_pieces_mode_supported_p (candidate, m_op))
    1495         6346 :               return candidate;
    1496              :           }
    1497              :     }
    1498              : 
    1499       490953 :   return smallest_int_mode_for_size (size * BITS_PER_UNIT).require ();
    1500              : }
    1501              : 
    1502              : /* This function contains the main loop used for expanding a block
    1503              :    operation.  First move what we can in the largest integer mode,
    1504              :    then go to successively smaller modes.  For every access, call
    1505              :    GENFUN with the two operands and the EXTRA_DATA.  */
    1506              : 
    1507              : void
    1508       766254 : op_by_pieces_d::run ()
    1509              : {
    1510       766254 :   if (m_len == 0)
    1511              :     return;
    1512              : 
    1513       759432 :   unsigned HOST_WIDE_INT length = m_len;
    1514              : 
    1515              :   /* widest_fixed_size_mode_for_size checks M_MAX_SIZE > 1.  */
    1516       759432 :   fixed_size_mode mode
    1517       759432 :     = widest_fixed_size_mode_for_size (m_max_size, m_op);
    1518       759432 :   mode = get_usable_mode (mode, length);
    1519              : 
    1520       759432 :   by_pieces_prev to_prev = { nullptr, mode };
    1521       759432 :   by_pieces_prev from_prev = { nullptr, mode };
    1522              : 
    1523      1256731 :   do
    1524              :     {
    1525      1256731 :       unsigned int size = GET_MODE_SIZE (mode);
    1526      1256731 :       rtx to1 = NULL_RTX, from1;
    1527              : 
    1528      3357996 :       while (length >= size)
    1529              :         {
    1530      2101265 :           if (m_reverse)
    1531           87 :             m_offset -= size;
    1532              : 
    1533      2101265 :           to1 = m_to.adjust (mode, m_offset, &to_prev);
    1534      2101265 :           to_prev.data = to1;
    1535      2101265 :           to_prev.mode = mode;
    1536      2101265 :           from1 = m_from.adjust (mode, m_offset, &from_prev);
    1537      2101265 :           from_prev.data = from1;
    1538      2101265 :           from_prev.mode = mode;
    1539              : 
    1540      2101265 :           m_to.maybe_predec (-(HOST_WIDE_INT)size);
    1541      2101265 :           m_from.maybe_predec (-(HOST_WIDE_INT)size);
    1542              : 
    1543      2101265 :           generate (to1, from1, mode);
    1544              : 
    1545      2101265 :           m_to.maybe_postinc (size);
    1546      2101265 :           m_from.maybe_postinc (size);
    1547              : 
    1548      2101265 :           if (!m_reverse)
    1549      2101178 :             m_offset += size;
    1550              : 
    1551      2101265 :           length -= size;
    1552              :         }
    1553              : 
    1554      1256731 :       finish_mode (mode);
    1555              : 
    1556      1256731 :       if (length == 0)
    1557              :         return;
    1558              : 
    1559       497299 :       if (!m_push && m_overlap_op_by_pieces)
    1560              :         {
    1561              :           /* NB: Generate overlapping operations if it is not a stack
    1562              :              push since stack push must not overlap.  Get the smallest
    1563              :              fixed size mode for M_LEN bytes.  */
    1564       497299 :           mode = smallest_fixed_size_mode_for_size (length);
    1565       994598 :           mode = get_usable_mode (mode, GET_MODE_SIZE (mode));
    1566       497299 :           int gap = GET_MODE_SIZE (mode) - length;
    1567       497299 :           if (gap > 0)
    1568              :             {
    1569              :               /* If size of MODE > M_LEN, generate the last operation
    1570              :                  in MODE for the remaining bytes with overlapping memory
    1571              :                  from the previois operation.  */
    1572        47773 :               if (m_reverse)
    1573            0 :                 m_offset += gap;
    1574              :               else
    1575        47773 :                 m_offset -= gap;
    1576        47773 :               length += gap;
    1577              :             }
    1578              :         }
    1579              :       else
    1580              :         {
    1581              :           /* widest_fixed_size_mode_for_size checks SIZE > 1.  */
    1582            0 :           mode = widest_fixed_size_mode_for_size (size, m_op);
    1583            0 :           mode = get_usable_mode (mode, length);
    1584              :         }
    1585              :     }
    1586              :   while (1);
    1587              : }
    1588              : 
    1589              : /* Derived class from op_by_pieces_d, providing support for block move
    1590              :    operations.  */
    1591              : 
    1592              : #ifdef PUSH_ROUNDING
    1593              : #define PUSHG_P(to)  ((to) == nullptr)
    1594              : #else
    1595              : #define PUSHG_P(to)  false
    1596              : #endif
    1597              : 
    1598              : class move_by_pieces_d : public op_by_pieces_d
    1599              : {
    1600              :   insn_gen_fn m_gen_fun;
    1601              :   void generate (rtx, rtx, machine_mode) final override;
    1602              :   bool prepare_mode (machine_mode, unsigned int) final override;
    1603              : 
    1604              :  public:
    1605       574832 :   move_by_pieces_d (rtx to, rtx from, unsigned HOST_WIDE_INT len,
    1606              :                     unsigned int align)
    1607       574832 :     : op_by_pieces_d (MOVE_MAX_PIECES, to, false, from, true, NULL,
    1608      1149664 :                       NULL, len, align, PUSHG_P (to), MOVE_BY_PIECES)
    1609              :   {
    1610       574832 :   }
    1611              :   rtx finish_retmode (memop_ret);
    1612              : };
    1613              : 
    1614              : /* Return true if MODE can be used for a set of copies, given an
    1615              :    alignment ALIGN.  Prepare whatever data is necessary for later
    1616              :    calls to generate.  */
    1617              : 
    1618              : bool
    1619       957597 : move_by_pieces_d::prepare_mode (machine_mode mode, unsigned int align)
    1620              : {
    1621       957597 :   insn_code icode = optab_handler (mov_optab, mode);
    1622       957597 :   m_gen_fun = GEN_FCN (icode);
    1623       957597 :   return icode != CODE_FOR_nothing && align >= GET_MODE_ALIGNMENT (mode);
    1624              : }
    1625              : 
    1626              : /* A callback used when iterating for a compare_by_pieces_operation.
    1627              :    OP0 and OP1 are the values that have been loaded and should be
    1628              :    compared in MODE.  If OP0 is NULL, this means we should generate a
    1629              :    push; otherwise EXTRA_DATA holds a pointer to a pointer to the insn
    1630              :    gen function that should be used to generate the mode.  */
    1631              : 
    1632              : void
    1633      1666364 : move_by_pieces_d::generate (rtx op0, rtx op1,
    1634              :                             machine_mode mode ATTRIBUTE_UNUSED)
    1635              : {
    1636              : #ifdef PUSH_ROUNDING
    1637      1666364 :   if (op0 == NULL_RTX)
    1638              :     {
    1639           87 :       emit_single_push_insn (mode, op1, NULL);
    1640           87 :       return;
    1641              :     }
    1642              : #endif
    1643      1666277 :   emit_insn (m_gen_fun (op0, op1));
    1644              : }
    1645              : 
    1646              : /* Perform the final adjustment at the end of a string to obtain the
    1647              :    correct return value for the block operation.
    1648              :    Return value is based on RETMODE argument.  */
    1649              : 
    1650              : rtx
    1651            0 : move_by_pieces_d::finish_retmode (memop_ret retmode)
    1652              : {
    1653            0 :   gcc_assert (!m_reverse);
    1654            0 :   if (retmode == RETURN_END_MINUS_ONE)
    1655              :     {
    1656            0 :       m_to.maybe_postinc (-1);
    1657            0 :       --m_offset;
    1658              :     }
    1659            0 :   return m_to.adjust (QImode, m_offset);
    1660              : }
    1661              : 
    1662              : /* Generate several move instructions to copy LEN bytes from block FROM to
    1663              :    block TO.  (These are MEM rtx's with BLKmode).
    1664              : 
    1665              :    If PUSH_ROUNDING is defined and TO is NULL, emit_single_push_insn is
    1666              :    used to push FROM to the stack.
    1667              : 
    1668              :    ALIGN is maximum stack alignment we can assume.
    1669              : 
    1670              :    Return value is based on RETMODE argument.  */
    1671              : 
    1672              : rtx
    1673       574832 : move_by_pieces (rtx to, rtx from, unsigned HOST_WIDE_INT len,
    1674              :                 unsigned int align, memop_ret retmode)
    1675              : {
    1676              : #ifndef PUSH_ROUNDING
    1677              :   if (to == NULL)
    1678              :     gcc_unreachable ();
    1679              : #endif
    1680              : 
    1681       574832 :   move_by_pieces_d data (to, from, len, align);
    1682              : 
    1683       574832 :   data.run ();
    1684              : 
    1685       574832 :   if (retmode != RETURN_BEGIN)
    1686            0 :     return data.finish_retmode (retmode);
    1687              :   else
    1688              :     return to;
    1689              : }
    1690              : 
    1691              : /* Derived class from op_by_pieces_d, providing support for block move
    1692              :    operations.  */
    1693              : 
    1694              : class store_by_pieces_d : public op_by_pieces_d
    1695              : {
    1696              :   insn_gen_fn m_gen_fun;
    1697              : 
    1698              :   void generate (rtx, rtx, machine_mode) final override;
    1699              :   bool prepare_mode (machine_mode, unsigned int) final override;
    1700              : 
    1701              :  public:
    1702       129427 :   store_by_pieces_d (rtx to, by_pieces_constfn cfn, void *cfn_data,
    1703              :                      unsigned HOST_WIDE_INT len, unsigned int align,
    1704              :                      by_pieces_operation op)
    1705       129427 :     : op_by_pieces_d (STORE_MAX_PIECES, to, false, NULL_RTX, true, cfn,
    1706       258854 :                       cfn_data, len, align, false, op)
    1707              :   {
    1708       129427 :   }
    1709              :   rtx finish_retmode (memop_ret);
    1710              : };
    1711              : 
    1712              : /* Return true if MODE can be used for a set of stores, given an
    1713              :    alignment ALIGN.  Prepare whatever data is necessary for later
    1714              :    calls to generate.  */
    1715              : 
    1716              : bool
    1717       206058 : store_by_pieces_d::prepare_mode (machine_mode mode, unsigned int align)
    1718              : {
    1719       206058 :   insn_code icode = optab_handler (mov_optab, mode);
    1720       206058 :   m_gen_fun = GEN_FCN (icode);
    1721       206058 :   return icode != CODE_FOR_nothing && align >= GET_MODE_ALIGNMENT (mode);
    1722              : }
    1723              : 
    1724              : /* A callback used when iterating for a store_by_pieces_operation.
    1725              :    OP0 and OP1 are the values that have been loaded and should be
    1726              :    compared in MODE.  If OP0 is NULL, this means we should generate a
    1727              :    push; otherwise EXTRA_DATA holds a pointer to a pointer to the insn
    1728              :    gen function that should be used to generate the mode.  */
    1729              : 
    1730              : void
    1731       338550 : store_by_pieces_d::generate (rtx op0, rtx op1, machine_mode)
    1732              : {
    1733       338550 :   emit_insn (m_gen_fun (op0, op1));
    1734       338550 : }
    1735              : 
    1736              : /* Perform the final adjustment at the end of a string to obtain the
    1737              :    correct return value for the block operation.
    1738              :    Return value is based on RETMODE argument.  */
    1739              : 
    1740              : rtx
    1741          868 : store_by_pieces_d::finish_retmode (memop_ret retmode)
    1742              : {
    1743          868 :   gcc_assert (!m_reverse);
    1744          868 :   if (retmode == RETURN_END_MINUS_ONE)
    1745              :     {
    1746           23 :       m_to.maybe_postinc (-1);
    1747           23 :       --m_offset;
    1748              :     }
    1749          868 :   return m_to.adjust (QImode, m_offset);
    1750              : }
    1751              : 
    1752              : /* Determine whether the LEN bytes generated by CONSTFUN can be
    1753              :    stored to memory using several move instructions.  CONSTFUNDATA is
    1754              :    a pointer which will be passed as argument in every CONSTFUN call.
    1755              :    ALIGN is maximum alignment we can assume.  MEMSETP is true if this is
    1756              :    a memset operation and false if it's a copy of a constant string.
    1757              :    Return true if a call to store_by_pieces should succeed.  */
    1758              : 
    1759              : bool
    1760        97367 : can_store_by_pieces (unsigned HOST_WIDE_INT len,
    1761              :                      by_pieces_constfn constfun,
    1762              :                      void *constfundata, unsigned int align, bool memsetp)
    1763              : {
    1764        97367 :   unsigned HOST_WIDE_INT l;
    1765        97367 :   unsigned int max_size;
    1766        97367 :   HOST_WIDE_INT offset = 0;
    1767        97367 :   enum insn_code icode;
    1768        97367 :   int reverse;
    1769              :   /* cst is set but not used if LEGITIMATE_CONSTANT doesn't use it.  */
    1770        97367 :   rtx cst ATTRIBUTE_UNUSED;
    1771              : 
    1772        97367 :   if (len == 0)
    1773              :     return true;
    1774              : 
    1775       146135 :   if (!targetm.use_by_pieces_infrastructure_p (len, align,
    1776              :                                                memsetp
    1777              :                                                  ? SET_BY_PIECES
    1778              :                                                  : STORE_BY_PIECES,
    1779              :                                                optimize_insn_for_speed_p ()))
    1780              :     return false;
    1781              : 
    1782        56021 :   align = alignment_for_piecewise_move (STORE_MAX_PIECES, align);
    1783              : 
    1784              :   /* We would first store what we can in the largest integer mode, then go to
    1785              :      successively smaller modes.  */
    1786              : 
    1787        56021 :   for (reverse = 0;
    1788       112042 :        reverse <= (HAVE_PRE_DECREMENT || HAVE_POST_DECREMENT);
    1789              :        reverse++)
    1790              :     {
    1791        56021 :       l = len;
    1792        56047 :       max_size = STORE_MAX_PIECES + 1;
    1793       267064 :       while (max_size > 1 && l > 0)
    1794              :         {
    1795       211043 :           auto op = memsetp ? SET_BY_PIECES : STORE_BY_PIECES;
    1796       211043 :           auto mode = widest_fixed_size_mode_for_size (max_size, op);
    1797              : 
    1798       211043 :           icode = optab_handler (mov_optab, mode);
    1799       211043 :           if (icode != CODE_FOR_nothing
    1800       211043 :               && align >= GET_MODE_ALIGNMENT (mode))
    1801              :             {
    1802       211043 :               unsigned int size = GET_MODE_SIZE (mode);
    1803              : 
    1804       371705 :               while (l >= size)
    1805              :                 {
    1806       160662 :                   if (reverse)
    1807              :                     offset -= size;
    1808              : 
    1809       160662 :                   cst = (*constfun) (constfundata, nullptr, offset, mode);
    1810              :                   /* All CONST_VECTORs can be loaded for memset since
    1811              :                      vec_duplicate_optab is a precondition to pick a
    1812              :                      vector mode for the memset expander.  */
    1813       299329 :                   if (!((memsetp && VECTOR_MODE_P (mode))
    1814       138667 :                         || targetm.legitimate_constant_p (mode, cst)))
    1815        97367 :                     return false;
    1816              : 
    1817       160662 :                   if (!reverse)
    1818       160662 :                     offset += size;
    1819              : 
    1820       160662 :                   l -= size;
    1821              :                 }
    1822              :             }
    1823              : 
    1824       422086 :           max_size = GET_MODE_SIZE (mode);
    1825              :         }
    1826              : 
    1827              :       /* The code above should have handled everything.  */
    1828        56021 :       gcc_assert (!l);
    1829              :     }
    1830              : 
    1831              :   return true;
    1832              : }
    1833              : 
    1834              : /* Generate several move instructions to store LEN bytes generated by
    1835              :    CONSTFUN to block TO.  (A MEM rtx with BLKmode).  CONSTFUNDATA is a
    1836              :    pointer which will be passed as argument in every CONSTFUN call.
    1837              :    ALIGN is maximum alignment we can assume.  MEMSETP is true if this is
    1838              :    a memset operation and false if it's a copy of a constant string.
    1839              :    Return value is based on RETMODE argument.  */
    1840              : 
    1841              : rtx
    1842        63239 : store_by_pieces (rtx to, unsigned HOST_WIDE_INT len,
    1843              :                  by_pieces_constfn constfun,
    1844              :                  void *constfundata, unsigned int align, bool memsetp,
    1845              :                  memop_ret retmode)
    1846              : {
    1847        63239 :   if (len == 0)
    1848              :     {
    1849         8031 :       gcc_assert (retmode != RETURN_END_MINUS_ONE);
    1850              :       return to;
    1851              :     }
    1852              : 
    1853        99554 :   gcc_assert (targetm.use_by_pieces_infrastructure_p
    1854              :                 (len, align,
    1855              :                  memsetp ? SET_BY_PIECES : STORE_BY_PIECES,
    1856              :                  optimize_insn_for_speed_p ()));
    1857              : 
    1858        55208 :   store_by_pieces_d data (to, constfun, constfundata, len, align,
    1859        55208 :                           memsetp ? SET_BY_PIECES : STORE_BY_PIECES);
    1860        55208 :   data.run ();
    1861              : 
    1862        55208 :   if (retmode != RETURN_BEGIN)
    1863          868 :     return data.finish_retmode (retmode);
    1864              :   else
    1865              :     return to;
    1866              : }
    1867              : 
    1868              : void
    1869        74219 : clear_by_pieces (rtx to, unsigned HOST_WIDE_INT len, unsigned int align)
    1870              : {
    1871        74219 :   if (len == 0)
    1872              :     return;
    1873              : 
    1874              :   /* Use builtin_memset_read_str to support vector mode broadcast.  */
    1875        74219 :   char c = 0;
    1876        74219 :   store_by_pieces_d data (to, builtin_memset_read_str, &c, len, align,
    1877        74219 :                           CLEAR_BY_PIECES);
    1878        74219 :   data.run ();
    1879              : }
    1880              : 
    1881              : /* Context used by compare_by_pieces_genfn.  It stores the fail label
    1882              :    to jump to in case of miscomparison, and for branch ratios greater than 1,
    1883              :    it stores an accumulator and the current and maximum counts before
    1884              :    emitting another branch.  */
    1885              : 
    1886              : class compare_by_pieces_d : public op_by_pieces_d
    1887              : {
    1888              :   rtx_code_label *m_fail_label;
    1889              :   rtx m_accumulator;
    1890              :   int m_count, m_batch;
    1891              : 
    1892              :   void generate (rtx, rtx, machine_mode) final override;
    1893              :   bool prepare_mode (machine_mode, unsigned int) final override;
    1894              :   void finish_mode (machine_mode) final override;
    1895              : 
    1896              :  public:
    1897        61995 :   compare_by_pieces_d (rtx op0, rtx op1, by_pieces_constfn op1_cfn,
    1898              :                        void *op1_cfn_data, HOST_WIDE_INT len, int align,
    1899              :                        rtx_code_label *fail_label)
    1900        61995 :     : op_by_pieces_d (COMPARE_MAX_PIECES, op0, true, op1, true, op1_cfn,
    1901       123990 :                       op1_cfn_data, len, align, false, COMPARE_BY_PIECES)
    1902              :   {
    1903        61995 :     m_fail_label = fail_label;
    1904        61995 :   }
    1905              : };
    1906              : 
    1907              : /* A callback used when iterating for a compare_by_pieces_operation.
    1908              :    OP0 and OP1 are the values that have been loaded and should be
    1909              :    compared in MODE.  DATA holds a pointer to the compare_by_pieces_data
    1910              :    context structure.  */
    1911              : 
    1912              : void
    1913        96351 : compare_by_pieces_d::generate (rtx op0, rtx op1, machine_mode mode)
    1914              : {
    1915        96351 :   if (m_batch > 1)
    1916              :     {
    1917           11 :       rtx temp = expand_binop (mode, sub_optab, op0, op1, NULL_RTX,
    1918              :                                true, OPTAB_LIB_WIDEN);
    1919           11 :       if (m_count != 0)
    1920            5 :         temp = expand_binop (mode, ior_optab, m_accumulator, temp, temp,
    1921              :                              true, OPTAB_LIB_WIDEN);
    1922           11 :       m_accumulator = temp;
    1923              : 
    1924           11 :       if (++m_count < m_batch)
    1925              :         return;
    1926              : 
    1927            5 :       m_count = 0;
    1928            5 :       op0 = m_accumulator;
    1929            5 :       op1 = const0_rtx;
    1930            5 :       m_accumulator = NULL_RTX;
    1931              :     }
    1932        96345 :   do_compare_rtx_and_jump (op0, op1, NE, true, mode, NULL_RTX, NULL,
    1933              :                            m_fail_label, profile_probability::uninitialized ());
    1934              : }
    1935              : 
    1936              : /* Return true if MODE can be used for a set of moves and comparisons,
    1937              :    given an alignment ALIGN.  Prepare whatever data is necessary for
    1938              :    later calls to generate.  */
    1939              : 
    1940              : bool
    1941        93076 : compare_by_pieces_d::prepare_mode (machine_mode mode, unsigned int align)
    1942              : {
    1943        93076 :   insn_code icode = optab_handler (mov_optab, mode);
    1944        93076 :   if (icode == CODE_FOR_nothing
    1945        93076 :       || align < GET_MODE_ALIGNMENT (mode)
    1946       186152 :       || !can_compare_p (EQ, mode, ccp_jump))
    1947              :     return false;
    1948        93076 :   m_batch = targetm.compare_by_pieces_branch_ratio (mode);
    1949        93076 :   if (m_batch < 0)
    1950              :     return false;
    1951        93076 :   m_accumulator = NULL_RTX;
    1952        93076 :   m_count = 0;
    1953        93076 :   return true;
    1954              : }
    1955              : 
    1956              : /* Called after expanding a series of comparisons in MODE.  If we have
    1957              :    accumulated results for which we haven't emitted a branch yet, do
    1958              :    so now.  */
    1959              : 
    1960              : void
    1961        93076 : compare_by_pieces_d::finish_mode (machine_mode mode)
    1962              : {
    1963        93076 :   if (m_accumulator != NULL_RTX)
    1964            1 :     do_compare_rtx_and_jump (m_accumulator, const0_rtx, NE, true, mode,
    1965              :                              NULL_RTX, NULL, m_fail_label,
    1966              :                              profile_probability::uninitialized ());
    1967        93076 : }
    1968              : 
    1969              : /* Generate several move instructions to compare LEN bytes from blocks
    1970              :    ARG0 and ARG1.  (These are MEM rtx's with BLKmode).
    1971              : 
    1972              :    If PUSH_ROUNDING is defined and TO is NULL, emit_single_push_insn is
    1973              :    used to push FROM to the stack.
    1974              : 
    1975              :    ALIGN is maximum stack alignment we can assume.
    1976              : 
    1977              :    Optionally, the caller can pass a constfn and associated data in A1_CFN
    1978              :    and A1_CFN_DATA. describing that the second operand being compared is a
    1979              :    known constant and how to obtain its data.  */
    1980              : 
    1981              : static rtx
    1982        61995 : compare_by_pieces (rtx arg0, rtx arg1, unsigned HOST_WIDE_INT len,
    1983              :                    rtx target, unsigned int align,
    1984              :                    by_pieces_constfn a1_cfn, void *a1_cfn_data)
    1985              : {
    1986        61995 :   rtx_code_label *fail_label = gen_label_rtx ();
    1987        61995 :   rtx_code_label *end_label = gen_label_rtx ();
    1988              : 
    1989        61995 :   if (target == NULL_RTX
    1990        61995 :       || !REG_P (target) || REGNO (target) < FIRST_PSEUDO_REGISTER)
    1991            2 :     target = gen_reg_rtx (TYPE_MODE (integer_type_node));
    1992              : 
    1993        61995 :   compare_by_pieces_d data (arg0, arg1, a1_cfn, a1_cfn_data, len, align,
    1994        61995 :                             fail_label);
    1995              : 
    1996        61995 :   data.run ();
    1997              : 
    1998        61995 :   emit_move_insn (target, const0_rtx);
    1999        61995 :   emit_jump (end_label);
    2000        61995 :   emit_barrier ();
    2001        61995 :   emit_label (fail_label);
    2002        61995 :   emit_move_insn (target, const1_rtx);
    2003        61995 :   emit_label (end_label);
    2004              : 
    2005        61995 :   return target;
    2006              : }
    2007              : 
    2008              : /* Emit code to move a block Y to a block X.  This may be done with
    2009              :    string-move instructions, with multiple scalar move instructions,
    2010              :    or with a library call.
    2011              : 
    2012              :    Both X and Y must be MEM rtx's (perhaps inside VOLATILE) with mode BLKmode.
    2013              :    SIZE is an rtx that says how long they are.
    2014              :    ALIGN is the maximum alignment we can assume they have.
    2015              :    METHOD describes what kind of copy this is, and what mechanisms may be used.
    2016              :    MIN_SIZE is the minimal size of block to move
    2017              :    MAX_SIZE is the maximal size of block to move, if it cannot be represented
    2018              :    in unsigned HOST_WIDE_INT, than it is mask of all ones.
    2019              :    CTZ_SIZE is the trailing-zeros count of SIZE; even a nonconstant SIZE is
    2020              :    known to be a multiple of 1<<CTZ_SIZE.
    2021              : 
    2022              :    Return the address of the new block, if memcpy is called and returns it,
    2023              :    0 otherwise.  */
    2024              : 
    2025              : rtx
    2026       674062 : emit_block_move_hints (rtx x, rtx y, rtx size, enum block_op_methods method,
    2027              :                        unsigned int expected_align, HOST_WIDE_INT expected_size,
    2028              :                        unsigned HOST_WIDE_INT min_size,
    2029              :                        unsigned HOST_WIDE_INT max_size,
    2030              :                        unsigned HOST_WIDE_INT probable_max_size,
    2031              :                        bool bail_out_libcall, bool *is_move_done,
    2032              :                        bool might_overlap, unsigned ctz_size)
    2033              : {
    2034       674062 :   int may_use_call;
    2035       674062 :   rtx retval = 0;
    2036       674062 :   unsigned int align;
    2037              : 
    2038       674062 :   if (is_move_done)
    2039        98017 :     *is_move_done = true;
    2040              : 
    2041       674062 :   gcc_assert (size);
    2042       674062 :   if (CONST_INT_P (size) && INTVAL (size) == 0)
    2043              :     return 0;
    2044              : 
    2045       673785 :   switch (method)
    2046              :     {
    2047              :     case BLOCK_OP_NORMAL:
    2048              :     case BLOCK_OP_TAILCALL:
    2049              :       may_use_call = 1;
    2050              :       break;
    2051              : 
    2052       269799 :     case BLOCK_OP_CALL_PARM:
    2053       269799 :       may_use_call = block_move_libcall_safe_for_call_parm ();
    2054              : 
    2055              :       /* Make inhibit_defer_pop nonzero around the library call
    2056              :          to force it to pop the arguments right away.  */
    2057       269799 :       NO_DEFER_POP;
    2058       269799 :       break;
    2059              : 
    2060          354 :     case BLOCK_OP_NO_LIBCALL:
    2061          354 :       may_use_call = 0;
    2062          354 :       break;
    2063              : 
    2064         1075 :     case BLOCK_OP_NO_LIBCALL_RET:
    2065         1075 :       may_use_call = -1;
    2066         1075 :       break;
    2067              : 
    2068            0 :     default:
    2069            0 :       gcc_unreachable ();
    2070              :     }
    2071              : 
    2072       673785 :   gcc_assert (MEM_P (x) && MEM_P (y));
    2073       673870 :   align = MIN (MEM_ALIGN (x), MEM_ALIGN (y));
    2074       673785 :   gcc_assert (align >= BITS_PER_UNIT);
    2075              : 
    2076              :   /* Make sure we've got BLKmode addresses; store_one_arg can decide that
    2077              :      block copy is more efficient for other large modes, e.g. DCmode.  */
    2078       673785 :   x = adjust_address (x, BLKmode, 0);
    2079       673785 :   y = adjust_address (y, BLKmode, 0);
    2080              : 
    2081              :   /* If source and destination are the same, no need to copy anything.  */
    2082       673785 :   if (rtx_equal_p (x, y)
    2083           17 :       && !MEM_VOLATILE_P (x)
    2084       673802 :       && !MEM_VOLATILE_P (y))
    2085              :     return 0;
    2086              : 
    2087              :   /* Set MEM_SIZE as appropriate for this block copy.  The main place this
    2088              :      can be incorrect is coming from __builtin_memcpy.  */
    2089       673768 :   poly_int64 const_size;
    2090       673768 :   if (poly_int_rtx_p (size, &const_size))
    2091              :     {
    2092       595179 :       x = shallow_copy_rtx (x);
    2093       595179 :       y = shallow_copy_rtx (y);
    2094       595179 :       set_mem_size (x, const_size);
    2095       595179 :       set_mem_size (y, const_size);
    2096              :     }
    2097              : 
    2098       673768 :   bool pieces_ok = CONST_INT_P (size)
    2099       673768 :     && can_move_by_pieces (INTVAL (size), align);
    2100       673768 :   bool pattern_ok = false;
    2101              : 
    2102       673768 :   if (!pieces_ok || might_overlap)
    2103              :     {
    2104       106391 :       pattern_ok
    2105       106391 :         = emit_block_move_via_pattern (x, y, size, align,
    2106              :                                        expected_align, expected_size,
    2107              :                                        min_size, max_size, probable_max_size,
    2108              :                                        might_overlap);
    2109       106391 :       if (!pattern_ok && might_overlap)
    2110              :         {
    2111              :           /* Do not try any of the other methods below as they are not safe
    2112              :              for overlapping moves.  */
    2113        12659 :           *is_move_done = false;
    2114        12659 :           return retval;
    2115              :         }
    2116              :     }
    2117              : 
    2118        93732 :   bool dynamic_direction = false;
    2119        93732 :   if (!pattern_ok && !pieces_ok && may_use_call
    2120       136090 :       && (flag_inline_stringops & (might_overlap ? ILSOP_MEMMOVE : ILSOP_MEMCPY)))
    2121              :     {
    2122       661109 :       may_use_call = 0;
    2123       661109 :       dynamic_direction = might_overlap;
    2124              :     }
    2125              : 
    2126       661109 :   if (pattern_ok)
    2127              :     ;
    2128       635422 :   else if (pieces_ok)
    2129       567377 :     move_by_pieces (x, y, INTVAL (size), align, RETURN_BEGIN);
    2130        68045 :   else if (may_use_call && !might_overlap
    2131        67994 :            && ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (x))
    2132       136039 :            && ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (y)))
    2133              :     {
    2134        67994 :       if (bail_out_libcall)
    2135              :         {
    2136          260 :           if (is_move_done)
    2137          260 :             *is_move_done = false;
    2138              :           return retval;
    2139              :         }
    2140              : 
    2141        67734 :       if (may_use_call < 0)
    2142            0 :         return pc_rtx;
    2143              : 
    2144        67734 :       retval = emit_block_copy_via_libcall (x, y, size,
    2145              :                                             method == BLOCK_OP_TAILCALL);
    2146              :     }
    2147           51 :   else if (dynamic_direction)
    2148            0 :     emit_block_move_via_oriented_loop (x, y, size, align, ctz_size);
    2149           51 :   else if (might_overlap)
    2150            0 :     *is_move_done = false;
    2151              :   else
    2152           51 :     emit_block_move_via_sized_loop (x, y, size, align, ctz_size);
    2153              : 
    2154       660849 :   if (method == BLOCK_OP_CALL_PARM)
    2155       269784 :     OK_DEFER_POP;
    2156              : 
    2157              :   return retval;
    2158              : }
    2159              : 
    2160              : rtx
    2161       576045 : emit_block_move (rtx x, rtx y, rtx size, enum block_op_methods method,
    2162              :                  unsigned int ctz_size)
    2163              : {
    2164       576045 :   unsigned HOST_WIDE_INT max, min = 0;
    2165       576045 :   if (GET_CODE (size) == CONST_INT)
    2166       575825 :     min = max = UINTVAL (size);
    2167              :   else
    2168          220 :     max = GET_MODE_MASK (GET_MODE (size));
    2169       576045 :   return emit_block_move_hints (x, y, size, method, 0, -1,
    2170              :                                 min, max, max,
    2171       576045 :                                 false, NULL, false, ctz_size);
    2172              : }
    2173              : 
    2174              : /* A subroutine of emit_block_move.  Returns true if calling the
    2175              :    block move libcall will not clobber any parameters which may have
    2176              :    already been placed on the stack.  */
    2177              : 
    2178              : static bool
    2179       269799 : block_move_libcall_safe_for_call_parm (void)
    2180              : {
    2181       269799 :   tree fn;
    2182              : 
    2183              :   /* If arguments are pushed on the stack, then they're safe.  */
    2184       269799 :   if (targetm.calls.push_argument (0))
    2185              :     return true;
    2186              : 
    2187              :   /* If registers go on the stack anyway, any argument is sure to clobber
    2188              :      an outgoing argument.  */
    2189              : #if defined (REG_PARM_STACK_SPACE)
    2190            3 :   fn = builtin_decl_implicit (BUILT_IN_MEMCPY);
    2191              :   /* Avoid set but not used warning if *REG_PARM_STACK_SPACE doesn't
    2192              :      depend on its argument.  */
    2193            3 :   (void) fn;
    2194            3 :   if (OUTGOING_REG_PARM_STACK_SPACE ((!fn ? NULL_TREE : TREE_TYPE (fn)))
    2195            3 :       && REG_PARM_STACK_SPACE (fn) != 0)
    2196              :     return false;
    2197              : #endif
    2198              : 
    2199              :   /* If any argument goes in memory, then it might clobber an outgoing
    2200              :      argument.  */
    2201            3 :   {
    2202            3 :     CUMULATIVE_ARGS args_so_far_v;
    2203            3 :     cumulative_args_t args_so_far;
    2204            3 :     tree arg;
    2205              : 
    2206            3 :     fn = builtin_decl_implicit (BUILT_IN_MEMCPY);
    2207            3 :     INIT_CUMULATIVE_ARGS (args_so_far_v, TREE_TYPE (fn), NULL_RTX, 0, 3);
    2208            3 :     args_so_far = pack_cumulative_args (&args_so_far_v);
    2209              : 
    2210            3 :     arg = TYPE_ARG_TYPES (TREE_TYPE (fn));
    2211           12 :     for ( ; arg != void_list_node ; arg = TREE_CHAIN (arg))
    2212              :       {
    2213            9 :         machine_mode mode = TYPE_MODE (TREE_VALUE (arg));
    2214            9 :         function_arg_info arg_info (mode, /*named=*/true);
    2215            9 :         rtx tmp = targetm.calls.function_arg (args_so_far, arg_info);
    2216            9 :         if (!tmp || !REG_P (tmp))
    2217            0 :           return false;
    2218            9 :         if (targetm.calls.arg_partial_bytes (args_so_far, arg_info))
    2219              :           return false;
    2220            9 :         targetm.calls.function_arg_advance (args_so_far, arg_info);
    2221              :       }
    2222              :   }
    2223            3 :   return true;
    2224              : }
    2225              : 
    2226              : /* A subroutine of emit_block_move.  Expand a cpymem or movmem pattern;
    2227              :    return true if successful.
    2228              : 
    2229              :    X is the destination of the copy or move.
    2230              :    Y is the source of the copy or move.
    2231              :    SIZE is the size of the block to be moved.
    2232              : 
    2233              :    MIGHT_OVERLAP indicates this originated with expansion of a
    2234              :    builtin_memmove() and the source and destination blocks may
    2235              :    overlap.
    2236              :   */
    2237              : 
    2238              : static bool
    2239       106391 : emit_block_move_via_pattern (rtx x, rtx y, rtx size, unsigned int align,
    2240              :                              unsigned int expected_align,
    2241              :                              HOST_WIDE_INT expected_size,
    2242              :                              unsigned HOST_WIDE_INT min_size,
    2243              :                              unsigned HOST_WIDE_INT max_size,
    2244              :                              unsigned HOST_WIDE_INT probable_max_size,
    2245              :                              bool might_overlap)
    2246              : {
    2247       106391 :   if (expected_align < align)
    2248              :     expected_align = align;
    2249       106391 :   if (expected_size != -1)
    2250              :     {
    2251           22 :       if ((unsigned HOST_WIDE_INT)expected_size > probable_max_size)
    2252            0 :         expected_size = probable_max_size;
    2253           22 :       if ((unsigned HOST_WIDE_INT)expected_size < min_size)
    2254            0 :         expected_size = min_size;
    2255              :     }
    2256              : 
    2257              :   /* Since this is a move insn, we don't care about volatility.  */
    2258       106391 :   temporary_volatile_ok v (true);
    2259              : 
    2260              :   /* Try the most limited insn first, because there's no point
    2261              :      including more than one in the machine description unless
    2262              :      the more limited one has some advantage.  */
    2263              : 
    2264       106391 :   opt_scalar_int_mode mode_iter;
    2265       726805 :   FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
    2266              :     {
    2267       646101 :       scalar_int_mode mode = mode_iter.require ();
    2268       646101 :       enum insn_code code;
    2269       646101 :       if (might_overlap)
    2270       102797 :         code = direct_optab_handler (movmem_optab, mode);
    2271              :       else
    2272       543304 :         code = direct_optab_handler (cpymem_optab, mode);
    2273              : 
    2274       646101 :       if (code != CODE_FOR_nothing
    2275              :           /* We don't need MODE to be narrower than BITS_PER_HOST_WIDE_INT
    2276              :              here because if SIZE is less than the mode mask, as it is
    2277              :              returned by the macro, it will definitely be less than the
    2278              :              actual mode mask.  Since SIZE is within the Pmode address
    2279              :              space, we limit MODE to Pmode.  */
    2280       646101 :           && ((CONST_INT_P (size)
    2281        42942 :                && ((unsigned HOST_WIDE_INT) INTVAL (size)
    2282        42942 :                    <= (GET_MODE_MASK (mode) >> 1)))
    2283       143141 :               || max_size <= (GET_MODE_MASK (mode) >> 1)
    2284       181084 :               || GET_MODE_BITSIZE (mode) >= GET_MODE_BITSIZE (Pmode)))
    2285              :         {
    2286       123525 :           class expand_operand ops[9];
    2287       123525 :           unsigned int nops;
    2288              : 
    2289              :           /* ??? When called via emit_block_move_for_call, it'd be
    2290              :              nice if there were some way to inform the backend, so
    2291              :              that it doesn't fail the expansion because it thinks
    2292              :              emitting the libcall would be more efficient.  */
    2293       123525 :           nops = insn_data[(int) code].n_generator_args;
    2294       123525 :           gcc_assert (nops == 4 || nops == 6 || nops == 8 || nops == 9);
    2295              : 
    2296       123525 :           create_fixed_operand (&ops[0], x);
    2297       123525 :           create_fixed_operand (&ops[1], y);
    2298              :           /* The check above guarantees that this size conversion is valid.  */
    2299       123525 :           create_convert_operand_to (&ops[2], size, mode, true);
    2300       123525 :           create_integer_operand (&ops[3], align / BITS_PER_UNIT);
    2301       123525 :           if (nops >= 6)
    2302              :             {
    2303       123525 :               create_integer_operand (&ops[4], expected_align / BITS_PER_UNIT);
    2304       123525 :               create_integer_operand (&ops[5], expected_size);
    2305              :             }
    2306       123525 :           if (nops >= 8)
    2307              :             {
    2308       123525 :               create_integer_operand (&ops[6], min_size);
    2309              :               /* If we cannot represent the maximal size,
    2310              :                  make parameter NULL.  */
    2311       123525 :               if ((HOST_WIDE_INT) max_size != -1)
    2312       105975 :                 create_integer_operand (&ops[7], max_size);
    2313              :               else
    2314        17550 :                 create_fixed_operand (&ops[7], NULL);
    2315              :             }
    2316       123525 :           if (nops == 9)
    2317              :             {
    2318              :               /* If we cannot represent the maximal size,
    2319              :                  make parameter NULL.  */
    2320       123525 :               if ((HOST_WIDE_INT) probable_max_size != -1)
    2321       108082 :                 create_integer_operand (&ops[8], probable_max_size);
    2322              :               else
    2323        15443 :                 create_fixed_operand (&ops[8], NULL);
    2324              :             }
    2325       123525 :           gcc_assert (min_size != max_size
    2326              :                       || rtx_equal_p (ops[2].value, GEN_INT (min_size)));
    2327       123525 :           if (maybe_expand_insn (code, nops, ops))
    2328        25687 :             return true;
    2329              :         }
    2330              :     }
    2331              : 
    2332              :   return false;
    2333       106391 : }
    2334              : 
    2335              : /* Like emit_block_move_via_loop, but choose a suitable INCR based on
    2336              :    ALIGN and CTZ_SIZE.  */
    2337              : 
    2338              : static void
    2339           51 : emit_block_move_via_sized_loop (rtx x, rtx y, rtx size,
    2340              :                                 unsigned int align,
    2341              :                                 unsigned int ctz_size)
    2342              : {
    2343           51 :   int incr = align / BITS_PER_UNIT;
    2344              : 
    2345           51 :   if (CONST_INT_P (size))
    2346            3 :     ctz_size = MAX (ctz_size, (unsigned) wi::ctz (UINTVAL (size)));
    2347              : 
    2348           51 :   if (HOST_WIDE_INT_1U << ctz_size < (unsigned HOST_WIDE_INT) incr)
    2349            0 :     incr = HOST_WIDE_INT_1U << ctz_size;
    2350              : 
    2351           51 :   while (incr > 1 && !can_move_by_pieces (incr, align))
    2352            0 :     incr >>= 1;
    2353              : 
    2354           51 :   gcc_checking_assert (incr);
    2355              : 
    2356           51 :   return emit_block_move_via_loop (x, y, size, align, incr);
    2357              : }
    2358              : 
    2359              : /* Like emit_block_move_via_sized_loop, but besides choosing INCR so
    2360              :    as to ensure safe moves even in case of overlap, output dynamic
    2361              :    tests to choose between two loops, one moving downwards, another
    2362              :    moving upwards.  */
    2363              : 
    2364              : static void
    2365            0 : emit_block_move_via_oriented_loop (rtx x, rtx y, rtx size,
    2366              :                                    unsigned int align,
    2367              :                                    unsigned int ctz_size)
    2368              : {
    2369            0 :   int incr = align / BITS_PER_UNIT;
    2370              : 
    2371            0 :   if (CONST_INT_P (size))
    2372            0 :     ctz_size = MAX (ctz_size, (unsigned) wi::ctz (UINTVAL (size)));
    2373              : 
    2374            0 :   if (HOST_WIDE_INT_1U << ctz_size < (unsigned HOST_WIDE_INT) incr)
    2375            0 :     incr = HOST_WIDE_INT_1U << ctz_size;
    2376              : 
    2377            0 :   while (incr > 1 && !int_mode_for_size (incr, 0).exists ())
    2378            0 :     incr >>= 1;
    2379              : 
    2380            0 :   gcc_checking_assert (incr);
    2381              : 
    2382            0 :   rtx_code_label *upw_label, *end_label;
    2383            0 :   upw_label = gen_label_rtx ();
    2384            0 :   end_label = gen_label_rtx ();
    2385              : 
    2386            0 :   rtx x_addr = force_operand (XEXP (x, 0), NULL_RTX);
    2387            0 :   rtx y_addr = force_operand (XEXP (y, 0), NULL_RTX);
    2388            0 :   do_pending_stack_adjust ();
    2389              : 
    2390            0 :   machine_mode mode = GET_MODE (x_addr);
    2391            0 :   if (mode != GET_MODE (y_addr))
    2392              :     {
    2393            0 :       scalar_int_mode xmode
    2394            0 :         = smallest_int_mode_for_size (GET_MODE_BITSIZE (mode)).require ();
    2395            0 :       scalar_int_mode ymode
    2396            0 :         = smallest_int_mode_for_size (GET_MODE_BITSIZE
    2397            0 :                                       (GET_MODE (y_addr))).require ();
    2398            0 :       if (GET_MODE_BITSIZE (xmode) < GET_MODE_BITSIZE (ymode))
    2399              :         mode = ymode;
    2400              :       else
    2401            0 :         mode = xmode;
    2402              : 
    2403              : #ifndef POINTERS_EXTEND_UNSIGNED
    2404              :       const int POINTERS_EXTEND_UNSIGNED = 1;
    2405              : #endif
    2406            0 :       x_addr = convert_modes (mode, GET_MODE (x_addr), x_addr,
    2407              :                               POINTERS_EXTEND_UNSIGNED);
    2408            0 :       y_addr = convert_modes (mode, GET_MODE (y_addr), y_addr,
    2409              :                               POINTERS_EXTEND_UNSIGNED);
    2410              :     }
    2411              : 
    2412              :   /* Test for overlap: if (x >= y || x + size <= y) goto upw_label.  */
    2413            0 :   emit_cmp_and_jump_insns (x_addr, y_addr, GEU, NULL_RTX, mode,
    2414              :                            true, upw_label,
    2415            0 :                            profile_probability::guessed_always ()
    2416              :                                 .apply_scale (5, 10));
    2417            0 :   rtx tmp = convert_modes (GET_MODE (x_addr), GET_MODE (size), size, true);
    2418            0 :   tmp = simplify_gen_binary (PLUS, GET_MODE (x_addr), x_addr, tmp);
    2419              : 
    2420            0 :   emit_cmp_and_jump_insns (tmp, y_addr, LEU, NULL_RTX, mode,
    2421              :                            true, upw_label,
    2422            0 :                            profile_probability::guessed_always ()
    2423              :                                 .apply_scale (8, 10));
    2424              : 
    2425            0 :   emit_block_move_via_loop (x, y, size, align, -incr);
    2426              : 
    2427            0 :   emit_jump (end_label);
    2428            0 :   emit_label (upw_label);
    2429              : 
    2430            0 :   emit_block_move_via_loop (x, y, size, align, incr);
    2431              : 
    2432            0 :   emit_label (end_label);
    2433            0 : }
    2434              : 
    2435              : /* A subroutine of emit_block_move.  Copy the data via an explicit
    2436              :    loop.  This is used only when libcalls are forbidden, or when
    2437              :    inlining is required.  INCR is the block size to be copied in each
    2438              :    loop iteration.  If it is negative, the absolute value is used, and
    2439              :    the block is copied backwards.  INCR must be a power of two, an
    2440              :    exact divisor for SIZE and ALIGN, and imply a mode that can be
    2441              :    safely copied per iteration assuming no overlap.  */
    2442              : 
    2443              : static void
    2444           51 : emit_block_move_via_loop (rtx x, rtx y, rtx size,
    2445              :                           unsigned int align, int incr)
    2446              : {
    2447           51 :   rtx_code_label *cmp_label, *top_label;
    2448           51 :   rtx iter, x_addr, y_addr, tmp;
    2449           51 :   machine_mode x_addr_mode = get_address_mode (x);
    2450           51 :   machine_mode y_addr_mode = get_address_mode (y);
    2451           51 :   machine_mode iter_mode;
    2452              : 
    2453           51 :   iter_mode = GET_MODE (size);
    2454           51 :   if (iter_mode == VOIDmode)
    2455            3 :     iter_mode = word_mode;
    2456              : 
    2457           51 :   top_label = gen_label_rtx ();
    2458           51 :   cmp_label = gen_label_rtx ();
    2459           51 :   iter = gen_reg_rtx (iter_mode);
    2460              : 
    2461           51 :   bool downwards = incr < 0;
    2462           51 :   rtx iter_init;
    2463           51 :   rtx_code iter_cond;
    2464           51 :   rtx iter_limit;
    2465           51 :   rtx iter_incr;
    2466           51 :   machine_mode move_mode;
    2467           51 :   if (downwards)
    2468              :     {
    2469            0 :       incr = -incr;
    2470            0 :       iter_init = size;
    2471            0 :       iter_cond = GEU;
    2472            0 :       iter_limit = const0_rtx;
    2473            0 :       iter_incr = GEN_INT (incr);
    2474              :     }
    2475              :   else
    2476              :     {
    2477           51 :       iter_init = const0_rtx;
    2478           51 :       iter_cond = LTU;
    2479           51 :       iter_limit = size;
    2480           51 :       iter_incr = GEN_INT (incr);
    2481              :     }
    2482           51 :   emit_move_insn (iter, iter_init);
    2483              : 
    2484           51 :   opt_scalar_int_mode int_move_mode
    2485           51 :     = int_mode_for_size (incr * BITS_PER_UNIT, 1);
    2486           51 :   if (!int_move_mode.exists (&move_mode)
    2487          102 :       || GET_MODE_BITSIZE (int_move_mode.require ()) != incr * BITS_PER_UNIT)
    2488              :     {
    2489            0 :       move_mode = BLKmode;
    2490            0 :       gcc_checking_assert (can_move_by_pieces (incr, align));
    2491              :     }
    2492              : 
    2493           51 :   x_addr = force_operand (XEXP (x, 0), NULL_RTX);
    2494           51 :   y_addr = force_operand (XEXP (y, 0), NULL_RTX);
    2495           51 :   do_pending_stack_adjust ();
    2496              : 
    2497           51 :   emit_jump (cmp_label);
    2498           51 :   emit_label (top_label);
    2499              : 
    2500           51 :   tmp = convert_modes (x_addr_mode, iter_mode, iter, true);
    2501           51 :   x_addr = simplify_gen_binary (PLUS, x_addr_mode, x_addr, tmp);
    2502              : 
    2503           51 :   if (x_addr_mode != y_addr_mode)
    2504            0 :     tmp = convert_modes (y_addr_mode, iter_mode, iter, true);
    2505           51 :   y_addr = simplify_gen_binary (PLUS, y_addr_mode, y_addr, tmp);
    2506              : 
    2507           51 :   x = change_address (x, move_mode, x_addr);
    2508           51 :   y = change_address (y, move_mode, y_addr);
    2509              : 
    2510           51 :   if (move_mode == BLKmode)
    2511              :     {
    2512            0 :       bool done;
    2513            0 :       emit_block_move_hints (x, y, iter_incr, BLOCK_OP_NO_LIBCALL,
    2514              :                              align, incr, incr, incr, incr,
    2515              :                              false, &done, false);
    2516            0 :       gcc_checking_assert (done);
    2517              :     }
    2518              :   else
    2519           51 :     emit_move_insn (x, y);
    2520              : 
    2521           51 :   if (downwards)
    2522            0 :     emit_label (cmp_label);
    2523              : 
    2524           51 :   tmp = expand_simple_binop (iter_mode, PLUS, iter, iter_incr, iter,
    2525              :                              true, OPTAB_LIB_WIDEN);
    2526           51 :   if (tmp != iter)
    2527            0 :     emit_move_insn (iter, tmp);
    2528              : 
    2529           51 :   if (!downwards)
    2530           51 :     emit_label (cmp_label);
    2531              : 
    2532           51 :   emit_cmp_and_jump_insns (iter, iter_limit, iter_cond, NULL_RTX, iter_mode,
    2533              :                            true, top_label,
    2534           51 :                            profile_probability::guessed_always ()
    2535              :                                 .apply_scale (9, 10));
    2536           51 : }
    2537              : 
    2538              : /* Expand a call to memcpy or memmove or memcmp, and return the result.
    2539              :    TAILCALL is true if this is a tail call.  */
    2540              : 
    2541              : rtx
    2542        67735 : emit_block_op_via_libcall (enum built_in_function fncode, rtx dst, rtx src,
    2543              :                            rtx size, bool tailcall)
    2544              : {
    2545        67735 :   rtx dst_addr, src_addr;
    2546        67735 :   tree call_expr, dst_tree, src_tree, size_tree;
    2547        67735 :   machine_mode size_mode;
    2548              : 
    2549              :   /* Since dst and src are passed to a libcall, mark the corresponding
    2550              :      tree EXPR as addressable.  */
    2551        67735 :   tree dst_expr = MEM_EXPR (dst);
    2552        67735 :   tree src_expr = MEM_EXPR (src);
    2553        67735 :   if (dst_expr)
    2554        61016 :     mark_addressable (dst_expr);
    2555        67735 :   if (src_expr)
    2556        66359 :     mark_addressable (src_expr);
    2557              : 
    2558        67735 :   dst_addr = copy_addr_to_reg (XEXP (dst, 0));
    2559        67735 :   dst_addr = convert_memory_address (ptr_mode, dst_addr);
    2560        67735 :   dst_tree = make_tree (ptr_type_node, dst_addr);
    2561              : 
    2562        67735 :   src_addr = copy_addr_to_reg (XEXP (src, 0));
    2563        67735 :   src_addr = convert_memory_address (ptr_mode, src_addr);
    2564        67735 :   src_tree = make_tree (ptr_type_node, src_addr);
    2565              : 
    2566        67735 :   size_mode = TYPE_MODE (sizetype);
    2567        67735 :   size = convert_to_mode (size_mode, size, 1);
    2568        67735 :   size = copy_to_mode_reg (size_mode, size);
    2569        67735 :   size_tree = make_tree (sizetype, size);
    2570              : 
    2571              :   /* It is incorrect to use the libcall calling conventions for calls to
    2572              :      memcpy/memmove/memcmp because they can be provided by the user.  */
    2573        67735 :   tree fn = builtin_decl_implicit (fncode);
    2574        67735 :   call_expr = build_call_expr (fn, 3, dst_tree, src_tree, size_tree);
    2575        67735 :   CALL_EXPR_TAILCALL (call_expr) = tailcall;
    2576              : 
    2577        67735 :   return expand_call (call_expr, NULL_RTX, false);
    2578              : }
    2579              : 
    2580              : /* Try to expand cmpstrn or cmpmem operation ICODE with the given operands.
    2581              :    ARG3_TYPE is the type of ARG3_RTX.  Return the result rtx on success,
    2582              :    otherwise return null.  */
    2583              : 
    2584              : rtx
    2585       171904 : expand_cmpstrn_or_cmpmem (insn_code icode, rtx target, rtx arg1_rtx,
    2586              :                           rtx arg2_rtx, tree arg3_type, rtx arg3_rtx,
    2587              :                           HOST_WIDE_INT align)
    2588              : {
    2589       171904 :   machine_mode insn_mode = insn_data[icode].operand[0].mode;
    2590              : 
    2591       171904 :   if (target && (!REG_P (target) || HARD_REGISTER_P (target)))
    2592              :     target = NULL_RTX;
    2593              : 
    2594       171904 :   class expand_operand ops[5];
    2595       171904 :   create_output_operand (&ops[0], target, insn_mode);
    2596       171904 :   create_fixed_operand (&ops[1], arg1_rtx);
    2597       171904 :   create_fixed_operand (&ops[2], arg2_rtx);
    2598       171904 :   create_convert_operand_from (&ops[3], arg3_rtx, TYPE_MODE (arg3_type),
    2599       171904 :                                TYPE_UNSIGNED (arg3_type));
    2600       171904 :   create_integer_operand (&ops[4], align);
    2601       171904 :   if (maybe_expand_insn (icode, 5, ops))
    2602         5802 :     return ops[0].value;
    2603              :   return NULL_RTX;
    2604              : }
    2605              : 
    2606              : /* Expand a block compare between X and Y with length LEN using the
    2607              :    cmpmem optab, placing the result in TARGET.  LEN_TYPE is the type
    2608              :    of the expression that was used to calculate the length.  ALIGN
    2609              :    gives the known minimum common alignment.  */
    2610              : 
    2611              : static rtx
    2612        43986 : emit_block_cmp_via_cmpmem (rtx x, rtx y, rtx len, tree len_type, rtx target,
    2613              :                            unsigned align)
    2614              : {
    2615              :   /* Note: The cmpstrnsi pattern, if it exists, is not suitable for
    2616              :      implementing memcmp because it will stop if it encounters two
    2617              :      zero bytes.  */
    2618        43986 :   insn_code icode = direct_optab_handler (cmpmem_optab, SImode);
    2619              : 
    2620        43986 :   if (icode == CODE_FOR_nothing)
    2621              :     return NULL_RTX;
    2622              : 
    2623        43986 :   return expand_cmpstrn_or_cmpmem (icode, target, x, y, len_type, len, align);
    2624              : }
    2625              : 
    2626              : /* Emit code to compare a block Y to a block X.  This may be done with
    2627              :    string-compare instructions, with multiple scalar instructions,
    2628              :    or with a library call.
    2629              : 
    2630              :    Both X and Y must be MEM rtx's.  LEN is an rtx that says how long
    2631              :    they are.  LEN_TYPE is the type of the expression that was used to
    2632              :    calculate it, and CTZ_LEN is the known trailing-zeros count of LEN,
    2633              :    so LEN must be a multiple of 1<<CTZ_LEN even if it's not constant.
    2634              : 
    2635              :    If EQUALITY_ONLY is true, it means we don't have to return the tri-state
    2636              :    value of a normal memcmp call, instead we can just compare for equality.
    2637              :    If FORCE_LIBCALL is true, we should emit a call to memcmp rather than
    2638              :    returning NULL_RTX.
    2639              : 
    2640              :    Optionally, the caller can pass a constfn and associated data in Y_CFN
    2641              :    and Y_CFN_DATA. describing that the second operand being compared is a
    2642              :    known constant and how to obtain its data.
    2643              :    Return the result of the comparison, or NULL_RTX if we failed to
    2644              :    perform the operation.  */
    2645              : 
    2646              : rtx
    2647       105980 : emit_block_cmp_hints (rtx x, rtx y, rtx len, tree len_type, rtx target,
    2648              :                       bool equality_only, by_pieces_constfn y_cfn,
    2649              :                       void *y_cfndata, unsigned ctz_len)
    2650              : {
    2651       105980 :   rtx result = 0;
    2652              : 
    2653       105980 :   if (CONST_INT_P (len) && INTVAL (len) == 0)
    2654            0 :     return const0_rtx;
    2655              : 
    2656       105980 :   gcc_assert (MEM_P (x) && MEM_P (y));
    2657       105980 :   unsigned int align = MIN (MEM_ALIGN (x), MEM_ALIGN (y));
    2658       105980 :   gcc_assert (align >= BITS_PER_UNIT);
    2659              : 
    2660       105980 :   x = adjust_address (x, BLKmode, 0);
    2661       105980 :   y = adjust_address (y, BLKmode, 0);
    2662              : 
    2663       105980 :   if (equality_only
    2664        90732 :       && CONST_INT_P (len)
    2665       175175 :       && can_do_by_pieces (INTVAL (len), align, COMPARE_BY_PIECES))
    2666        61994 :     result = compare_by_pieces (x, y, INTVAL (len), target, align,
    2667              :                                 y_cfn, y_cfndata);
    2668              :   else
    2669        43986 :     result = emit_block_cmp_via_cmpmem (x, y, len, len_type, target, align);
    2670              : 
    2671       105980 :   if (!result && (flag_inline_stringops & ILSOP_MEMCMP))
    2672          364 :     result = emit_block_cmp_via_loop (x, y, len, len_type,
    2673              :                                       target, equality_only,
    2674              :                                       align, ctz_len);
    2675              : 
    2676              :   return result;
    2677              : }
    2678              : 
    2679              : /* Like emit_block_cmp_hints, but with known alignment and no support
    2680              :    for constats.  Always expand to a loop with iterations that compare
    2681              :    blocks of the largest compare-by-pieces size that divides both len
    2682              :    and align, and then, if !EQUALITY_ONLY, identify the word and then
    2683              :    the unit that first differs to return the result.  */
    2684              : 
    2685              : rtx
    2686          406 : emit_block_cmp_via_loop (rtx x, rtx y, rtx len, tree len_type, rtx target,
    2687              :                          bool equality_only, unsigned align, unsigned ctz_len)
    2688              : {
    2689          406 :   unsigned incr = align / BITS_PER_UNIT;
    2690              : 
    2691          406 :   if (CONST_INT_P (len))
    2692          322 :     ctz_len = MAX (ctz_len, (unsigned) wi::ctz (UINTVAL (len)));
    2693              : 
    2694          406 :   if (HOST_WIDE_INT_1U << ctz_len < (unsigned HOST_WIDE_INT) incr)
    2695          148 :     incr = HOST_WIDE_INT_1U << ctz_len;
    2696              : 
    2697              :   while (incr > 1
    2698          410 :          && !can_do_by_pieces (incr, align, COMPARE_BY_PIECES))
    2699            4 :     incr >>= 1;
    2700              : 
    2701          406 :   rtx_code_label *cmp_label, *top_label, *ne_label, *res_label;
    2702          406 :   rtx iter, x_addr, y_addr, tmp;
    2703          406 :   machine_mode x_addr_mode = get_address_mode (x);
    2704          406 :   machine_mode y_addr_mode = get_address_mode (y);
    2705          406 :   machine_mode iter_mode;
    2706              : 
    2707          406 :   iter_mode = GET_MODE (len);
    2708          406 :   if (iter_mode == VOIDmode)
    2709          322 :     iter_mode = word_mode;
    2710              : 
    2711          406 :   rtx iter_init = const0_rtx;
    2712          406 :   rtx_code iter_cond = LTU;
    2713          406 :   rtx_code entry_cond = GEU;
    2714          406 :   rtx iter_limit = len;
    2715          406 :   rtx iter_incr = GEN_INT (incr);
    2716          406 :   machine_mode cmp_mode;
    2717              : 
    2718              :   /* We can drop the loop back edge if we know there's exactly one
    2719              :      iteration.  */
    2720          406 :   top_label = (!rtx_equal_p (len, iter_incr)
    2721          406 :                ? gen_label_rtx ()
    2722              :                : NULL);
    2723              :   /* We need not test before entering the loop if len is known
    2724              :      nonzero.  ??? This could be even stricter, testing whether a
    2725              :      nonconstant LEN could possibly be zero.  */
    2726          406 :   cmp_label = (!CONSTANT_P (len) || rtx_equal_p (len, iter_init)
    2727          406 :                ? gen_label_rtx ()
    2728              :                : NULL);
    2729          406 :   ne_label = gen_label_rtx ();
    2730          406 :   res_label = gen_label_rtx ();
    2731              : 
    2732          406 :   iter = gen_reg_rtx (iter_mode);
    2733          406 :   emit_move_insn (iter, iter_init);
    2734              : 
    2735          406 :   opt_scalar_int_mode int_cmp_mode
    2736          406 :     = int_mode_for_size (incr * BITS_PER_UNIT, 1);
    2737          406 :   if (!int_cmp_mode.exists (&cmp_mode)
    2738         1216 :       || GET_MODE_BITSIZE (int_cmp_mode.require ()) != incr * BITS_PER_UNIT
    2739          405 :       || !can_compare_p (NE, cmp_mode, ccp_jump))
    2740              :     {
    2741            1 :       cmp_mode = BLKmode;
    2742            1 :       gcc_checking_assert (incr != 1);
    2743              :     }
    2744              : 
    2745              :   /* Save the base addresses.  */
    2746          406 :   x_addr = force_operand (XEXP (x, 0), NULL_RTX);
    2747          406 :   y_addr = force_operand (XEXP (y, 0), NULL_RTX);
    2748          406 :   do_pending_stack_adjust ();
    2749              : 
    2750          406 :   if (cmp_label)
    2751              :     {
    2752           84 :       if (top_label)
    2753           84 :         emit_jump (cmp_label);
    2754              :       else
    2755            0 :         emit_cmp_and_jump_insns (iter, iter_limit, entry_cond,
    2756              :                                  NULL_RTX, iter_mode,
    2757              :                                  true, cmp_label,
    2758            0 :                                  profile_probability::guessed_always ()
    2759              :                                  .apply_scale (1, 10));
    2760              :     }
    2761          406 :   if (top_label)
    2762          389 :     emit_label (top_label);
    2763              : 
    2764              :   /* Offset the base addresses by ITER.  */
    2765          406 :   tmp = convert_modes (x_addr_mode, iter_mode, iter, true);
    2766          406 :   x_addr = simplify_gen_binary (PLUS, x_addr_mode, x_addr, tmp);
    2767              : 
    2768          406 :   if (x_addr_mode != y_addr_mode)
    2769            0 :     tmp = convert_modes (y_addr_mode, iter_mode, iter, true);
    2770          406 :   y_addr = simplify_gen_binary (PLUS, y_addr_mode, y_addr, tmp);
    2771              : 
    2772          406 :   x = change_address (x, cmp_mode, x_addr);
    2773          406 :   y = change_address (y, cmp_mode, y_addr);
    2774              : 
    2775              :   /* Compare one block.  */
    2776          406 :   rtx part_res;
    2777          406 :   if (cmp_mode == BLKmode)
    2778            1 :     part_res = compare_by_pieces (x, y, incr, target, align, 0, 0);
    2779              :   else
    2780          405 :     part_res = expand_binop (cmp_mode, sub_optab, x, y, NULL_RTX,
    2781              :                              true, OPTAB_LIB_WIDEN);
    2782              : 
    2783              :   /* Stop if we found a difference.  */
    2784          812 :   emit_cmp_and_jump_insns (part_res, GEN_INT (0), NE, NULL_RTX,
    2785          406 :                            GET_MODE (part_res), true, ne_label,
    2786          406 :                            profile_probability::guessed_always ()
    2787              :                                 .apply_scale (1, 10));
    2788              : 
    2789              :   /* Increment ITER.  */
    2790          406 :   tmp = expand_simple_binop (iter_mode, PLUS, iter, iter_incr, iter,
    2791              :                              true, OPTAB_LIB_WIDEN);
    2792          406 :   if (tmp != iter)
    2793            0 :     emit_move_insn (iter, tmp);
    2794              : 
    2795          406 :   if (cmp_label)
    2796           84 :     emit_label (cmp_label);
    2797              :   /* Loop until we reach the limit.  */
    2798              : 
    2799          406 :   if (top_label)
    2800          389 :     emit_cmp_and_jump_insns (iter, iter_limit, iter_cond, NULL_RTX, iter_mode,
    2801              :                              true, top_label,
    2802          778 :                              profile_probability::guessed_always ()
    2803              :                              .apply_scale (9, 10));
    2804              : 
    2805              :   /* We got to the end without differences, so the result is zero.  */
    2806          406 :   if (target == NULL_RTX
    2807          406 :       || !REG_P (target) || REGNO (target) < FIRST_PSEUDO_REGISTER)
    2808           49 :     target = gen_reg_rtx (TYPE_MODE (integer_type_node));
    2809              : 
    2810          406 :   emit_move_insn (target, const0_rtx);
    2811          406 :   emit_jump (res_label);
    2812              : 
    2813          406 :   emit_label (ne_label);
    2814              : 
    2815              :   /* Return nonzero, or pinpoint the difference to return the expected
    2816              :      result for non-equality tests.  */
    2817          406 :   if (equality_only)
    2818            0 :     emit_move_insn (target, const1_rtx);
    2819              :   else
    2820              :     {
    2821          406 :       if (incr > UNITS_PER_WORD)
    2822              :         /* ??? Re-compare the block found to be different one word at a
    2823              :            time.  */
    2824            5 :         part_res = emit_block_cmp_via_loop (x, y, GEN_INT (incr), len_type,
    2825              :                                             target, equality_only,
    2826              :                                             BITS_PER_WORD, 0);
    2827          401 :       else if (incr > 1)
    2828              :         /* ??? Re-compare the block found to be different one byte at a
    2829              :            time.  We could do better using part_res, and being careful
    2830              :            about endianness.  */
    2831           37 :         part_res = emit_block_cmp_via_loop (x, y, GEN_INT (incr), len_type,
    2832              :                                             target, equality_only,
    2833              :                                             BITS_PER_UNIT, 0);
    2834         1092 :       else if (known_gt (GET_MODE_BITSIZE (GET_MODE (target)),
    2835              :                          GET_MODE_BITSIZE (cmp_mode)))
    2836          364 :         part_res = expand_binop (GET_MODE (target), sub_optab, x, y, target,
    2837              :                                  true, OPTAB_LIB_WIDEN);
    2838              :       else
    2839              :         {
    2840              :           /* In the odd chance target is QImode, we can't count on
    2841              :              widening subtract to capture the result of the unsigned
    2842              :              compares.  */
    2843            0 :           rtx_code_label *ltu_label;
    2844            0 :           ltu_label = gen_label_rtx ();
    2845            0 :           emit_cmp_and_jump_insns (x, y, LTU, NULL_RTX,
    2846              :                                    cmp_mode, true, ltu_label,
    2847            0 :                                    profile_probability::guessed_always ()
    2848              :                                    .apply_scale (5, 10));
    2849              : 
    2850            0 :           emit_move_insn (target, const1_rtx);
    2851            0 :           emit_jump (res_label);
    2852              : 
    2853            0 :           emit_label (ltu_label);
    2854            0 :           emit_move_insn (target, constm1_rtx);
    2855            0 :           part_res = target;
    2856              :         }
    2857              : 
    2858          406 :       if (target != part_res)
    2859            0 :         convert_move (target, part_res, false);
    2860              :     }
    2861              : 
    2862          406 :   emit_label (res_label);
    2863              : 
    2864          406 :   return target;
    2865              : }
    2866              : 
    2867              : 
    2868              : /* Copy all or part of a value X into registers starting at REGNO.
    2869              :    The number of registers to be filled is NREGS.  */
    2870              : 
    2871              : void
    2872          434 : move_block_to_reg (int regno, rtx x, int nregs, machine_mode mode)
    2873              : {
    2874          434 :   if (nregs == 0)
    2875              :     return;
    2876              : 
    2877          420 :   if (CONSTANT_P (x) && !targetm.legitimate_constant_p (mode, x))
    2878            0 :     x = validize_mem (force_const_mem (mode, x));
    2879              : 
    2880              :   /* See if the machine can do this with a load multiple insn.  */
    2881          420 :   if (targetm.have_load_multiple ())
    2882              :     {
    2883            0 :       rtx_insn *last = get_last_insn ();
    2884            0 :       rtx first = gen_rtx_REG (word_mode, regno);
    2885            0 :       if (rtx_insn *pat = targetm.gen_load_multiple (first, x,
    2886              :                                                      GEN_INT (nregs)))
    2887              :         {
    2888            0 :           emit_insn (pat);
    2889            0 :           return;
    2890              :         }
    2891              :       else
    2892            0 :         delete_insns_since (last);
    2893              :     }
    2894              : 
    2895          848 :   for (int i = 0; i < nregs; i++)
    2896          428 :     emit_move_insn (gen_rtx_REG (word_mode, regno + i),
    2897          428 :                     operand_subword_force (x, i, mode));
    2898              : }
    2899              : 
    2900              : /* Copy all or part of a BLKmode value X out of registers starting at REGNO.
    2901              :    The number of registers to be filled is NREGS.  */
    2902              : 
    2903              : void
    2904         1216 : move_block_from_reg (int regno, rtx x, int nregs)
    2905              : {
    2906         1216 :   if (nregs == 0)
    2907              :     return;
    2908              : 
    2909              :   /* See if the machine can do this with a store multiple insn.  */
    2910         1216 :   if (targetm.have_store_multiple ())
    2911              :     {
    2912            0 :       rtx_insn *last = get_last_insn ();
    2913            0 :       rtx first = gen_rtx_REG (word_mode, regno);
    2914            0 :       if (rtx_insn *pat = targetm.gen_store_multiple (x, first,
    2915              :                                                       GEN_INT (nregs)))
    2916              :         {
    2917            0 :           emit_insn (pat);
    2918            0 :           return;
    2919              :         }
    2920              :       else
    2921            0 :         delete_insns_since (last);
    2922              :     }
    2923              : 
    2924         2436 :   for (int i = 0; i < nregs; i++)
    2925              :     {
    2926         1220 :       rtx tem = operand_subword (x, i, 1, BLKmode);
    2927              : 
    2928         1220 :       gcc_assert (tem);
    2929              : 
    2930         1220 :       emit_move_insn (tem, gen_rtx_REG (word_mode, regno + i));
    2931              :     }
    2932              : }
    2933              : 
    2934              : /* Generate a PARALLEL rtx for a new non-consecutive group of registers from
    2935              :    ORIG, where ORIG is a non-consecutive group of registers represented by
    2936              :    a PARALLEL.  The clone is identical to the original except in that the
    2937              :    original set of registers is replaced by a new set of pseudo registers.
    2938              :    The new set has the same modes as the original set.  */
    2939              : 
    2940              : rtx
    2941         3327 : gen_group_rtx (rtx orig)
    2942              : {
    2943         3327 :   int i, length;
    2944         3327 :   rtx *tmps;
    2945              : 
    2946         3327 :   gcc_assert (GET_CODE (orig) == PARALLEL);
    2947              : 
    2948         3327 :   length = XVECLEN (orig, 0);
    2949         3327 :   tmps = XALLOCAVEC (rtx, length);
    2950              : 
    2951              :   /* Skip a NULL entry in first slot.  */
    2952         3327 :   i = XEXP (XVECEXP (orig, 0, 0), 0) ? 0 : 1;
    2953              : 
    2954         3327 :   if (i)
    2955            0 :     tmps[0] = 0;
    2956              : 
    2957         8114 :   for (; i < length; i++)
    2958              :     {
    2959         4787 :       machine_mode mode = GET_MODE (XEXP (XVECEXP (orig, 0, i), 0));
    2960         4787 :       rtx offset = XEXP (XVECEXP (orig, 0, i), 1);
    2961              : 
    2962         4787 :       tmps[i] = gen_rtx_EXPR_LIST (VOIDmode, gen_reg_rtx (mode), offset);
    2963              :     }
    2964              : 
    2965         3327 :   return gen_rtx_PARALLEL (GET_MODE (orig), gen_rtvec_v (length, tmps));
    2966              : }
    2967              : 
    2968              : /* A subroutine of emit_group_load.  Arguments as for emit_group_load,
    2969              :    except that values are placed in TMPS[i], and must later be moved
    2970              :    into corresponding XEXP (XVECEXP (DST, 0, i), 0) element.  */
    2971              : 
    2972              : static void
    2973       301953 : emit_group_load_1 (rtx *tmps, rtx dst, rtx orig_src, tree type,
    2974              :                    poly_int64 ssize)
    2975              : {
    2976       301956 :   rtx src;
    2977       301956 :   int start, i;
    2978       301956 :   machine_mode m = GET_MODE (orig_src);
    2979              : 
    2980       301956 :   gcc_assert (GET_CODE (dst) == PARALLEL);
    2981              : 
    2982       301956 :   if (m != VOIDmode
    2983       282720 :       && !SCALAR_INT_MODE_P (m)
    2984        19463 :       && !MEM_P (orig_src)
    2985         5727 :       && GET_CODE (orig_src) != CONCAT)
    2986              :     {
    2987            3 :       scalar_int_mode imode;
    2988            3 :       if (int_mode_for_mode (GET_MODE (orig_src)).exists (&imode))
    2989              :         {
    2990            3 :           src = gen_reg_rtx (imode);
    2991            3 :           emit_move_insn (gen_lowpart (GET_MODE (orig_src), src), orig_src);
    2992              :         }
    2993              :       else
    2994              :         {
    2995            0 :           src = assign_stack_temp (GET_MODE (orig_src), ssize);
    2996            0 :           emit_move_insn (src, orig_src);
    2997              :         }
    2998            3 :       emit_group_load_1 (tmps, dst, src, type, ssize);
    2999              :       return;
    3000              :     }
    3001              : 
    3002              :   /* Check for a NULL entry, used to indicate that the parameter goes
    3003              :      both on the stack and in registers.  */
    3004       301953 :   if (XEXP (XVECEXP (dst, 0, 0), 0))
    3005              :     start = 0;
    3006              :   else
    3007            0 :     start = 1;
    3008              : 
    3009              :   /* Process the pieces.  */
    3010       894191 :   for (i = start; i < XVECLEN (dst, 0); i++)
    3011              :     {
    3012       592238 :       machine_mode mode = GET_MODE (XEXP (XVECEXP (dst, 0, i), 0));
    3013       592238 :       poly_int64 bytepos = rtx_to_poly_int64 (XEXP (XVECEXP (dst, 0, i), 1));
    3014      1184476 :       poly_int64 bytelen = GET_MODE_SIZE (mode);
    3015       592238 :       poly_int64 shift = 0;
    3016              : 
    3017              :       /* Handle trailing fragments that run over the size of the struct.
    3018              :          It's the target's responsibility to make sure that the fragment
    3019              :          cannot be strictly smaller in some cases and strictly larger
    3020              :          in others.  */
    3021       592238 :       gcc_checking_assert (ordered_p (bytepos + bytelen, ssize));
    3022       592238 :       if (known_size_p (ssize) && maybe_gt (bytepos + bytelen, ssize))
    3023              :         {
    3024              :           /* Arrange to shift the fragment to where it belongs.
    3025              :              extract_bit_field loads to the lsb of the reg.  */
    3026              :           if (
    3027              : #ifdef BLOCK_REG_PADDING
    3028              :               BLOCK_REG_PADDING (GET_MODE (orig_src), type, i == start)
    3029              :               == (BYTES_BIG_ENDIAN ? PAD_UPWARD : PAD_DOWNWARD)
    3030              : #else
    3031              :               BYTES_BIG_ENDIAN
    3032              : #endif
    3033              :               )
    3034              :             shift = (bytelen - (ssize - bytepos)) * BITS_PER_UNIT;
    3035         1843 :           bytelen = ssize - bytepos;
    3036         1843 :           gcc_assert (maybe_gt (bytelen, 0));
    3037              :         }
    3038              : 
    3039              :       /* If we won't be loading directly from memory, protect the real source
    3040              :          from strange tricks we might play; but make sure that the source can
    3041              :          be loaded directly into the destination.  */
    3042       592238 :       src = orig_src;
    3043       592238 :       if (!MEM_P (orig_src)
    3044       490719 :           && (!REG_P (orig_src) || HARD_REGISTER_P (orig_src))
    3045        47141 :           && GET_CODE (orig_src) != CONCAT
    3046       630712 :           && !CONSTANT_P (orig_src))
    3047              :         {
    3048            2 :           gcc_assert (GET_MODE (orig_src) != VOIDmode);
    3049            2 :           src = force_reg (GET_MODE (orig_src), orig_src);
    3050              :         }
    3051              : 
    3052              :       /* Optimize the access just a bit.  */
    3053       592238 :       if (MEM_P (src)
    3054       101519 :           && (! targetm.slow_unaligned_access (mode, MEM_ALIGN (src))
    3055            0 :               || MEM_ALIGN (src) >= GET_MODE_ALIGNMENT (mode))
    3056       203038 :           && multiple_p (bytepos * BITS_PER_UNIT, GET_MODE_ALIGNMENT (mode))
    3057       693757 :           && known_eq (bytelen, GET_MODE_SIZE (mode)))
    3058              :         {
    3059        99695 :           tmps[i] = gen_reg_rtx (mode);
    3060        99695 :           emit_move_insn (tmps[i], adjust_address (src, mode, bytepos));
    3061              :         }
    3062       492543 :       else if (COMPLEX_MODE_P (mode)
    3063            0 :                && GET_MODE (src) == mode
    3064       492543 :                && known_eq (bytelen, GET_MODE_SIZE (mode)))
    3065              :         /* Let emit_move_complex do the bulk of the work.  */
    3066            0 :         tmps[i] = src;
    3067       492543 :       else if (SCALAR_INT_MODE_P (mode)
    3068       486030 :                && COMPLEX_MODE_P (GET_MODE (src))
    3069         9444 :                && known_eq (GET_MODE_SIZE (mode),
    3070              :                             GET_MODE_SIZE (GET_MODE (src)))
    3071       495305 :                && known_eq (bytelen, GET_MODE_SIZE (mode)))
    3072              :         {
    3073              :           /* When passing a complex value in an integer mode of the same
    3074              :              size, explicitly construct (highpart<<isize)+lowpart to
    3075              :              avoid spilling to memory before reload.  */
    3076         2762 :           rtx tmp = read_complex_part (src, !BYTES_BIG_ENDIAN);
    3077         2762 :           scalar_int_mode imode = int_mode_for_mode (GET_MODE (tmp)).require();
    3078         2762 :           tmp = gen_lowpart (imode, tmp);
    3079         2762 :           tmp = simplify_gen_unary (ZERO_EXTEND, mode, tmp, imode);
    3080         2762 :           rtx result = force_reg (mode, tmp);
    3081         5524 :           result = expand_shift (LSHIFT_EXPR, mode, result,
    3082         2762 :                                  GET_MODE_BITSIZE (imode), NULL_RTX, 1);
    3083         2762 :           tmp = read_complex_part (src, BYTES_BIG_ENDIAN);
    3084         2762 :           tmp = gen_lowpart (imode, tmp);
    3085         2762 :           tmp = simplify_gen_unary (ZERO_EXTEND, mode, tmp, imode);
    3086         2762 :           result = simplify_gen_binary (PLUS, mode, result, tmp);
    3087         2762 :           tmps[i] = force_reg (mode, result);
    3088              :         }
    3089       489781 :       else if (GET_CODE (src) == CONCAT)
    3090              :         {
    3091        11810 :           poly_int64 slen = GET_MODE_SIZE (GET_MODE (src));
    3092        11810 :           poly_int64 slen0 = GET_MODE_SIZE (GET_MODE (XEXP (src, 0)));
    3093         5905 :           unsigned int elt;
    3094         5905 :           poly_int64 subpos;
    3095              : 
    3096         5905 :           if (can_div_trunc_p (bytepos, slen0, &elt, &subpos)
    3097         5905 :               && known_le (subpos + bytelen, slen0))
    3098              :             {
    3099              :               /* The following assumes that the concatenated objects all
    3100              :                  have the same size.  In this case, a simple calculation
    3101              :                  can be used to determine the object and the bit field
    3102              :                  to be extracted.  */
    3103         5886 :               tmps[i] = XEXP (src, elt);
    3104         5886 :               if (maybe_ne (subpos, 0)
    3105         5886 :                   || maybe_ne (subpos + bytelen, slen0)
    3106        11772 :                   || (!CONSTANT_P (tmps[i])
    3107         5886 :                       && (!REG_P (tmps[i]) || GET_MODE (tmps[i]) != mode)))
    3108            0 :                 tmps[i] = extract_bit_field (tmps[i], bytelen * BITS_PER_UNIT,
    3109            0 :                                              subpos * BITS_PER_UNIT,
    3110              :                                              1, NULL_RTX, mode, mode, false,
    3111              :                                              NULL);
    3112              :             }
    3113              :           else
    3114              :             {
    3115           19 :               rtx mem;
    3116              : 
    3117           19 :               gcc_assert (known_eq (bytepos, 0));
    3118           19 :               mem = assign_stack_temp (GET_MODE (src), slen);
    3119           19 :               emit_move_insn (mem, src);
    3120           19 :               tmps[i] = extract_bit_field (mem, bytelen * BITS_PER_UNIT,
    3121              :                                            0, 1, NULL_RTX, mode, mode, false,
    3122              :                                            NULL);
    3123              :             }
    3124              :         }
    3125       483876 :       else if (CONSTANT_P (src) && GET_MODE (dst) != BLKmode
    3126        38472 :                && XVECLEN (dst, 0) > 1)
    3127        38472 :         tmps[i] = force_subreg (mode, src, GET_MODE (dst), bytepos);
    3128       445404 :       else if (CONSTANT_P (src))
    3129              :         {
    3130            0 :           if (known_eq (bytelen, ssize))
    3131            0 :             tmps[i] = src;
    3132              :           else
    3133              :             {
    3134              :               rtx first, second;
    3135              : 
    3136              :               /* TODO: const_wide_int can have sizes other than this...  */
    3137            0 :               gcc_assert (known_eq (2 * bytelen, ssize));
    3138            0 :               split_double (src, &first, &second);
    3139            0 :               if (i)
    3140            0 :                 tmps[i] = second;
    3141              :               else
    3142            0 :                 tmps[i] = first;
    3143              :             }
    3144              :         }
    3145       445404 :       else if (REG_P (src) && GET_MODE (src) == mode)
    3146            0 :         tmps[i] = src;
    3147              :       else
    3148       445404 :         tmps[i] = extract_bit_field (src, bytelen * BITS_PER_UNIT,
    3149       890808 :                                      bytepos * BITS_PER_UNIT, 1, NULL_RTX,
    3150              :                                      mode, mode, false, NULL);
    3151              : 
    3152       592238 :       if (maybe_ne (shift, 0))
    3153              :         tmps[i] = expand_shift (LSHIFT_EXPR, mode, tmps[i],
    3154              :                                 shift, tmps[i], 0);
    3155              :     }
    3156              : }
    3157              : 
    3158              : /* Emit code to move a block SRC of type TYPE to a block DST,
    3159              :    where DST is non-consecutive registers represented by a PARALLEL.
    3160              :    SSIZE represents the total size of block ORIG_SRC in bytes, or -1
    3161              :    if not known.  */
    3162              : 
    3163              : void
    3164        11014 : emit_group_load (rtx dst, rtx src, tree type, poly_int64 ssize)
    3165              : {
    3166        11014 :   rtx *tmps;
    3167        11014 :   int i;
    3168              : 
    3169        11014 :   tmps = XALLOCAVEC (rtx, XVECLEN (dst, 0));
    3170        11014 :   emit_group_load_1 (tmps, dst, src, type, ssize);
    3171              : 
    3172              :   /* Copy the extracted pieces into the proper (probable) hard regs.  */
    3173        41705 :   for (i = 0; i < XVECLEN (dst, 0); i++)
    3174              :     {
    3175        19677 :       rtx d = XEXP (XVECEXP (dst, 0, i), 0);
    3176        19677 :       if (d == NULL)
    3177            0 :         continue;
    3178        19677 :       emit_move_insn (d, tmps[i]);
    3179              :     }
    3180        11014 : }
    3181              : 
    3182              : /* Similar, but load SRC into new pseudos in a format that looks like
    3183              :    PARALLEL.  This can later be fed to emit_group_move to get things
    3184              :    in the right place.  */
    3185              : 
    3186              : rtx
    3187       290939 : emit_group_load_into_temps (rtx parallel, rtx src, tree type, poly_int64 ssize)
    3188              : {
    3189       290939 :   rtvec vec;
    3190       290939 :   int i;
    3191              : 
    3192       290939 :   vec = rtvec_alloc (XVECLEN (parallel, 0));
    3193       290939 :   emit_group_load_1 (&RTVEC_ELT (vec, 0), parallel, src, type, ssize);
    3194              : 
    3195              :   /* Convert the vector to look just like the original PARALLEL, except
    3196              :      with the computed values.  */
    3197      1154439 :   for (i = 0; i < XVECLEN (parallel, 0); i++)
    3198              :     {
    3199       572561 :       rtx e = XVECEXP (parallel, 0, i);
    3200       572561 :       rtx d = XEXP (e, 0);
    3201              : 
    3202       572561 :       if (d)
    3203              :         {
    3204       572561 :           d = force_reg (GET_MODE (d), RTVEC_ELT (vec, i));
    3205       572561 :           e = alloc_EXPR_LIST (REG_NOTE_KIND (e), d, XEXP (e, 1));
    3206              :         }
    3207       572561 :       RTVEC_ELT (vec, i) = e;
    3208              :     }
    3209              : 
    3210       290939 :   return gen_rtx_PARALLEL (GET_MODE (parallel), vec);
    3211              : }
    3212              : 
    3213              : /* Emit code to move a block SRC to block DST, where SRC and DST are
    3214              :    non-consecutive groups of registers, each represented by a PARALLEL.  */
    3215              : 
    3216              : void
    3217       294266 : emit_group_move (rtx dst, rtx src)
    3218              : {
    3219       294266 :   int i;
    3220              : 
    3221       294266 :   gcc_assert (GET_CODE (src) == PARALLEL
    3222              :               && GET_CODE (dst) == PARALLEL
    3223              :               && XVECLEN (src, 0) == XVECLEN (dst, 0));
    3224              : 
    3225              :   /* Skip first entry if NULL.  */
    3226       871614 :   for (i = XEXP (XVECEXP (src, 0, 0), 0) ? 0 : 1; i < XVECLEN (src, 0); i++)
    3227       577348 :     emit_move_insn (XEXP (XVECEXP (dst, 0, i), 0),
    3228       577348 :                     XEXP (XVECEXP (src, 0, i), 0));
    3229       294266 : }
    3230              : 
    3231              : /* Move a group of registers represented by a PARALLEL into pseudos.  */
    3232              : 
    3233              : rtx
    3234         5828 : emit_group_move_into_temps (rtx src)
    3235              : {
    3236         5828 :   rtvec vec = rtvec_alloc (XVECLEN (src, 0));
    3237         5828 :   int i;
    3238              : 
    3239        19539 :   for (i = 0; i < XVECLEN (src, 0); i++)
    3240              :     {
    3241         7883 :       rtx e = XVECEXP (src, 0, i);
    3242         7883 :       rtx d = XEXP (e, 0);
    3243              : 
    3244         7883 :       if (d)
    3245         7883 :         e = alloc_EXPR_LIST (REG_NOTE_KIND (e), copy_to_reg (d), XEXP (e, 1));
    3246         7883 :       RTVEC_ELT (vec, i) = e;
    3247              :     }
    3248              : 
    3249         5828 :   return gen_rtx_PARALLEL (GET_MODE (src), vec);
    3250              : }
    3251              : 
    3252              : /* Emit code to move a block SRC to a block ORIG_DST of type TYPE,
    3253              :    where SRC is non-consecutive registers represented by a PARALLEL.
    3254              :    SSIZE represents the total size of block ORIG_DST, or -1 if not
    3255              :    known.  */
    3256              : 
    3257              : void
    3258        66333 : emit_group_store (rtx orig_dst, rtx src, tree type ATTRIBUTE_UNUSED,
    3259              :                   poly_int64 ssize)
    3260              : {
    3261        66333 :   rtx *tmps, dst;
    3262        66333 :   int start, finish, i;
    3263        66333 :   machine_mode m = GET_MODE (orig_dst);
    3264              : 
    3265        66333 :   gcc_assert (GET_CODE (src) == PARALLEL);
    3266              : 
    3267        66333 :   if (!SCALAR_INT_MODE_P (m)
    3268        14630 :       && !MEM_P (orig_dst) && GET_CODE (orig_dst) != CONCAT)
    3269              :     {
    3270            0 :       scalar_int_mode imode;
    3271            0 :       if (int_mode_for_mode (GET_MODE (orig_dst)).exists (&imode))
    3272              :         {
    3273            0 :           dst = gen_reg_rtx (imode);
    3274            0 :           emit_group_store (dst, src, type, ssize);
    3275            0 :           dst = gen_lowpart (GET_MODE (orig_dst), dst);
    3276              :         }
    3277              :       else
    3278              :         {
    3279            0 :           dst = assign_stack_temp (GET_MODE (orig_dst), ssize);
    3280            0 :           emit_group_store (dst, src, type, ssize);
    3281              :         }
    3282            0 :       emit_move_insn (orig_dst, dst);
    3283            0 :       return;
    3284              :     }
    3285              : 
    3286              :   /* Check for a NULL entry, used to indicate that the parameter goes
    3287              :      both on the stack and in registers.  */
    3288        66333 :   if (XEXP (XVECEXP (src, 0, 0), 0))
    3289              :     start = 0;
    3290              :   else
    3291            0 :     start = 1;
    3292        66333 :   finish = XVECLEN (src, 0);
    3293              : 
    3294        66333 :   tmps = XALLOCAVEC (rtx, finish);
    3295              : 
    3296              :   /* Copy the (probable) hard regs into pseudos.  */
    3297       190639 :   for (i = start; i < finish; i++)
    3298              :     {
    3299       124306 :       rtx reg = XEXP (XVECEXP (src, 0, i), 0);
    3300       124306 :       if (!REG_P (reg) || REGNO (reg) < FIRST_PSEUDO_REGISTER)
    3301              :         {
    3302       116423 :           tmps[i] = gen_reg_rtx (GET_MODE (reg));
    3303       116423 :           emit_move_insn (tmps[i], reg);
    3304              :         }
    3305              :       else
    3306         7883 :         tmps[i] = reg;
    3307              :     }
    3308              : 
    3309              :   /* If we won't be storing directly into memory, protect the real destination
    3310              :      from strange tricks we might play.  */
    3311        66333 :   dst = orig_dst;
    3312        66333 :   if (GET_CODE (dst) == PARALLEL)
    3313              :     {
    3314            0 :       rtx temp;
    3315              : 
    3316              :       /* We can get a PARALLEL dst if there is a conditional expression in
    3317              :          a return statement.  In that case, the dst and src are the same,
    3318              :          so no action is necessary.  */
    3319            0 :       if (rtx_equal_p (dst, src))
    3320              :         return;
    3321              : 
    3322              :       /* It is unclear if we can ever reach here, but we may as well handle
    3323              :          it.  Allocate a temporary, and split this into a store/load to/from
    3324              :          the temporary.  */
    3325            0 :       temp = assign_stack_temp (GET_MODE (dst), ssize);
    3326            0 :       emit_group_store (temp, src, type, ssize);
    3327            0 :       emit_group_load (dst, temp, type, ssize);
    3328            0 :       return;
    3329              :     }
    3330        66333 :   else if (!MEM_P (dst) && GET_CODE (dst) != CONCAT)
    3331              :     {
    3332        51069 :       machine_mode outer = GET_MODE (dst);
    3333        51069 :       machine_mode inner;
    3334        51069 :       poly_int64 bytepos;
    3335        51069 :       bool done = false;
    3336        51069 :       rtx temp;
    3337              : 
    3338        51069 :       if (!REG_P (dst) || REGNO (dst) < FIRST_PSEUDO_REGISTER)
    3339            0 :         dst = gen_reg_rtx (outer);
    3340              : 
    3341              :       /* Make life a bit easier for combine: if the first element of the
    3342              :          vector is the low part of the destination mode, use a paradoxical
    3343              :          subreg to initialize the destination.  */
    3344        51069 :       if (start < finish)
    3345              :         {
    3346        51069 :           inner = GET_MODE (tmps[start]);
    3347        51069 :           bytepos = subreg_lowpart_offset (inner, outer);
    3348        51069 :           if (known_eq (rtx_to_poly_int64 (XEXP (XVECEXP (src, 0, start), 1)),
    3349              :                         bytepos))
    3350              :             {
    3351        51045 :               temp = force_subreg (outer, tmps[start], inner, 0);
    3352        51045 :               if (temp)
    3353              :                 {
    3354        50383 :                   emit_move_insn (dst, temp);
    3355        50383 :                   done = true;
    3356        50383 :                   start++;
    3357              :                 }
    3358              :             }
    3359              :         }
    3360              : 
    3361              :       /* If the first element wasn't the low part, try the last.  */
    3362        50383 :       if (!done
    3363          686 :           && start < finish - 1)
    3364              :         {
    3365          619 :           inner = GET_MODE (tmps[finish - 1]);
    3366          619 :           bytepos = subreg_lowpart_offset (inner, outer);
    3367          619 :           if (known_eq (rtx_to_poly_int64 (XEXP (XVECEXP (src, 0,
    3368              :                                                           finish - 1), 1)),
    3369              :                         bytepos))
    3370              :             {
    3371            0 :               temp = force_subreg (outer, tmps[finish - 1], inner, 0);
    3372            0 :               if (temp)
    3373              :                 {
    3374            0 :                   emit_move_insn (dst, temp);
    3375            0 :                   done = true;
    3376            0 :                   finish--;
    3377              :                 }
    3378              :             }
    3379              :         }
    3380              : 
    3381              :       /* Otherwise, simply initialize the result to zero.  */
    3382        50383 :       if (!done)
    3383          686 :         emit_move_insn (dst, CONST0_RTX (outer));
    3384              :     }
    3385              : 
    3386              :   /* Process the pieces.  */
    3387       136684 :   for (i = start; i < finish; i++)
    3388              :     {
    3389        73923 :       poly_int64 bytepos = rtx_to_poly_int64 (XEXP (XVECEXP (src, 0, i), 1));
    3390        73923 :       machine_mode mode = GET_MODE (tmps[i]);
    3391       147846 :       poly_int64 bytelen = GET_MODE_SIZE (mode);
    3392        73923 :       poly_uint64 adj_bytelen;
    3393        73923 :       rtx dest = dst;
    3394              : 
    3395              :       /* Handle trailing fragments that run over the size of the struct.
    3396              :          It's the target's responsibility to make sure that the fragment
    3397              :          cannot be strictly smaller in some cases and strictly larger
    3398              :          in others.  */
    3399        73923 :       gcc_checking_assert (ordered_p (bytepos + bytelen, ssize));
    3400       146890 :       if (known_size_p (ssize) && maybe_gt (bytepos + bytelen, ssize))
    3401          956 :         adj_bytelen = ssize - bytepos;
    3402              :       else
    3403        73923 :         adj_bytelen = bytelen;
    3404              : 
    3405              :       /* Deal with destination CONCATs by either storing into one of the parts
    3406              :          or doing a copy after storing into a register or stack temporary.  */
    3407        73923 :       if (GET_CODE (dst) == CONCAT)
    3408              :         {
    3409        29140 :           if (known_le (bytepos + adj_bytelen,
    3410              :                         GET_MODE_SIZE (GET_MODE (XEXP (dst, 0)))))
    3411              :             dest = XEXP (dst, 0);
    3412              : 
    3413        18142 :           else if (known_ge (bytepos, GET_MODE_SIZE (GET_MODE (XEXP (dst, 0)))))
    3414              :             {
    3415        10998 :               bytepos -= GET_MODE_SIZE (GET_MODE (XEXP (dst, 0)));
    3416         5499 :               dest = XEXP (dst, 1);
    3417              :             }
    3418              : 
    3419              :           else
    3420              :             {
    3421         3572 :               machine_mode dest_mode = GET_MODE (dest);
    3422         3572 :               machine_mode tmp_mode = GET_MODE (tmps[i]);
    3423         3572 :               scalar_int_mode dest_imode;
    3424              : 
    3425         3572 :               gcc_assert (known_eq (bytepos, 0) && XVECLEN (src, 0));
    3426              : 
    3427              :               /* If the source is a single scalar integer register, and the
    3428              :                  destination has a complex mode for which a same-sized integer
    3429              :                  mode exists, then we can take the left-justified part of the
    3430              :                  source in the complex mode.  */
    3431         3572 :               if (finish == start + 1
    3432         3572 :                   && REG_P (tmps[i])
    3433         3572 :                   && SCALAR_INT_MODE_P (tmp_mode)
    3434         3572 :                   && COMPLEX_MODE_P (dest_mode)
    3435         7144 :                   && int_mode_for_mode (dest_mode).exists (&dest_imode))
    3436              :                 {
    3437         3572 :                   const scalar_int_mode tmp_imode
    3438         3572 :                     = as_a <scalar_int_mode> (tmp_mode);
    3439              : 
    3440         7144 :                   if (GET_MODE_BITSIZE (dest_imode)
    3441         3572 :                       < GET_MODE_BITSIZE (tmp_imode))
    3442              :                     {
    3443           60 :                       dest = gen_reg_rtx (dest_imode);
    3444           60 :                       if (BYTES_BIG_ENDIAN)
    3445              :                         tmps[i] = expand_shift (RSHIFT_EXPR, tmp_mode, tmps[i],
    3446              :                                                 GET_MODE_BITSIZE (tmp_imode)
    3447              :                                                 - GET_MODE_BITSIZE (dest_imode),
    3448              :                                                 NULL_RTX, 1);
    3449           60 :                       emit_move_insn (dest, gen_lowpart (dest_imode, tmps[i]));
    3450           60 :                       dst = gen_lowpart (dest_mode, dest);
    3451              :                     }
    3452              :                   else
    3453         3512 :                     dst = gen_lowpart (dest_mode, tmps[i]);
    3454              :                 }
    3455              : 
    3456              :               /* Otherwise spill the source onto the stack using the more
    3457              :                  aligned of the two modes.  */
    3458            0 :               else if (GET_MODE_ALIGNMENT (dest_mode)
    3459            0 :                        >= GET_MODE_ALIGNMENT (tmp_mode))
    3460              :                 {
    3461            0 :                   dest = assign_stack_temp (dest_mode,
    3462            0 :                                             GET_MODE_SIZE (dest_mode));
    3463            0 :                   emit_move_insn (adjust_address (dest, tmp_mode, bytepos),
    3464              :                                   tmps[i]);
    3465            0 :                   dst = dest;
    3466              :                 }
    3467              : 
    3468              :               else
    3469              :                 {
    3470            0 :                   dest = assign_stack_temp (tmp_mode,
    3471            0 :                                             GET_MODE_SIZE (tmp_mode));
    3472            0 :                   emit_move_insn (dest, tmps[i]);
    3473            0 :                   dst = adjust_address (dest, dest_mode, bytepos);
    3474              :                 }
    3475              : 
    3476              :               break;
    3477              :             }
    3478              :         }
    3479              : 
    3480              :       /* Handle trailing fragments that run over the size of the struct.  */
    3481        70351 :       if (known_size_p (ssize) && maybe_gt (bytepos + bytelen, ssize))
    3482              :         {
    3483              :           /* store_bit_field always takes its value from the lsb.
    3484              :              Move the fragment to the lsb if it's not already there.  */
    3485          896 :           if (
    3486              : #ifdef BLOCK_REG_PADDING
    3487              :               BLOCK_REG_PADDING (GET_MODE (orig_dst), type, i == start)
    3488              :               == (BYTES_BIG_ENDIAN ? PAD_UPWARD : PAD_DOWNWARD)
    3489              : #else
    3490              :               BYTES_BIG_ENDIAN
    3491              : #endif
    3492              :               )
    3493              :             {
    3494              :               poly_int64 shift = (bytelen - (ssize - bytepos)) * BITS_PER_UNIT;
    3495              :               tmps[i] = expand_shift (RSHIFT_EXPR, mode, tmps[i],
    3496              :                                       shift, tmps[i], 0);
    3497              :             }
    3498              : 
    3499              :           /* Make sure not to write past the end of the struct.  */
    3500          896 :           store_bit_field (dest,
    3501          896 :                            adj_bytelen * BITS_PER_UNIT, bytepos * BITS_PER_UNIT,
    3502         3584 :                            bytepos * BITS_PER_UNIT, ssize * BITS_PER_UNIT - 1,
    3503              :                            VOIDmode, tmps[i], false, false);
    3504              :         }
    3505              : 
    3506              :       /* Optimize the access just a bit.  */
    3507        69455 :       else if (MEM_P (dest)
    3508         7602 :                && (!targetm.slow_unaligned_access (mode, MEM_ALIGN (dest))
    3509            0 :                    || MEM_ALIGN (dest) >= GET_MODE_ALIGNMENT (mode))
    3510        15204 :                && multiple_p (bytepos * BITS_PER_UNIT,
    3511              :                               GET_MODE_ALIGNMENT (mode))
    3512        77057 :                && known_eq (bytelen, GET_MODE_SIZE (mode)))
    3513         7602 :         emit_move_insn (adjust_address (dest, mode, bytepos), tmps[i]);
    3514              : 
    3515              :       else
    3516       123706 :         store_bit_field (dest, bytelen * BITS_PER_UNIT, bytepos * BITS_PER_UNIT,
    3517              :                          0, 0, mode, tmps[i], false, false);
    3518              :     }
    3519              : 
    3520              :   /* Copy from the pseudo into the (probable) hard reg.  */
    3521        66333 :   if (orig_dst != dst)
    3522         3572 :     emit_move_insn (orig_dst, dst);
    3523              : }
    3524              : 
    3525              : /* Return a form of X that does not use a PARALLEL.  TYPE is the type
    3526              :    of the value stored in X.  */
    3527              : 
    3528              : rtx
    3529       338197 : maybe_emit_group_store (rtx x, tree type)
    3530              : {
    3531       338197 :   machine_mode mode = TYPE_MODE (type);
    3532       338197 :   gcc_checking_assert (GET_MODE (x) == VOIDmode || GET_MODE (x) == mode);
    3533       338197 :   if (GET_CODE (x) == PARALLEL)
    3534              :     {
    3535            0 :       rtx result = gen_reg_rtx (mode);
    3536            0 :       emit_group_store (result, x, type, int_size_in_bytes (type));
    3537            0 :       return result;
    3538              :     }
    3539              :   return x;
    3540              : }
    3541              : 
    3542              : /* Copy a BLKmode object of TYPE out of a register SRCREG into TARGET.
    3543              : 
    3544              :    This is used on targets that return BLKmode values in registers.  */
    3545              : 
    3546              : static void
    3547          257 : copy_blkmode_from_reg (rtx target, rtx srcreg, tree type)
    3548              : {
    3549          257 :   unsigned HOST_WIDE_INT bytes = int_size_in_bytes (type);
    3550          257 :   rtx src = NULL, dst = NULL;
    3551          257 :   unsigned HOST_WIDE_INT bitsize = MIN (TYPE_ALIGN (type), BITS_PER_WORD);
    3552          257 :   unsigned HOST_WIDE_INT bitpos, xbitpos, padding_correction = 0;
    3553              :   /* No current ABI uses variable-sized modes to pass a BLKmnode type.  */
    3554          257 :   fixed_size_mode mode = as_a <fixed_size_mode> (GET_MODE (srcreg));
    3555          257 :   fixed_size_mode tmode = as_a <fixed_size_mode> (GET_MODE (target));
    3556          257 :   fixed_size_mode copy_mode;
    3557              : 
    3558              :   /* BLKmode registers created in the back-end shouldn't have survived.  */
    3559          257 :   gcc_assert (mode != BLKmode);
    3560              : 
    3561              :   /* If the structure doesn't take up a whole number of words, see whether
    3562              :      SRCREG is padded on the left or on the right.  If it's on the left,
    3563              :      set PADDING_CORRECTION to the number of bits to skip.
    3564              : 
    3565              :      In most ABIs, the structure will be returned at the least end of
    3566              :      the register, which translates to right padding on little-endian
    3567              :      targets and left padding on big-endian targets.  The opposite
    3568              :      holds if the structure is returned at the most significant
    3569              :      end of the register.  */
    3570          257 :   if (bytes % UNITS_PER_WORD != 0
    3571          257 :       && (targetm.calls.return_in_msb (type)
    3572          225 :           ? !BYTES_BIG_ENDIAN
    3573              :           : BYTES_BIG_ENDIAN))
    3574            0 :     padding_correction
    3575            0 :       = (BITS_PER_WORD - ((bytes % UNITS_PER_WORD) * BITS_PER_UNIT));
    3576              : 
    3577              :   /* We can use a single move if we have an exact mode for the size.  */
    3578          257 :   else if (MEM_P (target)
    3579          257 :            && (!targetm.slow_unaligned_access (mode, MEM_ALIGN (target))
    3580            0 :                || MEM_ALIGN (target) >= GET_MODE_ALIGNMENT (mode))
    3581          514 :            && bytes == GET_MODE_SIZE (mode))
    3582              :   {
    3583           39 :     emit_move_insn (adjust_address (target, mode, 0), srcreg);
    3584           39 :     return;
    3585              :   }
    3586              : 
    3587              :   /* And if we additionally have the same mode for a register.  */
    3588          218 :   else if (REG_P (target)
    3589            0 :            && GET_MODE (target) == mode
    3590          218 :            && bytes == GET_MODE_SIZE (mode))
    3591              :   {
    3592            0 :     emit_move_insn (target, srcreg);
    3593            0 :     return;
    3594              :   }
    3595              : 
    3596              :   /* This code assumes srcreg is at least a full word.  If it isn't, copy it
    3597              :      into a new pseudo which is a full word.  */
    3598          436 :   if (GET_MODE_SIZE (mode) < UNITS_PER_WORD)
    3599              :     {
    3600           77 :       srcreg = convert_to_mode (word_mode, srcreg, TYPE_UNSIGNED (type));
    3601           77 :       mode = word_mode;
    3602              :     }
    3603              : 
    3604              :   /* Copy the structure BITSIZE bits at a time.  If the target lives in
    3605              :      memory, take care of not reading/writing past its end by selecting
    3606              :      a copy mode suited to BITSIZE.  This should always be possible given
    3607              :      how it is computed.
    3608              : 
    3609              :      If the target lives in register, make sure not to select a copy mode
    3610              :      larger than the mode of the register.
    3611              : 
    3612              :      We could probably emit more efficient code for machines which do not use
    3613              :      strict alignment, but it doesn't seem worth the effort at the current
    3614              :      time.  */
    3615              : 
    3616          218 :   copy_mode = word_mode;
    3617          218 :   if (MEM_P (target))
    3618              :     {
    3619          218 :       opt_scalar_int_mode mem_mode = int_mode_for_size (bitsize, 1);
    3620          218 :       if (mem_mode.exists ())
    3621          218 :         copy_mode = mem_mode.require ();
    3622              :     }
    3623            0 :   else if (REG_P (target) && GET_MODE_BITSIZE (tmode) < BITS_PER_WORD)
    3624              :     copy_mode = tmode;
    3625              : 
    3626          218 :   for (bitpos = 0, xbitpos = padding_correction;
    3627         1068 :        bitpos < bytes * BITS_PER_UNIT;
    3628          850 :        bitpos += bitsize, xbitpos += bitsize)
    3629              :     {
    3630              :       /* We need a new source operand each time xbitpos is on a
    3631              :          word boundary and when xbitpos == padding_correction
    3632              :          (the first time through).  */
    3633          850 :       if (xbitpos % BITS_PER_WORD == 0 || xbitpos == padding_correction)
    3634          218 :         src = operand_subword_force (srcreg, xbitpos / BITS_PER_WORD, mode);
    3635              : 
    3636              :       /* We need a new destination operand each time bitpos is on
    3637              :          a word boundary.  */
    3638          850 :       if (REG_P (target) && GET_MODE_BITSIZE (tmode) < BITS_PER_WORD)
    3639              :         dst = target;
    3640          850 :       else if (bitpos % BITS_PER_WORD == 0)
    3641          218 :         dst = operand_subword (target, bitpos / BITS_PER_WORD, 1, tmode);
    3642              : 
    3643              :       /* Use xbitpos for the source extraction (right justified) and
    3644              :          bitpos for the destination store (left justified).  */
    3645          850 :       store_bit_field (dst, bitsize, bitpos % BITS_PER_WORD, 0, 0, copy_mode,
    3646          850 :                        extract_bit_field (src, bitsize,
    3647          850 :                                           xbitpos % BITS_PER_WORD, 1,
    3648              :                                           NULL_RTX, copy_mode, copy_mode,
    3649              :                                           false, NULL),
    3650              :                        false, false);
    3651              :     }
    3652              : }
    3653              : 
    3654              : /* Copy BLKmode value SRC into a register of mode MODE_IN.  Return the
    3655              :    register if it contains any data, otherwise return null.
    3656              : 
    3657              :    This is used on targets that return BLKmode values in registers.  */
    3658              : 
    3659              : rtx
    3660         3765 : copy_blkmode_to_reg (machine_mode mode_in, tree src)
    3661              : {
    3662         3765 :   int i, n_regs;
    3663         3765 :   unsigned HOST_WIDE_INT bitpos, xbitpos, padding_correction = 0, bytes;
    3664         3765 :   unsigned int bitsize;
    3665         3765 :   rtx *dst_words, dst, x, src_word = NULL_RTX, dst_word = NULL_RTX;
    3666              :   /* No current ABI uses variable-sized modes to pass a BLKmnode type.  */
    3667         3765 :   fixed_size_mode mode = as_a <fixed_size_mode> (mode_in);
    3668         3765 :   fixed_size_mode dst_mode;
    3669         3765 :   scalar_int_mode min_mode;
    3670              : 
    3671         3765 :   gcc_assert (TYPE_MODE (TREE_TYPE (src)) == BLKmode);
    3672              : 
    3673         3765 :   x = expand_normal (src);
    3674              : 
    3675         3765 :   bytes = arg_int_size_in_bytes (TREE_TYPE (src));
    3676         3765 :   if (bytes == 0)
    3677              :     return NULL_RTX;
    3678              : 
    3679              :   /* If the structure doesn't take up a whole number of words, see
    3680              :      whether the register value should be padded on the left or on
    3681              :      the right.  Set PADDING_CORRECTION to the number of padding
    3682              :      bits needed on the left side.
    3683              : 
    3684              :      In most ABIs, the structure will be returned at the least end of
    3685              :      the register, which translates to right padding on little-endian
    3686              :      targets and left padding on big-endian targets.  The opposite
    3687              :      holds if the structure is returned at the most significant
    3688              :      end of the register.  */
    3689         1224 :   if (bytes % UNITS_PER_WORD != 0
    3690         1224 :       && (targetm.calls.return_in_msb (TREE_TYPE (src))
    3691         1188 :           ? !BYTES_BIG_ENDIAN
    3692              :           : BYTES_BIG_ENDIAN))
    3693            0 :     padding_correction = (BITS_PER_WORD - ((bytes % UNITS_PER_WORD)
    3694            0 :                                            * BITS_PER_UNIT));
    3695              : 
    3696         1224 :   n_regs = (bytes + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
    3697         1224 :   dst_words = XALLOCAVEC (rtx, n_regs);
    3698         1224 :   bitsize = MIN (TYPE_ALIGN (TREE_TYPE (src)), BITS_PER_WORD);
    3699         1224 :   min_mode = smallest_int_mode_for_size (bitsize).require ();
    3700              : 
    3701              :   /* Copy the structure BITSIZE bits at a time.  */
    3702         1224 :   for (bitpos = 0, xbitpos = padding_correction;
    3703         3974 :        bitpos < bytes * BITS_PER_UNIT;
    3704         2750 :        bitpos += bitsize, xbitpos += bitsize)
    3705              :     {
    3706              :       /* We need a new destination pseudo each time xbitpos is
    3707              :          on a word boundary and when xbitpos == padding_correction
    3708              :          (the first time through).  */
    3709         2750 :       if (xbitpos % BITS_PER_WORD == 0
    3710         1523 :           || xbitpos == padding_correction)
    3711              :         {
    3712              :           /* Generate an appropriate register.  */
    3713         1227 :           dst_word = gen_reg_rtx (word_mode);
    3714         1227 :           dst_words[xbitpos / BITS_PER_WORD] = dst_word;
    3715              : 
    3716              :           /* Clear the destination before we move anything into it.  */
    3717         1227 :           emit_move_insn (dst_word, CONST0_RTX (word_mode));
    3718              :         }
    3719              : 
    3720              :       /* Find the largest integer mode that can be used to copy all or as
    3721              :          many bits as possible of the structure if the target supports larger
    3722              :          copies.  There are too many corner cases here w.r.t to alignments on
    3723              :          the read/writes.  So if there is any padding just use single byte
    3724              :          operations.  */
    3725         2750 :       opt_scalar_int_mode mode_iter;
    3726         2750 :       if (padding_correction == 0 && !STRICT_ALIGNMENT)
    3727              :         {
    3728         7488 :           FOR_EACH_MODE_FROM (mode_iter, min_mode)
    3729              :             {
    3730         7488 :               unsigned int msize = GET_MODE_BITSIZE (mode_iter.require ());
    3731         7488 :               if (msize <= ((bytes * BITS_PER_UNIT) - bitpos)
    3732         4741 :                   && msize <= BITS_PER_WORD)
    3733         4738 :                 bitsize = msize;
    3734              :               else
    3735              :                 break;
    3736              :             }
    3737              :         }
    3738              : 
    3739              :       /* We need a new source operand each time bitpos is on a word
    3740              :          boundary.  */
    3741         2750 :       if (bitpos % BITS_PER_WORD == 0)
    3742         1227 :         src_word = operand_subword_force (x, bitpos / BITS_PER_WORD, BLKmode);
    3743              : 
    3744              :       /* Use bitpos for the source extraction (left justified) and
    3745              :          xbitpos for the destination store (right justified).  */
    3746         5500 :       store_bit_field (dst_word, bitsize, xbitpos % BITS_PER_WORD,
    3747              :                        0, 0, word_mode,
    3748         2750 :                        extract_bit_field (src_word, bitsize,
    3749         2750 :                                           bitpos % BITS_PER_WORD, 1,
    3750              :                                           NULL_RTX, word_mode, word_mode,
    3751              :                                           false, NULL),
    3752              :                        false, false);
    3753              :     }
    3754              : 
    3755         1224 :   if (mode == BLKmode)
    3756              :     {
    3757              :       /* Find the smallest integer mode large enough to hold the
    3758              :          entire structure.  */
    3759            0 :       opt_scalar_int_mode mode_iter;
    3760            0 :       FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
    3761            0 :         if (GET_MODE_SIZE (mode_iter.require ()) >= bytes)
    3762              :           break;
    3763              : 
    3764              :       /* A suitable mode should have been found.  */
    3765            0 :       mode = mode_iter.require ();
    3766              :     }
    3767              : 
    3768         3672 :   if (GET_MODE_SIZE (mode) < GET_MODE_SIZE (word_mode))
    3769              :     dst_mode = word_mode;
    3770              :   else
    3771          498 :     dst_mode = mode;
    3772         1224 :   dst = gen_reg_rtx (dst_mode);
    3773              : 
    3774         3675 :   for (i = 0; i < n_regs; i++)
    3775         1227 :     emit_move_insn (operand_subword (dst, i, 0, dst_mode), dst_words[i]);
    3776              : 
    3777         1224 :   if (mode != dst_mode)
    3778          726 :     dst = gen_lowpart (mode, dst);
    3779              : 
    3780              :   return dst;
    3781              : }
    3782              : 
    3783              : /* Add a USE expression for REG to the (possibly empty) list pointed
    3784              :    to by CALL_FUSAGE.  REG must denote a hard register.  */
    3785              : 
    3786              : void
    3787     11776617 : use_reg_mode (rtx *call_fusage, rtx reg, machine_mode mode)
    3788              : {
    3789     11776617 :   gcc_assert (REG_P (reg));
    3790              : 
    3791     11776617 :   if (!HARD_REGISTER_P (reg))
    3792              :     return;
    3793              : 
    3794     11776617 :   *call_fusage
    3795     11776617 :     = gen_rtx_EXPR_LIST (mode, gen_rtx_USE (VOIDmode, reg), *call_fusage);
    3796              : }
    3797              : 
    3798              : /* Add a CLOBBER expression for REG to the (possibly empty) list pointed
    3799              :    to by CALL_FUSAGE.  REG must denote a hard register.  */
    3800              : 
    3801              : void
    3802            0 : clobber_reg_mode (rtx *call_fusage, rtx reg, machine_mode mode)
    3803              : {
    3804            0 :   gcc_assert (REG_P (reg) && REGNO (reg) < FIRST_PSEUDO_REGISTER);
    3805              : 
    3806            0 :   *call_fusage
    3807            0 :     = gen_rtx_EXPR_LIST (mode, gen_rtx_CLOBBER (VOIDmode, reg), *call_fusage);
    3808            0 : }
    3809              : 
    3810              : /* Add USE expressions to *CALL_FUSAGE for each of NREGS consecutive regs,
    3811              :    starting at REGNO.  All of these registers must be hard registers.  */
    3812              : 
    3813              : void
    3814         1587 : use_regs (rtx *call_fusage, int regno, int nregs)
    3815              : {
    3816         1587 :   int i;
    3817              : 
    3818         1587 :   gcc_assert (regno + nregs <= FIRST_PSEUDO_REGISTER);
    3819              : 
    3820         3182 :   for (i = 0; i < nregs; i++)
    3821         1595 :     use_reg (call_fusage, regno_reg_rtx[regno + i]);
    3822         1587 : }
    3823              : 
    3824              : /* Add USE expressions to *CALL_FUSAGE for each REG contained in the
    3825              :    PARALLEL REGS.  This is for calls that pass values in multiple
    3826              :    non-contiguous locations.  The Irix 6 ABI has examples of this.  */
    3827              : 
    3828              : void
    3829       297673 : use_group_regs (rtx *call_fusage, rtx regs)
    3830              : {
    3831       297673 :   int i;
    3832              : 
    3833       883702 :   for (i = 0; i < XVECLEN (regs, 0); i++)
    3834              :     {
    3835       586029 :       rtx reg = XEXP (XVECEXP (regs, 0, i), 0);
    3836              : 
    3837              :       /* A NULL entry means the parameter goes both on the stack and in
    3838              :          registers.  This can also be a MEM for targets that pass values
    3839              :          partially on the stack and partially in registers.  */
    3840       586029 :       if (reg != 0 && REG_P (reg))
    3841       586029 :         use_reg (call_fusage, reg);
    3842              :     }
    3843       297673 : }
    3844              : 
    3845              : /* Return the defining gimple statement for SSA_NAME NAME if it is an
    3846              :    assignment and the code of the expression on the RHS is CODE.  Return
    3847              :    NULL otherwise.  */
    3848              : 
    3849              : static gassign *
    3850     12268836 : get_def_for_expr (tree name, enum tree_code code)
    3851              : {
    3852              : 
    3853     12268836 :   if (TREE_CODE (name) != SSA_NAME)
    3854              :     return NULL;
    3855              : 
    3856      9568164 :   auto def_stmt = safe_dyn_cast<gassign *> (get_gimple_for_ssa_name (name));
    3857      2051594 :   if (!def_stmt
    3858      2051594 :       || gimple_assign_rhs_code (def_stmt) != code)
    3859      9533612 :     return NULL;
    3860              : 
    3861              :   return def_stmt;
    3862              : }
    3863              : 
    3864              : /* Return the defining gimple statement for SSA_NAME NAME if it is an
    3865              :    assignment and the class of the expression on the RHS is CLASS.  Return
    3866              :    NULL otherwise.  */
    3867              : 
    3868              : static gassign *
    3869        17458 : get_def_for_expr_class (tree name, enum tree_code_class tclass)
    3870              : {
    3871              : 
    3872        17458 :   if (TREE_CODE (name) != SSA_NAME)
    3873              :     return NULL;
    3874              : 
    3875        17458 :   auto def_stmt = safe_dyn_cast<gassign *> (get_gimple_for_ssa_name (name));
    3876        15211 :   if (!def_stmt
    3877        15211 :       || TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)) != tclass)
    3878         2391 :     return NULL;
    3879              : 
    3880              :   return def_stmt;
    3881              : }
    3882              : 
    3883              : /* Write zeros through the storage of OBJECT.  If OBJECT has BLKmode, SIZE is
    3884              :    its length in bytes.  */
    3885              : 
    3886              : rtx
    3887       164567 : clear_storage_hints (rtx object, rtx size, enum block_op_methods method,
    3888              :                      unsigned int expected_align, HOST_WIDE_INT expected_size,
    3889              :                      unsigned HOST_WIDE_INT min_size,
    3890              :                      unsigned HOST_WIDE_INT max_size,
    3891              :                      unsigned HOST_WIDE_INT probable_max_size,
    3892              :                      unsigned ctz_size)
    3893              : {
    3894       164567 :   machine_mode mode = GET_MODE (object);
    3895       164567 :   unsigned int align;
    3896              : 
    3897       164567 :   gcc_assert (method == BLOCK_OP_NORMAL || method == BLOCK_OP_TAILCALL);
    3898              : 
    3899              :   /* If OBJECT is not BLKmode and SIZE is the same size as its mode,
    3900              :      just move a zero.  Otherwise, do this a piece at a time.  */
    3901       164567 :   poly_int64 size_val;
    3902       164567 :   if (mode != BLKmode
    3903        60600 :       && poly_int_rtx_p (size, &size_val)
    3904       225167 :       && known_eq (size_val, GET_MODE_SIZE (mode)))
    3905              :     {
    3906        60600 :       rtx zero = CONST0_RTX (mode);
    3907        60600 :       if (zero != NULL)
    3908              :         {
    3909        60600 :           emit_move_insn (object, zero);
    3910        60600 :           return NULL;
    3911              :         }
    3912              : 
    3913            0 :       if (COMPLEX_MODE_P (mode))
    3914              :         {
    3915            0 :           zero = CONST0_RTX (GET_MODE_INNER (mode));
    3916            0 :           if (zero != NULL)
    3917              :             {
    3918            0 :               write_complex_part (object, zero, 0, true);
    3919            0 :               write_complex_part (object, zero, 1, false);
    3920            0 :               return NULL;
    3921              :             }
    3922              :         }
    3923              :     }
    3924              : 
    3925       103967 :   if (size == const0_rtx)
    3926              :     return NULL;
    3927              : 
    3928       103966 :   align = MEM_ALIGN (object);
    3929              : 
    3930       103966 :   if (CONST_INT_P (size)
    3931       103966 :       && targetm.use_by_pieces_infrastructure_p (INTVAL (size), align,
    3932              :                                                  CLEAR_BY_PIECES,
    3933              :                                                  optimize_insn_for_speed_p ()))
    3934        74219 :     clear_by_pieces (object, INTVAL (size), align);
    3935        29747 :   else if (set_storage_via_setmem (object, size, const0_rtx, align,
    3936              :                                    expected_align, expected_size,
    3937              :                                    min_size, max_size, probable_max_size))
    3938              :     ;
    3939        17205 :   else if (try_store_by_multiple_pieces (object, size, ctz_size,
    3940              :                                          min_size, max_size,
    3941              :                                          NULL_RTX, 0, align))
    3942              :     ;
    3943        16941 :   else if (ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (object)))
    3944        16941 :     return set_storage_via_libcall (object, size, const0_rtx,
    3945        16941 :                                     method == BLOCK_OP_TAILCALL);
    3946              :   else
    3947            0 :     gcc_unreachable ();
    3948              : 
    3949              :   return NULL;
    3950              : }
    3951              : 
    3952              : rtx
    3953       115912 : clear_storage (rtx object, rtx size, enum block_op_methods method)
    3954              : {
    3955       115912 :   unsigned HOST_WIDE_INT max, min = 0;
    3956       115912 :   if (GET_CODE (size) == CONST_INT)
    3957       115912 :     min = max = UINTVAL (size);
    3958              :   else
    3959            0 :     max = GET_MODE_MASK (GET_MODE (size));
    3960       115912 :   return clear_storage_hints (object, size, method, 0, -1, min, max, max, 0);
    3961              : }
    3962              : 
    3963              : 
    3964              : /* A subroutine of clear_storage.  Expand a call to memset.
    3965              :    Return the return value of memset, 0 otherwise.  */
    3966              : 
    3967              : rtx
    3968        16942 : set_storage_via_libcall (rtx object, rtx size, rtx val, bool tailcall)
    3969              : {
    3970        16942 :   tree call_expr, fn, object_tree, size_tree, val_tree;
    3971        16942 :   machine_mode size_mode;
    3972              : 
    3973        16942 :   object = copy_addr_to_reg (XEXP (object, 0));
    3974        16942 :   object_tree = make_tree (ptr_type_node, object);
    3975              : 
    3976        16942 :   if (!CONST_INT_P (val))
    3977            0 :     val = convert_to_mode (TYPE_MODE (integer_type_node), val, 1);
    3978        16942 :   val_tree = make_tree (integer_type_node, val);
    3979              : 
    3980        16942 :   size_mode = TYPE_MODE (sizetype);
    3981        16942 :   size = convert_to_mode (size_mode, size, 1);
    3982        16942 :   size = copy_to_mode_reg (size_mode, size);
    3983        16942 :   size_tree = make_tree (sizetype, size);
    3984              : 
    3985              :   /* It is incorrect to use the libcall calling conventions for calls to
    3986              :      memset because it can be provided by the user.  */
    3987        16942 :   fn = builtin_decl_implicit (BUILT_IN_MEMSET);
    3988        16942 :   call_expr = build_call_expr (fn, 3, object_tree, val_tree, size_tree);
    3989        16942 :   CALL_EXPR_TAILCALL (call_expr) = tailcall;
    3990              : 
    3991        16942 :   return expand_call (call_expr, NULL_RTX, false);
    3992              : }
    3993              : 
    3994              : /* Expand a setmem pattern; return true if successful.  */
    3995              : 
    3996              : bool
    3997        39140 : set_storage_via_setmem (rtx object, rtx size, rtx val, unsigned int align,
    3998              :                         unsigned int expected_align, HOST_WIDE_INT expected_size,
    3999              :                         unsigned HOST_WIDE_INT min_size,
    4000              :                         unsigned HOST_WIDE_INT max_size,
    4001              :                         unsigned HOST_WIDE_INT probable_max_size)
    4002              : {
    4003              :   /* Try the most limited insn first, because there's no point
    4004              :      including more than one in the machine description unless
    4005              :      the more limited one has some advantage.  */
    4006              : 
    4007        39140 :   if (expected_align < align)
    4008              :     expected_align = align;
    4009        39140 :   if (expected_size != -1)
    4010              :     {
    4011            8 :       if ((unsigned HOST_WIDE_INT)expected_size > max_size)
    4012            0 :         expected_size = max_size;
    4013            8 :       if ((unsigned HOST_WIDE_INT)expected_size < min_size)
    4014            0 :         expected_size = min_size;
    4015              :     }
    4016              : 
    4017        39140 :   opt_scalar_int_mode mode_iter;
    4018       239630 :   FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT)
    4019              :     {
    4020       215342 :       scalar_int_mode mode = mode_iter.require ();
    4021       215342 :       enum insn_code code = direct_optab_handler (setmem_optab, mode);
    4022              : 
    4023       215342 :       if (code != CODE_FOR_nothing
    4024              :           /* We don't need MODE to be narrower than BITS_PER_HOST_WIDE_INT
    4025              :              here because if SIZE is less than the mode mask, as it is
    4026              :              returned by the macro, it will definitely be less than the
    4027              :              actual mode mask.  Since SIZE is within the Pmode address
    4028              :              space, we limit MODE to Pmode.  */
    4029       215342 :           && ((CONST_INT_P (size)
    4030        35268 :                && ((unsigned HOST_WIDE_INT) INTVAL (size)
    4031        35268 :                    <= (GET_MODE_MASK (mode) >> 1)))
    4032        27268 :               || max_size <= (GET_MODE_MASK (mode) >> 1)
    4033        32834 :               || GET_MODE_BITSIZE (mode) >= GET_MODE_BITSIZE (Pmode)))
    4034              :         {
    4035        51620 :           class expand_operand ops[9];
    4036        51620 :           unsigned int nops;
    4037              : 
    4038        51620 :           nops = insn_data[(int) code].n_generator_args;
    4039        51620 :           gcc_assert (nops == 4 || nops == 6 || nops == 8 || nops == 9);
    4040              : 
    4041        51620 :           create_fixed_operand (&ops[0], object);
    4042              :           /* The check above guarantees that this size conversion is valid.  */
    4043        51620 :           create_convert_operand_to (&ops[1], size, mode, true);
    4044        51620 :           create_convert_operand_from (&ops[2], val, byte_mode, true);
    4045        51620 :           create_integer_operand (&ops[3], align / BITS_PER_UNIT);
    4046        51620 :           if (nops >= 6)
    4047              :             {
    4048        51620 :               create_integer_operand (&ops[4], expected_align / BITS_PER_UNIT);
    4049        51620 :               create_integer_operand (&ops[5], expected_size);
    4050              :             }
    4051        51620 :           if (nops >= 8)
    4052              :             {
    4053        51620 :               create_integer_operand (&ops[6], min_size);
    4054              :               /* If we cannot represent the maximal size,
    4055              :                  make parameter NULL.  */
    4056        51620 :               if ((HOST_WIDE_INT) max_size != -1)
    4057        48189 :                 create_integer_operand (&ops[7], max_size);
    4058              :               else
    4059         3431 :                 create_fixed_operand (&ops[7], NULL);
    4060              :             }
    4061        51620 :           if (nops == 9)
    4062              :             {
    4063              :               /* If we cannot represent the maximal size,
    4064              :                  make parameter NULL.  */
    4065        51620 :               if ((HOST_WIDE_INT) probable_max_size != -1)
    4066        48380 :                 create_integer_operand (&ops[8], probable_max_size);
    4067              :               else
    4068         3240 :                 create_fixed_operand (&ops[8], NULL);
    4069              :             }
    4070        51620 :           gcc_assert (min_size != max_size
    4071              :                       || rtx_equal_p (ops[1].value, GEN_INT (min_size)));
    4072        51620 :           if (maybe_expand_insn (code, nops, ops))
    4073        14852 :             return true;
    4074              :         }
    4075              :     }
    4076              : 
    4077              :   return false;
    4078              : }
    4079              : 
    4080              : 
    4081              : /* Write to one of the components of the complex value CPLX.  Write VAL to
    4082              :    the real part if IMAG_P is false, and the imaginary part if its true.
    4083              :    If UNDEFINED_P then the value in CPLX is currently undefined.  */
    4084              : 
    4085              : void
    4086       585204 : write_complex_part (rtx cplx, rtx val, bool imag_p, bool undefined_p)
    4087              : {
    4088       585204 :   machine_mode cmode;
    4089       585204 :   scalar_mode imode;
    4090       585204 :   unsigned ibitsize;
    4091              : 
    4092       585204 :   if (GET_CODE (cplx) == CONCAT)
    4093              :     {
    4094       526634 :       emit_move_insn (XEXP (cplx, imag_p), val);
    4095       526634 :       return;
    4096              :     }
    4097              : 
    4098        58570 :   cmode = GET_MODE (cplx);
    4099        58570 :   imode = GET_MODE_INNER (cmode);
    4100        58570 :   ibitsize = GET_MODE_BITSIZE (imode);
    4101              : 
    4102              :   /* For MEMs simplify_gen_subreg may generate an invalid new address
    4103              :      because, e.g., the original address is considered mode-dependent
    4104              :      by the target, which restricts simplify_subreg from invoking
    4105              :      adjust_address_nv.  Instead of preparing fallback support for an
    4106              :      invalid address, we call adjust_address_nv directly.  */
    4107        58570 :   if (MEM_P (cplx))
    4108              :     {
    4109        69270 :       emit_move_insn (adjust_address_nv (cplx, imode,
    4110              :                                          imag_p ? GET_MODE_SIZE (imode) : 0),
    4111              :                       val);
    4112        46180 :       return;
    4113              :     }
    4114              : 
    4115              :   /* If the sub-object is at least word sized, then we know that subregging
    4116              :      will work.  This special case is important, since store_bit_field
    4117              :      wants to operate on integer modes, and there's rarely an OImode to
    4118              :      correspond to TCmode.  */
    4119        12390 :   if (ibitsize >= BITS_PER_WORD
    4120              :       /* For hard regs we have exact predicates.  Assume we can split
    4121              :          the original object if it spans an even number of hard regs.
    4122              :          This special case is important for SCmode on 64-bit platforms
    4123              :          where the natural size of floating-point regs is 32-bit.  */
    4124        12390 :       || (REG_P (cplx)
    4125         7326 :           && REGNO (cplx) < FIRST_PSEUDO_REGISTER
    4126         7122 :           && REG_NREGS (cplx) % 2 == 0))
    4127              :     {
    4128         5078 :       rtx part = simplify_gen_subreg (imode, cplx, cmode,
    4129         7617 :                                       imag_p ? GET_MODE_SIZE (imode) : 0);
    4130         5078 :       if (part)
    4131              :         {
    4132         5078 :           emit_move_insn (part, val);
    4133         5078 :           return;
    4134              :         }
    4135              :       else
    4136              :         /* simplify_gen_subreg may fail for sub-word MEMs.  */
    4137            0 :         gcc_assert (MEM_P (cplx) && ibitsize < BITS_PER_WORD);
    4138              :     }
    4139              : 
    4140        10968 :   store_bit_field (cplx, ibitsize, imag_p ? ibitsize : 0, 0, 0, imode, val,
    4141              :                    false, undefined_p);
    4142              : }
    4143              : 
    4144              : /* Extract one of the components of the complex value CPLX.  Extract the
    4145              :    real part if IMAG_P is false, and the imaginary part if it's true.  */
    4146              : 
    4147              : rtx
    4148       574595 : read_complex_part (rtx cplx, bool imag_p)
    4149              : {
    4150       574595 :   machine_mode cmode;
    4151       574595 :   scalar_mode imode;
    4152       574595 :   unsigned ibitsize;
    4153              : 
    4154       574595 :   if (GET_CODE (cplx) == CONCAT)
    4155       356920 :     return XEXP (cplx, imag_p);
    4156              : 
    4157       217675 :   cmode = GET_MODE (cplx);
    4158       217675 :   imode = GET_MODE_INNER (cmode);
    4159       217675 :   ibitsize = GET_MODE_BITSIZE (imode);
    4160              : 
    4161              :   /* Special case reads from complex constants that got spilled to memory.  */
    4162       217675 :   if (MEM_P (cplx) && GET_CODE (XEXP (cplx, 0)) == SYMBOL_REF)
    4163              :     {
    4164        37987 :       tree decl = SYMBOL_REF_DECL (XEXP (cplx, 0));
    4165        37987 :       if (decl && TREE_CODE (decl) == COMPLEX_CST)
    4166              :         {
    4167            0 :           tree part = imag_p ? TREE_IMAGPART (decl) : TREE_REALPART (decl);
    4168            0 :           if (CONSTANT_CLASS_P (part))
    4169            0 :             return expand_expr (part, NULL_RTX, imode, EXPAND_NORMAL);
    4170              :         }
    4171              :     }
    4172              : 
    4173              :   /* For MEMs simplify_gen_subreg may generate an invalid new address
    4174              :      because, e.g., the original address is considered mode-dependent
    4175              :      by the target, which restricts simplify_subreg from invoking
    4176              :      adjust_address_nv.  Instead of preparing fallback support for an
    4177              :      invalid address, we call adjust_address_nv directly.  */
    4178       217675 :   if (MEM_P (cplx))
    4179       237613 :     return adjust_address_nv (cplx, imode,
    4180              :                               imag_p ? GET_MODE_SIZE (imode) : 0);
    4181              : 
    4182              :   /* If the sub-object is at least word sized, then we know that subregging
    4183              :      will work.  This special case is important, since extract_bit_field
    4184              :      wants to operate on integer modes, and there's rarely an OImode to
    4185              :      correspond to TCmode.  */
    4186        59092 :   if (ibitsize >= BITS_PER_WORD
    4187              :       /* For hard regs we have exact predicates.  Assume we can split
    4188              :          the original object if it spans an even number of hard regs.
    4189              :          This special case is important for SCmode on 64-bit platforms
    4190              :          where the natural size of floating-point regs is 32-bit.  */
    4191        59092 :       || (REG_P (cplx)
    4192        38114 :           && REGNO (cplx) < FIRST_PSEUDO_REGISTER
    4193          294 :           && REG_NREGS (cplx) % 2 == 0))
    4194              :     {
    4195        10313 :       rtx ret = simplify_gen_subreg (imode, cplx, cmode,
    4196        15469 :                                      imag_p ? GET_MODE_SIZE (imode) : 0);
    4197        10313 :       if (ret)
    4198              :         return ret;
    4199              :     }
    4200              : 
    4201        73166 :   return extract_bit_field (cplx, ibitsize, imag_p ? ibitsize : 0,
    4202              :                             true, NULL_RTX, imode, imode, false, NULL);
    4203              : }
    4204              : 
    4205              : /* A subroutine of emit_move_insn_1.  Yet another lowpart generator.
    4206              :    NEW_MODE and OLD_MODE are the same size.  Return NULL if X cannot be
    4207              :    represented in NEW_MODE.  If FORCE is true, this will never happen, as
    4208              :    we'll force-create a SUBREG if needed.  */
    4209              : 
    4210              : static rtx
    4211       280623 : emit_move_change_mode (machine_mode new_mode,
    4212              :                        machine_mode old_mode, rtx x, bool force)
    4213              : {
    4214       280623 :   rtx ret;
    4215              : 
    4216       280623 :   if (push_operand (x, GET_MODE (x)))
    4217              :     {
    4218         1318 :       ret = gen_rtx_MEM (new_mode, XEXP (x, 0));
    4219         1318 :       MEM_COPY_ATTRIBUTES (ret, x);
    4220              :     }
    4221       279305 :   else if (MEM_P (x))
    4222              :     {
    4223              :       /* We don't have to worry about changing the address since the
    4224              :          size in bytes is supposed to be the same.  */
    4225        52747 :       if (reload_in_progress)
    4226              :         {
    4227              :           /* Copy the MEM to change the mode and move any
    4228              :              substitutions from the old MEM to the new one.  */
    4229            0 :           ret = adjust_address_nv (x, new_mode, 0);
    4230            0 :           copy_replacements (x, ret);
    4231              :         }
    4232              :       else
    4233        52747 :         ret = adjust_address (x, new_mode, 0);
    4234              :     }
    4235              :   else
    4236              :     {
    4237              :       /* Note that we do want simplify_subreg's behavior of validating
    4238              :          that the new mode is ok for a hard register.  If we were to use
    4239              :          simplify_gen_subreg, we would create the subreg, but would
    4240              :          probably run into the target not being able to implement it.  */
    4241              :       /* Except, of course, when FORCE is true, when this is exactly what
    4242              :          we want.  Which is needed for CCmodes on some targets.  */
    4243       226558 :       if (force)
    4244       226557 :         ret = simplify_gen_subreg (new_mode, x, old_mode, 0);
    4245              :       else
    4246            1 :         ret = simplify_subreg (new_mode, x, old_mode, 0);
    4247              :     }
    4248              : 
    4249       280623 :   return ret;
    4250              : }
    4251              : 
    4252              : /* A subroutine of emit_move_insn_1.  Generate a move from Y into X using
    4253              :    an integer mode of the same size as MODE.  Returns the instruction
    4254              :    emitted, or NULL if such a move could not be generated.  */
    4255              : 
    4256              : static rtx_insn *
    4257       140312 : emit_move_via_integer (machine_mode mode, rtx x, rtx y, bool force)
    4258              : {
    4259       140312 :   scalar_int_mode imode;
    4260       140312 :   enum insn_code code;
    4261              : 
    4262              :   /* There must exist a mode of the exact size we require.  */
    4263       140312 :   if (!int_mode_for_mode (mode).exists (&imode))
    4264            0 :     return NULL;
    4265              : 
    4266              :   /* The target must support moves in this mode.  */
    4267       140312 :   code = optab_handler (mov_optab, imode);
    4268       140312 :   if (code == CODE_FOR_nothing)
    4269              :     return NULL;
    4270              : 
    4271       140312 :   x = emit_move_change_mode (imode, mode, x, force);
    4272       140312 :   if (x == NULL_RTX)
    4273              :     return NULL;
    4274       140311 :   y = emit_move_change_mode (imode, mode, y, force);
    4275       140311 :   if (y == NULL_RTX)
    4276              :     return NULL;
    4277       140311 :   return emit_insn (GEN_FCN (code) (x, y));
    4278              : }
    4279              : 
    4280              : /* A subroutine of emit_move_insn_1.  X is a push_operand in MODE.
    4281              :    Return an equivalent MEM that does not use an auto-increment.  */
    4282              : 
    4283              : rtx
    4284         3638 : emit_move_resolve_push (machine_mode mode, rtx x)
    4285              : {
    4286         3638 :   enum rtx_code code = GET_CODE (XEXP (x, 0));
    4287         3638 :   rtx temp;
    4288              : 
    4289         7276 :   poly_int64 adjust = GET_MODE_SIZE (mode);
    4290              : #ifdef PUSH_ROUNDING
    4291         3638 :   adjust = PUSH_ROUNDING (adjust);
    4292              : #endif
    4293         3638 :   if (code == PRE_DEC || code == POST_DEC)
    4294         3242 :     adjust = -adjust;
    4295          396 :   else if (code == PRE_MODIFY || code == POST_MODIFY)
    4296              :     {
    4297          396 :       rtx expr = XEXP (XEXP (x, 0), 1);
    4298              : 
    4299          396 :       gcc_assert (GET_CODE (expr) == PLUS || GET_CODE (expr) == MINUS);
    4300          396 :       poly_int64 val = rtx_to_poly_int64 (XEXP (expr, 1));
    4301          396 :       if (GET_CODE (expr) == MINUS)
    4302            0 :         val = -val;
    4303          396 :       gcc_assert (known_eq (adjust, val) || known_eq (adjust, -val));
    4304              :       adjust = val;
    4305              :     }
    4306              : 
    4307              :   /* Do not use anti_adjust_stack, since we don't want to update
    4308              :      stack_pointer_delta.  */
    4309         3642 :   temp = expand_simple_binop (Pmode, PLUS, stack_pointer_rtx,
    4310         3638 :                               gen_int_mode (adjust, Pmode), stack_pointer_rtx,
    4311              :                               0, OPTAB_LIB_WIDEN);
    4312         3638 :   if (temp != stack_pointer_rtx)
    4313            0 :     emit_move_insn (stack_pointer_rtx, temp);
    4314              : 
    4315         3638 :   switch (code)
    4316              :     {
    4317         3638 :     case PRE_INC:
    4318         3638 :     case PRE_DEC:
    4319         3638 :     case PRE_MODIFY:
    4320         3638 :       temp = stack_pointer_rtx;
    4321         3638 :       break;
    4322              :     case POST_INC:
    4323              :     case POST_DEC:
    4324              :     case POST_MODIFY:
    4325            0 :       temp = plus_constant (Pmode, stack_pointer_rtx, -adjust);
    4326            0 :       break;
    4327            0 :     default:
    4328            0 :       gcc_unreachable ();
    4329              :     }
    4330              : 
    4331         3638 :   return replace_equiv_address (x, temp);
    4332              : }
    4333              : 
    4334              : /* A subroutine of emit_move_complex.  Generate a move from Y into X.
    4335              :    X is known to satisfy push_operand, and MODE is known to be complex.
    4336              :    Returns the last instruction emitted.  */
    4337              : 
    4338              : rtx_insn *
    4339         5646 : emit_move_complex_push (machine_mode mode, rtx x, rtx y)
    4340              : {
    4341         5646 :   scalar_mode submode = GET_MODE_INNER (mode);
    4342         5646 :   bool imag_first;
    4343              : 
    4344              : #ifdef PUSH_ROUNDING
    4345        11292 :   poly_int64 submodesize = GET_MODE_SIZE (submode);
    4346              : 
    4347              :   /* In case we output to the stack, but the size is smaller than the
    4348              :      machine can push exactly, we need to use move instructions.  */
    4349         5646 :   if (maybe_ne (PUSH_ROUNDING (submodesize), submodesize))
    4350              :     {
    4351          718 :       x = emit_move_resolve_push (mode, x);
    4352          718 :       return emit_move_insn (x, y);
    4353              :     }
    4354              : #endif
    4355              : 
    4356              :   /* Note that the real part always precedes the imag part in memory
    4357              :      regardless of machine's endianness.  */
    4358         4928 :   switch (GET_CODE (XEXP (x, 0)))
    4359              :     {
    4360              :     case PRE_DEC:
    4361              :     case POST_DEC:
    4362              :       imag_first = true;
    4363              :       break;
    4364            0 :     case PRE_INC:
    4365            0 :     case POST_INC:
    4366            0 :       imag_first = false;
    4367            0 :       break;
    4368            0 :     default:
    4369            0 :       gcc_unreachable ();
    4370              :     }
    4371              : 
    4372         4928 :   emit_move_insn (gen_rtx_MEM (submode, XEXP (x, 0)),
    4373              :                   read_complex_part (y, imag_first));
    4374         4928 :   return emit_move_insn (gen_rtx_MEM (submode, XEXP (x, 0)),
    4375         4928 :                          read_complex_part (y, !imag_first));
    4376              : }
    4377              : 
    4378              : /* A subroutine of emit_move_complex.  Perform the move from Y to X
    4379              :    via two moves of the parts.  Returns the last instruction emitted.  */
    4380              : 
    4381              : rtx_insn *
    4382        90372 : emit_move_complex_parts (rtx x, rtx y)
    4383              : {
    4384              :   /* Show the output dies here.  This is necessary for SUBREGs
    4385              :      of pseudos since we cannot track their lifetimes correctly;
    4386              :      hard regs shouldn't appear here except as return values.  */
    4387        90372 :   if (!reload_completed && !reload_in_progress
    4388       180744 :       && REG_P (x) && !reg_overlap_mentioned_p (x, y))
    4389         6187 :     emit_clobber (x);
    4390              : 
    4391        90372 :   write_complex_part (x, read_complex_part (y, false), false, true);
    4392        90372 :   write_complex_part (x, read_complex_part (y, true), true, false);
    4393              : 
    4394        90372 :   return get_last_insn ();
    4395              : }
    4396              : 
    4397              : /* A subroutine of emit_move_insn_1.  Generate a move from Y into X.
    4398              :    MODE is known to be complex.  Returns the last instruction emitted.  */
    4399              : 
    4400              : static rtx_insn *
    4401       114138 : emit_move_complex (machine_mode mode, rtx x, rtx y)
    4402              : {
    4403       114138 :   bool try_int;
    4404              : 
    4405              :   /* Need to take special care for pushes, to maintain proper ordering
    4406              :      of the data, and possibly extra padding.  */
    4407       114138 :   if (push_operand (x, mode))
    4408         5038 :     return emit_move_complex_push (mode, x, y);
    4409              : 
    4410              :   /* See if we can coerce the target into moving both values at once, except
    4411              :      for floating point where we favor moving as parts if this is easy.  */
    4412       109100 :   if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
    4413        63087 :       && optab_handler (mov_optab, GET_MODE_INNER (mode)) != CODE_FOR_nothing
    4414        63087 :       && !(REG_P (x)
    4415         2264 :            && HARD_REGISTER_P (x)
    4416          597 :            && REG_NREGS (x) == 1)
    4417       172187 :       && !(REG_P (y)
    4418         3337 :            && HARD_REGISTER_P (y)
    4419         1668 :            && REG_NREGS (y) == 1))
    4420              :     try_int = false;
    4421              :   /* Not possible if the values are inherently not adjacent.  */
    4422        46013 :   else if (GET_CODE (x) == CONCAT || GET_CODE (y) == CONCAT)
    4423              :     try_int = false;
    4424              :   /* Is possible if both are registers (or subregs of registers).  */
    4425        19651 :   else if (register_operand (x, mode) && register_operand (y, mode))
    4426              :     try_int = true;
    4427              :   /* If one of the operands is a memory, and alignment constraints
    4428              :      are friendly enough, we may be able to do combined memory operations.
    4429              :      We do not attempt this if Y is a constant because that combination is
    4430              :      usually better with the by-parts thing below.  */
    4431          635 :   else if ((MEM_P (x) ? !CONSTANT_P (y) : MEM_P (y))
    4432              :            && (!STRICT_ALIGNMENT
    4433              :                || get_mode_alignment (mode) == BIGGEST_ALIGNMENT))
    4434              :     try_int = true;
    4435              :   else
    4436              :     try_int = false;
    4437              : 
    4438              :   if (try_int)
    4439              :     {
    4440        19651 :       rtx_insn *ret;
    4441              : 
    4442              :       /* For memory to memory moves, optimal behavior can be had with the
    4443              :          existing block move logic.  But use normal expansion if optimizing
    4444              :          for size.  */
    4445        19651 :       if (MEM_P (x) && MEM_P (y))
    4446              :         {
    4447          726 :           emit_block_move (x, y, gen_int_mode (GET_MODE_SIZE (mode), Pmode),
    4448          360 :                            (optimize_insn_for_speed_p()
    4449              :                             ? BLOCK_OP_NO_LIBCALL : BLOCK_OP_NORMAL));
    4450          360 :           return get_last_insn ();
    4451              :         }
    4452              : 
    4453        19291 :       ret = emit_move_via_integer (mode, x, y, true);
    4454        19291 :       if (ret)
    4455              :         return ret;
    4456              :     }
    4457              : 
    4458        89449 :   return emit_move_complex_parts (x, y);
    4459              : }
    4460              : 
    4461              : /* A subroutine of emit_move_insn_1.  Generate a move from Y into X.
    4462              :    MODE is known to be MODE_CC.  Returns the last instruction emitted.  */
    4463              : 
    4464              : static rtx_insn *
    4465            0 : emit_move_ccmode (machine_mode mode, rtx x, rtx y)
    4466              : {
    4467            0 :   rtx_insn *ret;
    4468              : 
    4469              :   /* Assume all MODE_CC modes are equivalent; if we have movcc, use it.  */
    4470            0 :   if (mode != CCmode)
    4471              :     {
    4472            0 :       enum insn_code code = optab_handler (mov_optab, CCmode);
    4473            0 :       if (code != CODE_FOR_nothing)
    4474              :         {
    4475            0 :           x = emit_move_change_mode (CCmode, mode, x, true);
    4476            0 :           y = emit_move_change_mode (CCmode, mode, y, true);
    4477            0 :           return emit_insn (GEN_FCN (code) (x, y));
    4478              :         }
    4479              :     }
    4480              : 
    4481              :   /* Otherwise, find the MODE_INT mode of the same width.  */
    4482            0 :   ret = emit_move_via_integer (mode, x, y, false);
    4483            0 :   gcc_assert (ret != NULL);
    4484              :   return ret;
    4485              : }
    4486              : 
    4487              : /* Return true if word I of OP lies entirely in the
    4488              :    undefined bits of a paradoxical subreg.  */
    4489              : 
    4490              : static bool
    4491            2 : undefined_operand_subword_p (const_rtx op, int i)
    4492              : {
    4493            2 :   if (GET_CODE (op) != SUBREG)
    4494              :     return false;
    4495            0 :   machine_mode innermostmode = GET_MODE (SUBREG_REG (op));
    4496            0 :   poly_int64 offset = i * UNITS_PER_WORD + subreg_memory_offset (op);
    4497            0 :   return (known_ge (offset, GET_MODE_SIZE (innermostmode))
    4498            0 :           || known_le (offset, -UNITS_PER_WORD));
    4499              : }
    4500              : 
    4501              : /* A subroutine of emit_move_insn_1.  Generate a move from Y into X.
    4502              :    MODE is any multi-word or full-word mode that lacks a move_insn
    4503              :    pattern.  Note that you will get better code if you define such
    4504              :    patterns, even if they must turn into multiple assembler instructions.  */
    4505              : 
    4506              : static rtx_insn *
    4507            1 : emit_move_multi_word (machine_mode mode, rtx x, rtx y)
    4508              : {
    4509            1 :   rtx_insn *last_insn = 0;
    4510            1 :   rtx_insn *seq;
    4511            1 :   rtx inner;
    4512            1 :   bool need_clobber;
    4513            1 :   int i, mode_size;
    4514              : 
    4515              :   /* This function can only handle cases where the number of words is
    4516              :      known at compile time.  */
    4517            1 :   mode_size = GET_MODE_SIZE (mode).to_constant ();
    4518            1 :   gcc_assert (mode_size >= UNITS_PER_WORD);
    4519              : 
    4520              :   /* If X is a push on the stack, do the push now and replace
    4521              :      X with a reference to the stack pointer.  */
    4522            1 :   if (push_operand (x, mode))
    4523            0 :     x = emit_move_resolve_push (mode, x);
    4524              : 
    4525              :   /* If we are in reload, see if either operand is a MEM whose address
    4526              :      is scheduled for replacement.  */
    4527            0 :   if (reload_in_progress && MEM_P (x)
    4528            1 :       && (inner = find_replacement (&XEXP (x, 0))) != XEXP (x, 0))
    4529            0 :     x = replace_equiv_address_nv (x, inner);
    4530            0 :   if (reload_in_progress && MEM_P (y)
    4531            1 :       && (inner = find_replacement (&XEXP (y, 0))) != XEXP (y, 0))
    4532            0 :     y = replace_equiv_address_nv (y, inner);
    4533              : 
    4534            1 :   start_sequence ();
    4535              : 
    4536            1 :   need_clobber = false;
    4537            3 :   for (i = 0; i < CEIL (mode_size, UNITS_PER_WORD); i++)
    4538              :     {
    4539              :       /* Do not generate code for a move if it would go entirely
    4540              :          to the non-existing bits of a paradoxical subreg.  */
    4541            1 :       if (undefined_operand_subword_p (x, i))
    4542            0 :         continue;
    4543              : 
    4544            1 :       rtx xpart = operand_subword (x, i, 1, mode);
    4545            1 :       rtx ypart;
    4546              : 
    4547              :       /* Do not generate code for a move if it would come entirely
    4548              :          from the undefined bits of a paradoxical subreg.  */
    4549            1 :       if (undefined_operand_subword_p (y, i))
    4550            0 :         continue;
    4551              : 
    4552            1 :       ypart = operand_subword (y, i, 1, mode);
    4553              : 
    4554              :       /* If we can't get a part of Y, put Y into memory if it is a
    4555              :          constant.  Otherwise, force it into a register.  Then we must
    4556              :          be able to get a part of Y.  */
    4557            1 :       if (ypart == 0 && CONSTANT_P (y))
    4558              :         {
    4559            0 :           y = use_anchored_address (force_const_mem (mode, y));
    4560            0 :           ypart = operand_subword (y, i, 1, mode);
    4561              :         }
    4562            0 :       else if (ypart == 0)
    4563            0 :         ypart = operand_subword_force (y, i, mode);
    4564              : 
    4565            1 :       gcc_assert (xpart && ypart);
    4566              : 
    4567            1 :       need_clobber |= (GET_CODE (xpart) == SUBREG);
    4568              : 
    4569            1 :       last_insn = emit_move_insn (xpart, ypart);
    4570              :     }
    4571              : 
    4572            1 :   seq = end_sequence ();
    4573              : 
    4574              :   /* Show the output dies here.  This is necessary for SUBREGs
    4575              :      of pseudos since we cannot track their lifetimes correctly;
    4576              :      hard regs shouldn't appear here except as return values.
    4577              :      We never want to emit such a clobber after reload.  */
    4578            1 :   if (x != y
    4579            1 :       && ! (reload_in_progress || reload_completed)
    4580            1 :       && need_clobber != 0)
    4581            1 :     emit_clobber (x);
    4582              : 
    4583            1 :   emit_insn (seq);
    4584              : 
    4585            1 :   return last_insn;
    4586              : }
    4587              : 
    4588              : /* Low level part of emit_move_insn.
    4589              :    Called just like emit_move_insn, but assumes X and Y
    4590              :    are basically valid.  */
    4591              : 
    4592              : rtx_insn *
    4593     78741561 : emit_move_insn_1 (rtx x, rtx y)
    4594              : {
    4595     78741561 :   machine_mode mode = GET_MODE (x);
    4596     78741561 :   enum insn_code code;
    4597              : 
    4598     78741561 :   gcc_assert ((unsigned int) mode < (unsigned int) MAX_MACHINE_MODE);
    4599              : 
    4600     78741561 :   code = optab_handler (mov_optab, mode);
    4601     78741561 :   if (code != CODE_FOR_nothing)
    4602     78506402 :     return emit_insn (GEN_FCN (code) (x, y));
    4603              : 
    4604              :   /* Expand complex moves by moving real part and imag part.  */
    4605       235159 :   if (COMPLEX_MODE_P (mode))
    4606       114138 :     return emit_move_complex (mode, x, y);
    4607              : 
    4608              :   if (GET_MODE_CLASS (mode) == MODE_DECIMAL_FLOAT
    4609              :       || ALL_FIXED_POINT_MODE_P (mode))
    4610              :     {
    4611       121020 :       rtx_insn *result = emit_move_via_integer (mode, x, y, true);
    4612              : 
    4613              :       /* If we can't find an integer mode, use multi words.  */
    4614       121020 :       if (result)
    4615              :         return result;
    4616              :       else
    4617            0 :         return emit_move_multi_word (mode, x, y);
    4618              :     }
    4619              : 
    4620              :   if (GET_MODE_CLASS (mode) == MODE_CC)
    4621            0 :     return emit_move_ccmode (mode, x, y);
    4622              : 
    4623              :   /* Try using a move pattern for the corresponding integer mode.  This is
    4624              :      only safe when simplify_subreg can convert MODE constants into integer
    4625              :      constants.  At present, it can only do this reliably if the value
    4626              :      fits within a HOST_WIDE_INT.  */
    4627            1 :   if (!CONSTANT_P (y)
    4628            2 :       || known_le (GET_MODE_BITSIZE (mode), HOST_BITS_PER_WIDE_INT))
    4629              :     {
    4630            1 :       rtx_insn *ret = emit_move_via_integer (mode, x, y, lra_in_progress);
    4631              : 
    4632            1 :       if (ret)
    4633              :         {
    4634            0 :           if (! lra_in_progress || recog (PATTERN (ret), ret, 0) >= 0)
    4635              :             return ret;
    4636              :         }
    4637              :     }
    4638              : 
    4639            1 :   return emit_move_multi_word (mode, x, y);
    4640              : }
    4641              : 
    4642              : /* Generate code to copy Y into X.
    4643              :    Both Y and X must have the same mode, except that
    4644              :    Y can be a constant with VOIDmode.
    4645              :    This mode cannot be BLKmode; use emit_block_move for that.
    4646              : 
    4647              :    Return the last instruction emitted.  */
    4648              : 
    4649              : rtx_insn *
    4650     72731265 : emit_move_insn (rtx x, rtx y)
    4651              : {
    4652     72731265 :   machine_mode mode = GET_MODE (x);
    4653     72731265 :   rtx y_cst = NULL_RTX;
    4654     72731265 :   rtx_insn *last_insn;
    4655     72731265 :   rtx set;
    4656              : 
    4657     72731265 :   gcc_assert (mode != BLKmode
    4658              :               && (GET_MODE (y) == mode || GET_MODE (y) == VOIDmode));
    4659              : 
    4660              :   /* If we have a copy that looks like one of the following patterns:
    4661              :        (set (subreg:M1 (reg:M2 ...)) (subreg:M1 (reg:M2 ...)))
    4662              :        (set (subreg:M1 (reg:M2 ...)) (mem:M1 ADDR))
    4663              :        (set (mem:M1 ADDR) (subreg:M1 (reg:M2 ...)))
    4664              :        (set (subreg:M1 (reg:M2 ...)) (constant C))
    4665              :      where mode M1 is equal in size to M2, try to detect whether the
    4666              :      mode change involves an implicit round trip through memory.
    4667              :      If so, see if we can avoid that by removing the subregs and
    4668              :      doing the move in mode M2 instead.  */
    4669              : 
    4670     72731265 :   rtx x_inner = NULL_RTX;
    4671     72731265 :   rtx y_inner = NULL_RTX;
    4672              : 
    4673     75573384 :   auto candidate_subreg_p = [&](rtx subreg) {
    4674      2842119 :     return (REG_P (SUBREG_REG (subreg))
    4675      8524347 :             && known_eq (GET_MODE_SIZE (GET_MODE (SUBREG_REG (subreg))),
    4676              :                          GET_MODE_SIZE (GET_MODE (subreg)))
    4677      3225672 :             && optab_handler (mov_optab, GET_MODE (SUBREG_REG (subreg)))
    4678      2842119 :                != CODE_FOR_nothing);
    4679              :   };
    4680              : 
    4681     72737525 :   auto candidate_mem_p = [&](machine_mode innermode, rtx mem) {
    4682         6260 :     return (!targetm.can_change_mode_class (innermode, GET_MODE (mem), ALL_REGS)
    4683         6260 :             && !push_operand (mem, GET_MODE (mem))
    4684              :             /* Not a candidate if innermode requires too much alignment.  */
    4685        12458 :             && (MEM_ALIGN (mem) >= GET_MODE_ALIGNMENT (innermode)
    4686          242 :                 || targetm.slow_unaligned_access (GET_MODE (mem),
    4687          121 :                                                   MEM_ALIGN (mem))
    4688          242 :                 || !targetm.slow_unaligned_access (innermode,
    4689          121 :                                                    MEM_ALIGN (mem))));
    4690              :   };
    4691              : 
    4692     72731265 :   if (SUBREG_P (x) && candidate_subreg_p (x))
    4693        15068 :     x_inner = SUBREG_REG (x);
    4694              : 
    4695     72731265 :   if (SUBREG_P (y) && candidate_subreg_p (y))
    4696       329320 :     y_inner = SUBREG_REG (y);
    4697              : 
    4698     72731265 :   if (x_inner != NULL_RTX
    4699     72731265 :       && y_inner != NULL_RTX
    4700         1268 :       && GET_MODE (x_inner) == GET_MODE (y_inner)
    4701     72732109 :       && !targetm.can_change_mode_class (GET_MODE (x_inner), mode, ALL_REGS))
    4702              :     {
    4703          844 :       x = x_inner;
    4704          844 :       y = y_inner;
    4705          844 :       mode = GET_MODE (x_inner);
    4706              :     }
    4707     72730421 :   else if (x_inner != NULL_RTX
    4708        14224 :            && MEM_P (y)
    4709     72730746 :            && candidate_mem_p (GET_MODE (x_inner), y))
    4710              :     {
    4711          325 :       x = x_inner;
    4712          325 :       y = adjust_address (y, GET_MODE (x_inner), 0);
    4713          325 :       mode = GET_MODE (x_inner);
    4714              :     }
    4715     72730096 :   else if (y_inner != NULL_RTX
    4716       328476 :            && MEM_P (x)
    4717     72736031 :            && candidate_mem_p (GET_MODE (y_inner), x))
    4718              :     {
    4719         5873 :       x = adjust_address (x, GET_MODE (y_inner), 0);
    4720         5873 :       y = y_inner;
    4721         5873 :       mode = GET_MODE (y_inner);
    4722              :     }
    4723     72724223 :   else if (x_inner != NULL_RTX
    4724        13899 :            && CONSTANT_P (y)
    4725          487 :            && !targetm.can_change_mode_class (GET_MODE (x_inner),
    4726              :                                               mode, ALL_REGS)
    4727     72724710 :            && (y_inner = simplify_subreg (GET_MODE (x_inner), y, mode, 0)))
    4728              :     {
    4729          487 :       x = x_inner;
    4730          487 :       y = y_inner;
    4731          487 :       mode = GET_MODE (x_inner);
    4732              :     }
    4733              : 
    4734     72731265 :   if (CONSTANT_P (y))
    4735              :     {
    4736     17182411 :       if (optimize
    4737     13362538 :           && SCALAR_FLOAT_MODE_P (GET_MODE (x))
    4738     17963247 :           && (last_insn = compress_float_constant (x, y)))
    4739              :         return last_insn;
    4740              : 
    4741     17112792 :       y_cst = y;
    4742              : 
    4743     17112792 :       if (!targetm.legitimate_constant_p (mode, y))
    4744              :         {
    4745       530576 :           y = force_const_mem (mode, y);
    4746              : 
    4747              :           /* If the target's cannot_force_const_mem prevented the spill,
    4748              :              assume that the target's move expanders will also take care
    4749              :              of the non-legitimate constant.  */
    4750       530576 :           if (!y)
    4751              :             y = y_cst;
    4752              :           else
    4753       510525 :             y = use_anchored_address (y);
    4754              :         }
    4755              :     }
    4756              : 
    4757              :   /* If X or Y are memory references, verify that their addresses are valid
    4758              :      for the machine.  */
    4759     72661646 :   if (MEM_P (x)
    4760     89183682 :       && (! memory_address_addr_space_p (GET_MODE (x), XEXP (x, 0),
    4761     14251251 :                                          MEM_ADDR_SPACE (x))
    4762      2270959 :           && ! push_operand (x, GET_MODE (x))))
    4763          174 :     x = validize_mem (x);
    4764              : 
    4765     72661646 :   if (MEM_P (y)
    4766     90635475 :       && ! memory_address_addr_space_p (GET_MODE (y), XEXP (y, 0),
    4767     17973829 :                                         MEM_ADDR_SPACE (y)))
    4768         8778 :     y = validize_mem (y);
    4769              : 
    4770     72661646 :   gcc_assert (mode != BLKmode);
    4771              : 
    4772     72661646 :   last_insn = emit_move_insn_1 (x, y);
    4773              : 
    4774     17112792 :   if (y_cst && REG_P (x)
    4775     12531365 :       && (set = single_set (last_insn)) != NULL_RTX
    4776     12531365 :       && SET_DEST (set) == x
    4777     85178528 :       && ! rtx_equal_p (y_cst, SET_SRC (set)))
    4778      1290093 :     set_unique_reg_note (last_insn, REG_EQUAL, copy_rtx (y_cst));
    4779              : 
    4780              :   return last_insn;
    4781              : }
    4782              : 
    4783              : /* Generate the body of an instruction to copy Y into X.
    4784              :    It may be a list of insns, if one insn isn't enough.  */
    4785              : 
    4786              : rtx_insn *
    4787      6079835 : gen_move_insn (rtx x, rtx y)
    4788              : {
    4789      6079835 :   start_sequence ();
    4790      6079835 :   emit_move_insn_1 (x, y);
    4791      6079835 :   return end_sequence ();
    4792              : }
    4793              : 
    4794              : /* If Y is representable exactly in a narrower mode, and the target can
    4795              :    perform the extension directly from constant or memory, then emit the
    4796              :    move as an extension.  */
    4797              : 
    4798              : static rtx_insn *
    4799       780836 : compress_float_constant (rtx x, rtx y)
    4800              : {
    4801       780836 :   machine_mode dstmode = GET_MODE (x);
    4802       780836 :   machine_mode orig_srcmode = GET_MODE (y);
    4803       780836 :   machine_mode srcmode;
    4804       780836 :   const REAL_VALUE_TYPE *r;
    4805       780836 :   int oldcost, newcost;
    4806       780836 :   bool speed = optimize_insn_for_speed_p ();
    4807              : 
    4808       780836 :   r = CONST_DOUBLE_REAL_VALUE (y);
    4809              : 
    4810       780836 :   if (targetm.legitimate_constant_p (dstmode, y))
    4811       778686 :     oldcost = set_src_cost (y, orig_srcmode, speed);
    4812              :   else
    4813         2150 :     oldcost = set_src_cost (force_const_mem (dstmode, y), dstmode, speed);
    4814              : 
    4815      2766034 :   FOR_EACH_MODE_UNTIL (srcmode, orig_srcmode)
    4816              :     {
    4817      2054817 :       enum insn_code ic;
    4818      2054817 :       rtx trunc_y;
    4819      2054817 :       rtx_insn *last_insn;
    4820              : 
    4821              :       /* Skip if the target can't extend this way.  */
    4822      2054817 :       ic = can_extend_p (dstmode, srcmode, 0);
    4823      2054817 :       if (ic == CODE_FOR_nothing)
    4824      1624866 :         continue;
    4825              : 
    4826              :       /* Skip if the narrowed value isn't exact.  */
    4827       429951 :       if (! exact_real_truncate (srcmode, r))
    4828        53887 :         continue;
    4829              : 
    4830       376064 :       trunc_y = const_double_from_real_value (*r, srcmode);
    4831              : 
    4832       376064 :       if (targetm.legitimate_constant_p (srcmode, trunc_y))
    4833              :         {
    4834              :           /* Skip if the target needs extra instructions to perform
    4835              :              the extension.  */
    4836       372079 :           if (!insn_operand_matches (ic, 1, trunc_y))
    4837         4966 :             continue;
    4838              :           /* This is valid, but may not be cheaper than the original. */
    4839       367113 :           newcost = set_src_cost (gen_rtx_FLOAT_EXTEND (dstmode, trunc_y),
    4840              :                                   dstmode, speed);
    4841       367113 :           if (oldcost < newcost)
    4842       297494 :             continue;
    4843              :         }
    4844         3985 :       else if (float_extend_from_mem[dstmode][srcmode])
    4845              :         {
    4846            0 :           trunc_y = force_const_mem (srcmode, trunc_y);
    4847              :           /* This is valid, but may not be cheaper than the original. */
    4848            0 :           newcost = set_src_cost (gen_rtx_FLOAT_EXTEND (dstmode, trunc_y),
    4849              :                                   dstmode, speed);
    4850            0 :           if (oldcost < newcost)
    4851            0 :             continue;
    4852            0 :           trunc_y = validize_mem (trunc_y);
    4853              :         }
    4854              :       else
    4855         3985 :         continue;
    4856              : 
    4857              :       /* For CSE's benefit, force the compressed constant pool entry
    4858              :          into a new pseudo.  This constant may be used in different modes,
    4859              :          and if not, combine will put things back together for us.  */
    4860        69619 :       trunc_y = force_reg (srcmode, trunc_y);
    4861              : 
    4862              :       /* If x is a hard register, perform the extension into a pseudo,
    4863              :          so that e.g. stack realignment code is aware of it.  */
    4864        69619 :       rtx target = x;
    4865        69619 :       if (REG_P (x) && HARD_REGISTER_P (x))
    4866            2 :         target = gen_reg_rtx (dstmode);
    4867              : 
    4868        69619 :       emit_unop_insn (ic, target, trunc_y, UNKNOWN);
    4869        69619 :       last_insn = get_last_insn ();
    4870              : 
    4871        69619 :       if (REG_P (target))
    4872        58847 :         set_unique_reg_note (last_insn, REG_EQUAL, y);
    4873              : 
    4874        69619 :       if (target != x)
    4875            2 :         return emit_move_insn (x, target);
    4876              :       return last_insn;
    4877              :     }
    4878              : 
    4879              :   return NULL;
    4880              : }
    4881              : 
    4882              : /* Pushing data onto the stack.  */
    4883              : 
    4884              : /* Push a block of length SIZE (perhaps variable)
    4885              :    and return an rtx to address the beginning of the block.
    4886              :    The value may be virtual_outgoing_args_rtx.
    4887              : 
    4888              :    EXTRA is the number of bytes of padding to push in addition to SIZE.
    4889              :    BELOW nonzero means this padding comes at low addresses;
    4890              :    otherwise, the padding comes at high addresses.  */
    4891              : 
    4892              : rtx
    4893       269753 : push_block (rtx size, poly_int64 extra, int below)
    4894              : {
    4895       269753 :   rtx temp;
    4896              : 
    4897       334744 :   size = convert_modes (Pmode, ptr_mode, size, 1);
    4898       269753 :   if (CONSTANT_P (size))
    4899       334744 :     anti_adjust_stack (plus_constant (Pmode, size, extra));
    4900            0 :   else if (REG_P (size) && known_eq (extra, 0))
    4901            0 :     anti_adjust_stack (size);
    4902              :   else
    4903              :     {
    4904            0 :       temp = copy_to_mode_reg (Pmode, size);
    4905            0 :       if (maybe_ne (extra, 0))
    4906            0 :         temp = expand_binop (Pmode, add_optab, temp,
    4907            0 :                              gen_int_mode (extra, Pmode),
    4908              :                              temp, 0, OPTAB_LIB_WIDEN);
    4909            0 :       anti_adjust_stack (temp);
    4910              :     }
    4911              : 
    4912       269753 :   if (STACK_GROWS_DOWNWARD)
    4913              :     {
    4914       269753 :       temp = virtual_outgoing_args_rtx;
    4915       269753 :       if (maybe_ne (extra, 0) && below)
    4916            0 :         temp = plus_constant (Pmode, temp, extra);
    4917              :     }
    4918              :   else
    4919              :     {
    4920              :       poly_int64 csize;
    4921              :       if (poly_int_rtx_p (size, &csize))
    4922              :         temp = plus_constant (Pmode, virtual_outgoing_args_rtx,
    4923              :                               -csize - (below ? 0 : extra));
    4924              :       else if (maybe_ne (extra, 0) && !below)
    4925              :         temp = gen_rtx_PLUS (Pmode, virtual_outgoing_args_rtx,
    4926              :                              negate_rtx (Pmode, plus_constant (Pmode, size,
    4927              :                                                                extra)));
    4928              :       else
    4929              :         temp = gen_rtx_PLUS (Pmode, virtual_outgoing_args_rtx,
    4930              :                              negate_rtx (Pmode, size));
    4931              :     }
    4932              : 
    4933       269753 :   return memory_address (NARROWEST_INT_MODE, temp);
    4934              : }
    4935              : 
    4936              : /* A utility routine that returns the base of an auto-inc memory, or NULL.  */
    4937              : 
    4938              : static rtx
    4939      2589338 : mem_autoinc_base (rtx mem)
    4940              : {
    4941            0 :   if (MEM_P (mem))
    4942              :     {
    4943      1577878 :       rtx addr = XEXP (mem, 0);
    4944      1577878 :       if (GET_RTX_CLASS (GET_CODE (addr)) == RTX_AUTOINC)
    4945      1038184 :         return XEXP (addr, 0);
    4946              :     }
    4947              :   return NULL;
    4948              : }
    4949              : 
    4950              : /* A utility routine used here, in reload, and in try_split.  The insns
    4951              :    after PREV up to and including LAST are known to adjust the stack,
    4952              :    with a final value of END_ARGS_SIZE.  Iterate backward from LAST
    4953              :    placing notes as appropriate.  PREV may be NULL, indicating the
    4954              :    entire insn sequence prior to LAST should be scanned.
    4955              : 
    4956              :    The set of allowed stack pointer modifications is small:
    4957              :      (1) One or more auto-inc style memory references (aka pushes),
    4958              :      (2) One or more addition/subtraction with the SP as destination,
    4959              :      (3) A single move insn with the SP as destination,
    4960              :      (4) A call_pop insn,
    4961              :      (5) Noreturn call insns if !ACCUMULATE_OUTGOING_ARGS.
    4962              : 
    4963              :    Insns in the sequence that do not modify the SP are ignored,
    4964              :    except for noreturn calls.
    4965              : 
    4966              :    The return value is the amount of adjustment that can be trivially
    4967              :    verified, via immediate operand or auto-inc.  If the adjustment
    4968              :    cannot be trivially extracted, the return value is HOST_WIDE_INT_MIN.  */
    4969              : 
    4970              : poly_int64
    4971      4651020 : find_args_size_adjust (rtx_insn *insn)
    4972              : {
    4973      4651020 :   rtx dest, set, pat;
    4974      4651020 :   int i;
    4975              : 
    4976      4651020 :   pat = PATTERN (insn);
    4977      4651020 :   set = NULL;
    4978              : 
    4979              :   /* Look for a call_pop pattern.  */
    4980      4651020 :   if (CALL_P (insn))
    4981              :     {
    4982              :       /* We have to allow non-call_pop patterns for the case
    4983              :          of emit_single_push_insn of a TLS address.  */
    4984      2999613 :       if (GET_CODE (pat) != PARALLEL)
    4985      2984791 :         return 0;
    4986              : 
    4987              :       /* All call_pop have a stack pointer adjust in the parallel.
    4988              :          The call itself is always first, and the stack adjust is
    4989              :          usually last, so search from the end.  */
    4990        14822 :       for (i = XVECLEN (pat, 0) - 1; i > 0; --i)
    4991              :         {
    4992        14822 :           set = XVECEXP (pat, 0, i);
    4993        14822 :           if (GET_CODE (set) != SET)
    4994            0 :             continue;
    4995        14822 :           dest = SET_DEST (set);
    4996        14822 :           if (dest == stack_pointer_rtx)
    4997              :             break;
    4998              :         }
    4999              :       /* We'd better have found the stack pointer adjust.  */
    5000        14822 :       if (i == 0)
    5001            0 :         return 0;
    5002              :       /* Fall through to process the extracted SET and DEST
    5003              :          as if it was a standalone insn.  */
    5004              :     }
    5005      1651407 :   else if (GET_CODE (pat) == SET)
    5006              :     set = pat;
    5007       257325 :   else if ((set = single_set (insn)) != NULL)
    5008              :     ;
    5009        47839 :   else if (GET_CODE (pat) == PARALLEL)
    5010              :     {
    5011              :       /* ??? Some older ports use a parallel with a stack adjust
    5012              :          and a store for a PUSH_ROUNDING pattern, rather than a
    5013              :          PRE/POST_MODIFY rtx.  Don't force them to update yet...  */
    5014              :       /* ??? See h8300 and m68k, pushqi1.  */
    5015            0 :       for (i = XVECLEN (pat, 0) - 1; i >= 0; --i)
    5016              :         {
    5017            0 :           set = XVECEXP (pat, 0, i);
    5018            0 :           if (GET_CODE (set) != SET)
    5019            0 :             continue;
    5020            0 :           dest = SET_DEST (set);
    5021            0 :           if (dest == stack_pointer_rtx)
    5022              :             break;
    5023              : 
    5024              :           /* We do not expect an auto-inc of the sp in the parallel.  */
    5025            0 :           gcc_checking_assert (mem_autoinc_base (dest) != stack_pointer_rtx);
    5026            0 :           gcc_checking_assert (mem_autoinc_base (SET_SRC (set))
    5027              :                                != stack_pointer_rtx);
    5028              :         }
    5029            0 :       if (i < 0)
    5030            0 :         return 0;
    5031              :     }
    5032              :   else
    5033        47839 :     return 0;
    5034              : 
    5035      1618390 :   dest = SET_DEST (set);
    5036              : 
    5037              :   /* Look for direct modifications of the stack pointer.  */
    5038      1618390 :   if (REG_P (dest) && REGNO (dest) == STACK_POINTER_REGNUM)
    5039              :     {
    5040              :       /* Look for a trivial adjustment, otherwise assume nothing.  */
    5041              :       /* Note that the SPU restore_stack_block pattern refers to
    5042              :          the stack pointer in V4SImode.  Consider that non-trivial.  */
    5043       323721 :       poly_int64 offset;
    5044       323721 :       if (SCALAR_INT_MODE_P (GET_MODE (dest))
    5045       323721 :           && strip_offset (SET_SRC (set), &offset) == stack_pointer_rtx)
    5046       321228 :         return offset;
    5047              :       /* ??? Reload can generate no-op moves, which will be cleaned
    5048              :          up later.  Recognize it and continue searching.  */
    5049         2493 :       else if (rtx_equal_p (dest, SET_SRC (set)))
    5050            0 :         return 0;
    5051              :       else
    5052         2493 :         return HOST_WIDE_INT_MIN;
    5053              :     }
    5054              :   else
    5055              :     {
    5056      1294669 :       rtx mem, addr;
    5057              : 
    5058              :       /* Otherwise only think about autoinc patterns.  */
    5059      2340197 :       if (mem_autoinc_base (dest) == stack_pointer_rtx)
    5060              :         {
    5061       927232 :           mem = dest;
    5062      1279863 :           gcc_checking_assert (mem_autoinc_base (SET_SRC (set))
    5063              :                                != stack_pointer_rtx);
    5064              :         }
    5065       547156 :       else if (mem_autoinc_base (SET_SRC (set)) == stack_pointer_rtx)
    5066              :         mem = SET_SRC (set);
    5067              :       else
    5068       256485 :         return 0;
    5069              : 
    5070      1038184 :       addr = XEXP (mem, 0);
    5071      1038184 :       switch (GET_CODE (addr))
    5072              :         {
    5073       110952 :         case PRE_INC:
    5074       110952 :         case POST_INC:
    5075       221904 :           return GET_MODE_SIZE (GET_MODE (mem));
    5076       909098 :         case PRE_DEC:
    5077       909098 :         case POST_DEC:
    5078      1818196 :           return -GET_MODE_SIZE (GET_MODE (mem));
    5079        18134 :         case PRE_MODIFY:
    5080        18134 :         case POST_MODIFY:
    5081        18134 :           addr = XEXP (addr, 1);
    5082        18134 :           gcc_assert (GET_CODE (addr) == PLUS);
    5083        18134 :           gcc_assert (XEXP (addr, 0) == stack_pointer_rtx);
    5084        18134 :           return rtx_to_poly_int64 (XEXP (addr, 1));
    5085            0 :         default:
    5086            0 :           gcc_unreachable ();
    5087              :         }
    5088              :     }
    5089              : }
    5090              : 
    5091              : poly_int64
    5092       665653 : fixup_args_size_notes (rtx_insn *prev, rtx_insn *last,
    5093              :                        poly_int64 end_args_size)
    5094              : {
    5095       665653 :   poly_int64 args_size = end_args_size;
    5096       665653 :   bool saw_unknown = false;
    5097       665653 :   rtx_insn *insn;
    5098              : 
    5099      1900262 :   for (insn = last; insn != prev; insn = PREV_INSN (insn))
    5100              :     {
    5101      1234609 :       if (!NONDEBUG_INSN_P (insn))
    5102            0 :         continue;
    5103              : 
    5104              :       /* We might have existing REG_ARGS_SIZE notes, e.g. when pushing
    5105              :          a call argument containing a TLS address that itself requires
    5106              :          a call to __tls_get_addr.  The handling of stack_pointer_delta
    5107              :          in emit_single_push_insn is supposed to ensure that any such
    5108              :          notes are already correct.  */
    5109      1234609 :       rtx note = find_reg_note (insn, REG_ARGS_SIZE, NULL_RTX);
    5110      1234609 :       gcc_assert (!note || known_eq (args_size, get_args_size (note)));
    5111              : 
    5112      1234609 :       poly_int64 this_delta = find_args_size_adjust (insn);
    5113      1234609 :       if (known_eq (this_delta, 0))
    5114              :         {
    5115       604219 :           if (!CALL_P (insn)
    5116            9 :               || ACCUMULATE_OUTGOING_ARGS
    5117       302123 :               || find_reg_note (insn, REG_NORETURN, NULL_RTX) == NULL_RTX)
    5118       302105 :             continue;
    5119              :         }
    5120              : 
    5121       932504 :       gcc_assert (!saw_unknown);
    5122       932504 :       if (known_eq (this_delta, HOST_WIDE_INT_MIN))
    5123         2462 :         saw_unknown = true;
    5124              : 
    5125       932504 :       if (!note)
    5126       932504 :         add_args_size_note (insn, args_size);
    5127       932504 :       if (STACK_GROWS_DOWNWARD)
    5128      1865008 :         this_delta = -poly_uint64 (this_delta);
    5129              : 
    5130       932504 :       if (saw_unknown)
    5131              :         args_size = HOST_WIDE_INT_MIN;
    5132              :       else
    5133      1234609 :         args_size -= this_delta;
    5134              :     }
    5135              : 
    5136       665653 :   return args_size;
    5137              : }
    5138              : 
    5139              : #ifdef PUSH_ROUNDING
    5140              : /* Emit single push insn.  */
    5141              : 
    5142              : static void
    5143      1855407 : emit_single_push_insn_1 (machine_mode mode, rtx x, tree type)
    5144              : {
    5145      1855407 :   rtx dest_addr;
    5146      3710814 :   poly_int64 rounded_size = PUSH_ROUNDING (GET_MODE_SIZE (mode));
    5147      1855407 :   rtx dest;
    5148      1855407 :   enum insn_code icode;
    5149              : 
    5150              :   /* If there is push pattern, use it.  Otherwise try old way of throwing
    5151              :      MEM representing push operation to move expander.  */
    5152      1855407 :   icode = optab_handler (push_optab, mode);
    5153      1855407 :   if (icode != CODE_FOR_nothing)
    5154              :     {
    5155            0 :       class expand_operand ops[1];
    5156              : 
    5157            0 :       create_input_operand (&ops[0], x, mode);
    5158            0 :       if (maybe_expand_insn (icode, 1, ops))
    5159            0 :         return;
    5160              :     }
    5161      3710814 :   if (known_eq (GET_MODE_SIZE (mode), rounded_size))
    5162      3198925 :     dest_addr = gen_rtx_fmt_e (STACK_PUSH_CODE, Pmode, stack_pointer_rtx);
    5163              :   /* If we are to pad downward, adjust the stack pointer first and
    5164              :      then store X into the stack location using an offset.  This is
    5165              :      because emit_move_insn does not know how to pad; it does not have
    5166              :      access to type.  */
    5167       106305 :   else if (targetm.calls.function_arg_padding (mode, type) == PAD_DOWNWARD)
    5168              :     {
    5169            0 :       emit_move_insn (stack_pointer_rtx,
    5170            0 :                       expand_binop (Pmode,
    5171              :                                     STACK_GROWS_DOWNWARD ? sub_optab
    5172              :                                     : add_optab,
    5173              :                                     stack_pointer_rtx,
    5174            0 :                                     gen_int_mode (rounded_size, Pmode),
    5175              :                                     NULL_RTX, 0, OPTAB_LIB_WIDEN));
    5176              : 
    5177            0 :       poly_int64 offset = rounded_size - GET_MODE_SIZE (mode);
    5178            0 :       if (STACK_GROWS_DOWNWARD && STACK_PUSH_CODE == POST_DEC)
    5179              :         /* We have already decremented the stack pointer, so get the
    5180              :            previous value.  */
    5181              :         offset += rounded_size;
    5182              : 
    5183            0 :       if (!STACK_GROWS_DOWNWARD && STACK_PUSH_CODE == POST_INC)
    5184              :         /* We have already incremented the stack pointer, so get the
    5185              :            previous value.  */
    5186              :         offset -= rounded_size;
    5187              : 
    5188            0 :       dest_addr = plus_constant (Pmode, stack_pointer_rtx, offset);
    5189              :     }
    5190              :   else
    5191              :     {
    5192              :       if (STACK_GROWS_DOWNWARD)
    5193              :         /* ??? This seems wrong if STACK_PUSH_CODE == POST_DEC.  */
    5194       106879 :         dest_addr = plus_constant (Pmode, stack_pointer_rtx, -rounded_size);
    5195              :       else
    5196              :         /* ??? This seems wrong if STACK_PUSH_CODE == POST_INC.  */
    5197              :         dest_addr = plus_constant (Pmode, stack_pointer_rtx, rounded_size);
    5198              : 
    5199       106879 :       dest_addr = gen_rtx_PRE_MODIFY (Pmode, stack_pointer_rtx, dest_addr);
    5200              :     }
    5201              : 
    5202      1855407 :   dest = gen_rtx_MEM (mode, dest_addr);
    5203              : 
    5204      1855407 :   if (type != 0)
    5205              :     {
    5206      1855320 :       set_mem_attributes (dest, type, 1);
    5207              : 
    5208      1855320 :       if (cfun->tail_call_marked)
    5209              :         /* Function incoming arguments may overlap with sibling call
    5210              :            outgoing arguments and we cannot allow reordering of reads
    5211              :            from function arguments with stores to outgoing arguments
    5212              :            of sibling calls.  */
    5213       144163 :         set_mem_alias_set (dest, 0);
    5214              :     }
    5215      1855407 :   emit_move_insn (dest, x);
    5216              : }
    5217              : 
    5218              : /* Emit and annotate a single push insn.  */
    5219              : 
    5220              : static void
    5221      1855407 : emit_single_push_insn (machine_mode mode, rtx x, tree type)
    5222              : {
    5223      1855407 :   poly_int64 delta, old_delta = stack_pointer_delta;
    5224      1855407 :   rtx_insn *prev = get_last_insn ();
    5225      1855407 :   rtx_insn *last;
    5226              : 
    5227      1855407 :   emit_single_push_insn_1 (mode, x, type);
    5228              : 
    5229              :   /* Adjust stack_pointer_delta to describe the situation after the push
    5230              :      we just performed.  Note that we must do this after the push rather
    5231              :      than before the push in case calculating X needs pushes and pops of
    5232              :      its own (e.g. if calling __tls_get_addr).  The REG_ARGS_SIZE notes
    5233              :      for such pushes and pops must not include the effect of the future
    5234              :      push of X.  */
    5235      3710814 :   stack_pointer_delta += PUSH_ROUNDING (GET_MODE_SIZE (mode));
    5236              : 
    5237      1855407 :   last = get_last_insn ();
    5238              : 
    5239              :   /* Notice the common case where we emitted exactly one insn.  */
    5240      1855407 :   if (PREV_INSN (last) == prev)
    5241              :     {
    5242      1743952 :       add_args_size_note (last, stack_pointer_delta);
    5243      1743952 :       return;
    5244              :     }
    5245              : 
    5246       111455 :   delta = fixup_args_size_notes (prev, last, stack_pointer_delta);
    5247       111455 :   gcc_assert (known_eq (delta, HOST_WIDE_INT_MIN)
    5248              :               || known_eq (delta, old_delta));
    5249              : }
    5250              : #endif
    5251              : 
    5252              : /* If reading SIZE bytes from X will end up reading from
    5253              :    Y return the number of bytes that overlap.  Return -1
    5254              :    if there is no overlap or -2 if we can't determine
    5255              :    (for example when X and Y have different base registers).  */
    5256              : 
    5257              : static int
    5258            0 : memory_load_overlap (rtx x, rtx y, HOST_WIDE_INT size)
    5259              : {
    5260            0 :   rtx tmp = plus_constant (Pmode, x, size);
    5261            0 :   rtx sub = simplify_gen_binary (MINUS, Pmode, tmp, y);
    5262              : 
    5263            0 :   if (!CONST_INT_P (sub))
    5264              :     return -2;
    5265              : 
    5266            0 :   HOST_WIDE_INT val = INTVAL (sub);
    5267              : 
    5268            0 :   return IN_RANGE (val, 1, size) ? val : -1;
    5269              : }
    5270              : 
    5271              : /* Generate code to push X onto the stack, assuming it has mode MODE and
    5272              :    type TYPE.
    5273              :    MODE is redundant except when X is a CONST_INT (since they don't
    5274              :    carry mode info).
    5275              :    SIZE is an rtx for the size of data to be copied (in bytes),
    5276              :    needed only if X is BLKmode.
    5277              :    Return true if successful.  May return false if asked to push a
    5278              :    partial argument during a sibcall optimization (as specified by
    5279              :    SIBCALL_P) and the incoming and outgoing pointers cannot be shown
    5280              :    to not overlap.
    5281              : 
    5282              :    ALIGN (in bits) is maximum alignment we can assume.
    5283              : 
    5284              :    If PARTIAL and REG are both nonzero, then copy that many of the first
    5285              :    bytes of X into registers starting with REG, and push the rest of X.
    5286              :    The amount of space pushed is decreased by PARTIAL bytes.
    5287              :    REG must be a hard register in this case.
    5288              :    If REG is zero but PARTIAL is not, take any all others actions for an
    5289              :    argument partially in registers, but do not actually load any
    5290              :    registers.
    5291              : 
    5292              :    EXTRA is the amount in bytes of extra space to leave next to this arg.
    5293              :    This is ignored if an argument block has already been allocated.
    5294              : 
    5295              :    On a machine that lacks real push insns, ARGS_ADDR is the address of
    5296              :    the bottom of the argument block for this call.  We use indexing off there
    5297              :    to store the arg.  On machines with push insns, ARGS_ADDR is 0 when a
    5298              :    argument block has not been preallocated.
    5299              : 
    5300              :    ARGS_SO_FAR is the size of args previously pushed for this call.
    5301              : 
    5302              :    REG_PARM_STACK_SPACE is nonzero if functions require stack space
    5303              :    for arguments passed in registers.  If nonzero, it will be the number
    5304              :    of bytes required.  */
    5305              : 
    5306              : bool
    5307      2180618 : emit_push_insn (rtx x, machine_mode mode, tree type, rtx size,
    5308              :                 unsigned int align, int partial, rtx reg, poly_int64 extra,
    5309              :                 rtx args_addr, rtx args_so_far, int reg_parm_stack_space,
    5310              :                 rtx alignment_pad, bool sibcall_p)
    5311              : {
    5312      2180618 :   rtx xinner;
    5313      2180618 :   pad_direction stack_direction
    5314              :     = STACK_GROWS_DOWNWARD ? PAD_DOWNWARD : PAD_UPWARD;
    5315              : 
    5316              :   /* Decide where to pad the argument: PAD_DOWNWARD for below,
    5317              :      PAD_UPWARD for above, or PAD_NONE for don't pad it.
    5318              :      Default is below for small data on big-endian machines; else above.  */
    5319      2180618 :   pad_direction where_pad = targetm.calls.function_arg_padding (mode, type);
    5320              : 
    5321              :   /* Invert direction if stack is post-decrement.
    5322              :      FIXME: why?  */
    5323      2180618 :   if (STACK_PUSH_CODE == POST_DEC)
    5324              :     if (where_pad != PAD_NONE)
    5325              :       where_pad = (where_pad == PAD_DOWNWARD ? PAD_UPWARD : PAD_DOWNWARD);
    5326              : 
    5327      2180618 :   xinner = x;
    5328              : 
    5329      2180618 :   int nregs = partial / UNITS_PER_WORD;
    5330      2180618 :   rtx *tmp_regs = NULL;
    5331      2180618 :   int overlapping = 0;
    5332              : 
    5333      2180618 :   if (mode == BLKmode
    5334              :       || (STRICT_ALIGNMENT && align < GET_MODE_ALIGNMENT (mode)))
    5335              :     {
    5336              :       /* Copy a block into the stack, entirely or partially.  */
    5337              : 
    5338       269856 :       rtx temp;
    5339       269856 :       int used;
    5340       269856 :       int offset;
    5341       269856 :       int skip;
    5342              : 
    5343       269856 :       offset = partial % (PARM_BOUNDARY / BITS_PER_UNIT);
    5344       269856 :       used = partial - offset;
    5345              : 
    5346       269856 :       if (mode != BLKmode)
    5347              :         {
    5348              :           /* A value is to be stored in an insufficiently aligned
    5349              :              stack slot; copy via a suitably aligned slot if
    5350              :              necessary.  */
    5351              :           size = gen_int_mode (GET_MODE_SIZE (mode), Pmode);
    5352              :           if (!MEM_P (xinner))
    5353              :             {
    5354              :               temp = assign_temp (type, 1, 1);
    5355              :               emit_move_insn (temp, xinner);
    5356              :               xinner = temp;
    5357              :             }
    5358              :         }
    5359              : 
    5360       269856 :       gcc_assert (size);
    5361              : 
    5362              :       /* USED is now the # of bytes we need not copy to the stack
    5363              :          because registers will take care of them.  */
    5364              : 
    5365       269856 :       if (partial != 0)
    5366            0 :         xinner = adjust_address (xinner, BLKmode, used);
    5367              : 
    5368              :       /* If the partial register-part of the arg counts in its stack size,
    5369              :          skip the part of stack space corresponding to the registers.
    5370              :          Otherwise, start copying to the beginning of the stack space,
    5371              :          by setting SKIP to 0.  */
    5372       269856 :       skip = (reg_parm_stack_space == 0) ? 0 : used;
    5373              : 
    5374              : #ifdef PUSH_ROUNDING
    5375              :       /* NB: Let the backend known the number of bytes to push and
    5376              :          decide if push insns should be generated.  */
    5377       269856 :       unsigned int push_size;
    5378       269856 :       if (CONST_INT_P (size))
    5379       269856 :         push_size = INTVAL (size);
    5380              :       else
    5381              :         push_size = 0;
    5382              : 
    5383              :       /* Do it with several push insns if that doesn't take lots of insns
    5384              :          and if there is no difficulty with push insns that skip bytes
    5385              :          on the stack for alignment purposes.  */
    5386       269856 :       if (args_addr == 0
    5387       269798 :           && targetm.calls.push_argument (push_size)
    5388         3785 :           && CONST_INT_P (size)
    5389         3785 :           && skip == 0
    5390         3785 :           && MEM_ALIGN (xinner) >= align
    5391         2950 :           && can_move_by_pieces ((unsigned) INTVAL (size) - used, align)
    5392              :           /* Here we avoid the case of a structure whose weak alignment
    5393              :              forces many pushes of a small amount of data,
    5394              :              and such small pushes do rounding that causes trouble.  */
    5395         2950 :           && ((!targetm.slow_unaligned_access (word_mode, align))
    5396            0 :               || align >= BIGGEST_ALIGNMENT
    5397            0 :               || known_eq (PUSH_ROUNDING (align / BITS_PER_UNIT),
    5398              :                            align / BITS_PER_UNIT))
    5399       272806 :           && known_eq (PUSH_ROUNDING (INTVAL (size)), INTVAL (size)))
    5400              :         {
    5401              :           /* Push padding now if padding above and stack grows down,
    5402              :              or if padding below and stack grows up.
    5403              :              But if space already allocated, this has already been done.  */
    5404           54 :           if (maybe_ne (extra, 0)
    5405              :               && args_addr == 0
    5406            0 :               && where_pad != PAD_NONE
    5407           54 :               && where_pad != stack_direction)
    5408            0 :             anti_adjust_stack (gen_int_mode (extra, Pmode));
    5409              : 
    5410           54 :           move_by_pieces (NULL, xinner, INTVAL (size) - used, align,
    5411              :                           RETURN_BEGIN);
    5412              :         }
    5413              :       else
    5414              : #endif /* PUSH_ROUNDING  */
    5415              :         {
    5416       269802 :           rtx target;
    5417              : 
    5418              :           /* Otherwise make space on the stack and copy the data
    5419              :              to the address of that space.  */
    5420              : 
    5421              :           /* Deduct words put into registers from the size we must copy.  */
    5422       269802 :           if (partial != 0)
    5423              :             {
    5424            0 :               if (CONST_INT_P (size))
    5425            0 :                 size = GEN_INT (INTVAL (size) - used);
    5426              :               else
    5427            0 :                 size = expand_binop (GET_MODE (size), sub_optab, size,
    5428            0 :                                      gen_int_mode (used, GET_MODE (size)),
    5429              :                                      NULL_RTX, 0, OPTAB_LIB_WIDEN);
    5430              :             }
    5431              : 
    5432              :           /* Get the address of the stack space.
    5433              :              In this case, we do not deal with EXTRA separately.
    5434              :              A single stack adjust will do.  */
    5435       269802 :           poly_int64 const_args_so_far;
    5436       269802 :           if (! args_addr)
    5437              :             {
    5438       269744 :               temp = push_block (size, extra, where_pad == PAD_DOWNWARD);
    5439       269744 :               extra = 0;
    5440              :             }
    5441           58 :           else if (poly_int_rtx_p (args_so_far, &const_args_so_far))
    5442           76 :             temp = memory_address (BLKmode,
    5443              :                                    plus_constant (Pmode, args_addr,
    5444              :                                                   skip + const_args_so_far));
    5445              :           else
    5446            0 :             temp = memory_address (BLKmode,
    5447              :                                    plus_constant (Pmode,
    5448              :                                                   gen_rtx_PLUS (Pmode,
    5449              :                                                                 args_addr,
    5450              :                                                                 args_so_far),
    5451              :                                                   skip));
    5452              : 
    5453       269802 :           if (!ACCUMULATE_OUTGOING_ARGS)
    5454              :             {
    5455              :               /* If the source is referenced relative to the stack pointer,
    5456              :                  copy it to another register to stabilize it.  We do not need
    5457              :                  to do this if we know that we won't be changing sp.  */
    5458              : 
    5459       269802 :               if (reg_mentioned_p (virtual_stack_dynamic_rtx, temp)
    5460       269802 :                   || reg_mentioned_p (virtual_outgoing_args_rtx, temp))
    5461       269744 :                 temp = copy_to_reg (temp);
    5462              :             }
    5463              : 
    5464       269802 :           target = gen_rtx_MEM (BLKmode, temp);
    5465              : 
    5466              :           /* We do *not* set_mem_attributes here, because incoming arguments
    5467              :              may overlap with sibling call outgoing arguments and we cannot
    5468              :              allow reordering of reads from function arguments with stores
    5469              :              to outgoing arguments of sibling calls.  We do, however, want
    5470              :              to record the alignment of the stack slot.  */
    5471              :           /* ALIGN may well be better aligned than TYPE, e.g. due to
    5472              :              PARM_BOUNDARY.  Assume the caller isn't lying.  */
    5473       269802 :           set_mem_align (target, align);
    5474              : 
    5475              :           /* If part should go in registers and pushing to that part would
    5476              :              overwrite some of the values that need to go into regs, load the
    5477              :              overlapping values into temporary pseudos to be moved into the hard
    5478              :              regs at the end after the stack pushing has completed.
    5479              :              We cannot load them directly into the hard regs here because
    5480              :              they can be clobbered by the block move expansions.
    5481              :              See PR 65358.  */
    5482              : 
    5483       269802 :           if (partial > 0 && reg != 0 && mode == BLKmode
    5484            0 :               && GET_CODE (reg) != PARALLEL)
    5485              :             {
    5486            0 :               overlapping = memory_load_overlap (XEXP (x, 0), temp, partial);
    5487            0 :               if (overlapping > 0)
    5488              :                 {
    5489            0 :                   gcc_assert (overlapping % UNITS_PER_WORD == 0);
    5490            0 :                   overlapping /= UNITS_PER_WORD;
    5491              : 
    5492            0 :                   tmp_regs = XALLOCAVEC (rtx, overlapping);
    5493              : 
    5494            0 :                   for (int i = 0; i < overlapping; i++)
    5495            0 :                     tmp_regs[i] = gen_reg_rtx (word_mode);
    5496              : 
    5497            0 :                   for (int i = 0; i < overlapping; i++)
    5498            0 :                     emit_move_insn (tmp_regs[i],
    5499            0 :                                     operand_subword_force (target, i, mode));
    5500              :                 }
    5501            0 :               else if (overlapping == -1)
    5502              :                 overlapping = 0;
    5503              :               /* Could not determine whether there is overlap.
    5504              :                  Fail the sibcall.  */
    5505              :               else
    5506              :                 {
    5507            0 :                   overlapping = 0;
    5508            0 :                   if (sibcall_p)
    5509      2180618 :                     return false;
    5510              :                 }
    5511              :             }
    5512              : 
    5513              :           /* If source is a constant VAR_DECL with a simple constructor,
    5514              :              store the constructor to the stack instead of moving it.  */
    5515       269802 :           const_tree decl;
    5516       269802 :           HOST_WIDE_INT sz;
    5517       269802 :           if (partial == 0
    5518       269802 :               && MEM_P (xinner)
    5519       269802 :               && SYMBOL_REF_P (XEXP (xinner, 0))
    5520        83253 :               && (decl = SYMBOL_REF_DECL (XEXP (xinner, 0))) != NULL_TREE
    5521        83253 :               && VAR_P (decl)
    5522        83253 :               && TREE_READONLY (decl)
    5523         5906 :               && !TREE_SIDE_EFFECTS (decl)
    5524         5906 :               && immediate_const_ctor_p (DECL_INITIAL (decl), 2)
    5525            9 :               && (sz = int_expr_size (DECL_INITIAL (decl))) > 0
    5526            9 :               && CONST_INT_P (size)
    5527       269811 :               && INTVAL (size) == sz)
    5528            3 :             store_constructor (DECL_INITIAL (decl), target, 0, sz, false);
    5529              :           else
    5530       269799 :             emit_block_move (target, xinner, size, BLOCK_OP_CALL_PARM);
    5531              :         }
    5532              :     }
    5533      1910762 :   else if (partial > 0)
    5534              :     {
    5535              :       /* Scalar partly in registers.  This case is only supported
    5536              :          for fixed-wdth modes.  */
    5537            0 :       int num_words = GET_MODE_SIZE (mode).to_constant ();
    5538            0 :       num_words /= UNITS_PER_WORD;
    5539            0 :       int i;
    5540            0 :       int not_stack;
    5541              :       /* # bytes of start of argument
    5542              :          that we must make space for but need not store.  */
    5543            0 :       int offset = partial % (PARM_BOUNDARY / BITS_PER_UNIT);
    5544            0 :       int args_offset = INTVAL (args_so_far);
    5545            0 :       int skip;
    5546              : 
    5547              :       /* Push padding now if padding above and stack grows down,
    5548              :          or if padding below and stack grows up.
    5549              :          But if space already allocated, this has already been done.  */
    5550            0 :       if (maybe_ne (extra, 0)
    5551            0 :           && args_addr == 0
    5552            0 :           && where_pad != PAD_NONE
    5553            0 :           && where_pad != stack_direction)
    5554            0 :         anti_adjust_stack (gen_int_mode (extra, Pmode));
    5555              : 
    5556              :       /* If we make space by pushing it, we might as well push
    5557              :          the real data.  Otherwise, we can leave OFFSET nonzero
    5558              :          and leave the space uninitialized.  */
    5559            0 :       if (args_addr == 0)
    5560            0 :         offset = 0;
    5561              : 
    5562              :       /* Now NOT_STACK gets the number of words that we don't need to
    5563              :          allocate on the stack.  Convert OFFSET to words too.  */
    5564            0 :       not_stack = (partial - offset) / UNITS_PER_WORD;
    5565            0 :       offset /= UNITS_PER_WORD;
    5566              : 
    5567              :       /* If the partial register-part of the arg counts in its stack size,
    5568              :          skip the part of stack space corresponding to the registers.
    5569              :          Otherwise, start copying to the beginning of the stack space,
    5570              :          by setting SKIP to 0.  */
    5571            0 :       skip = (reg_parm_stack_space == 0) ? 0 : not_stack;
    5572              : 
    5573            0 :       if (CONSTANT_P (x) && !targetm.legitimate_constant_p (mode, x))
    5574            0 :         x = validize_mem (force_const_mem (mode, x));
    5575              : 
    5576              :       /* If X is a hard register in a non-integer mode, copy it into a pseudo;
    5577              :          SUBREGs of such registers are not allowed.  */
    5578            0 :       if ((REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER
    5579            0 :            && GET_MODE_CLASS (GET_MODE (x)) != MODE_INT))
    5580            0 :         x = copy_to_reg (x);
    5581              : 
    5582              :       /* Loop over all the words allocated on the stack for this arg.  */
    5583              :       /* We can do it by words, because any scalar bigger than a word
    5584              :          has a size a multiple of a word.  */
    5585            0 :       tree word_mode_type = lang_hooks.types.type_for_mode (word_mode, 1);
    5586            0 :       for (i = num_words - 1; i >= not_stack; i--)
    5587            0 :         if (i >= not_stack + offset)
    5588            0 :           if (!emit_push_insn (operand_subword_force (x, i, mode),
    5589              :                           word_mode, word_mode_type, NULL_RTX, align, 0,
    5590              :                           NULL_RTX, 0, args_addr,
    5591            0 :                           GEN_INT (args_offset + ((i - not_stack + skip)
    5592              :                                                   * UNITS_PER_WORD)),
    5593              :                           reg_parm_stack_space, alignment_pad, sibcall_p))
    5594      2180618 :             return false;
    5595              :     }
    5596              :   else
    5597              :     {
    5598      1910762 :       rtx addr;
    5599      1910762 :       rtx dest;
    5600              : 
    5601              :       /* Push padding now if padding above and stack grows down,
    5602              :          or if padding below and stack grows up.
    5603              :          But if space already allocated, this has already been done.  */
    5604      1910762 :       if (maybe_ne (extra, 0)
    5605            0 :           && args_addr == 0
    5606            0 :           && where_pad != PAD_NONE
    5607      1910762 :           && where_pad != stack_direction)
    5608            0 :         anti_adjust_stack (gen_int_mode (extra, Pmode));
    5609              : 
    5610              : #ifdef PUSH_ROUNDING
    5611      1910762 :       if (args_addr == 0 && targetm.calls.push_argument (0))
    5612      1855320 :         emit_single_push_insn (mode, x, type);
    5613              :       else
    5614              : #endif
    5615              :         {
    5616        63720 :           addr = simplify_gen_binary (PLUS, Pmode, args_addr, args_so_far);
    5617        55442 :           dest = gen_rtx_MEM (mode, memory_address (mode, addr));
    5618              : 
    5619              :           /* We do *not* set_mem_attributes here, because incoming arguments
    5620              :              may overlap with sibling call outgoing arguments and we cannot
    5621              :              allow reordering of reads from function arguments with stores
    5622              :              to outgoing arguments of sibling calls.  We do, however, want
    5623              :              to record the alignment of the stack slot.  */
    5624              :           /* ALIGN may well be better aligned than TYPE, e.g. due to
    5625              :              PARM_BOUNDARY.  Assume the caller isn't lying.  */
    5626        55442 :           set_mem_align (dest, align);
    5627              : 
    5628        55442 :           emit_move_insn (dest, x);
    5629              :         }
    5630              :     }
    5631              : 
    5632              :   /* Move the partial arguments into the registers and any overlapping
    5633              :      values that we moved into the pseudos in tmp_regs.  */
    5634      2180618 :   if (partial > 0 && reg != 0)
    5635              :     {
    5636              :       /* Handle calls that pass values in multiple non-contiguous locations.
    5637              :          The Irix 6 ABI has examples of this.  */
    5638            0 :       if (GET_CODE (reg) == PARALLEL)
    5639            0 :         emit_group_load (reg, x, type, -1);
    5640              :       else
    5641              :         {
    5642            0 :           gcc_assert (partial % UNITS_PER_WORD == 0);
    5643            0 :           move_block_to_reg (REGNO (reg), x, nregs - overlapping, mode);
    5644              : 
    5645            0 :           for (int i = 0; i < overlapping; i++)
    5646            0 :             emit_move_insn (gen_rtx_REG (word_mode, REGNO (reg)
    5647            0 :                                                     + nregs - overlapping + i),
    5648            0 :                             tmp_regs[i]);
    5649              : 
    5650              :         }
    5651              :     }
    5652              : 
    5653      2180618 :   if (maybe_ne (extra, 0) && args_addr == 0 && where_pad == stack_direction)
    5654            0 :     anti_adjust_stack (gen_int_mode (extra, Pmode));
    5655              : 
    5656      2180618 :   if (alignment_pad && args_addr == 0)
    5657      2125118 :     anti_adjust_stack (alignment_pad);
    5658              : 
    5659              :   return true;
    5660              : }
    5661              : 
    5662              : /* Return X if X can be used as a subtarget in a sequence of arithmetic
    5663              :    operations.  */
    5664              : 
    5665              : static rtx
    5666    208124379 : get_subtarget (rtx x)
    5667              : {
    5668    208124379 :   return (optimize
    5669     53779305 :           || x == 0
    5670              :            /* Only registers can be subtargets.  */
    5671     18039336 :            || !REG_P (x)
    5672              :            /* Don't use hard regs to avoid extending their life.  */
    5673     12258590 :            || REGNO (x) < FIRST_PSEUDO_REGISTER
    5674    208124379 :           ? 0 : x);
    5675              : }
    5676              : 
    5677              : /* A subroutine of expand_assignment.  Optimize FIELD op= VAL, where
    5678              :    FIELD is a bitfield.  Returns true if the optimization was successful,
    5679              :    and there's nothing else to do.  */
    5680              : 
    5681              : static bool
    5682      4938428 : optimize_bitfield_assignment_op (poly_uint64 pbitsize,
    5683              :                                  poly_uint64 pbitpos,
    5684              :                                  poly_uint64 pbitregion_start,
    5685              :                                  poly_uint64 pbitregion_end,
    5686              :                                  machine_mode mode1, rtx str_rtx,
    5687              :                                  tree to, tree src, bool reverse)
    5688              : {
    5689              :   /* str_mode is not guaranteed to be a scalar type.  */
    5690      4938428 :   machine_mode str_mode = GET_MODE (str_rtx);
    5691      4938428 :   unsigned int str_bitsize;
    5692      4938428 :   tree op0, op1;
    5693      4938428 :   rtx value, result;
    5694      4938428 :   optab binop;
    5695      4938428 :   enum tree_code code;
    5696              : 
    5697      4938428 :   unsigned HOST_WIDE_INT bitsize, bitpos, bitregion_start, bitregion_end;
    5698      4938428 :   if (mode1 != VOIDmode
    5699        67360 :       || !pbitsize.is_constant (&bitsize)
    5700        67360 :       || !pbitpos.is_constant (&bitpos)
    5701        67360 :       || !pbitregion_start.is_constant (&bitregion_start)
    5702        67360 :       || !pbitregion_end.is_constant (&bitregion_end)
    5703        68029 :       || bitsize >= BITS_PER_WORD
    5704        67088 :       || !GET_MODE_BITSIZE (str_mode).is_constant (&str_bitsize)
    5705        67757 :       || str_bitsize > BITS_PER_WORD
    5706        61683 :       || TREE_SIDE_EFFECTS (to)
    5707      4999982 :       || TREE_THIS_VOLATILE (to))
    5708              :     return false;
    5709              : 
    5710        61554 :   STRIP_NOPS (src);
    5711        61554 :   if (TREE_CODE (src) != SSA_NAME)
    5712              :     return false;
    5713        20228 :   if (TREE_CODE (TREE_TYPE (src)) != INTEGER_TYPE)
    5714              :     return false;
    5715              : 
    5716        18554 :   auto srcstmt = safe_dyn_cast<gassign *> (get_gimple_for_ssa_name (src));
    5717         5002 :   if (!srcstmt
    5718         5002 :       || TREE_CODE_CLASS (gimple_assign_rhs_code (srcstmt)) != tcc_binary)
    5719              :     return false;
    5720              : 
    5721          848 :   code = gimple_assign_rhs_code (srcstmt);
    5722              : 
    5723          848 :   op0 = gimple_assign_rhs1 (srcstmt);
    5724              : 
    5725              :   /* If OP0 is an SSA_NAME, then we want to walk the use-def chain
    5726              :      to find its initialization.  Hopefully the initialization will
    5727              :      be from a bitfield load.  */
    5728          848 :   if (TREE_CODE (op0) == SSA_NAME)
    5729              :     {
    5730          848 :       auto *op0stmt = safe_dyn_cast<gassign *> (get_gimple_for_ssa_name (op0));
    5731              : 
    5732              :       /* We want to eventually have OP0 be the same as TO, which
    5733              :          should be a bitfield.  */
    5734          778 :       if (!op0stmt
    5735          778 :           || gimple_assign_rhs_code (op0stmt) != TREE_CODE (to))
    5736              :         return false;
    5737          548 :       op0 = gimple_assign_rhs1 (op0stmt);
    5738              :     }
    5739              : 
    5740          548 :   op1 = gimple_assign_rhs2 (srcstmt);
    5741              : 
    5742          548 :   if (!operand_equal_p (to, op0, 0))
    5743              :     return false;
    5744              : 
    5745          463 :   if (MEM_P (str_rtx))
    5746              :     {
    5747          422 :       unsigned HOST_WIDE_INT offset1;
    5748              : 
    5749          422 :       if (str_bitsize == 0 || str_bitsize > BITS_PER_WORD)
    5750           82 :         str_bitsize = BITS_PER_WORD;
    5751              : 
    5752          422 :       scalar_int_mode best_mode;
    5753          422 :       if (!get_best_mode (bitsize, bitpos, bitregion_start, bitregion_end,
    5754          422 :                           MEM_ALIGN (str_rtx), str_bitsize, false, &best_mode))
    5755            0 :         return false;
    5756          422 :       str_mode = best_mode;
    5757          422 :       str_bitsize = GET_MODE_BITSIZE (best_mode);
    5758              : 
    5759          422 :       offset1 = bitpos;
    5760          422 :       bitpos %= str_bitsize;
    5761          422 :       offset1 = (offset1 - bitpos) / BITS_PER_UNIT;
    5762          422 :       str_rtx = adjust_address (str_rtx, str_mode, offset1);
    5763              :     }
    5764           41 :   else if (!REG_P (str_rtx) && GET_CODE (str_rtx) != SUBREG)
    5765              :     return false;
    5766              : 
    5767              :   /* If the bit field covers the whole REG/MEM, store_field
    5768              :      will likely generate better code.  */
    5769          463 :   if (bitsize >= str_bitsize)
    5770              :     return false;
    5771              : 
    5772              :   /* We can't handle fields split across multiple entities.  */
    5773          463 :   if (bitpos + bitsize > str_bitsize)
    5774              :     return false;
    5775              : 
    5776          463 :   if (reverse ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN)
    5777            0 :     bitpos = str_bitsize - bitpos - bitsize;
    5778              : 
    5779          463 :   switch (code)
    5780              :     {
    5781          140 :     case PLUS_EXPR:
    5782          140 :     case MINUS_EXPR:
    5783              :       /* For now, just optimize the case of the topmost bitfield
    5784              :          where we don't need to do any masking and also
    5785              :          1 bit bitfields where xor can be used.
    5786              :          We might win by one instruction for the other bitfields
    5787              :          too if insv/extv instructions aren't used, so that
    5788              :          can be added later.  */
    5789          140 :       if ((reverse || bitpos + bitsize != str_bitsize)
    5790           96 :           && (bitsize != 1 || TREE_CODE (op1) != INTEGER_CST))
    5791              :         break;
    5792              : 
    5793           69 :       value = expand_expr (op1, NULL_RTX, str_mode, EXPAND_NORMAL);
    5794           69 :       value = convert_modes (str_mode,
    5795           69 :                              TYPE_MODE (TREE_TYPE (op1)), value,
    5796           69 :                              TYPE_UNSIGNED (TREE_TYPE (op1)));
    5797              : 
    5798              :       /* We may be accessing data outside the field, which means
    5799              :          we can alias adjacent data.  */
    5800           69 :       if (MEM_P (str_rtx))
    5801              :         {
    5802           69 :           str_rtx = shallow_copy_rtx (str_rtx);
    5803           69 :           set_mem_alias_set (str_rtx, 0);
    5804           69 :           set_mem_expr (str_rtx, 0);
    5805              :         }
    5806              : 
    5807           69 :       if (bitsize == 1 && (reverse || bitpos + bitsize != str_bitsize))
    5808              :         {
    5809           25 :           value = expand_and (str_mode, value, const1_rtx, NULL);
    5810           25 :           binop = xor_optab;
    5811              :         }
    5812              :       else
    5813           44 :         binop = code == PLUS_EXPR ? add_optab : sub_optab;
    5814              : 
    5815           69 :       value = expand_shift (LSHIFT_EXPR, str_mode, value, bitpos, NULL_RTX, 1);
    5816           69 :       if (reverse)
    5817            0 :         value = flip_storage_order (str_mode, value);
    5818           69 :       result = expand_binop (str_mode, binop, str_rtx,
    5819              :                              value, str_rtx, 1, OPTAB_WIDEN);
    5820           69 :       if (result != str_rtx)
    5821            0 :         emit_move_insn (str_rtx, result);
    5822              :       return true;
    5823              : 
    5824          255 :     case BIT_IOR_EXPR:
    5825          255 :     case BIT_XOR_EXPR:
    5826          255 :       if (TREE_CODE (op1) != INTEGER_CST)
    5827              :         break;
    5828           97 :       value = expand_expr (op1, NULL_RTX, str_mode, EXPAND_NORMAL);
    5829           97 :       value = convert_modes (str_mode,
    5830           97 :                              TYPE_MODE (TREE_TYPE (op1)), value,
    5831           97 :                              TYPE_UNSIGNED (TREE_TYPE (op1)));
    5832              : 
    5833              :       /* We may be accessing data outside the field, which means
    5834              :          we can alias adjacent data.  */
    5835           97 :       if (MEM_P (str_rtx))
    5836              :         {
    5837           61 :           str_rtx = shallow_copy_rtx (str_rtx);
    5838           61 :           set_mem_alias_set (str_rtx, 0);
    5839           61 :           set_mem_expr (str_rtx, 0);
    5840              :         }
    5841              : 
    5842           97 :       binop = code == BIT_IOR_EXPR ? ior_optab : xor_optab;
    5843           97 :       if (bitpos + bitsize != str_bitsize)
    5844              :         {
    5845           55 :           rtx mask = gen_int_mode ((HOST_WIDE_INT_1U << bitsize) - 1,
    5846              :                                    str_mode);
    5847           55 :           value = expand_and (str_mode, value, mask, NULL_RTX);
    5848              :         }
    5849           97 :       value = expand_shift (LSHIFT_EXPR, str_mode, value, bitpos, NULL_RTX, 1);
    5850           97 :       if (reverse)
    5851            0 :         value = flip_storage_order (str_mode, value);
    5852           97 :       result = expand_binop (str_mode, binop, str_rtx,
    5853              :                              value, str_rtx, 1, OPTAB_WIDEN);
    5854           97 :       if (result != str_rtx)
    5855            0 :         emit_move_insn (str_rtx, result);
    5856              :       return true;
    5857              : 
    5858              :     default:
    5859              :       break;
    5860              :     }
    5861              : 
    5862              :   return false;
    5863              : }
    5864              : 
    5865              : /* In the C++ memory model, consecutive bit fields in a structure are
    5866              :    considered one memory location.
    5867              : 
    5868              :    Given a COMPONENT_REF EXP at position (BITPOS, OFFSET), this function
    5869              :    returns the bit range of consecutive bits in which this COMPONENT_REF
    5870              :    belongs.  The values are returned in *BITSTART and *BITEND.  *BITPOS
    5871              :    and *OFFSET may be adjusted in the process.
    5872              : 
    5873              :    If the access does not need to be restricted, 0 is returned in both
    5874              :    *BITSTART and *BITEND.  */
    5875              : 
    5876              : void
    5877       932351 : get_bit_range (poly_uint64 *bitstart, poly_uint64 *bitend, tree exp,
    5878              :                poly_int64 *bitpos, tree *offset)
    5879              : {
    5880       932351 :   poly_int64 bitoffset;
    5881       932351 :   tree field, repr;
    5882              : 
    5883       932351 :   gcc_assert (TREE_CODE (exp) == COMPONENT_REF);
    5884              : 
    5885       932351 :   field = TREE_OPERAND (exp, 1);
    5886       932351 :   repr = DECL_BIT_FIELD_REPRESENTATIVE (field);
    5887              :   /* If we do not have a DECL_BIT_FIELD_REPRESENTATIVE there is no
    5888              :      need to limit the range we can access.  */
    5889       932351 :   if (!repr)
    5890              :     {
    5891           65 :       *bitstart = *bitend = 0;
    5892           65 :       return;
    5893              :     }
    5894              : 
    5895              :   /* If we have a DECL_BIT_FIELD_REPRESENTATIVE but the enclosing record is
    5896              :      part of a larger bit field, then the representative does not serve any
    5897              :      useful purpose.  This can occur in Ada.  */
    5898       932286 :   if (handled_component_p (TREE_OPERAND (exp, 0)))
    5899              :     {
    5900       510275 :       machine_mode rmode;
    5901       510275 :       poly_int64 rbitsize, rbitpos;
    5902       510275 :       tree roffset;
    5903       510275 :       int unsignedp, reversep, volatilep = 0;
    5904       510275 :       get_inner_reference (TREE_OPERAND (exp, 0), &rbitsize, &rbitpos,
    5905              :                            &roffset, &rmode, &unsignedp, &reversep,
    5906              :                            &volatilep);
    5907      1020550 :       if (!multiple_p (rbitpos, BITS_PER_UNIT))
    5908              :         {
    5909            0 :           *bitstart = *bitend = 0;
    5910            0 :           return;
    5911              :         }
    5912              :     }
    5913              : 
    5914              :   /* Compute the adjustment to bitpos from the offset of the field
    5915              :      relative to the representative.  DECL_FIELD_OFFSET of field and
    5916              :      repr are the same by construction if they are not constants,
    5917              :      see finish_bitfield_layout.  */
    5918       932286 :   poly_uint64 field_offset, repr_offset;
    5919       932286 :   if (poly_int_tree_p (DECL_FIELD_OFFSET (field), &field_offset)
    5920      1864567 :       && poly_int_tree_p (DECL_FIELD_OFFSET (repr), &repr_offset))
    5921       932281 :     bitoffset = (field_offset - repr_offset) * BITS_PER_UNIT;
    5922              :   else
    5923              :     bitoffset = 0;
    5924       932286 :   bitoffset += (tree_to_uhwi (DECL_FIELD_BIT_OFFSET (field))
    5925       932286 :                 - tree_to_uhwi (DECL_FIELD_BIT_OFFSET (repr)));
    5926              : 
    5927              :   /* If the adjustment is larger than bitpos, we would have a negative bit
    5928              :      position for the lower bound and this may wreak havoc later.  Adjust
    5929              :      offset and bitpos to make the lower bound non-negative in that case.  */
    5930       932286 :   if (maybe_gt (bitoffset, *bitpos))
    5931              :     {
    5932            9 :       poly_int64 adjust_bits = upper_bound (bitoffset, *bitpos) - *bitpos;
    5933            9 :       poly_int64 adjust_bytes = exact_div (adjust_bits, BITS_PER_UNIT);
    5934              : 
    5935            9 :       *bitpos += adjust_bits;
    5936            9 :       if (*offset == NULL_TREE)
    5937            5 :         *offset = size_int (-adjust_bytes);
    5938              :       else
    5939            4 :         *offset = size_binop (MINUS_EXPR, *offset, size_int (adjust_bytes));
    5940            9 :       *bitstart = 0;
    5941              :     }
    5942              :   else
    5943       932277 :     *bitstart = *bitpos - bitoffset;
    5944              : 
    5945       932286 :   *bitend = *bitstart + tree_to_poly_uint64 (DECL_SIZE (repr)) - 1;
    5946              : }
    5947              : 
    5948              : /* Returns true if BASE is a DECL that does not reside in memory and
    5949              :    has non-BLKmode.  DECL_RTL must not be a MEM; if
    5950              :    DECL_RTL was not set yet, return false.  */
    5951              : 
    5952              : bool
    5953      5592994 : non_mem_decl_p (tree base)
    5954              : {
    5955      5592994 :   if (!DECL_P (base)
    5956      5592582 :       || TREE_ADDRESSABLE (base)
    5957      8084852 :       || DECL_MODE (base) == BLKmode)
    5958              :     return false;
    5959              : 
    5960      1614885 :   if (!DECL_RTL_SET_P (base))
    5961              :     return false;
    5962              : 
    5963      1495543 :   return (!MEM_P (DECL_RTL (base)));
    5964              : }
    5965              : 
    5966              : /* Returns true if REF refers to an object that does not
    5967              :    reside in memory and has non-BLKmode.  */
    5968              : 
    5969              : bool
    5970     12266144 : mem_ref_refers_to_non_mem_p (tree ref)
    5971              : {
    5972     12266144 :   tree base;
    5973              : 
    5974     12266144 :   if (TREE_CODE (ref) == MEM_REF
    5975     12266144 :       || TREE_CODE (ref) == TARGET_MEM_REF)
    5976              :     {
    5977     10721354 :       tree addr = TREE_OPERAND (ref, 0);
    5978              : 
    5979     10721354 :       if (TREE_CODE (addr) != ADDR_EXPR)
    5980              :         return false;
    5981              : 
    5982      4022348 :       base = TREE_OPERAND (addr, 0);
    5983              :     }
    5984              :   else
    5985              :     base = ref;
    5986              : 
    5987      5567138 :   return non_mem_decl_p (base);
    5988              : }
    5989              : 
    5990              : /* Helper function of expand_assignment.  Check if storing field of
    5991              :    size BITSIZE at position BITPOS overlaps with the most significant
    5992              :    bit of TO_RTX, known to be SUBREG_PROMOTED_VAR_P.
    5993              :    Updating this field requires an explicit extension.  */
    5994              : static bool
    5995            0 : store_field_updates_msb_p (poly_int64 bitpos, poly_int64 bitsize, rtx to_rtx)
    5996              : {
    5997            0 :   return (BYTES_BIG_ENDIAN
    5998              :           ? maybe_le (bitpos, 0)
    5999            0 :           : maybe_ge (bitpos + bitsize, GET_MODE_BITSIZE (GET_MODE (to_rtx))));
    6000              : }
    6001              : 
    6002              : /* Expand an assignment that stores the value of FROM into TO.  If NONTEMPORAL
    6003              :    is true, try generating a nontemporal store.  */
    6004              : 
    6005              : void
    6006     19009932 : expand_assignment (tree to, tree from, bool nontemporal)
    6007              : {
    6008     19009932 :   rtx to_rtx = 0;
    6009     19009932 :   rtx result;
    6010     19009932 :   machine_mode mode;
    6011     19009932 :   unsigned int align;
    6012     19009932 :   enum insn_code icode;
    6013              : 
    6014              :   /* Don't crash if the lhs of the assignment was erroneous.  */
    6015     19009932 :   if (TREE_CODE (to) == ERROR_MARK)
    6016              :     {
    6017            0 :       expand_normal (from);
    6018            0 :       return;
    6019              :     }
    6020              : 
    6021              :   /* Optimize away no-op moves without side-effects.  */
    6022     19009932 :   if (operand_equal_p (to, from, 0))
    6023              :     return;
    6024              : 
    6025              :   /* Handle misaligned stores.  */
    6026     19009778 :   mode = TYPE_MODE (TREE_TYPE (to));
    6027     19009778 :   if ((TREE_CODE (to) == MEM_REF
    6028     19009778 :        || TREE_CODE (to) == TARGET_MEM_REF
    6029     16748906 :        || DECL_P (to))
    6030      4137529 :       && mode != BLKmode
    6031      3665212 :       && !mem_ref_refers_to_non_mem_p (to)
    6032      6570076 :       && ((align = get_object_alignment (to))
    6033      3285038 :           < GET_MODE_ALIGNMENT (mode))
    6034     19445373 :       && (((icode = optab_handler (movmisalign_optab, mode))
    6035              :            != CODE_FOR_nothing)
    6036        97796 :           || targetm.slow_unaligned_access (mode, align)))
    6037              :     {
    6038       337799 :       rtx reg, mem;
    6039              : 
    6040       337799 :       reg = expand_expr (from, NULL_RTX, VOIDmode, EXPAND_NORMAL);
    6041              :       /* Handle PARALLEL.  */
    6042       337799 :       reg = maybe_emit_group_store (reg, TREE_TYPE (from));
    6043       337799 :       reg = force_not_mem (reg);
    6044       337799 :       mem = expand_expr (to, NULL_RTX, VOIDmode, EXPAND_WRITE);
    6045       337799 :       if (TREE_CODE (to) == MEM_REF && REF_REVERSE_STORAGE_ORDER (to))
    6046            0 :         reg = flip_storage_order (mode, reg);
    6047              : 
    6048       337799 :       if (icode != CODE_FOR_nothing)
    6049              :         {
    6050       337799 :           class expand_operand ops[2];
    6051              : 
    6052       337799 :           create_fixed_operand (&ops[0], mem);
    6053       337799 :           create_input_operand (&ops[1], reg, mode);
    6054              :           /* The movmisalign<mode> pattern cannot fail, else the assignment
    6055              :              would silently be omitted.  */
    6056       337799 :           expand_insn (icode, 2, ops);
    6057              :         }
    6058              :       else
    6059            0 :         store_bit_field (mem, GET_MODE_BITSIZE (mode), 0, 0, 0, mode, reg,
    6060              :                          false, false);
    6061              :       return;
    6062              :     }
    6063              : 
    6064              :   /* Assignment of a structure component needs special treatment
    6065              :      if the structure component's rtx is not simply a MEM.
    6066              :      Assignment of an array element at a constant index, and assignment of
    6067              :      an array element in an unaligned packed structure field, has the same
    6068              :      problem.  Same for (partially) storing into a non-memory object.  */
    6069     18671979 :   if (handled_component_p (to)
    6070     13970146 :       || (TREE_CODE (to) == MEM_REF
    6071      1683208 :           && (REF_REVERSE_STORAGE_ORDER (to)
    6072      1683114 :               || mem_ref_refers_to_non_mem_p (to)))
    6073     13857520 :       || TREE_CODE (TREE_TYPE (to)) == ARRAY_TYPE)
    6074              :     {
    6075      4938535 :       machine_mode mode1;
    6076      4938535 :       poly_int64 bitsize, bitpos;
    6077      4938535 :       poly_uint64 bitregion_start = 0;
    6078      4938535 :       poly_uint64 bitregion_end = 0;
    6079      4938535 :       tree offset;
    6080      4938535 :       int unsignedp, reversep, volatilep = 0;
    6081      4938535 :       tree tem;
    6082              : 
    6083      4938535 :       push_temp_slots ();
    6084      4938535 :       tem = get_inner_reference (to, &bitsize, &bitpos, &offset, &mode1,
    6085              :                                  &unsignedp, &reversep, &volatilep);
    6086              : 
    6087              :       /* Make sure bitpos is not negative, it can wreak havoc later.  */
    6088      4938535 :       if (maybe_lt (bitpos, 0))
    6089              :         {
    6090          207 :           gcc_assert (offset == NULL_TREE);
    6091          207 :           offset = size_int (bits_to_bytes_round_down (bitpos));
    6092          207 :           bitpos = num_trailing_bits (bitpos);
    6093              :         }
    6094              : 
    6095      4938535 :       if (TREE_CODE (to) == COMPONENT_REF
    6096      4938535 :           && DECL_BIT_FIELD_TYPE (TREE_OPERAND (to, 1)))
    6097        85518 :         get_bit_range (&bitregion_start, &bitregion_end, to, &bitpos, &offset);
    6098              :       /* The C++ memory model naturally applies to byte-aligned fields.
    6099              :          However, if we do not have a DECL_BIT_FIELD_TYPE but BITPOS or
    6100              :          BITSIZE are not byte-aligned, there is no need to limit the range
    6101              :          we can access.  This can occur with packed structures in Ada.  */
    6102      4853017 :       else if (maybe_gt (bitsize, 0)
    6103      4853002 :                && multiple_p (bitsize, BITS_PER_UNIT)
    6104      9705728 :                && multiple_p (bitpos, BITS_PER_UNIT))
    6105              :         {
    6106      4852711 :           bitregion_start = bitpos;
    6107      4852711 :           bitregion_end = bitpos + bitsize - 1;
    6108              :         }
    6109              : 
    6110      4938535 :       to_rtx = expand_expr (tem, NULL_RTX, VOIDmode, EXPAND_WRITE);
    6111              : 
    6112              :       /* If the field has a mode, we want to access it in the
    6113              :          field's mode, not the computed mode.
    6114              :          If a MEM has VOIDmode (external with incomplete type),
    6115              :          use BLKmode for it instead.  */
    6116      4938535 :       if (MEM_P (to_rtx))
    6117              :         {
    6118      4243263 :           if (mode1 != VOIDmode)
    6119      4176638 :             to_rtx = adjust_address (to_rtx, mode1, 0);
    6120        66625 :           else if (GET_MODE (to_rtx) == VOIDmode)
    6121            0 :             to_rtx = adjust_address (to_rtx, BLKmode, 0);
    6122              :         }
    6123              : 
    6124      4938535 :       rtx stemp = NULL_RTX, old_to_rtx = NULL_RTX;
    6125      4938535 :       if (offset != 0)
    6126              :         {
    6127       182440 :           machine_mode address_mode;
    6128       182440 :           rtx offset_rtx;
    6129              : 
    6130       182440 :           if (!MEM_P (to_rtx))
    6131              :             {
    6132              :               /* We can get constant negative offsets into arrays with broken
    6133              :                  user code.  Translate this to a trap instead of ICEing.  */
    6134            5 :               if (TREE_CODE (offset) == INTEGER_CST)
    6135              :                 {
    6136            2 :                   expand_builtin_trap ();
    6137            2 :                   to_rtx = gen_rtx_MEM (BLKmode, const0_rtx);
    6138              :                 }
    6139              :               /* Else spill for variable offset to the destination.  We expect
    6140              :                  to run into this only for hard registers.  */
    6141              :               else
    6142              :                 {
    6143            3 :                   gcc_assert (VAR_P (tem) && DECL_HARD_REGISTER (tem));
    6144            3 :                   stemp = assign_stack_temp (GET_MODE (to_rtx),
    6145            6 :                                              GET_MODE_SIZE (GET_MODE (to_rtx)));
    6146            3 :                   emit_move_insn (stemp, to_rtx);
    6147            3 :                   old_to_rtx = to_rtx;
    6148            3 :                   to_rtx = stemp;
    6149              :                 }
    6150              :             }
    6151              : 
    6152       182440 :           offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, EXPAND_SUM);
    6153       182440 :           address_mode = get_address_mode (to_rtx);
    6154       182440 :           if (GET_MODE (offset_rtx) != address_mode)
    6155              :             {
    6156              :                 /* We cannot be sure that the RTL in offset_rtx is valid outside
    6157              :                    of a memory address context, so force it into a register
    6158              :                    before attempting to convert it to the desired mode.  */
    6159          232 :               offset_rtx = force_operand (offset_rtx, NULL_RTX);
    6160          232 :               offset_rtx = convert_to_mode (address_mode, offset_rtx, 0);
    6161              :             }
    6162              : 
    6163              :           /* If we have an expression in OFFSET_RTX and a non-zero
    6164              :              byte offset in BITPOS, adding the byte offset before the
    6165              :              OFFSET_RTX results in better intermediate code, which makes
    6166              :              later rtl optimization passes perform better.
    6167              : 
    6168              :              We prefer intermediate code like this:
    6169              : 
    6170              :              r124:DI=r123:DI+0x18
    6171              :              [r124:DI]=r121:DI
    6172              : 
    6173              :              ... instead of ...
    6174              : 
    6175              :              r124:DI=r123:DI+0x10
    6176              :              [r124:DI+0x8]=r121:DI
    6177              : 
    6178              :              This is only done for aligned data values, as these can
    6179              :              be expected to result in single move instructions.  */
    6180       182440 :           poly_int64 bytepos;
    6181       182440 :           if (mode1 != VOIDmode
    6182       182321 :               && maybe_ne (bitpos, 0)
    6183        48088 :               && maybe_gt (bitsize, 0)
    6184       230389 :               && multiple_p (bitpos, BITS_PER_UNIT, &bytepos)
    6185       230389 :               && multiple_p (bitpos, bitsize)
    6186        95898 :               && multiple_p (bitsize, GET_MODE_ALIGNMENT (mode1))
    6187       230389 :               && MEM_ALIGN (to_rtx) >= GET_MODE_ALIGNMENT (mode1))
    6188              :             {
    6189        47700 :               to_rtx = adjust_address (to_rtx, mode1, bytepos);
    6190        47700 :               bitregion_start = 0;
    6191        47700 :               if (known_ge (bitregion_end, poly_uint64 (bitpos)))
    6192        47700 :                 bitregion_end -= bitpos;
    6193        47700 :               bitpos = 0;
    6194              :             }
    6195              : 
    6196       182440 :           to_rtx = offset_address (to_rtx, offset_rtx,
    6197              :                                    highest_pow2_factor_for_target (to,
    6198              :                                                                    offset));
    6199              :         }
    6200              : 
    6201              :       /* No action is needed if the target is not a memory and the field
    6202              :          lies completely outside that target.  This can occur if the source
    6203              :          code contains an out-of-bounds access to a small array.  */
    6204      4938535 :       if (!MEM_P (to_rtx)
    6205       695267 :           && GET_MODE (to_rtx) != BLKmode
    6206      5633802 :           && known_ge (bitpos, GET_MODE_PRECISION (GET_MODE (to_rtx))))
    6207              :         {
    6208            3 :           expand_normal (from);
    6209            3 :           result = NULL;
    6210              :         }
    6211              :       /* Handle expand_expr of a complex value returning a CONCAT.  */
    6212      4938532 :       else if (GET_CODE (to_rtx) == CONCAT)
    6213              :         {
    6214           98 :           machine_mode to_mode = GET_MODE (to_rtx);
    6215           98 :           gcc_checking_assert (COMPLEX_MODE_P (to_mode));
    6216          196 :           poly_int64 mode_bitsize = GET_MODE_BITSIZE (to_mode);
    6217           98 :           unsigned short inner_bitsize = GET_MODE_UNIT_BITSIZE (to_mode);
    6218           98 :           if (TYPE_MODE (TREE_TYPE (from)) == to_mode
    6219            0 :               && known_eq (bitpos, 0)
    6220           98 :               && known_eq (bitsize, mode_bitsize))
    6221            0 :             result = store_expr (from, to_rtx, false, nontemporal, reversep);
    6222           98 :           else if (TYPE_MODE (TREE_TYPE (from)) == GET_MODE_INNER (to_mode)
    6223           38 :                    && known_eq (bitsize, inner_bitsize)
    6224          136 :                    && (known_eq (bitpos, 0)
    6225           15 :                        || known_eq (bitpos, inner_bitsize)))
    6226           38 :             result = store_expr (from, XEXP (to_rtx, maybe_ne (bitpos, 0)),
    6227              :                                  false, nontemporal, reversep);
    6228           60 :           else if (known_le (bitpos + bitsize, inner_bitsize))
    6229            5 :             result = store_field (XEXP (to_rtx, 0), bitsize, bitpos,
    6230              :                                   bitregion_start, bitregion_end,
    6231              :                                   mode1, from, get_alias_set (to),
    6232              :                                   nontemporal, reversep);
    6233           55 :           else if (known_ge (bitpos, inner_bitsize))
    6234            3 :             result = store_field (XEXP (to_rtx, 1), bitsize,
    6235              :                                   bitpos - inner_bitsize,
    6236              :                                   bitregion_start, bitregion_end,
    6237              :                                   mode1, from, get_alias_set (to),
    6238              :                                   nontemporal, reversep);
    6239           52 :           else if (known_eq (bitpos, 0) && known_eq (bitsize, mode_bitsize))
    6240              :             {
    6241           45 :               result = expand_normal (from);
    6242           45 :               if (GET_CODE (result) == CONCAT)
    6243              :                 {
    6244            0 :                   to_mode = GET_MODE_INNER (to_mode);
    6245            0 :                   machine_mode from_mode = GET_MODE_INNER (GET_MODE (result));
    6246            0 :                   rtx from_real
    6247            0 :                     = force_subreg (to_mode, XEXP (result, 0), from_mode, 0);
    6248            0 :                   rtx from_imag
    6249            0 :                     = force_subreg (to_mode, XEXP (result, 1), from_mode, 0);
    6250            0 :                   if (!from_real || !from_imag)
    6251            0 :                     goto concat_store_slow;
    6252            0 :                   emit_move_insn (XEXP (to_rtx, 0), from_real);
    6253            0 :                   emit_move_insn (XEXP (to_rtx, 1), from_imag);
    6254              :                 }
    6255              :               else
    6256              :                 {
    6257           45 :                   machine_mode from_mode
    6258           45 :                     = GET_MODE (result) == VOIDmode
    6259           45 :                       ? TYPE_MODE (TREE_TYPE (from))
    6260           45 :                       : GET_MODE (result);
    6261           45 :                   rtx from_rtx;
    6262           45 :                   if (MEM_P (result))
    6263            1 :                     from_rtx = change_address (result, to_mode, NULL_RTX);
    6264              :                   else
    6265           44 :                     from_rtx = force_subreg (to_mode, result, from_mode, 0);
    6266           45 :                   if (from_rtx)
    6267              :                     {
    6268           45 :                       emit_move_insn (XEXP (to_rtx, 0),
    6269              :                                       read_complex_part (from_rtx, false));
    6270           45 :                       emit_move_insn (XEXP (to_rtx, 1),
    6271              :                                       read_complex_part (from_rtx, true));
    6272              :                     }
    6273              :                   else
    6274              :                     {
    6275            0 :                       to_mode = GET_MODE_INNER (to_mode);
    6276            0 :                       rtx from_real
    6277            0 :                         = force_subreg (to_mode, result, from_mode, 0);
    6278            0 :                       rtx from_imag
    6279            0 :                         = force_subreg (to_mode, result, from_mode,
    6280            0 :                                         GET_MODE_SIZE (to_mode));
    6281            0 :                       if (!from_real || !from_imag)
    6282            0 :                         goto concat_store_slow;
    6283            0 :                       emit_move_insn (XEXP (to_rtx, 0), from_real);
    6284            0 :                       emit_move_insn (XEXP (to_rtx, 1), from_imag);
    6285              :                     }
    6286              :                 }
    6287              :             }
    6288              :           else
    6289              :             {
    6290            7 :             concat_store_slow:;
    6291            7 :               rtx temp = assign_stack_temp (GET_MODE (to_rtx),
    6292           14 :                                             GET_MODE_SIZE (GET_MODE (to_rtx)));
    6293            7 :               write_complex_part (temp, XEXP (to_rtx, 0), false, true);
    6294            7 :               write_complex_part (temp, XEXP (to_rtx, 1), true, false);
    6295            7 :               result = store_field (temp, bitsize, bitpos,
    6296              :                                     bitregion_start, bitregion_end,
    6297              :                                     mode1, from, get_alias_set (to),
    6298              :                                     nontemporal, reversep);
    6299            7 :               emit_move_insn (XEXP (to_rtx, 0), read_complex_part (temp, false));
    6300            7 :               emit_move_insn (XEXP (to_rtx, 1), read_complex_part (temp, true));
    6301              :             }
    6302              :         }
    6303              :       /* For calls to functions returning variable length structures, if TO_RTX
    6304              :          is not a MEM, go through a MEM because we must not create temporaries
    6305              :          of the VLA type.  */
    6306      4938434 :       else if (!MEM_P (to_rtx)
    6307       695166 :                && TREE_CODE (from) == CALL_EXPR
    6308          243 :                && COMPLETE_TYPE_P (TREE_TYPE (from))
    6309      4938677 :                && TREE_CODE (TYPE_SIZE (TREE_TYPE (from))) != INTEGER_CST)
    6310              :         {
    6311            6 :           rtx temp = assign_stack_temp (GET_MODE (to_rtx),
    6312           12 :                                         GET_MODE_SIZE (GET_MODE (to_rtx)));
    6313            6 :           result = store_field (temp, bitsize, bitpos, bitregion_start,
    6314              :                                 bitregion_end, mode1, from, get_alias_set (to),
    6315              :                                 nontemporal, reversep);
    6316            6 :           emit_move_insn (to_rtx, temp);
    6317              :         }
    6318              :       else
    6319              :         {
    6320      4938428 :           if (MEM_P (to_rtx))
    6321              :             {
    6322              :               /* If the field is at offset zero, we could have been given the
    6323              :                  DECL_RTX of the parent struct.  Don't munge it.  */
    6324      4243268 :               to_rtx = shallow_copy_rtx (to_rtx);
    6325      4243268 :               set_mem_attributes_minus_bitpos (to_rtx, to, 0, bitpos, true);
    6326      4243268 :               if (volatilep)
    6327        75157 :                 MEM_VOLATILE_P (to_rtx) = 1;
    6328              :             }
    6329              : 
    6330      4938428 :           gcc_checking_assert (known_ge (bitpos, 0));
    6331      9876856 :           if (optimize_bitfield_assignment_op (bitsize, bitpos,
    6332              :                                                bitregion_start, bitregion_end,
    6333              :                                                mode1, to_rtx, to, from,
    6334              :                                                reversep))
    6335              :             result = NULL;
    6336      4938262 :           else if (SUBREG_P (to_rtx)
    6337      4938262 :                    && SUBREG_PROMOTED_VAR_P (to_rtx))
    6338              :             {
    6339              :               /* If to_rtx is a promoted subreg, we need to zero or sign
    6340              :                  extend the value afterwards.  */
    6341            0 :               if (TREE_CODE (to) == MEM_REF
    6342            0 :                   && TYPE_MODE (TREE_TYPE (from)) != BLKmode
    6343            0 :                   && !REF_REVERSE_STORAGE_ORDER (to)
    6344            0 :                   && known_eq (bitpos, 0)
    6345            0 :                   && known_eq (bitsize, GET_MODE_BITSIZE (GET_MODE (to_rtx))))
    6346            0 :                 result = store_expr (from, to_rtx, 0, nontemporal, false);
    6347              :               /* Check if the field overlaps the MSB, requiring extension.  */
    6348            0 :               else if (store_field_updates_msb_p (bitpos, bitsize, to_rtx))
    6349              :                 {
    6350            0 :                   scalar_int_mode imode = subreg_unpromoted_mode (to_rtx);
    6351            0 :                   scalar_int_mode omode = subreg_promoted_mode (to_rtx);
    6352            0 :                   rtx to_rtx1 = lowpart_subreg (imode, SUBREG_REG (to_rtx),
    6353              :                                                 omode);
    6354            0 :                   result = store_field (to_rtx1, bitsize, bitpos,
    6355              :                                         bitregion_start, bitregion_end,
    6356              :                                         mode1, from, get_alias_set (to),
    6357              :                                         nontemporal, reversep);
    6358              :                   /* If the target usually keeps IMODE appropriately
    6359              :                      extended in OMODE it's unsafe to refer to it using
    6360              :                      a SUBREG whilst this invariant doesn't hold.  */
    6361            0 :                   if (targetm.mode_rep_extended (imode, omode) != UNKNOWN)
    6362            0 :                     to_rtx1 = simplify_gen_unary (TRUNCATE, imode,
    6363              :                                                   SUBREG_REG (to_rtx), omode);
    6364            0 :                   convert_move (SUBREG_REG (to_rtx), to_rtx1,
    6365            0 :                                 SUBREG_PROMOTED_SIGN (to_rtx));
    6366              :                 }
    6367              :               else
    6368            0 :                 result = store_field (to_rtx, bitsize, bitpos,
    6369              :                                       bitregion_start, bitregion_end,
    6370              :                                       mode1, from, get_alias_set (to),
    6371              :                                       nontemporal, reversep);
    6372              :             }
    6373              :           else
    6374      4938262 :             result = store_field (to_rtx, bitsize, bitpos,
    6375              :                                   bitregion_start, bitregion_end,
    6376              :                                   mode1, from, get_alias_set (to),
    6377              :                                   nontemporal, reversep);
    6378              :           /* Move the temporary storage back to the non-MEM_P.  */
    6379      4938428 :           if (stemp)
    6380            3 :             emit_move_insn (old_to_rtx, stemp);
    6381              :         }
    6382              : 
    6383      4938535 :       if (result)
    6384       840029 :         preserve_temp_slots (result);
    6385      4938535 :       pop_temp_slots ();
    6386      4938535 :       return;
    6387              :     }
    6388              : 
    6389              :   /* If the rhs is a function call and its value is not an aggregate,
    6390              :      call the function before we start to compute the lhs.
    6391              :      This is needed for correct code for cases such as
    6392              :      val = setjmp (buf) on machines where reference to val
    6393              :      requires loading up part of an address in a separate insn.
    6394              : 
    6395              :      Don't do this if TO is a VAR_DECL or PARM_DECL whose DECL_RTL is REG
    6396              :      since it might be a promoted variable where the zero- or sign- extension
    6397              :      needs to be done.  Handling this in the normal way is safe because no
    6398              :      computation is done before the call.  The same is true for SSA names.  */
    6399      2384148 :   if (TREE_CODE (from) == CALL_EXPR && ! aggregate_value_p (from, from)
    6400      2183842 :       && COMPLETE_TYPE_P (TREE_TYPE (from))
    6401      2183842 :       && TREE_CODE (TYPE_SIZE (TREE_TYPE (from))) == INTEGER_CST
    6402     15917286 :       && ! (((VAR_P (to)
    6403              :               || TREE_CODE (to) == PARM_DECL
    6404              :               || TREE_CODE (to) == RESULT_DECL)
    6405       122374 :              && REG_P (DECL_RTL (to)))
    6406      2071639 :             || TREE_CODE (to) == SSA_NAME))
    6407              :     {
    6408        10444 :       rtx value;
    6409              : 
    6410        10444 :       push_temp_slots ();
    6411        10444 :       value = expand_normal (from);
    6412              : 
    6413        10444 :       if (to_rtx == 0)
    6414        10444 :         to_rtx = expand_expr (to, NULL_RTX, VOIDmode, EXPAND_WRITE);
    6415              : 
    6416              :       /* Handle calls that return values in multiple non-contiguous locations.
    6417              :          The Irix 6 ABI has examples of this.  */
    6418        10444 :       if (GET_CODE (to_rtx) == PARALLEL)
    6419              :         {
    6420            0 :           if (GET_CODE (value) == PARALLEL)
    6421            0 :             emit_group_move (to_rtx, value);
    6422              :           else
    6423            0 :             emit_group_load (to_rtx, value, TREE_TYPE (from),
    6424            0 :                              int_size_in_bytes (TREE_TYPE (from)));
    6425              :         }
    6426        10444 :       else if (GET_CODE (value) == PARALLEL)
    6427         1961 :         emit_group_store (to_rtx, value, TREE_TYPE (from),
    6428         1961 :                           int_size_in_bytes (TREE_TYPE (from)));
    6429         8483 :       else if (GET_MODE (to_rtx) == BLKmode)
    6430              :         {
    6431              :           /* Handle calls that return BLKmode values in registers.  */
    6432          255 :           if (REG_P (value))
    6433          255 :             copy_blkmode_from_reg (to_rtx, value, TREE_TYPE (from));
    6434              :           else
    6435            0 :             emit_block_move (to_rtx, value, expr_size (from), BLOCK_OP_NORMAL);
    6436              :         }
    6437              :       else
    6438              :         {
    6439         8228 :           if (POINTER_TYPE_P (TREE_TYPE (to)))
    6440            0 :             value = convert_memory_address_addr_space
    6441            0 :               (as_a <scalar_int_mode> (GET_MODE (to_rtx)), value,
    6442            0 :                TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (to))));
    6443              : 
    6444         8228 :           emit_move_insn (to_rtx, value);
    6445              :         }
    6446              : 
    6447        10444 :       preserve_temp_slots (to_rtx);
    6448        10444 :       pop_temp_slots ();
    6449        10444 :       return;
    6450              :     }
    6451              : 
    6452              :   /* Ordinary treatment.  Expand TO to get a REG or MEM rtx.  */
    6453     13723000 :   to_rtx = expand_expr (to, NULL_RTX, VOIDmode, EXPAND_WRITE);
    6454              : 
    6455              :   /* Don't move directly into a return register.  */
    6456     13723000 :   if (TREE_CODE (to) == RESULT_DECL
    6457        29171 :       && (REG_P (to_rtx) || GET_CODE (to_rtx) == PARALLEL))
    6458              :     {
    6459            0 :       rtx temp;
    6460              : 
    6461            0 :       push_temp_slots ();
    6462              : 
    6463              :       /* If the source is itself a return value, it still is in a pseudo at
    6464              :          this point so we can move it back to the return register directly.  */
    6465            0 :       if (REG_P (to_rtx)
    6466            0 :           && TYPE_MODE (TREE_TYPE (from)) == BLKmode
    6467            0 :           && TREE_CODE (from) != CALL_EXPR)
    6468            0 :         temp = copy_blkmode_to_reg (GET_MODE (to_rtx), from);
    6469              :       else
    6470            0 :         temp = expand_expr (from, NULL_RTX, GET_MODE (to_rtx), EXPAND_NORMAL);
    6471              : 
    6472              :       /* Handle calls that return values in multiple non-contiguous locations.
    6473              :          The Irix 6 ABI has examples of this.  */
    6474            0 :       if (GET_CODE (to_rtx) == PARALLEL)
    6475              :         {
    6476            0 :           if (GET_CODE (temp) == PARALLEL)
    6477            0 :             emit_group_move (to_rtx, temp);
    6478              :           else
    6479            0 :             emit_group_load (to_rtx, temp, TREE_TYPE (from),
    6480            0 :                              int_size_in_bytes (TREE_TYPE (from)));
    6481              :         }
    6482            0 :       else if (temp)
    6483            0 :         emit_move_insn (to_rtx, temp);
    6484              : 
    6485            0 :       preserve_temp_slots (to_rtx);
    6486            0 :       pop_temp_slots ();
    6487            0 :       return;
    6488              :     }
    6489              : 
    6490              :   /* In case we are returning the contents of an object which overlaps
    6491              :      the place the value is being stored, use a safe function when copying
    6492              :      a value through a pointer into a structure value return block.  */
    6493     13723000 :   if (TREE_CODE (to) == RESULT_DECL
    6494        29171 :       && TREE_CODE (from) == INDIRECT_REF
    6495            0 :       && ADDR_SPACE_GENERIC_P
    6496              :            (TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (from, 0)))))
    6497            0 :       && refs_may_alias_p (to, from)
    6498            0 :       && cfun->returns_struct
    6499     13723000 :       && !cfun->returns_pcc_struct)
    6500              :     {
    6501            0 :       rtx from_rtx, size;
    6502              : 
    6503            0 :       push_temp_slots ();
    6504            0 :       size = expr_size (from);
    6505            0 :       from_rtx = expand_normal (from);
    6506              : 
    6507            0 :       emit_block_move_via_libcall (XEXP (to_rtx, 0), XEXP (from_rtx, 0), size);
    6508              : 
    6509            0 :       preserve_temp_slots (to_rtx);
    6510            0 :       pop_temp_slots ();
    6511            0 :       return;
    6512              :     }
    6513              : 
    6514              :   /* Compute FROM and store the value in the rtx we got.  */
    6515              : 
    6516     13723000 :   push_temp_slots ();
    6517     13723000 :   result = store_expr (from, to_rtx, 0, nontemporal, false);
    6518     13722998 :   preserve_temp_slots (result);
    6519     13722998 :   pop_temp_slots ();
    6520     13722998 :   return;
    6521              : }
    6522              : 
    6523              : /* Emits nontemporal store insn that moves FROM to TO.  Returns true if this
    6524              :    succeeded, false otherwise.  */
    6525              : 
    6526              : bool
    6527           33 : emit_storent_insn (rtx to, rtx from)
    6528              : {
    6529           33 :   class expand_operand ops[2];
    6530           33 :   machine_mode mode = GET_MODE (to);
    6531           33 :   enum insn_code code = optab_handler (storent_optab, mode);
    6532              : 
    6533           33 :   if (code == CODE_FOR_nothing)
    6534              :     return false;
    6535              : 
    6536           33 :   create_fixed_operand (&ops[0], to);
    6537           33 :   create_input_operand (&ops[1], from, mode);
    6538           33 :   return maybe_expand_insn (code, 2, ops);
    6539              : }
    6540              : 
    6541              : /* Helper function for store_expr storing of STRING_CST.  */
    6542              : 
    6543              : static rtx
    6544       110578 : string_cst_read_str (void *data, void *, HOST_WIDE_INT offset,
    6545              :                      fixed_size_mode mode)
    6546              : {
    6547       110578 :   tree str = (tree) data;
    6548              : 
    6549       110578 :   gcc_assert (offset >= 0);
    6550       110578 :   if (offset >= TREE_STRING_LENGTH (str))
    6551        27304 :     return const0_rtx;
    6552              : 
    6553        83274 :   if ((unsigned HOST_WIDE_INT) offset + GET_MODE_SIZE (mode)
    6554        83274 :       > (unsigned HOST_WIDE_INT) TREE_STRING_LENGTH (str))
    6555              :     {
    6556         7638 :       char *p = XALLOCAVEC (char, GET_MODE_SIZE (mode));
    6557         7638 :       size_t l = TREE_STRING_LENGTH (str) - offset;
    6558         7638 :       memcpy (p, TREE_STRING_POINTER (str) + offset, l);
    6559         7638 :       memset (p + l, '\0', GET_MODE_SIZE (mode) - l);
    6560         7638 :       return c_readstr (p, mode, false);
    6561              :     }
    6562              : 
    6563        75636 :   return c_readstr (TREE_STRING_POINTER (str) + offset, mode, false);
    6564              : }
    6565              : 
    6566              : /* Helper function for store_expr storing of RAW_DATA_CST.  */
    6567              : 
    6568              : static rtx
    6569           36 : raw_data_cst_read_str (void *data, void *, HOST_WIDE_INT offset,
    6570              :                        fixed_size_mode mode)
    6571              : {
    6572           36 :   tree cst = (tree) data;
    6573              : 
    6574           36 :   gcc_assert (offset >= 0);
    6575           36 :   if (offset >= RAW_DATA_LENGTH (cst))
    6576            0 :     return const0_rtx;
    6577              : 
    6578           36 :   if ((unsigned HOST_WIDE_INT) offset + GET_MODE_SIZE (mode)
    6579           36 :       > (unsigned HOST_WIDE_INT) RAW_DATA_LENGTH (cst))
    6580              :     {
    6581            0 :       char *p = XALLOCAVEC (char, GET_MODE_SIZE (mode));
    6582            0 :       size_t l = RAW_DATA_LENGTH (cst) - offset;
    6583            0 :       memcpy (p, RAW_DATA_POINTER (cst) + offset, l);
    6584            0 :       memset (p + l, '\0', GET_MODE_SIZE (mode) - l);
    6585            0 :       return c_readstr (p, mode, false);
    6586              :     }
    6587              : 
    6588           36 :   return c_readstr (RAW_DATA_POINTER (cst) + offset, mode, false);
    6589              : }
    6590              : 
    6591              : /* Generate code for computing expression EXP,
    6592              :    and storing the value into TARGET.
    6593              : 
    6594              :    If the mode is BLKmode then we may return TARGET itself.
    6595              :    It turns out that in BLKmode it doesn't cause a problem.
    6596              :    because C has no operators that could combine two different
    6597              :    assignments into the same BLKmode object with different values
    6598              :    with no sequence point.  Will other languages need this to
    6599              :    be more thorough?
    6600              : 
    6601              :    If CALL_PARAM_P is nonzero, this is a store into a call param on the
    6602              :    stack, and block moves may need to be treated specially.
    6603              : 
    6604              :    If NONTEMPORAL is true, try using a nontemporal store instruction.
    6605              : 
    6606              :    If REVERSE is true, the store is to be done in reverse order.  */
    6607              : 
    6608              : rtx
    6609     17863881 : store_expr (tree exp, rtx target, int call_param_p,
    6610              :             bool nontemporal, bool reverse)
    6611              : {
    6612     17863881 :   rtx temp;
    6613     17863881 :   rtx alt_rtl = NULL_RTX;
    6614     17863881 :   location_t loc = curr_insn_location ();
    6615     17863881 :   bool shortened_string_cst = false;
    6616              : 
    6617     17863881 :   if (VOID_TYPE_P (TREE_TYPE (exp)))
    6618              :     {
    6619              :       /* C++ can generate ?: expressions with a throw expression in one
    6620              :          branch and an rvalue in the other. Here, we resolve attempts to
    6621              :          store the throw expression's nonexistent result.  */
    6622            0 :       gcc_assert (!call_param_p);
    6623            0 :       expand_expr (exp, const0_rtx, VOIDmode, EXPAND_NORMAL);
    6624            0 :       return NULL_RTX;
    6625              :     }
    6626     17863881 :   if (TREE_CODE (exp) == COMPOUND_EXPR)
    6627              :     {
    6628              :       /* Perform first part of compound expression, then assign from second
    6629              :          part.  */
    6630            0 :       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode,
    6631              :                    call_param_p ? EXPAND_STACK_PARM : EXPAND_NORMAL);
    6632            0 :       return store_expr (TREE_OPERAND (exp, 1), target,
    6633            0 :                                      call_param_p, nontemporal, reverse);
    6634              :     }
    6635     17863881 :   else if (TREE_CODE (exp) == COND_EXPR && GET_MODE (target) == BLKmode)
    6636              :     {
    6637              :       /* For conditional expression, get safe form of the target.  Then
    6638              :          test the condition, doing the appropriate assignment on either
    6639              :          side.  This avoids the creation of unnecessary temporaries.
    6640              :          For non-BLKmode, it is more efficient not to do this.  */
    6641              : 
    6642            0 :       rtx_code_label *lab1 = gen_label_rtx (), *lab2 = gen_label_rtx ();
    6643              : 
    6644            0 :       do_pending_stack_adjust ();
    6645            0 :       NO_DEFER_POP;
    6646            0 :       jumpifnot (TREE_OPERAND (exp, 0), lab1,
    6647              :                  profile_probability::uninitialized ());
    6648            0 :       store_expr (TREE_OPERAND (exp, 1), target, call_param_p,
    6649              :                   nontemporal, reverse);
    6650            0 :       emit_jump_insn (targetm.gen_jump (lab2));
    6651            0 :       emit_barrier ();
    6652            0 :       emit_label (lab1);
    6653            0 :       store_expr (TREE_OPERAND (exp, 2), target, call_param_p,
    6654              :                   nontemporal, reverse);
    6655            0 :       emit_label (lab2);
    6656            0 :       OK_DEFER_POP;
    6657              : 
    6658            0 :       return NULL_RTX;
    6659              :     }
    6660     17863881 :   else if (GET_CODE (target) == SUBREG && SUBREG_PROMOTED_VAR_P (target))
    6661              :     /* If this is a scalar in a register that is stored in a wider mode
    6662              :        than the declared mode, compute the result into its declared mode
    6663              :        and then convert to the wider mode.  Our value is the computed
    6664              :        expression.  */
    6665              :     {
    6666            7 :       rtx inner_target = 0;
    6667            7 :       scalar_int_mode outer_mode = subreg_unpromoted_mode (target);
    6668            7 :       scalar_int_mode inner_mode = subreg_promoted_mode (target);
    6669              : 
    6670              :       /* We can do the conversion inside EXP, which will often result
    6671              :          in some optimizations.  Do the conversion in two steps: first
    6672              :          change the signedness, if needed, then the extend.  But don't
    6673              :          do this if the type of EXP is a subtype of something else
    6674              :          since then the conversion might involve more than just
    6675              :          converting modes.  */
    6676           14 :       if (INTEGRAL_TYPE_P (TREE_TYPE (exp))
    6677            0 :           && TREE_TYPE (TREE_TYPE (exp)) == 0
    6678            7 :           && GET_MODE_PRECISION (outer_mode)
    6679            0 :              == TYPE_PRECISION (TREE_TYPE (exp)))
    6680              :         {
    6681            0 :           if (!SUBREG_CHECK_PROMOTED_SIGN (target,
    6682              :                                           TYPE_UNSIGNED (TREE_TYPE (exp))))
    6683              :             {
    6684              :               /* Some types, e.g. Fortran's logical*4, won't have a signed
    6685              :                  version, so use the mode instead.  */
    6686            0 :               tree ntype
    6687              :                 = (signed_or_unsigned_type_for
    6688            0 :                    (SUBREG_PROMOTED_SIGN (target), TREE_TYPE (exp)));
    6689            0 :               if (ntype == NULL)
    6690            0 :                 ntype = lang_hooks.types.type_for_mode
    6691            0 :                   (TYPE_MODE (TREE_TYPE (exp)),
    6692            0 :                    SUBREG_PROMOTED_SIGN (target));
    6693              : 
    6694            0 :               exp = fold_convert_loc (loc, ntype, exp);
    6695              :             }
    6696              : 
    6697            0 :           exp = fold_convert_loc (loc, lang_hooks.types.type_for_mode
    6698            0 :                                   (inner_mode, SUBREG_PROMOTED_SIGN (target)),
    6699              :                                   exp);
    6700              : 
    6701            0 :           inner_target = SUBREG_REG (target);
    6702              :         }
    6703              : 
    6704            7 :       temp = expand_expr (exp, inner_target, VOIDmode,
    6705              :                           call_param_p ? EXPAND_STACK_PARM : EXPAND_NORMAL);
    6706              : 
    6707              : 
    6708              :       /* If TEMP is a VOIDmode constant, use convert_modes to make
    6709              :          sure that we properly convert it.  */
    6710            7 :       if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode)
    6711              :         {
    6712            0 :           temp = convert_modes (outer_mode, TYPE_MODE (TREE_TYPE (exp)),
    6713            0 :                                 temp, SUBREG_PROMOTED_SIGN (target));
    6714            0 :           temp = convert_modes (inner_mode, outer_mode, temp,
    6715            0 :                                 SUBREG_PROMOTED_SIGN (target));
    6716            0 :         }
    6717            7 :       else if (!SCALAR_INT_MODE_P (GET_MODE (temp)))
    6718            0 :         temp = convert_modes (outer_mode, TYPE_MODE (TREE_TYPE (exp)),
    6719            0 :                               temp, SUBREG_PROMOTED_SIGN (target));
    6720              : 
    6721           21 :       convert_move (SUBREG_REG (target), temp,
    6722            7 :                     SUBREG_PROMOTED_SIGN (target));
    6723              : 
    6724            7 :       return NULL_RTX;
    6725              :     }
    6726     17863874 :   else if ((TREE_CODE (exp) == STRING_CST
    6727     17853910 :             || (TREE_CODE (exp) == MEM_REF
    6728      1362036 :                 && TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
    6729       444075 :                 && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
    6730              :                    == STRING_CST
    6731         6672 :                 && integer_zerop (TREE_OPERAND (exp, 1))))
    6732        16636 :            && !nontemporal && !call_param_p
    6733     17880510 :            && MEM_P (target))
    6734              :     {
    6735              :       /* Optimize initialization of an array with a STRING_CST.  */
    6736        16618 :       HOST_WIDE_INT exp_len, str_copy_len;
    6737        16618 :       rtx dest_mem;
    6738        16618 :       tree str = TREE_CODE (exp) == STRING_CST
    6739        16618 :                  ? exp : TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    6740              : 
    6741        16618 :       exp_len = int_expr_size (exp);
    6742        16618 :       if (exp_len <= 0)
    6743            0 :         goto normal_expr;
    6744              : 
    6745        16618 :       if (TREE_STRING_LENGTH (str) <= 0)
    6746            0 :         goto normal_expr;
    6747              : 
    6748        33236 :       if (can_store_by_pieces (exp_len, string_cst_read_str, (void *) str,
    6749        16618 :                                MEM_ALIGN (target), false))
    6750              :         {
    6751        16205 :           store_by_pieces (target, exp_len, string_cst_read_str, (void *) str,
    6752        16205 :                            MEM_ALIGN (target), false, RETURN_BEGIN);
    6753        16205 :           return NULL_RTX;
    6754              :         }
    6755              : 
    6756          413 :       str_copy_len = TREE_STRING_LENGTH (str);
    6757              : 
    6758              :       /* Trailing NUL bytes in EXP will be handled by the call to
    6759              :          clear_storage, which is more efficient than copying them from
    6760              :          the STRING_CST, so trim those from STR_COPY_LEN.  */
    6761          765 :       while (str_copy_len)
    6762              :         {
    6763          717 :           if (TREE_STRING_POINTER (str)[str_copy_len - 1])
    6764              :             break;
    6765          352 :           str_copy_len--;
    6766              :         }
    6767              : 
    6768          413 :       if ((STORE_MAX_PIECES & (STORE_MAX_PIECES - 1)) == 0)
    6769              :         {
    6770          413 :           str_copy_len += STORE_MAX_PIECES - 1;
    6771          413 :           str_copy_len &= ~(STORE_MAX_PIECES - 1);
    6772              :         }
    6773          413 :       if (str_copy_len >= exp_len)
    6774          136 :         goto normal_expr;
    6775              : 
    6776          554 :       if (!can_store_by_pieces (str_copy_len, string_cst_read_str,
    6777          277 :                                 (void *) str, MEM_ALIGN (target), false))
    6778            2 :         goto normal_expr;
    6779              : 
    6780          275 :       dest_mem = store_by_pieces (target, str_copy_len, string_cst_read_str,
    6781          275 :                                   (void *) str, MEM_ALIGN (target), false,
    6782              :                                   RETURN_END);
    6783          275 :       clear_storage (adjust_address_1 (dest_mem, BLKmode, 0, 1, 1, 0,
    6784          275 :                                        exp_len - str_copy_len),
    6785              :                      GEN_INT (exp_len - str_copy_len), BLOCK_OP_NORMAL);
    6786          275 :       return NULL_RTX;
    6787              :     }
    6788              :   else
    6789              :     {
    6790     17847394 :       rtx tmp_target;
    6791              : 
    6792     17847394 :   normal_expr:
    6793              :       /* If we want to use a nontemporal or a reverse order store, force the
    6794              :          value into a register first.  */
    6795     17847394 :       tmp_target = nontemporal || reverse ? NULL_RTX : target;
    6796     17847394 :       tree rexp = exp;
    6797     17847394 :       if (TREE_CODE (exp) == STRING_CST
    6798           20 :           && tmp_target == target
    6799           20 :           && GET_MODE (target) == BLKmode
    6800     17847414 :           && TYPE_MODE (TREE_TYPE (exp)) == BLKmode)
    6801              :         {
    6802           20 :           rtx size = expr_size (exp);
    6803           20 :           if (CONST_INT_P (size)
    6804           20 :               && size != const0_rtx
    6805           40 :               && (UINTVAL (size)
    6806           20 :                   > ((unsigned HOST_WIDE_INT) TREE_STRING_LENGTH (exp) + 32)))
    6807              :             {
    6808              :               /* If the STRING_CST has much larger array type than
    6809              :                  TREE_STRING_LENGTH, only emit the TREE_STRING_LENGTH part of
    6810              :                  it into the rodata section as the code later on will use
    6811              :                  memset zero for the remainder anyway.  See PR95052.  */
    6812            2 :               tmp_target = NULL_RTX;
    6813            2 :               rexp = copy_node (exp);
    6814            2 :               tree index
    6815            2 :                 = build_index_type (size_int (TREE_STRING_LENGTH (exp) - 1));
    6816            2 :               TREE_TYPE (rexp) = build_array_type (TREE_TYPE (TREE_TYPE (exp)),
    6817              :                                                    index);
    6818            2 :               shortened_string_cst = true;
    6819              :             }
    6820              :         }
    6821     35694788 :       temp = expand_expr_real (rexp, tmp_target, GET_MODE (target),
    6822              :                                (call_param_p
    6823              :                                 ? EXPAND_STACK_PARM : EXPAND_NORMAL),
    6824              :                                &alt_rtl, false);
    6825     17847392 :       if (shortened_string_cst)
    6826              :         {
    6827            2 :           gcc_assert (MEM_P (temp));
    6828            2 :           temp = change_address (temp, BLKmode, NULL_RTX);
    6829              :         }
    6830              :     }
    6831              : 
    6832              :   /* If TEMP is a VOIDmode constant and the mode of the type of EXP is not
    6833              :      the same as that of TARGET, adjust the constant.  This is needed, for
    6834              :      example, in case it is a CONST_DOUBLE or CONST_WIDE_INT and we want
    6835              :      only a word-sized value.  */
    6836      3748481 :   if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode
    6837      2725708 :       && TREE_CODE (exp) != ERROR_MARK
    6838     20573100 :       && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
    6839              :     {
    6840            0 :       gcc_assert (!shortened_string_cst);
    6841            0 :       if (GET_MODE_CLASS (GET_MODE (target))
    6842            0 :           != GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (exp)))
    6843            0 :           && known_eq (GET_MODE_BITSIZE (GET_MODE (target)),
    6844              :                        GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (exp)))))
    6845              :         {
    6846            0 :           rtx t = simplify_gen_subreg (GET_MODE (target), temp,
    6847            0 :                                        TYPE_MODE (TREE_TYPE (exp)), 0);
    6848            0 :           if (t)
    6849            0 :             temp = t;
    6850              :         }
    6851            0 :       if (GET_MODE (temp) == VOIDmode)
    6852            0 :         temp = convert_modes (GET_MODE (target), TYPE_MODE (TREE_TYPE (exp)),
    6853            0 :                               temp, TYPE_UNSIGNED (TREE_TYPE (exp)));
    6854              :     }
    6855              : 
    6856              :   /* If value was not generated in the target, store it there.
    6857              :      Convert the value to TARGET's type first if necessary and emit the
    6858              :      pending incrementations that have been queued when expanding EXP.
    6859              :      Note that we cannot emit the whole queue blindly because this will
    6860              :      effectively disable the POST_INC optimization later.
    6861              : 
    6862              :      If TEMP and TARGET compare equal according to rtx_equal_p, but
    6863              :      one or both of them are volatile memory refs, we have to distinguish
    6864              :      two cases:
    6865              :      - expand_expr has used TARGET.  In this case, we must not generate
    6866              :        another copy.  This can be detected by TARGET being equal according
    6867              :        to == .
    6868              :      - expand_expr has not used TARGET - that means that the source just
    6869              :        happens to have the same RTX form.  Since temp will have been created
    6870              :        by expand_expr, it will compare unequal according to == .
    6871              :        We must generate a copy in this case, to reach the correct number
    6872              :        of volatile memory references.  */
    6873              : 
    6874     17847392 :   if ((! rtx_equal_p (temp, target)
    6875      3164415 :        || (temp != target && (side_effects_p (temp)
    6876        47076 :                               || side_effects_p (target)
    6877        47076 :                               || (MEM_P (temp)
    6878        46665 :                                   && !mems_same_for_tbaa_p (temp, target)))))
    6879     14682981 :       && TREE_CODE (exp) != ERROR_MARK
    6880              :       /* If store_expr stores a DECL whose DECL_RTL(exp) == TARGET,
    6881              :          but TARGET is not valid memory reference, TEMP will differ
    6882              :          from TARGET although it is really the same location.  */
    6883     14682981 :       && !(alt_rtl
    6884      1999101 :            && rtx_equal_p (alt_rtl, target)
    6885            1 :            && !side_effects_p (alt_rtl)
    6886            0 :            && !side_effects_p (target))
    6887              :       /* If there's nothing to copy, don't bother.  Don't call
    6888              :          expr_size unless necessary, because some front-ends (C++)
    6889              :          expr_size-hook must not be given objects that are not
    6890              :          supposed to be bit-copied or bit-initialized.  */
    6891     32530373 :       && expr_size (exp) != const0_rtx)
    6892              :     {
    6893     14682981 :       if (GET_MODE (temp) != GET_MODE (target) && GET_MODE (temp) != VOIDmode)
    6894              :         {
    6895         1418 :           gcc_assert (!shortened_string_cst);
    6896         1418 :           if (GET_MODE (target) == BLKmode)
    6897              :             {
    6898              :               /* Handle calls that return BLKmode values in registers.  */
    6899            2 :               if (REG_P (temp) && TREE_CODE (exp) == CALL_EXPR)
    6900            2 :                 copy_blkmode_from_reg (target, temp, TREE_TYPE (exp));
    6901              :               else
    6902            0 :                 store_bit_field (target,
    6903            0 :                                  rtx_to_poly_int64 (expr_size (exp))
    6904            0 :                                  * BITS_PER_UNIT,
    6905              :                                  0, 0, 0, GET_MODE (temp), temp, reverse,
    6906              :                                  false);
    6907              :             }
    6908              :           else
    6909         1416 :             convert_move (target, temp, TYPE_UNSIGNED (TREE_TYPE (exp)));
    6910              :         }
    6911              : 
    6912     14681563 :       else if (GET_MODE (temp) == BLKmode && TREE_CODE (exp) == STRING_CST)
    6913              :         {
    6914              :           /* Handle copying a string constant into an array.  The string
    6915              :              constant may be shorter than the array.  So copy just the string's
    6916              :              actual length, and clear the rest.  First get the size of the data
    6917              :              type of the string, which is actually the size of the target.  */
    6918           20 :           rtx size = expr_size (exp);
    6919              : 
    6920           20 :           if (CONST_INT_P (size)
    6921           20 :               && INTVAL (size) < TREE_STRING_LENGTH (exp))
    6922            0 :             emit_block_move (target, temp, size,
    6923              :                              (call_param_p
    6924              :                               ? BLOCK_OP_CALL_PARM : BLOCK_OP_NORMAL));
    6925              :           else
    6926              :             {
    6927           20 :               machine_mode pointer_mode
    6928           20 :                 = targetm.addr_space.pointer_mode (MEM_ADDR_SPACE (target));
    6929           20 :               machine_mode address_mode = get_address_mode (target);
    6930              : 
    6931              :               /* Compute the size of the data to copy from the string.  */
    6932           20 :               tree copy_size
    6933           20 :                 = size_binop_loc (loc, MIN_EXPR,
    6934              :                                   make_tree (sizetype, size),
    6935           20 :                                   size_int (TREE_STRING_LENGTH (exp)));
    6936           20 :               rtx copy_size_rtx
    6937           20 :                 = expand_expr (copy_size, NULL_RTX, VOIDmode,
    6938              :                                (call_param_p
    6939              :                                 ? EXPAND_STACK_PARM : EXPAND_NORMAL));
    6940           20 :               rtx_code_label *label = 0;
    6941              : 
    6942              :               /* Copy that much.  */
    6943           60 :               copy_size_rtx = convert_to_mode (pointer_mode, copy_size_rtx,
    6944           20 :                                                TYPE_UNSIGNED (sizetype));
    6945           40 :               emit_block_move (target, temp, copy_size_rtx,
    6946              :                                (call_param_p
    6947              :                                 ? BLOCK_OP_CALL_PARM : BLOCK_OP_NORMAL));
    6948              : 
    6949              :               /* Figure out how much is left in TARGET that we have to clear.
    6950              :                  Do all calculations in pointer_mode.  */
    6951           20 :               poly_int64 const_copy_size;
    6952           20 :               if (poly_int_rtx_p (copy_size_rtx, &const_copy_size))
    6953              :                 {
    6954           20 :                   size = plus_constant (address_mode, size, -const_copy_size);
    6955           20 :                   target = adjust_address (target, BLKmode, const_copy_size);
    6956              :                 }
    6957              :               else
    6958              :                 {
    6959            0 :                   size = expand_binop (TYPE_MODE (sizetype), sub_optab, size,
    6960              :                                        copy_size_rtx, NULL_RTX, 0,
    6961              :                                        OPTAB_LIB_WIDEN);
    6962              : 
    6963            0 :                   if (GET_MODE (copy_size_rtx) != address_mode)
    6964            0 :                     copy_size_rtx = convert_to_mode (address_mode,
    6965              :                                                      copy_size_rtx,
    6966            0 :                                                      TYPE_UNSIGNED (sizetype));
    6967              : 
    6968            0 :                   target = offset_address (target, copy_size_rtx,
    6969              :                                            highest_pow2_factor (copy_size));
    6970            0 :                   label = gen_label_rtx ();
    6971            0 :                   emit_cmp_and_jump_insns (size, const0_rtx, LT, NULL_RTX,
    6972            0 :                                            GET_MODE (size), 0, label);
    6973              :                 }
    6974              : 
    6975           20 :               if (size != const0_rtx)
    6976            2 :                 clear_storage (target, size, BLOCK_OP_NORMAL);
    6977              : 
    6978           20 :               if (label)
    6979            0 :                 emit_label (label);
    6980              :             }
    6981              :         }
    6982     14681543 :       else if (shortened_string_cst)
    6983            0 :         gcc_unreachable ();
    6984              :       /* Handle calls that return values in multiple non-contiguous locations.
    6985              :          The Irix 6 ABI has examples of this.  */
    6986     14681543 :       else if (GET_CODE (target) == PARALLEL)
    6987              :         {
    6988            0 :           if (GET_CODE (temp) == PARALLEL)
    6989            0 :             emit_group_move (target, temp);
    6990              :           else
    6991            0 :             emit_group_load (target, temp, TREE_TYPE (exp),
    6992            0 :                              int_size_in_bytes (TREE_TYPE (exp)));
    6993              :         }
    6994     14681543 :       else if (GET_CODE (temp) == PARALLEL)
    6995            0 :         emit_group_store (target, temp, TREE_TYPE (exp),
    6996            0 :                           int_size_in_bytes (TREE_TYPE (exp)));
    6997     14681543 :       else if (GET_MODE (temp) == BLKmode)
    6998       609430 :         emit_block_move (target, temp, expr_size (exp),
    6999              :                          (call_param_p
    7000              :                           ? BLOCK_OP_CALL_PARM : BLOCK_OP_NORMAL));
    7001              :       /* If we emit a nontemporal store, there is nothing else to do.  */
    7002     14376828 :       else if (nontemporal && emit_storent_insn (target, temp))
    7003              :         ;
    7004              :       else
    7005              :         {
    7006     14376795 :           if (reverse)
    7007          763 :             temp = flip_storage_order (GET_MODE (target), temp);
    7008     14376795 :           temp = force_operand (temp, target);
    7009     14376795 :           if (temp != target)
    7010     14375338 :             emit_move_insn (target, temp);
    7011              :         }
    7012              :     }
    7013              :   else
    7014      3164411 :     gcc_assert (!shortened_string_cst);
    7015              : 
    7016              :   return NULL_RTX;
    7017              : }
    7018              : 
    7019              : /* Return true if field F of structure TYPE is a flexible array.  */
    7020              : 
    7021              : static bool
    7022      3989174 : flexible_array_member_p (const_tree f, const_tree type)
    7023              : {
    7024      3989174 :   const_tree tf;
    7025              : 
    7026      3989174 :   tf = TREE_TYPE (f);
    7027      3989174 :   return (DECL_CHAIN (f) == NULL
    7028      1091142 :           && TREE_CODE (tf) == ARRAY_TYPE
    7029         2443 :           && TYPE_DOMAIN (tf)
    7030         2443 :           && TYPE_MIN_VALUE (TYPE_DOMAIN (tf))
    7031         2443 :           && integer_zerop (TYPE_MIN_VALUE (TYPE_DOMAIN (tf)))
    7032         2443 :           && !TYPE_MAX_VALUE (TYPE_DOMAIN (tf))
    7033      3989214 :           && int_size_in_bytes (type) >= 0);
    7034              : }
    7035              : 
    7036              : /* If FOR_CTOR_P, return the number of top-level elements that a constructor
    7037              :    must have in order for it to completely initialize a value of type TYPE.
    7038              :    Return -1 if the number isn't known.
    7039              : 
    7040              :    If !FOR_CTOR_P, return an estimate of the number of scalars in TYPE.  */
    7041              : 
    7042              : static HOST_WIDE_INT
    7043      3743815 : count_type_elements (const_tree type, bool for_ctor_p)
    7044              : {
    7045      3745168 :   switch (TREE_CODE (type))
    7046              :     {
    7047       156427 :     case ARRAY_TYPE:
    7048       156427 :       {
    7049       156427 :         tree nelts_minus_one;
    7050              : 
    7051       156427 :         nelts_minus_one = array_type_nelts_minus_one (type);
    7052       156427 :         if (nelts_minus_one && tree_fits_uhwi_p (nelts_minus_one))
    7053              :           {
    7054       156416 :             unsigned HOST_WIDE_INT n;
    7055              : 
    7056       156416 :             n = tree_to_uhwi (nelts_minus_one) + 1;
    7057       156416 :             if (n == 0 || for_ctor_p)
    7058       155063 :               return n;
    7059              :             else
    7060         1353 :               return n * count_type_elements (TREE_TYPE (type), false);
    7061              :           }
    7062           11 :         return for_ctor_p ? -1 : 1;
    7063              :       }
    7064              : 
    7065      1834012 :     case RECORD_TYPE:
    7066      1834012 :       {
    7067      1834012 :         unsigned HOST_WIDE_INT n;
    7068      1834012 :         tree f;
    7069              : 
    7070      1834012 :         n = 0;
    7071     17483391 :         for (f = TYPE_FIELDS (type); f ; f = DECL_CHAIN (f))
    7072     15649379 :           if (TREE_CODE (f) == FIELD_DECL)
    7073              :             {
    7074      4454321 :               if (!for_ctor_p)
    7075       465147 :                 n += count_type_elements (TREE_TYPE (f), false);
    7076      3989174 :               else if (!flexible_array_member_p (f, type))
    7077              :                 /* Don't count flexible arrays, which are not supposed
    7078              :                    to be initialized.  */
    7079      3989134 :                 n += 1;
    7080              :             }
    7081              : 
    7082      1834012 :         return n;
    7083              :       }
    7084              : 
    7085         3393 :     case UNION_TYPE:
    7086         3393 :     case QUAL_UNION_TYPE:
    7087         3393 :       {
    7088         3393 :         tree f;
    7089         3393 :         HOST_WIDE_INT n, m;
    7090              : 
    7091         3393 :         gcc_assert (!for_ctor_p);
    7092              :         /* Estimate the number of scalars in each field and pick the
    7093              :            maximum.  Other estimates would do instead; the idea is simply
    7094              :            to make sure that the estimate is not sensitive to the ordering
    7095              :            of the fields.  */
    7096         3393 :         n = 1;
    7097        77132 :         for (f = TYPE_FIELDS (type); f ; f = DECL_CHAIN (f))
    7098        73739 :           if (TREE_CODE (f) == FIELD_DECL)
    7099              :             {
    7100        69219 :               m = count_type_elements (TREE_TYPE (f), false);
    7101              :               /* If the field doesn't span the whole union, add an extra
    7102              :                  scalar for the rest.  */
    7103        69219 :               if (simple_cst_equal (DECL_SIZE (f), TYPE_SIZE (type)) != 1)
    7104        49335 :                 m++;
    7105        69219 :               if (n < m)
    7106        73739 :                 n = m;
    7107              :             }
    7108              :         return n;
    7109              :       }
    7110              : 
    7111              :     case COMPLEX_TYPE:
    7112              :       return 2;
    7113              : 
    7114          424 :     case VECTOR_TYPE:
    7115          424 :       {
    7116          424 :         unsigned HOST_WIDE_INT nelts;
    7117          424 :         if (TYPE_VECTOR_SUBPARTS (type).is_constant (&nelts))
    7118          424 :           return nelts;
    7119              :         else
    7120              :           return -1;
    7121              :       }
    7122              : 
    7123              :     case INTEGER_TYPE:
    7124              :     case REAL_TYPE:
    7125              :     case FIXED_POINT_TYPE:
    7126              :     case ENUMERAL_TYPE:
    7127              :     case BOOLEAN_TYPE:
    7128              :     case POINTER_TYPE:
    7129              :     case OFFSET_TYPE:
    7130              :     case REFERENCE_TYPE:
    7131              :     /* This could represent the C++ std::meta::info type.  */
    7132              :     case LANG_TYPE:
    7133              :     case NULLPTR_TYPE:
    7134              :     case OPAQUE_TYPE:
    7135              :     case BITINT_TYPE:
    7136              :       return 1;
    7137              : 
    7138            0 :     case ERROR_MARK:
    7139            0 :       return 0;
    7140              : 
    7141            0 :     case VOID_TYPE:
    7142            0 :     case METHOD_TYPE:
    7143            0 :     case FUNCTION_TYPE:
    7144            0 :     default:
    7145            0 :       gcc_unreachable ();
    7146              :     }
    7147              : }
    7148              : 
    7149              : /* Helper for categorize_ctor_elements.  Identical interface.  */
    7150              : 
    7151              : static bool
    7152      1562865 : categorize_ctor_elements_1 (const_tree ctor, HOST_WIDE_INT *p_nz_elts,
    7153              :                             HOST_WIDE_INT *p_unique_nz_elts,
    7154              :                             HOST_WIDE_INT *p_init_elts,
    7155              :                             ctor_completeness *p_complete)
    7156              : {
    7157      1562865 :   unsigned HOST_WIDE_INT idx;
    7158      1562865 :   HOST_WIDE_INT nz_elts, unique_nz_elts, init_elts, num_fields;
    7159      1562865 :   tree value, purpose, elt_type;
    7160              : 
    7161              :   /* Whether CTOR is a valid constant initializer, in accordance with what
    7162              :      initializer_constant_valid_p does.  If inferred from the constructor
    7163              :      elements, true until proven otherwise.  */
    7164      1562865 :   bool const_from_elts_p = constructor_static_from_elts_p (ctor);
    7165      1562865 :   bool const_p = const_from_elts_p ? true : TREE_STATIC (ctor);
    7166              : 
    7167      1562865 :   nz_elts = 0;
    7168      1562865 :   unique_nz_elts = 0;
    7169      1562865 :   init_elts = 0;
    7170      1562865 :   num_fields = 0;
    7171      1562865 :   elt_type = NULL_TREE;
    7172              : 
    7173      5930067 :   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), idx, purpose, value)
    7174              :     {
    7175      4367202 :       HOST_WIDE_INT mult = 1;
    7176              : 
    7177      4367202 :       if (purpose && TREE_CODE (purpose) == RANGE_EXPR)
    7178              :         {
    7179          859 :           tree lo_index = TREE_OPERAND (purpose, 0);
    7180          859 :           tree hi_index = TREE_OPERAND (purpose, 1);
    7181              : 
    7182          859 :           if (tree_fits_uhwi_p (lo_index) && tree_fits_uhwi_p (hi_index))
    7183          859 :             mult = (tree_to_uhwi (hi_index)
    7184          859 :                     - tree_to_uhwi (lo_index) + 1);
    7185              :         }
    7186      4367202 :       num_fields += mult;
    7187      4367202 :       elt_type = TREE_TYPE (value);
    7188              : 
    7189      4367202 :       switch (TREE_CODE (value))
    7190              :         {
    7191       545715 :         case CONSTRUCTOR:
    7192       545715 :           {
    7193       545715 :             HOST_WIDE_INT nz = 0, unz = 0, ic = 0;
    7194              : 
    7195       545715 :             bool const_elt_p = categorize_ctor_elements_1 (value, &nz, &unz,
    7196              :                                                            &ic, p_complete);
    7197              : 
    7198       545715 :             nz_elts += mult * nz;
    7199       545715 :             unique_nz_elts += unz;
    7200       545715 :             init_elts += mult * ic;
    7201              : 
    7202       545715 :             if (const_from_elts_p && const_p)
    7203       332448 :               const_p = const_elt_p;
    7204              :           }
    7205       545715 :           break;
    7206              : 
    7207      2351195 :         case INTEGER_CST:
    7208      2351195 :         case REAL_CST:
    7209      2351195 :         case FIXED_CST:
    7210      2351195 :           if (!initializer_zerop (value))
    7211              :             {
    7212      1719884 :               nz_elts += mult;
    7213      1719884 :               unique_nz_elts++;
    7214              :             }
    7215      2351195 :           init_elts += mult;
    7216      2351195 :           break;
    7217              : 
    7218         3774 :         case STRING_CST:
    7219         3774 :           {
    7220         3774 :             HOST_WIDE_INT len = TREE_STRING_LENGTH (value);
    7221         3774 :             nz_elts += mult * len;
    7222         3774 :             unique_nz_elts += len;
    7223              :             /* Count implicit trailing zeros as well, so that the density
    7224              :                heuristic can prefer clearing to copying a mostly-zero
    7225              :                aggregate from read-only data.  */
    7226         3774 :             if (tree_fits_shwi_p (TYPE_SIZE_UNIT (elt_type)))
    7227         3774 :               len = MAX (len, tree_to_shwi (TYPE_SIZE_UNIT (elt_type)));
    7228         3774 :             init_elts += mult * len;
    7229              :           }
    7230         3774 :           break;
    7231              : 
    7232          166 :         case RAW_DATA_CST:
    7233          166 :           nz_elts += mult * RAW_DATA_LENGTH (value);
    7234          166 :           unique_nz_elts += RAW_DATA_LENGTH (value);
    7235          166 :           init_elts += mult * RAW_DATA_LENGTH (value);
    7236          166 :           num_fields += mult * (RAW_DATA_LENGTH (value) - 1);
    7237          166 :           break;
    7238              : 
    7239         3234 :         case COMPLEX_CST:
    7240         3234 :           if (!initializer_zerop (TREE_REALPART (value)))
    7241              :             {
    7242         2630 :               nz_elts += mult;
    7243         2630 :               unique_nz_elts++;
    7244              :             }
    7245         3234 :           if (!initializer_zerop (TREE_IMAGPART (value)))
    7246              :             {
    7247         2272 :               nz_elts += mult;
    7248         2272 :               unique_nz_elts++;
    7249              :             }
    7250         3234 :           init_elts += 2 * mult;
    7251         3234 :           break;
    7252              : 
    7253         6428 :         case VECTOR_CST:
    7254         6428 :           {
    7255         6428 :             unsigned int nunits
    7256              :               = constant_lower_bound
    7257         6428 :               (TYPE_VECTOR_SUBPARTS (TREE_TYPE (value)));
    7258        40023 :             for (unsigned int i = 0; i < nunits; ++i)
    7259              :               {
    7260        33595 :                 tree v = VECTOR_CST_ELT (value, i);
    7261        33595 :                 if (!initializer_zerop (v))
    7262              :                   {
    7263        19141 :                     nz_elts += mult;
    7264        19141 :                     unique_nz_elts++;
    7265              :                   }
    7266        33595 :                 init_elts += mult;
    7267              :               }
    7268              :           }
    7269              :           break;
    7270              : 
    7271      1456690 :         default:
    7272      1456690 :           {
    7273      1456690 :             HOST_WIDE_INT tc = count_type_elements (elt_type, false);
    7274      1456690 :             nz_elts += mult * tc;
    7275      1456690 :             unique_nz_elts += tc;
    7276      1456690 :             init_elts += mult * tc;
    7277              : 
    7278      1456690 :             if (const_from_elts_p && const_p)
    7279       600356 :               const_p
    7280       600356 :                 = initializer_constant_valid_p (value,
    7281              :                                                 elt_type,
    7282       600356 :                                                 TYPE_REVERSE_STORAGE_ORDER
    7283              :                                                 (TREE_TYPE (ctor)))
    7284              :                   != NULL_TREE;
    7285              :           }
    7286              :           break;
    7287              :         }
    7288              :     }
    7289              : 
    7290      1562865 :   if (!p_complete->sparse
    7291      1562865 :       && !complete_ctor_at_level_p (TREE_TYPE (ctor),
    7292              :                                     num_fields, elt_type))
    7293       196743 :     p_complete->sparse = true;
    7294      1366122 :   else if (TREE_CODE (TREE_TYPE (ctor)) == UNION_TYPE
    7295      1366122 :            || TREE_CODE (TREE_TYPE (ctor)) == QUAL_UNION_TYPE)
    7296              :     {
    7297        12818 :       tree member = NULL_TREE;
    7298        12818 :       if (num_fields)
    7299              :         {
    7300        12815 :           member = CONSTRUCTOR_ELT (ctor, 0)->index;
    7301        12815 :           if (!member)
    7302              :             {
    7303            0 :               for (member = TYPE_FIELDS (TREE_TYPE (ctor)); member;
    7304            0 :                    member = DECL_CHAIN (member))
    7305            0 :                 if (TREE_CODE (member) == FIELD_DECL)
    7306              :                   break;
    7307              :             }
    7308            0 :           if (member
    7309        12815 :               && DECL_BIT_FIELD (member)
    7310            0 :               && !p_complete->sparse
    7311            0 :               && flag_zero_init_padding_bits >= ZERO_INIT_PADDING_BITS_UNIONS
    7312            0 :               && simple_cst_equal (TYPE_SIZE (TREE_TYPE (ctor)),
    7313            0 :                                    DECL_SIZE (member)) != 1)
    7314            0 :             p_complete->sparse = true;
    7315              :         }
    7316        12818 :       if (!p_complete->sparse
    7317         8230 :           && CONSTRUCTOR_ZERO_PADDING_BITS (ctor)
    7318        22939 :           && (num_fields
    7319        10121 :               ? simple_cst_equal (TYPE_SIZE (TREE_TYPE (ctor)),
    7320         5059 :                                   member ? DECL_SIZE (member)
    7321            0 :                                   : TYPE_SIZE (elt_type)) != 1
    7322            3 :               : type_has_padding_at_level_p (TREE_TYPE (ctor))))
    7323         3367 :         p_complete->sparse = true;
    7324         4863 :       else if (!p_complete->sparse && !p_complete->padded_union
    7325        19169 :                && (num_fields
    7326         9718 :                    ? simple_cst_equal (TYPE_SIZE (TREE_TYPE (ctor)),
    7327         4859 :                                        member ? DECL_SIZE (member)
    7328            0 :                                        : TYPE_SIZE (elt_type)) != 1
    7329            0 :                    : type_has_padding_at_level_p (TREE_TYPE (ctor))))
    7330          536 :         p_complete->padded_union = true;
    7331              :     }
    7332      1353304 :   else if (!p_complete->sparse
    7333      1235387 :            && (CONSTRUCTOR_ZERO_PADDING_BITS (ctor)
    7334      1216450 :                || flag_zero_init_padding_bits == ZERO_INIT_PADDING_BITS_ALL)
    7335      1372270 :            && type_has_padding_at_level_p (TREE_TYPE (ctor)))
    7336         2495 :     p_complete->sparse = true;
    7337      1232892 :   else if (!p_complete->sparse && !p_complete->padded_non_union
    7338      2537068 :            && type_has_padding_at_level_p (TREE_TYPE (ctor)))
    7339        16007 :     p_complete->padded_non_union = true;
    7340              : 
    7341      1562865 :   *p_nz_elts += nz_elts;
    7342      1562865 :   *p_unique_nz_elts += unique_nz_elts;
    7343      1562865 :   *p_init_elts += init_elts;
    7344              : 
    7345      1562865 :   return const_p;
    7346              : }
    7347              : 
    7348              : /* Examine CTOR to discover:
    7349              :    * how many scalar fields are set to nonzero values,
    7350              :      and place it in *P_NZ_ELTS;
    7351              :    * the same, but counting RANGE_EXPRs as multiplier of 1 instead of
    7352              :      high - low + 1 (this can be useful for callers to determine ctors
    7353              :      that could be cheaply initialized with - perhaps nested - loops
    7354              :      compared to copied from huge read-only data),
    7355              :      and place it in *P_UNIQUE_NZ_ELTS;
    7356              :    * how many scalar fields in total are in CTOR,
    7357              :      and place it in *P_ELT_COUNT.
    7358              :    * whether the constructor is complete -- in the sense that every
    7359              :      meaningful byte is explicitly given a value --
    7360              :      and place it in *P_COMPLETE:
    7361              : 
    7362              :    Return whether or not CTOR is a valid static constant initializer, the same
    7363              :    as "initializer_constant_valid_p (CTOR, TREE_TYPE (CTOR)) != 0".  */
    7364              : 
    7365              : bool
    7366      1017150 : categorize_ctor_elements (const_tree ctor, HOST_WIDE_INT *p_nz_elts,
    7367              :                           HOST_WIDE_INT *p_unique_nz_elts,
    7368              :                           HOST_WIDE_INT *p_init_elts,
    7369              :                           ctor_completeness *p_complete)
    7370              : {
    7371      1017150 :   *p_nz_elts = 0;
    7372      1017150 :   *p_unique_nz_elts = 0;
    7373      1017150 :   *p_init_elts = 0;
    7374      1017150 :   *p_complete = {};
    7375              : 
    7376      1017150 :   return categorize_ctor_elements_1 (ctor, p_nz_elts, p_unique_nz_elts,
    7377      1017150 :                                      p_init_elts, p_complete);
    7378              : }
    7379              : 
    7380              : /* Return true if constructor CTOR is simple enough to be materialized
    7381              :    in an integer mode register.  Limit the size to WORDS words, which
    7382              :    is 1 by default.  */
    7383              : 
    7384              : bool
    7385        25528 : immediate_const_ctor_p (const_tree ctor, unsigned int words)
    7386              : {
    7387              :   /* Allow function to be called with a VAR_DECL's DECL_INITIAL.  */
    7388        25528 :   if (!ctor || TREE_CODE (ctor) != CONSTRUCTOR)
    7389              :     return false;
    7390              : 
    7391         2780 :   return TREE_CONSTANT (ctor)
    7392         2780 :          && !TREE_ADDRESSABLE (ctor)
    7393         2722 :          && CONSTRUCTOR_NELTS (ctor)
    7394         2696 :          && TREE_CODE (TREE_TYPE (ctor)) != ARRAY_TYPE
    7395          638 :          && int_expr_size (ctor) <= words * UNITS_PER_WORD
    7396         2969 :          && initializer_constant_valid_for_bitfield_p (ctor);
    7397              : }
    7398              : 
    7399              : /* TYPE is initialized by a constructor with NUM_ELTS elements, the last
    7400              :    of which had type LAST_TYPE.  Each element was itself a complete
    7401              :    initializer, in the sense that every meaningful byte was explicitly
    7402              :    given a value.  Return true if the same is true for the constructor
    7403              :    as a whole.  */
    7404              : 
    7405              : bool
    7406      1762216 : complete_ctor_at_level_p (const_tree type, HOST_WIDE_INT num_elts,
    7407              :                           const_tree last_type)
    7408              : {
    7409      1762216 :   if (TREE_CODE (type) == UNION_TYPE || TREE_CODE (type) == QUAL_UNION_TYPE)
    7410              :     {
    7411         9457 :       if (num_elts == 0)
    7412              :         {
    7413           24 :           if (flag_zero_init_padding_bits >= ZERO_INIT_PADDING_BITS_UNIONS)
    7414              :             return false;
    7415              : 
    7416              :           /* If the CONSTRUCTOR doesn't have any elts, it is
    7417              :              incomplete if the union has at least one field.  */
    7418          327 :           for (tree f = TYPE_FIELDS (type); f; f = DECL_CHAIN (f))
    7419          324 :             if (TREE_CODE (f) == FIELD_DECL)
    7420              :               return false;
    7421              : 
    7422              :           return true;
    7423              :         }
    7424              : 
    7425         9433 :       gcc_assert (num_elts == 1 && last_type);
    7426              : 
    7427         9433 :       if (flag_zero_init_padding_bits >= ZERO_INIT_PADDING_BITS_UNIONS)
    7428              :         /* ??? We could look at each element of the union, and find the
    7429              :            largest element.  Which would avoid comparing the size of the
    7430              :            initialized element against any tail padding in the union.
    7431              :            Doesn't seem worth the effort...  */
    7432          102 :         return simple_cst_equal (TYPE_SIZE (type), TYPE_SIZE (last_type)) == 1;
    7433              : 
    7434              :       return true;
    7435              :     }
    7436              : 
    7437      1752759 :   return count_type_elements (type, true) == num_elts;
    7438              : }
    7439              : 
    7440              : /* Return true if EXP contains mostly (3/4) zeros.  */
    7441              : 
    7442              : static bool
    7443       370346 : mostly_zeros_p (const_tree exp)
    7444              : {
    7445       370346 :   if (TREE_CODE (exp) == CONSTRUCTOR)
    7446              :     {
    7447           73 :       HOST_WIDE_INT nz_elts, unz_elts, init_elts;
    7448           73 :       ctor_completeness complete_p;
    7449              : 
    7450           73 :       categorize_ctor_elements (exp, &nz_elts, &unz_elts, &init_elts,
    7451              :                                 &complete_p);
    7452           73 :       return complete_p.sparse || nz_elts < init_elts / 4;
    7453              :     }
    7454              : 
    7455       370273 :   return initializer_zerop (exp);
    7456              : }
    7457              : 
    7458              : /* Return true if EXP contains all zeros.  */
    7459              : 
    7460              : static bool
    7461         1152 : all_zeros_p (const_tree exp)
    7462              : {
    7463         1152 :   if (TREE_CODE (exp) == CONSTRUCTOR)
    7464              :     {
    7465         1152 :       HOST_WIDE_INT nz_elts, unz_elts, init_elts;
    7466         1152 :       ctor_completeness complete_p;
    7467              : 
    7468         1152 :       categorize_ctor_elements (exp, &nz_elts, &unz_elts, &init_elts,
    7469              :                                 &complete_p);
    7470         1152 :       return nz_elts == 0;
    7471              :     }
    7472              : 
    7473            0 :   return initializer_zerop (exp);
    7474              : }
    7475              : 
    7476              : /* Helper function for store_constructor.
    7477              :    TARGET, BITSIZE, BITPOS, MODE, EXP are as for store_field.
    7478              :    CLEARED is as for store_constructor.
    7479              :    ALIAS_SET is the alias set to use for any stores.
    7480              :    If REVERSE is true, the store is to be done in reverse order.
    7481              : 
    7482              :    This provides a recursive shortcut back to store_constructor when it isn't
    7483              :    necessary to go through store_field.  This is so that we can pass through
    7484              :    the cleared field to let store_constructor know that we may not have to
    7485              :    clear a substructure if the outer structure has already been cleared.  */
    7486              : 
    7487              : static void
    7488        38265 : store_constructor_field (rtx target, poly_uint64 bitsize, poly_int64 bitpos,
    7489              :                          poly_uint64 bitregion_start,
    7490              :                          poly_uint64 bitregion_end,
    7491              :                          machine_mode mode,
    7492              :                          tree exp, int cleared,
    7493              :                          alias_set_type alias_set, bool reverse)
    7494              : {
    7495        38265 :   poly_int64 bytepos;
    7496        38265 :   poly_uint64 bytesize;
    7497        38265 :   if (TREE_CODE (exp) == CONSTRUCTOR
    7498              :       /* We can only call store_constructor recursively if the size and
    7499              :          bit position are on a byte boundary.  */
    7500        38265 :       && multiple_p (bitpos, BITS_PER_UNIT, &bytepos)
    7501           46 :       && maybe_ne (bitsize, 0U)
    7502        38219 :       && multiple_p (bitsize, BITS_PER_UNIT, &bytesize)
    7503              :       /* If we have a nonzero bitpos for a register target, then we just
    7504              :          let store_field do the bitfield handling.  This is unlikely to
    7505              :          generate unnecessary clear instructions anyways.  */
    7506        38311 :       && (known_eq (bitpos, 0) || MEM_P (target)))
    7507              :     {
    7508           46 :       if (MEM_P (target))
    7509              :         {
    7510            4 :           machine_mode target_mode = GET_MODE (target);
    7511            4 :           if (target_mode != BLKmode
    7512            4 :               && !multiple_p (bitpos, GET_MODE_ALIGNMENT (target_mode)))
    7513              :             target_mode = BLKmode;
    7514            4 :           target = adjust_address (target, target_mode, bytepos);
    7515              :         }
    7516              : 
    7517              : 
    7518              :       /* Update the alias set, if required.  */
    7519            4 :       if (MEM_P (target) && ! MEM_KEEP_ALIAS_SET_P (target)
    7520           50 :           && MEM_ALIAS_SET (target) != 0)
    7521              :         {
    7522            0 :           target = copy_rtx (target);
    7523            0 :           set_mem_alias_set (target, alias_set);
    7524              :         }
    7525              : 
    7526           46 :       store_constructor (exp, target, cleared, bytesize, reverse);
    7527              :     }
    7528              :   else
    7529        38219 :     store_field (target, bitsize, bitpos, bitregion_start, bitregion_end, mode,
    7530              :                  exp, alias_set, false, reverse);
    7531        38265 : }
    7532              : 
    7533              : 
    7534              : /* Returns the number of FIELD_DECLs in TYPE.  */
    7535              : 
    7536              : static int
    7537        71893 : fields_length (const_tree type)
    7538              : {
    7539        71893 :   tree t = TYPE_FIELDS (type);
    7540        71893 :   int count = 0;
    7541              : 
    7542       988693 :   for (; t; t = DECL_CHAIN (t))
    7543       916800 :     if (TREE_CODE (t) == FIELD_DECL)
    7544       313730 :       ++count;
    7545              : 
    7546        71893 :   return count;
    7547              : }
    7548              : 
    7549              : /* Store the value of constructor EXP into the rtx TARGET.
    7550              :    TARGET is either a REG or a MEM; we know it cannot conflict, since
    7551              :    safe_from_p has been called.
    7552              :    CLEARED is true if TARGET is known to have been zero'd.
    7553              :    If the constructor EXP has a vector type then elements of TARGET for which
    7554              :    there is no corresponding element in EXP are zero'd.  For a variable-length
    7555              :    vector type, only elements up to the minimum number of subparts of the type
    7556              :    are explicitly zero'd; any elements beyond that are implicitly zero.
    7557              :    SIZE is the number of bytes of TARGET we are allowed to modify: this
    7558              :    may not be the same as the size of EXP if we are assigning to a field
    7559              :    which has been packed to exclude padding bits.
    7560              :    If REVERSE is true, the store is to be done in reverse order.  */
    7561              : 
    7562              : void
    7563       254476 : store_constructor (tree exp, rtx target, int cleared, poly_int64 size,
    7564              :                    bool reverse)
    7565              : {
    7566       254476 :   tree type = TREE_TYPE (exp);
    7567       254476 :   HOST_WIDE_INT exp_size = int_size_in_bytes (type);
    7568       254476 :   gcc_assert (known_ge (size, 0));
    7569       254476 :   poly_int64 bitregion_end = known_gt (size, 0) ? size * BITS_PER_UNIT - 1 : 0;
    7570              : 
    7571       254476 :   switch (TREE_CODE (type))
    7572              :     {
    7573        72587 :     case RECORD_TYPE:
    7574        72587 :     case UNION_TYPE:
    7575        72587 :     case QUAL_UNION_TYPE:
    7576        72587 :       {
    7577        72587 :         unsigned HOST_WIDE_INT idx;
    7578        72587 :         tree field, value;
    7579              : 
    7580              :         /* The storage order is specified for every aggregate type.  */
    7581        72587 :         reverse = TYPE_REVERSE_STORAGE_ORDER (type);
    7582              : 
    7583              :         /* If size is zero or the target is already cleared, do nothing.  */
    7584        72587 :         if (known_eq (size, 0) || cleared)
    7585              :           cleared = 1;
    7586              :         /* We either clear the aggregate or indicate the value is dead.  */
    7587        72587 :         else if ((TREE_CODE (type) == UNION_TYPE
    7588        72587 :                   || TREE_CODE (type) == QUAL_UNION_TYPE)
    7589        73096 :                  && ! CONSTRUCTOR_ELTS (exp))
    7590              :           /* If the constructor is empty, clear the union.  */
    7591              :           {
    7592          460 :             clear_storage (target, expr_size (exp), BLOCK_OP_NORMAL);
    7593          460 :             cleared = 1;
    7594              :           }
    7595              : 
    7596              :         /* If we are building a static constructor into a register,
    7597              :            set the initial value as zero so we can fold the value into
    7598              :            a constant.  But if more than one register is involved,
    7599              :            this probably loses.  */
    7600         4561 :         else if (REG_P (target) && TREE_STATIC (exp)
    7601        72717 :                  && known_le (GET_MODE_SIZE (GET_MODE (target)),
    7602              :                               REGMODE_NATURAL_SIZE (GET_MODE (target))))
    7603              :           {
    7604          234 :             emit_move_insn (target, CONST0_RTX (GET_MODE (target)));
    7605          234 :             cleared = 1;
    7606              :           }
    7607              : 
    7608              :         /* If the constructor has fewer fields than the structure or
    7609              :            if we are initializing the structure to mostly zeros, clear
    7610              :            the whole structure first.  Don't do this if TARGET is a
    7611              :            register whose mode size isn't equal to SIZE since
    7612              :            clear_storage can't handle this case.  */
    7613        71938 :         else if ((((int) CONSTRUCTOR_NELTS (exp) != fields_length (type))
    7614           32 :                   || mostly_zeros_p (exp))
    7615        71897 :                  && (!REG_P (target)
    7616         8644 :                      || known_eq (GET_MODE_SIZE (GET_MODE (target)), size)))
    7617              :           {
    7618        82616 :             clear_storage (target, gen_int_mode (size, Pmode),
    7619              :                            BLOCK_OP_NORMAL);
    7620        71865 :             cleared = 1;
    7621              :           }
    7622              : 
    7623        72587 :         if (REG_P (target) && !cleared)
    7624            5 :           emit_clobber (target);
    7625              : 
    7626              :         /* Store each element of the constructor into the
    7627              :            corresponding field of TARGET.  */
    7628        72773 :         FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (exp), idx, field, value)
    7629              :           {
    7630          186 :             machine_mode mode;
    7631          186 :             HOST_WIDE_INT bitsize;
    7632          186 :             HOST_WIDE_INT bitpos = 0;
    7633          186 :             tree offset;
    7634          186 :             rtx to_rtx = target;
    7635              : 
    7636              :             /* Just ignore missing fields.  We cleared the whole
    7637              :                structure, above, if any fields are missing.  */
    7638          186 :             if (field == 0)
    7639          186 :               continue;
    7640              : 
    7641          186 :             if (cleared && initializer_zerop (value))
    7642           17 :               continue;
    7643              : 
    7644              :             /* Variable sized arrays are ignored.  */
    7645          169 :             tree decl_size = DECL_SIZE (field);
    7646          169 :             if (!decl_size)
    7647            4 :               continue;
    7648              : 
    7649          165 :             if (tree_fits_uhwi_p (decl_size))
    7650          165 :               bitsize = tree_to_uhwi (decl_size);
    7651              :             else
    7652            0 :               gcc_unreachable ();
    7653              : 
    7654          165 :             mode = DECL_MODE (field);
    7655          165 :             if (DECL_BIT_FIELD (field))
    7656           24 :               mode = VOIDmode;
    7657              : 
    7658          165 :             offset = DECL_FIELD_OFFSET (field);
    7659          165 :             if (tree_fits_shwi_p (offset)
    7660          165 :                 && tree_fits_shwi_p (bit_position (field)))
    7661              :               {
    7662          165 :                 bitpos = int_bit_position (field);
    7663          165 :                 offset = NULL_TREE;
    7664              :               }
    7665              :             else
    7666            0 :               gcc_unreachable ();
    7667              : 
    7668              :             /* If this initializes a field that is smaller than a
    7669              :                word, at the start of a word, try to widen it to a full
    7670              :                word.  This special case allows us to output C++ member
    7671              :                function initializations in a form that the optimizers
    7672              :                can understand.  */
    7673          165 :             if (WORD_REGISTER_OPERATIONS
    7674              :                 && REG_P (target)
    7675              :                 && bitsize < BITS_PER_WORD
    7676              :                 && bitpos % BITS_PER_WORD == 0
    7677              :                 && GET_MODE_CLASS (mode) == MODE_INT
    7678              :                 && TREE_CODE (value) == INTEGER_CST
    7679              :                 && exp_size >= 0
    7680              :                 && bitpos + BITS_PER_WORD <= exp_size * BITS_PER_UNIT)
    7681              :               {
    7682              :                 type = TREE_TYPE (value);
    7683              : 
    7684              :                 if (TYPE_PRECISION (type) < BITS_PER_WORD)
    7685              :                   {
    7686              :                     type = lang_hooks.types.type_for_mode
    7687              :                       (word_mode, TYPE_UNSIGNED (type));
    7688              :                     value = fold_convert (type, value);
    7689              :                     /* Make sure the bits beyond the original bitsize are zero
    7690              :                        so that we can correctly avoid extra zeroing stores in
    7691              :                        later constructor elements.  */
    7692              :                     tree bitsize_mask
    7693              :                       = wide_int_to_tree (type, wi::mask (bitsize, false,
    7694              :                                                            BITS_PER_WORD));
    7695              :                     value = fold_build2 (BIT_AND_EXPR, type, value, bitsize_mask);
    7696              :                   }
    7697              : 
    7698              :                 if (BYTES_BIG_ENDIAN)
    7699              :                   value
    7700              :                    = fold_build2 (LSHIFT_EXPR, type, value,
    7701              :                                    build_int_cst (type,
    7702              :                                                   BITS_PER_WORD - bitsize));
    7703              :                 bitsize = BITS_PER_WORD;
    7704              :                 mode = word_mode;
    7705              :               }
    7706              : 
    7707           47 :             if (MEM_P (to_rtx) && !MEM_KEEP_ALIAS_SET_P (to_rtx)
    7708          212 :                 && DECL_NONADDRESSABLE_P (field))
    7709              :               {
    7710            0 :                 to_rtx = copy_rtx (to_rtx);
    7711            0 :                 MEM_KEEP_ALIAS_SET_P (to_rtx) = 1;
    7712              :               }
    7713              : 
    7714          165 :             store_constructor_field (to_rtx, bitsize, bitpos,
    7715          165 :                                      0, bitregion_end, mode,
    7716              :                                      value, cleared,
    7717          165 :                                      get_alias_set (TREE_TYPE (field)),
    7718              :                                      reverse);
    7719              :           }
    7720              :         break;
    7721              :       }
    7722        40525 :     case ARRAY_TYPE:
    7723        40525 :       {
    7724        40525 :         tree value, index;
    7725        40525 :         unsigned HOST_WIDE_INT i, j = 0;
    7726        40525 :         bool need_to_clear;
    7727        40525 :         tree domain;
    7728        40525 :         tree elttype = TREE_TYPE (type);
    7729        40525 :         bool const_bounds_p;
    7730        40525 :         unsigned HOST_WIDE_INT minelt = 0;
    7731        40525 :         unsigned HOST_WIDE_INT maxelt = 0;
    7732              : 
    7733              :         /* The storage order is specified for every aggregate type.  */
    7734        40525 :         reverse = TYPE_REVERSE_STORAGE_ORDER (type);
    7735              : 
    7736        40525 :         domain = TYPE_DOMAIN (type);
    7737        40525 :         const_bounds_p = (TYPE_MIN_VALUE (domain)
    7738        40525 :                           && TYPE_MAX_VALUE (domain)
    7739        40525 :                           && tree_fits_uhwi_p (TYPE_MIN_VALUE (domain))
    7740        81050 :                           && tree_fits_uhwi_p (TYPE_MAX_VALUE (domain)));
    7741              : 
    7742              :         /* If we have constant bounds for the range of the type, get them.  */
    7743        40525 :         if (const_bounds_p)
    7744              :           {
    7745        40525 :             minelt = tree_to_uhwi (TYPE_MIN_VALUE (domain));
    7746        40525 :             maxelt = tree_to_uhwi (TYPE_MAX_VALUE (domain));
    7747              :           }
    7748              : 
    7749              :         /* If the constructor has fewer elements than the array, clear
    7750              :            the whole array first.  Similarly if this is static
    7751              :            constructor of a non-BLKmode object.  */
    7752        40525 :         if (cleared)
    7753              :           need_to_clear = false;
    7754        40479 :         else if (REG_P (target) && TREE_STATIC (exp))
    7755              :           need_to_clear = true;
    7756              :         else
    7757              :           {
    7758        40372 :             unsigned HOST_WIDE_INT idx;
    7759        40372 :             unsigned HOST_WIDE_INT count = 0, zero_count = 0;
    7760        40372 :             need_to_clear = ! const_bounds_p;
    7761              : 
    7762              :             /* This loop is a more accurate version of the loop in
    7763              :                mostly_zeros_p (it handles RANGE_EXPR in an index).  It
    7764              :                is also needed to check for missing elements.  */
    7765        40380 :             FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (exp), idx, index, value)
    7766              :               {
    7767            8 :                 unsigned HOST_WIDE_INT this_node_count;
    7768              : 
    7769            8 :                 if (need_to_clear)
    7770              :                   break;
    7771              : 
    7772            8 :                 if (index != NULL_TREE && TREE_CODE (index) == RANGE_EXPR)
    7773              :                   {
    7774            0 :                     tree lo_index = TREE_OPERAND (index, 0);
    7775            0 :                     tree hi_index = TREE_OPERAND (index, 1);
    7776              : 
    7777            0 :                     if (! tree_fits_uhwi_p (lo_index)
    7778            0 :                         || ! tree_fits_uhwi_p (hi_index))
    7779              :                       {
    7780              :                         need_to_clear = true;
    7781              :                         break;
    7782              :                       }
    7783              : 
    7784            0 :                     this_node_count = (tree_to_uhwi (hi_index)
    7785            0 :                                        - tree_to_uhwi (lo_index) + 1);
    7786            0 :                   }
    7787            8 :                 else if (TREE_CODE (value) == RAW_DATA_CST)
    7788            0 :                   this_node_count = RAW_DATA_LENGTH (value);
    7789              :                 else
    7790              :                   this_node_count = 1;
    7791              : 
    7792            8 :                 count += this_node_count;
    7793            8 :                 if (mostly_zeros_p (value))
    7794            0 :                   zero_count += this_node_count;
    7795              :               }
    7796              : 
    7797              :             /* Clear the entire array first if there are any missing
    7798              :                elements, or if the incidence of zero elements is >=
    7799              :                75%.  */
    7800        40372 :             if (! need_to_clear
    7801        40372 :                 && (count < maxelt - minelt + 1
    7802            1 :                     || 4 * zero_count >= 3 * count))
    7803              :               need_to_clear = true;
    7804              :           }
    7805              : 
    7806        40478 :         if (need_to_clear && maybe_gt (size, 0))
    7807              :           {
    7808        40478 :             if (REG_P (target))
    7809         1696 :               emit_move_insn (target, CONST0_RTX (GET_MODE (target)));
    7810              :             else
    7811        43556 :               clear_storage (target, gen_int_mode (size, Pmode),
    7812              :                              BLOCK_OP_NORMAL);
    7813              :             cleared = 1;
    7814              :           }
    7815              : 
    7816        40525 :         if (!cleared && REG_P (target))
    7817              :           /* Inform later passes that the old value is dead.  */
    7818            0 :           emit_clobber (target);
    7819              : 
    7820              :         /* Store each element of the constructor into the
    7821              :            corresponding element of TARGET, determined by counting the
    7822              :            elements.  */
    7823        41641 :         FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (exp), i, index, value)
    7824              :           {
    7825         1116 :             machine_mode mode;
    7826         1116 :             poly_int64 bitsize;
    7827         1116 :             HOST_WIDE_INT bitpos;
    7828         1116 :             rtx xtarget = target;
    7829              : 
    7830         1116 :             if (cleared && initializer_zerop (value))
    7831              :               {
    7832          672 :                 if (TREE_CODE (value) == RAW_DATA_CST)
    7833            0 :                   j += RAW_DATA_LENGTH (value) - 1;
    7834          674 :                 continue;
    7835              :               }
    7836              : 
    7837          444 :             mode = TYPE_MODE (elttype);
    7838          444 :             if (mode != BLKmode)
    7839          888 :               bitsize = GET_MODE_BITSIZE (mode);
    7840            0 :             else if (!poly_int_tree_p (TYPE_SIZE (elttype), &bitsize))
    7841            0 :               bitsize = -1;
    7842              : 
    7843          444 :             if (index != NULL_TREE && TREE_CODE (index) == RANGE_EXPR)
    7844              :               {
    7845            0 :                 tree lo_index = TREE_OPERAND (index, 0);
    7846            0 :                 tree hi_index = TREE_OPERAND (index, 1);
    7847            0 :                 rtx index_r;
    7848            0 :                 unsigned HOST_WIDE_INT lo, hi, count;
    7849            0 :                 tree offset;
    7850              : 
    7851            0 :                 gcc_assert (TREE_CODE (value) != RAW_DATA_CST);
    7852              : 
    7853              :                 /* If the range is constant and "small", unroll the loop.  */
    7854            0 :                 if (const_bounds_p
    7855            0 :                     && tree_fits_uhwi_p (lo_index)
    7856            0 :                     && tree_fits_uhwi_p (hi_index)
    7857            0 :                     && (lo = tree_to_uhwi (lo_index),
    7858            0 :                         hi = tree_to_uhwi (hi_index),
    7859            0 :                         count = hi - lo + 1,
    7860            0 :                         (!MEM_P (target)
    7861            0 :                          || count <= 2
    7862            0 :                          || (tree_fits_uhwi_p (TYPE_SIZE (elttype))
    7863            0 :                              && (tree_to_uhwi (TYPE_SIZE (elttype)) * count
    7864              :                                  <= 40 * 8)))))
    7865              :                   {
    7866            0 :                     lo -= minelt;  hi -= minelt;
    7867            0 :                     for (; lo <= hi; lo++)
    7868              :                       {
    7869            0 :                         bitpos = lo * tree_to_uhwi (TYPE_SIZE (elttype));
    7870              : 
    7871            0 :                         if (MEM_P (target)
    7872            0 :                             && !MEM_KEEP_ALIAS_SET_P (target)
    7873            0 :                             && TREE_CODE (type) == ARRAY_TYPE
    7874            0 :                             && TYPE_NONALIASED_COMPONENT (type))
    7875              :                           {
    7876            0 :                             target = copy_rtx (target);
    7877            0 :                             MEM_KEEP_ALIAS_SET_P (target) = 1;
    7878              :                           }
    7879              : 
    7880            0 :                         store_constructor_field
    7881            0 :                           (target, bitsize, bitpos, 0, bitregion_end,
    7882              :                            mode, value, cleared,
    7883              :                            get_alias_set (elttype), reverse);
    7884              :                       }
    7885              :                   }
    7886              :                 else
    7887              :                   {
    7888            0 :                     rtx_code_label *loop_start = gen_label_rtx ();
    7889            0 :                     rtx_code_label *loop_end = gen_label_rtx ();
    7890            0 :                     tree exit_cond;
    7891              : 
    7892            0 :                     expand_normal (hi_index);
    7893              : 
    7894            0 :                     index = build_decl (EXPR_LOCATION (exp),
    7895              :                                         VAR_DECL, NULL_TREE, domain);
    7896            0 :                     index_r = gen_reg_rtx (promote_decl_mode (index, NULL));
    7897            0 :                     SET_DECL_RTL (index, index_r);
    7898            0 :                     store_expr (lo_index, index_r, 0, false, reverse);
    7899              : 
    7900              :                     /* Build the head of the loop.  */
    7901            0 :                     do_pending_stack_adjust ();
    7902            0 :                     emit_label (loop_start);
    7903              : 
    7904              :                     /* Assign value to element index.  */
    7905            0 :                     offset = fold_build2 (MINUS_EXPR,
    7906              :                                           TREE_TYPE (index),
    7907              :                                           index,
    7908              :                                           TYPE_MIN_VALUE (domain));
    7909              : 
    7910            0 :                     offset = size_binop (MULT_EXPR,
    7911              :                                          fold_convert (sizetype, offset),
    7912              :                                          TYPE_SIZE_UNIT (elttype));
    7913              : 
    7914            0 :                     xtarget = offset_address (target,
    7915              :                                               expand_normal (offset),
    7916              :                                               highest_pow2_factor (offset));
    7917            0 :                     xtarget = adjust_address (xtarget, mode, 0);
    7918            0 :                     if (TREE_CODE (value) == CONSTRUCTOR)
    7919            0 :                       store_constructor (value, xtarget, cleared,
    7920              :                                          exact_div (bitsize, BITS_PER_UNIT),
    7921              :                                          reverse);
    7922              :                     else
    7923            0 :                       store_expr (value, xtarget, 0, false, reverse);
    7924              : 
    7925              :                     /* Generate a conditional jump to exit the loop.  */
    7926            0 :                     exit_cond = build2 (LT_EXPR, integer_type_node,
    7927              :                                         index, hi_index);
    7928            0 :                     jumpif (exit_cond, loop_end,
    7929              :                             profile_probability::uninitialized ());
    7930              : 
    7931              :                     /* Update the loop counter, and jump to the head of
    7932              :                        the loop.  */
    7933            0 :                     expand_assignment (index,
    7934            0 :                                        build2 (PLUS_EXPR, TREE_TYPE (index),
    7935              :                                                index, integer_one_node),
    7936              :                                        false);
    7937              : 
    7938            0 :                     emit_jump (loop_start);
    7939              : 
    7940              :                     /* Build the end of the loop.  */
    7941            0 :                     emit_label (loop_end);
    7942              :                   }
    7943              :               }
    7944          444 :             else if ((index && !tree_fits_uhwi_p (index))
    7945          444 :                      || !tree_fits_uhwi_p (TYPE_SIZE (elttype)))
    7946              :               {
    7947            0 :                 tree offset;
    7948              : 
    7949            0 :                 gcc_assert (TREE_CODE (value) != RAW_DATA_CST);
    7950            0 :                 if (index)
    7951            0 :                   offset = fold_build2 (MINUS_EXPR,
    7952              :                                         TREE_TYPE (index),
    7953              :                                         index,
    7954              :                                         TYPE_MIN_VALUE (domain));
    7955              :                 else
    7956            0 :                   offset = size_int (i + j);
    7957              : 
    7958            0 :                 offset = size_binop (MULT_EXPR,
    7959              :                                      fold_convert (sizetype, offset),
    7960              :                                      TYPE_SIZE_UNIT (elttype));
    7961            0 :                 xtarget = offset_address (target,
    7962              :                                           expand_normal (offset),
    7963              :                                           highest_pow2_factor (offset));
    7964            0 :                 xtarget = adjust_address (xtarget, mode, 0);
    7965            0 :                 store_expr (value, xtarget, 0, false, reverse);
    7966              :               }
    7967              :             else
    7968              :               {
    7969          444 :                 if (index)
    7970          888 :                   bitpos = ((tree_to_uhwi (index) - minelt)
    7971          444 :                             * tree_to_uhwi (TYPE_SIZE (elttype)));
    7972              :                 else
    7973            0 :                   bitpos = ((i + j) * tree_to_uhwi (TYPE_SIZE (elttype)));
    7974              : 
    7975           12 :                 if (MEM_P (target) && !MEM_KEEP_ALIAS_SET_P (target)
    7976           12 :                     && TREE_CODE (type) == ARRAY_TYPE
    7977          456 :                     && TYPE_NONALIASED_COMPONENT (type))
    7978              :                   {
    7979            0 :                     target = copy_rtx (target);
    7980            0 :                     MEM_KEEP_ALIAS_SET_P (target) = 1;
    7981              :                   }
    7982          444 :                 if (TREE_CODE (value) != RAW_DATA_CST)
    7983          440 :                   store_constructor_field (target, bitsize, bitpos, 0,
    7984          440 :                                            bitregion_end, mode, value,
    7985              :                                            cleared, get_alias_set (elttype),
    7986              :                                            reverse);
    7987              :                 else
    7988              :                   {
    7989            4 :                     j += RAW_DATA_LENGTH (value) - 1;
    7990            4 :                     gcc_assert (known_eq (bitsize, BITS_PER_UNIT));
    7991            4 :                     rtx to_rtx = adjust_address (target, mode,
    7992              :                                                  bitpos / BITS_PER_UNIT);
    7993              : 
    7994            4 :                     if (to_rtx == target)
    7995            0 :                       to_rtx = copy_rtx (to_rtx);
    7996              : 
    7997            4 :                     if (!MEM_KEEP_ALIAS_SET_P (to_rtx)
    7998            8 :                         && MEM_ALIAS_SET (to_rtx) != 0)
    7999            0 :                       set_mem_alias_set (to_rtx, get_alias_set (elttype));
    8000              : 
    8001            8 :                     if (can_store_by_pieces (RAW_DATA_LENGTH (value),
    8002              :                                              raw_data_cst_read_str,
    8003              :                                              (void *) value,
    8004            4 :                                              MEM_ALIGN (target), false))
    8005              :                       {
    8006            4 :                         store_by_pieces (target, RAW_DATA_LENGTH (value),
    8007              :                                          raw_data_cst_read_str, (void *) value,
    8008            2 :                                          MEM_ALIGN (target), false,
    8009              :                                          RETURN_BEGIN);
    8010            2 :                         continue;
    8011              :                       }
    8012              : 
    8013            2 :                     elttype
    8014            2 :                       = build_array_type_nelts (TREE_TYPE (value),
    8015            2 :                                                 RAW_DATA_LENGTH (value));
    8016            2 :                     tree ctor = build_constructor_single (elttype, NULL_TREE,
    8017              :                                                           value);
    8018            2 :                     ctor = tree_output_constant_def (ctor);
    8019            2 :                     mode = TYPE_MODE (type);
    8020            2 :                     store_constructor_field (target,
    8021            2 :                                              bitsize * RAW_DATA_LENGTH (value),
    8022            2 :                                              bitpos, 0, bitregion_end, mode,
    8023              :                                              ctor, cleared,
    8024              :                                              get_alias_set (elttype), reverse);
    8025              :                   }
    8026              :               }
    8027              :           }
    8028              :         break;
    8029              :       }
    8030              : 
    8031       141364 :     case VECTOR_TYPE:
    8032       141364 :       {
    8033       141364 :         unsigned HOST_WIDE_INT idx;
    8034       141364 :         constructor_elt *ce;
    8035       141364 :         bool need_to_clear;
    8036       141364 :         insn_code icode = CODE_FOR_nothing;
    8037       141364 :         tree elt;
    8038       141364 :         tree elttype = TREE_TYPE (type);
    8039       141364 :         int elt_size = vector_element_bits (type);
    8040       141364 :         machine_mode eltmode = TYPE_MODE (elttype);
    8041       141364 :         poly_int64 bitsize;
    8042       141364 :         poly_int64 bitpos;
    8043       141364 :         rtvec vector = NULL;
    8044       141364 :         poly_uint64 n_elts;
    8045       141364 :         unsigned HOST_WIDE_INT const_n_elts;
    8046       141364 :         alias_set_type alias;
    8047       141364 :         bool vec_vec_init_p = false;
    8048       141364 :         machine_mode mode = GET_MODE (target);
    8049              : 
    8050       141364 :         gcc_assert (eltmode != BLKmode);
    8051              : 
    8052              :         /* Try using vec_duplicate_optab for uniform vectors.  */
    8053       141364 :         icode = optab_handler (vec_duplicate_optab, mode);
    8054       141364 :         if (!TREE_SIDE_EFFECTS (exp)
    8055       141364 :             && VECTOR_MODE_P (mode)
    8056       137760 :             && icode != CODE_FOR_nothing
    8057              :             /* If the vec_duplicate target pattern does not specify an element
    8058              :                mode check that eltmode is the normal inner mode of the
    8059              :                requested vector mode.  But if the target allows eltmode
    8060              :                explicitly go ahead and use it.  */
    8061        93949 :             && (eltmode == GET_MODE_INNER (mode)
    8062            0 :                 || insn_data[icode].operand[1].mode == eltmode)
    8063        93949 :             && (elt = uniform_vector_p (exp))
    8064       160307 :             && !VECTOR_TYPE_P (TREE_TYPE (elt)))
    8065              :           {
    8066        18943 :             class expand_operand ops[2];
    8067        18943 :             create_output_operand (&ops[0], target, mode);
    8068        18943 :             create_input_operand (&ops[1], expand_normal (elt), eltmode);
    8069        18943 :             expand_insn (icode, 2, ops);
    8070        18943 :             if (!rtx_equal_p (target, ops[0].value))
    8071            0 :               emit_move_insn (target, ops[0].value);
    8072        18943 :             break;
    8073              :           }
    8074              :         /* Use sign-extension for uniform boolean vectors with
    8075              :            integer modes and single-bit mask entries.
    8076              :            Effectively "vec_duplicate" for bitmasks.  */
    8077       122421 :         if (elt_size == 1
    8078          146 :             && !TREE_SIDE_EFFECTS (exp)
    8079          146 :             && VECTOR_BOOLEAN_TYPE_P (type)
    8080          146 :             && SCALAR_INT_MODE_P (TYPE_MODE (type))
    8081          146 :             && (elt = uniform_vector_p (exp))
    8082          143 :             && !VECTOR_TYPE_P (TREE_TYPE (elt))
    8083       122421 :             && !BYTES_BIG_ENDIAN)
    8084              :           {
    8085          143 :             rtx op0 = force_reg (TYPE_MODE (TREE_TYPE (elt)),
    8086              :                                  expand_normal (elt));
    8087          143 :             rtx tmp = gen_reg_rtx (mode);
    8088          143 :             convert_move (tmp, op0, 0);
    8089              : 
    8090              :             /* Ensure no excess bits are set.
    8091              :                GCN needs this for nunits < 64.
    8092              :                x86 needs this for nunits < 8.  */
    8093          143 :             unsigned int nunits = TYPE_VECTOR_SUBPARTS (type).to_constant ();
    8094          143 :             if (maybe_ne (GET_MODE_PRECISION (mode), nunits))
    8095            2 :               tmp = expand_binop (mode, and_optab, tmp,
    8096            2 :                                   GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1),
    8097              :                                   target, true, OPTAB_WIDEN);
    8098          143 :             if (tmp != target)
    8099          141 :               emit_move_insn (target, tmp);
    8100              :             break;
    8101              :           }
    8102              : 
    8103       122278 :         n_elts = TYPE_VECTOR_SUBPARTS (type);
    8104       122278 :         if (REG_P (target)
    8105       119021 :             && VECTOR_MODE_P (mode))
    8106              :           {
    8107       118817 :             const_n_elts = 0;
    8108       118817 :             if (CONSTRUCTOR_NELTS (exp)
    8109       118817 :                 && (TREE_CODE (TREE_TYPE (CONSTRUCTOR_ELT (exp, 0)->value))
    8110              :                     == VECTOR_TYPE))
    8111              :               {
    8112         1492 :                 tree etype = TREE_TYPE (CONSTRUCTOR_ELT (exp, 0)->value);
    8113         1492 :                 gcc_assert (known_eq (CONSTRUCTOR_NELTS (exp)
    8114              :                                       * TYPE_VECTOR_SUBPARTS (etype),
    8115              :                                       n_elts));
    8116              : 
    8117         4476 :                 icode = convert_optab_handler (vec_init_optab, mode,
    8118         1492 :                                                TYPE_MODE (etype));
    8119         1492 :                 const_n_elts = CONSTRUCTOR_NELTS (exp);
    8120         1492 :                 vec_vec_init_p = icode != CODE_FOR_nothing;
    8121              :               }
    8122       234650 :             else if (exact_div (n_elts, GET_MODE_NUNITS (eltmode))
    8123       117325 :                         .is_constant (&const_n_elts))
    8124              :               {
    8125              :                 /* For a non-const type vector, we check it is made up of
    8126              :                    similarly non-const type vectors. */
    8127       117325 :                 icode = convert_optab_handler (vec_init_optab, mode, eltmode);
    8128              :               }
    8129              :             else
    8130              :               {
    8131              :                 /* Handle variable-length vector types.  */
    8132              :                 icode = convert_optab_handler (vec_init_optab, mode, eltmode);
    8133              :                 const_n_elts = constant_lower_bound (n_elts);
    8134              :               }
    8135              : 
    8136       118817 :             if (const_n_elts && icode != CODE_FOR_nothing)
    8137              :               {
    8138       118062 :                 vector = rtvec_alloc (const_n_elts);
    8139       560668 :                 for (unsigned int k = 0; k < const_n_elts; k++)
    8140       324544 :                   RTVEC_ELT (vector, k) = CONST0_RTX (eltmode);
    8141              :               }
    8142              :           }
    8143              :         else
    8144              :           gcc_assert (n_elts.is_constant ());
    8145              : 
    8146              :         /* Compute the size of the elements in the CTOR.  It differs
    8147              :            from the size of the vector type elements only when the
    8148              :            CTOR elements are vectors themselves.  */
    8149       122278 :         tree val_type = (CONSTRUCTOR_NELTS (exp) != 0
    8150       122278 :                          ? TREE_TYPE (CONSTRUCTOR_ELT (exp, 0)->value)
    8151       122278 :                          : elttype);
    8152       122278 :         if (VECTOR_TYPE_P (val_type))
    8153         1845 :           bitsize = tree_to_poly_uint64 (TYPE_SIZE (val_type));
    8154              :         else
    8155       120433 :           bitsize = elt_size;
    8156              : 
    8157              :         /* If the constructor has fewer elements than the vector,
    8158              :            clear the whole array first.  Similarly if this is static
    8159              :            constructor of a non-BLKmode object.  */
    8160       122278 :         if (cleared)
    8161              :           need_to_clear = false;
    8162       122278 :         else if (REG_P (target) && TREE_STATIC (exp))
    8163              :           need_to_clear = true;
    8164              :         else
    8165              :           {
    8166              :             poly_uint64 count = 0, zero_count = 0;
    8167              :             tree value;
    8168              : 
    8169       492543 :             FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, value)
    8170              :               {
    8171       370265 :                 poly_int64 n_elts_here = exact_div (bitsize, elt_size);
    8172       370265 :                 count += n_elts_here;
    8173       370265 :                 if (mostly_zeros_p (value))
    8174       370265 :                   zero_count += n_elts_here;
    8175              :               }
    8176              : 
    8177              :             /* Clear the entire vector first if there are any missing elements,
    8178              :                or if the incidence of zero elements is >= 75%.  */
    8179       122278 :             need_to_clear = (maybe_lt (count, n_elts)
    8180       122278 :                              || maybe_gt (4 * zero_count, 3 * count));
    8181              :           }
    8182              : 
    8183         1358 :         if (need_to_clear && maybe_gt (size, 0) && !vector)
    8184              :           {
    8185          766 :             if (REG_P (target))
    8186           29 :               emit_move_insn (target, CONST0_RTX (mode));
    8187              :             else
    8188          737 :               clear_storage (target, gen_int_mode (size, Pmode),
    8189              :                              BLOCK_OP_NORMAL);
    8190              :             cleared = 1;
    8191              :           }
    8192              : 
    8193              :         /* Inform later passes that the old value is dead.  */
    8194       122278 :         if (!cleared && !vector && REG_P (target) && maybe_gt (n_elts, 1u))
    8195              :           {
    8196          603 :             emit_move_insn (target, CONST0_RTX (mode));
    8197          603 :             cleared = 1;
    8198              :           }
    8199              : 
    8200       122278 :         if (MEM_P (target))
    8201         3257 :           alias = MEM_ALIAS_SET (target);
    8202              :         else
    8203       119021 :           alias = get_alias_set (elttype);
    8204              : 
    8205              :         /* Store each element of the constructor into the corresponding
    8206              :            element of TARGET, determined by counting the elements.  */
    8207       122278 :         HOST_WIDE_INT chunk_size = 0;
    8208       122278 :         bool chunk_multiple_p = constant_multiple_p (bitsize, elt_size,
    8209              :                                                      &chunk_size);
    8210       122278 :         gcc_assert (chunk_multiple_p || vec_vec_init_p);
    8211              : 
    8212       492543 :         for (idx = 0; vec_safe_iterate (CONSTRUCTOR_ELTS (exp), idx, &ce);
    8213              :              idx++)
    8214              :           {
    8215       370265 :             HOST_WIDE_INT eltpos;
    8216       370265 :             tree value = ce->value;
    8217              : 
    8218       370265 :             if (cleared && initializer_zerop (value))
    8219         9148 :               continue;
    8220              : 
    8221       361117 :             if (ce->index)
    8222        51270 :               eltpos = tree_to_uhwi (ce->index);
    8223              :             else
    8224       309847 :               eltpos = idx * chunk_size;
    8225              : 
    8226       361117 :             if (vector)
    8227              :               {
    8228       323459 :                 if (vec_vec_init_p)
    8229              :                   {
    8230         2862 :                     gcc_assert (ce->index == NULL_TREE);
    8231         2862 :                     gcc_assert (TREE_CODE (TREE_TYPE (value)) == VECTOR_TYPE);
    8232         2862 :                     eltpos = idx;
    8233              :                   }
    8234              :                 else
    8235       320597 :                   gcc_assert (TREE_CODE (TREE_TYPE (value)) != VECTOR_TYPE);
    8236       323459 :                 RTVEC_ELT (vector, eltpos) = expand_normal (value);
    8237              :               }
    8238              :             else
    8239              :               {
    8240        37658 :                 machine_mode value_mode
    8241        37658 :                   = (TREE_CODE (TREE_TYPE (value)) == VECTOR_TYPE
    8242        37658 :                      ? TYPE_MODE (TREE_TYPE (value)) : eltmode);
    8243        37658 :                 bitpos = eltpos * elt_size;
    8244        37658 :                 store_constructor_field (target, bitsize, bitpos, 0,
    8245        37658 :                                          bitregion_end, value_mode,
    8246              :                                          value, cleared, alias, reverse);
    8247              :               }
    8248              :           }
    8249              : 
    8250       122278 :         if (vector)
    8251       118062 :           emit_insn (GEN_FCN (icode) (target,
    8252              :                                       gen_rtx_PARALLEL (mode, vector)));
    8253              :         break;
    8254              :       }
    8255              : 
    8256            0 :     default:
    8257            0 :       gcc_unreachable ();
    8258              :     }
    8259       254476 : }
    8260              : 
    8261              : /* Store the value of EXP (an expression tree)
    8262              :    into a subfield of TARGET which has mode MODE and occupies
    8263              :    BITSIZE bits, starting BITPOS bits from the start of TARGET.
    8264              :    If MODE is VOIDmode, it means that we are storing into a bit-field.
    8265              : 
    8266              :    BITREGION_START is bitpos of the first bitfield in this region.
    8267              :    BITREGION_END is the bitpos of the ending bitfield in this region.
    8268              :    These two fields are 0, if the C++ memory model does not apply,
    8269              :    or we are not interested in keeping track of bitfield regions.
    8270              : 
    8271              :    Always return const0_rtx unless we have something particular to
    8272              :    return.
    8273              : 
    8274              :    ALIAS_SET is the alias set for the destination.  This value will
    8275              :    (in general) be different from that for TARGET, since TARGET is a
    8276              :    reference to the containing structure.
    8277              : 
    8278              :    If NONTEMPORAL is true, try generating a nontemporal store.
    8279              : 
    8280              :    If REVERSE is true, the store is to be done in reverse order.  */
    8281              : 
    8282              : static rtx
    8283      4976502 : store_field (rtx target, poly_int64 bitsize, poly_int64 bitpos,
    8284              :              poly_uint64 bitregion_start, poly_uint64 bitregion_end,
    8285              :              machine_mode mode, tree exp,
    8286              :              alias_set_type alias_set, bool nontemporal,  bool reverse)
    8287              : {
    8288      4976502 :   if (TREE_CODE (exp) == ERROR_MARK)
    8289            0 :     return const0_rtx;
    8290              : 
    8291              :   /* If we have nothing to store, do nothing unless the expression has
    8292              :      side-effects.  Don't do that for zero sized addressable lhs of
    8293              :      calls.  */
    8294      4976502 :   if (known_eq (bitsize, 0)
    8295      4976502 :       && (!TREE_ADDRESSABLE (TREE_TYPE (exp))
    8296            3 :           || TREE_CODE (exp) != CALL_EXPR))
    8297            0 :     return expand_expr (exp, const0_rtx, VOIDmode, EXPAND_NORMAL);
    8298              : 
    8299      4976502 :   if (GET_CODE (target) == CONCAT)
    8300              :     {
    8301              :       /* We're storing into a struct containing a single __complex.  */
    8302              : 
    8303            0 :       gcc_assert (known_eq (bitpos, 0));
    8304            0 :       return store_expr (exp, target, 0, nontemporal, reverse);
    8305              :     }
    8306              : 
    8307              :   /* If the structure is in a register or if the component
    8308              :      is a bit field, we cannot use addressing to access it.
    8309              :      Use bit-field techniques or SUBREG to store in it.  */
    8310              : 
    8311      4976502 :   poly_int64 decl_bitsize;
    8312      4976502 :   if (mode == VOIDmode
    8313      4909284 :       || (mode != BLKmode && ! direct_store[(int) mode]
    8314         5314 :           && GET_MODE_CLASS (mode) != MODE_COMPLEX_INT
    8315         5312 :           && GET_MODE_CLASS (mode) != MODE_COMPLEX_FLOAT)
    8316      4904004 :       || REG_P (target)
    8317      4207265 :       || GET_CODE (target) == SUBREG
    8318              :       /* If the field isn't aligned enough to store as an ordinary memref,
    8319              :          store it as a bit field.  */
    8320      4207265 :       || (mode != BLKmode
    8321      4086364 :           && ((((MEM_ALIGN (target) < GET_MODE_ALIGNMENT (mode))
    8322      8081503 :                 || !multiple_p (bitpos, GET_MODE_ALIGNMENT (mode)))
    8323        48373 :                && targetm.slow_unaligned_access (mode, MEM_ALIGN (target)))
    8324      4086364 :               || !multiple_p (bitpos, BITS_PER_UNIT)))
    8325      4207265 :       || (known_size_p (bitsize)
    8326      4207253 :           && mode != BLKmode
    8327      4086364 :           && maybe_gt (GET_MODE_BITSIZE (mode), bitsize))
    8328              :       /* If the RHS and field are a constant size and the size of the
    8329              :          RHS isn't the same size as the bitfield, we must use bitfield
    8330              :          operations.  */
    8331      4207256 :       || (known_size_p (bitsize)
    8332      4207244 :           && poly_int_tree_p (TYPE_SIZE (TREE_TYPE (exp)))
    8333      4976793 :           && maybe_ne (wi::to_poly_offset (TYPE_SIZE (TREE_TYPE (exp))),
    8334              :                        bitsize)
    8335              :           /* Except for initialization of full bytes from a CONSTRUCTOR, which
    8336              :              we will handle specially below.  */
    8337           42 :           && !(TREE_CODE (exp) == CONSTRUCTOR
    8338           11 :                && multiple_p (bitsize, BITS_PER_UNIT))
    8339              :           /* And except for bitwise copying of TREE_ADDRESSABLE types,
    8340              :              where the FIELD_DECL has the right bitsize, but TREE_TYPE (exp)
    8341              :              includes some extra padding.  store_expr / expand_expr will in
    8342              :              that case call get_inner_reference that will have the bitsize
    8343              :              we check here and thus the block move will not clobber the
    8344              :              padding that shouldn't be clobbered.  In the future we could
    8345              :              replace the TREE_ADDRESSABLE check with a check that
    8346              :              get_base_address needs to live in memory.  */
    8347           31 :           && (!TREE_ADDRESSABLE (TREE_TYPE (exp))
    8348            9 :               || TREE_CODE (exp) != COMPONENT_REF
    8349            6 :               || !multiple_p (bitsize, BITS_PER_UNIT)
    8350            6 :               || !multiple_p (bitpos, BITS_PER_UNIT)
    8351            6 :               || !poly_int_tree_p (DECL_SIZE (TREE_OPERAND (exp, 1)),
    8352              :                                    &decl_bitsize)
    8353            6 :               || maybe_ne (decl_bitsize, bitsize))
    8354              :           /* A call with an addressable return type and return-slot
    8355              :              optimization must not need bitfield operations but we must
    8356              :              pass down the original target.  */
    8357           25 :           && (TREE_CODE (exp) != CALL_EXPR
    8358            6 :               || !TREE_ADDRESSABLE (TREE_TYPE (exp))
    8359            0 :               || !CALL_EXPR_RETURN_SLOT_OPT (exp)))
    8360              :       /* If we are expanding a MEM_REF of a non-BLKmode non-addressable
    8361              :          decl we must use bitfield operations.  */
    8362      9183733 :       || (known_size_p (bitsize)
    8363      4207219 :           && TREE_CODE (exp) == MEM_REF
    8364        33408 :           && TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
    8365        27356 :           && DECL_P (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
    8366        20716 :           && !TREE_ADDRESSABLE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
    8367         5958 :           && DECL_MODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) != BLKmode))
    8368              :     {
    8369       769549 :       rtx temp;
    8370       769549 :       gassign *nop_def;
    8371              : 
    8372              :       /* If EXP is a NOP_EXPR of precision less than its mode, then that
    8373              :          implies a mask operation.  If the precision is the same size as
    8374              :          the field we're storing into, that mask is redundant.  This is
    8375              :          particularly common with bit field assignments generated by the
    8376              :          C front end.  */
    8377       769549 :       nop_def = get_def_for_expr (exp, NOP_EXPR);
    8378       769549 :       if (nop_def)
    8379              :         {
    8380         5446 :           tree type = TREE_TYPE (exp);
    8381         5446 :           if (INTEGRAL_TYPE_P (type)
    8382         5333 :               && maybe_ne (TYPE_PRECISION (type),
    8383        10666 :                            GET_MODE_BITSIZE (TYPE_MODE (type)))
    8384         8780 :               && known_eq (bitsize, TYPE_PRECISION (type)))
    8385              :             {
    8386         3334 :               tree op = gimple_assign_rhs1 (nop_def);
    8387         3334 :               type = TREE_TYPE (op);
    8388         3334 :               if (INTEGRAL_TYPE_P (type)
    8389         3334 :                   && known_ge (TYPE_PRECISION (type), bitsize))
    8390              :                 exp = op;
    8391              :             }
    8392              :         }
    8393              : 
    8394       769549 :       temp = expand_normal (exp);
    8395              : 
    8396              :       /* We don't support variable-sized BLKmode bitfields, since our
    8397              :          handling of BLKmode is bound up with the ability to break
    8398              :          things into words.  */
    8399       769549 :       gcc_assert (mode != BLKmode || bitsize.is_constant ());
    8400              : 
    8401              :       /* Handle calls that return values in multiple non-contiguous locations.
    8402              :          The Irix 6 ABI has examples of this.  */
    8403       769549 :       if (GET_CODE (temp) == PARALLEL)
    8404              :         {
    8405            6 :           HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
    8406            6 :           machine_mode temp_mode = GET_MODE (temp);
    8407            6 :           if (temp_mode == BLKmode || temp_mode == VOIDmode)
    8408            6 :             temp_mode
    8409            6 :               = smallest_int_mode_for_size (size * BITS_PER_UNIT).require ();
    8410            6 :           rtx temp_target = gen_reg_rtx (temp_mode);
    8411            6 :           emit_group_store (temp_target, temp, TREE_TYPE (exp), size);
    8412            6 :           temp = temp_target;
    8413              :         }
    8414              : 
    8415              :       /* Handle calls that return BLKmode values in registers.  */
    8416       769543 :       else if (mode == BLKmode && REG_P (temp) && TREE_CODE (exp) == CALL_EXPR)
    8417              :         {
    8418            0 :           rtx temp_target = gen_reg_rtx (GET_MODE (temp));
    8419            0 :           copy_blkmode_from_reg (temp_target, temp, TREE_TYPE (exp));
    8420            0 :           temp = temp_target;
    8421              :         }
    8422              : 
    8423              :       /* If the value has aggregate type and an integral mode then, if BITSIZE
    8424              :          is narrower than this mode and this is for big-endian data, we first
    8425              :          need to put the value into the low-order bits for store_bit_field,
    8426              :          except when MODE is BLKmode and BITSIZE larger than the word size
    8427              :          (see the handling of fields larger than a word in store_bit_field).
    8428              :          Moreover, the field may be not aligned on a byte boundary; in this
    8429              :          case, if it has reverse storage order, it needs to be accessed as a
    8430              :          scalar field with reverse storage order and we must first put the
    8431              :          value into target order.  */
    8432       769549 :       scalar_int_mode temp_mode;
    8433      1536942 :       if (AGGREGATE_TYPE_P (TREE_TYPE (exp))
    8434       770305 :           && is_int_mode (GET_MODE (temp), &temp_mode))
    8435              :         {
    8436         2556 :           HOST_WIDE_INT size = GET_MODE_BITSIZE (temp_mode);
    8437              : 
    8438         2556 :           reverse = TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (exp));
    8439              : 
    8440         2556 :           if (reverse)
    8441            0 :             temp = flip_storage_order (temp_mode, temp);
    8442              : 
    8443         2556 :           gcc_checking_assert (known_le (bitsize, size));
    8444         2556 :           if (maybe_lt (bitsize, size)
    8445         2556 :               && reverse ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN
    8446              :               /* Use of to_constant for BLKmode was checked above.  */
    8447              :               && !(mode == BLKmode && bitsize.to_constant () > BITS_PER_WORD))
    8448            0 :             temp = expand_shift (RSHIFT_EXPR, temp_mode, temp,
    8449              :                                  size - bitsize, NULL_RTX, 1);
    8450              :         }
    8451              : 
    8452              :       /* Unless MODE is VOIDmode or BLKmode, convert TEMP to MODE.  */
    8453       702331 :       if (mode != VOIDmode && mode != BLKmode
    8454      1471574 :           && mode != TYPE_MODE (TREE_TYPE (exp)))
    8455            4 :         temp = convert_modes (mode, TYPE_MODE (TREE_TYPE (exp)), temp, 1);
    8456              : 
    8457              :       /* If the mode of TEMP and TARGET is BLKmode, both must be in memory
    8458              :          and BITPOS must be aligned on a byte boundary.  If so, we simply do
    8459              :          a block copy.  Likewise for a BLKmode-like TARGET.  */
    8460       769549 :       if (GET_MODE (temp) == BLKmode
    8461       769549 :           && (GET_MODE (target) == BLKmode
    8462          203 :               || (MEM_P (target)
    8463            0 :                   && GET_MODE_CLASS (GET_MODE (target)) == MODE_INT
    8464            0 :                   && multiple_p (bitpos, BITS_PER_UNIT)
    8465            0 :                   && multiple_p (bitsize, BITS_PER_UNIT))))
    8466              :         {
    8467           97 :           gcc_assert (MEM_P (target) && MEM_P (temp));
    8468           97 :           poly_int64 bytepos = exact_div (bitpos, BITS_PER_UNIT);
    8469           97 :           poly_int64 bytesize = bits_to_bytes_round_up (bitsize);
    8470              : 
    8471           97 :           target = adjust_address (target, VOIDmode, bytepos);
    8472           97 :           emit_block_move (target, temp,
    8473           97 :                            gen_int_mode (bytesize, Pmode),
    8474              :                            BLOCK_OP_NORMAL);
    8475              : 
    8476           97 :           return const0_rtx;
    8477              :         }
    8478              : 
    8479              :       /* If the mode of TEMP is still BLKmode and BITSIZE not larger than the
    8480              :          word size, we need to load the value (see again store_bit_field).  */
    8481       769470 :       if (GET_MODE (temp) == BLKmode && known_le (bitsize, BITS_PER_WORD))
    8482              :         {
    8483           81 :           temp_mode = smallest_int_mode_for_size (bitsize).require ();
    8484           81 :           temp = extract_bit_field (temp, bitsize, 0, 1, NULL_RTX, temp_mode,
    8485              :                                     temp_mode, false, NULL);
    8486              :         }
    8487              : 
    8488              :       /* Store the value in the bitfield.  */
    8489       769452 :       gcc_checking_assert (known_ge (bitpos, 0));
    8490       769452 :       store_bit_field (target, bitsize, bitpos,
    8491              :                        bitregion_start, bitregion_end,
    8492              :                        mode, temp, reverse, false);
    8493              : 
    8494       769452 :       return const0_rtx;
    8495              :     }
    8496              :   else
    8497              :     {
    8498              :       /* Now build a reference to just the desired component.  */
    8499      4206953 :       rtx to_rtx = adjust_address (target, mode,
    8500              :                                    exact_div (bitpos, BITS_PER_UNIT));
    8501              : 
    8502      4206953 :       if (to_rtx == target)
    8503      1319120 :         to_rtx = copy_rtx (to_rtx);
    8504              : 
    8505      8129609 :       if (!MEM_KEEP_ALIAS_SET_P (to_rtx) && MEM_ALIAS_SET (to_rtx) != 0)
    8506      3660580 :         set_mem_alias_set (to_rtx, alias_set);
    8507              : 
    8508              :       /* Above we avoided using bitfield operations for storing a CONSTRUCTOR
    8509              :          into a target smaller than its type; handle that case now.  */
    8510      4206953 :       if (TREE_CODE (exp) == CONSTRUCTOR && known_size_p (bitsize))
    8511              :         {
    8512        73084 :           poly_int64 bytesize = exact_div (bitsize, BITS_PER_UNIT);
    8513        73084 :           store_constructor (exp, to_rtx, 0, bytesize, reverse);
    8514        73084 :           return to_rtx;
    8515              :         }
    8516              : 
    8517      4133869 :       return store_expr (exp, to_rtx, 0, nontemporal, reverse);
    8518              :     }
    8519              : }
    8520              : 
    8521              : /* Given an expression EXP that may be a COMPONENT_REF, a BIT_FIELD_REF,
    8522              :    an ARRAY_REF, or an ARRAY_RANGE_REF, look for nested operations of these
    8523              :    codes and find the ultimate containing object, which we return.
    8524              : 
    8525              :    We set *PBITSIZE to the size in bits that we want, *PBITPOS to the
    8526              :    bit position, *PUNSIGNEDP to the signedness and *PREVERSEP to the
    8527              :    storage order of the field.
    8528              :    If the position of the field is variable, we store a tree
    8529              :    giving the variable offset (in units) in *POFFSET.
    8530              :    This offset is in addition to the bit position.
    8531              :    If the position is not variable, we store 0 in *POFFSET.
    8532              : 
    8533              :    If any of the extraction expressions is volatile,
    8534              :    we store 1 in *PVOLATILEP.  Otherwise we don't change that.
    8535              : 
    8536              :    If the field is a non-BLKmode bit-field, *PMODE is set to VOIDmode.
    8537              :    Otherwise, it is a mode that can be used to access the field.
    8538              : 
    8539              :    If the field describes a variable-sized object, *PMODE is set to
    8540              :    BLKmode and *PBITSIZE is set to -1.  An access cannot be made in
    8541              :    this case, but the address of the object can be found.  */
    8542              : 
    8543              : tree
    8544    264986540 : get_inner_reference (tree exp, poly_int64 *pbitsize,
    8545              :                      poly_int64 *pbitpos, tree *poffset,
    8546              :                      machine_mode *pmode, int *punsignedp,
    8547              :                      int *preversep, int *pvolatilep)
    8548              : {
    8549    264986540 :   tree size_tree = 0;
    8550    264986540 :   machine_mode mode = VOIDmode;
    8551    264986540 :   bool blkmode_bitfield = false;
    8552    264986540 :   tree offset = size_zero_node;
    8553    264986540 :   poly_offset_int bit_offset = 0;
    8554              : 
    8555              :   /* First get the mode, signedness, storage order and size.  We do this from
    8556              :      just the outermost expression.  */
    8557    264986540 :   *pbitsize = -1;
    8558    264986540 :   if (TREE_CODE (exp) == COMPONENT_REF)
    8559              :     {
    8560    120369906 :       tree field = TREE_OPERAND (exp, 1);
    8561    120369906 :       size_tree = DECL_SIZE (field);
    8562    120369906 :       if (flag_strict_volatile_bitfields > 0
    8563           58 :           && TREE_THIS_VOLATILE (exp)
    8564           40 :           && DECL_BIT_FIELD_TYPE (field)
    8565    120369928 :           && DECL_MODE (field) != BLKmode)
    8566              :         /* Volatile bitfields should be accessed in the mode of the
    8567              :              field's type, not the mode computed based on the bit
    8568              :              size.  */
    8569           22 :         mode = TYPE_MODE (DECL_BIT_FIELD_TYPE (field));
    8570    120369884 :       else if (!DECL_BIT_FIELD (field))
    8571              :         {
    8572    119058371 :           mode = DECL_MODE (field);
    8573              :           /* For vector fields re-check the target flags, as DECL_MODE
    8574              :              could have been set with different target flags than
    8575              :              the current function has.  */
    8576    119058371 :           if (VECTOR_TYPE_P (TREE_TYPE (field))
    8577    119058371 :               && VECTOR_MODE_P (TYPE_MODE_RAW (TREE_TYPE (field))))
    8578       370626 :             mode = TYPE_MODE (TREE_TYPE (field));
    8579              :         }
    8580      1311513 :       else if (DECL_MODE (field) == BLKmode)
    8581          653 :         blkmode_bitfield = true;
    8582              : 
    8583    120369906 :       *punsignedp = DECL_UNSIGNED (field);
    8584              :     }
    8585    144616634 :   else if (TREE_CODE (exp) == BIT_FIELD_REF)
    8586              :     {
    8587       649047 :       size_tree = TREE_OPERAND (exp, 1);
    8588      1297687 :       *punsignedp = (! INTEGRAL_TYPE_P (TREE_TYPE (exp))
    8589      1145485 :                      || TYPE_UNSIGNED (TREE_TYPE (exp)));
    8590              : 
    8591              :       /* For vector element types with the correct size of access or for
    8592              :          vector typed accesses use the mode of the access type.  */
    8593       649047 :       if ((TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == VECTOR_TYPE
    8594       504226 :            && TREE_TYPE (exp) == TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0)))
    8595       457408 :            && tree_int_cst_equal (size_tree, TYPE_SIZE (TREE_TYPE (exp))))
    8596       695900 :           || VECTOR_TYPE_P (TREE_TYPE (exp)))
    8597       481566 :         mode = TYPE_MODE (TREE_TYPE (exp));
    8598              :     }
    8599              :   else
    8600              :     {
    8601    143967587 :       mode = TYPE_MODE (TREE_TYPE (exp));
    8602    143967587 :       *punsignedp = TYPE_UNSIGNED (TREE_TYPE (exp));
    8603              : 
    8604    143967587 :       if (mode == BLKmode)
    8605     59716468 :         size_tree = TYPE_SIZE (TREE_TYPE (exp));
    8606              :       else
    8607    168502238 :         *pbitsize = GET_MODE_BITSIZE (mode);
    8608              :     }
    8609              : 
    8610    264986540 :   if (size_tree != 0)
    8611              :     {
    8612    180027838 :       if (!poly_int_tree_p (size_tree, pbitsize))
    8613       517052 :         mode = BLKmode, *pbitsize = -1;
    8614              :     }
    8615              : 
    8616    264986540 :   *preversep = reverse_storage_order_for_component_p (exp);
    8617              : 
    8618              :   /* Compute cumulative bit-offset for nested component-refs and array-refs,
    8619              :      and find the ultimate containing object.  */
    8620    696679054 :   while (1)
    8621              :     {
    8622    480832797 :       switch (TREE_CODE (exp))
    8623              :         {
    8624       649047 :         case BIT_FIELD_REF:
    8625       649047 :           bit_offset += wi::to_poly_offset (TREE_OPERAND (exp, 2));
    8626       649047 :           break;
    8627              : 
    8628    183026225 :         case COMPONENT_REF:
    8629    183026225 :           {
    8630    183026225 :             tree field = TREE_OPERAND (exp, 1);
    8631    183026225 :             tree this_offset = component_ref_field_offset (exp);
    8632              : 
    8633              :             /* If this field hasn't been filled in yet, don't go past it.
    8634              :                This should only happen when folding expressions made during
    8635              :                type construction.  */
    8636    183026225 :             if (this_offset == 0)
    8637              :               break;
    8638              : 
    8639    183026225 :             offset = size_binop (PLUS_EXPR, offset, this_offset);
    8640    183026225 :             bit_offset += wi::to_poly_offset (DECL_FIELD_BIT_OFFSET (field));
    8641              : 
    8642              :             /* ??? Right now we don't do anything with DECL_OFFSET_ALIGN.  */
    8643              :           }
    8644    183026225 :           break;
    8645              : 
    8646     28893501 :         case ARRAY_REF:
    8647     28893501 :         case ARRAY_RANGE_REF:
    8648     28893501 :           {
    8649     28893501 :             tree index = TREE_OPERAND (exp, 1);
    8650     28893501 :             tree low_bound = array_ref_low_bound (exp);
    8651     28893501 :             tree unit_size = array_ref_element_size (exp);
    8652              : 
    8653              :             /* We assume all arrays have sizes that are a multiple of a byte.
    8654              :                First subtract the lower bound, if any, in the type of the
    8655              :                index, then convert to sizetype and multiply by the size of
    8656              :                the array element.  */
    8657     28893501 :             if (! integer_zerop (low_bound))
    8658       837500 :               index = fold_build2 (MINUS_EXPR, TREE_TYPE (index),
    8659              :                                    index, low_bound);
    8660              : 
    8661     28893501 :             offset = size_binop (PLUS_EXPR, offset,
    8662              :                                  size_binop (MULT_EXPR,
    8663              :                                              fold_convert (sizetype, index),
    8664              :                                              unit_size));
    8665              :           }
    8666     28893501 :           break;
    8667              : 
    8668              :         case REALPART_EXPR:
    8669              :           break;
    8670              : 
    8671              :         case IMAGPART_EXPR:
    8672    215846257 :           bit_offset += *pbitsize;
    8673              :           break;
    8674              : 
    8675              :         case VIEW_CONVERT_EXPR:
    8676              :           break;
    8677              : 
    8678     86051336 :         case MEM_REF:
    8679              :           /* Hand back the decl for MEM[&decl, off].  */
    8680     86051336 :           if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR)
    8681              :             {
    8682     18682169 :               tree off = TREE_OPERAND (exp, 1);
    8683     18682169 :               if (!integer_zerop (off))
    8684              :                 {
    8685     10010225 :                   poly_offset_int boff = mem_ref_offset (exp);
    8686     10010225 :                   boff <<= LOG2_BITS_PER_UNIT;
    8687     10010225 :                   bit_offset += boff;
    8688              :                 }
    8689     18682169 :               exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    8690              :             }
    8691     86051336 :           goto done;
    8692              : 
    8693    178935204 :         default:
    8694    178935204 :           goto done;
    8695              :         }
    8696              : 
    8697              :       /* If any reference in the chain is volatile, the effect is volatile.  */
    8698    215846257 :       if (TREE_THIS_VOLATILE (exp))
    8699       754357 :         *pvolatilep = 1;
    8700              : 
    8701    215846257 :       exp = TREE_OPERAND (exp, 0);
    8702    215846257 :     }
    8703    264986540 :  done:
    8704              : 
    8705              :   /* If OFFSET is constant, see if we can return the whole thing as a
    8706              :      constant bit position.  Make sure to handle overflow during
    8707              :      this conversion.  */
    8708    264986540 :   if (poly_int_tree_p (offset))
    8709              :     {
    8710    254304345 :       poly_offset_int tem = wi::sext (wi::to_poly_offset (offset),
    8711    254304345 :                                       TYPE_PRECISION (sizetype));
    8712    254304345 :       tem <<= LOG2_BITS_PER_UNIT;
    8713    254304345 :       tem += bit_offset;
    8714    254304345 :       if (tem.to_shwi (pbitpos))
    8715    254302948 :         *poffset = offset = NULL_TREE;
    8716              :     }
    8717              : 
    8718              :   /* Otherwise, split it up.  */
    8719    254304345 :   if (offset)
    8720              :     {
    8721              :       /* Avoid returning a negative bitpos as this may wreak havoc later.  */
    8722     10683592 :       if (!bit_offset.to_shwi (pbitpos) || maybe_lt (*pbitpos, 0))
    8723              :         {
    8724          288 :           *pbitpos = num_trailing_bits (bit_offset.force_shwi ());
    8725          288 :           poly_offset_int bytes = bits_to_bytes_round_down (bit_offset);
    8726          288 :           offset = size_binop (PLUS_EXPR, offset,
    8727              :                                build_int_cst (sizetype, bytes.force_shwi ()));
    8728              :         }
    8729              : 
    8730     10683592 :       *poffset = offset;
    8731              :     }
    8732              : 
    8733              :   /* We can use BLKmode for a byte-aligned BLKmode bitfield.  */
    8734    264986540 :   if (mode == VOIDmode
    8735      5681141 :       && blkmode_bitfield
    8736          653 :       && multiple_p (*pbitpos, BITS_PER_UNIT)
    8737    264987057 :       && multiple_p (*pbitsize, BITS_PER_UNIT))
    8738            6 :     *pmode = BLKmode;
    8739              :   else
    8740    264986534 :     *pmode = mode;
    8741              : 
    8742    264986540 :   return exp;
    8743              : }
    8744              : 
    8745              : /* Alignment in bits the TARGET of an assignment may be assumed to have.  */
    8746              : 
    8747              : static unsigned HOST_WIDE_INT
    8748       522675 : target_align (const_tree target)
    8749              : {
    8750              :   /* We might have a chain of nested references with intermediate misaligning
    8751              :      bitfields components, so need to recurse to find out.  */
    8752              : 
    8753       522675 :   unsigned HOST_WIDE_INT this_align, outer_align;
    8754              : 
    8755       522675 :   switch (TREE_CODE (target))
    8756              :     {
    8757              :     case BIT_FIELD_REF:
    8758              :       return 1;
    8759              : 
    8760       141582 :     case COMPONENT_REF:
    8761       141582 :       this_align = DECL_ALIGN (TREE_OPERAND (target, 1));
    8762       141582 :       outer_align = target_align (TREE_OPERAND (target, 0));
    8763       141582 :       return MIN (this_align, outer_align);
    8764              : 
    8765       193782 :     case ARRAY_REF:
    8766       193782 :     case ARRAY_RANGE_REF:
    8767       193782 :       this_align = TYPE_ALIGN (TREE_TYPE (target));
    8768       193782 :       outer_align = target_align (TREE_OPERAND (target, 0));
    8769       193782 :       return MIN (this_align, outer_align);
    8770              : 
    8771         4871 :     CASE_CONVERT:
    8772         4871 :     case NON_LVALUE_EXPR:
    8773         4871 :     case VIEW_CONVERT_EXPR:
    8774         4871 :       this_align = TYPE_ALIGN (TREE_TYPE (target));
    8775         4871 :       outer_align = target_align (TREE_OPERAND (target, 0));
    8776         4871 :       return MAX (this_align, outer_align);
    8777              : 
    8778       182426 :     default:
    8779       182426 :       return TYPE_ALIGN (TREE_TYPE (target));
    8780              :     }
    8781              : }
    8782              : 
    8783              : 
    8784              : /* Given an rtx VALUE that may contain additions and multiplications, return
    8785              :    an equivalent value that just refers to a register, memory, or constant.
    8786              :    This is done by generating instructions to perform the arithmetic and
    8787              :    returning a pseudo-register containing the value.
    8788              : 
    8789              :    The returned value may be a REG, SUBREG, MEM or constant.  */
    8790              : 
    8791              : rtx
    8792     32254284 : force_operand (rtx value, rtx target)
    8793              : {
    8794     32254284 :   rtx op1, op2;
    8795              :   /* Use subtarget as the target for operand 0 of a binary operation.  */
    8796     32254284 :   rtx subtarget = get_subtarget (target);
    8797     32254284 :   enum rtx_code code = GET_CODE (value);
    8798              : 
    8799              :   /* Check for subreg applied to an expression produced by loop optimizer.  */
    8800     32254284 :   if (code == SUBREG
    8801       309473 :       && !REG_P (SUBREG_REG (value))
    8802          168 :       && !MEM_P (SUBREG_REG (value)))
    8803              :     {
    8804          168 :       value
    8805          168 :         = simplify_gen_subreg (GET_MODE (value),
    8806          168 :                                force_reg (GET_MODE (SUBREG_REG (value)),
    8807              :                                           force_operand (SUBREG_REG (value),
    8808              :                                                          NULL_RTX)),
    8809          168 :                                GET_MODE (SUBREG_REG (value)),
    8810          168 :                                SUBREG_BYTE (value));
    8811          168 :       code = GET_CODE (value);
    8812              :     }
    8813              : 
    8814              :   /* Check for a PIC address load.  */
    8815     32254284 :   if ((code == PLUS || code == MINUS)
    8816      3826491 :       && XEXP (value, 0) == pic_offset_table_rtx
    8817         1949 :       && (GET_CODE (XEXP (value, 1)) == SYMBOL_REF
    8818         1949 :           || GET_CODE (XEXP (value, 1)) == LABEL_REF
    8819         1949 :           || GET_CODE (XEXP (value, 1)) == CONST))
    8820              :     {
    8821          209 :       if (!subtarget)
    8822          209 :         subtarget = gen_reg_rtx (GET_MODE (value));
    8823          209 :       emit_move_insn (subtarget, value);
    8824          209 :       return subtarget;
    8825              :     }
    8826              : 
    8827     32254075 :   if (ARITHMETIC_P (value))
    8828              :     {
    8829      3949978 :       op2 = XEXP (value, 1);
    8830      3949978 :       if (!CONSTANT_P (op2) && !(REG_P (op2) && op2 != subtarget))
    8831      3949978 :         subtarget = 0;
    8832      3949978 :       if (code == MINUS && CONST_INT_P (op2))
    8833              :         {
    8834            0 :           code = PLUS;
    8835            0 :           op2 = negate_rtx (GET_MODE (value), op2);
    8836              :         }
    8837              : 
    8838              :       /* Check for an addition with OP2 a constant integer and our first
    8839              :          operand a PLUS of a virtual register and something else.  In that
    8840              :          case, we want to emit the sum of the virtual register and the
    8841              :          constant first and then add the other value.  This allows virtual
    8842              :          register instantiation to simply modify the constant rather than
    8843              :          creating another one around this addition.  */
    8844      3761599 :       if (code == PLUS && CONST_INT_P (op2)
    8845      3378976 :           && GET_CODE (XEXP (value, 0)) == PLUS
    8846        66217 :           && REG_P (XEXP (XEXP (value, 0), 0))
    8847      3957735 :           && VIRTUAL_REGISTER_P (XEXP (XEXP (value, 0), 0)))
    8848              :         {
    8849         1174 :           rtx temp = expand_simple_binop (GET_MODE (value), code,
    8850              :                                           XEXP (XEXP (value, 0), 0), op2,
    8851              :                                           subtarget, 0, OPTAB_LIB_WIDEN);
    8852         1174 :           return expand_simple_binop (GET_MODE (value), code, temp,
    8853         1174 :                                       force_operand (XEXP (XEXP (value,
    8854              :                                                                  0), 1), 0),
    8855         1174 :                                       target, 0, OPTAB_LIB_WIDEN);
    8856              :         }
    8857              : 
    8858      3948804 :       op1 = force_operand (XEXP (value, 0), subtarget);
    8859      3948804 :       op2 = force_operand (op2, NULL_RTX);
    8860      3948804 :       switch (code)
    8861              :         {
    8862        99468 :         case MULT:
    8863        99468 :           return expand_mult (GET_MODE (value), op1, op2, target, 1);
    8864          506 :         case DIV:
    8865          506 :           if (!INTEGRAL_MODE_P (GET_MODE (value)))
    8866          506 :             return expand_simple_binop (GET_MODE (value), code, op1, op2,
    8867          506 :                                         target, 1, OPTAB_LIB_WIDEN);
    8868              :           else
    8869            0 :             return expand_divmod (0,
    8870              :                                   FLOAT_MODE_P (GET_MODE (value))
    8871              :                                   ? RDIV_EXPR : TRUNC_DIV_EXPR,
    8872            0 :                                   GET_MODE (value), op1, op2, target, 0);
    8873            0 :         case MOD:
    8874            0 :           return expand_divmod (1, TRUNC_MOD_EXPR, GET_MODE (value), op1, op2,
    8875            0 :                                 target, 0);
    8876          348 :         case UDIV:
    8877          348 :           return expand_divmod (0, TRUNC_DIV_EXPR, GET_MODE (value), op1, op2,
    8878          348 :                                 target, 1);
    8879            0 :         case UMOD:
    8880            0 :           return expand_divmod (1, TRUNC_MOD_EXPR, GET_MODE (value), op1, op2,
    8881            0 :                                 target, 1);
    8882          194 :         case ASHIFTRT:
    8883          194 :           return expand_simple_binop (GET_MODE (value), code, op1, op2,
    8884          194 :                                       target, 0, OPTAB_LIB_WIDEN);
    8885      3848288 :         default:
    8886      3848288 :           return expand_simple_binop (GET_MODE (value), code, op1, op2,
    8887      3848288 :                                       target, 1, OPTAB_LIB_WIDEN);
    8888              :         }
    8889              :     }
    8890     28304097 :   if (UNARY_P (value))
    8891              :     {
    8892        26185 :       if (!target)
    8893        11617 :         target = gen_reg_rtx (GET_MODE (value));
    8894              :       /* FIX or UNSIGNED_FIX with integral mode has unspecified rounding,
    8895              :          while FIX with floating point mode rounds toward zero.  So, some
    8896              :          targets use expressions like (fix:SI (fix:DF (reg:DF ...)))
    8897              :          to express rounding toward zero during the conversion to int.
    8898              :          expand_fix isn't able to handle that, it can only handle
    8899              :          FIX/UNSIGNED_FIX from floating point mode to integral one.  */
    8900        26185 :       if ((code == FIX || code == UNSIGNED_FIX)
    8901            8 :           && GET_CODE (XEXP (value, 0)) == FIX
    8902            0 :           && (GET_MODE (XEXP (value, 0))
    8903            0 :               == GET_MODE (XEXP (XEXP (value, 0), 0))))
    8904            0 :         op1 = force_operand (XEXP (XEXP (value, 0), 0), NULL_RTX);
    8905              :       else
    8906        26185 :         op1 = force_operand (XEXP (value, 0), NULL_RTX);
    8907        26185 :       switch (code)
    8908              :         {
    8909        11728 :         case ZERO_EXTEND:
    8910        11728 :         case SIGN_EXTEND:
    8911        11728 :         case TRUNCATE:
    8912        11728 :         case FLOAT_EXTEND:
    8913        11728 :         case FLOAT_TRUNCATE:
    8914        11728 :           convert_move (target, op1, code == ZERO_EXTEND);
    8915        11728 :           return target;
    8916              : 
    8917            8 :         case FIX:
    8918            8 :         case UNSIGNED_FIX:
    8919            8 :           expand_fix (target, op1, code == UNSIGNED_FIX);
    8920            8 :           return target;
    8921              : 
    8922           72 :         case FLOAT:
    8923           72 :         case UNSIGNED_FLOAT:
    8924           72 :           expand_float (target, op1, code == UNSIGNED_FLOAT);
    8925           72 :           return target;
    8926              : 
    8927        14377 :         default:
    8928        14377 :           return expand_simple_unop (GET_MODE (value), code, op1, target, 0);
    8929              :         }
    8930              :     }
    8931              : 
    8932              : #ifdef INSN_SCHEDULING
    8933              :   /* On machines that have insn scheduling, we want all memory reference to be
    8934              :      explicit, so we need to deal with such paradoxical SUBREGs.  */
    8935     28277912 :   if (paradoxical_subreg_p (value) && MEM_P (SUBREG_REG (value)))
    8936            0 :     value
    8937            0 :       = simplify_gen_subreg (GET_MODE (value),
    8938            0 :                              force_reg (GET_MODE (SUBREG_REG (value)),
    8939              :                                         force_operand (SUBREG_REG (value),
    8940              :                                                        NULL_RTX)),
    8941              :                              GET_MODE (SUBREG_REG (value)),
    8942            0 :                              SUBREG_BYTE (value));
    8943              : #endif
    8944              : 
    8945              :   return value;
    8946              : }
    8947              : 
    8948              : /* Subroutine of expand_expr: return true iff there is no way that
    8949              :    EXP can reference X, which is being modified.  TOP_P is nonzero if this
    8950              :    call is going to be used to determine whether we need a temporary
    8951              :    for EXP, as opposed to a recursive call to this function.
    8952              : 
    8953              :    It is always safe for this routine to return false since it merely
    8954              :    searches for optimization opportunities.  */
    8955              : 
    8956              : bool
    8957      9094574 : safe_from_p (const_rtx x, tree exp, int top_p)
    8958              : {
    8959      9094590 :   rtx exp_rtl = 0;
    8960      9094590 :   int i, nops;
    8961              : 
    8962      9094590 :   if (x == 0
    8963              :       /* If EXP has varying size, we MUST use a target since we currently
    8964              :          have no way of allocating temporaries of variable size
    8965              :          (except for arrays that have TYPE_ARRAY_MAX_SIZE set).
    8966              :          So we assume here that something at a higher level has prevented a
    8967              :          clash.  This is somewhat bogus, but the best we can do.  Only
    8968              :          do this when X is BLKmode and when we are at the top level.  */
    8969      2053405 :       || (top_p && TREE_TYPE (exp) != 0 && COMPLETE_TYPE_P (TREE_TYPE (exp))
    8970      1915433 :           && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST
    8971            0 :           && (TREE_CODE (TREE_TYPE (exp)) != ARRAY_TYPE
    8972            0 :               || TYPE_ARRAY_MAX_SIZE (TREE_TYPE (exp)) == NULL_TREE
    8973            0 :               || TREE_CODE (TYPE_ARRAY_MAX_SIZE (TREE_TYPE (exp)))
    8974              :               != INTEGER_CST)
    8975            0 :           && GET_MODE (x) == BLKmode)
    8976              :       /* If X is in the outgoing argument area, it is always safe.  */
    8977     11147995 :       || (MEM_P (x)
    8978       182177 :           && (XEXP (x, 0) == virtual_outgoing_args_rtx
    8979       182177 :               || (GET_CODE (XEXP (x, 0)) == PLUS
    8980       133165 :                   && XEXP (XEXP (x, 0), 0) == virtual_outgoing_args_rtx))))
    8981              :     return true;
    8982              : 
    8983              :   /* If this is a subreg of a hard register, declare it unsafe, otherwise,
    8984              :      find the underlying pseudo.  */
    8985      2053405 :   if (GET_CODE (x) == SUBREG)
    8986              :     {
    8987            0 :       x = SUBREG_REG (x);
    8988            0 :       if (REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER)
    8989              :         return false;
    8990              :     }
    8991              : 
    8992              :   /* Now look at our tree code and possibly recurse.  */
    8993      2053405 :   switch (TREE_CODE_CLASS (TREE_CODE (exp)))
    8994              :     {
    8995          442 :     case tcc_declaration:
    8996          442 :       exp_rtl = DECL_RTL_IF_SET (exp);
    8997              :       break;
    8998              : 
    8999              :     case tcc_constant:
    9000              :       return true;
    9001              : 
    9002       882738 :     case tcc_exceptional:
    9003       882738 :       if (TREE_CODE (exp) == TREE_LIST)
    9004              :         {
    9005            0 :           while (1)
    9006              :             {
    9007            0 :               if (TREE_VALUE (exp) && !safe_from_p (x, TREE_VALUE (exp), 0))
    9008              :                 return false;
    9009            0 :               exp = TREE_CHAIN (exp);
    9010            0 :               if (!exp)
    9011              :                 return true;
    9012            0 :               if (TREE_CODE (exp) != TREE_LIST)
    9013              :                 return safe_from_p (x, exp, 0);
    9014              :             }
    9015              :         }
    9016       882738 :       else if (TREE_CODE (exp) == CONSTRUCTOR)
    9017              :         {
    9018              :           constructor_elt *ce;
    9019              :           unsigned HOST_WIDE_INT idx;
    9020              : 
    9021      8383701 :           FOR_EACH_VEC_SAFE_ELT (CONSTRUCTOR_ELTS (exp), idx, ce)
    9022         6070 :             if ((ce->index != NULL_TREE && !safe_from_p (x, ce->index, 0))
    9023       137545 :                 || !safe_from_p (x, ce->value, 0))
    9024              :               return false;
    9025              :           return true;
    9026              :         }
    9027       736436 :       else if (TREE_CODE (exp) == ERROR_MARK)
    9028              :         return true;    /* An already-visited SAVE_EXPR? */
    9029              :       else
    9030              :         return false;
    9031              : 
    9032            0 :     case tcc_statement:
    9033              :       /* The only case we look at here is the DECL_INITIAL inside a
    9034              :          DECL_EXPR.  */
    9035            0 :       return (TREE_CODE (exp) != DECL_EXPR
    9036            0 :               || TREE_CODE (DECL_EXPR_DECL (exp)) != VAR_DECL
    9037            0 :               || !DECL_INITIAL (DECL_EXPR_DECL (exp))
    9038            0 :               || safe_from_p (x, DECL_INITIAL (DECL_EXPR_DECL (exp)), 0));
    9039              : 
    9040            0 :     case tcc_binary:
    9041            0 :     case tcc_comparison:
    9042            0 :       if (!safe_from_p (x, TREE_OPERAND (exp, 1), 0))
    9043              :         return false;
    9044              :       /* Fall through.  */
    9045              : 
    9046           16 :     case tcc_unary:
    9047           16 :       return safe_from_p (x, TREE_OPERAND (exp, 0), 0);
    9048              : 
    9049          473 :     case tcc_expression:
    9050          473 :     case tcc_reference:
    9051          473 :     case tcc_vl_exp:
    9052              :       /* Now do code-specific tests.  EXP_RTL is set to any rtx we find in
    9053              :          the expression.  If it is set, we conflict iff we are that rtx or
    9054              :          both are in memory.  Otherwise, we check all operands of the
    9055              :          expression recursively.  */
    9056              : 
    9057          473 :       switch (TREE_CODE (exp))
    9058              :         {
    9059          385 :         case ADDR_EXPR:
    9060              :           /* If the operand is static or we are static, we can't conflict.
    9061              :              Likewise if we don't conflict with the operand at all.  */
    9062          385 :           if (staticp (TREE_OPERAND (exp, 0))
    9063          235 :               || TREE_STATIC (exp)
    9064          620 :               || safe_from_p (x, TREE_OPERAND (exp, 0), 0))
    9065              :             return true;
    9066              : 
    9067              :           /* Otherwise, the only way this can conflict is if we are taking
    9068              :              the address of a DECL a that address if part of X, which is
    9069              :              very rare.  */
    9070            0 :           exp = TREE_OPERAND (exp, 0);
    9071            0 :           if (DECL_P (exp))
    9072              :             {
    9073            0 :               if (!DECL_RTL_SET_P (exp)
    9074            0 :                   || !MEM_P (DECL_RTL (exp)))
    9075              :                 return false;
    9076              :               else
    9077            0 :                 exp_rtl = XEXP (DECL_RTL (exp), 0);
    9078              :             }
    9079              :           break;
    9080              : 
    9081           73 :         case MEM_REF:
    9082           73 :           if (MEM_P (x)
    9083           73 :               && alias_sets_conflict_p (MEM_ALIAS_SET (x),
    9084              :                                         get_alias_set (exp)))
    9085              :             return false;
    9086              :           break;
    9087              : 
    9088            0 :         case CALL_EXPR:
    9089              :           /* Assume that the call will clobber all hard registers and
    9090              :              all of memory.  */
    9091            0 :           if ((REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER)
    9092            0 :               || MEM_P (x))
    9093              :             return false;
    9094              :           break;
    9095              : 
    9096            0 :         case WITH_CLEANUP_EXPR:
    9097            0 :         case CLEANUP_POINT_EXPR:
    9098              :           /* Lowered by gimplify.cc.  */
    9099            0 :           gcc_unreachable ();
    9100              : 
    9101            0 :         case SAVE_EXPR:
    9102            0 :           return safe_from_p (x, TREE_OPERAND (exp, 0), 0);
    9103              : 
    9104              :         default:
    9105              :           break;
    9106              :         }
    9107              : 
    9108              :       /* If we have an rtx, we do not need to scan our operands.  */
    9109            0 :       if (exp_rtl)
    9110              :         break;
    9111              : 
    9112           88 :       nops = TREE_OPERAND_LENGTH (exp);
    9113          371 :       for (i = 0; i < nops; i++)
    9114          195 :         if (TREE_OPERAND (exp, i) != 0
    9115          195 :             && ! safe_from_p (x, TREE_OPERAND (exp, i), 0))
    9116              :           return false;
    9117              : 
    9118              :       break;
    9119              : 
    9120            0 :     case tcc_type:
    9121              :       /* Should never get a type here.  */
    9122            0 :       gcc_unreachable ();
    9123              :     }
    9124              : 
    9125              :   /* If we have an rtl, find any enclosed object.  Then see if we conflict
    9126              :      with it.  */
    9127          394 :   if (exp_rtl)
    9128              :     {
    9129          306 :       if (GET_CODE (exp_rtl) == SUBREG)
    9130              :         {
    9131            0 :           exp_rtl = SUBREG_REG (exp_rtl);
    9132            0 :           if (REG_P (exp_rtl)
    9133            0 :               && REGNO (exp_rtl) < FIRST_PSEUDO_REGISTER)
    9134              :             return false;
    9135              :         }
    9136              : 
    9137              :       /* If the rtl is X, then it is not safe.  Otherwise, it is unless both
    9138              :          are memory and they conflict.  */
    9139          306 :       return ! (rtx_equal_p (x, exp_rtl)
    9140          306 :                 || (MEM_P (x) && MEM_P (exp_rtl)
    9141            4 :                     && true_dependence (exp_rtl, VOIDmode, x)));
    9142              :     }
    9143              : 
    9144              :   /* If we reach here, it is safe.  */
    9145              :   return true;
    9146              : }
    9147              : 
    9148              : 
    9149              : /* Return the highest power of two that EXP is known to be a multiple of.
    9150              :    This is used in updating alignment of MEMs in array references.  */
    9151              : 
    9152              : unsigned HOST_WIDE_INT
    9153     33715922 : highest_pow2_factor (const_tree exp)
    9154              : {
    9155     33715922 :   unsigned HOST_WIDE_INT ret;
    9156     33715922 :   int trailing_zeros = tree_ctz (exp);
    9157     33715922 :   if (trailing_zeros >= HOST_BITS_PER_WIDE_INT)
    9158     23654173 :     return BIGGEST_ALIGNMENT;
    9159     10061749 :   ret = HOST_WIDE_INT_1U << trailing_zeros;
    9160     19649745 :   if (ret > BIGGEST_ALIGNMENT)
    9161      6638673 :     return BIGGEST_ALIGNMENT;
    9162              :   return ret;
    9163              : }
    9164              : 
    9165              : /* Similar, except that the alignment requirements of TARGET are
    9166              :    taken into account.  Assume it is at least as aligned as its
    9167              :    type, unless it is a COMPONENT_REF in which case the layout of
    9168              :    the structure gives the alignment.  */
    9169              : 
    9170              : static unsigned HOST_WIDE_INT
    9171       182440 : highest_pow2_factor_for_target (const_tree target, const_tree exp)
    9172              : {
    9173       182440 :   unsigned HOST_WIDE_INT talign = target_align (target) / BITS_PER_UNIT;
    9174       182440 :   unsigned HOST_WIDE_INT factor = highest_pow2_factor (exp);
    9175              : 
    9176       182440 :   return MAX (factor, talign);
    9177              : }
    9178              : 
    9179              : /* Convert the tree comparison code TCODE to the rtl one where the
    9180              :    signedness is UNSIGNEDP.  */
    9181              : 
    9182              : enum rtx_code
    9183        22312 : convert_tree_comp_to_rtx (enum tree_code tcode, int unsignedp)
    9184              : {
    9185        22312 :   enum rtx_code code;
    9186        22312 :   switch (tcode)
    9187              :     {
    9188              :     case EQ_EXPR:
    9189              :       code = EQ;
    9190              :       break;
    9191         2636 :     case NE_EXPR:
    9192         2636 :       code = NE;
    9193         2636 :       break;
    9194         4142 :     case LT_EXPR:
    9195         4142 :       code = unsignedp ? LTU : LT;
    9196              :       break;
    9197         3131 :     case LE_EXPR:
    9198         3131 :       code = unsignedp ? LEU : LE;
    9199              :       break;
    9200         3301 :     case GT_EXPR:
    9201         3301 :       code = unsignedp ? GTU : GT;
    9202              :       break;
    9203         4395 :     case GE_EXPR:
    9204         4395 :       code = unsignedp ? GEU : GE;
    9205              :       break;
    9206           35 :     case UNORDERED_EXPR:
    9207           35 :       code = UNORDERED;
    9208           35 :       break;
    9209           35 :     case ORDERED_EXPR:
    9210           35 :       code = ORDERED;
    9211           35 :       break;
    9212           10 :     case UNLT_EXPR:
    9213           10 :       code = UNLT;
    9214           10 :       break;
    9215           19 :     case UNLE_EXPR:
    9216           19 :       code = UNLE;
    9217           19 :       break;
    9218           10 :     case UNGT_EXPR:
    9219           10 :       code = UNGT;
    9220           10 :       break;
    9221           11 :     case UNGE_EXPR:
    9222           11 :       code = UNGE;
    9223           11 :       break;
    9224            4 :     case UNEQ_EXPR:
    9225            4 :       code = UNEQ;
    9226            4 :       break;
    9227            4 :     case LTGT_EXPR:
    9228            4 :       code = LTGT;
    9229            4 :       break;
    9230              : 
    9231            0 :     default:
    9232            0 :       gcc_unreachable ();
    9233              :     }
    9234        22312 :   return code;
    9235              : }
    9236              : 
    9237              : /* Subroutine of expand_expr.  Expand the two operands of a binary
    9238              :    expression EXP0 and EXP1 placing the results in OP0 and OP1.
    9239              :    The value may be stored in TARGET if TARGET is nonzero.  The
    9240              :    MODIFIER argument is as documented by expand_expr.  */
    9241              : 
    9242              : void
    9243      8461370 : expand_operands (tree exp0, tree exp1, rtx target, rtx *op0, rtx *op1,
    9244              :                  enum expand_modifier modifier)
    9245              : {
    9246      8461370 :   if (! safe_from_p (target, exp1, 1))
    9247       611910 :     target = 0;
    9248      8461370 :   if (operand_equal_p (exp0, exp1, 0))
    9249              :     {
    9250        46909 :       *op0 = expand_expr (exp0, target, VOIDmode, modifier);
    9251        46909 :       *op1 = copy_rtx (*op0);
    9252              :     }
    9253              :   else
    9254              :     {
    9255      8414461 :       *op0 = expand_expr (exp0, target, VOIDmode, modifier);
    9256      8414461 :       *op1 = expand_expr (exp1, NULL_RTX, VOIDmode, modifier);
    9257              :     }
    9258      8461370 : }
    9259              : 
    9260              : 
    9261              : /* Return a MEM that contains constant EXP.  DEFER is as for
    9262              :    output_constant_def and MODIFIER is as for expand_expr.  */
    9263              : 
    9264              : static rtx
    9265      2993205 : expand_expr_constant (tree exp, int defer, enum expand_modifier modifier)
    9266              : {
    9267      2993205 :   rtx mem;
    9268              : 
    9269      2993205 :   mem = output_constant_def (exp, defer);
    9270      2993205 :   if (modifier != EXPAND_INITIALIZER)
    9271      1926747 :     mem = use_anchored_address (mem);
    9272      2993205 :   return mem;
    9273              : }
    9274              : 
    9275              : /* A subroutine of expand_expr_addr_expr.  Evaluate the address of EXP.
    9276              :    The TARGET, TMODE and MODIFIER arguments are as for expand_expr.  */
    9277              : 
    9278              : static rtx
    9279     14661651 : expand_expr_addr_expr_1 (tree exp, rtx target, scalar_int_mode tmode,
    9280              :                          enum expand_modifier modifier, addr_space_t as)
    9281              : {
    9282     14661651 :   rtx result, subtarget;
    9283     14661651 :   tree inner, offset;
    9284     14661651 :   poly_int64 bitsize, bitpos;
    9285     14661651 :   int unsignedp, reversep, volatilep = 0;
    9286     14661651 :   machine_mode mode1;
    9287              : 
    9288              :   /* If we are taking the address of a constant and are at the top level,
    9289              :      we have to use output_constant_def since we can't call force_const_mem
    9290              :      at top level.  */
    9291              :   /* ??? This should be considered a front-end bug.  We should not be
    9292              :      generating ADDR_EXPR of something that isn't an LVALUE.  The only
    9293              :      exception here is STRING_CST.  */
    9294     14661651 :   if (CONSTANT_CLASS_P (exp))
    9295              :     {
    9296      2746764 :       result = XEXP (expand_expr_constant (exp, 0, modifier), 0);
    9297      2746764 :       if (modifier < EXPAND_SUM)
    9298      1838405 :         result = force_operand (result, target);
    9299              :       return result;
    9300              :     }
    9301              : 
    9302              :   /* Everything must be something allowed by is_gimple_addressable.  */
    9303     11914887 :   switch (TREE_CODE (exp))
    9304              :     {
    9305           46 :     case INDIRECT_REF:
    9306              :       /* This case will happen via recursion for &a->b.  */
    9307           46 :       return expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
    9308              : 
    9309       585505 :     case MEM_REF:
    9310       585505 :       {
    9311       585505 :         tree tem = TREE_OPERAND (exp, 0);
    9312       585505 :         if (!integer_zerop (TREE_OPERAND (exp, 1)))
    9313       309584 :           tem = fold_build_pointer_plus (tem, TREE_OPERAND (exp, 1));
    9314       585505 :         return expand_expr (tem, target, tmode, modifier);
    9315              :       }
    9316              : 
    9317         1188 :     case TARGET_MEM_REF:
    9318         1188 :       return addr_for_mem_ref (exp, as, true);
    9319              : 
    9320        56776 :     case CONST_DECL:
    9321              :       /* Expand the initializer like constants above.  */
    9322        56776 :       result = XEXP (expand_expr_constant (DECL_INITIAL (exp),
    9323              :                                            0, modifier), 0);
    9324        56776 :       if (modifier < EXPAND_SUM)
    9325        56770 :         result = force_operand (result, target);
    9326              :       return result;
    9327              : 
    9328          208 :     case REALPART_EXPR:
    9329              :       /* The real part of the complex number is always first, therefore
    9330              :          the address is the same as the address of the parent object.  */
    9331          208 :       offset = 0;
    9332          208 :       bitpos = 0;
    9333          208 :       inner = TREE_OPERAND (exp, 0);
    9334          208 :       break;
    9335              : 
    9336          135 :     case IMAGPART_EXPR:
    9337              :       /* The imaginary part of the complex number is always second.
    9338              :          The expression is therefore always offset by the size of the
    9339              :          scalar type.  */
    9340          135 :       offset = 0;
    9341          270 :       bitpos = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (exp)));
    9342          135 :       inner = TREE_OPERAND (exp, 0);
    9343          135 :       break;
    9344              : 
    9345           13 :     case COMPOUND_LITERAL_EXPR:
    9346              :       /* Allow COMPOUND_LITERAL_EXPR in initializers or coming from
    9347              :          initializers, if e.g. rtl_for_decl_init is called on DECL_INITIAL
    9348              :          with COMPOUND_LITERAL_EXPRs in it, or ARRAY_REF on a const static
    9349              :          array with address of COMPOUND_LITERAL_EXPR in DECL_INITIAL;
    9350              :          the initializers aren't gimplified.  */
    9351           13 :       if (COMPOUND_LITERAL_EXPR_DECL (exp)
    9352           13 :           && is_global_var (COMPOUND_LITERAL_EXPR_DECL (exp)))
    9353           13 :         return expand_expr_addr_expr_1 (COMPOUND_LITERAL_EXPR_DECL (exp),
    9354           13 :                                         target, tmode, modifier, as);
    9355              :       /* FALLTHRU */
    9356     11271016 :     default:
    9357              :       /* If the object is a DECL, then expand it for its rtl.  Don't bypass
    9358              :          expand_expr, as that can have various side effects; LABEL_DECLs for
    9359              :          example, may not have their DECL_RTL set yet.  Expand the rtl of
    9360              :          CONSTRUCTORs too, which should yield a memory reference for the
    9361              :          constructor's contents.  Assume language specific tree nodes can
    9362              :          be expanded in some interesting way.  */
    9363     11271016 :       gcc_assert (TREE_CODE (exp) < LAST_AND_UNUSED_TREE_CODE);
    9364     11271016 :       if (DECL_P (exp)
    9365      1335203 :           || TREE_CODE (exp) == CONSTRUCTOR
    9366      1335203 :           || TREE_CODE (exp) == COMPOUND_LITERAL_EXPR)
    9367              :         {
    9368     16350748 :           result = expand_expr (exp, target, tmode,
    9369              :                                 modifier == EXPAND_INITIALIZER
    9370              :                                 ? EXPAND_INITIALIZER : EXPAND_CONST_ADDRESS);
    9371              : 
    9372              :           /* If the DECL isn't in memory, then the DECL wasn't properly
    9373              :              marked TREE_ADDRESSABLE, which will be either a front-end
    9374              :              or a tree optimizer bug.  */
    9375              : 
    9376      9935813 :           gcc_assert (MEM_P (result));
    9377      9935811 :           result = XEXP (result, 0);
    9378              : 
    9379              :           /* ??? Is this needed anymore?  */
    9380      9935811 :           if (DECL_P (exp))
    9381      9935811 :             TREE_USED (exp) = 1;
    9382              : 
    9383      9935811 :           if (modifier != EXPAND_INITIALIZER
    9384              :               && modifier != EXPAND_CONST_ADDRESS
    9385      9935811 :               && modifier != EXPAND_SUM)
    9386      4348840 :             result = force_operand (result, target);
    9387              :           return result;
    9388              :         }
    9389              : 
    9390              :       /* Pass FALSE as the last argument to get_inner_reference although
    9391              :          we are expanding to RTL.  The rationale is that we know how to
    9392              :          handle "aligning nodes" here: we can just bypass them because
    9393              :          they won't change the final object whose address will be returned
    9394              :          (they actually exist only for that purpose).  */
    9395      1335203 :       inner = get_inner_reference (exp, &bitsize, &bitpos, &offset, &mode1,
    9396              :                                    &unsignedp, &reversep, &volatilep);
    9397      1335203 :       break;
    9398              :     }
    9399              : 
    9400              :   /* We must have made progress.  */
    9401      1335546 :   gcc_assert (inner != exp);
    9402              : 
    9403      1335546 :   subtarget = offset || maybe_ne (bitpos, 0) ? NULL_RTX : target;
    9404              :   /* For VIEW_CONVERT_EXPR, where the outer alignment is bigger than
    9405              :      inner alignment, force the inner to be sufficiently aligned.  */
    9406      1335546 :   if (CONSTANT_CLASS_P (inner)
    9407      1335546 :       && TYPE_ALIGN (TREE_TYPE (inner)) < TYPE_ALIGN (TREE_TYPE (exp)))
    9408              :     {
    9409            0 :       inner = copy_node (inner);
    9410            0 :       TREE_TYPE (inner) = copy_node (TREE_TYPE (inner));
    9411            0 :       SET_TYPE_ALIGN (TREE_TYPE (inner), TYPE_ALIGN (TREE_TYPE (exp)));
    9412            0 :       TYPE_USER_ALIGN (TREE_TYPE (inner)) = 1;
    9413              :     }
    9414      1335546 :   result = expand_expr_addr_expr_1 (inner, subtarget, tmode, modifier, as);
    9415              : 
    9416      1335546 :   if (offset)
    9417              :     {
    9418        56101 :       rtx tmp;
    9419              : 
    9420        56101 :       if (modifier != EXPAND_NORMAL)
    9421         1719 :         result = force_operand (result, NULL);
    9422        57820 :       tmp = expand_expr (offset, NULL_RTX, tmode,
    9423              :                          modifier == EXPAND_INITIALIZER
    9424              :                           ? EXPAND_INITIALIZER : EXPAND_NORMAL);
    9425              : 
    9426              :       /* expand_expr is allowed to return an object in a mode other
    9427              :          than TMODE.  If it did, we need to convert.  */
    9428        56101 :       if (GET_MODE (tmp) != VOIDmode && tmode != GET_MODE (tmp))
    9429            0 :         tmp = convert_modes (tmode, GET_MODE (tmp),
    9430            0 :                              tmp, TYPE_UNSIGNED (TREE_TYPE (offset)));
    9431        56101 :       result = convert_memory_address_addr_space (tmode, result, as);
    9432        56101 :       tmp = convert_memory_address_addr_space (tmode, tmp, as);
    9433              : 
    9434        56101 :       if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
    9435         1719 :         result = simplify_gen_binary (PLUS, tmode, result, tmp);
    9436              :       else
    9437              :         {
    9438        54382 :           subtarget = maybe_ne (bitpos, 0) ? NULL_RTX : target;
    9439        54382 :           result = expand_simple_binop (tmode, PLUS, result, tmp, subtarget,
    9440              :                                         1, OPTAB_LIB_WIDEN);
    9441              :         }
    9442              :     }
    9443              : 
    9444      1335546 :   if (maybe_ne (bitpos, 0))
    9445              :     {
    9446              :       /* Someone beforehand should have rejected taking the address
    9447              :          of an object that isn't byte-aligned.  */
    9448       620614 :       poly_int64 bytepos = exact_div (bitpos, BITS_PER_UNIT);
    9449       620614 :       result = convert_memory_address_addr_space (tmode, result, as);
    9450       620614 :       result = plus_constant (tmode, result, bytepos);
    9451       620614 :       if (modifier < EXPAND_SUM)
    9452       583088 :         result = force_operand (result, target);
    9453              :     }
    9454              : 
    9455              :   return result;
    9456              : }
    9457              : 
    9458              : /* A subroutine of expand_expr.  Evaluate EXP, which is an ADDR_EXPR.
    9459              :    The TARGET, TMODE and MODIFIER arguments are as for expand_expr.  */
    9460              : 
    9461              : static rtx
    9462     13326090 : expand_expr_addr_expr (tree exp, rtx target, machine_mode tmode,
    9463              :                        enum expand_modifier modifier)
    9464              : {
    9465     13326090 :   addr_space_t as = ADDR_SPACE_GENERIC;
    9466     13326090 :   scalar_int_mode address_mode = Pmode;
    9467     13326090 :   scalar_int_mode pointer_mode = ptr_mode;
    9468     13326090 :   machine_mode rmode;
    9469     13326090 :   rtx result;
    9470              : 
    9471              :   /* Target mode of VOIDmode says "whatever's natural".  */
    9472     13326090 :   if (tmode == VOIDmode)
    9473     11345278 :     tmode = TYPE_MODE (TREE_TYPE (exp));
    9474              : 
    9475     13326090 :   if (POINTER_TYPE_P (TREE_TYPE (exp)))
    9476              :     {
    9477     13326090 :       as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)));
    9478     13326090 :       address_mode = targetm.addr_space.address_mode (as);
    9479     13326090 :       pointer_mode = targetm.addr_space.pointer_mode (as);
    9480              :     }
    9481              : 
    9482              :   /* We can get called with some Weird Things if the user does silliness
    9483              :      like "(short) &a".  In that case, convert_memory_address won't do
    9484              :      the right thing, so ignore the given target mode.  */
    9485     13326090 :   scalar_int_mode new_tmode = (tmode == pointer_mode
    9486     13326090 :                                ? pointer_mode
    9487     13326090 :                                : address_mode);
    9488              : 
    9489     13326090 :   result = expand_expr_addr_expr_1 (TREE_OPERAND (exp, 0), target,
    9490              :                                     new_tmode, modifier, as);
    9491              : 
    9492              :   /* Despite expand_expr claims concerning ignoring TMODE when not
    9493              :      strictly convenient, stuff breaks if we don't honor it.  Note
    9494              :      that combined with the above, we only do this for pointer modes.  */
    9495     13326088 :   rmode = GET_MODE (result);
    9496     13326088 :   if (rmode == VOIDmode)
    9497            6 :     rmode = new_tmode;
    9498     13326088 :   if (rmode != new_tmode)
    9499           74 :     result = convert_memory_address_addr_space (new_tmode, result, as);
    9500              : 
    9501     13326088 :   return result;
    9502              : }
    9503              : 
    9504              : /* Generate code for computing CONSTRUCTOR EXP.
    9505              :    An rtx for the computed value is returned.  If AVOID_TEMP_MEM
    9506              :    is TRUE, instead of creating a temporary variable in memory
    9507              :    NULL is returned and the caller needs to handle it differently.  */
    9508              : 
    9509              : static rtx
    9510       182463 : expand_constructor (tree exp, rtx target, enum expand_modifier modifier,
    9511              :                     bool avoid_temp_mem)
    9512              : {
    9513       182463 :   tree type = TREE_TYPE (exp);
    9514       182463 :   machine_mode mode = TYPE_MODE (type);
    9515              : 
    9516              :   /* Try to avoid creating a temporary at all.  This is possible
    9517              :      if all of the initializer is zero.
    9518              :      FIXME: try to handle all [0..255] initializers we can handle
    9519              :      with memset.  */
    9520       182463 :   if (TREE_STATIC (exp)
    9521         2500 :       && !TREE_ADDRESSABLE (exp)
    9522         2500 :       && target != 0 && mode == BLKmode
    9523       183615 :       && all_zeros_p (exp))
    9524              :     {
    9525         1143 :       clear_storage (target, expr_size (exp), BLOCK_OP_NORMAL);
    9526         1143 :       return target;
    9527              :     }
    9528              : 
    9529              :   /* All elts simple constants => refer to a constant in memory.  But
    9530              :      if this is a non-BLKmode mode, let it store a field at a time
    9531              :      since that should make a CONST_INT, CONST_WIDE_INT or
    9532              :      CONST_DOUBLE when we fold.  Likewise, if we have a target we can
    9533              :      use, it is best to store directly into the target unless the type
    9534              :      is large enough that memcpy will be used.  If we are making an
    9535              :      initializer and all operands are constant, put it in memory as
    9536              :      well.
    9537              : 
    9538              :      FIXME: Avoid trying to fill vector constructors piece-meal.
    9539              :      Output them with output_constant_def below unless we're sure
    9540              :      they're zeros.  This should go away when vector initializers
    9541              :      are treated like VECTOR_CST instead of arrays.  */
    9542       181320 :   if ((TREE_STATIC (exp)
    9543         1357 :        && ((mode == BLKmode
    9544           47 :             && ! (target != 0 && safe_from_p (target, exp, 1)))
    9545         1319 :            || TREE_ADDRESSABLE (exp)
    9546         1319 :            || (tree_fits_uhwi_p (TYPE_SIZE_UNIT (type))
    9547         1319 :                && (! can_move_by_pieces
    9548         1319 :                    (tree_to_uhwi (TYPE_SIZE_UNIT (type)),
    9549         1319 :                     TYPE_ALIGN (type)))
    9550            4 :                && ! mostly_zeros_p (exp))))
    9551       182637 :       || ((modifier == EXPAND_INITIALIZER || modifier == EXPAND_CONST_ADDRESS)
    9552            0 :           && TREE_CONSTANT (exp)))
    9553              :     {
    9554           40 :       rtx constructor;
    9555              : 
    9556           40 :       if (avoid_temp_mem)
    9557              :         return NULL_RTX;
    9558              : 
    9559           38 :       constructor = expand_expr_constant (exp, 1, modifier);
    9560              : 
    9561           38 :       if (modifier != EXPAND_CONST_ADDRESS
    9562              :           && modifier != EXPAND_INITIALIZER
    9563           38 :           && modifier != EXPAND_SUM)
    9564           38 :         constructor = validize_mem (constructor);
    9565              : 
    9566              :       return constructor;
    9567              :     }
    9568              : 
    9569              :   /* If the CTOR is available in static storage and not mostly
    9570              :      zeros and we can move it by pieces prefer to do so since
    9571              :      that's usually more efficient than performing a series of
    9572              :      stores from immediates.  */
    9573       181280 :   if (avoid_temp_mem
    9574           53 :       && TREE_STATIC (exp)
    9575           38 :       && TREE_CONSTANT (exp)
    9576           38 :       && tree_fits_uhwi_p (TYPE_SIZE_UNIT (type))
    9577           38 :       && can_move_by_pieces (tree_to_uhwi (TYPE_SIZE_UNIT (type)),
    9578           38 :                              TYPE_ALIGN (type))
    9579       181317 :       && ! mostly_zeros_p (exp))
    9580              :     return NULL_RTX;
    9581              : 
    9582              :   /* Handle calls that pass values in multiple non-contiguous
    9583              :      locations.  The Irix 6 ABI has examples of this.  */
    9584       146285 :   if (target == 0 || ! safe_from_p (target, exp, 1)
    9585        39196 :       || GET_CODE (target) == PARALLEL || modifier == EXPAND_STACK_PARM
    9586              :       /* Also make a temporary if the store is to volatile memory, to
    9587              :          avoid individual accesses to aggregate members.  */
    9588       220434 :       || (GET_CODE (target) == MEM
    9589        34539 :           && MEM_VOLATILE_P (target)
    9590          134 :           && !TREE_ADDRESSABLE (TREE_TYPE (exp))))
    9591              :     {
    9592       142194 :       if (avoid_temp_mem)
    9593              :         return NULL_RTX;
    9594              : 
    9595       142183 :       target = assign_temp (type, TREE_ADDRESSABLE (exp), 1);
    9596              :     }
    9597              : 
    9598       181239 :   store_constructor (exp, target, 0, tree_to_poly_int64 (size_in_bytes (type)),
    9599              :                      false);
    9600       181239 :   return target;
    9601              : }
    9602              : 
    9603              : 
    9604              : /* expand_expr: generate code for computing expression EXP.
    9605              :    An rtx for the computed value is returned.  The value is never null.
    9606              :    In the case of a void EXP, const0_rtx is returned.
    9607              : 
    9608              :    The value may be stored in TARGET if TARGET is nonzero.
    9609              :    TARGET is just a suggestion; callers must assume that
    9610              :    the rtx returned may not be the same as TARGET.
    9611              : 
    9612              :    If TARGET is CONST0_RTX, it means that the value will be ignored.
    9613              : 
    9614              :    If TMODE is not VOIDmode, it suggests generating the
    9615              :    result in mode TMODE.  But this is done only when convenient.
    9616              :    Otherwise, TMODE is ignored and the value generated in its natural mode.
    9617              :    TMODE is just a suggestion; callers must assume that
    9618              :    the rtx returned may not have mode TMODE.
    9619              : 
    9620              :    Note that TARGET may have neither TMODE nor MODE.  In that case, it
    9621              :    probably will not be used.
    9622              : 
    9623              :    If MODIFIER is EXPAND_SUM then when EXP is an addition
    9624              :    we can return an rtx of the form (MULT (REG ...) (CONST_INT ...))
    9625              :    or a nest of (PLUS ...) and (MINUS ...) where the terms are
    9626              :    products as above, or REG or MEM, or constant.
    9627              :    Ordinarily in such cases we would output mul or add instructions
    9628              :    and then return a pseudo reg containing the sum.
    9629              : 
    9630              :    EXPAND_INITIALIZER is much like EXPAND_SUM except that
    9631              :    it also marks a label as absolutely required (it can't be dead).
    9632              :    It also makes a ZERO_EXTEND or SIGN_EXTEND instead of emitting extend insns.
    9633              :    This is used for outputting expressions used in initializers.
    9634              : 
    9635              :    EXPAND_CONST_ADDRESS says that it is okay to return a MEM
    9636              :    with a constant address even if that address is not normally legitimate.
    9637              :    EXPAND_INITIALIZER and EXPAND_SUM also have this effect.
    9638              : 
    9639              :    EXPAND_STACK_PARM is used when expanding to a TARGET on the stack for
    9640              :    a call parameter.  Such targets require special care as we haven't yet
    9641              :    marked TARGET so that it's safe from being trashed by libcalls.  We
    9642              :    don't want to use TARGET for anything but the final result;
    9643              :    Intermediate values must go elsewhere.   Additionally, calls to
    9644              :    emit_block_move will be flagged with BLOCK_OP_CALL_PARM.
    9645              : 
    9646              :    If EXP is a VAR_DECL whose DECL_RTL was a MEM with an invalid
    9647              :    address, and ALT_RTL is non-NULL, then *ALT_RTL is set to the
    9648              :    DECL_RTL of the VAR_DECL.  *ALT_RTL is also set if EXP is a
    9649              :    COMPOUND_EXPR whose second argument is such a VAR_DECL, and so on
    9650              :    recursively.
    9651              :    If the result can be stored at TARGET, and ALT_RTL is non-NULL,
    9652              :    then *ALT_RTL is set to TARGET (before legitimziation).
    9653              : 
    9654              :    If INNER_REFERENCE_P is true, we are expanding an inner reference.
    9655              :    In this case, we don't adjust a returned MEM rtx that wouldn't be
    9656              :    sufficiently aligned for its mode; instead, it's up to the caller
    9657              :    to deal with it afterwards.  This is used to make sure that unaligned
    9658              :    base objects for which out-of-bounds accesses are supported, for
    9659              :    example record types with trailing arrays, aren't realigned behind
    9660              :    the back of the caller.
    9661              :    The normal operating mode is to pass FALSE for this parameter.  */
    9662              : 
    9663              : rtx
    9664    161355220 : expand_expr_real (tree exp, rtx target, machine_mode tmode,
    9665              :                   enum expand_modifier modifier, rtx *alt_rtl,
    9666              :                   bool inner_reference_p)
    9667              : {
    9668    161355220 :   rtx ret;
    9669              : 
    9670              :   /* Handle ERROR_MARK before anybody tries to access its type.  */
    9671    161355220 :   if (TREE_CODE (exp) == ERROR_MARK
    9672    161355220 :       || (TREE_CODE (TREE_TYPE (exp)) == ERROR_MARK))
    9673              :     {
    9674            0 :       ret = CONST0_RTX (tmode);
    9675            0 :       return ret ? ret : const0_rtx;
    9676              :     }
    9677              : 
    9678    161355220 :   ret = expand_expr_real_1 (exp, target, tmode, modifier, alt_rtl,
    9679              :                             inner_reference_p);
    9680    161355220 :   return ret;
    9681              : }
    9682              : 
    9683              : /* Try to expand the conditional expression which is represented by
    9684              :    TREEOP0 ? TREEOP1 : TREEOP2 using conditional moves.  If it succeeds
    9685              :    return the rtl reg which represents the result.  Otherwise return
    9686              :    NULL_RTX.  */
    9687              : 
    9688              : static rtx
    9689        18154 : expand_cond_expr_using_cmove (tree treeop0 ATTRIBUTE_UNUSED,
    9690              :                               tree treeop1 ATTRIBUTE_UNUSED,
    9691              :                               tree treeop2 ATTRIBUTE_UNUSED)
    9692              : {
    9693        18154 :   rtx insn;
    9694        18154 :   rtx op00, op01, op1, op2;
    9695        18154 :   enum rtx_code comparison_code;
    9696        18154 :   machine_mode comparison_mode;
    9697        18154 :   gimple *srcstmt;
    9698        18154 :   rtx temp;
    9699        18154 :   tree type = TREE_TYPE (treeop1);
    9700        18154 :   int unsignedp = TYPE_UNSIGNED (type);
    9701        18154 :   machine_mode mode = TYPE_MODE (type);
    9702        18154 :   machine_mode orig_mode = mode;
    9703        18154 :   static bool expanding_cond_expr_using_cmove = false;
    9704              : 
    9705              :   /* Conditional move expansion can end up TERing two operands which,
    9706              :      when recursively hitting conditional expressions can result in
    9707              :      exponential behavior if the cmove expansion ultimatively fails.
    9708              :      It's hardly profitable to TER a cmove into a cmove so avoid doing
    9709              :      that by failing early if we end up recursing.  */
    9710        18154 :   if (expanding_cond_expr_using_cmove)
    9711              :     return NULL_RTX;
    9712              : 
    9713              :   /* If we cannot do a conditional move on the mode, try doing it
    9714              :      with the promoted mode. */
    9715        17909 :   if (!can_conditionally_move_p (mode))
    9716              :     {
    9717          288 :       mode = promote_mode (type, mode, &unsignedp);
    9718          288 :       if (!can_conditionally_move_p (mode))
    9719              :         return NULL_RTX;
    9720            0 :       temp = assign_temp (type, 0, 0); /* Use promoted mode for temp.  */
    9721              :     }
    9722              :   else
    9723        17621 :     temp = assign_temp (type, 0, 1);
    9724              : 
    9725        17621 :   expanding_cond_expr_using_cmove = true;
    9726        17621 :   start_sequence ();
    9727        17621 :   expand_operands (treeop1, treeop2,
    9728              :                    mode == orig_mode ? temp : NULL_RTX, &op1, &op2,
    9729              :                    EXPAND_NORMAL);
    9730              : 
    9731        17621 :   if (TREE_CODE (treeop0) == SSA_NAME
    9732        17458 :       && (srcstmt = get_def_for_expr_class (treeop0, tcc_comparison))
    9733        32688 :       && !VECTOR_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (srcstmt))))
    9734              :     {
    9735        15067 :       type = TREE_TYPE (gimple_assign_rhs1 (srcstmt));
    9736        15067 :       enum tree_code cmpcode = gimple_assign_rhs_code (srcstmt);
    9737        15067 :       op00 = expand_normal (gimple_assign_rhs1 (srcstmt));
    9738        15067 :       op01 = expand_normal (gimple_assign_rhs2 (srcstmt));
    9739        15067 :       comparison_mode = TYPE_MODE (type);
    9740        15067 :       unsignedp = TYPE_UNSIGNED (type);
    9741        15067 :       comparison_code = convert_tree_comp_to_rtx (cmpcode, unsignedp);
    9742              :     }
    9743         2554 :   else if (COMPARISON_CLASS_P (treeop0)
    9744         2554 :            && !VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (treeop0, 0))))
    9745              :     {
    9746          163 :       type = TREE_TYPE (TREE_OPERAND (treeop0, 0));
    9747          163 :       enum tree_code cmpcode = TREE_CODE (treeop0);
    9748          163 :       op00 = expand_normal (TREE_OPERAND (treeop0, 0));
    9749          163 :       op01 = expand_normal (TREE_OPERAND (treeop0, 1));
    9750          163 :       unsignedp = TYPE_UNSIGNED (type);
    9751          163 :       comparison_mode = TYPE_MODE (type);
    9752          163 :       comparison_code = convert_tree_comp_to_rtx (cmpcode, unsignedp);
    9753              :     }
    9754              :   else
    9755              :     {
    9756         2391 :       op00 = expand_normal (treeop0);
    9757         2391 :       op01 = const0_rtx;
    9758         2391 :       comparison_code = NE;
    9759         2391 :       comparison_mode = GET_MODE (op00);
    9760         2391 :       if (comparison_mode == VOIDmode)
    9761            0 :         comparison_mode = TYPE_MODE (TREE_TYPE (treeop0));
    9762              :     }
    9763        17621 :   expanding_cond_expr_using_cmove = false;
    9764              : 
    9765        17621 :   if (GET_MODE (op1) != mode)
    9766         2475 :     op1 = gen_lowpart (mode, op1);
    9767              : 
    9768        17621 :   if (GET_MODE (op2) != mode)
    9769         9372 :     op2 = gen_lowpart (mode, op2);
    9770              : 
    9771              :   /* Try to emit the conditional move.  */
    9772        17621 :   insn = emit_conditional_move (temp,
    9773              :                                 { comparison_code, op00, op01,
    9774              :                                   comparison_mode },
    9775              :                                 op1, op2, mode,
    9776              :                                 unsignedp);
    9777              : 
    9778              :   /* If we could do the conditional move, emit the sequence,
    9779              :      and return.  */
    9780        17621 :   if (insn)
    9781              :     {
    9782        14975 :       rtx_insn *seq = end_sequence ();
    9783        14975 :       emit_insn (seq);
    9784        14975 :       return convert_modes (orig_mode, mode, temp, 0);
    9785              :     }
    9786              : 
    9787              :   /* Otherwise discard the sequence and fall back to code with
    9788              :      branches.  */
    9789         2646 :   end_sequence ();
    9790         2646 :   return NULL_RTX;
    9791              : }
    9792              : 
    9793              : /* A helper function for expand_expr_real_2 to be used with a
    9794              :    misaligned mem_ref TEMP.  Assume an unsigned type if UNSIGNEDP
    9795              :    is nonzero, with alignment ALIGN in bits.
    9796              :    Store the value at TARGET if possible (if TARGET is nonzero).
    9797              :    Regardless of TARGET, we return the rtx for where the value is placed.
    9798              :    If the result can be stored at TARGET, and ALT_RTL is non-NULL,
    9799              :    then *ALT_RTL is set to TARGET (before legitimziation).  */
    9800              : 
    9801              : static rtx
    9802       207830 : expand_misaligned_mem_ref (rtx temp, machine_mode mode, int unsignedp,
    9803              :                            unsigned int align, rtx target, rtx *alt_rtl)
    9804              : {
    9805       207830 :   enum insn_code icode;
    9806              : 
    9807       207830 :   if ((icode = optab_handler (movmisalign_optab, mode))
    9808              :       != CODE_FOR_nothing)
    9809              :     {
    9810       131206 :       class expand_operand ops[2];
    9811              : 
    9812              :       /* We've already validated the memory, and we're creating a
    9813              :          new pseudo destination.  The predicates really can't fail,
    9814              :          nor can the generator.  */
    9815       131206 :       create_output_operand (&ops[0], NULL_RTX, mode);
    9816       131206 :       create_fixed_operand (&ops[1], temp);
    9817       131206 :       expand_insn (icode, 2, ops);
    9818       131206 :       temp = ops[0].value;
    9819              :     }
    9820        76624 :   else if (targetm.slow_unaligned_access (mode, align))
    9821            0 :     temp = extract_bit_field (temp, GET_MODE_BITSIZE (mode),
    9822              :                               0, unsignedp, target,
    9823              :                               mode, mode, false, alt_rtl);
    9824       207830 :   return temp;
    9825              : }
    9826              : 
    9827              : /* Return true if OP is known to be either LOWER or LOWER + 1, with one
    9828              :    value a positive power of two.  */
    9829              : 
    9830              : static bool
    9831        64929 : near_pow2_divisor_range_p (tree op, wide_int &lower)
    9832              : {
    9833        64929 :   if (TREE_CODE (op) != SSA_NAME)
    9834              :     return false;
    9835              : 
    9836        35090 :   int_range_max range;
    9837        35090 :   range_query *query = get_range_query (cfun);
    9838        35090 :   if (!query->range_of_expr (range, op, currently_expanding_gimple_stmt)
    9839        35090 :       || range.num_pairs () != 1)
    9840              :     return false;
    9841              : 
    9842        33029 :   lower = range.lower_bound ();
    9843        33029 :   wide_int upper = lower + 1;
    9844        66058 :   return (range.upper_bound () == upper
    9845          101 :           && wi::gt_p (lower, 0, TYPE_SIGN (TREE_TYPE (op)))
    9846        33234 :           && (wi::popcount (lower) == 1 || wi::popcount (upper) == 1));
    9847        35090 : }
    9848              : 
    9849              : /* Helper function of expand_expr_2, expand a division or modulo.
    9850              :    op0 and op1 should be already expanded treeop0 and treeop1, using
    9851              :    expand_operands.  */
    9852              : 
    9853              : static rtx
    9854       177767 : expand_expr_divmod (tree_code code, machine_mode mode, tree treeop0,
    9855              :                     tree treeop1, rtx op0, rtx op1, rtx target, int unsignedp)
    9856              : {
    9857       355534 :   bool mod_p = (code == TRUNC_MOD_EXPR || code == FLOOR_MOD_EXPR
    9858       177767 :                 || code == CEIL_MOD_EXPR || code == ROUND_MOD_EXPR);
    9859       177767 :   bool speed_p = optimize_insn_for_speed_p ();
    9860              : 
    9861       177767 :   scalar_int_mode int_mode;
    9862       177767 :   wide_int lower;
    9863              :   /* Split x / y when y is one of two neighboring constants and the target can
    9864              :      select between the constant divisions cheaply.  */
    9865       177767 :   if (code == TRUNC_DIV_EXPR
    9866       247934 :       && is_a <scalar_int_mode> (mode, &int_mode)
    9867        70240 :       && speed_p
    9868        67565 :       && can_conditionally_move_p (int_mode)
    9869       242696 :       && near_pow2_divisor_range_p (treeop1, lower))
    9870              :     {
    9871           73 :       signop sgn = TYPE_SIGN (TREE_TYPE (treeop1));
    9872           73 :       unsigned int prec = GET_MODE_PRECISION (int_mode);
    9873           73 :       wide_int upper = lower + 1;
    9874           73 :       rtx op_lower
    9875           73 :         = immed_wide_int_const (wide_int::from (lower, prec, sgn), int_mode);
    9876           73 :       rtx op_upper
    9877           73 :         = immed_wide_int_const (wide_int::from (upper, prec, sgn), int_mode);
    9878              : 
    9879           73 :       do_pending_stack_adjust ();
    9880           73 :       start_sequence ();
    9881           73 :       rtx q_lower = expand_divmod (0, TRUNC_DIV_EXPR, mode, op0, op_lower,
    9882              :                                    NULL_RTX, unsignedp);
    9883           73 :       rtx q_upper = expand_divmod (0, TRUNC_DIV_EXPR, mode, op0, op_upper,
    9884              :                                    NULL_RTX, unsignedp);
    9885           73 :       rtx split_ret
    9886           73 :         = emit_conditional_move (target, { EQ, op1, op_lower, int_mode },
    9887              :                                  q_lower, q_upper, int_mode, unsignedp);
    9888           73 :       rtx_insn *split_insns = end_sequence ();
    9889              : 
    9890              :       /* Cost the unsplit form as a single DIV/UDIV.  */
    9891           73 :       rtx div_rtx = gen_rtx_fmt_ee (unsignedp ? UDIV : DIV, int_mode, op0, op1);
    9892           73 :       unsigned div_cost = set_src_cost (div_rtx, int_mode, speed_p);
    9893           73 :       if (split_ret && seq_cost (split_insns, speed_p) < div_cost)
    9894              :         {
    9895           73 :           emit_insn (split_insns);
    9896           73 :           return split_ret;
    9897              :         }
    9898           73 :     }
    9899              : 
    9900       177694 :   if (SCALAR_INT_MODE_P (mode)
    9901       177694 :       && optimize >= 2
    9902       149555 :       && get_range_pos_neg (treeop0, currently_expanding_gimple_stmt) == 1
    9903       227116 :       && get_range_pos_neg (treeop1, currently_expanding_gimple_stmt) == 1)
    9904              :     {
    9905              :       /* If both arguments are known to be positive when interpreted
    9906              :          as signed, we can expand it as both signed and unsigned
    9907              :          division or modulo.  Choose the cheaper sequence in that case.  */
    9908        14326 :       do_pending_stack_adjust ();
    9909        14326 :       start_sequence ();
    9910        14326 :       rtx uns_ret = expand_divmod (mod_p, code, mode, op0, op1, target, 1);
    9911        14326 :       rtx_insn *uns_insns = end_sequence ();
    9912        14326 :       start_sequence ();
    9913        14326 :       rtx sgn_ret = expand_divmod (mod_p, code, mode, op0, op1, target, 0);
    9914        14326 :       rtx_insn *sgn_insns = end_sequence ();
    9915        14326 :       unsigned uns_cost = seq_cost (uns_insns, speed_p);
    9916        14326 :       unsigned sgn_cost = seq_cost (sgn_insns, speed_p);
    9917        14326 :       bool was_tie = false;
    9918              : 
    9919              :       /* If costs are the same then use as tie breaker the other other
    9920              :          factor.  */
    9921        14326 :       if (uns_cost == sgn_cost)
    9922              :         {
    9923         3476 :           uns_cost = seq_cost (uns_insns, !speed_p);
    9924         3476 :           sgn_cost = seq_cost (sgn_insns, !speed_p);
    9925         3476 :           was_tie = true;
    9926              :         }
    9927              : 
    9928        14326 :       if (dump_file && (dump_flags & TDF_DETAILS))
    9929            0 :         fprintf (dump_file, ";; positive division:%s unsigned cost: %u; "
    9930              :                             "signed cost: %u\n",
    9931              :                  was_tie ? " (needed tie breaker)" : "", uns_cost, sgn_cost);
    9932              : 
    9933        14326 :       if (uns_cost < sgn_cost || (uns_cost == sgn_cost && unsignedp))
    9934              :         {
    9935        11719 :           emit_insn (uns_insns);
    9936        11719 :           return uns_ret;
    9937              :         }
    9938         2607 :       emit_insn (sgn_insns);
    9939         2607 :       return sgn_ret;
    9940              :     }
    9941       163368 :   return expand_divmod (mod_p, code, mode, op0, op1, target, unsignedp);
    9942       177767 : }
    9943              : 
    9944              : /* Return true if EXP has a range of values [0..1], false
    9945              :    otherwise. This works for constants and ssa names, calling back into the ranger.  */
    9946              : static bool
    9947      1579388 : expr_has_boolean_range (tree exp, gimple *stmt)
    9948              : {
    9949              :   /* An integral type with a single bit of precision.  */
    9950      3158763 :   if (INTEGRAL_TYPE_P (TREE_TYPE (exp))
    9951      1579388 :       && TYPE_UNSIGNED (TREE_TYPE (exp))
    9952      2621030 :       && TYPE_PRECISION (TREE_TYPE (exp)) == 1)
    9953              :     return true;
    9954              : 
    9955              :   /* Signed 1 bit integers are not boolean ranges. */
    9956      3158763 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (exp))
    9957      3158763 :       || TYPE_PRECISION (TREE_TYPE (exp)) <= 1)
    9958              :     return false;
    9959              : 
    9960      1579332 :   if (TREE_CODE (exp) == SSA_NAME)
    9961       942209 :     return ssa_name_has_boolean_range (exp, stmt);
    9962       637123 :   if (TREE_CODE (exp) == INTEGER_CST)
    9963       562954 :     return wi::leu_p (wi::to_wide (exp), 1);
    9964              :   return false;
    9965              : }
    9966              : 
    9967              : rtx
    9968     13907927 : expand_expr_real_2 (const_sepops ops, rtx target, machine_mode tmode,
    9969              :                     enum expand_modifier modifier)
    9970              : {
    9971     13907927 :   rtx op0, op1, op2, temp;
    9972     13907927 :   rtx_code_label *lab;
    9973     13907927 :   tree type;
    9974     13907927 :   int unsignedp;
    9975     13907927 :   machine_mode mode;
    9976     13907927 :   scalar_int_mode int_mode;
    9977     13907927 :   enum tree_code code = ops->code;
    9978     13907927 :   optab this_optab;
    9979     13907927 :   rtx subtarget, original_target;
    9980     13907927 :   int ignore;
    9981     13907927 :   bool reduce_bit_field;
    9982     13907927 :   location_t loc = ops->location;
    9983     13907927 :   tree treeop0, treeop1, treeop2;
    9984              : #define REDUCE_BIT_FIELD(expr)  (reduce_bit_field                         \
    9985              :                                  ? reduce_to_bit_field_precision ((expr), \
    9986              :                                                                   target, \
    9987              :                                                                   type)   \
    9988              :                                  : (expr))
    9989              : 
    9990     13907927 :   type = ops->type;
    9991     13907927 :   mode = TYPE_MODE (type);
    9992     13907927 :   unsignedp = TYPE_UNSIGNED (type);
    9993              : 
    9994     13907927 :   treeop0 = ops->op0;
    9995     13907927 :   treeop1 = ops->op1;
    9996     13907927 :   treeop2 = ops->op2;
    9997              : 
    9998              :   /* We should be called only on simple (binary or unary) expressions,
    9999              :      exactly those that are valid in gimple expressions that aren't
   10000              :      GIMPLE_SINGLE_RHS (or invalid).  */
   10001     13907927 :   gcc_assert (get_gimple_rhs_class (code) == GIMPLE_UNARY_RHS
   10002              :               || get_gimple_rhs_class (code) == GIMPLE_BINARY_RHS
   10003              :               || get_gimple_rhs_class (code) == GIMPLE_TERNARY_RHS);
   10004              : 
   10005     27815854 :   ignore = (target == const0_rtx
   10006     13907927 :             || ((CONVERT_EXPR_CODE_P (code)
   10007      9994550 :                  || code == COND_EXPR || code == VIEW_CONVERT_EXPR)
   10008      3931531 :                 && TREE_CODE (type) == VOID_TYPE));
   10009              : 
   10010              :   /* We should be called only if we need the result.  */
   10011            0 :   gcc_assert (!ignore);
   10012              : 
   10013              :   /* An operation in what may be a bit-field type needs the
   10014              :      result to be reduced to the precision of the bit-field type,
   10015              :      which is narrower than that of the type's mode.  */
   10016     28641362 :   reduce_bit_field = (INTEGRAL_TYPE_P (type)
   10017     13907927 :                       && !type_has_mode_precision_p (type));
   10018              : 
   10019       825508 :   if (reduce_bit_field
   10020       825508 :       && (modifier == EXPAND_STACK_PARM
   10021       825008 :           || (target && GET_MODE (target) != mode)))
   10022       505538 :     target = 0;
   10023              : 
   10024              :   /* Use subtarget as the target for operand 0 of a binary operation.  */
   10025     13907927 :   subtarget = get_subtarget (target);
   10026     13907927 :   original_target = target;
   10027              : 
   10028     13907927 :   switch (code)
   10029              :     {
   10030      3917612 :     case NON_LVALUE_EXPR:
   10031      3917612 :     case PAREN_EXPR:
   10032      3917612 :     CASE_CONVERT:
   10033      3917612 :       if (treeop0 == error_mark_node)
   10034            0 :         return const0_rtx;
   10035              : 
   10036      3917612 :       if (TREE_CODE (type) == UNION_TYPE)
   10037              :         {
   10038            0 :           tree valtype = TREE_TYPE (treeop0);
   10039              : 
   10040              :           /* If both input and output are BLKmode, this conversion isn't doing
   10041              :              anything except possibly changing memory attribute.  */
   10042            0 :           if (mode == BLKmode && TYPE_MODE (valtype) == BLKmode)
   10043              :             {
   10044            0 :               rtx result = expand_expr (treeop0, target, tmode,
   10045              :                                         modifier);
   10046              : 
   10047            0 :               result = copy_rtx (result);
   10048            0 :               set_mem_attributes (result, type, 0);
   10049            0 :               return result;
   10050              :             }
   10051              : 
   10052            0 :           if (target == 0)
   10053              :             {
   10054            0 :               if (TYPE_MODE (type) != BLKmode)
   10055            0 :                 target = gen_reg_rtx (TYPE_MODE (type));
   10056              :               else
   10057            0 :                 target = assign_temp (type, 1, 1);
   10058              :             }
   10059              : 
   10060            0 :           if (MEM_P (target))
   10061              :             /* Store data into beginning of memory target.  */
   10062            0 :             store_expr (treeop0,
   10063            0 :                         adjust_address (target, TYPE_MODE (valtype), 0),
   10064              :                         modifier == EXPAND_STACK_PARM,
   10065            0 :                         false, TYPE_REVERSE_STORAGE_ORDER (type));
   10066              : 
   10067              :           else
   10068              :             {
   10069            0 :               gcc_assert (REG_P (target)
   10070              :                           && !TYPE_REVERSE_STORAGE_ORDER (type));
   10071              : 
   10072              :               /* Store this field into a union of the proper type.  */
   10073            0 :               poly_uint64 op0_size
   10074            0 :                 = tree_to_poly_uint64 (TYPE_SIZE (TREE_TYPE (treeop0)));
   10075            0 :               poly_uint64 union_size = GET_MODE_BITSIZE (mode);
   10076            0 :               store_field (target,
   10077              :                            /* The conversion must be constructed so that
   10078              :                               we know at compile time how many bits
   10079              :                               to preserve.  */
   10080            0 :                            ordered_min (op0_size, union_size),
   10081            0 :                            0, 0, 0, TYPE_MODE (valtype), treeop0, 0,
   10082              :                            false, false);
   10083              :             }
   10084              : 
   10085              :           /* Return the entire union.  */
   10086              :           return target;
   10087              :         }
   10088              : 
   10089      3917612 :       if (mode == TYPE_MODE (TREE_TYPE (treeop0)))
   10090              :         {
   10091      2325389 :           op0 = expand_expr (treeop0, target, VOIDmode,
   10092              :                              modifier);
   10093              : 
   10094      2325389 :           return REDUCE_BIT_FIELD (op0);
   10095              :         }
   10096              : 
   10097      1963896 :       op0 = expand_expr (treeop0, NULL_RTX, mode,
   10098              :                          modifier == EXPAND_SUM ? EXPAND_NORMAL : modifier);
   10099      1592223 :       if (GET_MODE (op0) == mode)
   10100              :         ;
   10101              : 
   10102              :       /* If OP0 is a constant, just convert it into the proper mode.  */
   10103      1548960 :       else if (CONSTANT_P (op0))
   10104              :         {
   10105          902 :           tree inner_type = TREE_TYPE (treeop0);
   10106          902 :           machine_mode inner_mode = GET_MODE (op0);
   10107              : 
   10108          902 :           if (inner_mode == VOIDmode)
   10109           15 :             inner_mode = TYPE_MODE (inner_type);
   10110              : 
   10111          902 :           if (modifier == EXPAND_INITIALIZER)
   10112            0 :             op0 = force_lowpart_subreg (mode, op0, inner_mode);
   10113              :           else
   10114          902 :             op0 = convert_modes (mode, inner_mode, op0,
   10115          902 :                                  TYPE_UNSIGNED (inner_type));
   10116              :         }
   10117              : 
   10118      1548058 :       else if (modifier == EXPAND_INITIALIZER)
   10119           24 :         op0 = gen_rtx_fmt_e (TYPE_UNSIGNED (TREE_TYPE (treeop0))
   10120              :                              ? ZERO_EXTEND : SIGN_EXTEND, mode, op0);
   10121              : 
   10122      1548046 :       else if (SCALAR_INT_MODE_P (GET_MODE (op0))
   10123      1371752 :                && optimize >= 2
   10124       807810 :                && SCALAR_INT_MODE_P (mode)
   10125       807810 :                && INTEGRAL_TYPE_P (TREE_TYPE (treeop0))
   10126       807642 :                && (GET_MODE_SIZE (as_a <scalar_int_mode> (mode))
   10127      1615284 :                    > GET_MODE_SIZE (as_a <scalar_int_mode> (GET_MODE (op0))))
   10128      2113537 :                && get_range_pos_neg (treeop0,
   10129              :                                      currently_expanding_gimple_stmt) == 1)
   10130              :         {
   10131              :           /* If argument is known to be positive when interpreted
   10132              :              as signed, we can expand it as both sign and zero
   10133              :              extension.  Choose the cheaper sequence in that case.  */
   10134       144482 :           bool speed_p = optimize_insn_for_speed_p ();
   10135       144482 :           rtx uns_ret = NULL_RTX, sgn_ret = NULL_RTX;
   10136       144482 :           do_pending_stack_adjust ();
   10137       144482 :           start_sequence ();
   10138       144482 :           if (target == NULL_RTX)
   10139       119643 :             uns_ret = convert_to_mode (mode, op0, 1);
   10140              :           else
   10141        24839 :             convert_move (target, op0, 1);
   10142       144482 :           rtx_insn *uns_insns = end_sequence ();
   10143       144482 :           start_sequence ();
   10144       144482 :           if (target == NULL_RTX)
   10145       119643 :             sgn_ret = convert_to_mode (mode, op0, 0);
   10146              :           else
   10147        24839 :             convert_move (target, op0, 0);
   10148       144482 :           rtx_insn *sgn_insns = end_sequence ();
   10149       144482 :           unsigned uns_cost = seq_cost (uns_insns, speed_p);
   10150       144482 :           unsigned sgn_cost = seq_cost (sgn_insns, speed_p);
   10151       144482 :           bool was_tie = false;
   10152              : 
   10153              :           /* If costs are the same then use as tie breaker the other other
   10154              :              factor.  */
   10155       144482 :           if (uns_cost == sgn_cost)
   10156              :             {
   10157        35937 :               uns_cost = seq_cost (uns_insns, !speed_p);
   10158        35937 :               sgn_cost = seq_cost (sgn_insns, !speed_p);
   10159        35937 :               was_tie = true;
   10160              :             }
   10161              : 
   10162       144482 :           if (dump_file && (dump_flags & TDF_DETAILS))
   10163            0 :             fprintf (dump_file, ";; positive extension:%s unsigned cost: %u; "
   10164              :                                 "signed cost: %u\n",
   10165              :                      was_tie ? " (needed tie breaker)" : "",
   10166              :                      uns_cost, sgn_cost);
   10167       144482 :           if (uns_cost < sgn_cost
   10168       144482 :               || (uns_cost == sgn_cost && TYPE_UNSIGNED (TREE_TYPE (treeop0))))
   10169              :             {
   10170       131186 :               emit_insn (uns_insns);
   10171       131186 :               sgn_ret = uns_ret;
   10172              :             }
   10173              :           else
   10174        13296 :             emit_insn (sgn_insns);
   10175       144482 :           if (target == NULL_RTX)
   10176       119643 :             op0 = sgn_ret;
   10177              :           else
   10178        24839 :             op0 = target;
   10179              :         }
   10180      1403564 :       else if (target == 0)
   10181       879422 :         op0 = convert_to_mode (mode, op0, TYPE_UNSIGNED (TREE_TYPE (treeop0)));
   10182              :       else
   10183              :         {
   10184       524142 :           convert_move (target, op0, TYPE_UNSIGNED (TREE_TYPE (treeop0)));
   10185       524142 :           op0 = target;
   10186              :         }
   10187              : 
   10188      1592223 :       return REDUCE_BIT_FIELD (op0);
   10189              : 
   10190            0 :     case ADDR_SPACE_CONVERT_EXPR:
   10191            0 :       {
   10192            0 :         tree treeop0_type = TREE_TYPE (treeop0);
   10193              : 
   10194            0 :         gcc_assert (POINTER_TYPE_P (type));
   10195            0 :         gcc_assert (POINTER_TYPE_P (treeop0_type));
   10196              : 
   10197            0 :         addr_space_t as_to = TYPE_ADDR_SPACE (TREE_TYPE (type));
   10198            0 :         addr_space_t as_from = TYPE_ADDR_SPACE (TREE_TYPE (treeop0_type));
   10199              : 
   10200              :         /* Conversions between pointers to the same address space should
   10201              :            have been implemented via CONVERT_EXPR / NOP_EXPR.  */
   10202            0 :         gcc_assert (as_to != as_from);
   10203              : 
   10204            0 :         op0 = expand_expr (treeop0, NULL_RTX, VOIDmode, modifier);
   10205              : 
   10206              :         /* Ask target code to handle conversion between pointers
   10207              :            to overlapping address spaces.  */
   10208            0 :         if (targetm.addr_space.subset_p (as_to, as_from)
   10209            0 :             || targetm.addr_space.subset_p (as_from, as_to))
   10210              :           {
   10211            0 :             op0 = targetm.addr_space.convert (op0, treeop0_type, type);
   10212              :           }
   10213              :         else
   10214              :           {
   10215              :             /* For disjoint address spaces, converting anything but a null
   10216              :                pointer invokes undefined behavior.  We truncate or extend the
   10217              :                value as if we'd converted via integers, which handles 0 as
   10218              :                required, and all others as the programmer likely expects.  */
   10219              : #ifndef POINTERS_EXTEND_UNSIGNED
   10220              :             const int POINTERS_EXTEND_UNSIGNED = 1;
   10221              : #endif
   10222            0 :             op0 = convert_modes (mode, TYPE_MODE (treeop0_type),
   10223              :                                  op0, POINTERS_EXTEND_UNSIGNED);
   10224              :           }
   10225            0 :         gcc_assert (op0);
   10226              :         return op0;
   10227              :       }
   10228              : 
   10229      1384749 :     case POINTER_PLUS_EXPR:
   10230              :       /* Even though the sizetype mode and the pointer's mode can be different
   10231              :          expand is able to handle this correctly and get the correct result out
   10232              :          of the PLUS_EXPR code.  */
   10233              :       /* Make sure to sign-extend the sizetype offset in a POINTER_PLUS_EXPR
   10234              :          if sizetype precision is smaller than pointer precision.  */
   10235      1384749 :       if (TYPE_PRECISION (sizetype) < TYPE_PRECISION (type))
   10236            0 :         treeop1 = fold_convert_loc (loc, type,
   10237              :                                     fold_convert_loc (loc, ssizetype,
   10238              :                                                       treeop1));
   10239              :       /* If sizetype precision is larger than pointer precision, truncate the
   10240              :          offset to have matching modes.  */
   10241      1384749 :       else if (TYPE_PRECISION (sizetype) > TYPE_PRECISION (type))
   10242            0 :         treeop1 = fold_convert_loc (loc, type, treeop1);
   10243              :       /* FALLTHRU */
   10244              : 
   10245      5483920 :     case PLUS_EXPR:
   10246              :       /* If we are adding a constant, a VAR_DECL that is sp, fp, or ap, and
   10247              :          something else, make sure we add the register to the constant and
   10248              :          then to the other thing.  This case can occur during strength
   10249              :          reduction and doing it this way will produce better code if the
   10250              :          frame pointer or argument pointer is eliminated.
   10251              : 
   10252              :          fold-const.cc will ensure that the constant is always in the inner
   10253              :          PLUS_EXPR, so the only case we need to do anything about is if
   10254              :          sp, ap, or fp is our second argument, in which case we must swap
   10255              :          the innermost first argument and our second argument.  */
   10256              : 
   10257      5483920 :       if (TREE_CODE (treeop0) == PLUS_EXPR
   10258         6601 :           && TREE_CODE (TREE_OPERAND (treeop0, 1)) == INTEGER_CST
   10259            0 :           && VAR_P (treeop1)
   10260      5483920 :           && (DECL_RTL (treeop1) == frame_pointer_rtx
   10261            0 :               || DECL_RTL (treeop1) == stack_pointer_rtx
   10262            0 :               || DECL_RTL (treeop1) == arg_pointer_rtx))
   10263              :         {
   10264            0 :           gcc_unreachable ();
   10265              :         }
   10266              : 
   10267              :       /* If the result is to be ptr_mode and we are adding an integer to
   10268              :          something, we might be forming a constant.  So try to use
   10269              :          plus_constant.  If it produces a sum and we can't accept it,
   10270              :          use force_operand.  This allows P = &ARR[const] to generate
   10271              :          efficient code on machines where a SYMBOL_REF is not a valid
   10272              :          address.
   10273              : 
   10274              :          If this is an EXPAND_SUM call, always return the sum.  */
   10275      5483920 :       if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER
   10276      5483920 :           || (mode == ptr_mode && (unsignedp || ! flag_trapv)))
   10277              :         {
   10278      3571222 :           if (modifier == EXPAND_STACK_PARM)
   10279        18874 :             target = 0;
   10280      3571222 :           if (TREE_CODE (treeop0) == INTEGER_CST
   10281      3572227 :               && HWI_COMPUTABLE_MODE_P (mode)
   10282      3572231 :               && TREE_CONSTANT (treeop1))
   10283              :             {
   10284            4 :               rtx constant_part;
   10285            4 :               HOST_WIDE_INT wc;
   10286            4 :               machine_mode wmode = TYPE_MODE (TREE_TYPE (treeop1));
   10287              : 
   10288            4 :               op1 = expand_expr (treeop1, subtarget, VOIDmode,
   10289              :                                  EXPAND_SUM);
   10290              :               /* Use wi::shwi to ensure that the constant is
   10291              :                  truncated according to the mode of OP1, then sign extended
   10292              :                  to a HOST_WIDE_INT.  Using the constant directly can result
   10293              :                  in non-canonical RTL in a 64x32 cross compile.  */
   10294            4 :               wc = TREE_INT_CST_LOW (treeop0);
   10295            4 :               constant_part =
   10296            4 :                 immed_wide_int_const (wi::shwi (wc, wmode), wmode);
   10297            4 :               op1 = plus_constant (mode, op1, INTVAL (constant_part));
   10298            4 :               if (modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
   10299            1 :                 op1 = force_operand (op1, target);
   10300            4 :               return REDUCE_BIT_FIELD (op1);
   10301              :             }
   10302              : 
   10303      3571218 :           else if (TREE_CODE (treeop1) == INTEGER_CST
   10304      7609419 :                    && HWI_COMPUTABLE_MODE_P (mode)
   10305      5983234 :                    && TREE_CONSTANT (treeop0))
   10306              :             {
   10307       286513 :               rtx constant_part;
   10308       286513 :               HOST_WIDE_INT wc;
   10309       286513 :               machine_mode wmode = TYPE_MODE (TREE_TYPE (treeop0));
   10310              : 
   10311       500784 :               op0 = expand_expr (treeop0, subtarget, VOIDmode,
   10312              :                                  (modifier == EXPAND_INITIALIZER
   10313              :                                  ? EXPAND_INITIALIZER : EXPAND_SUM));
   10314       286513 :               if (! CONSTANT_P (op0))
   10315              :                 {
   10316            6 :                   op1 = expand_expr (treeop1, NULL_RTX,
   10317              :                                      VOIDmode, modifier);
   10318              :                   /* Return a PLUS if modifier says it's OK.  */
   10319            6 :                   if (modifier == EXPAND_SUM
   10320              :                       || modifier == EXPAND_INITIALIZER)
   10321            6 :                     return simplify_gen_binary (PLUS, mode, op0, op1);
   10322            0 :                   goto binop2;
   10323              :                 }
   10324              :               /* Use wi::shwi to ensure that the constant is
   10325              :                  truncated according to the mode of OP1, then sign extended
   10326              :                  to a HOST_WIDE_INT.  Using the constant directly can result
   10327              :                  in non-canonical RTL in a 64x32 cross compile.  */
   10328       286507 :               wc = TREE_INT_CST_LOW (treeop1);
   10329       286507 :               constant_part
   10330       286507 :                 = immed_wide_int_const (wi::shwi (wc, wmode), wmode);
   10331       286507 :               op0 = plus_constant (mode, op0, INTVAL (constant_part));
   10332       286507 :               if (modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
   10333       213438 :                 op0 = force_operand (op0, target);
   10334       286507 :               return REDUCE_BIT_FIELD (op0);
   10335              :             }
   10336              :         }
   10337              : 
   10338              :       /* Use TER to expand pointer addition of a negated value
   10339              :          as pointer subtraction.  */
   10340      9314693 :       if ((POINTER_TYPE_P (TREE_TYPE (treeop0))
   10341      4099158 :            || (TREE_CODE (TREE_TYPE (treeop0)) == VECTOR_TYPE
   10342        83954 :                && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (treeop0)))))
   10343      1098245 :           && TREE_CODE (treeop1) == SSA_NAME
   10344      6340159 :           && TYPE_MODE (TREE_TYPE (treeop0))
   10345       571378 :              == TYPE_MODE (TREE_TYPE (treeop1)))
   10346              :         {
   10347       571378 :           gassign *def = get_def_for_expr (treeop1, NEGATE_EXPR);
   10348       571378 :           if (def)
   10349              :             {
   10350         2125 :               treeop1 = gimple_assign_rhs1 (def);
   10351         2125 :               code = MINUS_EXPR;
   10352         2125 :               goto do_minus;
   10353              :             }
   10354              :         }
   10355              : 
   10356              :       /* No sense saving up arithmetic to be done
   10357              :          if it's all in the wrong mode to form part of an address.
   10358              :          And force_operand won't know whether to sign-extend or
   10359              :          zero-extend.  */
   10360      5195278 :       if (modifier != EXPAND_INITIALIZER
   10361      5195278 :           && (modifier != EXPAND_SUM || mode != ptr_mode))
   10362              :         {
   10363      4610138 :           expand_operands (treeop0, treeop1,
   10364              :                            subtarget, &op0, &op1, modifier);
   10365      4610138 :           if (op0 == const0_rtx)
   10366         8670 :             return op1;
   10367      4601468 :           if (op1 == const0_rtx)
   10368              :             return op0;
   10369      4601217 :           goto binop2;
   10370              :         }
   10371              : 
   10372       585140 :       expand_operands (treeop0, treeop1,
   10373              :                        subtarget, &op0, &op1, modifier);
   10374       585140 :       return REDUCE_BIT_FIELD (simplify_gen_binary (PLUS, mode, op0, op1));
   10375              : 
   10376       554452 :     case MINUS_EXPR:
   10377       554452 :     case POINTER_DIFF_EXPR:
   10378       554452 :     do_minus:
   10379              :       /* For initializers, we are allowed to return a MINUS of two
   10380              :          symbolic constants.  Here we handle all cases when both operands
   10381              :          are constant.  */
   10382              :       /* Handle difference of two symbolic constants,
   10383              :          for the sake of an initializer.  */
   10384       554452 :       if ((modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
   10385         2754 :           && really_constant_p (treeop0)
   10386       555051 :           && really_constant_p (treeop1))
   10387              :         {
   10388           68 :           expand_operands (treeop0, treeop1,
   10389              :                            NULL_RTX, &op0, &op1, modifier);
   10390           68 :           return simplify_gen_binary (MINUS, mode, op0, op1);
   10391              :         }
   10392              : 
   10393              :       /* No sense saving up arithmetic to be done
   10394              :          if it's all in the wrong mode to form part of an address.
   10395              :          And force_operand won't know whether to sign-extend or
   10396              :          zero-extend.  */
   10397       554384 :       if (modifier != EXPAND_INITIALIZER
   10398       554384 :           && (modifier != EXPAND_SUM || mode != ptr_mode))
   10399       551698 :         goto binop;
   10400              : 
   10401         2686 :       expand_operands (treeop0, treeop1,
   10402              :                        subtarget, &op0, &op1, modifier);
   10403              : 
   10404              :       /* Convert A - const to A + (-const).  */
   10405         2686 :       if (CONST_INT_P (op1))
   10406              :         {
   10407            0 :           op1 = negate_rtx (mode, op1);
   10408            0 :           return REDUCE_BIT_FIELD (simplify_gen_binary (PLUS, mode, op0, op1));
   10409              :         }
   10410              : 
   10411         2686 :       goto binop2;
   10412              : 
   10413            0 :     case WIDEN_MULT_PLUS_EXPR:
   10414            0 :     case WIDEN_MULT_MINUS_EXPR:
   10415            0 :       expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, EXPAND_NORMAL);
   10416            0 :       op2 = expand_normal (treeop2);
   10417            0 :       target = expand_widen_pattern_expr (ops, op0, op1, op2,
   10418              :                                           target, unsignedp);
   10419            0 :       return target;
   10420              : 
   10421        24197 :     case WIDEN_MULT_EXPR:
   10422              :       /* If first operand is constant, swap them.
   10423              :          Thus the following special case checks need only
   10424              :          check the second operand.  */
   10425        24197 :       if (TREE_CODE (treeop0) == INTEGER_CST)
   10426          368 :         std::swap (treeop0, treeop1);
   10427              : 
   10428              :       /* First, check if we have a multiplication of one signed and one
   10429              :          unsigned operand.  */
   10430        24197 :       if (TREE_CODE (treeop1) != INTEGER_CST
   10431        24197 :           && (TYPE_UNSIGNED (TREE_TYPE (treeop0))
   10432        18682 :               != TYPE_UNSIGNED (TREE_TYPE (treeop1))))
   10433              :         {
   10434            0 :           machine_mode innermode = TYPE_MODE (TREE_TYPE (treeop0));
   10435            0 :           this_optab = usmul_widen_optab;
   10436            0 :           if (find_widening_optab_handler (this_optab, mode, innermode)
   10437              :                 != CODE_FOR_nothing)
   10438              :             {
   10439            0 :               if (TYPE_UNSIGNED (TREE_TYPE (treeop0)))
   10440            0 :                 expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1,
   10441              :                                  EXPAND_NORMAL);
   10442              :               else
   10443            0 :                 expand_operands (treeop0, treeop1, NULL_RTX, &op1, &op0,
   10444              :                                  EXPAND_NORMAL);
   10445              :               /* op0 and op1 might still be constant, despite the above
   10446              :                  != INTEGER_CST check.  Handle it.  */
   10447            0 :               if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode)
   10448              :                 {
   10449            0 :                   op0 = convert_modes (mode, innermode, op0, true);
   10450            0 :                   op1 = convert_modes (mode, innermode, op1, false);
   10451            0 :                   return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1,
   10452              :                                                         target, unsignedp));
   10453              :                 }
   10454            0 :               goto binop3;
   10455              :             }
   10456              :         }
   10457              :       /* Check for a multiplication with matching signedness.  */
   10458        24197 :       else if ((TREE_CODE (treeop1) == INTEGER_CST
   10459         5515 :                 && int_fits_type_p (treeop1, TREE_TYPE (treeop0)))
   10460        24201 :                || (TYPE_UNSIGNED (TREE_TYPE (treeop1))
   10461        18686 :                    == TYPE_UNSIGNED (TREE_TYPE (treeop0))))
   10462              :         {
   10463        24197 :           tree op0type = TREE_TYPE (treeop0);
   10464        24197 :           machine_mode innermode = TYPE_MODE (op0type);
   10465        24197 :           bool zextend_p = TYPE_UNSIGNED (op0type);
   10466        24197 :           optab other_optab = zextend_p ? smul_widen_optab : umul_widen_optab;
   10467         2588 :           this_optab = zextend_p ? umul_widen_optab : smul_widen_optab;
   10468              : 
   10469        24197 :           if (TREE_CODE (treeop0) != INTEGER_CST)
   10470              :             {
   10471        24197 :               if (find_widening_optab_handler (this_optab, mode, innermode)
   10472              :                   != CODE_FOR_nothing)
   10473              :                 {
   10474        24197 :                   expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1,
   10475              :                                    EXPAND_NORMAL);
   10476              :                   /* op0 and op1 might still be constant, despite the above
   10477              :                      != INTEGER_CST check.  Handle it.  */
   10478        24197 :                   if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode)
   10479              :                     {
   10480            0 :                      widen_mult_const:
   10481            0 :                       op0 = convert_modes (mode, innermode, op0, zextend_p);
   10482            0 :                       op1
   10483            0 :                         = convert_modes (mode, innermode, op1,
   10484            0 :                                          TYPE_UNSIGNED (TREE_TYPE (treeop1)));
   10485            0 :                       return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1,
   10486              :                                                             target,
   10487              :                                                             unsignedp));
   10488              :                     }
   10489        24197 :                   temp = expand_widening_mult (mode, op0, op1, target,
   10490              :                                                unsignedp, this_optab);
   10491        24197 :                   return REDUCE_BIT_FIELD (temp);
   10492              :                 }
   10493            0 :               if (find_widening_optab_handler (other_optab, mode, innermode)
   10494              :                   != CODE_FOR_nothing
   10495            0 :                   && innermode == word_mode)
   10496              :                 {
   10497            0 :                   rtx htem, hipart;
   10498            0 :                   op0 = expand_normal (treeop0);
   10499            0 :                   op1 = expand_normal (treeop1);
   10500              :                   /* op0 and op1 might be constants, despite the above
   10501              :                      != INTEGER_CST check.  Handle it.  */
   10502            0 :                   if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode)
   10503            0 :                     goto widen_mult_const;
   10504            0 :                   temp = expand_binop (mode, other_optab, op0, op1, target,
   10505              :                                        unsignedp, OPTAB_LIB_WIDEN);
   10506            0 :                   hipart = gen_highpart (word_mode, temp);
   10507            0 :                   htem = expand_mult_highpart_adjust (word_mode, hipart,
   10508              :                                                       op0, op1, hipart,
   10509              :                                                       zextend_p);
   10510            0 :                   if (htem != hipart)
   10511            0 :                     emit_move_insn (hipart, htem);
   10512            0 :                   return REDUCE_BIT_FIELD (temp);
   10513              :                 }
   10514              :             }
   10515              :         }
   10516            0 :       treeop0 = fold_build1 (CONVERT_EXPR, type, treeop0);
   10517            0 :       treeop1 = fold_build1 (CONVERT_EXPR, type, treeop1);
   10518            0 :       expand_operands (treeop0, treeop1, subtarget, &op0, &op1, EXPAND_NORMAL);
   10519            0 :       return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1, target, unsignedp));
   10520              : 
   10521      1463951 :     case MULT_EXPR:
   10522              :       /* If this is a fixed-point operation, then we cannot use the code
   10523              :          below because "expand_mult" doesn't support sat/no-sat fixed-point
   10524              :          multiplications.   */
   10525      1463951 :       if (ALL_FIXED_POINT_MODE_P (mode))
   10526            0 :         goto binop;
   10527              : 
   10528              :       /* If first operand is constant, swap them.
   10529              :          Thus the following special case checks need only
   10530              :          check the second operand.  */
   10531      1463951 :       if (TREE_CODE (treeop0) == INTEGER_CST)
   10532          686 :         std::swap (treeop0, treeop1);
   10533              : 
   10534              :       /* Attempt to return something suitable for generating an
   10535              :          indexed address, for machines that support that.  */
   10536              : 
   10537       545951 :       if (modifier == EXPAND_SUM && mode == ptr_mode
   10538      2009902 :           && tree_fits_shwi_p (treeop1))
   10539              :         {
   10540       538539 :           tree exp1 = treeop1;
   10541              : 
   10542       538539 :           op0 = expand_expr (treeop0, subtarget, VOIDmode,
   10543              :                              EXPAND_SUM);
   10544              : 
   10545       538539 :           if (!REG_P (op0))
   10546       246162 :             op0 = force_operand (op0, NULL_RTX);
   10547       538539 :           if (!REG_P (op0))
   10548         2448 :             op0 = copy_to_mode_reg (mode, op0);
   10549              : 
   10550       538539 :           op1 = gen_int_mode (tree_to_shwi (exp1),
   10551       538539 :                               TYPE_MODE (TREE_TYPE (exp1)));
   10552       538539 :           return REDUCE_BIT_FIELD (gen_rtx_MULT (mode, op0, op1));
   10553              :         }
   10554              : 
   10555       925412 :       if (modifier == EXPAND_STACK_PARM)
   10556         2906 :         target = 0;
   10557              : 
   10558       925412 :       if (SCALAR_INT_MODE_P (mode) && optimize >= 2)
   10559              :         {
   10560       562297 :           gassign *def_stmt0 = get_def_for_expr (treeop0, TRUNC_DIV_EXPR);
   10561       562297 :           gassign *def_stmt1 = get_def_for_expr (treeop1, TRUNC_DIV_EXPR);
   10562       562297 :           if (def_stmt0
   10563       575188 :               && !operand_equal_p (treeop1, gimple_assign_rhs2 (def_stmt0), 0))
   10564              :             def_stmt0 = NULL;
   10565       562297 :           if (def_stmt1
   10566       562297 :               && !operand_equal_p (treeop0, gimple_assign_rhs2 (def_stmt1), 0))
   10567              :             def_stmt1 = NULL;
   10568              : 
   10569       562297 :           if (def_stmt0 || def_stmt1)
   10570              :             {
   10571              :               /* X / Y * Y can be expanded as X - X % Y too.
   10572              :                  Choose the cheaper sequence of those two.  */
   10573          188 :               if (def_stmt0)
   10574          188 :                 treeop0 = gimple_assign_rhs1 (def_stmt0);
   10575              :               else
   10576              :                 {
   10577            0 :                   treeop1 = treeop0;
   10578            0 :                   treeop0 = gimple_assign_rhs1 (def_stmt1);
   10579              :                 }
   10580          188 :               expand_operands (treeop0, treeop1, subtarget, &op0, &op1,
   10581              :                                EXPAND_NORMAL);
   10582          188 :               bool speed_p = optimize_insn_for_speed_p ();
   10583          188 :               do_pending_stack_adjust ();
   10584          188 :               start_sequence ();
   10585          188 :               rtx divmul_ret
   10586          188 :                 = expand_expr_divmod (TRUNC_DIV_EXPR, mode, treeop0, treeop1,
   10587              :                                       op0, op1, NULL_RTX, unsignedp);
   10588          188 :               divmul_ret = expand_mult (mode, divmul_ret, op1, target,
   10589              :                                         unsignedp);
   10590          188 :               rtx_insn *divmul_insns = end_sequence ();
   10591          188 :               start_sequence ();
   10592          188 :               rtx modsub_ret
   10593          188 :                 = expand_expr_divmod (TRUNC_MOD_EXPR, mode, treeop0, treeop1,
   10594              :                                       op0, op1, NULL_RTX, unsignedp);
   10595          188 :               this_optab = optab_for_tree_code (MINUS_EXPR, type,
   10596              :                                                 optab_default);
   10597          188 :               modsub_ret = expand_binop (mode, this_optab, op0, modsub_ret,
   10598              :                                          target, unsignedp, OPTAB_LIB_WIDEN);
   10599          188 :               rtx_insn *modsub_insns = end_sequence ();
   10600          188 :               unsigned divmul_cost = seq_cost (divmul_insns, speed_p);
   10601          188 :               unsigned modsub_cost = seq_cost (modsub_insns, speed_p);
   10602              :               /* If costs are the same then use as tie breaker the other other
   10603              :                  factor.  */
   10604          188 :               if (divmul_cost == modsub_cost)
   10605              :                 {
   10606            5 :                   divmul_cost = seq_cost (divmul_insns, !speed_p);
   10607            5 :                   modsub_cost = seq_cost (modsub_insns, !speed_p);
   10608              :                 }
   10609              : 
   10610          188 :               if (divmul_cost <= modsub_cost)
   10611              :                 {
   10612          123 :                   emit_insn (divmul_insns);
   10613          123 :                   return REDUCE_BIT_FIELD (divmul_ret);
   10614              :                 }
   10615           65 :               emit_insn (modsub_insns);
   10616           65 :               return REDUCE_BIT_FIELD (modsub_ret);
   10617              :             }
   10618              :         }
   10619              : 
   10620       925224 :       expand_operands (treeop0, treeop1, subtarget, &op0, &op1, EXPAND_NORMAL);
   10621              : 
   10622              :       /* Expand X*Y as X&-Y when Y must be zero or one.  */
   10623       925224 :       if (SCALAR_INT_MODE_P (mode))
   10624              :         {
   10625       789694 :           bool bit0_p = expr_has_boolean_range (treeop0, currently_expanding_gimple_stmt);
   10626       789694 :           bool bit1_p = expr_has_boolean_range (treeop1, currently_expanding_gimple_stmt);
   10627              : 
   10628              :           /* Expand X*Y as X&Y when both X and Y must be zero or one.  */
   10629       789694 :           if (bit0_p && bit1_p)
   10630            0 :             return REDUCE_BIT_FIELD (expand_and (mode, op0, op1, target));
   10631              : 
   10632       789694 :           if (bit0_p || bit1_p)
   10633              :             {
   10634         3249 :               bool speed = optimize_insn_for_speed_p ();
   10635         3249 :               int cost = add_cost (speed, mode) + neg_cost (speed, mode);
   10636         3249 :               struct algorithm algorithm;
   10637         3249 :               enum mult_variant variant;
   10638         3249 :               if (CONST_INT_P (op1)
   10639         3249 :                   ? !choose_mult_variant (mode, INTVAL (op1),
   10640              :                                           &algorithm, &variant, cost)
   10641          650 :                   : cost < mul_cost (speed, mode))
   10642              :                 {
   10643         1437 :                   temp = bit0_p ? expand_and (mode, negate_rtx (mode, op0),
   10644              :                                               op1, target)
   10645          270 :                                 : expand_and (mode, op0,
   10646              :                                               negate_rtx (mode, op1),
   10647              :                                               target);
   10648         1437 :                   return REDUCE_BIT_FIELD (temp);
   10649              :                 }
   10650              :             }
   10651              :         }
   10652              : 
   10653       923787 :       return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1, target, unsignedp));
   10654              : 
   10655       177391 :     case TRUNC_MOD_EXPR:
   10656       177391 :     case FLOOR_MOD_EXPR:
   10657       177391 :     case CEIL_MOD_EXPR:
   10658       177391 :     case ROUND_MOD_EXPR:
   10659              : 
   10660       177391 :     case TRUNC_DIV_EXPR:
   10661       177391 :     case FLOOR_DIV_EXPR:
   10662       177391 :     case CEIL_DIV_EXPR:
   10663       177391 :     case ROUND_DIV_EXPR:
   10664       177391 :     case EXACT_DIV_EXPR:
   10665              :       /* If this is a fixed-point operation, then we cannot use the code
   10666              :          below because "expand_divmod" doesn't support sat/no-sat fixed-point
   10667              :          divisions.   */
   10668       177391 :       if (ALL_FIXED_POINT_MODE_P (mode))
   10669            0 :         goto binop;
   10670              : 
   10671       177391 :       if (modifier == EXPAND_STACK_PARM)
   10672          309 :         target = 0;
   10673              :       /* Possible optimization: compute the dividend with EXPAND_SUM
   10674              :          then if the divisor is constant can optimize the case
   10675              :          where some terms of the dividend have coeffs divisible by it.  */
   10676       177391 :       expand_operands (treeop0, treeop1, subtarget, &op0, &op1, EXPAND_NORMAL);
   10677       177391 :       return expand_expr_divmod (code, mode, treeop0, treeop1, op0, op1,
   10678       177391 :                                  target, unsignedp);
   10679              : 
   10680        31918 :     case RDIV_EXPR:
   10681        31918 :       goto binop;
   10682              : 
   10683         3536 :     case MULT_HIGHPART_EXPR:
   10684         3536 :       expand_operands (treeop0, treeop1, subtarget, &op0, &op1, EXPAND_NORMAL);
   10685         3536 :       temp = expand_mult_highpart (mode, op0, op1, target, unsignedp);
   10686         3536 :       gcc_assert (temp);
   10687              :       return temp;
   10688              : 
   10689            0 :     case FIXED_CONVERT_EXPR:
   10690            0 :       op0 = expand_normal (treeop0);
   10691            0 :       if (target == 0 || modifier == EXPAND_STACK_PARM)
   10692            0 :         target = gen_reg_rtx (mode);
   10693              : 
   10694            0 :       if ((TREE_CODE (TREE_TYPE (treeop0)) == INTEGER_TYPE
   10695            0 :            && TYPE_UNSIGNED (TREE_TYPE (treeop0)))
   10696            0 :           || (TREE_CODE (type) == INTEGER_TYPE && TYPE_UNSIGNED (type)))
   10697            0 :         expand_fixed_convert (target, op0, 1, TYPE_SATURATING (type));
   10698              :       else
   10699            0 :         expand_fixed_convert (target, op0, 0, TYPE_SATURATING (type));
   10700              :       return target;
   10701              : 
   10702        48726 :     case FIX_TRUNC_EXPR:
   10703        48726 :       op0 = expand_normal (treeop0);
   10704        48726 :       if (target == 0 || modifier == EXPAND_STACK_PARM)
   10705         3602 :         target = gen_reg_rtx (mode);
   10706        48726 :       expand_fix (target, op0, unsignedp);
   10707        48726 :       return target;
   10708              : 
   10709       134926 :     case FLOAT_EXPR:
   10710       134926 :       op0 = expand_normal (treeop0);
   10711       134926 :       if (target == 0 || modifier == EXPAND_STACK_PARM)
   10712        64013 :         target = gen_reg_rtx (mode);
   10713              :       /* expand_float can't figure out what to do if FROM has VOIDmode.
   10714              :          So give it the correct mode.  With -O, cse will optimize this.  */
   10715       134926 :       if (GET_MODE (op0) == VOIDmode)
   10716          109 :         op0 = copy_to_mode_reg (TYPE_MODE (TREE_TYPE (treeop0)),
   10717              :                                 op0);
   10718       269852 :       expand_float (target, op0,
   10719       134926 :                     TYPE_UNSIGNED (TREE_TYPE (treeop0)));
   10720       134926 :       return target;
   10721              : 
   10722        60965 :     case NEGATE_EXPR:
   10723        60965 :       op0 = expand_expr (treeop0, subtarget,
   10724              :                          VOIDmode, EXPAND_NORMAL);
   10725        60965 :       if (modifier == EXPAND_STACK_PARM)
   10726          243 :         target = 0;
   10727        60965 :       temp = expand_unop (mode,
   10728              :                           optab_for_tree_code (NEGATE_EXPR, type,
   10729              :                                                optab_default),
   10730              :                           op0, target, 0);
   10731        60965 :       gcc_assert (temp);
   10732        60965 :       return REDUCE_BIT_FIELD (temp);
   10733              : 
   10734        28484 :     case ABS_EXPR:
   10735        28484 :     case ABSU_EXPR:
   10736        28484 :       op0 = expand_expr (treeop0, subtarget,
   10737              :                          VOIDmode, EXPAND_NORMAL);
   10738        28484 :       if (modifier == EXPAND_STACK_PARM)
   10739           63 :         target = 0;
   10740              : 
   10741              :       /* ABS_EXPR is not valid for complex arguments.  */
   10742        28484 :       gcc_assert (GET_MODE_CLASS (mode) != MODE_COMPLEX_INT
   10743              :                   && GET_MODE_CLASS (mode) != MODE_COMPLEX_FLOAT);
   10744              : 
   10745              :       /* Unsigned abs is simply the operand.  Testing here means we don't
   10746              :          risk generating incorrect code below.  */
   10747        28484 :       if (TYPE_UNSIGNED (TREE_TYPE (treeop0)))
   10748              :         return op0;
   10749              : 
   10750        28484 :       return expand_abs (mode, op0, target, unsignedp,
   10751        56968 :                          safe_from_p (target, treeop0, 1));
   10752              : 
   10753       141946 :     case MAX_EXPR:
   10754       141946 :     case MIN_EXPR:
   10755       141946 :       target = original_target;
   10756       141946 :       if (target == 0
   10757       141946 :           || modifier == EXPAND_STACK_PARM
   10758        79604 :           || (MEM_P (target) && MEM_VOLATILE_P (target))
   10759        79604 :           || GET_MODE (target) != mode
   10760       221550 :           || (REG_P (target)
   10761        72944 :               && REGNO (target) < FIRST_PSEUDO_REGISTER))
   10762        62342 :         target = gen_reg_rtx (mode);
   10763       141946 :       expand_operands (treeop0, treeop1,
   10764              :                        target, &op0, &op1, EXPAND_NORMAL);
   10765              : 
   10766              :       /* First try to do it with a special MIN or MAX instruction.
   10767              :          If that does not win, use a conditional jump to select the proper
   10768              :          value.  */
   10769       141946 :       this_optab = optab_for_tree_code (code, type, optab_default);
   10770       141946 :       temp = expand_binop (mode, this_optab, op0, op1, target, unsignedp,
   10771              :                            OPTAB_WIDEN);
   10772       141946 :       if (temp != 0)
   10773              :         return temp;
   10774              : 
   10775          147 :       if (VECTOR_TYPE_P (type))
   10776            0 :         gcc_unreachable ();
   10777              : 
   10778              :       /* At this point, a MEM target is no longer useful; we will get better
   10779              :          code without it.  */
   10780              : 
   10781          147 :       if (! REG_P (target))
   10782            1 :         target = gen_reg_rtx (mode);
   10783              : 
   10784              :       /* If op1 was placed in target, swap op0 and op1.  */
   10785          147 :       if (target != op0 && target == op1)
   10786            0 :         std::swap (op0, op1);
   10787              : 
   10788              :       /* We generate better code and avoid problems with op1 mentioning
   10789              :          target by forcing op1 into a pseudo if it isn't a constant.  */
   10790          147 :       if (! CONSTANT_P (op1))
   10791           42 :         op1 = force_reg (mode, op1);
   10792              : 
   10793          147 :       {
   10794          147 :         enum rtx_code comparison_code;
   10795          147 :         rtx cmpop1 = op1;
   10796              : 
   10797          147 :         if (code == MAX_EXPR)
   10798           75 :           comparison_code = unsignedp ? GEU : GE;
   10799              :         else
   10800           72 :           comparison_code = unsignedp ? LEU : LE;
   10801              : 
   10802              :         /* Canonicalize to comparisons against 0.  */
   10803          147 :         if (op1 == const1_rtx)
   10804              :           {
   10805              :             /* Converting (a >= 1 ? a : 1) into (a > 0 ? a : 1)
   10806              :                or (a != 0 ? a : 1) for unsigned.
   10807              :                For MIN we are safe converting (a <= 1 ? a : 1)
   10808              :                into (a <= 0 ? a : 1)  */
   10809            0 :             cmpop1 = const0_rtx;
   10810            0 :             if (code == MAX_EXPR)
   10811            0 :               comparison_code = unsignedp ? NE : GT;
   10812              :           }
   10813          147 :         if (op1 == constm1_rtx && !unsignedp)
   10814              :           {
   10815              :             /* Converting (a >= -1 ? a : -1) into (a >= 0 ? a : -1)
   10816              :                and (a <= -1 ? a : -1) into (a < 0 ? a : -1) */
   10817            0 :             cmpop1 = const0_rtx;
   10818            0 :             if (code == MIN_EXPR)
   10819            0 :               comparison_code = LT;
   10820              :           }
   10821              : 
   10822              :         /* Use a conditional move if possible.  */
   10823          147 :         if (can_conditionally_move_p (mode))
   10824              :           {
   10825           85 :             rtx insn;
   10826              : 
   10827           85 :             start_sequence ();
   10828              : 
   10829              :             /* Try to emit the conditional move.  */
   10830           85 :             insn = emit_conditional_move (target,
   10831              :                                           { comparison_code,
   10832              :                                             op0, cmpop1, mode },
   10833              :                                           op0, op1, mode,
   10834              :                                           unsignedp);
   10835              : 
   10836              :             /* If we could do the conditional move, emit the sequence,
   10837              :                and return.  */
   10838           85 :             if (insn)
   10839              :               {
   10840           41 :                 rtx_insn *seq = end_sequence ();
   10841           41 :                 emit_insn (seq);
   10842           41 :                 return target;
   10843              :               }
   10844              : 
   10845              :             /* Otherwise discard the sequence and fall back to code with
   10846              :                branches.  */
   10847           44 :             end_sequence ();
   10848              :           }
   10849              : 
   10850          106 :         if (target != op0)
   10851           77 :           emit_move_insn (target, op0);
   10852              : 
   10853          106 :         lab = gen_label_rtx ();
   10854          106 :         do_compare_rtx_and_jump (target, cmpop1, comparison_code,
   10855              :                                  unsignedp, mode, NULL_RTX, NULL, lab,
   10856              :                                  profile_probability::uninitialized ());
   10857              :       }
   10858          106 :       emit_move_insn (target, op1);
   10859          106 :       emit_label (lab);
   10860          106 :       return target;
   10861              : 
   10862        62827 :     case BIT_NOT_EXPR:
   10863        62827 :       op0 = expand_expr (treeop0, subtarget,
   10864              :                          VOIDmode, EXPAND_NORMAL);
   10865        62827 :       if (modifier == EXPAND_STACK_PARM)
   10866           94 :         target = 0;
   10867              :       /* In case we have to reduce the result to bitfield precision
   10868              :          for unsigned bitfield expand this as XOR with a proper constant
   10869              :          instead.  */
   10870        62827 :       if (reduce_bit_field && TYPE_UNSIGNED (type))
   10871              :         {
   10872        23701 :           int_mode = SCALAR_INT_TYPE_MODE (type);
   10873        23701 :           wide_int mask = wi::mask (TYPE_PRECISION (type),
   10874        47402 :                                     false, GET_MODE_PRECISION (int_mode));
   10875              : 
   10876        47402 :           temp = expand_binop (int_mode, xor_optab, op0,
   10877        47402 :                                immed_wide_int_const (mask, int_mode),
   10878              :                                target, 1, OPTAB_LIB_WIDEN);
   10879        23701 :         }
   10880              :       else
   10881        39126 :         temp = expand_unop (mode, one_cmpl_optab, op0, target, 1);
   10882        62827 :       gcc_assert (temp);
   10883              :       return temp;
   10884              : 
   10885              :       /* ??? Can optimize bitwise operations with one arg constant.
   10886              :          Can optimize (a bitwise1 n) bitwise2 (a bitwise3 b)
   10887              :          and (a bitwise1 b) bitwise2 b (etc)
   10888              :          but that is probably not worth while.  */
   10889              : 
   10890       399206 :     case BIT_AND_EXPR:
   10891       399206 :       goto binop;
   10892              : 
   10893       229285 :     case BIT_IOR_EXPR:
   10894       229285 :     case BIT_XOR_EXPR:
   10895       229285 :       if ((get_nonzero_bits (treeop0) & get_nonzero_bits (treeop1)) == 0)
   10896              :         {
   10897        18792 :           expand_operands (treeop0, treeop1,
   10898              :                            subtarget, &op0, &op1, EXPAND_NORMAL);
   10899        18792 :           this_optab = aop_optab;
   10900        18792 :           goto binop3;
   10901              :         }
   10902       210493 :       goto binop;
   10903              : 
   10904         8657 :     case LROTATE_EXPR:
   10905         8657 :     case RROTATE_EXPR:
   10906         8657 :       gcc_assert (VECTOR_MODE_P (TYPE_MODE (type))
   10907              :                   || type_has_mode_precision_p (type));
   10908              :       /* fall through */
   10909              : 
   10910       318105 :     case LSHIFT_EXPR:
   10911       318105 :     case RSHIFT_EXPR:
   10912       318105 :       {
   10913              :         /* If this is a fixed-point operation, then we cannot use the code
   10914              :            below because "expand_shift" doesn't support sat/no-sat fixed-point
   10915              :            shifts.  */
   10916       318105 :         if (ALL_FIXED_POINT_MODE_P (mode))
   10917            0 :           goto binop;
   10918              : 
   10919       318105 :         if (! safe_from_p (subtarget, treeop1, 1))
   10920         4999 :           subtarget = 0;
   10921       318105 :         if (modifier == EXPAND_STACK_PARM)
   10922         2600 :           target = 0;
   10923       318105 :         op0 = expand_expr (treeop0, subtarget,
   10924              :                            VOIDmode, EXPAND_NORMAL);
   10925              : 
   10926              :         /* Left shift optimization when shifting across word_size boundary.
   10927              : 
   10928              :            If mode == GET_MODE_WIDER_MODE (word_mode), then normally
   10929              :            there isn't native instruction to support this wide mode
   10930              :            left shift.  Given below scenario:
   10931              : 
   10932              :             Type A = (Type) B  << C
   10933              : 
   10934              :             |<                T          >|
   10935              :             | dest_high  |  dest_low |
   10936              : 
   10937              :                          | word_size |
   10938              : 
   10939              :            If the shift amount C caused we shift B to across the word
   10940              :            size boundary, i.e part of B shifted into high half of
   10941              :            destination register, and part of B remains in the low
   10942              :            half, then GCC will use the following left shift expand
   10943              :            logic:
   10944              : 
   10945              :            1. Initialize dest_low to B.
   10946              :            2. Initialize every bit of dest_high to the sign bit of B.
   10947              :            3. Logic left shift dest_low by C bit to finalize dest_low.
   10948              :               The value of dest_low before this shift is kept in a temp D.
   10949              :            4. Logic left shift dest_high by C.
   10950              :            5. Logic right shift D by (word_size - C).
   10951              :            6. Or the result of 4 and 5 to finalize dest_high.
   10952              : 
   10953              :            While, by checking gimple statements, if operand B is
   10954              :            coming from signed extension, then we can simplify above
   10955              :            expand logic into:
   10956              : 
   10957              :               1. dest_high = src_low >> (word_size - C).
   10958              :               2. dest_low = src_low << C.
   10959              : 
   10960              :            We can use one arithmetic right shift to finish all the
   10961              :            purpose of steps 2, 4, 5, 6, thus we reduce the steps
   10962              :            needed from 6 into 2.
   10963              : 
   10964              :            The case is similar for zero extension, except that we
   10965              :            initialize dest_high to zero rather than copies of the sign
   10966              :            bit from B.  Furthermore, we need to use a logical right shift
   10967              :            in this case.
   10968              : 
   10969              :            The choice of sign-extension versus zero-extension is
   10970              :            determined entirely by whether or not B is signed and is
   10971              :            independent of the current setting of unsignedp.  */
   10972              : 
   10973       318105 :         temp = NULL_RTX;
   10974       318105 :         if (code == LSHIFT_EXPR
   10975       318105 :             && target
   10976        34204 :             && REG_P (target)
   10977        31094 :             && GET_MODE_2XWIDER_MODE (word_mode).exists (&int_mode)
   10978        31094 :             && mode == int_mode
   10979         1507 :             && TREE_CONSTANT (treeop1)
   10980       318949 :             && TREE_CODE (treeop0) == SSA_NAME)
   10981              :           {
   10982          844 :             auto *def = dyn_cast<gassign *> (SSA_NAME_DEF_STMT (treeop0));
   10983          770 :             if (def && gimple_assign_rhs_code (def) == NOP_EXPR)
   10984              :               {
   10985          330 :                 scalar_int_mode rmode = SCALAR_INT_TYPE_MODE
   10986              :                   (TREE_TYPE (gimple_assign_rhs1 (def)));
   10987              : 
   10988          660 :                 if (GET_MODE_SIZE (rmode) < GET_MODE_SIZE (int_mode)
   10989          614 :                     && TREE_INT_CST_LOW (treeop1) < GET_MODE_BITSIZE (word_mode)
   10990          476 :                     && ((TREE_INT_CST_LOW (treeop1) + GET_MODE_BITSIZE (rmode))
   10991           73 :                         >= GET_MODE_BITSIZE (word_mode)))
   10992              :                   {
   10993           69 :                     rtx_insn *seq, *seq_old;
   10994           69 :                     poly_uint64 high_off = subreg_highpart_offset (word_mode,
   10995              :                                                                    int_mode);
   10996           69 :                     bool extend_unsigned
   10997           69 :                       = TYPE_UNSIGNED (TREE_TYPE (gimple_assign_rhs1 (def)));
   10998           69 :                     rtx low = lowpart_subreg (word_mode, op0, int_mode);
   10999           69 :                     rtx dest_low = lowpart_subreg (word_mode, target, int_mode);
   11000           69 :                     rtx dest_high = simplify_gen_subreg (word_mode, target,
   11001              :                                                          int_mode, high_off);
   11002           69 :                     HOST_WIDE_INT ramount = (BITS_PER_WORD
   11003           69 :                                              - TREE_INT_CST_LOW (treeop1));
   11004           69 :                     tree rshift = build_int_cst (TREE_TYPE (treeop1), ramount);
   11005              : 
   11006           69 :                     start_sequence ();
   11007              :                     /* dest_high = src_low >> (word_size - C).  */
   11008           69 :                     temp = expand_variable_shift (RSHIFT_EXPR, word_mode, low,
   11009              :                                                   rshift, dest_high,
   11010              :                                                   extend_unsigned);
   11011           69 :                     if (temp != dest_high)
   11012            0 :                       emit_move_insn (dest_high, temp);
   11013              : 
   11014              :                     /* dest_low = src_low << C.  */
   11015           69 :                     temp = expand_variable_shift (LSHIFT_EXPR, word_mode, low,
   11016              :                                                   treeop1, dest_low, unsignedp);
   11017           69 :                     if (temp != dest_low)
   11018            1 :                       emit_move_insn (dest_low, temp);
   11019              : 
   11020           69 :                     seq = end_sequence ();
   11021           69 :                     temp = target ;
   11022              : 
   11023           69 :                     if (have_insn_for (ASHIFT, int_mode))
   11024              :                       {
   11025           69 :                         bool speed_p = optimize_insn_for_speed_p ();
   11026           69 :                         start_sequence ();
   11027           69 :                         rtx ret_old = expand_variable_shift (code, int_mode,
   11028              :                                                              op0, treeop1,
   11029              :                                                              target,
   11030              :                                                              unsignedp);
   11031              : 
   11032           69 :                         seq_old = end_sequence ();
   11033          138 :                         if (seq_cost (seq, speed_p)
   11034           69 :                             >= seq_cost (seq_old, speed_p))
   11035              :                           {
   11036           69 :                             seq = seq_old;
   11037           69 :                             temp = ret_old;
   11038              :                           }
   11039              :                       }
   11040           69 :                       emit_insn (seq);
   11041              :                   }
   11042              :               }
   11043              :           }
   11044              : 
   11045           69 :         if (temp == NULL_RTX)
   11046       318036 :           temp = expand_variable_shift (code, mode, op0, treeop1, target,
   11047              :                                         unsignedp);
   11048       318105 :         if (code == LSHIFT_EXPR)
   11049        82419 :           temp = REDUCE_BIT_FIELD (temp);
   11050              :         return temp;
   11051              :       }
   11052              : 
   11053              :       /* Could determine the answer when only additive constants differ.  Also,
   11054              :          the addition of one can be handled by changing the condition.  */
   11055       642659 :     case LT_EXPR:
   11056       642659 :     case LE_EXPR:
   11057       642659 :     case GT_EXPR:
   11058       642659 :     case GE_EXPR:
   11059       642659 :     case EQ_EXPR:
   11060       642659 :     case NE_EXPR:
   11061       642659 :     case UNORDERED_EXPR:
   11062       642659 :     case ORDERED_EXPR:
   11063       642659 :     case UNLT_EXPR:
   11064       642659 :     case UNLE_EXPR:
   11065       642659 :     case UNGT_EXPR:
   11066       642659 :     case UNGE_EXPR:
   11067       642659 :     case UNEQ_EXPR:
   11068       642659 :     case LTGT_EXPR:
   11069       642659 :       {
   11070      1053557 :         temp = do_store_flag (ops,
   11071              :                               modifier != EXPAND_STACK_PARM ? target : NULL_RTX,
   11072              :                               tmode != VOIDmode ? tmode : mode);
   11073       642659 :         if (temp)
   11074              :           return temp;
   11075              : 
   11076              :         /* Use a compare and a jump for BLKmode comparisons, or for function
   11077              :            type comparisons is have_canonicalize_funcptr_for_compare.  */
   11078              : 
   11079            0 :         if ((target == 0
   11080            0 :              || modifier == EXPAND_STACK_PARM
   11081            0 :              || ! safe_from_p (target, treeop0, 1)
   11082            0 :              || ! safe_from_p (target, treeop1, 1)
   11083              :              /* Make sure we don't have a hard reg (such as function's return
   11084              :                 value) live across basic blocks, if not optimizing.  */
   11085            0 :              || (!optimize && REG_P (target)
   11086            0 :                  && REGNO (target) < FIRST_PSEUDO_REGISTER)))
   11087            0 :           target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
   11088              : 
   11089            0 :         emit_move_insn (target, const0_rtx);
   11090              : 
   11091            0 :         rtx_code_label *lab1 = gen_label_rtx ();
   11092            0 :         jumpifnot_1 (code, treeop0, treeop1, lab1,
   11093              :                      profile_probability::uninitialized ());
   11094              : 
   11095            0 :         if (TYPE_PRECISION (type) == 1 && !TYPE_UNSIGNED (type))
   11096            0 :           emit_move_insn (target, constm1_rtx);
   11097              :         else
   11098            0 :           emit_move_insn (target, const1_rtx);
   11099              : 
   11100            0 :         emit_label (lab1);
   11101            0 :         return target;
   11102              :       }
   11103        56662 :     case COMPLEX_EXPR:
   11104              :       /* Get the rtx code of the operands.  */
   11105        56662 :       op0 = expand_normal (treeop0);
   11106        56662 :       op1 = expand_normal (treeop1);
   11107              : 
   11108        56662 :       if (!target)
   11109         3104 :         target = gen_reg_rtx (TYPE_MODE (type));
   11110              :       else
   11111              :         /* If target overlaps with op1, then either we need to force
   11112              :            op1 into a pseudo (if target also overlaps with op0),
   11113              :            or write the complex parts in reverse order.  */
   11114        53558 :         switch (GET_CODE (target))
   11115              :           {
   11116        50797 :           case CONCAT:
   11117        50797 :             if (reg_overlap_mentioned_p (XEXP (target, 0), op1))
   11118              :               {
   11119            0 :                 if (reg_overlap_mentioned_p (XEXP (target, 1), op0))
   11120              :                   {
   11121            0 :                   complex_expr_force_op1:
   11122         1728 :                     temp = gen_reg_rtx (GET_MODE_INNER (GET_MODE (target)));
   11123          864 :                     emit_move_insn (temp, op1);
   11124          864 :                     op1 = temp;
   11125          864 :                     break;
   11126              :                   }
   11127            0 :               complex_expr_swap_order:
   11128              :                 /* Move the imaginary (op1) and real (op0) parts to their
   11129              :                    location.  */
   11130            1 :                 write_complex_part (target, op1, true, true);
   11131            1 :                 write_complex_part (target, op0, false, false);
   11132              : 
   11133            1 :                 return target;
   11134              :               }
   11135              :             break;
   11136         2761 :           case MEM:
   11137         5522 :             temp = adjust_address_nv (target,
   11138              :                                       GET_MODE_INNER (GET_MODE (target)), 0);
   11139         2761 :             if (reg_overlap_mentioned_p (temp, op1))
   11140              :               {
   11141          865 :                 scalar_mode imode = GET_MODE_INNER (GET_MODE (target));
   11142         1730 :                 temp = adjust_address_nv (target, imode,
   11143              :                                           GET_MODE_SIZE (imode));
   11144          865 :                 if (reg_overlap_mentioned_p (temp, op0))
   11145          864 :                   goto complex_expr_force_op1;
   11146            1 :                 goto complex_expr_swap_order;
   11147              :               }
   11148              :             break;
   11149            0 :           default:
   11150            0 :             if (reg_overlap_mentioned_p (target, op1))
   11151              :               {
   11152            0 :                 if (reg_overlap_mentioned_p (target, op0))
   11153            0 :                   goto complex_expr_force_op1;
   11154            0 :                 goto complex_expr_swap_order;
   11155              :               }
   11156              :             break;
   11157              :           }
   11158              : 
   11159              :       /* Move the real (op0) and imaginary (op1) parts to their location.  */
   11160        56661 :       write_complex_part (target, op0, false, true);
   11161        56661 :       write_complex_part (target, op1, true, false);
   11162              : 
   11163        56661 :       return target;
   11164              : 
   11165            0 :     case WIDEN_SUM_EXPR:
   11166            0 :       {
   11167            0 :         tree oprnd0 = treeop0;
   11168            0 :         tree oprnd1 = treeop1;
   11169              : 
   11170            0 :         expand_operands (oprnd0, oprnd1, NULL_RTX, &op0, &op1, EXPAND_NORMAL);
   11171            0 :         target = expand_widen_pattern_expr (ops, op0, NULL_RTX, op1,
   11172              :                                             target, unsignedp);
   11173            0 :         return target;
   11174              :       }
   11175              : 
   11176        18339 :     case VEC_UNPACK_HI_EXPR:
   11177        18339 :     case VEC_UNPACK_LO_EXPR:
   11178        18339 :     case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
   11179        18339 :     case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
   11180        18339 :       {
   11181        18339 :         op0 = expand_normal (treeop0);
   11182        18339 :         temp = expand_widen_pattern_expr (ops, op0, NULL_RTX, NULL_RTX,
   11183              :                                           target, unsignedp);
   11184        18339 :         gcc_assert (temp);
   11185              :         return temp;
   11186              :       }
   11187              : 
   11188         1932 :     case VEC_UNPACK_FLOAT_HI_EXPR:
   11189         1932 :     case VEC_UNPACK_FLOAT_LO_EXPR:
   11190         1932 :       {
   11191         1932 :         op0 = expand_normal (treeop0);
   11192              :         /* The signedness is determined from input operand.  */
   11193         1932 :         temp = expand_widen_pattern_expr
   11194         3864 :           (ops, op0, NULL_RTX, NULL_RTX,
   11195         1932 :            target, TYPE_UNSIGNED (TREE_TYPE (treeop0)));
   11196              : 
   11197         1932 :         gcc_assert (temp);
   11198              :         return temp;
   11199              :       }
   11200              : 
   11201         1099 :     case VEC_WIDEN_MULT_HI_EXPR:
   11202         1099 :     case VEC_WIDEN_MULT_LO_EXPR:
   11203         1099 :     case VEC_WIDEN_MULT_EVEN_EXPR:
   11204         1099 :     case VEC_WIDEN_MULT_ODD_EXPR:
   11205         1099 :     case VEC_WIDEN_LSHIFT_HI_EXPR:
   11206         1099 :     case VEC_WIDEN_LSHIFT_LO_EXPR:
   11207         1099 :       expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, EXPAND_NORMAL);
   11208         1099 :       target = expand_widen_pattern_expr (ops, op0, op1, NULL_RTX,
   11209              :                                           target, unsignedp);
   11210         1099 :       gcc_assert (target);
   11211              :       return target;
   11212              : 
   11213          371 :     case VEC_PACK_SAT_EXPR:
   11214          371 :     case VEC_PACK_FIX_TRUNC_EXPR:
   11215          371 :       mode = TYPE_MODE (TREE_TYPE (treeop0));
   11216          371 :       subtarget = NULL_RTX;
   11217          371 :       goto binop;
   11218              : 
   11219        11437 :     case VEC_PACK_TRUNC_EXPR:
   11220        11437 :       if (VECTOR_BOOLEAN_TYPE_P (type)
   11221         2604 :           && VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (treeop0))
   11222         2604 :           && mode == TYPE_MODE (TREE_TYPE (treeop0))
   11223        12143 :           && SCALAR_INT_MODE_P (mode))
   11224              :         {
   11225          706 :           class expand_operand eops[4];
   11226          706 :           machine_mode imode = TYPE_MODE (TREE_TYPE (treeop0));
   11227          706 :           expand_operands (treeop0, treeop1,
   11228              :                            subtarget, &op0, &op1, EXPAND_NORMAL);
   11229          706 :           this_optab = vec_pack_sbool_trunc_optab;
   11230          706 :           enum insn_code icode = optab_handler (this_optab, imode);
   11231          706 :           create_output_operand (&eops[0], target, mode);
   11232          706 :           create_convert_operand_from (&eops[1], op0, imode, false);
   11233          706 :           create_convert_operand_from (&eops[2], op1, imode, false);
   11234          706 :           temp = GEN_INT (TYPE_VECTOR_SUBPARTS (type).to_constant ());
   11235          706 :           create_input_operand (&eops[3], temp, imode);
   11236          706 :           expand_insn (icode, 4, eops);
   11237          706 :           return eops[0].value;
   11238              :         }
   11239        10731 :       mode = TYPE_MODE (TREE_TYPE (treeop0));
   11240        10731 :       subtarget = NULL_RTX;
   11241        10731 :       goto binop;
   11242              : 
   11243           27 :     case VEC_PACK_FLOAT_EXPR:
   11244           27 :       mode = TYPE_MODE (TREE_TYPE (treeop0));
   11245           27 :       expand_operands (treeop0, treeop1,
   11246              :                        subtarget, &op0, &op1, EXPAND_NORMAL);
   11247           27 :       this_optab = optab_for_tree_code (code, TREE_TYPE (treeop0),
   11248              :                                         optab_default);
   11249           81 :       target = expand_binop (mode, this_optab, op0, op1, target,
   11250           27 :                              TYPE_UNSIGNED (TREE_TYPE (treeop0)),
   11251              :                              OPTAB_LIB_WIDEN);
   11252           27 :       gcc_assert (target);
   11253              :       return target;
   11254              : 
   11255        76449 :     case VEC_PERM_EXPR:
   11256        76449 :       {
   11257        76449 :         expand_operands (treeop0, treeop1, target, &op0, &op1, EXPAND_NORMAL);
   11258        76449 :         vec_perm_builder sel;
   11259        76449 :         if (TREE_CODE (treeop2) == VECTOR_CST
   11260        76449 :             && tree_to_vec_perm_builder (&sel, treeop2))
   11261              :           {
   11262        76431 :             machine_mode sel_mode = TYPE_MODE (TREE_TYPE (treeop2));
   11263        76431 :             temp = expand_vec_perm_const (mode, op0, op1, sel,
   11264              :                                           sel_mode, target);
   11265              :           }
   11266              :         else
   11267              :           {
   11268           18 :             op2 = expand_normal (treeop2);
   11269           18 :             temp = expand_vec_perm_var (mode, op0, op1, op2, target);
   11270              :           }
   11271        76449 :         gcc_assert (temp);
   11272        76449 :         return temp;
   11273        76449 :       }
   11274              : 
   11275          507 :     case DOT_PROD_EXPR:
   11276          507 :       {
   11277          507 :         tree oprnd0 = treeop0;
   11278          507 :         tree oprnd1 = treeop1;
   11279          507 :         tree oprnd2 = treeop2;
   11280              : 
   11281          507 :         expand_operands (oprnd0, oprnd1, NULL_RTX, &op0, &op1, EXPAND_NORMAL);
   11282          507 :         op2 = expand_normal (oprnd2);
   11283          507 :         target = expand_widen_pattern_expr (ops, op0, op1, op2,
   11284              :                                             target, unsignedp);
   11285          507 :         return target;
   11286              :       }
   11287              : 
   11288          119 :       case SAD_EXPR:
   11289          119 :       {
   11290          119 :         tree oprnd0 = treeop0;
   11291          119 :         tree oprnd1 = treeop1;
   11292          119 :         tree oprnd2 = treeop2;
   11293              : 
   11294          119 :         expand_operands (oprnd0, oprnd1, NULL_RTX, &op0, &op1, EXPAND_NORMAL);
   11295          119 :         op2 = expand_normal (oprnd2);
   11296          119 :         target = expand_widen_pattern_expr (ops, op0, op1, op2,
   11297              :                                             target, unsignedp);
   11298          119 :         return target;
   11299              :       }
   11300              : 
   11301            0 :     case REALIGN_LOAD_EXPR:
   11302            0 :       {
   11303            0 :         tree oprnd0 = treeop0;
   11304            0 :         tree oprnd1 = treeop1;
   11305            0 :         tree oprnd2 = treeop2;
   11306              : 
   11307            0 :         this_optab = optab_for_tree_code (code, type, optab_default);
   11308            0 :         expand_operands (oprnd0, oprnd1, NULL_RTX, &op0, &op1, EXPAND_NORMAL);
   11309            0 :         op2 = expand_normal (oprnd2);
   11310            0 :         temp = expand_ternary_op (mode, this_optab, op0, op1, op2,
   11311              :                                   target, unsignedp);
   11312            0 :         gcc_assert (temp);
   11313              :         return temp;
   11314              :       }
   11315              : 
   11316        18154 :     case COND_EXPR:
   11317        18154 :       {
   11318              :         /* A COND_EXPR with its type being VOID_TYPE represents a
   11319              :            conditional jump and is handled in
   11320              :            expand_gimple_cond_expr.  */
   11321        18154 :         gcc_assert (!VOID_TYPE_P (type));
   11322              : 
   11323              :         /* Note that COND_EXPRs whose type is a structure or union
   11324              :            are required to be constructed to contain assignments of
   11325              :            a temporary variable, so that we can evaluate them here
   11326              :            for side effect only.  If type is void, we must do likewise.  */
   11327              : 
   11328        18154 :         gcc_assert (!TREE_ADDRESSABLE (type)
   11329              :                     && !ignore
   11330              :                     && TREE_TYPE (treeop1) != void_type_node
   11331              :                     && TREE_TYPE (treeop2) != void_type_node);
   11332              : 
   11333        18154 :         temp = expand_cond_expr_using_cmove (treeop0, treeop1, treeop2);
   11334        18154 :         if (temp)
   11335              :           return temp;
   11336              : 
   11337              :         /* If we are not to produce a result, we have no target.  Otherwise,
   11338              :            if a target was specified use it; it will not be used as an
   11339              :            intermediate target unless it is safe.  If no target, use a
   11340              :            temporary.  */
   11341              : 
   11342         3179 :         if (modifier != EXPAND_STACK_PARM
   11343         3179 :             && original_target
   11344         2365 :             && safe_from_p (original_target, treeop0, 1)
   11345            0 :             && GET_MODE (original_target) == mode
   11346         3179 :             && !MEM_P (original_target))
   11347              :           temp = original_target;
   11348              :         else
   11349         3179 :           temp = assign_temp (type, 0, 1);
   11350              : 
   11351         3179 :         do_pending_stack_adjust ();
   11352         3179 :         NO_DEFER_POP;
   11353         3179 :         rtx_code_label *lab0 = gen_label_rtx ();
   11354         3179 :         rtx_code_label *lab1 = gen_label_rtx ();
   11355         3179 :         jumpifnot (treeop0, lab0,
   11356              :                    profile_probability::uninitialized ());
   11357         3179 :         store_expr (treeop1, temp,
   11358              :                     modifier == EXPAND_STACK_PARM,
   11359              :                     false, false);
   11360              : 
   11361         3179 :         emit_jump_insn (targetm.gen_jump (lab1));
   11362         3179 :         emit_barrier ();
   11363         3179 :         emit_label (lab0);
   11364         3179 :         store_expr (treeop2, temp,
   11365              :                     modifier == EXPAND_STACK_PARM,
   11366              :                     false, false);
   11367              : 
   11368         3179 :         emit_label (lab1);
   11369         3179 :         OK_DEFER_POP;
   11370         3179 :         return temp;
   11371              :       }
   11372              : 
   11373            0 :     case VEC_DUPLICATE_EXPR:
   11374            0 :       op0 = expand_expr (treeop0, NULL_RTX, VOIDmode, modifier);
   11375            0 :       target = expand_vector_broadcast (mode, op0);
   11376            0 :       gcc_assert (target);
   11377              :       return target;
   11378              : 
   11379            0 :     case VEC_SERIES_EXPR:
   11380            0 :       expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, modifier);
   11381            0 :       return expand_vec_series_expr (mode, op0, op1, target);
   11382              : 
   11383          850 :     case BIT_INSERT_EXPR:
   11384          850 :       {
   11385          850 :         unsigned bitpos = tree_to_uhwi (treeop2);
   11386          850 :         unsigned bitsize;
   11387          850 :         if (INTEGRAL_TYPE_P (TREE_TYPE (treeop1)))
   11388          550 :           bitsize = TYPE_PRECISION (TREE_TYPE (treeop1));
   11389              :         else
   11390          300 :           bitsize = tree_to_uhwi (TYPE_SIZE (TREE_TYPE (treeop1)));
   11391          850 :         op0 = expand_normal (treeop0);
   11392          850 :         op1 = expand_normal (treeop1);
   11393          850 :         rtx dst = gen_reg_rtx (mode);
   11394          850 :         emit_move_insn (dst, op0);
   11395          850 :         store_bit_field (dst, bitsize, bitpos, 0, 0,
   11396          850 :                          TYPE_MODE (TREE_TYPE (treeop1)), op1, false, false);
   11397          850 :         return dst;
   11398              :       }
   11399              : 
   11400            0 :     default:
   11401            0 :       gcc_unreachable ();
   11402              :     }
   11403              : 
   11404              :   /* Here to do an ordinary binary operator.  */
   11405      1204417 :  binop:
   11406      1204417 :   expand_operands (treeop0, treeop1,
   11407              :                    subtarget, &op0, &op1, EXPAND_NORMAL);
   11408      5808320 :  binop2:
   11409      5808320 :   this_optab = optab_for_tree_code (code, type, optab_default);
   11410      5827112 :  binop3:
   11411      5827112 :   if (modifier == EXPAND_STACK_PARM)
   11412        27479 :     target = 0;
   11413      5827112 :   temp = expand_binop (mode, this_optab, op0, op1, target,
   11414              :                        unsignedp, OPTAB_LIB_WIDEN);
   11415      5827112 :   gcc_assert (temp);
   11416              :   /* Bitwise operations do not need bitfield reduction as we expect their
   11417              :      operands being properly truncated.  */
   11418      5827112 :   if (code == BIT_XOR_EXPR
   11419              :       || code == BIT_AND_EXPR
   11420      5827112 :       || code == BIT_IOR_EXPR)
   11421              :     return temp;
   11422      5198621 :   return REDUCE_BIT_FIELD (temp);
   11423              : }
   11424              : #undef REDUCE_BIT_FIELD
   11425              : 
   11426              : 
   11427              : /* Return TRUE if expression STMT is suitable for replacement.
   11428              :    Never consider memory loads as replaceable, because those don't ever lead
   11429              :    into constant expressions.  */
   11430              : 
   11431              : static bool
   11432            8 : stmt_is_replaceable_p (gimple *stmt)
   11433              : {
   11434            8 :   if (ssa_is_replaceable_p (stmt))
   11435              :     {
   11436              :       /* Don't move around loads.  */
   11437            7 :       if (!gimple_assign_single_p (stmt)
   11438            7 :           || is_gimple_val (gimple_assign_rhs1 (stmt)))
   11439            6 :         return true;
   11440              :     }
   11441              :   return false;
   11442              : }
   11443              : 
   11444              : /* A subroutine of expand_expr_real_1.  Expand gimple assignment G,
   11445              :    which is known to set an SSA_NAME result.  The other arguments are
   11446              :    as for expand_expr_real_1.  */
   11447              : 
   11448              : rtx
   11449     15491146 : expand_expr_real_gassign (gassign *g, rtx target, machine_mode tmode,
   11450              :                           enum expand_modifier modifier, rtx *alt_rtl,
   11451              :                           bool inner_reference_p)
   11452              : {
   11453     15491146 :   separate_ops ops;
   11454     15491146 :   rtx r;
   11455     15491146 :   location_t saved_loc = curr_insn_location ();
   11456     15491146 :   auto loc = gimple_location (g);
   11457     15491146 :   if (loc != UNKNOWN_LOCATION)
   11458     12424275 :     set_curr_insn_location (loc);
   11459     15491146 :   tree lhs = gimple_assign_lhs (g);
   11460     15491146 :   ops.code = gimple_assign_rhs_code (g);
   11461     15491146 :   ops.type = TREE_TYPE (lhs);
   11462     15491146 :   switch (get_gimple_rhs_class (ops.code))
   11463              :     {
   11464        95916 :     case GIMPLE_TERNARY_RHS:
   11465       191832 :       ops.op2 = gimple_assign_rhs3 (g);
   11466              :       /* Fallthru */
   11467      8333688 :     case GIMPLE_BINARY_RHS:
   11468      8333688 :       ops.op1 = gimple_assign_rhs2 (g);
   11469              : 
   11470              :       /* Try to expand conditional compare.  */
   11471      8333688 :       if (targetm.have_ccmp ())
   11472              :         {
   11473       165133 :           gcc_checking_assert (targetm.gen_ccmp_next != NULL);
   11474       165133 :           r = expand_ccmp_expr (g, TYPE_MODE (ops.type));
   11475       165133 :           if (r)
   11476              :             break;
   11477              :         }
   11478              :       /* Fallthru */
   11479     11984475 :     case GIMPLE_UNARY_RHS:
   11480     11984475 :       ops.op0 = gimple_assign_rhs1 (g);
   11481     11984475 :       ops.location = loc;
   11482     11984475 :       r = expand_expr_real_2 (&ops, target, tmode, modifier);
   11483     11984475 :       break;
   11484      3506642 :     case GIMPLE_SINGLE_RHS:
   11485      3506642 :       {
   11486      3506642 :         r = expand_expr_real (gimple_assign_rhs1 (g), target,
   11487              :                               tmode, modifier, alt_rtl,
   11488              :                               inner_reference_p);
   11489      3506642 :         break;
   11490              :       }
   11491            0 :     default:
   11492            0 :       gcc_unreachable ();
   11493              :     }
   11494     15491146 :   set_curr_insn_location (saved_loc);
   11495     15491146 :   if (REG_P (r) && !REG_EXPR (r))
   11496      4031972 :     set_reg_attrs_for_decl_rtl (lhs, r);
   11497     15491146 :   return r;
   11498              : }
   11499              : 
   11500              : /* A subroutine of expand_expr_real_1.  Attempt to VIEW_CONVERT_EXPR
   11501              :    the complex expression OP0 to the vector mode MODE.  Store the
   11502              :    result at TARGET if possible (if TARGET is nonzero).  Returns
   11503              :    NULL_RTX on failure.  */
   11504              : static rtx
   11505         6745 : try_expand_complex_as_vector (machine_mode mode, rtx op0, rtx target)
   11506              : {
   11507         6745 :   if (COMPLEX_MODE_P (GET_MODE (op0))
   11508         1453 :       && VECTOR_MODE_P (mode)
   11509           42 :       && known_eq (GET_MODE_NUNITS (mode), 2)
   11510         6787 :       && GET_MODE_INNER (mode) == GET_MODE_INNER (GET_MODE (op0)))
   11511              :     {
   11512           21 :       enum insn_code icode = convert_optab_handler (vec_init_optab, mode,
   11513           21 :                                                     GET_MODE_INNER (mode));
   11514           21 :       if (icode != CODE_FOR_nothing)
   11515              :         {
   11516           21 :           if (!target || !REG_P (target))
   11517            4 :             target = gen_reg_rtx (mode);
   11518           21 :           rtx rpart = read_complex_part (op0, false);
   11519           21 :           rtx ipart = read_complex_part (op0, true);
   11520           21 :           if (!REG_P (rpart) && !CONSTANT_P (rpart))
   11521            0 :             rpart = force_reg (GET_MODE_INNER (mode), rpart);
   11522           21 :           if (!REG_P (ipart) && !CONSTANT_P (ipart))
   11523            0 :             ipart = force_reg (GET_MODE_INNER (mode), ipart);
   11524           21 :           rtvec vec = rtvec_alloc (2);
   11525           21 :           RTVEC_ELT (vec, 0) = rpart;
   11526           21 :           RTVEC_ELT (vec, 1) = ipart;
   11527           21 :           rtx par = gen_rtx_PARALLEL (mode, vec);
   11528           21 :           rtx_insn *insn = GEN_FCN (icode) (target, par);
   11529           21 :           if (insn)
   11530              :             {
   11531           21 :               emit_insn (insn);
   11532           21 :               return target;
   11533              :             }
   11534              :         }
   11535              :     }
   11536              :   return NULL_RTX;
   11537              : }
   11538              : 
   11539              : rtx
   11540    161356963 : expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
   11541              :                     enum expand_modifier modifier, rtx *alt_rtl,
   11542              :                     bool inner_reference_p)
   11543              : {
   11544    161356963 :   rtx op0, op1, temp, decl_rtl;
   11545    161356963 :   tree type;
   11546    161356963 :   int unsignedp;
   11547    161356963 :   machine_mode mode, dmode;
   11548    161356963 :   enum tree_code code = TREE_CODE (exp);
   11549    161356963 :   rtx subtarget, original_target;
   11550    161356963 :   int ignore;
   11551    161356963 :   bool reduce_bit_field;
   11552    161356963 :   location_t loc = EXPR_LOCATION (exp);
   11553    161356963 :   struct separate_ops ops;
   11554    161356963 :   tree treeop0, treeop1, treeop2;
   11555    161356963 :   tree ssa_name = NULL_TREE;
   11556    161356963 :   gimple *g;
   11557              : 
   11558              :   /* EXPAND_NORMAL is the only modifier that guarantees that a memory
   11559              :      reference describes a load.  Use store semantics otherwise.  */
   11560    161356963 :   const bool may_store_p = modifier != EXPAND_NORMAL;
   11561              : 
   11562              :   /* Some ABIs define padding bits in _BitInt uninitialized.  Normally, RTL
   11563              :      expansion sign/zero extends integral types with less than mode precision
   11564              :      when reading from bit-fields and after arithmetic operations (see
   11565              :      REDUCE_BIT_FIELD in expand_expr_real_2) and on subsequent loads relies
   11566              :      on those extensions to have been already performed, but because of the
   11567              :      above for _BitInt they need to be sign/zero extended when reading from
   11568              :      locations that could be exposed to ABI boundaries (when loading from
   11569              :      objects in memory, or function arguments, return value).  Because we
   11570              :      internally extend after arithmetic operations, we can avoid doing that
   11571              :      when reading from SSA_NAMEs of vars.  */
   11572              : #define EXTEND_BITINT(expr) \
   11573              :   ((BITINT_TYPE_P (type)                                                \
   11574              :     && !bitint_extended                                                 \
   11575              :     && reduce_bit_field                                                 \
   11576              :     && mode != BLKmode                                                  \
   11577              :     && modifier != EXPAND_MEMORY                                        \
   11578              :     && modifier != EXPAND_WRITE                                         \
   11579              :     && modifier != EXPAND_INITIALIZER                                   \
   11580              :     && modifier != EXPAND_CONST_ADDRESS)                                \
   11581              :    ? reduce_to_bit_field_precision ((expr), NULL_RTX, type) : (expr))
   11582              : 
   11583    161356963 :   type = TREE_TYPE (exp);
   11584    161356963 :   mode = TYPE_MODE (type);
   11585    161356963 :   unsignedp = TYPE_UNSIGNED (type);
   11586    161356963 :   if (BITINT_TYPE_P (type) && bitint_extended == -1)
   11587              :     {
   11588         9850 :       struct bitint_info info;
   11589         9850 :       bool ok = targetm.c.bitint_type_info (TYPE_PRECISION (type), &info);
   11590         9850 :       gcc_assert (ok);
   11591         9850 :       bitint_extended = info.extended;
   11592              :     }
   11593              : 
   11594    161356963 :   treeop0 = treeop1 = treeop2 = NULL_TREE;
   11595    161356963 :   if (!VL_EXP_CLASS_P (exp))
   11596    154480783 :     switch (TREE_CODE_LENGTH (code))
   11597              :       {
   11598      5645049 :         default:
   11599      5645049 :         case 3: treeop2 = TREE_OPERAND (exp, 2); /* FALLTHRU */
   11600     13861250 :         case 2: treeop1 = TREE_OPERAND (exp, 1); /* FALLTHRU */
   11601     28541401 :         case 1: treeop0 = TREE_OPERAND (exp, 0); /* FALLTHRU */
   11602              :         case 0: break;
   11603              :       }
   11604    161356963 :   ops.code = code;
   11605    161356963 :   ops.type = type;
   11606    161356963 :   ops.op0 = treeop0;
   11607    161356963 :   ops.op1 = treeop1;
   11608    161356963 :   ops.op2 = treeop2;
   11609    161356963 :   ops.location = loc;
   11610              : 
   11611    322713926 :   ignore = (target == const0_rtx
   11612    161356963 :             || ((CONVERT_EXPR_CODE_P (code)
   11613    156195103 :                  || code == COND_EXPR || code == VIEW_CONVERT_EXPR)
   11614       973377 :                 && TREE_CODE (type) == VOID_TYPE));
   11615              : 
   11616              :   /* An operation in what may be a bit-field type needs the
   11617              :      result to be reduced to the precision of the bit-field type,
   11618              :      which is narrower than that of the type's mode.  */
   11619    322713686 :   reduce_bit_field = (!ignore
   11620    156817215 :                       && INTEGRAL_TYPE_P (type)
   11621     83015032 :                       && !type_has_mode_precision_p (type));
   11622              : 
   11623              :   /* If we are going to ignore this result, we need only do something
   11624              :      if there is a side-effect somewhere in the expression.  If there
   11625              :      is, short-circuit the most common cases here.  Note that we must
   11626              :      not call expand_expr with anything but const0_rtx in case this
   11627              :      is an initial expansion of a size that contains a PLACEHOLDER_EXPR.  */
   11628              : 
   11629              :   if (ignore)
   11630              :     {
   11631      4539748 :       if (! TREE_SIDE_EFFECTS (exp))
   11632              :         return const0_rtx;
   11633              : 
   11634              :       /* Ensure we reference a volatile object even if value is ignored, but
   11635              :          don't do this if all we are doing is taking its address.  */
   11636      4539508 :       if (TREE_THIS_VOLATILE (exp)
   11637            0 :           && TREE_CODE (exp) != FUNCTION_DECL
   11638            0 :           && mode != VOIDmode && mode != BLKmode
   11639            0 :           && modifier != EXPAND_CONST_ADDRESS)
   11640              :         {
   11641            0 :           temp = expand_expr (exp, NULL_RTX, VOIDmode, modifier);
   11642            0 :           if (MEM_P (temp))
   11643            0 :             copy_to_reg (temp);
   11644            0 :           return const0_rtx;
   11645              :         }
   11646              : 
   11647      4539508 :       if (TREE_CODE_CLASS (code) == tcc_unary
   11648              :           || code == BIT_FIELD_REF
   11649      4539508 :           || code == COMPONENT_REF
   11650      4539508 :           || code == INDIRECT_REF)
   11651            0 :         return expand_expr (treeop0, const0_rtx, VOIDmode,
   11652            0 :                             modifier);
   11653              : 
   11654      4539508 :       else if (TREE_CODE_CLASS (code) == tcc_binary
   11655      4539508 :                || TREE_CODE_CLASS (code) == tcc_comparison
   11656      4539508 :                || code == ARRAY_REF || code == ARRAY_RANGE_REF)
   11657              :         {
   11658            0 :           expand_expr (treeop0, const0_rtx, VOIDmode, modifier);
   11659            0 :           expand_expr (treeop1, const0_rtx, VOIDmode, modifier);
   11660            0 :           return const0_rtx;
   11661              :         }
   11662              : 
   11663              :       target = 0;
   11664              :     }
   11665              : 
   11666    161356723 :   if (reduce_bit_field && modifier == EXPAND_STACK_PARM)
   11667        40959 :     target = 0;
   11668              : 
   11669              :   /* Use subtarget as the target for operand 0 of a binary operation.  */
   11670    161356723 :   subtarget = get_subtarget (target);
   11671    161356723 :   original_target = target;
   11672              : 
   11673    161356723 :   switch (code)
   11674              :     {
   11675        11035 :     case LABEL_DECL:
   11676        11035 :       {
   11677        11035 :         tree function = decl_function_context (exp);
   11678              : 
   11679        11035 :         temp = label_rtx (exp);
   11680        14979 :         temp = gen_rtx_LABEL_REF (Pmode, temp);
   11681              : 
   11682        11035 :         if (function != current_function_decl
   11683         1383 :             && function != 0)
   11684         1383 :           LABEL_REF_NONLOCAL_P (temp) = 1;
   11685              : 
   11686        11035 :         temp = gen_rtx_MEM (FUNCTION_MODE, temp);
   11687        11035 :         return temp;
   11688              :       }
   11689              : 
   11690     58386910 :     case SSA_NAME:
   11691              :       /* ??? ivopts calls expander, without any preparation from
   11692              :          out-of-ssa.  So fake instructions as if this was an access to the
   11693              :          base variable.  This unnecessarily allocates a pseudo, see how we can
   11694              :          reuse it, if partition base vars have it set already.  */
   11695     58386910 :       if (!currently_expanding_to_rtl)
   11696              :         {
   11697            0 :           tree var = SSA_NAME_VAR (exp);
   11698            0 :           if (var && DECL_RTL_SET_P (var))
   11699            0 :             return DECL_RTL (var);
   11700            0 :           return gen_raw_REG (TYPE_MODE (TREE_TYPE (exp)),
   11701            0 :                               LAST_VIRTUAL_REGISTER + 1);
   11702              :         }
   11703              : 
   11704     58386910 :       g = get_gimple_for_ssa_name (exp);
   11705              :       /* For EXPAND_INITIALIZER try harder to get something simpler.  */
   11706     58386910 :       if (g == NULL
   11707     58386910 :           && modifier == EXPAND_INITIALIZER
   11708           26 :           && !SSA_NAME_IS_DEFAULT_DEF (exp)
   11709           11 :           && (optimize || !SSA_NAME_VAR (exp)
   11710            1 :               || DECL_IGNORED_P (SSA_NAME_VAR (exp)))
   11711           10 :           && is_gimple_assign (SSA_NAME_DEF_STMT (exp))
   11712     58386918 :           && stmt_is_replaceable_p (SSA_NAME_DEF_STMT (exp)))
   11713            6 :         g = SSA_NAME_DEF_STMT (exp);
   11714     58386910 :       if (safe_is_a <gassign *> (g))
   11715      9310834 :         return expand_expr_real_gassign (as_a<gassign *> (g), target, tmode,
   11716      9310834 :                                          modifier, alt_rtl, inner_reference_p);
   11717     49076076 :       else if (safe_is_a <gcall *> (g))
   11718              :         {
   11719              :           /* ???  internal call expansion doesn't follow the usual API
   11720              :              of returning the destination RTX and being passed a desired
   11721              :              target.  */
   11722        70154 :           if (modifier == EXPAND_WRITE)
   11723        35081 :             return DECL_RTL (SSA_NAME_VAR (exp));
   11724        35073 :           rtx dest = gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp)));
   11725        35073 :           tree tmplhs = make_tree (TREE_TYPE (exp), dest);
   11726        35073 :           tree var_or_id = SSA_NAME_VAR (exp);
   11727              :           if (!var_or_id)
   11728        24623 :             var_or_id = SSA_NAME_IDENTIFIER (exp);
   11729        35073 :           SET_SSA_NAME_VAR_OR_IDENTIFIER (exp, tmplhs);
   11730        35073 :           expand_internal_call (as_a <gcall *> (g));
   11731        35073 :           SET_SSA_NAME_VAR_OR_IDENTIFIER (exp, var_or_id);
   11732        35073 :           return dest;
   11733              :         }
   11734              : 
   11735     49005922 :       ssa_name = exp;
   11736     49005922 :       decl_rtl = get_rtx_for_ssa_name (ssa_name);
   11737     49005922 :       exp = SSA_NAME_VAR (ssa_name);
   11738              :       /* Optimize and avoid to EXTEND_BITINIT doing anything if it is an
   11739              :          SSA_NAME computed within the current function.  In such case the
   11740              :          value have been already extended before.  While if it is a function
   11741              :          parameter, result or some memory location, we need to be prepared
   11742              :          for some other compiler leaving the bits uninitialized.  */
   11743     19198971 :       if (!exp || VAR_P (exp))
   11744              :         reduce_bit_field = false;
   11745     49005922 :       goto expand_decl_rtl;
   11746              : 
   11747     20106236 :     case VAR_DECL:
   11748              :       /* Allow accel compiler to handle variables that require special
   11749              :          treatment, e.g. if they have been modified in some way earlier in
   11750              :          compilation by the adjust_private_decl OpenACC hook.  */
   11751     20106236 :       if (flag_openacc && targetm.goacc.expand_var_decl)
   11752              :         {
   11753            0 :           temp = targetm.goacc.expand_var_decl (exp);
   11754            0 :           if (temp)
   11755              :             return temp;
   11756              :         }
   11757              :       /* Expand const VAR_DECLs with CONSTRUCTOR initializers that
   11758              :          have scalar integer modes to a reg via store_constructor.  */
   11759     20106236 :       if (TREE_READONLY (exp)
   11760      3393651 :           && !TREE_SIDE_EFFECTS (exp)
   11761      3371243 :           && (modifier == EXPAND_NORMAL || modifier == EXPAND_STACK_PARM)
   11762        19606 :           && immediate_const_ctor_p (DECL_INITIAL (exp))
   11763          163 :           && SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (exp)))
   11764          127 :           && crtl->emit.regno_pointer_align_length
   11765     20106363 :           && !target)
   11766              :         {
   11767           88 :           target = gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp)));
   11768           88 :           store_constructor (DECL_INITIAL (exp), target, 0,
   11769           88 :                              int_expr_size (DECL_INITIAL (exp)), false);
   11770           88 :           return target;
   11771              :         }
   11772              :       /* ... fall through ...  */
   11773              : 
   11774     20657097 :     case PARM_DECL:
   11775              :       /* If a static var's type was incomplete when the decl was written,
   11776              :          but the type is complete now, lay out the decl now.  */
   11777     20657097 :       if (DECL_SIZE (exp) == 0
   11778        45582 :           && COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (TREE_TYPE (exp))
   11779     20702567 :           && (TREE_STATIC (exp) || DECL_EXTERNAL (exp)))
   11780        45470 :         layout_decl (exp, 0);
   11781              : 
   11782              :       /* fall through */
   11783              : 
   11784     22133441 :     case FUNCTION_DECL:
   11785     22133441 :     case RESULT_DECL:
   11786     22133441 :       decl_rtl = DECL_RTL (exp);
   11787     71139363 :     expand_decl_rtl:
   11788     71139363 :       gcc_assert (decl_rtl);
   11789              : 
   11790              :       /* DECL_MODE might change when TYPE_MODE depends on attribute target
   11791              :          settings for VECTOR_TYPE_P that might switch for the function.  */
   11792     71139363 :       if (currently_expanding_to_rtl
   11793     67446489 :           && code == VAR_DECL && MEM_P (decl_rtl)
   11794     86186635 :           && VECTOR_TYPE_P (type) && exp && DECL_MODE (exp) != mode)
   11795           61 :         decl_rtl = change_address (decl_rtl, TYPE_MODE (type), 0);
   11796              :       else
   11797     71139302 :         decl_rtl = copy_rtx (decl_rtl);
   11798              : 
   11799     71139363 :       if (exp && MEM_P (decl_rtl))
   11800     23099131 :         MEM_NOTRAP_P (decl_rtl)
   11801     46198262 :           = !(may_store_p
   11802     23099131 :               ? lhs_could_trap_p (exp) : tree_could_trap_p (exp));
   11803              : 
   11804              :       /* Record writes to register variables.  */
   11805     71139363 :       if (modifier == EXPAND_WRITE
   11806     22450478 :           && REG_P (decl_rtl)
   11807     87515983 :           && HARD_REGISTER_P (decl_rtl))
   11808         2059 :         add_to_hard_reg_set (&crtl->asm_clobbers,
   11809         2059 :                              GET_MODE (decl_rtl), REGNO (decl_rtl));
   11810              : 
   11811              :       /* Ensure variable marked as used even if it doesn't go through
   11812              :          a parser.  If it hasn't be used yet, write out an external
   11813              :          definition.  */
   11814     71139363 :       if (exp)
   11815     41332412 :         TREE_USED (exp) = 1;
   11816              : 
   11817              :       /* Show we haven't gotten RTL for this yet.  */
   11818    112471775 :       temp = 0;
   11819              : 
   11820              :       /* Variables inherited from containing functions should have
   11821              :          been lowered by this point.  */
   11822     41332412 :       if (exp)
   11823              :         {
   11824     41332412 :           tree context = decl_function_context (exp);
   11825     41332412 :           gcc_assert (SCOPE_FILE_SCOPE_P (context)
   11826              :                       || context == current_function_decl
   11827              :                       || TREE_STATIC (exp)
   11828              :                       || DECL_EXTERNAL (exp)
   11829              :                       /* ??? C++ creates functions that are not
   11830              :                          TREE_STATIC.  */
   11831              :                       || TREE_CODE (exp) == FUNCTION_DECL);
   11832              :         }
   11833              : 
   11834              :       /* This is the case of an array whose size is to be determined
   11835              :          from its initializer, while the initializer is still being parsed.
   11836              :          ??? We aren't parsing while expanding anymore.  */
   11837              : 
   11838     71139363 :       if (MEM_P (decl_rtl) && REG_P (XEXP (decl_rtl, 0)))
   11839       403701 :         temp = validize_mem (decl_rtl);
   11840              : 
   11841              :       /* If DECL_RTL is memory, we are in the normal case and the
   11842              :          address is not valid, get the address into a register.  */
   11843              : 
   11844     70735662 :       else if (MEM_P (decl_rtl) && modifier != EXPAND_INITIALIZER)
   11845              :         {
   11846     19193923 :           if (alt_rtl)
   11847      2045698 :             *alt_rtl = decl_rtl;
   11848     19193923 :           decl_rtl = use_anchored_address (decl_rtl);
   11849     19193923 :           if (modifier != EXPAND_CONST_ADDRESS
   11850     19193923 :               && modifier != EXPAND_SUM
   11851     31804692 :               && !memory_address_addr_space_p (exp ? DECL_MODE (exp)
   11852        18522 :                                                : GET_MODE (decl_rtl),
   11853              :                                                XEXP (decl_rtl, 0),
   11854     12610769 :                                                MEM_ADDR_SPACE (decl_rtl)))
   11855       166670 :             temp = replace_equiv_address (decl_rtl,
   11856              :                                           copy_rtx (XEXP (decl_rtl, 0)));
   11857              :         }
   11858              : 
   11859              :       /* If we got something, return it.  But first, set the alignment
   11860              :          if the address is a register.  */
   11861     19597624 :       if (temp != 0)
   11862              :         {
   11863       570371 :           if (exp && MEM_P (temp) && REG_P (XEXP (temp, 0)))
   11864       537945 :             mark_reg_pointer (XEXP (temp, 0), DECL_ALIGN (exp));
   11865              :         }
   11866     70568992 :       else if (MEM_P (decl_rtl))
   11867              :         temp = decl_rtl;
   11868              : 
   11869     48559655 :       if (temp != 0)
   11870              :         {
   11871     23117663 :           if (MEM_P (temp)
   11872              :               && modifier != EXPAND_WRITE
   11873     23117663 :               && modifier != EXPAND_MEMORY
   11874              :               && modifier != EXPAND_INITIALIZER
   11875     16982105 :               && modifier != EXPAND_CONST_ADDRESS
   11876      7057321 :               && modifier != EXPAND_SUM
   11877      7057321 :               && !inner_reference_p
   11878      4627083 :               && mode != BLKmode
   11879     27375028 :               && MEM_ALIGN (temp) < GET_MODE_ALIGNMENT (mode))
   11880        20368 :             temp = expand_misaligned_mem_ref (temp, mode, unsignedp,
   11881        20368 :                                               MEM_ALIGN (temp), NULL_RTX, NULL);
   11882              : 
   11883     23117663 :           return EXTEND_BITINT (temp);
   11884              :         }
   11885              : 
   11886     48021700 :       if (exp)
   11887     18233281 :         dmode = DECL_MODE (exp);
   11888              :       else
   11889     29788419 :         dmode = TYPE_MODE (TREE_TYPE (ssa_name));
   11890              : 
   11891              :       /* If the mode of DECL_RTL does not match that of the decl,
   11892              :          there are two cases: we are dealing with a BLKmode value
   11893              :          that is returned in a register, or we are dealing with
   11894              :          a promoted value.  In the latter case, return a SUBREG
   11895              :          of the wanted mode, but mark it so that we know that it
   11896              :          was already extended.  */
   11897     48021700 :       if (REG_P (decl_rtl)
   11898     47472185 :           && dmode != BLKmode
   11899     47472185 :           && GET_MODE (decl_rtl) != dmode)
   11900              :         {
   11901           84 :           machine_mode pmode;
   11902              : 
   11903              :           /* Get the signedness to be used for this variable.  Ensure we get
   11904              :              the same mode we got when the variable was declared.  */
   11905           84 :           if (code != SSA_NAME)
   11906            0 :             pmode = promote_decl_mode (exp, &unsignedp);
   11907           84 :           else if ((g = SSA_NAME_DEF_STMT (ssa_name))
   11908           84 :                    && gimple_code (g) == GIMPLE_CALL
   11909           86 :                    && !gimple_call_internal_p (g))
   11910            2 :             pmode = promote_function_mode (type, mode, &unsignedp,
   11911            2 :                                            gimple_call_fntype (g),
   11912              :                                            2);
   11913              :           else
   11914           82 :             pmode = promote_ssa_mode (ssa_name, &unsignedp);
   11915           84 :           gcc_assert (GET_MODE (decl_rtl) == pmode);
   11916              : 
   11917              :           /* Some ABIs require scalar floating point modes to be passed
   11918              :              in a wider scalar integer mode.  We need to explicitly
   11919              :              truncate to an integer mode of the correct precision before
   11920              :              using a SUBREG to reinterpret as a floating point value.  */
   11921           84 :           if (SCALAR_FLOAT_MODE_P (mode)
   11922            0 :               && SCALAR_INT_MODE_P (pmode)
   11923           84 :               && known_lt (GET_MODE_SIZE (mode), GET_MODE_SIZE (pmode)))
   11924            0 :             return convert_wider_int_to_float (mode, pmode, decl_rtl);
   11925              : 
   11926           84 :           temp = gen_lowpart_SUBREG (mode, decl_rtl);
   11927           84 :           SUBREG_PROMOTED_VAR_P (temp) = 1;
   11928           84 :           SUBREG_PROMOTED_SET (temp, unsignedp);
   11929           84 :           return EXTEND_BITINT (temp);
   11930              :         }
   11931              : 
   11932     48021616 :       return EXTEND_BITINT (decl_rtl);
   11933              : 
   11934     43573367 :     case INTEGER_CST:
   11935     43573367 :       {
   11936     43573367 :         if (BITINT_TYPE_P (type))
   11937              :           {
   11938        13095 :             unsigned int prec = TYPE_PRECISION (type);
   11939        13095 :             struct bitint_info info;
   11940        13095 :             bool ok = targetm.c.bitint_type_info (prec, &info);
   11941        13095 :             gcc_assert (ok);
   11942        13095 :             scalar_int_mode limb_mode
   11943        13095 :               = as_a <scalar_int_mode> (info.limb_mode);
   11944        13095 :             unsigned int limb_prec = GET_MODE_PRECISION (limb_mode);
   11945        21312 :             if (prec > limb_prec && prec > MAX_FIXED_MODE_SIZE)
   11946              :               {
   11947              :                 /* Emit large/huge _BitInt INTEGER_CSTs into memory.  */
   11948         5857 :                 exp = tree_output_constant_def (exp);
   11949         5857 :                 return expand_expr (exp, target, VOIDmode, modifier);
   11950              :               }
   11951              :           }
   11952              : 
   11953              :         /* Given that TYPE_PRECISION (type) is not always equal to
   11954              :            GET_MODE_PRECISION (TYPE_MODE (type)), we need to extend from
   11955              :            the former to the latter according to the signedness of the
   11956              :            type.  */
   11957     43567510 :         scalar_int_mode int_mode = SCALAR_INT_TYPE_MODE (type);
   11958     43567510 :         temp = immed_wide_int_const
   11959     43567510 :           (wi::to_wide (exp, GET_MODE_PRECISION (int_mode)), int_mode);
   11960     43567510 :         return temp;
   11961              :       }
   11962              : 
   11963       587196 :     case VECTOR_CST:
   11964       587196 :       {
   11965       587196 :         tree tmp = NULL_TREE;
   11966       587196 :         if (VECTOR_MODE_P (mode))
   11967       584325 :           return const_vector_from_tree (exp);
   11968         2871 :         scalar_int_mode int_mode;
   11969         2871 :         if (is_int_mode (mode, &int_mode))
   11970              :           {
   11971          926 :             tree type_for_mode = lang_hooks.types.type_for_mode (int_mode, 1);
   11972          926 :             if (type_for_mode)
   11973          926 :               tmp = fold_unary_loc (loc, VIEW_CONVERT_EXPR,
   11974              :                                     type_for_mode, exp);
   11975              :           }
   11976          926 :         if (!tmp)
   11977              :           {
   11978         1945 :             vec<constructor_elt, va_gc> *v;
   11979              :             /* Constructors need to be fixed-length.  FIXME.  */
   11980         1945 :             unsigned int nunits = VECTOR_CST_NELTS (exp).to_constant ();
   11981         1945 :             vec_alloc (v, nunits);
   11982        31893 :             for (unsigned int i = 0; i < nunits; ++i)
   11983        28003 :               CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, VECTOR_CST_ELT (exp, i));
   11984         1945 :             tmp = build_constructor (type, v);
   11985              :           }
   11986         2871 :         return expand_expr (tmp, ignore ? const0_rtx : target,
   11987         2871 :                             tmode, modifier);
   11988              :       }
   11989              : 
   11990          137 :     case CONST_DECL:
   11991          137 :       if (modifier == EXPAND_WRITE)
   11992              :         {
   11993              :           /* Writing into CONST_DECL is always invalid, but handle it
   11994              :              gracefully.  */
   11995            2 :           addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (exp));
   11996            2 :           scalar_int_mode address_mode = targetm.addr_space.address_mode (as);
   11997            2 :           op0 = expand_expr_addr_expr_1 (exp, NULL_RTX, address_mode,
   11998              :                                          EXPAND_NORMAL, as);
   11999            2 :           op0 = memory_address_addr_space (mode, op0, as);
   12000            2 :           temp = gen_rtx_MEM (mode, op0);
   12001            2 :           set_mem_addr_space (temp, as);
   12002            2 :           return temp;
   12003              :         }
   12004          135 :       return expand_expr (DECL_INITIAL (exp), target, VOIDmode, modifier);
   12005              : 
   12006       874931 :     case REAL_CST:
   12007              :       /* If optimized, generate immediate CONST_DOUBLE
   12008              :          which will be turned into memory by reload if necessary.
   12009              : 
   12010              :          We used to force a register so that loop.c could see it.  But
   12011              :          this does not allow gen_* patterns to perform optimizations with
   12012              :          the constants.  It also produces two insns in cases like "x = 1.0;".
   12013              :          On most machines, floating-point constants are not permitted in
   12014              :          many insns, so we'd end up copying it to a register in any case.
   12015              : 
   12016              :          Now, we do the copying in expand_binop, if appropriate.  */
   12017       874931 :       return const_double_from_real_value (TREE_REAL_CST (exp),
   12018      1749862 :                                            TYPE_MODE (TREE_TYPE (exp)));
   12019              : 
   12020            0 :     case FIXED_CST:
   12021            0 :       return CONST_FIXED_FROM_FIXED_VALUE (TREE_FIXED_CST (exp),
   12022              :                                            TYPE_MODE (TREE_TYPE (exp)));
   12023              : 
   12024        18413 :     case COMPLEX_CST:
   12025              :       /* Handle evaluating a complex constant in a CONCAT target.  */
   12026        18413 :       if (original_target && GET_CODE (original_target) == CONCAT)
   12027              :         {
   12028          231 :           rtx rtarg, itarg;
   12029              : 
   12030          231 :           mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (exp)));
   12031          231 :           rtarg = XEXP (original_target, 0);
   12032          231 :           itarg = XEXP (original_target, 1);
   12033              : 
   12034              :           /* Move the real and imaginary parts separately.  */
   12035          231 :           op0 = expand_expr (TREE_REALPART (exp), rtarg, mode, EXPAND_NORMAL);
   12036          231 :           op1 = expand_expr (TREE_IMAGPART (exp), itarg, mode, EXPAND_NORMAL);
   12037              : 
   12038          231 :           if (op0 != rtarg)
   12039          231 :             emit_move_insn (rtarg, op0);
   12040          231 :           if (op1 != itarg)
   12041          231 :             emit_move_insn (itarg, op1);
   12042              : 
   12043              :           return original_target;
   12044              :         }
   12045              : 
   12046              :       /* fall through */
   12047              : 
   12048       189627 :     case STRING_CST:
   12049       189627 :       temp = expand_expr_constant (exp, 1, modifier);
   12050              : 
   12051              :       /* temp contains a constant address.
   12052              :          On RISC machines where a constant address isn't valid,
   12053              :          make some insns to get that address into a register.  */
   12054       189627 :       if (modifier != EXPAND_CONST_ADDRESS
   12055              :           && modifier != EXPAND_INITIALIZER
   12056       189627 :           && modifier != EXPAND_SUM
   12057       208181 :           && ! memory_address_addr_space_p (mode, XEXP (temp, 0),
   12058        18554 :                                             MEM_ADDR_SPACE (temp)))
   12059           12 :         return replace_equiv_address (temp,
   12060           12 :                                       copy_rtx (XEXP (temp, 0)));
   12061              :       return temp;
   12062              : 
   12063            0 :     case POLY_INT_CST:
   12064            0 :       return immed_wide_int_const (poly_int_cst_value (exp), mode);
   12065              : 
   12066         1743 :     case SAVE_EXPR:
   12067         1743 :       {
   12068         1743 :         tree val = treeop0;
   12069         1743 :         rtx ret = expand_expr_real_1 (val, target, tmode, modifier, alt_rtl,
   12070              :                                       inner_reference_p);
   12071              : 
   12072         1743 :         if (!SAVE_EXPR_RESOLVED_P (exp))
   12073              :           {
   12074              :             /* We can indeed still hit this case, typically via builtin
   12075              :                expanders calling save_expr immediately before expanding
   12076              :                something.  Assume this means that we only have to deal
   12077              :                with non-BLKmode values.  */
   12078         1696 :             gcc_assert (GET_MODE (ret) != BLKmode);
   12079              : 
   12080         1696 :             val = build_decl (curr_insn_location (),
   12081         1696 :                               VAR_DECL, NULL, TREE_TYPE (exp));
   12082         1696 :             DECL_ARTIFICIAL (val) = 1;
   12083         1696 :             DECL_IGNORED_P (val) = 1;
   12084         1696 :             treeop0 = val;
   12085         1696 :             TREE_OPERAND (exp, 0) = treeop0;
   12086         1696 :             SAVE_EXPR_RESOLVED_P (exp) = 1;
   12087              : 
   12088         1696 :             if (!CONSTANT_P (ret))
   12089         1696 :               ret = copy_to_reg (ret);
   12090         1696 :             SET_DECL_RTL (val, ret);
   12091              :           }
   12092              : 
   12093              :         return ret;
   12094              :       }
   12095              : 
   12096              : 
   12097       182407 :     case CONSTRUCTOR:
   12098              :       /* If we don't need the result, just ensure we evaluate any
   12099              :          subexpressions.  */
   12100       182407 :       if (ignore)
   12101              :         {
   12102              :           unsigned HOST_WIDE_INT idx;
   12103              :           tree value;
   12104              : 
   12105            0 :           FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, value)
   12106            0 :             expand_expr (value, const0_rtx, VOIDmode, EXPAND_NORMAL);
   12107              : 
   12108            0 :           return const0_rtx;
   12109              :         }
   12110              : 
   12111       182407 :       return expand_constructor (exp, target, modifier, false);
   12112              : 
   12113       867466 :     case TARGET_MEM_REF:
   12114       867466 :       {
   12115       867466 :         addr_space_t as
   12116       867466 :           = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0))));
   12117       867466 :         unsigned int align;
   12118              : 
   12119       867466 :         op0 = addr_for_mem_ref (exp, as, true);
   12120       867466 :         op0 = memory_address_addr_space (mode, op0, as);
   12121       867466 :         temp = gen_rtx_MEM (mode, op0);
   12122       867466 :         set_mem_attributes (temp, exp, 0, may_store_p);
   12123       867466 :         set_mem_addr_space (temp, as);
   12124       867466 :         align = get_object_alignment (exp);
   12125       867466 :         if (modifier != EXPAND_WRITE
   12126       867466 :             && modifier != EXPAND_MEMORY
   12127       595227 :             && mode != BLKmode
   12128      1456666 :             && align < GET_MODE_ALIGNMENT (mode))
   12129        54638 :           temp = expand_misaligned_mem_ref (temp, mode, unsignedp,
   12130              :                                             align, NULL_RTX, NULL);
   12131       867466 :         return EXTEND_BITINT (temp);
   12132              :       }
   12133              : 
   12134      6890130 :     case MEM_REF:
   12135      6890130 :       {
   12136      6890130 :         const bool reverse = REF_REVERSE_STORAGE_ORDER (exp);
   12137      6890130 :         addr_space_t as
   12138      6890130 :           = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0))));
   12139      6890130 :         machine_mode address_mode;
   12140      6890130 :         tree base = TREE_OPERAND (exp, 0);
   12141      6890130 :         gimple *def_stmt;
   12142      6890130 :         unsigned align;
   12143              :         /* Handle expansion of non-aliased memory with non-BLKmode.  That
   12144              :            might end up in a register.  */
   12145      6890130 :         if (mem_ref_refers_to_non_mem_p (exp))
   12146              :           {
   12147        82262 :             poly_int64 offset = mem_ref_offset (exp).force_shwi ();
   12148        82262 :             base = TREE_OPERAND (base, 0);
   12149        82262 :             poly_uint64 type_size;
   12150        82262 :             if (known_eq (offset, 0)
   12151        47062 :                 && !reverse
   12152        47062 :                 && poly_int_tree_p (TYPE_SIZE (type), &type_size)
   12153       176386 :                 && known_eq (GET_MODE_BITSIZE (DECL_MODE (base)), type_size))
   12154        19281 :               return expand_expr (build1 (VIEW_CONVERT_EXPR, type, base),
   12155        19281 :                                   target, tmode, modifier);
   12156        62981 :             unsigned align;
   12157        62981 :             if (TYPE_MODE (type) == BLKmode || maybe_lt (offset, 0))
   12158              :               {
   12159          219 :                 temp = assign_stack_temp (DECL_MODE (base),
   12160          438 :                                           GET_MODE_SIZE (DECL_MODE (base)));
   12161          219 :                 store_expr (base, temp, 0, false, false);
   12162          219 :                 temp = adjust_address (temp, TYPE_MODE (type), offset);
   12163          219 :                 if (TYPE_MODE (type) == BLKmode)
   12164          198 :                   set_mem_size (temp, int_size_in_bytes (type));
   12165              :                 /* When the original ref was misaligned so will be the
   12166              :                    access to the stack temporary.  Not all targets handle
   12167              :                    this correctly, some will ICE in sanity checking.
   12168              :                    Handle this by doing bitfield extraction when necessary.  */
   12169           42 :                 else if ((align = get_object_alignment (exp))
   12170           21 :                          < GET_MODE_ALIGNMENT (TYPE_MODE (type)))
   12171            3 :                   temp
   12172            3 :                     = expand_misaligned_mem_ref (temp, TYPE_MODE (type),
   12173              :                                                  unsignedp, align,
   12174              :                                                  modifier == EXPAND_STACK_PARM
   12175              :                                                  ? NULL_RTX : target, NULL);
   12176              :                 return temp;
   12177              :               }
   12178              :             /* When the access is fully outside of the underlying object
   12179              :                expand the offset as zero.  This avoids out-of-bound
   12180              :                BIT_FIELD_REFs and generates smaller code for these cases
   12181              :                with UB.  */
   12182        62762 :             type_size = tree_to_poly_uint64 (TYPE_SIZE_UNIT (type));
   12183       125524 :             if (!ranges_maybe_overlap_p (offset, type_size, 0,
   12184       125524 :                                          GET_MODE_SIZE (DECL_MODE (base))))
   12185           38 :               offset = 0;
   12186        62762 :             exp = build3 (BIT_FIELD_REF, type, base, TYPE_SIZE (type),
   12187        62762 :                           bitsize_int (offset * BITS_PER_UNIT));
   12188        62762 :             REF_REVERSE_STORAGE_ORDER (exp) = reverse;
   12189        62762 :             return expand_expr (exp, target, tmode, modifier);
   12190              :           }
   12191      6807868 :         address_mode = targetm.addr_space.address_mode (as);
   12192      6807868 :         if ((def_stmt = get_def_for_expr (base, BIT_AND_EXPR)))
   12193              :           {
   12194           42 :             tree mask = gimple_assign_rhs2 (def_stmt);
   12195           42 :             base = build2 (BIT_AND_EXPR, TREE_TYPE (base),
   12196              :                            gimple_assign_rhs1 (def_stmt), mask);
   12197           42 :             TREE_OPERAND (exp, 0) = base;
   12198              :           }
   12199      6807868 :         align = get_object_alignment (exp);
   12200      6807868 :         op0 = expand_expr (base, NULL_RTX, VOIDmode, EXPAND_SUM);
   12201      6807868 :         op0 = memory_address_addr_space (mode, op0, as);
   12202      6807868 :         if (!integer_zerop (TREE_OPERAND (exp, 1)))
   12203              :           {
   12204      2054042 :             rtx off = immed_wide_int_const (mem_ref_offset (exp), address_mode);
   12205      2054042 :             op0 = simplify_gen_binary (PLUS, address_mode, op0, off);
   12206      2054042 :             op0 = memory_address_addr_space (mode, op0, as);
   12207              :           }
   12208      6807868 :         temp = gen_rtx_MEM (mode, op0);
   12209      6807868 :         set_mem_attributes (temp, exp, 0, may_store_p);
   12210      6807868 :         set_mem_addr_space (temp, as);
   12211      6807868 :         if (TREE_THIS_VOLATILE (exp))
   12212        13079 :           MEM_VOLATILE_P (temp) = 1;
   12213      6807868 :         if (modifier == EXPAND_WRITE || modifier == EXPAND_MEMORY)
   12214              :           return temp;
   12215      4036420 :         if (!inner_reference_p
   12216      2072297 :             && mode != BLKmode
   12217      6045951 :             && align < GET_MODE_ALIGNMENT (mode))
   12218       138195 :           temp = expand_misaligned_mem_ref (temp, mode, unsignedp, align,
   12219              :                                             modifier == EXPAND_STACK_PARM
   12220              :                                             ? NULL_RTX : target, alt_rtl);
   12221      4036420 :         if (reverse)
   12222           16 :           temp = flip_storage_order (mode, temp);
   12223      4036420 :         return EXTEND_BITINT (temp);
   12224              :       }
   12225              : 
   12226       643108 :     case ARRAY_REF:
   12227              : 
   12228       643108 :       {
   12229       643108 :         tree array = treeop0;
   12230       643108 :         tree index = treeop1;
   12231       643108 :         tree init;
   12232              : 
   12233              :         /* Fold an expression like: "foo"[2].
   12234              :            This is not done in fold so it won't happen inside &.
   12235              :            Don't fold if this is for wide characters since it's too
   12236              :            difficult to do correctly and this is a very rare case.  */
   12237              : 
   12238       643108 :         if (modifier != EXPAND_CONST_ADDRESS
   12239       643108 :             && modifier != EXPAND_INITIALIZER
   12240       643108 :             && modifier != EXPAND_MEMORY)
   12241              :           {
   12242       643003 :             tree t = fold_read_from_constant_string (exp);
   12243              : 
   12244       643003 :             if (t)
   12245            0 :               return expand_expr (t, target, tmode, modifier);
   12246              :           }
   12247              : 
   12248              :         /* If this is a constant index into a constant array,
   12249              :            just get the value from the array.  Handle both the cases when
   12250              :            we have an explicit constructor and when our operand is a variable
   12251              :            that was declared const.  */
   12252              : 
   12253       643108 :         if (modifier != EXPAND_CONST_ADDRESS
   12254              :             && modifier != EXPAND_INITIALIZER
   12255              :             && modifier != EXPAND_MEMORY
   12256       643003 :             && TREE_CODE (array) == CONSTRUCTOR
   12257            0 :             && ! TREE_SIDE_EFFECTS (array)
   12258       643108 :             && TREE_CODE (index) == INTEGER_CST)
   12259              :           {
   12260              :             unsigned HOST_WIDE_INT ix;
   12261              :             tree field, value;
   12262              : 
   12263            0 :             FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (array), ix,
   12264              :                                       field, value)
   12265            0 :               if (tree_int_cst_equal (field, index))
   12266              :                 {
   12267            0 :                   if (!TREE_SIDE_EFFECTS (value)
   12268            0 :                       && TREE_CODE (value) != RAW_DATA_CST)
   12269            0 :                     return expand_expr (fold (value), target, tmode, modifier);
   12270              :                   break;
   12271              :                 }
   12272              :           }
   12273              : 
   12274       643108 :         else if (optimize >= 1
   12275              :                  && modifier != EXPAND_CONST_ADDRESS
   12276       370544 :                  && modifier != EXPAND_INITIALIZER
   12277       370544 :                  && modifier != EXPAND_MEMORY
   12278       370443 :                  && TREE_READONLY (array) && ! TREE_SIDE_EFFECTS (array)
   12279         9542 :                  && TREE_CODE (index) == INTEGER_CST
   12280         2209 :                  && (VAR_P (array) || TREE_CODE (array) == CONST_DECL)
   12281       643213 :                  && (init = ctor_for_folding (array)) != error_mark_node)
   12282              :           {
   12283           64 :             if (init == NULL_TREE)
   12284              :               {
   12285            5 :                 tree value = build_zero_cst (type);
   12286            5 :                 if (TREE_CODE (value) == CONSTRUCTOR)
   12287              :                   {
   12288              :                     /* If VALUE is a CONSTRUCTOR, this optimization is only
   12289              :                        useful if this doesn't store the CONSTRUCTOR into
   12290              :                        memory.  If it does, it is more efficient to just
   12291              :                        load the data from the array directly.  */
   12292            5 :                     rtx ret = expand_constructor (value, target,
   12293              :                                                   modifier, true);
   12294            5 :                     if (ret == NULL_RTX)
   12295              :                       value = NULL_TREE;
   12296              :                   }
   12297              : 
   12298              :                 if (value)
   12299            0 :                   return expand_expr (value, target, tmode, modifier);
   12300              :               }
   12301           59 :             else if (TREE_CODE (init) == CONSTRUCTOR)
   12302              :               {
   12303              :                 unsigned HOST_WIDE_INT ix;
   12304              :                 tree field, value;
   12305              : 
   12306           99 :                 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (init), ix,
   12307              :                                           field, value)
   12308           97 :                   if (tree_int_cst_equal (field, index))
   12309              :                     {
   12310           56 :                       if (TREE_SIDE_EFFECTS (value)
   12311           56 :                           || TREE_CODE (value) == RAW_DATA_CST)
   12312              :                         break;
   12313              : 
   12314           56 :                       if (TREE_CODE (value) == CONSTRUCTOR)
   12315              :                         {
   12316              :                           /* If VALUE is a CONSTRUCTOR, this
   12317              :                              optimization is only useful if
   12318              :                              this doesn't store the CONSTRUCTOR
   12319              :                              into memory.  If it does, it is more
   12320              :                              efficient to just load the data from
   12321              :                              the array directly.  */
   12322           51 :                           rtx ret = expand_constructor (value, target,
   12323              :                                                         modifier, true);
   12324           51 :                           if (ret == NULL_RTX)
   12325              :                             break;
   12326              :                         }
   12327              : 
   12328           18 :                       return expand_expr (fold (value), target, tmode,
   12329           18 :                                           modifier);
   12330              :                     }
   12331              :               }
   12332            1 :             else if (TREE_CODE (init) == STRING_CST)
   12333              :               {
   12334            1 :                 tree low_bound = array_ref_low_bound (exp);
   12335            1 :                 tree index1 = fold_convert_loc (loc, sizetype, treeop1);
   12336              : 
   12337              :                 /* Optimize the special case of a zero lower bound.
   12338              : 
   12339              :                    We convert the lower bound to sizetype to avoid problems
   12340              :                    with constant folding.  E.g. suppose the lower bound is
   12341              :                    1 and its mode is QI.  Without the conversion
   12342              :                       (ARRAY + (INDEX - (unsigned char)1))
   12343              :                    becomes
   12344              :                       (ARRAY + (-(unsigned char)1) + INDEX)
   12345              :                    which becomes
   12346              :                       (ARRAY + 255 + INDEX).  Oops!  */
   12347            1 :                 if (!integer_zerop (low_bound))
   12348            0 :                   index1 = size_diffop_loc (loc, index1,
   12349              :                                             fold_convert_loc (loc, sizetype,
   12350              :                                                               low_bound));
   12351              : 
   12352            1 :                 if (tree_fits_uhwi_p (index1)
   12353            2 :                     && compare_tree_int (index1, TREE_STRING_LENGTH (init)) < 0)
   12354              :                   {
   12355            0 :                     tree char_type = TREE_TYPE (TREE_TYPE (init));
   12356            0 :                     scalar_int_mode char_mode;
   12357              : 
   12358       643090 :                     if (is_int_mode (TYPE_MODE (char_type), &char_mode)
   12359            0 :                         && GET_MODE_SIZE (char_mode) == 1)
   12360            0 :                       return gen_int_mode (TREE_STRING_POINTER (init)
   12361            0 :                                            [TREE_INT_CST_LOW (index1)],
   12362              :                                            char_mode);
   12363              :                   }
   12364              :               }
   12365              :           }
   12366              :       }
   12367       643090 :       goto normal_inner_ref;
   12368              : 
   12369      3802545 :     case COMPONENT_REF:
   12370      3802545 :       gcc_assert (TREE_CODE (treeop0) != CONSTRUCTOR);
   12371              :       /* Fall through.  */
   12372      4695478 :     case BIT_FIELD_REF:
   12373      4695478 :     case ARRAY_RANGE_REF:
   12374      3802545 :     normal_inner_ref:
   12375      4695478 :       {
   12376      4695478 :         machine_mode mode1, mode2;
   12377      4695478 :         poly_int64 bitsize, bitpos, bytepos;
   12378      4695478 :         tree offset;
   12379      4695478 :         int reversep, volatilep = 0;
   12380      4695478 :         tree tem
   12381      4695478 :           = get_inner_reference (exp, &bitsize, &bitpos, &offset, &mode1,
   12382              :                                  &unsignedp, &reversep, &volatilep);
   12383      4695478 :         rtx orig_op0, memloc;
   12384      4695478 :         bool clear_mem_expr = false;
   12385      4695478 :         bool must_force_mem;
   12386              : 
   12387              :         /* If we got back the original object, something is wrong.  Perhaps
   12388              :            we are evaluating an expression too early.  In any event, don't
   12389              :            infinitely recurse.  */
   12390      4695478 :         gcc_assert (tem != exp);
   12391              : 
   12392              :         /* Make sure bitpos is not negative, this can wreak havoc later.  */
   12393      4695478 :         if (maybe_lt (bitpos, 0))
   12394              :           {
   12395          249 :             gcc_checking_assert (offset == NULL_TREE);
   12396          249 :             offset = size_int (bits_to_bytes_round_down (bitpos));
   12397          249 :             bitpos = num_trailing_bits (bitpos);
   12398              :           }
   12399              : 
   12400              :         /* If we have either an offset, a BLKmode result, or a reference
   12401              :            outside the underlying object, we must force it to memory.
   12402              :            Such a case can occur in Ada if we have unchecked conversion
   12403              :            of an expression from a scalar type to an aggregate type or
   12404              :            for an ARRAY_RANGE_REF whose type is BLKmode, or if we were
   12405              :            passed a partially uninitialized object or a view-conversion
   12406              :            to a larger size.  */
   12407      9390956 :         must_force_mem = offset != NULL_TREE
   12408      4408115 :                          || mode1 == BLKmode
   12409      9031179 :                          || (mode == BLKmode
   12410            0 :                              && !int_mode_for_size (bitsize, 1).exists ());
   12411              : 
   12412       531041 :         const enum expand_modifier tem_modifier
   12413              :           = must_force_mem
   12414              :             ? EXPAND_MEMORY
   12415      4335701 :             : modifier == EXPAND_SUM ? EXPAND_NORMAL : modifier;
   12416              : 
   12417              :         /* If TEM's type is a union of variable size, pass TARGET to the inner
   12418              :            computation, since it will need a temporary and TARGET is known
   12419              :            to have to do.  This occurs in unchecked conversion in Ada.  */
   12420      4695478 :         const rtx tem_target
   12421      4695478 :           = TREE_CODE (TREE_TYPE (tem)) == UNION_TYPE
   12422        36803 :             && COMPLETE_TYPE_P (TREE_TYPE (tem))
   12423        36798 :             && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) != INTEGER_CST
   12424            0 :             && modifier != EXPAND_STACK_PARM
   12425      4695478 :             ? target
   12426              :             : NULL_RTX;
   12427              : 
   12428      9390956 :         orig_op0 = op0
   12429      4695478 :           = expand_expr_real (tem, tem_target, VOIDmode, tem_modifier, NULL,
   12430              :                               true);
   12431              : 
   12432              :         /* If the field has a mode, we want to access it in the
   12433              :            field's mode, not the computed mode.
   12434              :            If a MEM has VOIDmode (external with incomplete type),
   12435              :            use BLKmode for it instead.  */
   12436      4695478 :         if (MEM_P (op0))
   12437              :           {
   12438      4368429 :             if (mode1 != VOIDmode)
   12439      4210160 :               op0 = adjust_address (op0, mode1, 0);
   12440       158269 :             else if (GET_MODE (op0) == VOIDmode)
   12441            0 :               op0 = adjust_address (op0, BLKmode, 0);
   12442              :           }
   12443              : 
   12444      4695478 :         mode2
   12445      4695478 :           = CONSTANT_P (op0) ? TYPE_MODE (TREE_TYPE (tem)) : GET_MODE (op0);
   12446              : 
   12447              :         /* See above for the rationale.  */
   12448      9390956 :         if (maybe_gt (bitpos + bitsize, GET_MODE_BITSIZE (mode2)))
   12449      2989332 :           must_force_mem = true;
   12450              : 
   12451              :         /* Handle CONCAT first.  */
   12452      4695478 :         if (GET_CODE (op0) == CONCAT && !must_force_mem)
   12453              :           {
   12454          114 :             if (known_eq (bitpos, 0)
   12455          206 :                 && known_eq (bitsize, GET_MODE_BITSIZE (GET_MODE (op0)))
   12456           98 :                 && COMPLEX_MODE_P (mode1)
   12457           93 :                 && COMPLEX_MODE_P (GET_MODE (op0))
   12458          393 :                 && (GET_MODE_PRECISION (GET_MODE_INNER (mode1))
   12459          186 :                     == GET_MODE_PRECISION (GET_MODE_INNER (GET_MODE (op0)))))
   12460              :               {
   12461           93 :                 if (reversep)
   12462            0 :                   op0 = flip_storage_order (GET_MODE (op0), op0);
   12463           93 :                 if (mode1 != GET_MODE (op0))
   12464              :                   {
   12465              :                     rtx parts[2];
   12466            0 :                     for (int i = 0; i < 2; i++)
   12467              :                       {
   12468            0 :                         rtx op = read_complex_part (op0, i != 0);
   12469            0 :                         if (GET_CODE (op) == SUBREG)
   12470            0 :                           op = force_reg (GET_MODE (op), op);
   12471            0 :                         temp = gen_lowpart_common (GET_MODE_INNER (mode1), op);
   12472            0 :                         if (temp)
   12473              :                           op = temp;
   12474              :                         else
   12475              :                           {
   12476            0 :                             if (!REG_P (op) && !MEM_P (op))
   12477            0 :                               op = force_reg (GET_MODE (op), op);
   12478            0 :                             op = gen_lowpart (GET_MODE_INNER (mode1), op);
   12479              :                           }
   12480            0 :                         parts[i] = op;
   12481              :                       }
   12482            0 :                     op0 = gen_rtx_CONCAT (mode1, parts[0], parts[1]);
   12483              :                   }
   12484              :                 return op0;
   12485              :               }
   12486           21 :             if (known_eq (bitpos, 0)
   12487           20 :                 && known_eq (bitsize,
   12488              :                              GET_MODE_BITSIZE (GET_MODE (XEXP (op0, 0))))
   12489           23 :                 && maybe_ne (bitsize, 0))
   12490              :               {
   12491              :                 op0 = XEXP (op0, 0);
   12492              :                 mode2 = GET_MODE (op0);
   12493              :               }
   12494           38 :             else if (known_eq (bitpos,
   12495              :                                GET_MODE_BITSIZE (GET_MODE (XEXP (op0, 0))))
   12496            4 :                      && known_eq (bitsize,
   12497              :                                   GET_MODE_BITSIZE (GET_MODE (XEXP (op0, 1))))
   12498            0 :                      && maybe_ne (bitpos, 0)
   12499           19 :                      && maybe_ne (bitsize, 0))
   12500              :               {
   12501            0 :                 op0 = XEXP (op0, 1);
   12502            0 :                 bitpos = 0;
   12503            0 :                 mode2 = GET_MODE (op0);
   12504              :               }
   12505              :             else
   12506              :               /* Otherwise force into memory.  */
   12507              :               must_force_mem = true;
   12508              :           }
   12509              : 
   12510              :         /* If this is a constant, put it in a register if it is a legitimate
   12511              :            constant and we don't need a memory reference.  */
   12512      4695385 :         if (CONSTANT_P (op0)
   12513           33 :             && mode2 != BLKmode
   12514           33 :             && targetm.legitimate_constant_p (mode2, op0)
   12515      4695406 :             && !must_force_mem)
   12516           21 :           op0 = force_reg (mode2, op0);
   12517              : 
   12518              :         /* Otherwise, if this is a constant, try to force it to the constant
   12519              :            pool.  Note that back-ends, e.g. MIPS, may refuse to do so if it
   12520              :            is a legitimate constant.  */
   12521      4695364 :         else if (CONSTANT_P (op0) && (memloc = force_const_mem (mode2, op0)))
   12522           12 :           op0 = validize_mem (memloc);
   12523              : 
   12524              :         /* Otherwise, if this is a constant or the object is not in memory
   12525              :            and need be, put it there.  */
   12526      4695352 :         else if (CONSTANT_P (op0) || (!MEM_P (op0) && must_force_mem))
   12527              :           {
   12528         1095 :             machine_mode tem_mode = TYPE_MODE (TREE_TYPE (tem));
   12529         1095 :             poly_int64 size;
   12530         1095 :             if (!poly_int_tree_p (TYPE_SIZE_UNIT (TREE_TYPE (tem)), &size))
   12531            0 :               size = max_int_size_in_bytes (TREE_TYPE (tem));
   12532         1095 :             unsigned int align = TREE_CODE (tem) == SSA_NAME
   12533         1095 :                                  ? TYPE_ALIGN (TREE_TYPE (tem))
   12534         1095 :                                  : get_object_alignment (tem);
   12535         1095 :             if (STRICT_ALIGNMENT)
   12536              :               {
   12537              :                 /* For STRICT_ALIGNMENT targets, when we force the operand to
   12538              :                    memory, we may need to increase the alignment to meet the
   12539              :                    expectation in later RTL lowering passes.  The increased
   12540              :                    alignment is capped by MAX_SUPPORTED_STACK_ALIGNMENT.  */
   12541              :                 if (tem_mode != BLKmode)
   12542              :                   align = MAX (align, GET_MODE_ALIGNMENT (tem_mode));
   12543              :                 else
   12544              :                   align = MAX (align, TYPE_ALIGN (TREE_TYPE (tem)));
   12545              :                 align = MIN (align, (unsigned) MAX_SUPPORTED_STACK_ALIGNMENT);
   12546              :               }
   12547         1095 :             memloc = assign_stack_local (tem_mode, size, align);
   12548         1095 :             emit_move_insn (memloc, op0);
   12549         1095 :             op0 = memloc;
   12550         1095 :             clear_mem_expr = true;
   12551              :           }
   12552              : 
   12553      4695385 :         if (offset)
   12554              :           {
   12555       287363 :             machine_mode address_mode;
   12556       287363 :             rtx offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode,
   12557              :                                           EXPAND_SUM);
   12558              : 
   12559       287363 :             gcc_assert (MEM_P (op0));
   12560              : 
   12561       287363 :             address_mode = get_address_mode (op0);
   12562       287363 :             if (GET_MODE (offset_rtx) != address_mode)
   12563              :               {
   12564              :                 /* We cannot be sure that the RTL in offset_rtx is valid outside
   12565              :                    of a memory address context, so force it into a register
   12566              :                    before attempting to convert it to the desired mode.  */
   12567          424 :                 offset_rtx = force_operand (offset_rtx, NULL_RTX);
   12568          424 :                 offset_rtx = convert_to_mode (address_mode, offset_rtx, 0);
   12569              :               }
   12570              : 
   12571              :             /* See the comment in expand_assignment for the rationale.  */
   12572       287363 :             if (mode1 != VOIDmode
   12573       287147 :                 && maybe_ne (bitpos, 0)
   12574        75505 :                 && maybe_gt (bitsize, 0)
   12575       362329 :                 && multiple_p (bitpos, BITS_PER_UNIT, &bytepos)
   12576       362329 :                 && multiple_p (bitpos, bitsize)
   12577       149932 :                 && multiple_p (bitsize, GET_MODE_ALIGNMENT (mode1))
   12578       362329 :                 && MEM_ALIGN (op0) >= GET_MODE_ALIGNMENT (mode1))
   12579              :               {
   12580        74608 :                 op0 = adjust_address (op0, mode1, bytepos);
   12581        74608 :                 bitpos = 0;
   12582              :               }
   12583              : 
   12584       287363 :             op0 = offset_address (op0, offset_rtx,
   12585              :                                   highest_pow2_factor (offset));
   12586              :           }
   12587              : 
   12588              :         /* If OFFSET is making OP0 more aligned than BIGGEST_ALIGNMENT,
   12589              :            record its alignment as BIGGEST_ALIGNMENT.  */
   12590      4695385 :         if (MEM_P (op0)
   12591      4369536 :             && known_eq (bitpos, 0)
   12592      1466277 :             && offset != 0
   12593      4981701 :             && is_aligning_offset (offset, tem))
   12594            0 :           set_mem_align (op0, BIGGEST_ALIGNMENT);
   12595              : 
   12596              :         /* Don't forget about volatility even if this is a bitfield.  */
   12597      4695385 :         if (MEM_P (op0) && volatilep && ! MEM_VOLATILE_P (op0))
   12598              :           {
   12599          514 :             if (op0 == orig_op0)
   12600          158 :               op0 = copy_rtx (op0);
   12601              : 
   12602          514 :             MEM_VOLATILE_P (op0) = 1;
   12603              :           }
   12604              : 
   12605      4695385 :         if (MEM_P (op0) && TREE_CODE (tem) == FUNCTION_DECL)
   12606              :           {
   12607            6 :             if (op0 == orig_op0)
   12608            0 :               op0 = copy_rtx (op0);
   12609              : 
   12610            6 :             set_mem_align (op0, BITS_PER_UNIT);
   12611              :           }
   12612              : 
   12613              :         /* In cases where an aligned union has an unaligned object
   12614              :            as a field, we might be extracting a BLKmode value from
   12615              :            an integer-mode (e.g., SImode) object.  Handle this case
   12616              :            by doing the extract into an object as wide as the field
   12617              :            (which we know to be the width of a basic mode), then
   12618              :            storing into memory, and changing the mode to BLKmode.  */
   12619      4695385 :         if (mode1 == VOIDmode
   12620      4461995 :             || REG_P (op0) || GET_CODE (op0) == SUBREG
   12621      4211233 :             || (mode1 != BLKmode && ! direct_load[(int) mode1]
   12622        26765 :                 && GET_MODE_CLASS (mode) != MODE_COMPLEX_INT
   12623        22582 :                 && GET_MODE_CLASS (mode) != MODE_COMPLEX_FLOAT
   12624              :                 && modifier != EXPAND_CONST_ADDRESS
   12625        15389 :                 && modifier != EXPAND_INITIALIZER
   12626        15389 :                 && modifier != EXPAND_MEMORY)
   12627              :             /* If the bitfield is volatile and the bitsize
   12628              :                is narrower than the access size of the bitfield,
   12629              :                we need to extract bitfields from the access.  */
   12630      4195844 :             || (volatilep && TREE_CODE (exp) == COMPONENT_REF
   12631         1497 :                 && DECL_BIT_FIELD_TYPE (TREE_OPERAND (exp, 1))
   12632           10 :                 && mode1 != BLKmode
   12633           20 :                 && maybe_lt (bitsize, GET_MODE_SIZE (mode1) * BITS_PER_UNIT))
   12634              :             /* If the field isn't aligned enough to fetch as a memref,
   12635              :                fetch it as a bit field.  */
   12636      4195835 :             || (mode1 != BLKmode
   12637      4122534 :                 && (((MEM_P (op0)
   12638      4122534 :                       ? MEM_ALIGN (op0) < GET_MODE_ALIGNMENT (mode1)
   12639      8099609 :                         || !multiple_p (bitpos, GET_MODE_ALIGNMENT (mode1))
   12640            0 :                       : TYPE_ALIGN (TREE_TYPE (tem)) < GET_MODE_ALIGNMENT (mode)
   12641            0 :                         || !multiple_p (bitpos, GET_MODE_ALIGNMENT (mode)))
   12642        76000 :                      && modifier != EXPAND_MEMORY
   12643        76000 :                      && ((modifier == EXPAND_CONST_ADDRESS
   12644        76000 :                           || modifier == EXPAND_INITIALIZER)
   12645        76000 :                          ? STRICT_ALIGNMENT
   12646        76000 :                          : targetm.slow_unaligned_access (mode1,
   12647        76000 :                                                           MEM_ALIGN (op0))))
   12648      4122534 :                     || !multiple_p (bitpos, BITS_PER_UNIT)))
   12649              :             /* If the type and the field are a constant size and the
   12650              :                size of the type isn't the same size as the bitfield,
   12651              :                we must use bitfield operations.  */
   12652     13013754 :             || (known_size_p (bitsize)
   12653      4195835 :                 && TYPE_SIZE (TREE_TYPE (exp))
   12654      4195835 :                 && poly_int_tree_p (TYPE_SIZE (TREE_TYPE (exp)))
   12655      4695385 :                 && maybe_ne (wi::to_poly_offset (TYPE_SIZE (TREE_TYPE (exp))),
   12656              :                              bitsize)))
   12657              :           {
   12658       499588 :             machine_mode ext_mode = mode;
   12659              : 
   12660       499588 :             if (ext_mode == BLKmode
   12661       499588 :                 && ! (target != 0 && MEM_P (op0)
   12662           22 :                       && MEM_P (target)
   12663           22 :                       && multiple_p (bitpos, BITS_PER_UNIT)))
   12664           12 :               ext_mode = int_mode_for_size (bitsize, 1).else_blk ();
   12665              : 
   12666       499588 :             if (ext_mode == BLKmode)
   12667              :               {
   12668           34 :                 if (target == 0)
   12669           12 :                   target = assign_temp (type, 1, 1);
   12670              : 
   12671              :                 /* ??? Unlike the similar test a few lines below, this one is
   12672              :                    very likely obsolete.  */
   12673           34 :                 if (known_eq (bitsize, 0))
   12674              :                   return target;
   12675              : 
   12676              :                 /* In this case, BITPOS must start at a byte boundary and
   12677              :                    TARGET, if specified, must be a MEM.  */
   12678           34 :                 gcc_assert (MEM_P (op0)
   12679              :                             && (!target || MEM_P (target)));
   12680              : 
   12681           34 :                 bytepos = exact_div (bitpos, BITS_PER_UNIT);
   12682           34 :                 poly_int64 bytesize = bits_to_bytes_round_up (bitsize);
   12683           68 :                 emit_block_move (target,
   12684              :                                  adjust_address (op0, VOIDmode, bytepos),
   12685           34 :                                  gen_int_mode (bytesize, Pmode),
   12686              :                                  (modifier == EXPAND_STACK_PARM
   12687              :                                   ? BLOCK_OP_CALL_PARM : BLOCK_OP_NORMAL));
   12688              : 
   12689           34 :                 return target;
   12690              :               }
   12691              : 
   12692              :             /* If we have nothing to extract, the result will be 0 for targets
   12693              :                with SHIFT_COUNT_TRUNCATED == 0 and garbage otherwise.  Always
   12694              :                return 0 for the sake of consistency, as reading a zero-sized
   12695              :                bitfield is valid in Ada and the value is fully specified.  */
   12696       499554 :             if (known_eq (bitsize, 0))
   12697            0 :               return const0_rtx;
   12698              : 
   12699       499554 :             op0 = validize_mem (op0);
   12700              : 
   12701       499554 :             if (MEM_P (op0) && REG_P (XEXP (op0, 0)))
   12702        49977 :               mark_reg_pointer (XEXP (op0, 0), MEM_ALIGN (op0));
   12703              : 
   12704              :             /* If the result has aggregate type and the extraction is done in
   12705              :                an integral mode, then the field may be not aligned on a byte
   12706              :                boundary; in this case, if it has reverse storage order, it
   12707              :                needs to be extracted as a scalar field with reverse storage
   12708              :                order and put back into memory order afterwards.  */
   12709       499554 :             if (AGGREGATE_TYPE_P (type)
   12710         5979 :                 && GET_MODE_CLASS (ext_mode) == MODE_INT)
   12711         5897 :               reversep = TYPE_REVERSE_STORAGE_ORDER (type);
   12712              : 
   12713       499554 :             gcc_checking_assert (known_ge (bitpos, 0));
   12714      1005539 :             op0 = extract_bit_field (op0, bitsize, bitpos, unsignedp,
   12715              :                                      (modifier == EXPAND_STACK_PARM
   12716              :                                       ? NULL_RTX : target),
   12717              :                                      ext_mode, ext_mode, reversep, alt_rtl);
   12718              : 
   12719              :             /* If the result has aggregate type and the mode of OP0 is an
   12720              :                integral mode then, if BITSIZE is narrower than this mode
   12721              :                and this is for big-endian data, we must put the field
   12722              :                into the high-order bits.  And we must also put it back
   12723              :                into memory order if it has been previously reversed.  */
   12724       499554 :             scalar_int_mode op0_mode;
   12725       499554 :             if (AGGREGATE_TYPE_P (type)
   12726       499554 :                 && is_int_mode (GET_MODE (op0), &op0_mode))
   12727              :               {
   12728         5897 :                 HOST_WIDE_INT size = GET_MODE_BITSIZE (op0_mode);
   12729              : 
   12730         5897 :                 gcc_checking_assert (known_le (bitsize, size));
   12731         5897 :                 if (maybe_lt (bitsize, size)
   12732         5897 :                     && reversep ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN)
   12733            0 :                   op0 = expand_shift (LSHIFT_EXPR, op0_mode, op0,
   12734              :                                       size - bitsize, op0, 1);
   12735              : 
   12736         5897 :                 if (reversep)
   12737            0 :                   op0 = flip_storage_order (op0_mode, op0);
   12738              :               }
   12739              : 
   12740              :             /* If the result type is BLKmode, store the data into a temporary
   12741              :                of the appropriate type, but with the mode corresponding to the
   12742              :                mode for the data we have (op0's mode).  */
   12743       499554 :             if (mode == BLKmode)
   12744              :               {
   12745            0 :                 rtx new_rtx
   12746            0 :                   = assign_stack_temp_for_type (ext_mode,
   12747            0 :                                                 GET_MODE_BITSIZE (ext_mode),
   12748              :                                                 type);
   12749            0 :                 emit_move_insn (new_rtx, op0);
   12750            0 :                 op0 = copy_rtx (new_rtx);
   12751            0 :                 PUT_MODE (op0, BLKmode);
   12752              :               }
   12753              : 
   12754              :             return op0;
   12755              :           }
   12756              : 
   12757              :         /* If the result is BLKmode, use that to access the object
   12758              :            now as well.  */
   12759      4195797 :         if (mode == BLKmode)
   12760        73267 :           mode1 = BLKmode;
   12761              : 
   12762              :         /* Get a reference to just this component.  */
   12763      4195797 :         bytepos = bits_to_bytes_round_down (bitpos);
   12764      4195797 :         if (modifier == EXPAND_CONST_ADDRESS
   12765      4195797 :             || modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
   12766       162099 :           op0 = adjust_address_nv (op0, mode1, bytepos);
   12767              :         else
   12768      4033698 :           op0 = adjust_address (op0, mode1, bytepos);
   12769              : 
   12770      4195797 :         if (op0 == orig_op0)
   12771       129676 :           op0 = copy_rtx (op0);
   12772              : 
   12773              :         /* Don't set memory attributes if the base expression is
   12774              :            SSA_NAME that got expanded as a MEM or a CONSTANT.  In that case,
   12775              :            we should just honor its original memory attributes.  */
   12776      4195797 :         if (!(TREE_CODE (tem) == SSA_NAME
   12777        11001 :               && (MEM_P (orig_op0) || CONSTANT_P (orig_op0))))
   12778      4184796 :           set_mem_attributes (op0, exp, 0, may_store_p);
   12779              : 
   12780      4195797 :         if (REG_P (XEXP (op0, 0)))
   12781       672065 :           mark_reg_pointer (XEXP (op0, 0), MEM_ALIGN (op0));
   12782              : 
   12783              :         /* If op0 is a temporary because the original expressions was forced
   12784              :            to memory, clear MEM_EXPR so that the original expression cannot
   12785              :            be marked as addressable through MEM_EXPR of the temporary.  */
   12786      4195797 :         if (clear_mem_expr)
   12787         1061 :           set_mem_expr (op0, NULL_TREE);
   12788              : 
   12789      4195797 :         MEM_VOLATILE_P (op0) |= volatilep;
   12790              : 
   12791      4195797 :         if (reversep
   12792              :             && modifier != EXPAND_MEMORY
   12793          507 :             && modifier != EXPAND_WRITE)
   12794          507 :           op0 = flip_storage_order (mode1, op0);
   12795              : 
   12796      4195797 :         op0 = EXTEND_BITINT (op0);
   12797              : 
   12798      4195797 :         if (mode == mode1 || mode1 == BLKmode || mode1 == tmode
   12799              :             || modifier == EXPAND_CONST_ADDRESS
   12800            0 :             || modifier == EXPAND_INITIALIZER)
   12801              :           return op0;
   12802              : 
   12803            0 :         if (target == 0)
   12804            0 :           target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
   12805              : 
   12806            0 :         convert_move (target, op0, unsignedp);
   12807            0 :         return target;
   12808              :       }
   12809              : 
   12810        81924 :     case OBJ_TYPE_REF:
   12811        81924 :       return expand_expr (OBJ_TYPE_REF_EXPR (exp), target, tmode, modifier);
   12812              : 
   12813      6875952 :     case CALL_EXPR:
   12814              :       /* All valid uses of __builtin_va_arg_pack () are removed during
   12815              :          inlining.  */
   12816      6875952 :       if (CALL_EXPR_VA_ARG_PACK (exp))
   12817            6 :         error ("invalid use of %<__builtin_va_arg_pack ()%>");
   12818      6875952 :       {
   12819      6875952 :         tree fndecl = get_callee_fndecl (exp), attr;
   12820              : 
   12821      6875952 :         if (fndecl
   12822              :             /* Don't diagnose the error attribute in thunks, those are
   12823              :                artificially created.  */
   12824      6687960 :             && !CALL_FROM_THUNK_P (exp)
   12825     13560229 :             && (attr = lookup_attribute ("error",
   12826      6684277 :                                          DECL_ATTRIBUTES (fndecl))) != NULL)
   12827              :           {
   12828            5 :             const char *ident = lang_hooks.decl_printable_name (fndecl, 1);
   12829           10 :             error ("call to %qs declared with attribute error: %s",
   12830              :                    identifier_to_locale (ident),
   12831            5 :                    TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
   12832              :           }
   12833      6875952 :         if (fndecl
   12834              :             /* Don't diagnose the warning attribute in thunks, those are
   12835              :                artificially created.  */
   12836      6687960 :             && !CALL_FROM_THUNK_P (exp)
   12837     13560229 :             && (attr = lookup_attribute ("warning",
   12838      6684277 :                                          DECL_ATTRIBUTES (fndecl))) != NULL)
   12839              :           {
   12840           21 :             const char *ident = lang_hooks.decl_printable_name (fndecl, 1);
   12841           42 :             warning_at (EXPR_LOCATION (exp),
   12842           21 :                         OPT_Wattribute_warning,
   12843              :                         "call to %qs declared with attribute warning: %s",
   12844              :                         identifier_to_locale (ident),
   12845           21 :                         TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
   12846              :           }
   12847              : 
   12848              :         /* Check for a built-in function.  */
   12849      6875952 :         if (fndecl && fndecl_built_in_p (fndecl))
   12850              :           {
   12851      2053834 :             gcc_assert (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_FRONTEND);
   12852      2053834 :             return expand_builtin (exp, target, subtarget, tmode, ignore);
   12853              :           }
   12854              :       }
   12855      4822118 :       temp = expand_call (exp, target, ignore);
   12856      4822116 :       return EXTEND_BITINT (temp);
   12857              : 
   12858       351102 :     case VIEW_CONVERT_EXPR:
   12859       351102 :       op0 = NULL_RTX;
   12860              : 
   12861              :       /* If we are converting to BLKmode, try to avoid an intermediate
   12862              :          temporary by fetching an inner memory reference.  */
   12863       351102 :       if (mode == BLKmode
   12864        74282 :           && poly_int_tree_p (TYPE_SIZE (type))
   12865        74282 :           && TYPE_MODE (TREE_TYPE (treeop0)) != BLKmode
   12866       351102 :           && handled_component_p (treeop0))
   12867              :       {
   12868            0 :         machine_mode mode1;
   12869            0 :         poly_int64 bitsize, bitpos, bytepos;
   12870            0 :         tree offset;
   12871            0 :         int reversep, volatilep = 0;
   12872            0 :         tree tem
   12873            0 :           = get_inner_reference (treeop0, &bitsize, &bitpos, &offset, &mode1,
   12874              :                                  &unsignedp, &reversep, &volatilep);
   12875              : 
   12876              :         /* ??? We should work harder and deal with non-zero offsets.  */
   12877            0 :         if (!offset
   12878            0 :             && multiple_p (bitpos, BITS_PER_UNIT, &bytepos)
   12879            0 :             && !reversep
   12880            0 :             && known_size_p (bitsize)
   12881            0 :             && known_eq (wi::to_poly_offset (TYPE_SIZE (type)), bitsize))
   12882              :           {
   12883              :             /* See the normal_inner_ref case for the rationale.  */
   12884            0 :             rtx orig_op0
   12885            0 :               = expand_expr_real (tem,
   12886            0 :                                   (TREE_CODE (TREE_TYPE (tem)) == UNION_TYPE
   12887            0 :                                    && (TREE_CODE (TYPE_SIZE (TREE_TYPE (tem)))
   12888              :                                        != INTEGER_CST)
   12889            0 :                                    && modifier != EXPAND_STACK_PARM
   12890              :                                    ? target : NULL_RTX),
   12891              :                                   VOIDmode,
   12892              :                                   modifier == EXPAND_SUM ? EXPAND_NORMAL : modifier,
   12893              :                                   NULL, true);
   12894              : 
   12895            0 :             if (MEM_P (orig_op0))
   12896              :               {
   12897            0 :                 op0 = orig_op0;
   12898              : 
   12899              :                 /* Get a reference to just this component.  */
   12900            0 :                 if (modifier == EXPAND_CONST_ADDRESS
   12901              :                     || modifier == EXPAND_SUM
   12902            0 :                     || modifier == EXPAND_INITIALIZER)
   12903            0 :                   op0 = adjust_address_nv (op0, mode, bytepos);
   12904              :                 else
   12905            0 :                   op0 = adjust_address (op0, mode, bytepos);
   12906              : 
   12907            0 :                 if (op0 == orig_op0)
   12908            0 :                   op0 = copy_rtx (op0);
   12909              : 
   12910            0 :                 set_mem_attributes (op0, treeop0, 0, may_store_p);
   12911            0 :                 if (REG_P (XEXP (op0, 0)))
   12912            0 :                   mark_reg_pointer (XEXP (op0, 0), MEM_ALIGN (op0));
   12913              : 
   12914            0 :                 MEM_VOLATILE_P (op0) |= volatilep;
   12915              :               }
   12916              :           }
   12917              :       }
   12918              : 
   12919            0 :       if (!op0)
   12920       425395 :         op0 = expand_expr_real (treeop0, NULL_RTX, VOIDmode, modifier,
   12921              :                                 NULL, inner_reference_p || mode == BLKmode);
   12922              : 
   12923              :       /* If the input and output modes are both the same, we are done.  */
   12924       351102 :       if (mode == GET_MODE (op0))
   12925              :         ;
   12926              :       /* Similarly if the output mode is BLKmode and input is a MEM,
   12927              :          adjust_address done below is all we need.  */
   12928       153810 :       else if (mode == BLKmode && MEM_P (op0))
   12929              :         ;
   12930              :       /* If neither mode is BLKmode, and both modes are the same size
   12931              :          then we can use gen_lowpart.  */
   12932              :       else if (mode != BLKmode
   12933       153776 :                && GET_MODE (op0) != BLKmode
   12934       152415 :                && known_eq (GET_MODE_PRECISION (mode),
   12935              :                             GET_MODE_PRECISION (GET_MODE (op0)))
   12936       148516 :                && !COMPLEX_MODE_P (GET_MODE (op0)))
   12937              :         {
   12938       147063 :           if (GET_CODE (op0) == SUBREG)
   12939          159 :             op0 = force_reg (GET_MODE (op0), op0);
   12940       147063 :           temp = gen_lowpart_common (mode, op0);
   12941       147063 :           if (temp)
   12942              :             op0 = temp;
   12943              :           else
   12944              :             {
   12945        28508 :               if (!REG_P (op0) && !MEM_P (op0))
   12946           18 :                 op0 = force_reg (GET_MODE (op0), op0);
   12947        28508 :               op0 = gen_lowpart (mode, op0);
   12948              :             }
   12949              :         }
   12950              :       /* If both types are integral, convert from one mode to the other.  */
   12951         6745 :       else if (INTEGRAL_TYPE_P (type)
   12952         3155 :                && INTEGRAL_TYPE_P (TREE_TYPE (treeop0))
   12953            0 :                && mode != BLKmode
   12954         6745 :                && GET_MODE (op0) != BLKmode)
   12955            0 :         op0 = convert_modes (mode, GET_MODE (op0), op0,
   12956            0 :                              TYPE_UNSIGNED (TREE_TYPE (treeop0)));
   12957              :       /* If the output type is a bit-field type, do an extraction.  */
   12958         6745 :       else if (reduce_bit_field
   12959            2 :                && mode != BLKmode
   12960            2 :                && (MEM_P (op0) || !COMPLEX_MODE_P (GET_MODE (op0))))
   12961            0 :         return extract_bit_field (op0, TYPE_PRECISION (type), 0,
   12962            0 :                                   TYPE_UNSIGNED (type), NULL_RTX,
   12963              :                                   mode, mode, false, NULL);
   12964              :       /* If source is a complex number and destination is a
   12965              :          two-component vector with same inner type, try to use
   12966              :          vector initialization.  */
   12967         6745 :       else if ((temp = try_expand_complex_as_vector (mode, op0, target))
   12968              :                != NULL_RTX)
   12969              :         return temp;
   12970              :       /* As a last resort, spill op0 to memory, and reload it in a
   12971              :          different mode.  */
   12972         6724 :       else if (!MEM_P (op0))
   12973              :         {
   12974              :           /* If the operand is not a MEM, force it into memory.  Since we
   12975              :              are going to be changing the mode of the MEM, don't call
   12976              :              force_const_mem for constants because we don't allow pool
   12977              :              constants to change mode.  */
   12978         5350 :           tree inner_type = TREE_TYPE (treeop0);
   12979              : 
   12980         5350 :           gcc_assert (!TREE_ADDRESSABLE (exp));
   12981              : 
   12982         5350 :           if (target == 0 || GET_MODE (target) != TYPE_MODE (inner_type))
   12983         5346 :             target
   12984              :               = assign_stack_temp_for_type
   12985         5346 :                 (TYPE_MODE (inner_type),
   12986        10692 :                  GET_MODE_SIZE (TYPE_MODE (inner_type)), inner_type);
   12987              : 
   12988         5350 :           emit_move_insn (target, op0);
   12989         5350 :           op0 = target;
   12990              : 
   12991         5350 :           if (reduce_bit_field && mode != BLKmode)
   12992            2 :             return extract_bit_field (op0, TYPE_PRECISION (type), 0,
   12993            2 :                                       TYPE_UNSIGNED (type), NULL_RTX,
   12994              :                                       mode, mode, false, NULL);
   12995              :         }
   12996              : 
   12997              :       /* If OP0 is (now) a MEM, we need to deal with alignment issues.  If the
   12998              :          output type is such that the operand is known to be aligned, indicate
   12999              :          that it is.  Otherwise, we need only be concerned about alignment for
   13000              :          non-BLKmode results.  */
   13001       351079 :       if (MEM_P (op0))
   13002              :         {
   13003       129458 :           enum insn_code icode;
   13004              : 
   13005       129458 :           if (modifier != EXPAND_WRITE
   13006       129458 :               && modifier != EXPAND_MEMORY
   13007       129458 :               && !inner_reference_p
   13008       129457 :               && mode != BLKmode
   13009       184633 :               && MEM_ALIGN (op0) < GET_MODE_ALIGNMENT (mode))
   13010              :             {
   13011              :               /* If the target does have special handling for unaligned
   13012              :                  loads of mode then use them.  */
   13013        15834 :               if ((icode = optab_handler (movmisalign_optab, mode))
   13014              :                   != CODE_FOR_nothing)
   13015              :                 {
   13016         1878 :                   rtx reg;
   13017              : 
   13018         1878 :                   op0 = adjust_address (op0, mode, 0);
   13019              :                   /* We've already validated the memory, and we're creating a
   13020              :                      new pseudo destination.  The predicates really can't
   13021              :                      fail.  */
   13022         1878 :                   reg = gen_reg_rtx (mode);
   13023              : 
   13024              :                   /* Nor can the insn generator.  */
   13025         1878 :                   rtx_insn *insn = GEN_FCN (icode) (reg, op0);
   13026         1878 :                   emit_insn (insn);
   13027         1878 :                   return reg;
   13028              :                 }
   13029              :               else if (STRICT_ALIGNMENT)
   13030              :                 {
   13031              :                   poly_uint64 mode_size = GET_MODE_SIZE (mode);
   13032              :                   poly_uint64 temp_size = mode_size;
   13033              :                   if (GET_MODE (op0) != BLKmode)
   13034              :                     temp_size = upper_bound (temp_size,
   13035              :                                              GET_MODE_SIZE (GET_MODE (op0)));
   13036              :                   rtx new_rtx
   13037              :                     = assign_stack_temp_for_type (mode, temp_size, type);
   13038              :                   rtx new_with_op0_mode
   13039              :                     = adjust_address (new_rtx, GET_MODE (op0), 0);
   13040              : 
   13041              :                   gcc_assert (!TREE_ADDRESSABLE (exp));
   13042              : 
   13043              :                   if (GET_MODE (op0) == BLKmode)
   13044              :                     {
   13045              :                       rtx size_rtx = gen_int_mode (mode_size, Pmode);
   13046              :                       emit_block_move (new_with_op0_mode, op0, size_rtx,
   13047              :                                        (modifier == EXPAND_STACK_PARM
   13048              :                                         ? BLOCK_OP_CALL_PARM
   13049              :                                         : BLOCK_OP_NORMAL));
   13050              :                     }
   13051              :                   else
   13052              :                     emit_move_insn (new_with_op0_mode, op0);
   13053              : 
   13054              :                   op0 = new_rtx;
   13055              :                 }
   13056              :             }
   13057              : 
   13058       127580 :           op0 = adjust_address (op0, mode, 0);
   13059              :         }
   13060              : 
   13061              :       return op0;
   13062              : 
   13063        63777 :     case MODIFY_EXPR:
   13064        63777 :       {
   13065        63777 :         tree lhs = treeop0;
   13066        63777 :         tree rhs = treeop1;
   13067        63777 :         gcc_assert (ignore);
   13068              : 
   13069              :         /* Check for |= or &= of a bitfield of size one into another bitfield
   13070              :            of size 1.  In this case, (unless we need the result of the
   13071              :            assignment) we can do this more efficiently with a
   13072              :            test followed by an assignment, if necessary.
   13073              : 
   13074              :            ??? At this point, we can't get a BIT_FIELD_REF here.  But if
   13075              :            things change so we do, this code should be enhanced to
   13076              :            support it.  */
   13077        63777 :         if (TREE_CODE (lhs) == COMPONENT_REF
   13078        60635 :             && (TREE_CODE (rhs) == BIT_IOR_EXPR
   13079        60635 :                 || TREE_CODE (rhs) == BIT_AND_EXPR)
   13080            0 :             && TREE_OPERAND (rhs, 0) == lhs
   13081            0 :             && TREE_CODE (TREE_OPERAND (rhs, 1)) == COMPONENT_REF
   13082            0 :             && integer_onep (DECL_SIZE (TREE_OPERAND (lhs, 1)))
   13083        63777 :             && integer_onep (DECL_SIZE (TREE_OPERAND (TREE_OPERAND (rhs, 1), 1))))
   13084              :           {
   13085            0 :             rtx_code_label *label = gen_label_rtx ();
   13086            0 :             int value = TREE_CODE (rhs) == BIT_IOR_EXPR;
   13087            0 :             profile_probability prob = profile_probability::uninitialized ();
   13088            0 :             if (value)
   13089            0 :               jumpifnot (TREE_OPERAND (rhs, 1), label, prob);
   13090              :             else
   13091            0 :               jumpif (TREE_OPERAND (rhs, 1), label, prob);
   13092            0 :             expand_assignment (lhs, build_int_cst (TREE_TYPE (rhs), value),
   13093              :                                false);
   13094            0 :             do_pending_stack_adjust ();
   13095            0 :             emit_label (label);
   13096            0 :             return const0_rtx;
   13097              :           }
   13098              : 
   13099        63777 :         expand_assignment (lhs, rhs, false);
   13100        63777 :         return const0_rtx;
   13101              :       }
   13102              : 
   13103     13326090 :     case ADDR_EXPR:
   13104     13326090 :       return expand_expr_addr_expr (exp, target, tmode, modifier);
   13105              : 
   13106       177388 :     case REALPART_EXPR:
   13107       177388 :       op0 = expand_normal (treeop0);
   13108       177388 :       return read_complex_part (op0, false);
   13109              : 
   13110       200833 :     case IMAGPART_EXPR:
   13111       200833 :       op0 = expand_normal (treeop0);
   13112       200833 :       return read_complex_part (op0, true);
   13113              : 
   13114            0 :     case RETURN_EXPR:
   13115            0 :     case LABEL_EXPR:
   13116            0 :     case GOTO_EXPR:
   13117            0 :     case SWITCH_EXPR:
   13118            0 :     case ASM_EXPR:
   13119              :       /* Expanded in cfgexpand.cc.  */
   13120            0 :       gcc_unreachable ();
   13121              : 
   13122            0 :     case TRY_CATCH_EXPR:
   13123            0 :     case CATCH_EXPR:
   13124            0 :     case EH_FILTER_EXPR:
   13125            0 :     case TRY_FINALLY_EXPR:
   13126            0 :     case EH_ELSE_EXPR:
   13127              :       /* Lowered by tree-eh.cc.  */
   13128            0 :       gcc_unreachable ();
   13129              : 
   13130            0 :     case WITH_CLEANUP_EXPR:
   13131            0 :     case CLEANUP_POINT_EXPR:
   13132            0 :     case TARGET_EXPR:
   13133            0 :     case CASE_LABEL_EXPR:
   13134            0 :     case VA_ARG_EXPR:
   13135            0 :     case BIND_EXPR:
   13136            0 :     case INIT_EXPR:
   13137            0 :     case CONJ_EXPR:
   13138            0 :     case COMPOUND_EXPR:
   13139            0 :     case PREINCREMENT_EXPR:
   13140            0 :     case PREDECREMENT_EXPR:
   13141            0 :     case POSTINCREMENT_EXPR:
   13142            0 :     case POSTDECREMENT_EXPR:
   13143            0 :     case LOOP_EXPR:
   13144            0 :     case EXIT_EXPR:
   13145            0 :     case COMPOUND_LITERAL_EXPR:
   13146              :       /* Lowered by gimplify.cc.  */
   13147            0 :       gcc_unreachable ();
   13148              : 
   13149            0 :     case FDESC_EXPR:
   13150              :       /* Function descriptors are not valid except for as
   13151              :          initialization constants, and should not be expanded.  */
   13152            0 :       gcc_unreachable ();
   13153              : 
   13154          258 :     case WITH_SIZE_EXPR:
   13155              :       /* WITH_SIZE_EXPR expands to its first argument.  The caller should
   13156              :          have pulled out the size to use in whatever context it needed.  */
   13157          258 :       return expand_expr_real (treeop0, original_target, tmode,
   13158          258 :                                modifier, alt_rtl, inner_reference_p);
   13159              : 
   13160      1885194 :     default:
   13161      1885194 :       return expand_expr_real_2 (&ops, target, tmode, modifier);
   13162              :     }
   13163              : }
   13164              : #undef EXTEND_BITINT
   13165              : 
   13166              : /* Subroutine of above: reduce EXP to the precision of TYPE (in the
   13167              :    signedness of TYPE), possibly returning the result in TARGET.
   13168              :    TYPE is known to be a partial integer type.  */
   13169              : static rtx
   13170        91544 : reduce_to_bit_field_precision (rtx exp, rtx target, tree type)
   13171              : {
   13172        91544 :   scalar_int_mode mode = SCALAR_INT_TYPE_MODE (type);
   13173        91544 :   HOST_WIDE_INT prec = TYPE_PRECISION (type);
   13174        91544 :   gcc_assert ((GET_MODE (exp) == VOIDmode || GET_MODE (exp) == mode)
   13175              :               && (!target || GET_MODE (target) == mode));
   13176              : 
   13177              :   /* For constant values, reduce using wide_int_to_tree. */
   13178        91544 :   if (poly_int_rtx_p (exp))
   13179              :     {
   13180            0 :       auto value = wi::to_poly_wide (exp, mode);
   13181            0 :       tree t = wide_int_to_tree (type, value);
   13182            0 :       return expand_expr (t, target, VOIDmode, EXPAND_NORMAL);
   13183              :     }
   13184        91544 :   else if (TYPE_UNSIGNED (type))
   13185              :     {
   13186        72002 :       rtx mask = immed_wide_int_const
   13187        72002 :         (wi::mask (prec, false, GET_MODE_PRECISION (mode)), mode);
   13188        72002 :       return expand_and (mode, exp, mask, target);
   13189              :     }
   13190              :   else
   13191              :     {
   13192        19542 :       int count = GET_MODE_PRECISION (mode) - prec;
   13193        19542 :       exp = expand_shift (LSHIFT_EXPR, mode, exp, count, target, 0);
   13194        19542 :       return expand_shift (RSHIFT_EXPR, mode, exp, count, target, 0);
   13195              :     }
   13196              : }
   13197              : 
   13198              : /* Subroutine of above: returns true if OFFSET corresponds to an offset that
   13199              :    when applied to the address of EXP produces an address known to be
   13200              :    aligned more than BIGGEST_ALIGNMENT.  */
   13201              : 
   13202              : static bool
   13203       286316 : is_aligning_offset (const_tree offset, const_tree exp)
   13204              : {
   13205              :   /* Strip off any conversions.  */
   13206       306732 :   while (CONVERT_EXPR_P (offset))
   13207        20416 :     offset = TREE_OPERAND (offset, 0);
   13208              : 
   13209              :   /* We must now have a BIT_AND_EXPR with a constant that is one less than
   13210              :      power of 2 and which is larger than BIGGEST_ALIGNMENT.  */
   13211       286316 :   if (TREE_CODE (offset) != BIT_AND_EXPR
   13212            0 :       || !tree_fits_uhwi_p (TREE_OPERAND (offset, 1))
   13213            0 :       || compare_tree_int (TREE_OPERAND (offset, 1),
   13214            0 :                            BIGGEST_ALIGNMENT / BITS_PER_UNIT) <= 0
   13215       286316 :       || !pow2p_hwi (tree_to_uhwi (TREE_OPERAND (offset, 1)) + 1))
   13216              :     return false;
   13217              : 
   13218              :   /* Look at the first operand of BIT_AND_EXPR and strip any conversion.
   13219              :      It must be NEGATE_EXPR.  Then strip any more conversions.  */
   13220            0 :   offset = TREE_OPERAND (offset, 0);
   13221            0 :   while (CONVERT_EXPR_P (offset))
   13222            0 :     offset = TREE_OPERAND (offset, 0);
   13223              : 
   13224            0 :   if (TREE_CODE (offset) != NEGATE_EXPR)
   13225              :     return false;
   13226              : 
   13227            0 :   offset = TREE_OPERAND (offset, 0);
   13228            0 :   while (CONVERT_EXPR_P (offset))
   13229            0 :     offset = TREE_OPERAND (offset, 0);
   13230              : 
   13231              :   /* This must now be the address of EXP.  */
   13232            0 :   return TREE_CODE (offset) == ADDR_EXPR && TREE_OPERAND (offset, 0) == exp;
   13233              : }
   13234              : 
   13235              : /* Return a STRING_CST corresponding to ARG's constant initializer either
   13236              :    if it's a string constant, or, when VALREP is set, any other constant,
   13237              :    or null otherwise.
   13238              :    On success, set *PTR_OFFSET to the (possibly non-constant) byte offset
   13239              :    within the byte string that ARG is references.  If nonnull set *MEM_SIZE
   13240              :    to the size of the byte string.  If nonnull, set *DECL to the constant
   13241              :    declaration ARG refers to.  */
   13242              : 
   13243              : static tree
   13244     15801261 : constant_byte_string (tree arg, tree *ptr_offset, tree *mem_size, tree *decl,
   13245              :                       bool valrep = false)
   13246              : {
   13247     15801261 :   tree dummy = NULL_TREE;
   13248     15801261 :   if (!mem_size)
   13249        11244 :     mem_size = &dummy;
   13250              : 
   13251              :   /* Store the type of the original expression before conversions
   13252              :      via NOP_EXPR or POINTER_PLUS_EXPR to other types have been
   13253              :      removed.  */
   13254     15801261 :   tree argtype = TREE_TYPE (arg);
   13255              : 
   13256     15801261 :   tree array;
   13257     15801261 :   STRIP_NOPS (arg);
   13258              : 
   13259              :   /* Non-constant index into the character array in an ARRAY_REF
   13260              :      expression or null.  */
   13261     15801261 :   tree varidx = NULL_TREE;
   13262              : 
   13263     15801261 :   poly_int64 base_off = 0;
   13264              : 
   13265     15801261 :   if (TREE_CODE (arg) == ADDR_EXPR)
   13266              :     {
   13267      6446397 :       arg = TREE_OPERAND (arg, 0);
   13268      6446397 :       tree ref = arg;
   13269      6446397 :       if (TREE_CODE (arg) == ARRAY_REF)
   13270              :         {
   13271       575972 :           tree idx = TREE_OPERAND (arg, 1);
   13272       575972 :           if (TREE_CODE (idx) != INTEGER_CST)
   13273              :             {
   13274              :               /* From a pointer (but not array) argument extract the variable
   13275              :                  index to prevent get_addr_base_and_unit_offset() from failing
   13276              :                  due to it.  Use it later to compute the non-constant offset
   13277              :                  into the string and return it to the caller.  */
   13278       168946 :               varidx = idx;
   13279       168946 :               ref = TREE_OPERAND (arg, 0);
   13280              : 
   13281       168946 :               if (TREE_CODE (TREE_TYPE (arg)) == ARRAY_TYPE)
   13282              :                 return NULL_TREE;
   13283              : 
   13284        29117 :               if (!integer_zerop (array_ref_low_bound (arg)))
   13285              :                 return NULL_TREE;
   13286              : 
   13287        28367 :               if (!integer_onep (array_ref_element_size (arg)))
   13288              :                 return NULL_TREE;
   13289              :             }
   13290              :         }
   13291      6304468 :       array = get_addr_base_and_unit_offset (ref, &base_off);
   13292      6304468 :       if (!array
   13293      6256765 :           || (TREE_CODE (array) != VAR_DECL
   13294      6256765 :               && TREE_CODE (array) != CONST_DECL
   13295      3913933 :               && TREE_CODE (array) != STRING_CST))
   13296              :         return NULL_TREE;
   13297              :     }
   13298      9354864 :   else if (TREE_CODE (arg) == PLUS_EXPR || TREE_CODE (arg) == POINTER_PLUS_EXPR)
   13299              :     {
   13300        27204 :       tree arg0 = TREE_OPERAND (arg, 0);
   13301        27204 :       tree arg1 = TREE_OPERAND (arg, 1);
   13302              : 
   13303        27204 :       tree offset;
   13304        27204 :       tree str = string_constant (arg0, &offset, mem_size, decl);
   13305        27204 :       if (!str)
   13306              :         {
   13307        17562 :            str = string_constant (arg1, &offset, mem_size, decl);
   13308        17562 :            arg1 = arg0;
   13309              :         }
   13310              : 
   13311        17562 :       if (str)
   13312              :         {
   13313              :           /* Avoid pointers to arrays (see bug 86622).  */
   13314         9642 :           if (POINTER_TYPE_P (TREE_TYPE (arg))
   13315         9642 :               && TREE_CODE (TREE_TYPE (TREE_TYPE (arg))) == ARRAY_TYPE
   13316         1890 :               && !(decl && !*decl)
   13317        12162 :               && !(decl && tree_fits_uhwi_p (DECL_SIZE_UNIT (*decl))
   13318         1260 :                    && tree_fits_uhwi_p (*mem_size)
   13319         1260 :                    && tree_int_cst_equal (*mem_size, DECL_SIZE_UNIT (*decl))))
   13320              :             return NULL_TREE;
   13321              : 
   13322         7752 :           tree type = TREE_TYPE (offset);
   13323         7752 :           arg1 = fold_convert (type, arg1);
   13324         7752 :           *ptr_offset = fold_build2 (PLUS_EXPR, type, offset, arg1);
   13325         7752 :           return str;
   13326              :         }
   13327              :       return NULL_TREE;
   13328              :     }
   13329      9327660 :   else if (TREE_CODE (arg) == SSA_NAME)
   13330              :     {
   13331      3877881 :       gimple *stmt = SSA_NAME_DEF_STMT (arg);
   13332      3877881 :       if (!is_gimple_assign (stmt))
   13333              :         return NULL_TREE;
   13334              : 
   13335      1052747 :       tree rhs1 = gimple_assign_rhs1 (stmt);
   13336      1052747 :       tree_code code = gimple_assign_rhs_code (stmt);
   13337      1052747 :       if (code == ADDR_EXPR)
   13338       236296 :         return string_constant (rhs1, ptr_offset, mem_size, decl);
   13339       816451 :       else if (code != POINTER_PLUS_EXPR)
   13340              :         return NULL_TREE;
   13341              : 
   13342       195052 :       tree offset;
   13343       195052 :       if (tree str = string_constant (rhs1, &offset, mem_size, decl))
   13344              :         {
   13345              :           /* Avoid pointers to arrays (see bug 86622).  */
   13346        23682 :           if (POINTER_TYPE_P (TREE_TYPE (rhs1))
   13347        23682 :               && TREE_CODE (TREE_TYPE (TREE_TYPE (rhs1))) == ARRAY_TYPE
   13348        19747 :               && !(decl && !*decl)
   13349        39978 :               && !(decl && tree_fits_uhwi_p (DECL_SIZE_UNIT (*decl))
   13350         8148 :                    && tree_fits_uhwi_p (*mem_size)
   13351         8148 :                    && tree_int_cst_equal (*mem_size, DECL_SIZE_UNIT (*decl))))
   13352              :             return NULL_TREE;
   13353              : 
   13354         7229 :           tree rhs2 = gimple_assign_rhs2 (stmt);
   13355         7229 :           tree type = TREE_TYPE (offset);
   13356         7229 :           rhs2 = fold_convert (type, rhs2);
   13357         7229 :           *ptr_offset = fold_build2 (PLUS_EXPR, type, offset, rhs2);
   13358         7229 :           return str;
   13359              :         }
   13360              :       return NULL_TREE;
   13361              :     }
   13362      5449779 :   else if (DECL_P (arg))
   13363              :     array = arg;
   13364              :   else
   13365              :     return NULL_TREE;
   13366              : 
   13367      8838388 :   tree offset = wide_int_to_tree (sizetype, base_off);
   13368      8838388 :   if (varidx)
   13369              :     {
   13370         2853 :       if (TREE_CODE (TREE_TYPE (array)) != ARRAY_TYPE)
   13371              :         return NULL_TREE;
   13372              : 
   13373         2142 :       gcc_assert (TREE_CODE (arg) == ARRAY_REF);
   13374         2142 :       tree chartype = TREE_TYPE (TREE_TYPE (TREE_OPERAND (arg, 0)));
   13375         2142 :       if (TREE_CODE (chartype) != INTEGER_TYPE)
   13376              :         return NULL;
   13377              : 
   13378         1986 :       offset = fold_convert (sizetype, varidx);
   13379              :     }
   13380              : 
   13381      8837521 :   if (TREE_CODE (array) == STRING_CST)
   13382              :     {
   13383      3521509 :       *ptr_offset = fold_convert (sizetype, offset);
   13384      3521509 :       *mem_size = TYPE_SIZE_UNIT (TREE_TYPE (array));
   13385      3521509 :       if (decl)
   13386       753162 :         *decl = NULL_TREE;
   13387      3521509 :       gcc_checking_assert (tree_to_shwi (TYPE_SIZE_UNIT (TREE_TYPE (array)))
   13388              :                            >= TREE_STRING_LENGTH (array));
   13389              :       return array;
   13390              :     }
   13391              : 
   13392      5316012 :   tree init = ctor_for_folding (array);
   13393      5316012 :   if (!init || init == error_mark_node)
   13394              :     return NULL_TREE;
   13395              : 
   13396       164365 :   if (valrep)
   13397              :     {
   13398        58882 :       HOST_WIDE_INT cstoff;
   13399        58882 :       if (!base_off.is_constant (&cstoff))
   13400              :         return NULL_TREE;
   13401              : 
   13402              :       /* Check that the host and target are sane.  */
   13403        58882 :       if (CHAR_BIT != 8 || BITS_PER_UNIT != 8)
   13404              :         return NULL_TREE;
   13405              : 
   13406        58882 :       HOST_WIDE_INT typesz = int_size_in_bytes (TREE_TYPE (init));
   13407        58882 :       if (typesz <= 0 || (int) typesz != typesz)
   13408              :         return NULL_TREE;
   13409              : 
   13410        58729 :       HOST_WIDE_INT size = typesz;
   13411        58729 :       if (VAR_P (array)
   13412        58719 :           && DECL_SIZE_UNIT (array)
   13413       117448 :           && tree_fits_shwi_p (DECL_SIZE_UNIT (array)))
   13414              :         {
   13415        58719 :           size = tree_to_shwi (DECL_SIZE_UNIT (array));
   13416        58719 :           gcc_checking_assert (size >= typesz);
   13417              :         }
   13418              : 
   13419              :       /* If value representation was requested convert the initializer
   13420              :          for the whole array or object into a string of bytes forming
   13421              :          its value representation and return it.  */
   13422        58729 :       unsigned char *bytes = XNEWVEC (unsigned char, size);
   13423        58729 :       int r = native_encode_initializer (init, bytes, size);
   13424        58729 :       if (r < typesz)
   13425              :         {
   13426           64 :           XDELETEVEC (bytes);
   13427           64 :           return NULL_TREE;
   13428              :         }
   13429              : 
   13430        58665 :       if (r < size)
   13431            0 :         memset (bytes + r, '\0', size - r);
   13432              : 
   13433        58665 :       const char *p = reinterpret_cast<const char *>(bytes);
   13434        58665 :       init = build_string_literal (size, p, char_type_node);
   13435        58665 :       init = TREE_OPERAND (init, 0);
   13436        58665 :       init = TREE_OPERAND (init, 0);
   13437        58665 :       XDELETE (bytes);
   13438              : 
   13439        58665 :       *mem_size = size_int (TREE_STRING_LENGTH (init));
   13440        58665 :       *ptr_offset = wide_int_to_tree (ssizetype, base_off);
   13441              : 
   13442        58665 :       if (decl)
   13443            0 :         *decl = array;
   13444              : 
   13445              :       return init;
   13446              :     }
   13447              : 
   13448       105483 :   if (TREE_CODE (init) == CONSTRUCTOR)
   13449              :     {
   13450              :       /* Convert the 64-bit constant offset to a wider type to avoid
   13451              :          overflow and use it to obtain the initializer for the subobject
   13452              :          it points into.  */
   13453        84619 :       offset_int wioff;
   13454        84619 :       if (!base_off.is_constant (&wioff))
   13455          155 :         return NULL_TREE;
   13456              : 
   13457        84619 :       wioff *= BITS_PER_UNIT;
   13458        84619 :       if (!wi::fits_uhwi_p (wioff))
   13459              :         return NULL_TREE;
   13460              : 
   13461        84511 :       base_off = wioff.to_uhwi ();
   13462        84511 :       unsigned HOST_WIDE_INT fieldoff = 0;
   13463        84511 :       init = fold_ctor_reference (TREE_TYPE (arg), init, base_off, 0, array,
   13464              :                                   &fieldoff);
   13465        84511 :       if (!init || init == error_mark_node)
   13466              :         return NULL_TREE;
   13467              : 
   13468        84464 :       HOST_WIDE_INT cstoff;
   13469        84464 :       if (!base_off.is_constant (&cstoff))
   13470              :         return NULL_TREE;
   13471              : 
   13472        84464 :       cstoff = (cstoff - fieldoff) / BITS_PER_UNIT;
   13473        84464 :       tree off = build_int_cst (sizetype, cstoff);
   13474        84464 :       if (varidx)
   13475         1122 :         offset = fold_build2 (PLUS_EXPR, TREE_TYPE (offset), offset, off);
   13476              :       else
   13477              :         offset = off;
   13478              :     }
   13479              : 
   13480       105328 :   *ptr_offset = offset;
   13481              : 
   13482       105328 :   tree inittype = TREE_TYPE (init);
   13483              : 
   13484       105328 :   if (TREE_CODE (init) == INTEGER_CST
   13485       105328 :       && (TREE_CODE (TREE_TYPE (array)) == INTEGER_TYPE
   13486         1195 :           || TYPE_MAIN_VARIANT (inittype) == char_type_node))
   13487              :     {
   13488              :       /* Check that the host and target are sane.  */
   13489          912 :       if (CHAR_BIT != 8 || BITS_PER_UNIT != 8)
   13490              :         return NULL_TREE;
   13491              : 
   13492              :       /* For a reference to (address of) a single constant character,
   13493              :          store the native representation of the character in CHARBUF.
   13494              :          If the reference is to an element of an array or a member
   13495              :          of a struct, only consider narrow characters until ctors
   13496              :          for wide character arrays are transformed to STRING_CSTs
   13497              :          like those for narrow arrays.  */
   13498          912 :       unsigned char charbuf[MAX_BITSIZE_MODE_ANY_MODE / BITS_PER_UNIT];
   13499          912 :       int len = native_encode_expr (init, charbuf, sizeof charbuf, 0);
   13500          912 :       if (len > 0)
   13501              :         {
   13502              :           /* Construct a string literal with elements of INITTYPE and
   13503              :              the representation above.  Then strip
   13504              :              the ADDR_EXPR (ARRAY_REF (...)) around the STRING_CST.  */
   13505          912 :           init = build_string_literal (len, (char *)charbuf, inittype);
   13506          912 :           init = TREE_OPERAND (TREE_OPERAND (init, 0), 0);
   13507              :         }
   13508              :     }
   13509              : 
   13510       105328 :   tree initsize = TYPE_SIZE_UNIT (inittype);
   13511              : 
   13512       105328 :   if (TREE_CODE (init) == CONSTRUCTOR && initializer_zerop (init))
   13513              :     {
   13514              :       /* Fold an empty/zero constructor for an implicitly initialized
   13515              :          object or subobject into the empty string.  */
   13516              : 
   13517              :       /* Determine the character type from that of the original
   13518              :          expression.  */
   13519         9339 :       tree chartype = argtype;
   13520         9339 :       if (POINTER_TYPE_P (chartype))
   13521         9332 :         chartype = TREE_TYPE (chartype);
   13522        14962 :       while (TREE_CODE (chartype) == ARRAY_TYPE)
   13523         5623 :         chartype = TREE_TYPE (chartype);
   13524              : 
   13525         9339 :       if (INTEGRAL_TYPE_P (chartype)
   13526         9339 :           && TYPE_PRECISION (chartype) == TYPE_PRECISION (char_type_node))
   13527              :         {
   13528              :           /* Convert a char array to an empty STRING_CST having an array
   13529              :              of the expected type and size.  */
   13530         9133 :           if (!initsize)
   13531         3090 :             initsize = integer_zero_node;
   13532         6043 :           else if (!tree_fits_uhwi_p (initsize))
   13533              :             return NULL_TREE;
   13534              : 
   13535         9127 :           unsigned HOST_WIDE_INT size = tree_to_uhwi (initsize);
   13536         9127 :           if (size > (unsigned HOST_WIDE_INT) INT_MAX)
   13537              :             return NULL_TREE;
   13538              : 
   13539         9127 :           init = build_string_literal (size, NULL, chartype, size);
   13540         9127 :           init = TREE_OPERAND (init, 0);
   13541         9127 :           init = TREE_OPERAND (init, 0);
   13542              : 
   13543         9127 :           *ptr_offset = integer_zero_node;
   13544              :         }
   13545              :     }
   13546              : 
   13547       105322 :   if (decl)
   13548        54726 :     *decl = array;
   13549              : 
   13550       105322 :   if (TREE_CODE (init) != STRING_CST)
   13551              :     return NULL_TREE;
   13552              : 
   13553        72622 :   *mem_size = initsize;
   13554              : 
   13555        72622 :   gcc_checking_assert (tree_to_shwi (initsize) >= TREE_STRING_LENGTH (init));
   13556              : 
   13557              :   return init;
   13558              : }
   13559              : 
   13560              : /* Return STRING_CST if an ARG corresponds to a string constant or zero
   13561              :    if it doesn't.  If we return nonzero, set *PTR_OFFSET to the (possibly
   13562              :    non-constant) offset in bytes within the string that ARG is accessing.
   13563              :    If MEM_SIZE is non-zero the storage size of the memory is returned.
   13564              :    If DECL is non-zero the constant declaration is returned if available.  */
   13565              : 
   13566              : tree
   13567     11121173 : string_constant (tree arg, tree *ptr_offset, tree *mem_size, tree *decl)
   13568              : {
   13569     11121173 :   return constant_byte_string (arg, ptr_offset, mem_size, decl, false);
   13570              : }
   13571              : 
   13572              : /* Similar to string_constant, return a STRING_CST corresponding
   13573              :    to the value representation of the first argument if it's
   13574              :    a constant.  */
   13575              : 
   13576              : tree
   13577      4680088 : byte_representation (tree arg, tree *ptr_offset, tree *mem_size, tree *decl)
   13578              : {
   13579      4680088 :   return constant_byte_string (arg, ptr_offset, mem_size, decl, true);
   13580              : }
   13581              : 
   13582              : /* Optimize x % C1 == C2 for signed modulo if C1 is a power of two and C2
   13583              :    is non-zero and C3 ((1<<(prec-1)) | (C1 - 1)):
   13584              :    for C2 > 0 to x & C3 == C2
   13585              :    for C2 < 0 to x & C3 == (C2 & C3).  */
   13586              : enum tree_code
   13587           35 : maybe_optimize_pow2p_mod_cmp (enum tree_code code, tree *arg0, tree *arg1)
   13588              : {
   13589           35 :   gassign *stmt = get_def_for_expr (*arg0, TRUNC_MOD_EXPR);
   13590           35 :   tree treeop0 = gimple_assign_rhs1 (stmt);
   13591           35 :   tree treeop1 = gimple_assign_rhs2 (stmt);
   13592           35 :   tree type = TREE_TYPE (*arg0);
   13593           35 :   scalar_int_mode mode;
   13594           35 :   if (!is_a <scalar_int_mode> (TYPE_MODE (type), &mode))
   13595              :     return code;
   13596           70 :   if (GET_MODE_BITSIZE (mode) != TYPE_PRECISION (type)
   13597           35 :       || TYPE_PRECISION (type) <= 1
   13598           35 :       || TYPE_UNSIGNED (type)
   13599              :       /* Signed x % c == 0 should have been optimized into unsigned modulo
   13600              :          earlier.  */
   13601           35 :       || integer_zerop (*arg1)
   13602              :       /* If c is known to be non-negative, modulo will be expanded as unsigned
   13603              :          modulo.  */
   13604           70 :       || get_range_pos_neg (treeop0, currently_expanding_gimple_stmt) == 1)
   13605              :     return code;
   13606              : 
   13607              :   /* x % c == d where d < 0 && d <= -c should be always false.  */
   13608           35 :   if (tree_int_cst_sgn (*arg1) == -1
   13609           51 :       && -wi::to_widest (treeop1) >= wi::to_widest (*arg1))
   13610              :     return code;
   13611              : 
   13612           35 :   int prec = TYPE_PRECISION (type);
   13613           35 :   wide_int w = wi::to_wide (treeop1) - 1;
   13614           35 :   w |= wi::shifted_mask (0, prec - 1, true, prec);
   13615           35 :   tree c3 = wide_int_to_tree (type, w);
   13616           35 :   tree c4 = *arg1;
   13617           35 :   if (tree_int_cst_sgn (*arg1) == -1)
   13618           16 :     c4 = wide_int_to_tree (type, w & wi::to_wide (*arg1));
   13619              : 
   13620           35 :   rtx op0 = expand_normal (treeop0);
   13621           35 :   treeop0 = make_tree (TREE_TYPE (treeop0), op0);
   13622              : 
   13623           35 :   bool speed_p = optimize_insn_for_speed_p ();
   13624              : 
   13625           35 :   do_pending_stack_adjust ();
   13626              : 
   13627           35 :   location_t loc = gimple_location (stmt);
   13628           35 :   struct separate_ops ops;
   13629           35 :   ops.code = TRUNC_MOD_EXPR;
   13630           35 :   ops.location = loc;
   13631           35 :   ops.type = TREE_TYPE (treeop0);
   13632           35 :   ops.op0 = treeop0;
   13633           35 :   ops.op1 = treeop1;
   13634           35 :   ops.op2 = NULL_TREE;
   13635           35 :   start_sequence ();
   13636           35 :   rtx mor = expand_expr_real_2 (&ops, NULL_RTX, TYPE_MODE (ops.type),
   13637              :                                 EXPAND_NORMAL);
   13638           35 :   rtx_insn *moinsns = end_sequence ();
   13639              : 
   13640           35 :   unsigned mocost = seq_cost (moinsns, speed_p);
   13641           35 :   mocost += rtx_cost (mor, mode, EQ, 0, speed_p);
   13642           35 :   mocost += rtx_cost (expand_normal (*arg1), mode, EQ, 1, speed_p);
   13643              : 
   13644           35 :   ops.code = BIT_AND_EXPR;
   13645           35 :   ops.location = loc;
   13646           35 :   ops.type = TREE_TYPE (treeop0);
   13647           35 :   ops.op0 = treeop0;
   13648           35 :   ops.op1 = c3;
   13649           35 :   ops.op2 = NULL_TREE;
   13650           35 :   start_sequence ();
   13651           35 :   rtx mur = expand_expr_real_2 (&ops, NULL_RTX, TYPE_MODE (ops.type),
   13652              :                                 EXPAND_NORMAL);
   13653           35 :   rtx_insn *muinsns = end_sequence ();
   13654              : 
   13655           35 :   unsigned mucost = seq_cost (muinsns, speed_p);
   13656           35 :   mucost += rtx_cost (mur, mode, EQ, 0, speed_p);
   13657           35 :   mucost += rtx_cost (expand_normal (c4), mode, EQ, 1, speed_p);
   13658              : 
   13659           35 :   if (mocost <= mucost)
   13660              :     {
   13661            0 :       emit_insn (moinsns);
   13662            0 :       *arg0 = make_tree (TREE_TYPE (*arg0), mor);
   13663            0 :       return code;
   13664              :     }
   13665              : 
   13666           35 :   emit_insn (muinsns);
   13667           35 :   *arg0 = make_tree (TREE_TYPE (*arg0), mur);
   13668           35 :   *arg1 = c4;
   13669           35 :   return code;
   13670           35 : }
   13671              : 
   13672              : /* Attempt to optimize unsigned (X % C1) == C2 (or (X % C1) != C2).
   13673              :    If C1 is odd to:
   13674              :    (X - C2) * C3 <= C4 (or >), where
   13675              :    C3 is modular multiplicative inverse of C1 and 1<<prec and
   13676              :    C4 is ((1<<prec) - 1) / C1 or ((1<<prec) - 1) / C1 - 1 (the latter
   13677              :    if C2 > ((1<<prec) - 1) % C1).
   13678              :    If C1 is even, S = ctz (C1) and C2 is 0, use
   13679              :    ((X * C3) r>> S) <= C4, where C3 is modular multiplicative
   13680              :    inverse of C1>>S and 1<<prec and C4 is (((1<<prec) - 1) / (C1>>S)) >> S.
   13681              : 
   13682              :    For signed (X % C1) == 0 if C1 is odd to (all operations in it
   13683              :    unsigned):
   13684              :    (X * C3) + C4 <= 2 * C4, where
   13685              :    C3 is modular multiplicative inverse of (unsigned) C1 and 1<<prec and
   13686              :    C4 is ((1<<(prec - 1) - 1) / C1).
   13687              :    If C1 is even, S = ctz(C1), use
   13688              :    ((X * C3) + C4) r>> S <= (C4 >> (S - 1))
   13689              :    where C3 is modular multiplicative inverse of (unsigned)(C1>>S) and 1<<prec
   13690              :    and C4 is ((1<<(prec - 1) - 1) / (C1>>S)) & (-1<<S).
   13691              : 
   13692              :    See the Hacker's Delight book, section 10-17.  */
   13693              : enum tree_code
   13694      3416135 : maybe_optimize_mod_cmp (enum tree_code code, tree *arg0, tree *arg1)
   13695              : {
   13696      3416135 :   gcc_checking_assert (code == EQ_EXPR || code == NE_EXPR);
   13697      3416135 :   gcc_checking_assert (TREE_CODE (*arg1) == INTEGER_CST);
   13698              : 
   13699      3416135 :   if (optimize < 2)
   13700              :     return code;
   13701              : 
   13702      2582628 :   gassign *stmt = get_def_for_expr (*arg0, TRUNC_MOD_EXPR);
   13703      2582628 :   if (stmt == NULL)
   13704              :     return code;
   13705              : 
   13706         2213 :   tree treeop0 = gimple_assign_rhs1 (stmt);
   13707         2213 :   tree treeop1 = gimple_assign_rhs2 (stmt);
   13708         2213 :   if (TREE_CODE (treeop0) != SSA_NAME
   13709         2107 :       || TREE_CODE (treeop1) != INTEGER_CST
   13710              :       /* Don't optimize the undefined behavior case x % 0;
   13711              :          x % 1 should have been optimized into zero, punt if
   13712              :          it makes it here for whatever reason;
   13713              :          x % -c should have been optimized into x % c.  */
   13714         1685 :       || compare_tree_int (treeop1, 2) <= 0
   13715              :       /* Likewise x % c == d where d >= c should be always false.  */
   13716         3822 :       || tree_int_cst_le (treeop1, *arg1))
   13717              :     return code;
   13718              : 
   13719              :   /* Unsigned x % pow2 is handled right already, for signed
   13720              :      modulo handle it in maybe_optimize_pow2p_mod_cmp.  */
   13721         1609 :   if (integer_pow2p (treeop1))
   13722           35 :     return maybe_optimize_pow2p_mod_cmp (code, arg0, arg1);
   13723              : 
   13724         1574 :   tree type = TREE_TYPE (*arg0);
   13725         1574 :   scalar_int_mode mode;
   13726         1574 :   if (!is_a <scalar_int_mode> (TYPE_MODE (type), &mode))
   13727              :     return code;
   13728         3148 :   if (GET_MODE_BITSIZE (mode) != TYPE_PRECISION (type)
   13729         1574 :       || TYPE_PRECISION (type) <= 1)
   13730              :     return code;
   13731              : 
   13732         1574 :   signop sgn = UNSIGNED;
   13733              :   /* If both operands are known to have the sign bit clear, handle
   13734              :      even the signed modulo case as unsigned.  treeop1 is always
   13735              :      positive >= 2, checked above.  */
   13736         1574 :   if (!TYPE_UNSIGNED (type)
   13737         1574 :       && get_range_pos_neg (treeop0, currently_expanding_gimple_stmt) != 1)
   13738              :     sgn = SIGNED;
   13739              : 
   13740         1574 :   if (!TYPE_UNSIGNED (type))
   13741              :     {
   13742         1346 :       if (tree_int_cst_sgn (*arg1) == -1)
   13743              :         return code;
   13744         1339 :       type = unsigned_type_for (type);
   13745         1339 :       if (!type || TYPE_MODE (type) != TYPE_MODE (TREE_TYPE (*arg0)))
   13746              :         return code;
   13747              :     }
   13748              : 
   13749         1567 :   int prec = TYPE_PRECISION (type);
   13750         1567 :   wide_int w = wi::to_wide (treeop1);
   13751         1567 :   int shift = wi::ctz (w);
   13752              :   /* Unsigned (X % C1) == C2 is equivalent to (X - C2) % C1 == 0 if
   13753              :      C2 <= -1U % C1, because for any Z >= 0U - C2 in that case (Z % C1) != 0.
   13754              :      If C1 is odd, we can handle all cases by subtracting
   13755              :      C4 below.  We could handle even the even C1 and C2 > -1U % C1 cases
   13756              :      e.g. by testing for overflow on the subtraction, punt on that for now
   13757              :      though.  */
   13758         1567 :   if ((sgn == SIGNED || shift) && !integer_zerop (*arg1))
   13759              :     {
   13760          187 :       if (sgn == SIGNED)
   13761          172 :         return code;
   13762           27 :       wide_int x = wi::umod_trunc (wi::mask (prec, false, prec), w);
   13763           27 :       if (wi::gtu_p (wi::to_wide (*arg1), x))
   13764           12 :         return code;
   13765           27 :     }
   13766              : 
   13767         1395 :   imm_use_iterator imm_iter;
   13768         1395 :   use_operand_p use_p;
   13769         7110 :   FOR_EACH_IMM_USE_FAST (use_p, imm_iter, treeop0)
   13770              :     {
   13771         5725 :       auto *use_stmt = dyn_cast<gassign *> (USE_STMT (use_p));
   13772         5725 :       if (!use_stmt)
   13773         1419 :         continue;
   13774              :       /* Punt if treeop0 is used in the same bb in a division
   13775              :          or another modulo with the same divisor.  We should expect
   13776              :          the division and modulo combined together.  */
   13777         8508 :       if (use_stmt == stmt
   13778         4306 :           || gimple_bb (use_stmt) != gimple_bb (stmt))
   13779         4202 :         continue;
   13780          104 :       if ((gimple_assign_rhs_code (use_stmt) != TRUNC_DIV_EXPR
   13781          104 :               && gimple_assign_rhs_code (use_stmt) != TRUNC_MOD_EXPR))
   13782           79 :         continue;
   13783           25 :       if (gimple_assign_rhs1 (use_stmt) != treeop0
   13784           50 :           || !operand_equal_p (gimple_assign_rhs2 (use_stmt), treeop1, 0))
   13785           15 :         continue;
   13786           10 :       return code;
   13787           10 :     }
   13788              : 
   13789         1385 :   w = wi::lrshift (w, shift);
   13790         1385 :   wide_int a = wide_int::from (w, prec + 1, UNSIGNED);
   13791         1385 :   wide_int b = wi::shifted_mask (prec, 1, false, prec + 1);
   13792         1385 :   wide_int m = wide_int::from (wi::mod_inv (a, b), prec, UNSIGNED);
   13793         1385 :   tree c3 = wide_int_to_tree (type, m);
   13794         1385 :   tree c5 = NULL_TREE;
   13795         1385 :   wide_int d, e;
   13796         1385 :   if (sgn == UNSIGNED)
   13797              :     {
   13798         1024 :       d = wi::divmod_trunc (wi::mask (prec, false, prec), w, UNSIGNED, &e);
   13799              :       /* Use <= floor ((1<<prec) - 1) / C1 only if C2 <= ((1<<prec) - 1) % C1,
   13800              :          otherwise use < or subtract one from C4.  E.g. for
   13801              :          x % 3U == 0 we transform this into x * 0xaaaaaaab <= 0x55555555, but
   13802              :          x % 3U == 1 already needs to be
   13803              :          (x - 1) * 0xaaaaaaabU <= 0x55555554.  */
   13804         1024 :       if (!shift && wi::gtu_p (wi::to_wide (*arg1), e))
   13805           22 :         d -= 1;
   13806         1024 :       if (shift)
   13807          442 :         d = wi::lrshift (d, shift);
   13808              :     }
   13809              :   else
   13810              :     {
   13811          361 :       e = wi::udiv_trunc (wi::mask (prec - 1, false, prec), w);
   13812          361 :       if (!shift)
   13813          166 :         d = wi::lshift (e, 1);
   13814              :       else
   13815              :         {
   13816          195 :           e = wi::bit_and (e, wi::mask (shift, true, prec));
   13817          195 :           d = wi::lrshift (e, shift - 1);
   13818              :         }
   13819          361 :       c5 = wide_int_to_tree (type, e);
   13820              :     }
   13821         1385 :   tree c4 = wide_int_to_tree (type, d);
   13822              : 
   13823         1385 :   rtx op0 = expand_normal (treeop0);
   13824         1385 :   treeop0 = make_tree (TREE_TYPE (treeop0), op0);
   13825              : 
   13826         1385 :   bool speed_p = optimize_insn_for_speed_p ();
   13827              : 
   13828         1385 :   do_pending_stack_adjust ();
   13829              : 
   13830         1385 :   location_t loc = gimple_location (stmt);
   13831         1385 :   struct separate_ops ops;
   13832         1385 :   ops.code = TRUNC_MOD_EXPR;
   13833         1385 :   ops.location = loc;
   13834         1385 :   ops.type = TREE_TYPE (treeop0);
   13835         1385 :   ops.op0 = treeop0;
   13836         1385 :   ops.op1 = treeop1;
   13837         1385 :   ops.op2 = NULL_TREE;
   13838         1385 :   start_sequence ();
   13839         1385 :   rtx mor = expand_expr_real_2 (&ops, NULL_RTX, TYPE_MODE (ops.type),
   13840              :                                 EXPAND_NORMAL);
   13841         1385 :   rtx_insn *moinsns = end_sequence ();
   13842              : 
   13843         1385 :   unsigned mocost = seq_cost (moinsns, speed_p);
   13844         1385 :   mocost += rtx_cost (mor, mode, EQ, 0, speed_p);
   13845         1385 :   mocost += rtx_cost (expand_normal (*arg1), mode, EQ, 1, speed_p);
   13846              : 
   13847         1385 :   tree t = fold_convert_loc (loc, type, treeop0);
   13848         1385 :   if (!integer_zerop (*arg1))
   13849           49 :     t = fold_build2_loc (loc, MINUS_EXPR, type, t, fold_convert (type, *arg1));
   13850         1385 :   t = fold_build2_loc (loc, MULT_EXPR, type, t, c3);
   13851         1385 :   if (sgn == SIGNED)
   13852          361 :     t = fold_build2_loc (loc, PLUS_EXPR, type, t, c5);
   13853         1385 :   if (shift)
   13854              :     {
   13855          637 :       tree s = build_int_cst (integer_type_node, shift);
   13856          637 :       t = fold_build2_loc (loc, RROTATE_EXPR, type, t, s);
   13857              :     }
   13858              : 
   13859         1385 :   start_sequence ();
   13860         1385 :   rtx mur = expand_normal (t);
   13861         1385 :   rtx_insn *muinsns = end_sequence ();
   13862              : 
   13863         1385 :   unsigned mucost = seq_cost (muinsns, speed_p);
   13864         1385 :   mucost += rtx_cost (mur, mode, LE, 0, speed_p);
   13865         1385 :   mucost += rtx_cost (expand_normal (c4), mode, LE, 1, speed_p);
   13866              : 
   13867         1385 :   if (mocost <= mucost)
   13868              :     {
   13869          226 :       emit_insn (moinsns);
   13870          226 :       *arg0 = make_tree (TREE_TYPE (*arg0), mor);
   13871          226 :       return code;
   13872              :     }
   13873              : 
   13874         1159 :   emit_insn (muinsns);
   13875         1159 :   *arg0 = make_tree (type, mur);
   13876         1159 :   *arg1 = c4;
   13877         1159 :   return code == EQ_EXPR ? LE_EXPR : GT_EXPR;
   13878         2952 : }
   13879              : 
   13880              : /* Optimize x - y < 0 into x < 0 if x - y has undefined overflow.  */
   13881              : 
   13882              : void
   13883       247191 : maybe_optimize_sub_cmp_0 (enum tree_code code, tree *arg0, tree *arg1)
   13884              : {
   13885       247191 :   gcc_checking_assert (code == GT_EXPR || code == GE_EXPR
   13886              :                        || code == LT_EXPR || code == LE_EXPR);
   13887       247191 :   gcc_checking_assert (integer_zerop (*arg1));
   13888              : 
   13889       247191 :   if (!optimize)
   13890              :     return;
   13891              : 
   13892       212861 :   gassign *stmt = get_def_for_expr (*arg0, MINUS_EXPR);
   13893       212861 :   if (stmt == NULL)
   13894              :     return;
   13895              : 
   13896         1383 :   tree treeop0 = gimple_assign_rhs1 (stmt);
   13897         1383 :   tree treeop1 = gimple_assign_rhs2 (stmt);
   13898         1383 :   if (!TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (treeop0)))
   13899              :     return;
   13900              : 
   13901         1293 :   *arg0 = treeop0;
   13902         1293 :   *arg1 = treeop1;
   13903              : }
   13904              : 
   13905              : 
   13906              : /* Expand CODE with arguments INNER & (1<<BITNUM) and 0 that represents
   13907              :    a single bit equality/inequality test, returns where the result is located.  */
   13908              : 
   13909              : static rtx
   13910        10169 : expand_single_bit_test (location_t loc, enum tree_code code,
   13911              :                         tree inner, int bitnum,
   13912              :                         tree result_type, rtx target,
   13913              :                         machine_mode mode)
   13914              : {
   13915        10169 :   gcc_assert (code == NE_EXPR || code == EQ_EXPR);
   13916              : 
   13917        10169 :   tree type = TREE_TYPE (inner);
   13918        10169 :   scalar_int_mode operand_mode = SCALAR_INT_TYPE_MODE (type);
   13919        10169 :   int ops_unsigned;
   13920        10169 :   tree signed_type, unsigned_type, intermediate_type;
   13921        10169 :   gimple *inner_def;
   13922              : 
   13923              :   /* First, see if we can fold the single bit test into a sign-bit
   13924              :      test.  */
   13925        10169 :   if (bitnum == TYPE_PRECISION (type) - 1
   13926        10169 :       && type_has_mode_precision_p (type))
   13927              :     {
   13928          248 :       tree stype = signed_type_for (type);
   13929          458 :       tree tmp = fold_build2_loc (loc, code == EQ_EXPR ? GE_EXPR : LT_EXPR,
   13930              :                                   result_type,
   13931              :                                   fold_convert_loc (loc, stype, inner),
   13932              :                                   build_int_cst (stype, 0));
   13933          248 :       return expand_expr (tmp, target, VOIDmode, EXPAND_NORMAL);
   13934              :     }
   13935              : 
   13936              :   /* Otherwise we have (A & C) != 0 where C is a single bit,
   13937              :      convert that into ((A >> C2) & 1).  Where C2 = log2(C).
   13938              :      Similarly for (A & C) == 0.  */
   13939              : 
   13940              :   /* If INNER is a right shift of a constant and it plus BITNUM does
   13941              :      not overflow, adjust BITNUM and INNER.  */
   13942         9921 :   if ((inner_def = get_def_for_expr (inner, RSHIFT_EXPR))
   13943           59 :        && TREE_CODE (gimple_assign_rhs2 (inner_def)) == INTEGER_CST
   13944           16 :        && bitnum < TYPE_PRECISION (type)
   13945         9937 :        && wi::ltu_p (wi::to_wide (gimple_assign_rhs2 (inner_def)),
   13946         9921 :                      TYPE_PRECISION (type) - bitnum))
   13947              :     {
   13948           16 :       bitnum += tree_to_uhwi (gimple_assign_rhs2 (inner_def));
   13949           16 :       inner = gimple_assign_rhs1 (inner_def);
   13950              :     }
   13951              : 
   13952              :   /* If we are going to be able to omit the AND below, we must do our
   13953              :      operations as unsigned.  If we must use the AND, we have a choice.
   13954              :      Normally unsigned is faster, but for some machines signed is.  */
   13955         9921 :   ops_unsigned = (load_extend_op (operand_mode) == SIGN_EXTEND
   13956              :                   && !flag_syntax_only) ? 0 : 1;
   13957              : 
   13958         9921 :   signed_type = lang_hooks.types.type_for_mode (operand_mode, 0);
   13959         9921 :   unsigned_type = lang_hooks.types.type_for_mode (operand_mode, 1);
   13960         9921 :   intermediate_type = ops_unsigned ? unsigned_type : signed_type;
   13961         9921 :   inner = fold_convert_loc (loc, intermediate_type, inner);
   13962              : 
   13963         9921 :   rtx inner0 = expand_expr (inner, NULL_RTX, VOIDmode, EXPAND_NORMAL);
   13964              : 
   13965         9921 :   if (CONST_SCALAR_INT_P (inner0))
   13966              :     {
   13967            0 :       wide_int t = rtx_mode_t (inner0, operand_mode);
   13968            0 :       bool setp = (wi::lrshift (t, bitnum) & 1) != 0;
   13969            0 :       return (setp ^ (code == EQ_EXPR)) ? const1_rtx : const0_rtx;
   13970            0 :     }
   13971         9921 :   int bitpos = bitnum;
   13972              : 
   13973         9921 :   if (BYTES_BIG_ENDIAN)
   13974              :     bitpos = GET_MODE_BITSIZE (operand_mode) - 1 - bitpos;
   13975              : 
   13976         9921 :   inner0 = extract_bit_field (inner0, 1, bitpos, 1, target,
   13977              :                               operand_mode, mode, 0, NULL);
   13978              : 
   13979         9921 :   if (code == EQ_EXPR)
   13980         2757 :     inner0 = expand_binop (GET_MODE (inner0), xor_optab, inner0, const1_rtx,
   13981              :                            NULL_RTX, 1, OPTAB_LIB_WIDEN);
   13982         9921 :   if (GET_MODE (inner0) != mode)
   13983              :     {
   13984            0 :       rtx t = gen_reg_rtx (mode);
   13985            0 :       convert_move (t, inner0, 0);
   13986            0 :       return t;
   13987              :     }
   13988              :   return inner0;
   13989              : }
   13990              : 
   13991              : /* Generate code to calculate OPS, and exploded expression
   13992              :    using a store-flag instruction and return an rtx for the result.
   13993              :    OPS reflects a comparison.
   13994              : 
   13995              :    If TARGET is nonzero, store the result there if convenient.
   13996              : 
   13997              :    Return zero if there is no suitable set-flag instruction
   13998              :    available on this machine.
   13999              : 
   14000              :    Once expand_expr has been called on the arguments of the comparison,
   14001              :    we are committed to doing the store flag, since it is not safe to
   14002              :    re-evaluate the expression.  We emit the store-flag insn by calling
   14003              :    emit_store_flag, but only expand the arguments if we have a reason
   14004              :    to believe that emit_store_flag will be successful.  If we think that
   14005              :    it will, but it isn't, we have to simulate the store-flag with a
   14006              :    set/jump/set sequence.  */
   14007              : 
   14008              : static rtx
   14009       642775 : do_store_flag (const_sepops ops, rtx target, machine_mode mode)
   14010              : {
   14011       642775 :   enum rtx_code code;
   14012       642775 :   tree arg0, arg1, type;
   14013       642775 :   machine_mode operand_mode;
   14014       642775 :   int unsignedp;
   14015       642775 :   rtx op0, op1;
   14016       642775 :   rtx subtarget = target;
   14017       642775 :   location_t loc = ops->location;
   14018       642775 :   unsigned HOST_WIDE_INT nunits;
   14019              : 
   14020       642775 :   arg0 = ops->op0;
   14021       642775 :   arg1 = ops->op1;
   14022              : 
   14023              :   /* Don't crash if the comparison was erroneous.  */
   14024       642775 :   if (arg0 == error_mark_node || arg1 == error_mark_node)
   14025            0 :     return const0_rtx;
   14026              : 
   14027       642775 :   type = TREE_TYPE (arg0);
   14028       642775 :   operand_mode = TYPE_MODE (type);
   14029       642775 :   unsignedp = TYPE_UNSIGNED (type);
   14030              : 
   14031              :   /* We won't bother with BLKmode store-flag operations because it would mean
   14032              :      passing a lot of information to emit_store_flag.  */
   14033       642775 :   if (operand_mode == BLKmode)
   14034              :     return 0;
   14035              : 
   14036              :   /* We won't bother with store-flag operations involving function pointers
   14037              :      when function pointers must be canonicalized before comparisons.  */
   14038       642775 :   if (targetm.have_canonicalize_funcptr_for_compare ()
   14039       642775 :       && ((POINTER_TYPE_P (TREE_TYPE (arg0))
   14040            0 :            && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (arg0))))
   14041            0 :           || (POINTER_TYPE_P (TREE_TYPE (arg1))
   14042            0 :               && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (arg1))))))
   14043              :     return 0;
   14044              : 
   14045       642775 :   STRIP_NOPS (arg0);
   14046       642775 :   STRIP_NOPS (arg1);
   14047              : 
   14048              :   /* For vector typed comparisons emit code to generate the desired
   14049              :      all-ones or all-zeros mask.  */
   14050       642775 :   if (VECTOR_TYPE_P (ops->type))
   14051              :     {
   14052        27045 :       tree ifexp = build2 (ops->code, ops->type, arg0, arg1);
   14053        27045 :       if (VECTOR_BOOLEAN_TYPE_P (ops->type)
   14054        54090 :           && expand_vec_cmp_expr_p (TREE_TYPE (arg0), ops->type, ops->code))
   14055        27045 :         return expand_vec_cmp_expr (ops->type, ifexp, target);
   14056              :       else
   14057            0 :         gcc_unreachable ();
   14058              :     }
   14059              : 
   14060              :   /* Optimize (x % C1) == C2 or (x % C1) != C2 if it is beneficial
   14061              :      into (x - C2) * C3 < C4.  */
   14062       615730 :   if ((ops->code == EQ_EXPR || ops->code == NE_EXPR)
   14063       422312 :       && TREE_CODE (arg0) == SSA_NAME
   14064       421735 :       && TREE_CODE (arg1) == INTEGER_CST)
   14065              :     {
   14066       254320 :       enum tree_code new_code = maybe_optimize_mod_cmp (ops->code,
   14067              :                                                         &arg0, &arg1);
   14068       254320 :       if (new_code != ops->code)
   14069              :         {
   14070          116 :           struct separate_ops nops = *ops;
   14071          116 :           nops.code = new_code;
   14072          116 :           nops.op0 = arg0;
   14073          116 :           nops.op1 = arg1;
   14074          116 :           nops.type = TREE_TYPE (arg0);
   14075          116 :           return do_store_flag (&nops, target, mode);
   14076              :         }
   14077              :     }
   14078              : 
   14079              :   /* Optimize (x - y) < 0 into x < y if x - y has undefined overflow.  */
   14080       615614 :   if (!unsignedp
   14081       442755 :       && (ops->code == LT_EXPR || ops->code == LE_EXPR
   14082       442755 :           || ops->code == GT_EXPR || ops->code == GE_EXPR)
   14083       119532 :       && integer_zerop (arg1)
   14084       654849 :       && TREE_CODE (arg0) == SSA_NAME)
   14085        39230 :     maybe_optimize_sub_cmp_0 (ops->code, &arg0, &arg1);
   14086              : 
   14087              :   /* Get the rtx comparison code to use.  We know that EXP is a comparison
   14088              :      operation of some type.  Some comparisons against 1 and -1 can be
   14089              :      converted to comparisons with zero.  Do so here so that the tests
   14090              :      below will be aware that we have a comparison with zero.   These
   14091              :      tests will not catch constants in the first operand, but constants
   14092              :      are rarely passed as the first operand.  */
   14093              : 
   14094       615614 :   switch (ops->code)
   14095              :     {
   14096              :     case EQ_EXPR:
   14097              :       code = EQ;
   14098              :       break;
   14099       239515 :     case NE_EXPR:
   14100       239515 :       code = NE;
   14101       239515 :       break;
   14102        34012 :     case LT_EXPR:
   14103        34012 :       if (integer_onep (arg1))
   14104            0 :         arg1 = integer_zero_node, code = unsignedp ? LEU : LE;
   14105              :       else
   14106        34012 :         code = unsignedp ? LTU : LT;
   14107              :       break;
   14108        33677 :     case LE_EXPR:
   14109        33677 :       if (! unsignedp && integer_all_onesp (arg1))
   14110            0 :         arg1 = integer_zero_node, code = LT;
   14111              :       else
   14112        33677 :         code = unsignedp ? LEU : LE;
   14113              :       break;
   14114        51328 :     case GT_EXPR:
   14115        51328 :       if (! unsignedp && integer_all_onesp (arg1))
   14116            0 :         arg1 = integer_zero_node, code = GE;
   14117              :       else
   14118        51328 :         code = unsignedp ? GTU : GT;
   14119              :       break;
   14120        49651 :     case GE_EXPR:
   14121        49651 :       if (integer_onep (arg1))
   14122            0 :         arg1 = integer_zero_node, code = unsignedp ? GTU : GT;
   14123              :       else
   14124        49651 :         code = unsignedp ? GEU : GE;
   14125              :       break;
   14126              : 
   14127         1043 :     case UNORDERED_EXPR:
   14128         1043 :       code = UNORDERED;
   14129         1043 :       break;
   14130          772 :     case ORDERED_EXPR:
   14131          772 :       code = ORDERED;
   14132          772 :       break;
   14133          573 :     case UNLT_EXPR:
   14134          573 :       code = UNLT;
   14135          573 :       break;
   14136        11139 :     case UNLE_EXPR:
   14137        11139 :       code = UNLE;
   14138        11139 :       break;
   14139         1019 :     case UNGT_EXPR:
   14140         1019 :       code = UNGT;
   14141         1019 :       break;
   14142         9939 :     case UNGE_EXPR:
   14143         9939 :       code = UNGE;
   14144         9939 :       break;
   14145          194 :     case UNEQ_EXPR:
   14146          194 :       code = UNEQ;
   14147          194 :       break;
   14148           71 :     case LTGT_EXPR:
   14149           71 :       code = LTGT;
   14150           71 :       break;
   14151              : 
   14152            0 :     default:
   14153            0 :       gcc_unreachable ();
   14154              :     }
   14155              : 
   14156              :   /* Put a constant second.  */
   14157       615614 :   if (TREE_CODE (arg0) == REAL_CST || TREE_CODE (arg0) == INTEGER_CST
   14158       613174 :       || TREE_CODE (arg0) == FIXED_CST)
   14159              :     {
   14160         2440 :       std::swap (arg0, arg1);
   14161         2440 :       code = swap_condition (code);
   14162              :     }
   14163              : 
   14164              :   /* If this is an equality or inequality test of a single bit, we can
   14165              :      do this by shifting the bit being tested to the low-order bit and
   14166              :      masking the result with the constant 1.  If the condition was EQ,
   14167              :      we xor it with 1.  This does not require an scc insn and is faster
   14168              :      than an scc insn even if we have it.  */
   14169              : 
   14170       615614 :   if ((code == NE || code == EQ)
   14171       422196 :       && (integer_zerop (arg1)
   14172       265981 :           || integer_pow2p (arg1))
   14173              :       /* vector types are not handled here. */
   14174       190033 :       && TREE_CODE (TREE_TYPE (arg1)) != VECTOR_TYPE
   14175       805616 :       && (TYPE_PRECISION (ops->type) != 1 || TYPE_UNSIGNED (ops->type)))
   14176              :     {
   14177       190002 :       tree narg0 = arg0;
   14178       190002 :       wide_int nz = tree_nonzero_bits (narg0);
   14179       190002 :       gassign *srcstmt = get_def_for_expr (narg0, BIT_AND_EXPR);
   14180              :       /* If the defining statement was (x & POW2), then use that instead of
   14181              :          the non-zero bits.  */
   14182       200360 :       if (srcstmt && integer_pow2p (gimple_assign_rhs2 (srcstmt)))
   14183              :         {
   14184        11424 :           nz = wi::to_wide (gimple_assign_rhs2 (srcstmt));
   14185         5712 :           narg0 = gimple_assign_rhs1 (srcstmt);
   14186              :         }
   14187              : 
   14188       190002 :       if (wi::popcount (nz) == 1
   14189       190002 :           && (integer_zerop (arg1)
   14190       190002 :               || wi::to_wide (arg1) == nz))
   14191              :         {
   14192        10169 :           int bitnum = wi::exact_log2 (nz);
   14193        10169 :           enum tree_code tcode = EQ_EXPR;
   14194        10169 :           if ((code == NE) ^ !integer_zerop (arg1))
   14195         7374 :             tcode = NE_EXPR;
   14196              : 
   14197        10169 :           type = lang_hooks.types.type_for_mode (mode, unsignedp);
   14198        10169 :           return expand_single_bit_test (loc, tcode,
   14199              :                                          narg0,
   14200              :                                          bitnum, type, target, mode);
   14201              :         }
   14202       190002 :     }
   14203              : 
   14204              : 
   14205       605445 :   if (! get_subtarget (target)
   14206       605445 :       || GET_MODE (subtarget) != operand_mode)
   14207              :     subtarget = 0;
   14208              : 
   14209       605445 :   expand_operands (arg0, arg1, subtarget, &op0, &op1, EXPAND_NORMAL);
   14210              : 
   14211              :   /* For boolean vectors with less than mode precision
   14212              :      make sure to fill padding with consistent values.  */
   14213           31 :   if (VECTOR_BOOLEAN_TYPE_P (type)
   14214           27 :       && SCALAR_INT_MODE_P (operand_mode)
   14215       605445 :       && TYPE_VECTOR_SUBPARTS (type).is_constant (&nunits)
   14216       605445 :       && maybe_ne (GET_MODE_PRECISION (operand_mode), nunits))
   14217              :     {
   14218            0 :       gcc_assert (code == EQ || code == NE);
   14219            0 :       op0 = expand_binop (mode, and_optab, op0,
   14220            0 :                           GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1),
   14221              :                           NULL_RTX, true, OPTAB_WIDEN);
   14222            0 :       op1 = expand_binop (mode, and_optab, op1,
   14223              :                           GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1),
   14224              :                           NULL_RTX, true, OPTAB_WIDEN);
   14225              :     }
   14226              : 
   14227       605445 :   if (target == 0)
   14228       414139 :     target = gen_reg_rtx (mode);
   14229              : 
   14230              :   /* Try a cstore if possible.  */
   14231       605445 :   return emit_store_flag_force (target, code, op0, op1,
   14232              :                                 operand_mode, unsignedp,
   14233       605445 :                                 (TYPE_PRECISION (ops->type) == 1
   14234      1210202 :                                  && !TYPE_UNSIGNED (ops->type)) ? -1 : 1);
   14235              : }
   14236              : 
   14237              : /* Attempt to generate a casesi instruction.  Returns true if successful,
   14238              :    false otherwise (i.e. if there is no casesi instruction).
   14239              : 
   14240              :    DEFAULT_PROBABILITY is the probability of jumping to the default
   14241              :    label.  */
   14242              : bool
   14243         7648 : try_casesi (tree index_type, tree index_expr, tree minval, tree range,
   14244              :             rtx_code_label *table_label, rtx_code_label *default_label,
   14245              :             rtx_insn *fallback_label, profile_probability default_probability)
   14246              : {
   14247         7648 :   class expand_operand ops[5];
   14248         7648 :   scalar_int_mode index_mode = SImode;
   14249         7648 :   rtx op1, op2, index;
   14250              : 
   14251         7648 :   if (! targetm.have_casesi ())
   14252              :     return false;
   14253              : 
   14254              :   /* The index must be some form of integer.  Convert it to SImode.  */
   14255            0 :   scalar_int_mode omode = SCALAR_INT_TYPE_MODE (index_type);
   14256            0 :   if (GET_MODE_BITSIZE (omode) > GET_MODE_BITSIZE (index_mode))
   14257              :     {
   14258            0 :       rtx rangertx = expand_normal (range);
   14259              : 
   14260              :       /* We must handle the endpoints in the original mode.  */
   14261            0 :       index_expr = build2 (MINUS_EXPR, index_type,
   14262              :                            index_expr, minval);
   14263            0 :       minval = integer_zero_node;
   14264            0 :       index = expand_normal (index_expr);
   14265            0 :       if (default_label)
   14266            0 :         emit_cmp_and_jump_insns (rangertx, index, LTU, NULL_RTX,
   14267              :                                  omode, 1, default_label,
   14268              :                                  default_probability);
   14269              :       /* Now we can safely truncate.  */
   14270            0 :       index = convert_to_mode (index_mode, index, 0);
   14271              :     }
   14272              :   else
   14273              :     {
   14274            0 :       if (omode != index_mode)
   14275              :         {
   14276            0 :           index_type = lang_hooks.types.type_for_mode (index_mode, 0);
   14277            0 :           index_expr = fold_convert (index_type, index_expr);
   14278              :         }
   14279              : 
   14280            0 :       index = expand_normal (index_expr);
   14281              :     }
   14282              : 
   14283            0 :   do_pending_stack_adjust ();
   14284              : 
   14285            0 :   op1 = expand_normal (minval);
   14286            0 :   op2 = expand_normal (range);
   14287              : 
   14288            0 :   create_input_operand (&ops[0], index, index_mode);
   14289            0 :   create_convert_operand_from_type (&ops[1], op1, TREE_TYPE (minval));
   14290            0 :   create_convert_operand_from_type (&ops[2], op2, TREE_TYPE (range));
   14291            0 :   create_fixed_operand (&ops[3], table_label);
   14292            0 :   create_fixed_operand (&ops[4], (default_label
   14293              :                                   ? default_label
   14294              :                                   : fallback_label));
   14295            0 :   expand_jump_insn (targetm.code_for_casesi, 5, ops);
   14296            0 :   return true;
   14297              : }
   14298              : 
   14299              : /* Attempt to generate a tablejump instruction; same concept.  */
   14300              : /* Subroutine of the next function.
   14301              : 
   14302              :    INDEX is the value being switched on, with the lowest value
   14303              :    in the table already subtracted.
   14304              :    MODE is its expected mode (needed if INDEX is constant).
   14305              :    RANGE is the length of the jump table.
   14306              :    TABLE_LABEL is a CODE_LABEL rtx for the table itself.
   14307              : 
   14308              :    DEFAULT_LABEL is a CODE_LABEL rtx to jump to if the
   14309              :    index value is out of range.
   14310              :    DEFAULT_PROBABILITY is the probability of jumping to
   14311              :    the default label.  */
   14312              : 
   14313              : static void
   14314         7648 : do_tablejump (rtx index, machine_mode mode, rtx range,
   14315              :               rtx_code_label *table_label, rtx_code_label *default_label,
   14316              :               profile_probability default_probability)
   14317              : {
   14318         7648 :   rtx temp, vector;
   14319              : 
   14320         7648 :   if (INTVAL (range) > cfun->cfg->max_jumptable_ents)
   14321         6353 :     cfun->cfg->max_jumptable_ents = INTVAL (range);
   14322              : 
   14323              :   /* Do an unsigned comparison (in the proper mode) between the index
   14324              :      expression and the value which represents the length of the range.
   14325              :      Since we just finished subtracting the lower bound of the range
   14326              :      from the index expression, this comparison allows us to simultaneously
   14327              :      check that the original index expression value is both greater than
   14328              :      or equal to the minimum value of the range and less than or equal to
   14329              :      the maximum value of the range.  */
   14330              : 
   14331         7648 :   if (default_label)
   14332         7571 :     emit_cmp_and_jump_insns (index, range, GTU, NULL_RTX, mode, 1,
   14333              :                              default_label, default_probability);
   14334              : 
   14335              :   /* If index is in range, it must fit in Pmode.
   14336              :      Convert to Pmode so we can index with it.  */
   14337         8723 :   if (mode != Pmode)
   14338              :     {
   14339         6578 :       unsigned int width;
   14340              : 
   14341              :       /* We know the value of INDEX is between 0 and RANGE.  If we have a
   14342              :          sign-extended subreg, and RANGE does not have the sign bit set, then
   14343              :          we have a value that is valid for both sign and zero extension.  In
   14344              :          this case, we get better code if we sign extend.  */
   14345         6578 :       if (GET_CODE (index) == SUBREG
   14346            9 :           && SUBREG_PROMOTED_VAR_P (index)
   14347            0 :           && SUBREG_PROMOTED_SIGNED_P (index)
   14348            0 :           && ((width = GET_MODE_PRECISION (as_a <scalar_int_mode> (mode)))
   14349              :               <= HOST_BITS_PER_WIDE_INT)
   14350         6578 :           && ! (UINTVAL (range) & (HOST_WIDE_INT_1U << (width - 1))))
   14351            0 :         index = convert_to_mode (Pmode, index, 0);
   14352              :       else
   14353         6578 :         index = convert_to_mode (Pmode, index, 1);
   14354              :     }
   14355              : 
   14356              :   /* Don't let a MEM slip through, because then INDEX that comes
   14357              :      out of PIC_CASE_VECTOR_ADDRESS won't be a valid address,
   14358              :      and break_out_memory_refs will go to work on it and mess it up.  */
   14359              : #ifdef PIC_CASE_VECTOR_ADDRESS
   14360              :   if (flag_pic && !REG_P (index))
   14361              :     index = copy_to_mode_reg (Pmode, index);
   14362              : #endif
   14363              : 
   14364              :   /* ??? The only correct use of CASE_VECTOR_MODE is the one inside the
   14365              :      GET_MODE_SIZE, because this indicates how large insns are.  The other
   14366              :      uses should all be Pmode, because they are addresses.  This code
   14367              :      could fail if addresses and insns are not the same size.  */
   14368         8723 :   index = simplify_gen_binary (MULT, Pmode, index,
   14369        15296 :                                gen_int_mode (GET_MODE_SIZE (CASE_VECTOR_MODE),
   14370         7648 :                                              Pmode));
   14371         8723 :   index = simplify_gen_binary (PLUS, Pmode, index,
   14372         7648 :                                gen_rtx_LABEL_REF (Pmode, table_label));
   14373              : 
   14374              : #ifdef PIC_CASE_VECTOR_ADDRESS
   14375              :   if (flag_pic)
   14376              :     index = PIC_CASE_VECTOR_ADDRESS (index);
   14377              :   else
   14378              : #endif
   14379         9367 :     index = memory_address (CASE_VECTOR_MODE, index);
   14380         9367 :   temp = gen_reg_rtx (CASE_VECTOR_MODE);
   14381         9367 :   vector = gen_const_mem (CASE_VECTOR_MODE, index);
   14382         7648 :   convert_move (temp, vector, 0);
   14383              : 
   14384         7648 :   emit_jump_insn (targetm.gen_tablejump (temp, table_label));
   14385              : 
   14386              :   /* If we are generating PIC code or if the table is PC-relative, the
   14387              :      table and JUMP_INSN must be adjacent, so don't output a BARRIER.  */
   14388         7648 :   if (! CASE_VECTOR_PC_RELATIVE && ! flag_pic)
   14389         6434 :     emit_barrier ();
   14390         7648 : }
   14391              : 
   14392              : bool
   14393         7648 : try_tablejump (tree index_type, tree index_expr, tree minval, tree range,
   14394              :                rtx_code_label *table_label, rtx_code_label *default_label,
   14395              :                profile_probability default_probability)
   14396              : {
   14397         7648 :   rtx index;
   14398              : 
   14399         7648 :   if (! targetm.have_tablejump ())
   14400              :     return false;
   14401              : 
   14402         7648 :   index_expr = fold_build2 (MINUS_EXPR, index_type,
   14403              :                             fold_convert (index_type, index_expr),
   14404              :                             fold_convert (index_type, minval));
   14405         7648 :   index = expand_normal (index_expr);
   14406         7648 :   do_pending_stack_adjust ();
   14407              : 
   14408         7648 :   do_tablejump (index, TYPE_MODE (index_type),
   14409         7648 :                 convert_modes (TYPE_MODE (index_type),
   14410         7648 :                                TYPE_MODE (TREE_TYPE (range)),
   14411              :                                expand_normal (range),
   14412         7648 :                                TYPE_UNSIGNED (TREE_TYPE (range))),
   14413              :                 table_label, default_label, default_probability);
   14414         7648 :   return true;
   14415              : }
   14416              : 
   14417              : /* Return a CONST_VECTOR rtx representing vector mask for
   14418              :    a VECTOR_CST of booleans.  */
   14419              : static rtx
   14420          691 : const_vector_mask_from_tree (tree exp)
   14421              : {
   14422          691 :   machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
   14423          691 :   machine_mode inner = GET_MODE_INNER (mode);
   14424              : 
   14425          691 :   rtx_vector_builder builder (mode, VECTOR_CST_NPATTERNS (exp),
   14426          691 :                               VECTOR_CST_NELTS_PER_PATTERN (exp));
   14427          691 :   unsigned int count = builder.encoded_nelts ();
   14428         3715 :   for (unsigned int i = 0; i < count; ++i)
   14429              :     {
   14430         3024 :       tree elt = VECTOR_CST_ELT (exp, i);
   14431         3024 :       gcc_assert (TREE_CODE (elt) == INTEGER_CST);
   14432         3024 :       if (integer_zerop (elt))
   14433         1190 :         builder.quick_push (CONST0_RTX (inner));
   14434         1834 :       else if (integer_onep (elt)
   14435         1834 :                || integer_minus_onep (elt))
   14436         1834 :         builder.quick_push (CONSTM1_RTX (inner));
   14437              :       else
   14438            0 :         gcc_unreachable ();
   14439              :     }
   14440          691 :   return builder.build ();
   14441          691 : }
   14442              : 
   14443              : /* Return a CONST_VECTOR rtx for a VECTOR_CST tree.  */
   14444              : static rtx
   14445       584325 : const_vector_from_tree (tree exp)
   14446              : {
   14447       584325 :   machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
   14448              : 
   14449       584325 :   if (initializer_zerop (exp))
   14450       168154 :     return CONST0_RTX (mode);
   14451              : 
   14452       416171 :   if (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (exp)))
   14453          691 :     return const_vector_mask_from_tree (exp);
   14454              : 
   14455       415480 :   machine_mode inner = GET_MODE_INNER (mode);
   14456              : 
   14457       415480 :   rtx_vector_builder builder (mode, VECTOR_CST_NPATTERNS (exp),
   14458       415480 :                               VECTOR_CST_NELTS_PER_PATTERN (exp));
   14459       415480 :   unsigned int count = builder.encoded_nelts ();
   14460      1331939 :   for (unsigned int i = 0; i < count; ++i)
   14461              :     {
   14462       916459 :       tree elt = VECTOR_CST_ELT (exp, i);
   14463       916459 :       if (TREE_CODE (elt) == REAL_CST)
   14464       138955 :         builder.quick_push (const_double_from_real_value (TREE_REAL_CST (elt),
   14465              :                                                           inner));
   14466       777504 :       else if (TREE_CODE (elt) == FIXED_CST)
   14467            0 :         builder.quick_push (CONST_FIXED_FROM_FIXED_VALUE (TREE_FIXED_CST (elt),
   14468              :                                                           inner));
   14469              :       else
   14470       777504 :         builder.quick_push (immed_wide_int_const (wi::to_poly_wide (elt),
   14471              :                                                   inner));
   14472              :     }
   14473       415480 :   return builder.build ();
   14474       415480 : }
   14475              : 
   14476              : /* Build a decl for a personality function given a language prefix.  */
   14477              : 
   14478              : tree
   14479        33060 : build_personality_function (const char *lang)
   14480              : {
   14481        33060 :   const char *unwind_and_version;
   14482        33060 :   tree decl, type;
   14483        33060 :   char *name;
   14484              : 
   14485        33060 :   switch (targetm_common.except_unwind_info (&global_options))
   14486              :     {
   14487              :     case UI_NONE:
   14488              :       return NULL;
   14489              :     case UI_SJLJ:
   14490              :       unwind_and_version = "_sj0";
   14491              :       break;
   14492        33060 :     case UI_DWARF2:
   14493        33060 :     case UI_TARGET:
   14494        33060 :       unwind_and_version = "_v0";
   14495        33060 :       break;
   14496            0 :     case UI_SEH:
   14497            0 :       unwind_and_version = "_seh0";
   14498            0 :       break;
   14499            0 :     default:
   14500            0 :       gcc_unreachable ();
   14501              :     }
   14502              : 
   14503        33060 :   name = ACONCAT (("__", lang, "_personality", unwind_and_version, NULL));
   14504              : 
   14505        33060 :   type = build_function_type_list (unsigned_type_node,
   14506              :                                    integer_type_node, integer_type_node,
   14507              :                                    long_long_unsigned_type_node,
   14508              :                                    ptr_type_node, ptr_type_node, NULL_TREE);
   14509        33060 :   decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
   14510              :                      get_identifier (name), type);
   14511        33060 :   DECL_ARTIFICIAL (decl) = 1;
   14512        33060 :   DECL_EXTERNAL (decl) = 1;
   14513        33060 :   TREE_PUBLIC (decl) = 1;
   14514              : 
   14515              :   /* Zap the nonsensical SYMBOL_REF_DECL for this.  What we're left with
   14516              :      are the flags assigned by targetm.encode_section_info.  */
   14517        33060 :   SET_SYMBOL_REF_DECL (XEXP (DECL_RTL (decl), 0), NULL);
   14518              : 
   14519        33060 :   return decl;
   14520              : }
   14521              : 
   14522              : /* Extracts the personality function of DECL and returns the corresponding
   14523              :    libfunc.  */
   14524              : 
   14525              : rtx
   14526      1682271 : get_personality_function (tree decl)
   14527              : {
   14528      1682271 :   tree personality = DECL_FUNCTION_PERSONALITY (decl);
   14529      1682271 :   enum eh_personality_kind pk;
   14530              : 
   14531      1682271 :   pk = function_needs_eh_personality (DECL_STRUCT_FUNCTION (decl));
   14532      1682271 :   if (pk == eh_personality_none)
   14533              :     return NULL;
   14534              : 
   14535       159912 :   if (!personality
   14536       159912 :       && pk == eh_personality_any)
   14537        72790 :     personality = lang_hooks.eh_personality ();
   14538              : 
   14539       159912 :   if (pk == eh_personality_lang)
   14540        87122 :     gcc_assert (personality != NULL_TREE);
   14541              : 
   14542       159912 :   return XEXP (DECL_RTL (personality), 0);
   14543              : }
   14544              : 
   14545              : /* Returns a tree for the size of EXP in bytes.  */
   14546              : 
   14547              : static tree
   14548     15006204 : tree_expr_size (const_tree exp)
   14549              : {
   14550     15006204 :   if (DECL_P (exp)
   14551     15006204 :       && DECL_SIZE_UNIT (exp) != 0)
   14552      1967730 :     return DECL_SIZE_UNIT (exp);
   14553              :   else
   14554     13038474 :     return size_in_bytes (TREE_TYPE (exp));
   14555              : }
   14556              : 
   14557              : /* Return an rtx for the size in bytes of the value of EXP.  */
   14558              : 
   14559              : rtx
   14560     14989615 : expr_size (tree exp)
   14561              : {
   14562     14989615 :   tree size;
   14563              : 
   14564     14989615 :   if (TREE_CODE (exp) == WITH_SIZE_EXPR)
   14565          773 :     size = TREE_OPERAND (exp, 1);
   14566              :   else
   14567              :     {
   14568     14988842 :       size = tree_expr_size (exp);
   14569     14988842 :       gcc_assert (size);
   14570     14988842 :       gcc_assert (size == SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, exp));
   14571              :     }
   14572              : 
   14573     14989615 :   return expand_expr (size, NULL_RTX, TYPE_MODE (sizetype), EXPAND_NORMAL);
   14574              : }
   14575              : 
   14576              : /* Return a wide integer for the size in bytes of the value of EXP, or -1
   14577              :    if the size can vary or is larger than an integer.  */
   14578              : 
   14579              : HOST_WIDE_INT
   14580        17362 : int_expr_size (const_tree exp)
   14581              : {
   14582        17362 :   tree size;
   14583              : 
   14584        17362 :   if (TREE_CODE (exp) == WITH_SIZE_EXPR)
   14585            0 :     size = TREE_OPERAND (exp, 1);
   14586              :   else
   14587              :     {
   14588        17362 :       size = tree_expr_size (exp);
   14589        17362 :       gcc_assert (size);
   14590              :     }
   14591              : 
   14592        17362 :   if (size == 0 || !tree_fits_shwi_p (size))
   14593              :     return -1;
   14594              : 
   14595        17362 :   return tree_to_shwi (size);
   14596              : }
   14597              : 
   14598              : /* Return the quotient of polynomial long division of x^2N by POLYNOMIAL
   14599              :    in GF (2^N).
   14600              :    Author: Richard Sandiford <richard.sandiford@arm.com>  */
   14601              : 
   14602              : unsigned HOST_WIDE_INT
   14603           32 : gf2n_poly_long_div_quotient (unsigned HOST_WIDE_INT polynomial,
   14604              :                              unsigned short n)
   14605              : {
   14606              :   /* The result has degree N, so needs N + 1 bits.
   14607              :      For 64-bit CRC, compute the lower 64 bits of the division.
   14608              :      The 65th bit is 1 since the leading bit of polynomial is 1.  */
   14609           32 :   gcc_assert (n <= 64);
   14610              : 
   14611              :   /* Perform a division step for the x^2N coefficient.  At this point the
   14612              :      quotient and remainder have N implicit trailing zeros.  */
   14613              :   unsigned HOST_WIDE_INT quotient = 1;
   14614              :   unsigned HOST_WIDE_INT remainder = polynomial;
   14615              : 
   14616              :   /* Process the coefficients for x^(2N-1) down to x^N, with each step
   14617              :      reducing the number of implicit trailing zeros by one.  */
   14618         1536 :   for (unsigned int i = 0; i < n; ++i)
   14619              :     {
   14620         1504 :       bool coeff = remainder & (HOST_WIDE_INT_1U << (n - 1));
   14621         1504 :       quotient = (quotient << 1) | coeff;
   14622         2202 :       remainder = (remainder << 1) ^ (coeff ? polynomial : 0);
   14623              :     }
   14624           32 :   return quotient;
   14625              : }
   14626              : 
   14627              : /* Assemble CRC table with 256 elements for the given POLYNOM and CRC_BITS.
   14628              :    POLYNOM is the polynomial used to calculate the CRC table's elements.
   14629              :    CRC_BITS is the size of CRC, may be 8, 16, ... . */
   14630              : 
   14631              : static rtx
   14632          180 : assemble_crc_table (unsigned HOST_WIDE_INT polynom, unsigned short crc_bits)
   14633              : {
   14634          180 :   unsigned table_el_n = 0x100;
   14635          180 :   tree ar = build_array_type (make_unsigned_type (crc_bits),
   14636          180 :                               build_index_type (size_int (table_el_n - 1)));
   14637              : 
   14638              :   /* Initialize the table.  */
   14639          180 :   vec<tree, va_gc> *initial_values;
   14640          180 :   vec_alloc (initial_values, table_el_n);
   14641        46440 :   for (size_t i = 0; i < table_el_n; ++i)
   14642              :     {
   14643        46080 :       unsigned HOST_WIDE_INT crc = calculate_crc (0, i, polynom, crc_bits, 8);
   14644        46080 :       tree element = build_int_cstu (make_unsigned_type (crc_bits), crc);
   14645        46080 :       vec_safe_push (initial_values, element);
   14646              :     }
   14647          180 :   tree ctor = build_constructor_from_vec (ar, initial_values);
   14648          180 :   rtx mem = output_constant_def (ctor, 1);
   14649          180 :   gcc_assert (MEM_P (mem));
   14650          180 :   if (dump_file && (dump_flags & TDF_DETAILS))
   14651              :     {
   14652           16 :       fprintf (dump_file,
   14653              :                ";; emitting crc table crc_%u_polynomial_"
   14654              :                HOST_WIDE_INT_PRINT_HEX " ",
   14655              :                crc_bits, polynom);
   14656           16 :       print_rtl_single (dump_file, XEXP (mem, 0));
   14657           16 :       fprintf (dump_file, "\n");
   14658              :     }
   14659              : 
   14660          180 :   return XEXP (mem, 0);
   14661              : }
   14662              : 
   14663              : /* Generate CRC lookup table by calculating CRC for all possible
   14664              :    8-bit data values.  The table is stored with a specific name in the read-only
   14665              :    static data section.
   14666              :    POLYNOM is the polynomial used to calculate the CRC table's elements.
   14667              :    CRC_BITS is the size of CRC, may be 8, 16, ... .  */
   14668              : 
   14669              : static rtx
   14670          180 : generate_crc_table (unsigned HOST_WIDE_INT polynom, unsigned short crc_bits)
   14671              : {
   14672          180 :   gcc_assert (crc_bits <= 64);
   14673              : 
   14674          180 :   return assemble_crc_table (polynom, crc_bits);
   14675              : }
   14676              : 
   14677              : /* Assemble CRC table with 256 elements for the given POLYNOM and CRC_BITS.
   14678              :    POLYNOM is the polynomial used to calculate the CRC table's elements.
   14679              :    CRC_BITS is the size of CRC, may be 8, 16, ... . */
   14680              : 
   14681              : static rtx
   14682          178 : assemble_reversed_crc_table (unsigned HOST_WIDE_INT polynom, unsigned short crc_bits)
   14683              : {
   14684          178 :   unsigned table_el_n = 0x100;
   14685          178 :   tree ar = build_array_type (make_unsigned_type (crc_bits),
   14686          178 :                               build_index_type (size_int (table_el_n - 1)));
   14687              : 
   14688              :   /* Initialize the table.  */
   14689          178 :   vec<tree, va_gc> *initial_values;
   14690          178 :   vec_alloc (initial_values, table_el_n);
   14691        45924 :   for (size_t i = 0; i < table_el_n; ++i)
   14692              :     {
   14693        45568 :       unsigned HOST_WIDE_INT crc = calculate_reversed_crc (0, i, polynom,
   14694        45568 :                                                            crc_bits, 8);
   14695        45568 :       tree element = build_int_cstu (make_unsigned_type (crc_bits), crc);
   14696        45568 :       vec_safe_push (initial_values, element);
   14697              :     }
   14698          178 :   tree ctor = build_constructor_from_vec (ar, initial_values);
   14699          178 :   rtx mem = output_constant_def (ctor, 1);
   14700          178 :   gcc_assert (MEM_P (mem));
   14701          178 :   if (dump_file && (dump_flags & TDF_DETAILS))
   14702              :     {
   14703           16 :       fprintf (dump_file,
   14704              :                ";; emitting reversed crc table crc_%u_polynomial_"
   14705              :                HOST_WIDE_INT_PRINT_HEX " ",
   14706              :                crc_bits, polynom);
   14707           16 :       print_rtl_single (dump_file, XEXP (mem, 0));
   14708           16 :       fprintf (dump_file, "\n");
   14709              :     }
   14710              : 
   14711          178 :   return XEXP (mem, 0);
   14712              : }
   14713              : 
   14714              : /* Generate reversed CRC table for the given POLYNOM and CRC_BITS.  */
   14715              : 
   14716              : static rtx
   14717          178 : generate_reversed_crc_table (unsigned HOST_WIDE_INT polynom,
   14718              :                              unsigned short crc_bits)
   14719              : {
   14720          178 :   gcc_assert (crc_bits <= 64);
   14721              : 
   14722          178 :   return assemble_reversed_crc_table (polynom, crc_bits);
   14723              : }
   14724              : 
   14725              : /* Generate table-based CRC code for the given CRC, INPUT_DATA and the
   14726              :    POLYNOMIAL (without leading 1).
   14727              : 
   14728              :    First, using POLYNOMIAL's value generates CRC table of 256 elements,
   14729              :    then generates the assembly for the following code,
   14730              :    where crc_bit_size may be 8, 16, 32, 64 and data_bit_size multiple of 8,
   14731              :    depending on CRC:
   14732              : 
   14733              :      for (int i = 0; i < data_bit_size / 8; i++)
   14734              :        crc = (crc << 8) ^ crc_table[(crc >> (crc_bit_size - 8))
   14735              :                                     ^ (data >> (data_bit_size - (i + 1) * 8)
   14736              :                                     & 0xFF))];
   14737              : 
   14738              :    So to take values from the table, we need 8-bit data.
   14739              :    If input data size is not 8, then first we extract upper 8 bits,
   14740              :    then the other 8 bits, and so on.  */
   14741              : 
   14742              : static void
   14743          180 : calculate_table_based_CRC (rtx *crc, const rtx &input_data,
   14744              :                            const rtx &polynomial,
   14745              :                            unsigned short data_bit_size)
   14746              : {
   14747          180 :   machine_mode mode = GET_MODE (*crc);
   14748          180 :   unsigned short crc_bit_size = GET_MODE_BITSIZE (mode).to_constant ();
   14749          180 :   gcc_assert (data_bit_size % 8 == 0);
   14750          180 :   unsigned short data_size = data_bit_size / 8;
   14751          180 :   rtx tab = generate_crc_table (UINTVAL (polynomial), crc_bit_size);
   14752              : 
   14753          740 :   for (unsigned short i = 0; i < data_size; i++)
   14754              :     {
   14755              :       /* crc >> (crc_bit_size - 8).  */
   14756          380 :       *crc = force_reg (mode, *crc);
   14757          380 :       rtx op1 = expand_shift (RSHIFT_EXPR, mode, *crc, crc_bit_size - 8,
   14758              :                               NULL_RTX, 1);
   14759              : 
   14760              :       /* data >> (8 * (data_size - i - 1)).  */
   14761          380 :       unsigned range_8 = 8 * (data_size - i - 1);
   14762              :       /* CRC's mode is always at least as wide as INPUT_DATA.  Convert
   14763              :          INPUT_DATA into CRC's mode.  */
   14764          380 :       rtx data = gen_reg_rtx (mode);
   14765          380 :       convert_move (data, input_data, 1);
   14766          380 :       data = expand_shift (RSHIFT_EXPR, mode, data, range_8, NULL_RTX, 1);
   14767              : 
   14768              :       /* data >> (8 * (data_size - i - 1)) & 0xFF.  */
   14769          380 :       rtx data_final = expand_and (mode, data,
   14770              :                                    gen_int_mode (255, mode), NULL_RTX);
   14771              : 
   14772              :       /* (crc >> (crc_bit_size - 8)) ^ data_8bit.  */
   14773          380 :       rtx in = expand_binop (mode, xor_optab, op1, data_final,
   14774              :                              NULL_RTX, 1, OPTAB_WIDEN);
   14775              : 
   14776              :       /* ((crc >> (crc_bit_size - 8)) ^ data_8bit) & 0xFF.  */
   14777          380 :       rtx index = expand_and (mode, in, gen_int_mode (255, mode),
   14778              :                               NULL_RTX);
   14779          760 :       int log_crc_size = exact_log2 (GET_MODE_SIZE (mode).to_constant ());
   14780          380 :       index = expand_shift (LSHIFT_EXPR, mode, index,
   14781          380 :                             log_crc_size, NULL_RTX, 0);
   14782              : 
   14783          385 :       rtx addr = gen_reg_rtx (Pmode);
   14784          380 :       convert_move (addr, index, 1);
   14785          385 :       addr = expand_binop (Pmode, add_optab, addr, tab, NULL_RTX,
   14786              :                             0, OPTAB_DIRECT);
   14787              : 
   14788              :       /* crc_table[(crc >> (crc_bit_size - 8)) ^ data_8bit]  */
   14789          380 :       rtx tab_el = validize_mem (gen_rtx_MEM (mode, addr));
   14790              : 
   14791              :       /* (crc << 8) if CRC is larger than 8, otherwise crc = 0.  */
   14792          380 :       rtx high = NULL_RTX;
   14793          380 :       if (crc_bit_size != 8)
   14794          343 :         high = expand_shift (LSHIFT_EXPR, mode, *crc, 8, NULL_RTX, 0);
   14795              :       else
   14796           37 :         high = gen_int_mode (0, mode);
   14797              : 
   14798              :       /* crc = (crc << 8)
   14799              :                ^ crc_table[(crc >> (crc_bit_size - 8)) ^ data_8bit];  */
   14800          380 :       *crc = expand_binop (mode, xor_optab, tab_el, high, NULL_RTX, 1,
   14801              :                            OPTAB_WIDEN);
   14802              :     }
   14803          180 : }
   14804              : 
   14805              : /* Generate table-based reversed CRC code for the given CRC, INPUT_DATA
   14806              :    and the POLYNOMIAL (without leading 1).
   14807              : 
   14808              :    This function generates code for reversed (bit-reflected) CRC calculation
   14809              :    using a pre-computed lookup table.  Unlike the standard CRC calculation,
   14810              :    this processes data from LSB to MSB, eliminating the need for explicit
   14811              :    bit reflection before and after the CRC computation.  */
   14812              : 
   14813              : static void
   14814          178 : calculate_table_based_reversed_CRC (rtx *crc, const rtx &input_data,
   14815              :                                     const rtx &polynomial,
   14816              :                                     unsigned short data_bit_size)
   14817              : {
   14818          178 :   machine_mode mode = GET_MODE (*crc);
   14819          178 :   unsigned short crc_bit_size = GET_MODE_BITSIZE (mode).to_constant ();
   14820          178 :   gcc_assert (data_bit_size % 8 == 0);
   14821          178 :   unsigned short data_size = data_bit_size / 8;
   14822          178 :   rtx tab = generate_reversed_crc_table (UINTVAL (polynomial), crc_bit_size);
   14823              : 
   14824              :   /* CRC's mode is always at least as wide as INPUT_DATA.  Convert
   14825              :      INPUT_DATA into CRC's mode once outside the loop since INPUT_DATA
   14826              :      is loop-invariant.  */
   14827          178 :   rtx data_in_crc_mode = gen_reg_rtx (mode);
   14828          178 :   convert_move (data_in_crc_mode, input_data, 1);
   14829              : 
   14830          704 :   for (unsigned short i = 0; i < data_size; i++)
   14831              :     {
   14832          348 :       *crc = force_reg (mode, *crc);
   14833              : 
   14834              :       /* data >> (8 * i).  */
   14835          348 :       unsigned range_8 = 8 * i;
   14836          348 :       rtx data = expand_shift (RSHIFT_EXPR, mode, data_in_crc_mode,
   14837          348 :                                range_8, NULL_RTX, 1);
   14838              : 
   14839              :       /* crc ^ (data >> (8 * i)).  */
   14840          348 :       rtx in = expand_binop (mode, xor_optab, *crc, data,
   14841              :                              NULL_RTX, 1, OPTAB_WIDEN);
   14842              : 
   14843              :       /* (crc ^ data) & 0xFF.  */
   14844          348 :       rtx index = expand_and (mode, in, gen_int_mode (255, mode),
   14845              :                               NULL_RTX);
   14846          696 :       int log_crc_size = exact_log2 (GET_MODE_SIZE (mode).to_constant ());
   14847          348 :       index = expand_shift (LSHIFT_EXPR, mode, index,
   14848          348 :                             log_crc_size, NULL_RTX, 0);
   14849              : 
   14850          361 :       rtx addr = gen_reg_rtx (Pmode);
   14851          348 :       convert_move (addr, index, 1);
   14852          361 :       addr = expand_binop (Pmode, add_optab, addr, tab, NULL_RTX,
   14853              :                             0, OPTAB_DIRECT);
   14854              : 
   14855              :       /* crc_table[(crc ^ data) & 0xFF].  */
   14856          348 :       rtx tab_el = validize_mem (gen_rtx_MEM (mode, addr));
   14857              : 
   14858              :       /* (crc >> 8) if CRC is larger than 8, otherwise 0.  */
   14859          348 :       rtx high = NULL_RTX;
   14860          348 :       if (crc_bit_size != 8)
   14861          337 :         high = expand_shift (RSHIFT_EXPR, mode, *crc, 8, NULL_RTX, 1);
   14862              :       else
   14863           11 :         high = gen_int_mode (0, mode);
   14864              : 
   14865              :       /* crc = (crc >> 8) ^ crc_table[(crc ^ data) & 0xFF].  */
   14866          348 :       *crc = expand_binop (mode, xor_optab, tab_el, high, NULL_RTX, 1,
   14867              :                            OPTAB_WIDEN);
   14868              :     }
   14869          178 : }
   14870              : 
   14871              : /* Generate table-based CRC code for the given CRC, INPUT_DATA and the
   14872              :    POLYNOMIAL (without leading 1).
   14873              : 
   14874              :    CRC is OP1, data is OP2 and the polynomial is OP3.
   14875              :    This must generate a CRC table and an assembly for the following code,
   14876              :    where crc_bit_size may be 8, 16, 32, 64 and data_bit_size multiple of 8:
   14877              :    uint_crc_bit_size_t
   14878              :    crc_crc_bit_size (uint_crc_bit_size_t crc_init,
   14879              :                      uint_data_bit_size_t data, size_t size)
   14880              :    {
   14881              :      uint_crc_bit_size_t crc = crc_init;
   14882              :      for (int i = 0; i < data_bit_size / 8; i++)
   14883              :        crc = (crc << 8) ^ crc_table[(crc >> (crc_bit_size - 8))
   14884              :                                     ^ (data >> (data_bit_size - (i + 1) * 8)
   14885              :                                     & 0xFF))];
   14886              :      return crc;
   14887              :    }  */
   14888              : 
   14889              : void
   14890          180 : expand_crc_table_based (rtx op0, rtx op1, rtx op2, rtx op3,
   14891              :                         unsigned short data_bit_size)
   14892              : {
   14893          180 :   gcc_assert (!CONST_INT_P (op0));
   14894          180 :   gcc_assert (CONST_INT_P (op3));
   14895          180 :   machine_mode crc_mode = GET_MODE (op0);
   14896          180 :   rtx crc = gen_reg_rtx (crc_mode);
   14897          180 :   convert_move (crc, op1, 0);
   14898          180 :   calculate_table_based_CRC (&crc, op2, op3, data_bit_size);
   14899          180 :   convert_move (op0, crc, 0);
   14900          180 : }
   14901              : 
   14902              : /* Generate table-based reversed CRC code for the given CRC, INPUT_DATA and
   14903              :    the POLYNOMIAL (without leading 1).
   14904              : 
   14905              :    CRC is OP1, data is OP2 and the polynomial is OP3.
   14906              :    This generates a reversed CRC table and assembly for the following code,
   14907              :    where crc_bit_size may be 8, 16, 32, 64 and data_bit_size multiple of 8:
   14908              :    uint_crc_bit_size_t
   14909              :    crc_crc_bit_size (uint_crc_bit_size_t crc_init,
   14910              :                      uint_data_bit_size_t data)
   14911              :    {
   14912              :      uint_crc_bit_size_t crc = crc_init;
   14913              :      for (int i = 0; i < data_bit_size / 8; i++)
   14914              :        crc = (crc >> 8) ^ crc_table[(crc ^ (data >> (i * 8))) & 0xFF];
   14915              :      return crc;
   14916              :    }
   14917              : 
   14918              :    This approach uses a pre-computed reversed polynomial table, eliminating
   14919              :    the need for explicit bit reflection before and after the CRC computation.  */
   14920              : 
   14921              : void
   14922          178 : expand_reversed_crc_table_based (rtx op0, rtx op1, rtx op2, rtx op3,
   14923              :                                  unsigned short data_bit_size)
   14924              : {
   14925          178 :   gcc_assert (!CONST_INT_P (op0));
   14926          178 :   gcc_assert (CONST_INT_P (op3));
   14927          178 :   machine_mode crc_mode = GET_MODE (op0);
   14928          178 :   rtx crc = gen_reg_rtx (crc_mode);
   14929          178 :   convert_move (crc, op1, 0);
   14930          178 :   calculate_table_based_reversed_CRC (&crc, op2, op3, data_bit_size);
   14931          178 :   convert_move (op0, crc, 0);
   14932          178 : }
        

Generated by: LCOV version 2.6-beta

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