LCOV - code coverage report
Current view: top level - gcc - rtlanal.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 86.0 % 2781 2391
Test Date: 2025-02-01 13:18:56 Functions: 88.3 % 171 151
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Analyze RTL for GNU compiler.
       2                 :             :    Copyright (C) 1987-2025 Free Software Foundation, Inc.
       3                 :             : 
       4                 :             : This file is part of GCC.
       5                 :             : 
       6                 :             : GCC is free software; you can redistribute it and/or modify it under
       7                 :             : the terms of the GNU General Public License as published by the Free
       8                 :             : Software Foundation; either version 3, or (at your option) any later
       9                 :             : version.
      10                 :             : 
      11                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14                 :             : for more details.
      15                 :             : 
      16                 :             : You should have received a copy of the GNU General Public License
      17                 :             : along with GCC; see the file COPYING3.  If not see
      18                 :             : <http://www.gnu.org/licenses/>.  */
      19                 :             : 
      20                 :             : 
      21                 :             : #include "config.h"
      22                 :             : #include "system.h"
      23                 :             : #include "coretypes.h"
      24                 :             : #include "backend.h"
      25                 :             : #include "target.h"
      26                 :             : #include "rtl.h"
      27                 :             : #include "rtlanal.h"
      28                 :             : #include "tree.h"
      29                 :             : #include "predict.h"
      30                 :             : #include "df.h"
      31                 :             : #include "memmodel.h"
      32                 :             : #include "tm_p.h"
      33                 :             : #include "insn-config.h"
      34                 :             : #include "regs.h"
      35                 :             : #include "emit-rtl.h"  /* FIXME: Can go away once crtl is moved to rtl.h.  */
      36                 :             : #include "recog.h"
      37                 :             : #include "addresses.h"
      38                 :             : #include "rtl-iter.h"
      39                 :             : #include "hard-reg-set.h"
      40                 :             : #include "function-abi.h"
      41                 :             : 
      42                 :             : /* Forward declarations */
      43                 :             : static void set_of_1 (rtx, const_rtx, void *);
      44                 :             : static bool covers_regno_p (const_rtx, unsigned int);
      45                 :             : static bool covers_regno_no_parallel_p (const_rtx, unsigned int);
      46                 :             : static bool computed_jump_p_1 (const_rtx);
      47                 :             : static void parms_set (rtx, const_rtx, void *);
      48                 :             : 
      49                 :             : static unsigned HOST_WIDE_INT cached_nonzero_bits (const_rtx, scalar_int_mode,
      50                 :             :                                                    const_rtx, machine_mode,
      51                 :             :                                                    unsigned HOST_WIDE_INT);
      52                 :             : static unsigned HOST_WIDE_INT nonzero_bits1 (const_rtx, scalar_int_mode,
      53                 :             :                                              const_rtx, machine_mode,
      54                 :             :                                              unsigned HOST_WIDE_INT);
      55                 :             : static unsigned int cached_num_sign_bit_copies (const_rtx, scalar_int_mode,
      56                 :             :                                                 const_rtx, machine_mode,
      57                 :             :                                                 unsigned int);
      58                 :             : static unsigned int num_sign_bit_copies1 (const_rtx, scalar_int_mode,
      59                 :             :                                           const_rtx, machine_mode,
      60                 :             :                                           unsigned int);
      61                 :             : 
      62                 :             : rtx_subrtx_bound_info rtx_all_subrtx_bounds[NUM_RTX_CODE];
      63                 :             : rtx_subrtx_bound_info rtx_nonconst_subrtx_bounds[NUM_RTX_CODE];
      64                 :             : 
      65                 :             : /* Truncation narrows the mode from SOURCE mode to DESTINATION mode.
      66                 :             :    If TARGET_MODE_REP_EXTENDED (DESTINATION, DESTINATION_REP) is
      67                 :             :    SIGN_EXTEND then while narrowing we also have to enforce the
      68                 :             :    representation and sign-extend the value to mode DESTINATION_REP.
      69                 :             : 
      70                 :             :    If the value is already sign-extended to DESTINATION_REP mode we
      71                 :             :    can just switch to DESTINATION mode on it.  For each pair of
      72                 :             :    integral modes SOURCE and DESTINATION, when truncating from SOURCE
      73                 :             :    to DESTINATION, NUM_SIGN_BIT_COPIES_IN_REP[SOURCE][DESTINATION]
      74                 :             :    contains the number of high-order bits in SOURCE that have to be
      75                 :             :    copies of the sign-bit so that we can do this mode-switch to
      76                 :             :    DESTINATION.  */
      77                 :             : 
      78                 :             : static unsigned int
      79                 :             : num_sign_bit_copies_in_rep[MAX_MODE_INT + 1][MAX_MODE_INT + 1];
      80                 :             : 
      81                 :             : /* Store X into index I of ARRAY.  ARRAY is known to have at least I
      82                 :             :    elements.  Return the new base of ARRAY.  */
      83                 :             : 
      84                 :             : template <typename T>
      85                 :             : typename T::value_type *
      86                 :     8021183 : generic_subrtx_iterator <T>::add_single_to_queue (array_type &array,
      87                 :             :                                                   value_type *base,
      88                 :             :                                                   size_t i, value_type x)
      89                 :             : {
      90                 :     8021183 :   if (base == array.stack)
      91                 :             :     {
      92                 :     4188077 :       if (i < LOCAL_ELEMS)
      93                 :             :         {
      94                 :     3917606 :           base[i] = x;
      95                 :     3917606 :           return base;
      96                 :             :         }
      97                 :      270471 :       gcc_checking_assert (i == LOCAL_ELEMS);
      98                 :             :       /* A previous iteration might also have moved from the stack to the
      99                 :             :          heap, in which case the heap array will already be big enough.  */
     100                 :      270471 :       if (vec_safe_length (array.heap) <= i)
     101                 :      270471 :         vec_safe_grow (array.heap, i + 1, true);
     102                 :      270471 :       base = array.heap->address ();
     103                 :      270471 :       memcpy (base, array.stack, sizeof (array.stack));
     104                 :      270471 :       base[LOCAL_ELEMS] = x;
     105                 :      270471 :       return base;
     106                 :             :     }
     107                 :     3833106 :   unsigned int length = array.heap->length ();
     108                 :     3833106 :   if (length > i)
     109                 :             :     {
     110                 :     1156393 :       gcc_checking_assert (base == array.heap->address ());
     111                 :     1156393 :       base[i] = x;
     112                 :     1156393 :       return base;
     113                 :             :     }
     114                 :             :   else
     115                 :             :     {
     116                 :     2676713 :       gcc_checking_assert (i == length);
     117                 :     2676713 :       vec_safe_push (array.heap, x);
     118                 :     2676713 :       return array.heap->address ();
     119                 :             :     }
     120                 :             : }
     121                 :             : 
     122                 :             : /* Add the subrtxes of X to worklist ARRAY, starting at END.  Return the
     123                 :             :    number of elements added to the worklist.  */
     124                 :             : 
     125                 :             : template <typename T>
     126                 :             : size_t
     127                 :   309914283 : generic_subrtx_iterator <T>::add_subrtxes_to_queue (array_type &array,
     128                 :             :                                                     value_type *base,
     129                 :             :                                                     size_t end, rtx_type x)
     130                 :             : {
     131                 :   309914283 :   enum rtx_code code = GET_CODE (x);
     132                 :   309914283 :   const char *format = GET_RTX_FORMAT (code);
     133                 :   309914283 :   size_t orig_end = end;
     134                 :   309914283 :   if (UNLIKELY (INSN_P (x)))
     135                 :             :     {
     136                 :             :       /* Put the pattern at the top of the queue, since that's what
     137                 :             :          we're likely to want most.  It also allows for the SEQUENCE
     138                 :             :          code below.  */
     139                 :       75329 :       for (int i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; --i)
     140                 :       66168 :         if (format[i] == 'e')
     141                 :             :           {
     142                 :       19044 :             value_type subx = T::get_value (x->u.fld[i].rt_rtx);
     143                 :       19044 :             if (LIKELY (end < LOCAL_ELEMS))
     144                 :       19044 :               base[end++] = subx;
     145                 :             :             else
     146                 :           0 :               base = add_single_to_queue (array, base, end++, subx);
     147                 :             :           }
     148                 :             :     }
     149                 :             :   else
     150                 :   673862095 :     for (int i = 0; format[i]; ++i)
     151                 :   363956973 :       if (format[i] == 'e')
     152                 :             :         {
     153                 :      508035 :           value_type subx = T::get_value (x->u.fld[i].rt_rtx);
     154                 :      508035 :           if (LIKELY (end < LOCAL_ELEMS))
     155                 :           0 :             base[end++] = subx;
     156                 :             :           else
     157                 :      508035 :             base = add_single_to_queue (array, base, end++, subx);
     158                 :             :         }
     159                 :   363448938 :       else if (format[i] == 'E')
     160                 :             :         {
     161                 :   315609705 :           unsigned int length = GET_NUM_ELEM (x->u.fld[i].rt_rtvec);
     162                 :   315609705 :           rtx *vec = x->u.fld[i].rt_rtvec->elem;
     163                 :   315609705 :           if (LIKELY (end + length <= LOCAL_ELEMS))
     164                 :   965941204 :             for (unsigned int j = 0; j < length; j++)
     165                 :   650684234 :               base[end++] = T::get_value (vec[j]);
     166                 :             :           else
     167                 :     7865883 :             for (unsigned int j = 0; j < length; j++)
     168                 :     7513148 :               base = add_single_to_queue (array, base, end++,
     169                 :     7513148 :                                           T::get_value (vec[j]));
     170                 :   315609705 :           if (code == SEQUENCE && end == length)
     171                 :             :             /* If the subrtxes of the sequence fill the entire array then
     172                 :             :                we know that no other parts of a containing insn are queued.
     173                 :             :                The caller is therefore iterating over the sequence as a
     174                 :             :                PATTERN (...), so we also want the patterns of the
     175                 :             :                subinstructions.  */
     176                 :           0 :             for (unsigned int j = 0; j < length; j++)
     177                 :             :               {
     178                 :           0 :                 typename T::rtx_type x = T::get_rtx (base[j]);
     179                 :           0 :                 if (INSN_P (x))
     180                 :           0 :                   base[j] = T::get_value (PATTERN (x));
     181                 :             :               }
     182                 :             :         }
     183                 :   309914283 :   return end - orig_end;
     184                 :             : }
     185                 :             : 
     186                 :             : template <typename T>
     187                 :             : void
     188                 :      270471 : generic_subrtx_iterator <T>::free_array (array_type &array)
     189                 :             : {
     190                 :      270471 :   vec_free (array.heap);
     191                 :      270471 : }
     192                 :             : 
     193                 :             : template <typename T>
     194                 :             : const size_t generic_subrtx_iterator <T>::LOCAL_ELEMS;
     195                 :             : 
     196                 :             : template class generic_subrtx_iterator <const_rtx_accessor>;
     197                 :             : template class generic_subrtx_iterator <rtx_var_accessor>;
     198                 :             : template class generic_subrtx_iterator <rtx_ptr_accessor>;
     199                 :             : 
     200                 :             : /* Return true if the value of X is unstable
     201                 :             :    (would be different at a different point in the program).
     202                 :             :    The frame pointer, arg pointer, etc. are considered stable
     203                 :             :    (within one function) and so is anything marked `unchanging'.  */
     204                 :             : 
     205                 :             : bool
     206                 :           0 : rtx_unstable_p (const_rtx x)
     207                 :             : {
     208                 :           0 :   const RTX_CODE code = GET_CODE (x);
     209                 :           0 :   int i;
     210                 :           0 :   const char *fmt;
     211                 :             : 
     212                 :           0 :   switch (code)
     213                 :             :     {
     214                 :           0 :     case MEM:
     215                 :           0 :       return !MEM_READONLY_P (x) || rtx_unstable_p (XEXP (x, 0));
     216                 :             : 
     217                 :             :     case CONST:
     218                 :             :     CASE_CONST_ANY:
     219                 :             :     case SYMBOL_REF:
     220                 :             :     case LABEL_REF:
     221                 :             :       return false;
     222                 :             : 
     223                 :           0 :     case REG:
     224                 :             :       /* As in rtx_varies_p, we have to use the actual rtx, not reg number.  */
     225                 :           0 :       if (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
     226                 :             :           /* The arg pointer varies if it is not a fixed register.  */
     227                 :           0 :           || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM]))
     228                 :             :         return false;
     229                 :             :       /* ??? When call-clobbered, the value is stable modulo the restore
     230                 :             :          that must happen after a call.  This currently screws up local-alloc
     231                 :             :          into believing that the restore is not needed.  */
     232                 :           0 :       if (!PIC_OFFSET_TABLE_REG_CALL_CLOBBERED && x == pic_offset_table_rtx)
     233                 :             :         return false;
     234                 :             :       return true;
     235                 :             : 
     236                 :           0 :     case ASM_OPERANDS:
     237                 :           0 :       if (MEM_VOLATILE_P (x))
     238                 :             :         return true;
     239                 :             : 
     240                 :             :       /* Fall through.  */
     241                 :             : 
     242                 :           0 :     default:
     243                 :           0 :       break;
     244                 :             :     }
     245                 :             : 
     246                 :           0 :   fmt = GET_RTX_FORMAT (code);
     247                 :           0 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
     248                 :           0 :     if (fmt[i] == 'e')
     249                 :             :       {
     250                 :           0 :         if (rtx_unstable_p (XEXP (x, i)))
     251                 :             :           return true;
     252                 :             :       }
     253                 :           0 :     else if (fmt[i] == 'E')
     254                 :             :       {
     255                 :             :         int j;
     256                 :           0 :         for (j = 0; j < XVECLEN (x, i); j++)
     257                 :           0 :           if (rtx_unstable_p (XVECEXP (x, i, j)))
     258                 :             :             return true;
     259                 :             :       }
     260                 :             : 
     261                 :             :   return false;
     262                 :             : }
     263                 :             : 
     264                 :             : /* Return true if X has a value that can vary even between two
     265                 :             :    executions of the program.  false means X can be compared reliably
     266                 :             :    against certain constants or near-constants.
     267                 :             :    FOR_ALIAS is nonzero if we are called from alias analysis; if it is
     268                 :             :    zero, we are slightly more conservative.
     269                 :             :    The frame pointer and the arg pointer are considered constant.  */
     270                 :             : 
     271                 :             : bool
     272                 :   467043787 : rtx_varies_p (const_rtx x, bool for_alias)
     273                 :             : {
     274                 :   467043787 :   RTX_CODE code;
     275                 :   467043787 :   int i;
     276                 :   467043787 :   const char *fmt;
     277                 :             : 
     278                 :   467043787 :   if (!x)
     279                 :             :     return false;
     280                 :             : 
     281                 :   467043787 :   code = GET_CODE (x);
     282                 :   467043787 :   switch (code)
     283                 :             :     {
     284                 :    87315178 :     case MEM:
     285                 :    87315178 :       return !MEM_READONLY_P (x) || rtx_varies_p (XEXP (x, 0), for_alias);
     286                 :             : 
     287                 :             :     case CONST:
     288                 :             :     CASE_CONST_ANY:
     289                 :             :     case SYMBOL_REF:
     290                 :             :     case LABEL_REF:
     291                 :             :       return false;
     292                 :             : 
     293                 :   150714238 :     case REG:
     294                 :             :       /* Note that we have to test for the actual rtx used for the frame
     295                 :             :          and arg pointers and not just the register number in case we have
     296                 :             :          eliminated the frame and/or arg pointer and are using it
     297                 :             :          for pseudos.  */
     298                 :   150714238 :       if (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
     299                 :             :           /* The arg pointer varies if it is not a fixed register.  */
     300                 :   133381777 :           || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM]))
     301                 :             :         return false;
     302                 :   133156772 :       if (x == pic_offset_table_rtx
     303                 :             :           /* ??? When call-clobbered, the value is stable modulo the restore
     304                 :             :              that must happen after a call.  This currently screws up
     305                 :             :              local-alloc into believing that the restore is not needed, so we
     306                 :             :              must return 0 only if we are called from alias analysis.  */
     307                 :             :           && (!PIC_OFFSET_TABLE_REG_CALL_CLOBBERED || for_alias))
     308                 :             :         return false;
     309                 :             :       return true;
     310                 :             : 
     311                 :           0 :     case LO_SUM:
     312                 :             :       /* The operand 0 of a LO_SUM is considered constant
     313                 :             :          (in fact it is related specifically to operand 1)
     314                 :             :          during alias analysis.  */
     315                 :           0 :       return (! for_alias && rtx_varies_p (XEXP (x, 0), for_alias))
     316                 :           0 :              || rtx_varies_p (XEXP (x, 1), for_alias);
     317                 :             : 
     318                 :       89698 :     case ASM_OPERANDS:
     319                 :       89698 :       if (MEM_VOLATILE_P (x))
     320                 :             :         return true;
     321                 :             : 
     322                 :             :       /* Fall through.  */
     323                 :             : 
     324                 :   129029694 :     default:
     325                 :   129029694 :       break;
     326                 :             :     }
     327                 :             : 
     328                 :   129029694 :   fmt = GET_RTX_FORMAT (code);
     329                 :   227033658 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
     330                 :   205428168 :     if (fmt[i] == 'e')
     331                 :             :       {
     332                 :   187706811 :         if (rtx_varies_p (XEXP (x, i), for_alias))
     333                 :             :           return true;
     334                 :             :       }
     335                 :    17721357 :     else if (fmt[i] == 'E')
     336                 :             :       {
     337                 :             :         int j;
     338                 :    18321546 :         for (j = 0; j < XVECLEN (x, i); j++)
     339                 :    14417169 :           if (rtx_varies_p (XVECEXP (x, i, j), for_alias))
     340                 :             :             return true;
     341                 :             :       }
     342                 :             : 
     343                 :             :   return false;
     344                 :             : }
     345                 :             : 
     346                 :             : /* Compute an approximation for the offset between the register
     347                 :             :    FROM and TO for the current function, as it was at the start
     348                 :             :    of the routine.  */
     349                 :             : 
     350                 :             : static poly_int64
     351                 :   233788926 : get_initial_register_offset (int from, int to)
     352                 :             : {
     353                 :   233788926 :   static const struct elim_table_t
     354                 :             :   {
     355                 :             :     const int from;
     356                 :             :     const int to;
     357                 :             :   } table[] = ELIMINABLE_REGS;
     358                 :   233788926 :   poly_int64 offset1, offset2;
     359                 :   233788926 :   unsigned int i, j;
     360                 :             : 
     361                 :   233788926 :   if (to == from)
     362                 :           0 :     return 0;
     363                 :             : 
     364                 :             :   /* It is not safe to call INITIAL_ELIMINATION_OFFSET before the epilogue
     365                 :             :      is completed, but we need to give at least an estimate for the stack
     366                 :             :      pointer based on the frame size.  */
     367                 :   233788926 :   if (!epilogue_completed)
     368                 :             :     {
     369                 :   129849412 :       offset1 = crtl->outgoing_args_size + get_frame_size ();
     370                 :             : #if !STACK_GROWS_DOWNWARD
     371                 :             :       offset1 = - offset1;
     372                 :             : #endif
     373                 :   129849412 :       if (to == STACK_POINTER_REGNUM)
     374                 :   129313404 :         return offset1;
     375                 :      536008 :       else if (from == STACK_POINTER_REGNUM)
     376                 :      268004 :         return - offset1;
     377                 :             :       else
     378                 :      268004 :         return 0;
     379                 :             :      }
     380                 :             : 
     381                 :   105050162 :   for (i = 0; i < ARRAY_SIZE (table); i++)
     382                 :   105050162 :       if (table[i].from == from)
     383                 :             :         {
     384                 :   103939514 :           if (table[i].to == to)
     385                 :             :             {
     386                 :   102828866 :               INITIAL_ELIMINATION_OFFSET (table[i].from, table[i].to,
     387                 :             :                                           offset1);
     388                 :   102828866 :               return offset1;
     389                 :             :             }
     390                 :     5553240 :           for (j = 0; j < ARRAY_SIZE (table); j++)
     391                 :             :             {
     392                 :     4442592 :               if (table[j].to == to
     393                 :     2221296 :                   && table[j].from == table[i].to)
     394                 :             :                 {
     395                 :           0 :                   INITIAL_ELIMINATION_OFFSET (table[i].from, table[i].to,
     396                 :             :                                               offset1);
     397                 :           0 :                   INITIAL_ELIMINATION_OFFSET (table[j].from, table[j].to,
     398                 :             :                                               offset2);
     399                 :           0 :                   return offset1 + offset2;
     400                 :             :                 }
     401                 :     4442592 :               if (table[j].from == to
     402                 :           0 :                   && table[j].to == table[i].to)
     403                 :             :                 {
     404                 :           0 :                   INITIAL_ELIMINATION_OFFSET (table[i].from, table[i].to,
     405                 :             :                                               offset1);
     406                 :           0 :                   INITIAL_ELIMINATION_OFFSET (table[j].from, table[j].to,
     407                 :             :                                               offset2);
     408                 :           0 :                   return offset1 - offset2;
     409                 :             :                 }
     410                 :             :             }
     411                 :             :         }
     412                 :     1110648 :       else if (table[i].to == from)
     413                 :             :         {
     414                 :     1110648 :           if (table[i].from == to)
     415                 :             :             {
     416                 :           0 :               INITIAL_ELIMINATION_OFFSET (table[i].from, table[i].to,
     417                 :             :                                           offset1);
     418                 :           0 :               return - offset1;
     419                 :             :             }
     420                 :     2221296 :           for (j = 0; j < ARRAY_SIZE (table); j++)
     421                 :             :             {
     422                 :     2221296 :               if (table[j].to == to
     423                 :     1110648 :                   && table[j].from == table[i].from)
     424                 :             :                 {
     425                 :     1110648 :                   INITIAL_ELIMINATION_OFFSET (table[i].from, table[i].to,
     426                 :             :                                               offset1);
     427                 :     1110648 :                   INITIAL_ELIMINATION_OFFSET (table[j].from, table[j].to,
     428                 :             :                                               offset2);
     429                 :     1110648 :                   return - offset1 + offset2;
     430                 :             :                 }
     431                 :     1110648 :               if (table[j].from == to
     432                 :           0 :                   && table[j].to == table[i].from)
     433                 :             :                 {
     434                 :           0 :                   INITIAL_ELIMINATION_OFFSET (table[i].from, table[i].to,
     435                 :             :                                               offset1);
     436                 :           0 :                   INITIAL_ELIMINATION_OFFSET (table[j].from, table[j].to,
     437                 :             :                                               offset2);
     438                 :           0 :                   return - offset1 - offset2;
     439                 :             :                 }
     440                 :             :             }
     441                 :             :         }
     442                 :             : 
     443                 :             :   /* If the requested register combination was not found,
     444                 :             :      try a different more simple combination.  */
     445                 :           0 :   if (from == ARG_POINTER_REGNUM)
     446                 :             :     return get_initial_register_offset (HARD_FRAME_POINTER_REGNUM, to);
     447                 :           0 :   else if (to == ARG_POINTER_REGNUM)
     448                 :             :     return get_initial_register_offset (from, HARD_FRAME_POINTER_REGNUM);
     449                 :           0 :   else if (from == HARD_FRAME_POINTER_REGNUM)
     450                 :             :     return get_initial_register_offset (FRAME_POINTER_REGNUM, to);
     451                 :           0 :   else if (to == HARD_FRAME_POINTER_REGNUM)
     452                 :             :     return get_initial_register_offset (from, FRAME_POINTER_REGNUM);
     453                 :             :   else
     454                 :           0 :     return 0;
     455                 :             : }
     456                 :             : 
     457                 :             : /* Return true if the use of X+OFFSET as an address in a MEM with SIZE
     458                 :             :    bytes can cause a trap.  MODE is the mode of the MEM (not that of X) and
     459                 :             :    UNALIGNED_MEMS controls whether true is returned for unaligned memory
     460                 :             :    references on strict alignment machines.  */
     461                 :             : 
     462                 :             : static bool
     463                 :   764646084 : rtx_addr_can_trap_p_1 (const_rtx x, poly_int64 offset, poly_int64 size,
     464                 :             :                        machine_mode mode, bool unaligned_mems)
     465                 :             : {
     466                 :   764646084 :   enum rtx_code code = GET_CODE (x);
     467                 :   764646084 :   gcc_checking_assert (mode == BLKmode
     468                 :             :                        || mode == VOIDmode
     469                 :             :                        || known_size_p (size));
     470                 :   764646084 :   poly_int64 const_x1;
     471                 :             : 
     472                 :             :   /* The offset must be a multiple of the mode size if we are considering
     473                 :             :      unaligned memory references on strict alignment machines.  */
     474                 :   764646084 :   if (STRICT_ALIGNMENT
     475                 :             :       && unaligned_mems
     476                 :             :       && mode != BLKmode
     477                 :             :       && mode != VOIDmode)
     478                 :             :     {
     479                 :             :       poly_int64 actual_offset = offset;
     480                 :             : 
     481                 :             : #ifdef SPARC_STACK_BOUNDARY_HACK
     482                 :             :       /* ??? The SPARC port may claim a STACK_BOUNDARY higher than
     483                 :             :              the real alignment of %sp.  However, when it does this, the
     484                 :             :              alignment of %sp+STACK_POINTER_OFFSET is STACK_BOUNDARY.  */
     485                 :             :       if (SPARC_STACK_BOUNDARY_HACK
     486                 :             :           && (x == stack_pointer_rtx || x == hard_frame_pointer_rtx))
     487                 :             :         actual_offset -= STACK_POINTER_OFFSET;
     488                 :             : #endif
     489                 :             : 
     490                 :             :       if (!multiple_p (actual_offset, GET_MODE_SIZE (mode)))
     491                 :             :         return true;
     492                 :             :     }
     493                 :             : 
     494                 :   764646084 :   switch (code)
     495                 :             :     {
     496                 :     5813512 :     case SYMBOL_REF:
     497                 :     5813512 :       if (SYMBOL_REF_WEAK (x))
     498                 :             :         return true;
     499                 :     5559257 :       if (!CONSTANT_POOL_ADDRESS_P (x) && !SYMBOL_REF_FUNCTION_P (x))
     500                 :             :         {
     501                 :      683115 :           tree decl;
     502                 :      683115 :           poly_int64 decl_size;
     503                 :             : 
     504                 :      683115 :           if (maybe_lt (offset, 0))
     505                 :             :             return true;
     506                 :      682068 :           if (!known_size_p (size))
     507                 :         658 :             return maybe_ne (offset, 0);
     508                 :             : 
     509                 :             :           /* If the size of the access or of the symbol is unknown,
     510                 :             :              assume the worst.  */
     511                 :      681410 :           decl = SYMBOL_REF_DECL (x);
     512                 :             : 
     513                 :             :           /* Else check that the access is in bounds.  TODO: restructure
     514                 :             :              expr_size/tree_expr_size/int_expr_size and just use the latter.  */
     515                 :      681410 :           if (!decl)
     516                 :      239839 :             decl_size = -1;
     517                 :      441571 :           else if (DECL_P (decl) && DECL_SIZE_UNIT (decl))
     518                 :             :             {
     519                 :      434039 :               if (!poly_int_tree_p (DECL_SIZE_UNIT (decl), &decl_size))
     520                 :           0 :                 decl_size = -1;
     521                 :             :             }
     522                 :        7532 :           else if (TREE_CODE (decl) == STRING_CST)
     523                 :           0 :             decl_size = TREE_STRING_LENGTH (decl);
     524                 :        7532 :           else if (TYPE_SIZE_UNIT (TREE_TYPE (decl)))
     525                 :           0 :             decl_size = int_size_in_bytes (TREE_TYPE (decl));
     526                 :             :           else
     527                 :        7532 :             decl_size = -1;
     528                 :             : 
     529                 :      681410 :           return (!known_size_p (decl_size) || known_eq (decl_size, 0)
     530                 :      682283 :                   ? maybe_ne (offset, 0)
     531                 :      681410 :                   : !known_subrange_p (offset, size, 0, decl_size));
     532                 :             :         }
     533                 :             : 
     534                 :             :       return false;
     535                 :             : 
     536                 :             :     case LABEL_REF:
     537                 :             :       return false;
     538                 :             : 
     539                 :   384541428 :     case REG:
     540                 :             :       /* Stack references are assumed not to trap, but we need to deal with
     541                 :             :          nonsensical offsets.  */
     542                 :   384541428 :       if (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
     543                 :   376074051 :          || x == stack_pointer_rtx
     544                 :             :          /* The arg pointer varies if it is not a fixed register.  */
     545                 :   145039374 :          || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM]))
     546                 :             :         {
     547                 :             : #ifdef RED_ZONE_SIZE
     548                 :   239586804 :           poly_int64 red_zone_size = RED_ZONE_SIZE;
     549                 :             : #else
     550                 :             :           poly_int64 red_zone_size = 0;
     551                 :             : #endif
     552                 :   239586804 :           poly_int64 stack_boundary = PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT;
     553                 :   239586804 :           poly_int64 low_bound, high_bound;
     554                 :             : 
     555                 :   239586804 :           if (!known_size_p (size))
     556                 :             :             return true;
     557                 :             : 
     558                 :   239582713 :           if (x == frame_pointer_rtx)
     559                 :             :             {
     560                 :     7087689 :               if (FRAME_GROWS_DOWNWARD)
     561                 :             :                 {
     562                 :     7087689 :                   high_bound = targetm.starting_frame_offset ();
     563                 :     7087689 :                   low_bound  = high_bound - get_frame_size ();
     564                 :             :                 }
     565                 :             :               else
     566                 :             :                 {
     567                 :             :                   low_bound  = targetm.starting_frame_offset ();
     568                 :             :                   high_bound = low_bound + get_frame_size ();
     569                 :             :                 }
     570                 :             :             }
     571                 :   232495024 :           else if (x == hard_frame_pointer_rtx)
     572                 :             :             {
     573                 :     1378652 :               poly_int64 sp_offset
     574                 :     1378652 :                 = get_initial_register_offset (STACK_POINTER_REGNUM,
     575                 :             :                                                HARD_FRAME_POINTER_REGNUM);
     576                 :     1378652 :               poly_int64 ap_offset
     577                 :     1378652 :                 = get_initial_register_offset (ARG_POINTER_REGNUM,
     578                 :             :                                                HARD_FRAME_POINTER_REGNUM);
     579                 :             : 
     580                 :             : #if STACK_GROWS_DOWNWARD
     581                 :     1378652 :               low_bound  = sp_offset - red_zone_size - stack_boundary;
     582                 :     1378652 :               high_bound = ap_offset
     583                 :     1378652 :                            + FIRST_PARM_OFFSET (current_function_decl)
     584                 :             : #if !ARGS_GROW_DOWNWARD
     585                 :     1378652 :                            + crtl->args.size
     586                 :             : #endif
     587                 :     1378652 :                            + stack_boundary;
     588                 :             : #else
     589                 :             :               high_bound = sp_offset + red_zone_size + stack_boundary;
     590                 :             :               low_bound  = ap_offset
     591                 :             :                            + FIRST_PARM_OFFSET (current_function_decl)
     592                 :             : #if ARGS_GROW_DOWNWARD
     593                 :             :                            - crtl->args.size
     594                 :             : #endif
     595                 :             :                            - stack_boundary;
     596                 :             : #endif
     597                 :             :             }
     598                 :   231116372 :           else if (x == stack_pointer_rtx)
     599                 :             :             {
     600                 :   231031622 :               poly_int64 ap_offset
     601                 :   231031622 :                 = get_initial_register_offset (ARG_POINTER_REGNUM,
     602                 :             :                                                STACK_POINTER_REGNUM);
     603                 :             : 
     604                 :             : #if STACK_GROWS_DOWNWARD
     605                 :   231031622 :               low_bound  = - red_zone_size - stack_boundary;
     606                 :   231031622 :               high_bound = ap_offset
     607                 :   231031622 :                            + FIRST_PARM_OFFSET (current_function_decl)
     608                 :             : #if !ARGS_GROW_DOWNWARD
     609                 :   231031622 :                            + crtl->args.size
     610                 :             : #endif
     611                 :   231031622 :                            + stack_boundary;
     612                 :             : #else
     613                 :             :               high_bound = red_zone_size + stack_boundary;
     614                 :             :               low_bound  = ap_offset
     615                 :             :                            + FIRST_PARM_OFFSET (current_function_decl)
     616                 :             : #if ARGS_GROW_DOWNWARD
     617                 :             :                            - crtl->args.size
     618                 :             : #endif
     619                 :             :                            - stack_boundary;
     620                 :             : #endif
     621                 :             :             }
     622                 :             :           else
     623                 :             :             {
     624                 :             :               /* We assume that accesses are safe to at least the
     625                 :             :                  next stack boundary.
     626                 :             :                  Examples are varargs and __builtin_return_address.  */
     627                 :             : #if ARGS_GROW_DOWNWARD
     628                 :             :               high_bound = FIRST_PARM_OFFSET (current_function_decl)
     629                 :             :                            + stack_boundary;
     630                 :             :               low_bound  = FIRST_PARM_OFFSET (current_function_decl)
     631                 :             :                            - crtl->args.size - stack_boundary;
     632                 :             : #else
     633                 :       84750 :               low_bound  = FIRST_PARM_OFFSET (current_function_decl)
     634                 :       84750 :                            - stack_boundary;
     635                 :       84750 :               high_bound = FIRST_PARM_OFFSET (current_function_decl)
     636                 :       84750 :                            + crtl->args.size + stack_boundary;
     637                 :             : #endif
     638                 :             :             }
     639                 :             : 
     640                 :   239582713 :           if (known_ge (offset, low_bound)
     641                 :   239582713 :               && known_le (offset, high_bound - size))
     642                 :             :             return false;
     643                 :             :           return true;
     644                 :             :         }
     645                 :             :       /* All of the virtual frame registers are stack references.  */
     646                 :   144954624 :       if (VIRTUAL_REGISTER_P (x))
     647                 :             :         return false;
     648                 :             :       return true;
     649                 :             : 
     650                 :      281967 :     case CONST:
     651                 :      281967 :       return rtx_addr_can_trap_p_1 (XEXP (x, 0), offset, size,
     652                 :      281967 :                                     mode, unaligned_mems);
     653                 :             : 
     654                 :   156753076 :     case PLUS:
     655                 :             :       /* An address is assumed not to trap if:
     656                 :             :          - it is the pic register plus a const unspec without offset.  */
     657                 :   156753076 :       if (XEXP (x, 0) == pic_offset_table_rtx
     658                 :       38093 :           && GET_CODE (XEXP (x, 1)) == CONST
     659                 :       38059 :           && GET_CODE (XEXP (XEXP (x, 1), 0)) == UNSPEC
     660                 :   156787988 :           && known_eq (offset, 0))
     661                 :             :         return false;
     662                 :             : 
     663                 :             :       /* - or it is an address that can't trap plus a constant integer.  */
     664                 :   156718164 :       if (poly_int_rtx_p (XEXP (x, 1), &const_x1)
     665                 :   135128626 :           && !rtx_addr_can_trap_p_1 (XEXP (x, 0), offset + const_x1,
     666                 :             :                                      size, mode, unaligned_mems))
     667                 :             :         return false;
     668                 :             : 
     669                 :             :       return true;
     670                 :             : 
     671                 :     2202916 :     case LO_SUM:
     672                 :     2202916 :     case PRE_MODIFY:
     673                 :     2202916 :       return rtx_addr_can_trap_p_1 (XEXP (x, 1), offset, size,
     674                 :     2202916 :                                     mode, unaligned_mems);
     675                 :             : 
     676                 :   189680643 :     case PRE_DEC:
     677                 :   189680643 :     case PRE_INC:
     678                 :   189680643 :     case POST_DEC:
     679                 :   189680643 :     case POST_INC:
     680                 :   189680643 :     case POST_MODIFY:
     681                 :   189680643 :       return rtx_addr_can_trap_p_1 (XEXP (x, 0), offset, size,
     682                 :   189680643 :                                     mode, unaligned_mems);
     683                 :             : 
     684                 :             :     default:
     685                 :             :       break;
     686                 :             :     }
     687                 :             : 
     688                 :             :   /* If it isn't one of the case above, it can cause a trap.  */
     689                 :             :   return true;
     690                 :             : }
     691                 :             : 
     692                 :             : /* Return true if the use of X as an address in a MEM can cause a trap.  */
     693                 :             : 
     694                 :             : bool
     695                 :    13003486 : rtx_addr_can_trap_p (const_rtx x)
     696                 :             : {
     697                 :    13003486 :   return rtx_addr_can_trap_p_1 (x, 0, -1, BLKmode, false);
     698                 :             : }
     699                 :             : 
     700                 :             : /* Return true if X contains a MEM subrtx.  */
     701                 :             : 
     702                 :             : bool
     703                 :    20609689 : contains_mem_rtx_p (rtx x)
     704                 :             : {
     705                 :    20609689 :   subrtx_iterator::array_type array;
     706                 :    64191479 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
     707                 :    50340105 :     if (MEM_P (*iter))
     708                 :     6758315 :       return true;
     709                 :             : 
     710                 :    13851374 :   return false;
     711                 :    20609689 : }
     712                 :             : 
     713                 :             : /* Return true if X is an address that is known to not be zero.  */
     714                 :             : 
     715                 :             : bool
     716                 :    52727115 : nonzero_address_p (const_rtx x)
     717                 :             : {
     718                 :    52729341 :   const enum rtx_code code = GET_CODE (x);
     719                 :             : 
     720                 :    52729341 :   switch (code)
     721                 :             :     {
     722                 :        3398 :     case SYMBOL_REF:
     723                 :        3398 :       return flag_delete_null_pointer_checks && !SYMBOL_REF_WEAK (x);
     724                 :             : 
     725                 :             :     case LABEL_REF:
     726                 :             :       return true;
     727                 :             : 
     728                 :    25285223 :     case REG:
     729                 :             :       /* As in rtx_varies_p, we have to use the actual rtx, not reg number.  */
     730                 :    25285223 :       if (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
     731                 :    25285119 :           || x == stack_pointer_rtx
     732                 :    25285119 :           || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM]))
     733                 :             :         return true;
     734                 :             :       /* All of the virtual frame registers are stack references.  */
     735                 :    25285119 :       if (VIRTUAL_REGISTER_P (x))
     736                 :             :         return true;
     737                 :             :       return false;
     738                 :             : 
     739                 :        2226 :     case CONST:
     740                 :        2226 :       return nonzero_address_p (XEXP (x, 0));
     741                 :             : 
     742                 :    11267111 :     case PLUS:
     743                 :             :       /* Handle PIC references.  */
     744                 :    11267111 :       if (XEXP (x, 0) == pic_offset_table_rtx
     745                 :           0 :                && CONSTANT_P (XEXP (x, 1)))
     746                 :             :         return true;
     747                 :             :       return false;
     748                 :             : 
     749                 :           0 :     case PRE_MODIFY:
     750                 :             :       /* Similar to the above; allow positive offsets.  Further, since
     751                 :             :          auto-inc is only allowed in memories, the register must be a
     752                 :             :          pointer.  */
     753                 :           0 :       if (CONST_INT_P (XEXP (x, 1))
     754                 :           0 :           && INTVAL (XEXP (x, 1)) > 0)
     755                 :             :         return true;
     756                 :           0 :       return nonzero_address_p (XEXP (x, 0));
     757                 :             : 
     758                 :             :     case PRE_INC:
     759                 :             :       /* Similarly.  Further, the offset is always positive.  */
     760                 :             :       return true;
     761                 :             : 
     762                 :           0 :     case PRE_DEC:
     763                 :           0 :     case POST_DEC:
     764                 :           0 :     case POST_INC:
     765                 :           0 :     case POST_MODIFY:
     766                 :           0 :       return nonzero_address_p (XEXP (x, 0));
     767                 :             : 
     768                 :           0 :     case LO_SUM:
     769                 :           0 :       return nonzero_address_p (XEXP (x, 1));
     770                 :             : 
     771                 :             :     default:
     772                 :             :       break;
     773                 :             :     }
     774                 :             : 
     775                 :             :   /* If it isn't one of the case above, might be zero.  */
     776                 :             :   return false;
     777                 :             : }
     778                 :             : 
     779                 :             : /* Return true if X refers to a memory location whose address
     780                 :             :    cannot be compared reliably with constant addresses,
     781                 :             :    or if X refers to a BLKmode memory object.
     782                 :             :    FOR_ALIAS is nonzero if we are called from alias analysis; if it is
     783                 :             :    zero, we are slightly more conservative.  */
     784                 :             : 
     785                 :             : bool
     786                 :           0 : rtx_addr_varies_p (const_rtx x, bool for_alias)
     787                 :             : {
     788                 :           0 :   enum rtx_code code;
     789                 :           0 :   int i;
     790                 :           0 :   const char *fmt;
     791                 :             : 
     792                 :           0 :   if (x == 0)
     793                 :             :     return false;
     794                 :             : 
     795                 :           0 :   code = GET_CODE (x);
     796                 :           0 :   if (code == MEM)
     797                 :           0 :     return GET_MODE (x) == BLKmode || rtx_varies_p (XEXP (x, 0), for_alias);
     798                 :             : 
     799                 :           0 :   fmt = GET_RTX_FORMAT (code);
     800                 :           0 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
     801                 :           0 :     if (fmt[i] == 'e')
     802                 :             :       {
     803                 :           0 :         if (rtx_addr_varies_p (XEXP (x, i), for_alias))
     804                 :             :           return true;
     805                 :             :       }
     806                 :           0 :     else if (fmt[i] == 'E')
     807                 :             :       {
     808                 :             :         int j;
     809                 :           0 :         for (j = 0; j < XVECLEN (x, i); j++)
     810                 :           0 :           if (rtx_addr_varies_p (XVECEXP (x, i, j), for_alias))
     811                 :             :             return true;
     812                 :             :       }
     813                 :             :   return false;
     814                 :             : }
     815                 :             : 
     816                 :             : /* Return the CALL in X if there is one.  */
     817                 :             : 
     818                 :             : rtx
     819                 :    30193080 : get_call_rtx_from (const rtx_insn *insn)
     820                 :             : {
     821                 :    30193080 :   rtx x = PATTERN (insn);
     822                 :    30193080 :   if (GET_CODE (x) == PARALLEL)
     823                 :     1438254 :     x = XVECEXP (x, 0, 0);
     824                 :    30193080 :   if (GET_CODE (x) == SET)
     825                 :    11458369 :     x = SET_SRC (x);
     826                 :    30193080 :   if (GET_CODE (x) == CALL && MEM_P (XEXP (x, 0)))
     827                 :    30193080 :     return x;
     828                 :             :   return NULL_RTX;
     829                 :             : }
     830                 :             : 
     831                 :             : /* Get the declaration of the function called by INSN.  */
     832                 :             : 
     833                 :             : tree
     834                 :   278246038 : get_call_fndecl (const rtx_insn *insn)
     835                 :             : {
     836                 :   278246038 :   rtx note, datum;
     837                 :             : 
     838                 :   278246038 :   note = find_reg_note (insn, REG_CALL_DECL, NULL_RTX);
     839                 :   278246038 :   if (note == NULL_RTX)
     840                 :             :     return NULL_TREE;
     841                 :             : 
     842                 :   275360417 :   datum = XEXP (note, 0);
     843                 :   275360417 :   if (datum != NULL_RTX)
     844                 :   265160175 :     return SYMBOL_REF_DECL (datum);
     845                 :             : 
     846                 :             :   return NULL_TREE;
     847                 :             : }
     848                 :             : 
     849                 :             : /* Return the value of the integer term in X, if one is apparent;
     850                 :             :    otherwise return 0.
     851                 :             :    Only obvious integer terms are detected.
     852                 :             :    This is used in cse.cc with the `related_value' field.  */
     853                 :             : 
     854                 :             : HOST_WIDE_INT
     855                 :      445722 : get_integer_term (const_rtx x)
     856                 :             : {
     857                 :      445722 :   if (GET_CODE (x) == CONST)
     858                 :      252854 :     x = XEXP (x, 0);
     859                 :             : 
     860                 :      445722 :   if (GET_CODE (x) == MINUS
     861                 :           0 :       && CONST_INT_P (XEXP (x, 1)))
     862                 :           0 :     return - INTVAL (XEXP (x, 1));
     863                 :      445722 :   if (GET_CODE (x) == PLUS
     864                 :      252854 :       && CONST_INT_P (XEXP (x, 1)))
     865                 :      252854 :     return INTVAL (XEXP (x, 1));
     866                 :             :   return 0;
     867                 :             : }
     868                 :             : 
     869                 :             : /* If X is a constant, return the value sans apparent integer term;
     870                 :             :    otherwise return 0.
     871                 :             :    Only obvious integer terms are detected.  */
     872                 :             : 
     873                 :             : rtx
     874                 :     1241965 : get_related_value (const_rtx x)
     875                 :             : {
     876                 :     1241965 :   if (GET_CODE (x) != CONST)
     877                 :             :     return 0;
     878                 :     1241965 :   x = XEXP (x, 0);
     879                 :     1241965 :   if (GET_CODE (x) == PLUS
     880                 :     1214696 :       && CONST_INT_P (XEXP (x, 1)))
     881                 :     1214696 :     return XEXP (x, 0);
     882                 :       27269 :   else if (GET_CODE (x) == MINUS
     883                 :           0 :            && CONST_INT_P (XEXP (x, 1)))
     884                 :           0 :     return XEXP (x, 0);
     885                 :             :   return 0;
     886                 :             : }
     887                 :             : 
     888                 :             : /* Return true if SYMBOL is a SYMBOL_REF and OFFSET + SYMBOL points
     889                 :             :    to somewhere in the same object or object_block as SYMBOL.  */
     890                 :             : 
     891                 :             : bool
     892                 :           0 : offset_within_block_p (const_rtx symbol, HOST_WIDE_INT offset)
     893                 :             : {
     894                 :           0 :   tree decl;
     895                 :             : 
     896                 :           0 :   if (GET_CODE (symbol) != SYMBOL_REF)
     897                 :             :     return false;
     898                 :             : 
     899                 :           0 :   if (offset == 0)
     900                 :             :     return true;
     901                 :             : 
     902                 :           0 :   if (offset > 0)
     903                 :             :     {
     904                 :           0 :       if (CONSTANT_POOL_ADDRESS_P (symbol)
     905                 :           0 :           && offset < (int) GET_MODE_SIZE (get_pool_mode (symbol)))
     906                 :           0 :         return true;
     907                 :             : 
     908                 :           0 :       decl = SYMBOL_REF_DECL (symbol);
     909                 :           0 :       if (decl && offset < int_size_in_bytes (TREE_TYPE (decl)))
     910                 :             :         return true;
     911                 :             :     }
     912                 :             : 
     913                 :           0 :   if (SYMBOL_REF_HAS_BLOCK_INFO_P (symbol)
     914                 :           0 :       && SYMBOL_REF_BLOCK (symbol)
     915                 :           0 :       && SYMBOL_REF_BLOCK_OFFSET (symbol) >= 0
     916                 :           0 :       && ((unsigned HOST_WIDE_INT) offset + SYMBOL_REF_BLOCK_OFFSET (symbol)
     917                 :           0 :           < (unsigned HOST_WIDE_INT) SYMBOL_REF_BLOCK (symbol)->size))
     918                 :             :     return true;
     919                 :             : 
     920                 :             :   return false;
     921                 :             : }
     922                 :             : 
     923                 :             : /* Split X into a base and a constant offset, storing them in *BASE_OUT
     924                 :             :    and *OFFSET_OUT respectively.  */
     925                 :             : 
     926                 :             : void
     927                 :           0 : split_const (rtx x, rtx *base_out, rtx *offset_out)
     928                 :             : {
     929                 :           0 :   if (GET_CODE (x) == CONST)
     930                 :             :     {
     931                 :           0 :       x = XEXP (x, 0);
     932                 :           0 :       if (GET_CODE (x) == PLUS && CONST_INT_P (XEXP (x, 1)))
     933                 :             :         {
     934                 :           0 :           *base_out = XEXP (x, 0);
     935                 :           0 :           *offset_out = XEXP (x, 1);
     936                 :           0 :           return;
     937                 :             :         }
     938                 :             :     }
     939                 :           0 :   *base_out = x;
     940                 :           0 :   *offset_out = const0_rtx;
     941                 :             : }
     942                 :             : 
     943                 :             : /* Express integer value X as some value Y plus a polynomial offset,
     944                 :             :    where Y is either const0_rtx, X or something within X (as opposed
     945                 :             :    to a new rtx).  Return the Y and store the offset in *OFFSET_OUT.  */
     946                 :             : 
     947                 :             : rtx
     948                 :   379349184 : strip_offset (rtx x, poly_int64 *offset_out)
     949                 :             : {
     950                 :   379349184 :   rtx base = const0_rtx;
     951                 :   379349184 :   rtx test = x;
     952                 :   379349184 :   if (GET_CODE (test) == CONST)
     953                 :     8186903 :     test = XEXP (test, 0);
     954                 :   379349184 :   if (GET_CODE (test) == PLUS)
     955                 :             :     {
     956                 :   287380018 :       base = XEXP (test, 0);
     957                 :   287380018 :       test = XEXP (test, 1);
     958                 :             :     }
     959                 :   379349184 :   if (poly_int_rtx_p (test, offset_out))
     960                 :   269745645 :     return base;
     961                 :   109603539 :   *offset_out = 0;
     962                 :   109603539 :   return x;
     963                 :             : }
     964                 :             : 
     965                 :             : /* Return the argument size in REG_ARGS_SIZE note X.  */
     966                 :             : 
     967                 :             : poly_int64
     968                 :     5210291 : get_args_size (const_rtx x)
     969                 :             : {
     970                 :     5210291 :   gcc_checking_assert (REG_NOTE_KIND (x) == REG_ARGS_SIZE);
     971                 :     5210291 :   return rtx_to_poly_int64 (XEXP (x, 0));
     972                 :             : }
     973                 :             : 
     974                 :             : /* Return the number of places FIND appears within X.  If COUNT_DEST is
     975                 :             :    zero, we do not count occurrences inside the destination of a SET.  */
     976                 :             : 
     977                 :             : int
     978                 :     8766779 : count_occurrences (const_rtx x, const_rtx find, int count_dest)
     979                 :             : {
     980                 :     8766779 :   int i, j;
     981                 :     8766779 :   enum rtx_code code;
     982                 :     8766779 :   const char *format_ptr;
     983                 :     8766779 :   int count;
     984                 :             : 
     985                 :     8766779 :   if (x == find)
     986                 :             :     return 1;
     987                 :             : 
     988                 :     6388415 :   code = GET_CODE (x);
     989                 :             : 
     990                 :     6388415 :   switch (code)
     991                 :             :     {
     992                 :             :     case REG:
     993                 :             :     CASE_CONST_ANY:
     994                 :             :     case SYMBOL_REF:
     995                 :             :     case CODE_LABEL:
     996                 :             :     case PC:
     997                 :             :       return 0;
     998                 :             : 
     999                 :           0 :     case EXPR_LIST:
    1000                 :           0 :       count = count_occurrences (XEXP (x, 0), find, count_dest);
    1001                 :           0 :       if (XEXP (x, 1))
    1002                 :           0 :         count += count_occurrences (XEXP (x, 1), find, count_dest);
    1003                 :             :       return count;
    1004                 :             : 
    1005                 :       72791 :     case MEM:
    1006                 :       72791 :       if (MEM_P (find) && rtx_equal_p (x, find))
    1007                 :             :         return 1;
    1008                 :             :       break;
    1009                 :             : 
    1010                 :           0 :     case SET:
    1011                 :           0 :       if (SET_DEST (x) == find && ! count_dest)
    1012                 :           0 :         return count_occurrences (SET_SRC (x), find, count_dest);
    1013                 :             :       break;
    1014                 :             : 
    1015                 :             :     default:
    1016                 :             :       break;
    1017                 :             :     }
    1018                 :             : 
    1019                 :     3244228 :   format_ptr = GET_RTX_FORMAT (code);
    1020                 :     3244228 :   count = 0;
    1021                 :             : 
    1022                 :     9597196 :   for (i = 0; i < GET_RTX_LENGTH (code); i++)
    1023                 :             :     {
    1024                 :     6352968 :       switch (*format_ptr++)
    1025                 :             :         {
    1026                 :     6195108 :         case 'e':
    1027                 :     6195108 :           count += count_occurrences (XEXP (x, i), find, count_dest);
    1028                 :     6195108 :           break;
    1029                 :             : 
    1030                 :             :         case 'E':
    1031                 :      130751 :           for (j = 0; j < XVECLEN (x, i); j++)
    1032                 :      108141 :             count += count_occurrences (XVECEXP (x, i, j), find, count_dest);
    1033                 :             :           break;
    1034                 :             :         }
    1035                 :             :     }
    1036                 :             :   return count;
    1037                 :             : }
    1038                 :             : 
    1039                 :             : 
    1040                 :             : /* Return TRUE if OP is a register or subreg of a register that
    1041                 :             :    holds an unsigned quantity.  Otherwise, return FALSE.  */
    1042                 :             : 
    1043                 :             : bool
    1044                 :           0 : unsigned_reg_p (rtx op)
    1045                 :             : {
    1046                 :           0 :   if (REG_P (op)
    1047                 :           0 :       && REG_EXPR (op)
    1048                 :           0 :       && TYPE_UNSIGNED (TREE_TYPE (REG_EXPR (op))))
    1049                 :             :     return true;
    1050                 :             : 
    1051                 :           0 :   if (GET_CODE (op) == SUBREG
    1052                 :           0 :       && SUBREG_PROMOTED_SIGN (op))
    1053                 :           0 :     return true;
    1054                 :             : 
    1055                 :             :   return false;
    1056                 :             : }
    1057                 :             : 
    1058                 :             : 
    1059                 :             : /* Return true if register REG appears somewhere within IN.
    1060                 :             :    Also works if REG is not a register; in this case it checks
    1061                 :             :    for a subexpression of IN that is Lisp "equal" to REG.  */
    1062                 :             : 
    1063                 :             : bool
    1064                 :   448583262 : reg_mentioned_p (const_rtx reg, const_rtx in)
    1065                 :             : {
    1066                 :   448583262 :   const char *fmt;
    1067                 :   448583262 :   int i;
    1068                 :   448583262 :   enum rtx_code code;
    1069                 :             : 
    1070                 :   448583262 :   if (in == 0)
    1071                 :             :     return false;
    1072                 :             : 
    1073                 :   444419438 :   if (reg == in)
    1074                 :             :     return true;
    1075                 :             : 
    1076                 :   422405242 :   if (GET_CODE (in) == LABEL_REF)
    1077                 :     5565389 :     return reg == label_ref_label (in);
    1078                 :             : 
    1079                 :   416839853 :   code = GET_CODE (in);
    1080                 :             : 
    1081                 :   416839853 :   switch (code)
    1082                 :             :     {
    1083                 :             :       /* Compare registers by number.  */
    1084                 :   130319316 :     case REG:
    1085                 :   130319316 :       return REG_P (reg) && REGNO (in) == REGNO (reg);
    1086                 :             : 
    1087                 :             :       /* These codes have no constituent expressions
    1088                 :             :          and are unique.  */
    1089                 :             :     case SCRATCH:
    1090                 :             :     case PC:
    1091                 :             :       return false;
    1092                 :             : 
    1093                 :             :     CASE_CONST_ANY:
    1094                 :             :       /* These are kept unique for a given value.  */
    1095                 :             :       return false;
    1096                 :             : 
    1097                 :   190109545 :     default:
    1098                 :   190109545 :       break;
    1099                 :             :     }
    1100                 :             : 
    1101                 :   190109545 :   if (GET_CODE (reg) == code && rtx_equal_p (reg, in))
    1102                 :             :     return true;
    1103                 :             : 
    1104                 :   189947043 :   fmt = GET_RTX_FORMAT (code);
    1105                 :             : 
    1106                 :   520467180 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    1107                 :             :     {
    1108                 :   367617882 :       if (fmt[i] == 'E')
    1109                 :             :         {
    1110                 :     2985904 :           int j;
    1111                 :    10152024 :           for (j = XVECLEN (in, i) - 1; j >= 0; j--)
    1112                 :     7380441 :             if (reg_mentioned_p (reg, XVECEXP (in, i, j)))
    1113                 :             :               return true;
    1114                 :             :         }
    1115                 :   364631978 :       else if (fmt[i] == 'e'
    1116                 :   364631978 :                && reg_mentioned_p (reg, XEXP (in, i)))
    1117                 :             :         return true;
    1118                 :             :     }
    1119                 :             :   return false;
    1120                 :             : }
    1121                 :             : 
    1122                 :             : /* Return true if in between BEG and END, exclusive of BEG and END, there is
    1123                 :             :    no CODE_LABEL insn.  */
    1124                 :             : 
    1125                 :             : bool
    1126                 :           0 : no_labels_between_p (const rtx_insn *beg, const rtx_insn *end)
    1127                 :             : {
    1128                 :           0 :   rtx_insn *p;
    1129                 :           0 :   if (beg == end)
    1130                 :             :     return false;
    1131                 :           0 :   for (p = NEXT_INSN (beg); p != end; p = NEXT_INSN (p))
    1132                 :           0 :     if (LABEL_P (p))
    1133                 :             :       return false;
    1134                 :             :   return true;
    1135                 :             : }
    1136                 :             : 
    1137                 :             : /* Return true if register REG is used in an insn between
    1138                 :             :    FROM_INSN and TO_INSN (exclusive of those two).  */
    1139                 :             : 
    1140                 :             : bool
    1141                 :    17570446 : reg_used_between_p (const_rtx reg, const rtx_insn *from_insn,
    1142                 :             :                     const rtx_insn *to_insn)
    1143                 :             : {
    1144                 :    17570446 :   rtx_insn *insn;
    1145                 :             : 
    1146                 :    17570446 :   if (from_insn == to_insn)
    1147                 :             :     return false;
    1148                 :             : 
    1149                 :   142248371 :   for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
    1150                 :   107444510 :     if (NONDEBUG_INSN_P (insn)
    1151                 :   107444510 :         && (reg_overlap_mentioned_p (reg, PATTERN (insn))
    1152                 :    62136891 :            || (CALL_P (insn) && find_reg_fusage (insn, USE, reg))))
    1153                 :      337031 :       return true;
    1154                 :             :   return false;
    1155                 :             : }
    1156                 :             : 
    1157                 :             : /* Return true if the old value of X, a register, is referenced in BODY.  If X
    1158                 :             :    is entirely replaced by a new value and the only use is as a SET_DEST,
    1159                 :             :    we do not consider it a reference.  */
    1160                 :             : 
    1161                 :             : bool
    1162                 :   116175248 : reg_referenced_p (const_rtx x, const_rtx body)
    1163                 :             : {
    1164                 :   116175248 :   int i;
    1165                 :             : 
    1166                 :   116175248 :   switch (GET_CODE (body))
    1167                 :             :     {
    1168                 :    83818953 :     case SET:
    1169                 :    83818953 :       if (reg_overlap_mentioned_p (x, SET_SRC (body)))
    1170                 :             :         return true;
    1171                 :             : 
    1172                 :             :       /* If the destination is anything other than PC, a REG or a SUBREG
    1173                 :             :          of a REG that occupies all of the REG, the insn references X if
    1174                 :             :          it is mentioned in the destination.  */
    1175                 :    58691187 :       if (GET_CODE (SET_DEST (body)) != PC
    1176                 :    58691187 :           && !REG_P (SET_DEST (body))
    1177                 :     2578464 :           && ! (GET_CODE (SET_DEST (body)) == SUBREG
    1178                 :      484140 :                 && REG_P (SUBREG_REG (SET_DEST (body)))
    1179                 :      484140 :                 && !read_modify_subreg_p (SET_DEST (body)))
    1180                 :    60500042 :           && reg_overlap_mentioned_p (x, SET_DEST (body)))
    1181                 :             :         return true;
    1182                 :             :       return false;
    1183                 :             : 
    1184                 :        6728 :     case ASM_OPERANDS:
    1185                 :       15867 :       for (i = ASM_OPERANDS_INPUT_LENGTH (body) - 1; i >= 0; i--)
    1186                 :       14645 :         if (reg_overlap_mentioned_p (x, ASM_OPERANDS_INPUT (body, i)))
    1187                 :             :           return true;
    1188                 :             :       return false;
    1189                 :             : 
    1190                 :      700471 :     case CALL:
    1191                 :      700471 :     case USE:
    1192                 :      700471 :     case IF_THEN_ELSE:
    1193                 :      700471 :       return reg_overlap_mentioned_p (x, body);
    1194                 :             : 
    1195                 :           0 :     case TRAP_IF:
    1196                 :           0 :       return reg_overlap_mentioned_p (x, TRAP_CONDITION (body));
    1197                 :             : 
    1198                 :        2046 :     case PREFETCH:
    1199                 :        2046 :       return reg_overlap_mentioned_p (x, XEXP (body, 0));
    1200                 :             : 
    1201                 :       20280 :     case UNSPEC:
    1202                 :       20280 :     case UNSPEC_VOLATILE:
    1203                 :       40542 :       for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
    1204                 :       22872 :         if (reg_overlap_mentioned_p (x, XVECEXP (body, 0, i)))
    1205                 :             :           return true;
    1206                 :             :       return false;
    1207                 :             : 
    1208                 :    16306255 :     case PARALLEL:
    1209                 :    46861791 :       for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
    1210                 :    33718596 :         if (reg_referenced_p (x, XVECEXP (body, 0, i)))
    1211                 :             :           return true;
    1212                 :             :       return false;
    1213                 :             : 
    1214                 :    15315238 :     case CLOBBER:
    1215                 :    15315238 :       if (MEM_P (XEXP (body, 0)))
    1216                 :       11855 :         if (reg_overlap_mentioned_p (x, XEXP (XEXP (body, 0), 0)))
    1217                 :             :           return true;
    1218                 :             :       return false;
    1219                 :             : 
    1220                 :           0 :     case COND_EXEC:
    1221                 :           0 :       if (reg_overlap_mentioned_p (x, COND_EXEC_TEST (body)))
    1222                 :             :         return true;
    1223                 :           0 :       return reg_referenced_p (x, COND_EXEC_CODE (body));
    1224                 :             : 
    1225                 :             :     default:
    1226                 :             :       return false;
    1227                 :             :     }
    1228                 :             : }
    1229                 :             : 
    1230                 :             : /* Return true if register REG is set or clobbered in an insn between
    1231                 :             :    FROM_INSN and TO_INSN (exclusive of those two).  */
    1232                 :             : 
    1233                 :             : bool
    1234                 :    59444610 : reg_set_between_p (const_rtx reg, const rtx_insn *from_insn,
    1235                 :             :                    const rtx_insn *to_insn)
    1236                 :             : {
    1237                 :    59444610 :   const rtx_insn *insn;
    1238                 :             : 
    1239                 :    59444610 :   if (from_insn == to_insn)
    1240                 :             :     return false;
    1241                 :             : 
    1242                 :   293547268 :   for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
    1243                 :   177873155 :     if (INSN_P (insn) && reg_set_p (reg, insn))
    1244                 :             :       return true;
    1245                 :             :   return false;
    1246                 :             : }
    1247                 :             : 
    1248                 :             : /* Return true if REG is set or clobbered inside INSN.  */
    1249                 :             : 
    1250                 :             : bool
    1251                 :  1073034189 : reg_set_p (const_rtx reg, const_rtx insn)
    1252                 :             : {
    1253                 :             :   /* After delay slot handling, call and branch insns might be in a
    1254                 :             :      sequence.  Check all the elements there.  */
    1255                 :  1073034189 :   if (INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE)
    1256                 :             :     {
    1257                 :           0 :       for (int i = 0; i < XVECLEN (PATTERN (insn), 0); ++i)
    1258                 :           0 :         if (reg_set_p (reg, XVECEXP (PATTERN (insn), 0, i)))
    1259                 :             :           return true;
    1260                 :             : 
    1261                 :             :       return false;
    1262                 :             :     }
    1263                 :             : 
    1264                 :             :   /* We can be passed an insn or part of one.  If we are passed an insn,
    1265                 :             :      check if a side-effect of the insn clobbers REG.  */
    1266                 :  1073034189 :   if (INSN_P (insn)
    1267                 :  1073034189 :       && (FIND_REG_INC_NOTE (insn, reg)
    1268                 :             :           || (CALL_P (insn)
    1269                 :    63598014 :               && ((REG_P (reg)
    1270                 :    63598014 :                    && REGNO (reg) < FIRST_PSEUDO_REGISTER
    1271                 :    59536318 :                    && (insn_callee_abi (as_a<const rtx_insn *> (insn))
    1272                 :    59536318 :                        .clobbers_reg_p (GET_MODE (reg), REGNO (reg))))
    1273                 :    62660180 :                   || MEM_P (reg)
    1274                 :    62660180 :                   || find_reg_fusage (insn, CLOBBER, reg)))))
    1275                 :      937962 :     return true;
    1276                 :             : 
    1277                 :             :   /* There are no REG_INC notes for SP autoinc.  */
    1278                 :  1072096227 :   if (reg == stack_pointer_rtx && INSN_P (insn))
    1279                 :             :     {
    1280                 :     6158874 :       subrtx_var_iterator::array_type array;
    1281                 :    49584283 :       FOR_EACH_SUBRTX_VAR (iter, array, PATTERN (insn), NONCONST)
    1282                 :             :         {
    1283                 :    44139947 :           rtx mem = *iter;
    1284                 :    44139947 :           if (mem
    1285                 :    44139947 :               && MEM_P (mem)
    1286                 :     4896847 :               && GET_RTX_CLASS (GET_CODE (XEXP (mem, 0))) == RTX_AUTOINC)
    1287                 :             :             {
    1288                 :      714538 :               if (XEXP (XEXP (mem, 0), 0) == stack_pointer_rtx)
    1289                 :      714538 :                 return true;
    1290                 :           0 :               iter.skip_subrtxes ();
    1291                 :             :             }
    1292                 :             :         }
    1293                 :     6158874 :     }
    1294                 :             : 
    1295                 :  1071381689 :   return set_of (reg, insn) != NULL_RTX;
    1296                 :             : }
    1297                 :             : 
    1298                 :             : /* Similar to reg_set_between_p, but check all registers in X.  Return false
    1299                 :             :    only if none of them are modified between START and END.  Return true if
    1300                 :             :    X contains a MEM; this routine does use memory aliasing.  */
    1301                 :             : 
    1302                 :             : bool
    1303                 :   147966303 : modified_between_p (const_rtx x, const rtx_insn *start, const rtx_insn *end)
    1304                 :             : {
    1305                 :   147966303 :   const enum rtx_code code = GET_CODE (x);
    1306                 :   147966303 :   const char *fmt;
    1307                 :   147966303 :   int i, j;
    1308                 :   147966303 :   rtx_insn *insn;
    1309                 :             : 
    1310                 :   147966303 :   if (start == end)
    1311                 :             :     return false;
    1312                 :             : 
    1313                 :   147966303 :   switch (code)
    1314                 :             :     {
    1315                 :             :     CASE_CONST_ANY:
    1316                 :             :     case CONST:
    1317                 :             :     case SYMBOL_REF:
    1318                 :             :     case LABEL_REF:
    1319                 :             :       return false;
    1320                 :             : 
    1321                 :             :     case PC:
    1322                 :             :       return true;
    1323                 :             : 
    1324                 :     9953702 :     case MEM:
    1325                 :     9953702 :       if (modified_between_p (XEXP (x, 0), start, end))
    1326                 :             :         return true;
    1327                 :     9945462 :       if (MEM_READONLY_P (x))
    1328                 :             :         return false;
    1329                 :    53545419 :       for (insn = NEXT_INSN (start); insn != end; insn = NEXT_INSN (insn))
    1330                 :    34528097 :         if (memory_modified_in_insn_p (x, insn))
    1331                 :             :           return true;
    1332                 :             :       return false;
    1333                 :             : 
    1334                 :    56521750 :     case REG:
    1335                 :    56521750 :       return reg_set_between_p (x, start, end);
    1336                 :             : 
    1337                 :    46564514 :     default:
    1338                 :    46564514 :       break;
    1339                 :             :     }
    1340                 :             : 
    1341                 :    46564514 :   fmt = GET_RTX_FORMAT (code);
    1342                 :   136645293 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    1343                 :             :     {
    1344                 :    91334480 :       if (fmt[i] == 'e' && modified_between_p (XEXP (x, i), start, end))
    1345                 :             :         return true;
    1346                 :             : 
    1347                 :    90081447 :       else if (fmt[i] == 'E')
    1348                 :     3563889 :         for (j = XVECLEN (x, i) - 1; j >= 0; j--)
    1349                 :     2587474 :           if (modified_between_p (XVECEXP (x, i, j), start, end))
    1350                 :             :             return true;
    1351                 :             :     }
    1352                 :             : 
    1353                 :             :   return false;
    1354                 :             : }
    1355                 :             : 
    1356                 :             : /* Similar to reg_set_p, but check all registers in X.  Return false only if
    1357                 :             :    none of them are modified in INSN.  Return true if X contains a MEM; this
    1358                 :             :    routine does use memory aliasing.  */
    1359                 :             : 
    1360                 :             : bool
    1361                 :   988640315 : modified_in_p (const_rtx x, const_rtx insn)
    1362                 :             : {
    1363                 :   988640315 :   const enum rtx_code code = GET_CODE (x);
    1364                 :   988640315 :   const char *fmt;
    1365                 :   988640315 :   int i, j;
    1366                 :             : 
    1367                 :   988640315 :   switch (code)
    1368                 :             :     {
    1369                 :             :     CASE_CONST_ANY:
    1370                 :             :     case CONST:
    1371                 :             :     case SYMBOL_REF:
    1372                 :             :     case LABEL_REF:
    1373                 :             :       return false;
    1374                 :             : 
    1375                 :             :     case PC:
    1376                 :             :       return true;
    1377                 :             : 
    1378                 :     7491539 :     case MEM:
    1379                 :     7491539 :       if (modified_in_p (XEXP (x, 0), insn))
    1380                 :             :         return true;
    1381                 :     7456420 :       if (MEM_READONLY_P (x))
    1382                 :             :         return false;
    1383                 :     7250690 :       if (memory_modified_in_insn_p (x, insn))
    1384                 :             :         return true;
    1385                 :             :       return false;
    1386                 :             : 
    1387                 :   865031578 :     case REG:
    1388                 :   865031578 :       return reg_set_p (x, insn);
    1389                 :             : 
    1390                 :    64834654 :     default:
    1391                 :    64834654 :       break;
    1392                 :             :     }
    1393                 :             : 
    1394                 :    64834654 :   fmt = GET_RTX_FORMAT (code);
    1395                 :   186081101 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    1396                 :             :     {
    1397                 :   127114365 :       if (fmt[i] == 'e' && modified_in_p (XEXP (x, i), insn))
    1398                 :             :         return true;
    1399                 :             : 
    1400                 :   121254563 :       else if (fmt[i] == 'E')
    1401                 :     1263762 :         for (j = XVECLEN (x, i) - 1; j >= 0; j--)
    1402                 :      652718 :           if (modified_in_p (XVECEXP (x, i, j), insn))
    1403                 :             :             return true;
    1404                 :             :     }
    1405                 :             : 
    1406                 :             :   return false;
    1407                 :             : }
    1408                 :             : 
    1409                 :             : /* Return true if X is a SUBREG and if storing a value to X would
    1410                 :             :    preserve some of its SUBREG_REG.  For example, on a normal 32-bit
    1411                 :             :    target, using a SUBREG to store to one half of a DImode REG would
    1412                 :             :    preserve the other half.  */
    1413                 :             : 
    1414                 :             : bool
    1415                 :   136254988 : read_modify_subreg_p (const_rtx x)
    1416                 :             : {
    1417                 :   136254988 :   if (GET_CODE (x) != SUBREG)
    1418                 :             :     return false;
    1419                 :    47350774 :   poly_uint64 isize = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)));
    1420                 :    47350774 :   poly_uint64 osize = GET_MODE_SIZE (GET_MODE (x));
    1421                 :    23675387 :   poly_uint64 regsize = REGMODE_NATURAL_SIZE (GET_MODE (SUBREG_REG (x)));
    1422                 :             :   /* The inner and outer modes of a subreg must be ordered, so that we
    1423                 :             :      can tell whether they're paradoxical or partial.  */
    1424                 :    23675387 :   gcc_checking_assert (ordered_p (isize, osize));
    1425                 :    23675387 :   return (maybe_gt (isize, osize) && maybe_gt (isize, regsize));
    1426                 :             : }
    1427                 :             : 
    1428                 :             : /* Helper function for set_of.  */
    1429                 :             : struct set_of_data
    1430                 :             :   {
    1431                 :             :     const_rtx found;
    1432                 :             :     const_rtx pat;
    1433                 :             :   };
    1434                 :             : 
    1435                 :             : static void
    1436                 :  1144368704 : set_of_1 (rtx x, const_rtx pat, void *data1)
    1437                 :             : {
    1438                 :  1144368704 :   struct set_of_data *const data = (struct set_of_data *) (data1);
    1439                 :  1144368704 :   if (rtx_equal_p (x, data->pat)
    1440                 :  1144368704 :       || (!MEM_P (x) && reg_overlap_mentioned_p (data->pat, x)))
    1441                 :    57365965 :     data->found = pat;
    1442                 :  1144368704 : }
    1443                 :             : 
    1444                 :             : /* Give an INSN, return a SET or CLOBBER expression that does modify PAT
    1445                 :             :    (either directly or via STRICT_LOW_PART and similar modifiers).  */
    1446                 :             : const_rtx
    1447                 :  1117805949 : set_of (const_rtx pat, const_rtx insn)
    1448                 :             : {
    1449                 :  1117805949 :   struct set_of_data data;
    1450                 :  1117805949 :   data.found = NULL_RTX;
    1451                 :  1117805949 :   data.pat = pat;
    1452                 :  1117805949 :   note_pattern_stores (INSN_P (insn) ? PATTERN (insn) : insn, set_of_1, &data);
    1453                 :  1117805949 :   return data.found;
    1454                 :             : }
    1455                 :             : 
    1456                 :             : /* Check whether instruction pattern PAT contains a SET with the following
    1457                 :             :    properties:
    1458                 :             : 
    1459                 :             :    - the SET is executed unconditionally; and
    1460                 :             :    - either:
    1461                 :             :      - the destination of the SET is a REG that contains REGNO; or
    1462                 :             :      - both:
    1463                 :             :        - the destination of the SET is a SUBREG of such a REG; and
    1464                 :             :        - writing to the subreg clobbers all of the SUBREG_REG
    1465                 :             :          (in other words, read_modify_subreg_p is false).
    1466                 :             : 
    1467                 :             :    If PAT does have a SET like that, return the set, otherwise return null.
    1468                 :             : 
    1469                 :             :    This is intended to be an alternative to single_set for passes that
    1470                 :             :    can handle patterns with multiple_sets.  */
    1471                 :             : rtx
    1472                 :   120450066 : simple_regno_set (rtx pat, unsigned int regno)
    1473                 :             : {
    1474                 :   120450066 :   if (GET_CODE (pat) == PARALLEL)
    1475                 :             :     {
    1476                 :    19831322 :       int last = XVECLEN (pat, 0) - 1;
    1477                 :    19831436 :       for (int i = 0; i < last; ++i)
    1478                 :    19831322 :         if (rtx set = simple_regno_set (XVECEXP (pat, 0, i), regno))
    1479                 :             :           return set;
    1480                 :             : 
    1481                 :         114 :       pat = XVECEXP (pat, 0, last);
    1482                 :             :     }
    1483                 :             : 
    1484                 :   100618858 :   if (GET_CODE (pat) == SET
    1485                 :   100618858 :       && covers_regno_no_parallel_p (SET_DEST (pat), regno))
    1486                 :             :     return pat;
    1487                 :             : 
    1488                 :             :   return nullptr;
    1489                 :             : }
    1490                 :             : 
    1491                 :             : /* Add all hard register in X to *PSET.  */
    1492                 :             : void
    1493                 :     3669100 : find_all_hard_regs (const_rtx x, HARD_REG_SET *pset)
    1494                 :             : {
    1495                 :     3669100 :   subrtx_iterator::array_type array;
    1496                 :     9990740 :   FOR_EACH_SUBRTX (iter, array, x, NONCONST)
    1497                 :             :     {
    1498                 :     6321640 :       const_rtx x = *iter;
    1499                 :     6321640 :       if (REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER)
    1500                 :     3088152 :         add_to_hard_reg_set (pset, GET_MODE (x), REGNO (x));
    1501                 :             :     }
    1502                 :     3669100 : }
    1503                 :             : 
    1504                 :             : /* This function, called through note_stores, collects sets and
    1505                 :             :    clobbers of hard registers in a HARD_REG_SET, which is pointed to
    1506                 :             :    by DATA.  */
    1507                 :             : void
    1508                 :    21343586 : record_hard_reg_sets (rtx x, const_rtx pat ATTRIBUTE_UNUSED, void *data)
    1509                 :             : {
    1510                 :    21343586 :   HARD_REG_SET *pset = (HARD_REG_SET *)data;
    1511                 :    21343586 :   if (REG_P (x) && HARD_REGISTER_P (x))
    1512                 :    14188965 :     add_to_hard_reg_set (pset, GET_MODE (x), REGNO (x));
    1513                 :    21343586 : }
    1514                 :             : 
    1515                 :             : /* Examine INSN, and compute the set of hard registers written by it.
    1516                 :             :    Store it in *PSET.  Should only be called after reload.
    1517                 :             : 
    1518                 :             :    IMPLICIT is true if we should include registers that are fully-clobbered
    1519                 :             :    by calls.  This should be used with caution, since it doesn't include
    1520                 :             :    partially-clobbered registers.  */
    1521                 :             : void
    1522                 :    16402236 : find_all_hard_reg_sets (const rtx_insn *insn, HARD_REG_SET *pset, bool implicit)
    1523                 :             : {
    1524                 :    16402236 :   rtx link;
    1525                 :             : 
    1526                 :    16402236 :   CLEAR_HARD_REG_SET (*pset);
    1527                 :    16402236 :   note_stores (insn, record_hard_reg_sets, pset);
    1528                 :    16402236 :   if (CALL_P (insn) && implicit)
    1529                 :           0 :     *pset |= insn_callee_abi (insn).full_reg_clobbers ();
    1530                 :    32267913 :   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    1531                 :    15865677 :     if (REG_NOTE_KIND (link) == REG_INC)
    1532                 :           0 :       record_hard_reg_sets (XEXP (link, 0), NULL, pset);
    1533                 :    16402236 : }
    1534                 :             : 
    1535                 :             : /* Like record_hard_reg_sets, but called through note_uses.  */
    1536                 :             : void
    1537                 :     3669100 : record_hard_reg_uses (rtx *px, void *data)
    1538                 :             : {
    1539                 :     3669100 :   find_all_hard_regs (*px, (HARD_REG_SET *) data);
    1540                 :     3669100 : }
    1541                 :             : 
    1542                 :             : /* Given an INSN, return a SET expression if this insn has only a single SET.
    1543                 :             :    It may also have CLOBBERs, USEs, or SET whose output
    1544                 :             :    will not be used, which we ignore.  */
    1545                 :             : 
    1546                 :             : rtx
    1547                 :  1693291871 : single_set_2 (const rtx_insn *insn, const_rtx pat)
    1548                 :             : {
    1549                 :  1693291871 :   rtx set = NULL;
    1550                 :  1693291871 :   int set_verified = 1;
    1551                 :  1693291871 :   int i;
    1552                 :             : 
    1553                 :  1693291871 :   if (GET_CODE (pat) == PARALLEL)
    1554                 :             :     {
    1555                 :  2003194420 :       for (i = 0; i < XVECLEN (pat, 0); i++)
    1556                 :             :         {
    1557                 :  1364458735 :           rtx sub = XVECEXP (pat, 0, i);
    1558                 :  1364458735 :           switch (GET_CODE (sub))
    1559                 :             :             {
    1560                 :             :             case USE:
    1561                 :             :             case CLOBBER:
    1562                 :             :               break;
    1563                 :             : 
    1564                 :   686753476 :             case SET:
    1565                 :             :               /* We can consider insns having multiple sets, where all
    1566                 :             :                  but one are dead as single set insns.  In common case
    1567                 :             :                  only single set is present in the pattern so we want
    1568                 :             :                  to avoid checking for REG_UNUSED notes unless necessary.
    1569                 :             : 
    1570                 :             :                  When we reach set first time, we just expect this is
    1571                 :             :                  the single set we are looking for and only when more
    1572                 :             :                  sets are found in the insn, we check them.  */
    1573                 :   686753476 :               if (!set_verified)
    1574                 :             :                 {
    1575                 :    30254816 :                   if (find_reg_note (insn, REG_UNUSED, SET_DEST (set))
    1576                 :    30254816 :                       && !side_effects_p (set))
    1577                 :             :                     set = NULL;
    1578                 :             :                   else
    1579                 :             :                     set_verified = 1;
    1580                 :             :                 }
    1581                 :   686753476 :               if (!set)
    1582                 :             :                 set = sub, set_verified = 0;
    1583                 :    21585290 :               else if (!find_reg_note (insn, REG_UNUSED, SET_DEST (sub))
    1584                 :    21585290 :                        || side_effects_p (sub))
    1585                 :    17309193 :                 return NULL_RTX;
    1586                 :             :               break;
    1587                 :             : 
    1588                 :             :             default:
    1589                 :             :               return NULL_RTX;
    1590                 :             :             }
    1591                 :             :         }
    1592                 :             :     }
    1593                 :             :   return set;
    1594                 :             : }
    1595                 :             : 
    1596                 :             : /* Given an INSN, return true if it has more than one SET, else return
    1597                 :             :    false.  */
    1598                 :             : 
    1599                 :             : bool
    1600                 :   267659573 : multiple_sets (const_rtx insn)
    1601                 :             : {
    1602                 :   267659573 :   bool found;
    1603                 :   267659573 :   int i;
    1604                 :             : 
    1605                 :             :   /* INSN must be an insn.  */
    1606                 :   267659573 :   if (! INSN_P (insn))
    1607                 :             :     return false;
    1608                 :             : 
    1609                 :             :   /* Only a PARALLEL can have multiple SETs.  */
    1610                 :   267659573 :   if (GET_CODE (PATTERN (insn)) == PARALLEL)
    1611                 :             :     {
    1612                 :   242042046 :       for (i = 0, found = false; i < XVECLEN (PATTERN (insn), 0); i++)
    1613                 :   163235935 :         if (GET_CODE (XVECEXP (PATTERN (insn), 0, i)) == SET)
    1614                 :             :           {
    1615                 :             :             /* If we have already found a SET, then return now.  */
    1616                 :    82457925 :             if (found)
    1617                 :             :               return true;
    1618                 :             :             else
    1619                 :             :               found = true;
    1620                 :             :           }
    1621                 :             :     }
    1622                 :             : 
    1623                 :             :   /* Either zero or one SET.  */
    1624                 :             :   return false;
    1625                 :             : }
    1626                 :             : 
    1627                 :             : /* Return true if the destination of SET equals the source
    1628                 :             :    and there are no side effects.  */
    1629                 :             : 
    1630                 :             : bool
    1631                 :  1567045248 : set_noop_p (const_rtx set)
    1632                 :             : {
    1633                 :  1567045248 :   rtx src = SET_SRC (set);
    1634                 :  1567045248 :   rtx dst = SET_DEST (set);
    1635                 :             : 
    1636                 :  1567045248 :   if (dst == pc_rtx && src == pc_rtx)
    1637                 :             :     return true;
    1638                 :             : 
    1639                 :  1567038220 :   if (MEM_P (dst) && MEM_P (src))
    1640                 :     8956581 :     return (rtx_equal_p (dst, src)
    1641                 :        5973 :             && !side_effects_p (dst)
    1642                 :     8962417 :             && !side_effects_p (src));
    1643                 :             : 
    1644                 :  1558081639 :   if (GET_CODE (dst) == ZERO_EXTRACT)
    1645                 :      121700 :     return (rtx_equal_p (XEXP (dst, 0), src)
    1646                 :        6263 :             && !BITS_BIG_ENDIAN && XEXP (dst, 2) == const0_rtx
    1647                 :           0 :             && !side_effects_p (src)
    1648                 :      121700 :             && !side_effects_p (XEXP (dst, 0)));
    1649                 :             : 
    1650                 :  1557959939 :   if (GET_CODE (dst) == STRICT_LOW_PART)
    1651                 :      261381 :     dst = XEXP (dst, 0);
    1652                 :             : 
    1653                 :  1557959939 :   if (GET_CODE (src) == SUBREG && GET_CODE (dst) == SUBREG)
    1654                 :             :     {
    1655                 :      858014 :       if (maybe_ne (SUBREG_BYTE (src), SUBREG_BYTE (dst)))
    1656                 :             :         return false;
    1657                 :      805226 :       src = SUBREG_REG (src);
    1658                 :      805226 :       dst = SUBREG_REG (dst);
    1659                 :      805226 :       if (GET_MODE (src) != GET_MODE (dst))
    1660                 :             :         /* It is hard to tell whether subregs refer to the same bits, so act
    1661                 :             :            conservatively and return false.  */
    1662                 :             :         return false;
    1663                 :             :     }
    1664                 :             : 
    1665                 :             :   /* It is a NOOP if destination overlaps with selected src vector
    1666                 :             :      elements.  */
    1667                 :  1557835598 :   if (GET_CODE (src) == VEC_SELECT
    1668                 :     7300421 :       && REG_P (XEXP (src, 0)) && REG_P (dst)
    1669                 :     2442225 :       && HARD_REGISTER_P (XEXP (src, 0))
    1670                 :  1558353615 :       && HARD_REGISTER_P (dst))
    1671                 :             :     {
    1672                 :      517777 :       int i;
    1673                 :      517777 :       rtx par = XEXP (src, 1);
    1674                 :      517777 :       rtx src0 = XEXP (src, 0);
    1675                 :      517777 :       poly_int64 c0;
    1676                 :      517777 :       if (!poly_int_rtx_p (XVECEXP (par, 0, 0), &c0))
    1677                 :             :         return false;
    1678                 :     1035554 :       poly_int64 offset = GET_MODE_UNIT_SIZE (GET_MODE (src0)) * c0;
    1679                 :             : 
    1680                 :      874095 :       for (i = 1; i < XVECLEN (par, 0); i++)
    1681                 :             :         {
    1682                 :      557518 :           poly_int64 c0i;
    1683                 :      557518 :           if (!poly_int_rtx_p (XVECEXP (par, 0, i), &c0i)
    1684                 :      557518 :               || maybe_ne (c0i, c0 + i))
    1685                 :  1566457152 :             return false;
    1686                 :             :         }
    1687                 :      316577 :       return
    1688                 :      316577 :         REG_CAN_CHANGE_MODE_P (REGNO (dst), GET_MODE (src0), GET_MODE (dst))
    1689                 :      316577 :         && validate_subreg (GET_MODE (dst), GET_MODE (src0), src0, offset)
    1690                 :      744004 :         && simplify_subreg_regno (REGNO (src0), GET_MODE (src0),
    1691                 :      125313 :                                   offset, GET_MODE (dst)) == (int) REGNO (dst);
    1692                 :             :     }
    1693                 :             : 
    1694                 :   395593397 :   return (REG_P (src) && REG_P (dst)
    1695                 :  1778048456 :           && REGNO (src) == REGNO (dst));
    1696                 :             : }
    1697                 :             : 
    1698                 :             : /* Return true if an insn consists only of SETs, each of which only sets a
    1699                 :             :    value to itself.  */
    1700                 :             : 
    1701                 :             : bool
    1702                 :  1065196906 : noop_move_p (const rtx_insn *insn)
    1703                 :             : {
    1704                 :  1065196906 :   rtx pat = PATTERN (insn);
    1705                 :             : 
    1706                 :  1065196906 :   if (INSN_CODE (insn) == NOOP_MOVE_INSN_CODE)
    1707                 :             :     return true;
    1708                 :             : 
    1709                 :             :   /* Check the code to be executed for COND_EXEC.  */
    1710                 :  1065191352 :   if (GET_CODE (pat) == COND_EXEC)
    1711                 :           0 :     pat = COND_EXEC_CODE (pat);
    1712                 :             : 
    1713                 :  1065191352 :   if (GET_CODE (pat) == SET && set_noop_p (pat))
    1714                 :             :     return true;
    1715                 :             : 
    1716                 :  1065158461 :   if (GET_CODE (pat) == PARALLEL)
    1717                 :             :     {
    1718                 :             :       int i;
    1719                 :             :       /* If nothing but SETs of registers to themselves,
    1720                 :             :          this insn can also be deleted.  */
    1721                 :   147513750 :       for (i = 0; i < XVECLEN (pat, 0); i++)
    1722                 :             :         {
    1723                 :   147513622 :           rtx tem = XVECEXP (pat, 0, i);
    1724                 :             : 
    1725                 :   147513622 :           if (GET_CODE (tem) == USE || GET_CODE (tem) == CLOBBER)
    1726                 :       21443 :             continue;
    1727                 :             : 
    1728                 :   147492179 :           if (GET_CODE (tem) != SET || ! set_noop_p (tem))
    1729                 :   147492013 :             return false;
    1730                 :             :         }
    1731                 :             : 
    1732                 :             :       return true;
    1733                 :             :     }
    1734                 :             :   return false;
    1735                 :             : }
    1736                 :             : 
    1737                 :             : 
    1738                 :             : /* Return true if register in range [REGNO, ENDREGNO)
    1739                 :             :    appears either explicitly or implicitly in X
    1740                 :             :    other than being stored into.
    1741                 :             : 
    1742                 :             :    References contained within the substructure at LOC do not count.
    1743                 :             :    LOC may be zero, meaning don't ignore anything.  */
    1744                 :             : 
    1745                 :             : bool
    1746                 :  2035121747 : refers_to_regno_p (unsigned int regno, unsigned int endregno, const_rtx x,
    1747                 :             :                    rtx *loc)
    1748                 :             : {
    1749                 :  2698036660 :   int i;
    1750                 :  2698036660 :   unsigned int x_regno;
    1751                 :  2698036660 :   RTX_CODE code;
    1752                 :  2698036660 :   const char *fmt;
    1753                 :             : 
    1754                 :  2698036660 :  repeat:
    1755                 :             :   /* The contents of a REG_NONNEG note is always zero, so we must come here
    1756                 :             :      upon repeat in case the last REG_NOTE is a REG_NONNEG note.  */
    1757                 :  2698036660 :   if (x == 0)
    1758                 :             :     return false;
    1759                 :             : 
    1760                 :  2698036660 :   code = GET_CODE (x);
    1761                 :             : 
    1762                 :  2698036660 :   switch (code)
    1763                 :             :     {
    1764                 :  1490534759 :     case REG:
    1765                 :  1490534759 :       x_regno = REGNO (x);
    1766                 :             : 
    1767                 :             :       /* If we modifying the stack, frame, or argument pointer, it will
    1768                 :             :          clobber a virtual register.  In fact, we could be more precise,
    1769                 :             :          but it isn't worth it.  */
    1770                 :  1490534759 :       if ((x_regno == STACK_POINTER_REGNUM
    1771                 :  1490534759 :            || (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
    1772                 :  1490534759 :                && x_regno == ARG_POINTER_REGNUM)
    1773                 :             :            || x_regno == FRAME_POINTER_REGNUM)
    1774                 :   123672766 :           && VIRTUAL_REGISTER_NUM_P (regno))
    1775                 :             :         return true;
    1776                 :             : 
    1777                 :  1490534757 :       return endregno > x_regno && regno < END_REGNO (x);
    1778                 :             : 
    1779                 :    32516027 :     case SUBREG:
    1780                 :             :       /* If this is a SUBREG of a hard reg, we can see exactly which
    1781                 :             :          registers are being modified.  Otherwise, handle normally.  */
    1782                 :    32516027 :       if (REG_P (SUBREG_REG (x))
    1783                 :    32516027 :           && REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER)
    1784                 :             :         {
    1785                 :        6210 :           unsigned int inner_regno = subreg_regno (x);
    1786                 :        6210 :           unsigned int inner_endregno
    1787                 :             :             = inner_regno + (inner_regno < FIRST_PSEUDO_REGISTER
    1788                 :        6210 :                              ? subreg_nregs (x) : 1);
    1789                 :             : 
    1790                 :        6210 :           return endregno > inner_regno && regno < inner_endregno;
    1791                 :             :         }
    1792                 :             :       break;
    1793                 :             : 
    1794                 :    88807064 :     case CLOBBER:
    1795                 :    88807064 :     case SET:
    1796                 :    88807064 :       if (&SET_DEST (x) != loc
    1797                 :             :           /* Note setting a SUBREG counts as referring to the REG it is in for
    1798                 :             :              a pseudo but not for hard registers since we can
    1799                 :             :              treat each word individually.  */
    1800                 :    88807064 :           && ((GET_CODE (SET_DEST (x)) == SUBREG
    1801                 :      620593 :                && loc != &SUBREG_REG (SET_DEST (x))
    1802                 :      620593 :                && REG_P (SUBREG_REG (SET_DEST (x)))
    1803                 :      620593 :                && REGNO (SUBREG_REG (SET_DEST (x))) >= FIRST_PSEUDO_REGISTER
    1804                 :      620593 :                && refers_to_regno_p (regno, endregno,
    1805                 :             :                                      SUBREG_REG (SET_DEST (x)), loc))
    1806                 :    88781765 :               || (!REG_P (SET_DEST (x))
    1807                 :     9523735 :                   && refers_to_regno_p (regno, endregno, SET_DEST (x), loc))))
    1808                 :      128396 :         return true;
    1809                 :             : 
    1810                 :    88678668 :       if (code == CLOBBER || loc == &SET_SRC (x))
    1811                 :             :         return false;
    1812                 :    74207790 :       x = SET_SRC (x);
    1813                 :    74207790 :       goto repeat;
    1814                 :             : 
    1815                 :             :     default:
    1816                 :             :       break;
    1817                 :             :     }
    1818                 :             : 
    1819                 :             :   /* X does not match, so try its subexpressions.  */
    1820                 :             : 
    1821                 :  1118688627 :   fmt = GET_RTX_FORMAT (code);
    1822                 :  2181938438 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    1823                 :             :     {
    1824                 :  1658591242 :       if (fmt[i] == 'e' && loc != &XEXP (x, i))
    1825                 :             :         {
    1826                 :  1013988025 :           if (i == 0)
    1827                 :             :             {
    1828                 :   588707123 :               x = XEXP (x, 0);
    1829                 :   588707123 :               goto repeat;
    1830                 :             :             }
    1831                 :             :           else
    1832                 :   425280902 :             if (refers_to_regno_p (regno, endregno, XEXP (x, i), loc))
    1833                 :             :               return true;
    1834                 :             :         }
    1835                 :   644603217 :       else if (fmt[i] == 'E')
    1836                 :             :         {
    1837                 :    40853272 :           int j;
    1838                 :   150427103 :           for (j = XVECLEN (x, i) - 1; j >= 0; j--)
    1839                 :   111170346 :             if (loc != &XVECEXP (x, i, j)
    1840                 :   111170346 :                 && refers_to_regno_p (regno, endregno, XVECEXP (x, i, j), loc))
    1841                 :             :               return true;
    1842                 :             :         }
    1843                 :             :     }
    1844                 :             :   return false;
    1845                 :             : }
    1846                 :             : 
    1847                 :             : /* Rreturn true if modifying X will affect IN.  If X is a register or a SUBREG,
    1848                 :             :    we check if any register number in X conflicts with the relevant register
    1849                 :             :    numbers.  If X is a constant, return false.  If X is a MEM, return true iff
    1850                 :             :    IN contains a MEM (we don't bother checking for memory addresses that can't
    1851                 :             :    conflict because we expect this to be a rare case.  */
    1852                 :             : 
    1853                 :             : bool
    1854                 :  1380469149 : reg_overlap_mentioned_p (const_rtx x, const_rtx in)
    1855                 :             : {
    1856                 :  1380469149 :   unsigned int regno, endregno;
    1857                 :             : 
    1858                 :             :   /* If either argument is a constant, then modifying X cannot
    1859                 :             :      affect IN.  Here we look at IN, we can profitably combine
    1860                 :             :      CONSTANT_P (x) with the switch statement below.  */
    1861                 :  1380469149 :   if (CONSTANT_P (in))
    1862                 :             :     return false;
    1863                 :             : 
    1864                 :  1352363625 :  recurse:
    1865                 :  1352367084 :   switch (GET_CODE (x))
    1866                 :             :     {
    1867                 :        3459 :     case CLOBBER:
    1868                 :        3459 :     case STRICT_LOW_PART:
    1869                 :        3459 :     case ZERO_EXTRACT:
    1870                 :        3459 :     case SIGN_EXTRACT:
    1871                 :             :       /* Overly conservative.  */
    1872                 :        3459 :       x = XEXP (x, 0);
    1873                 :        3459 :       goto recurse;
    1874                 :             : 
    1875                 :     1333408 :     case SUBREG:
    1876                 :     1333408 :       regno = REGNO (SUBREG_REG (x));
    1877                 :     1333408 :       if (regno < FIRST_PSEUDO_REGISTER)
    1878                 :           0 :         regno = subreg_regno (x);
    1879                 :     1333408 :       endregno = regno + (regno < FIRST_PSEUDO_REGISTER
    1880                 :           0 :                           ? subreg_nregs (x) : 1);
    1881                 :     1333408 :       goto do_reg;
    1882                 :             : 
    1883                 :  1347615163 :     case REG:
    1884                 :  1347615163 :       regno = REGNO (x);
    1885                 :  1347615163 :       endregno = END_REGNO (x);
    1886                 :  1348948571 :     do_reg:
    1887                 :  1348948571 :       return refers_to_regno_p (regno, endregno, in, (rtx*) 0);
    1888                 :             : 
    1889                 :     1632974 :     case MEM:
    1890                 :     1632974 :       {
    1891                 :     1632974 :         const char *fmt;
    1892                 :     1632974 :         int i;
    1893                 :             : 
    1894                 :     1632974 :         if (MEM_P (in))
    1895                 :             :           return true;
    1896                 :             : 
    1897                 :     1497589 :         fmt = GET_RTX_FORMAT (GET_CODE (in));
    1898                 :     3154291 :         for (i = GET_RTX_LENGTH (GET_CODE (in)) - 1; i >= 0; i--)
    1899                 :     1707992 :           if (fmt[i] == 'e')
    1900                 :             :             {
    1901                 :      400525 :               if (reg_overlap_mentioned_p (x, XEXP (in, i)))
    1902                 :             :                 return true;
    1903                 :             :             }
    1904                 :     1307467 :           else if (fmt[i] == 'E')
    1905                 :             :             {
    1906                 :       13050 :               int j;
    1907                 :       45245 :               for (j = XVECLEN (in, i) - 1; j >= 0; --j)
    1908                 :       38412 :                 if (reg_overlap_mentioned_p (x, XVECEXP (in, i, j)))
    1909                 :             :                   return true;
    1910                 :             :             }
    1911                 :             : 
    1912                 :             :         return false;
    1913                 :             :       }
    1914                 :             : 
    1915                 :     1654762 :     case SCRATCH:
    1916                 :     1654762 :     case PC:
    1917                 :     1654762 :       return reg_mentioned_p (x, in);
    1918                 :             : 
    1919                 :         250 :     case PARALLEL:
    1920                 :         250 :       {
    1921                 :         250 :         int i;
    1922                 :             : 
    1923                 :             :         /* If any register in here refers to it we return true.  */
    1924                 :         500 :         for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
    1925                 :         500 :           if (XEXP (XVECEXP (x, 0, i), 0) != 0
    1926                 :         500 :               && reg_overlap_mentioned_p (XEXP (XVECEXP (x, 0, i), 0), in))
    1927                 :             :             return true;
    1928                 :             :         return false;
    1929                 :             :       }
    1930                 :             : 
    1931                 :      127068 :     default:
    1932                 :      127068 :       gcc_assert (CONSTANT_P (x));
    1933                 :             :       return false;
    1934                 :             :     }
    1935                 :             : }
    1936                 :             : 
    1937                 :             : /* Call FUN on each register or MEM that is stored into or clobbered by X.
    1938                 :             :    (X would be the pattern of an insn).  DATA is an arbitrary pointer,
    1939                 :             :    ignored by note_stores, but passed to FUN.
    1940                 :             : 
    1941                 :             :    FUN receives three arguments:
    1942                 :             :    1. the REG, MEM or PC being stored in or clobbered,
    1943                 :             :    2. the SET or CLOBBER rtx that does the store,
    1944                 :             :    3. the pointer DATA provided to note_stores.
    1945                 :             : 
    1946                 :             :   If the item being stored in or clobbered is a SUBREG of a hard register,
    1947                 :             :   the SUBREG will be passed.  */
    1948                 :             : 
    1949                 :             : void
    1950                 :  6509130435 : note_pattern_stores (const_rtx x,
    1951                 :             :                      void (*fun) (rtx, const_rtx, void *), void *data)
    1952                 :             : {
    1953                 :  6509130435 :   int i;
    1954                 :             : 
    1955                 :  6509130435 :   if (GET_CODE (x) == COND_EXEC)
    1956                 :           0 :     x = COND_EXEC_CODE (x);
    1957                 :             : 
    1958                 :  6509130435 :   if (GET_CODE (x) == SET || GET_CODE (x) == CLOBBER)
    1959                 :             :     {
    1960                 :  4851577440 :       rtx dest = SET_DEST (x);
    1961                 :             : 
    1962                 :  4851577440 :       while ((GET_CODE (dest) == SUBREG
    1963                 :    20309338 :               && (!REG_P (SUBREG_REG (dest))
    1964                 :    20309338 :                   || REGNO (SUBREG_REG (dest)) >= FIRST_PSEUDO_REGISTER))
    1965                 :  4852554616 :              || GET_CODE (dest) == ZERO_EXTRACT
    1966                 :  9725090534 :              || GET_CODE (dest) == STRICT_LOW_PART)
    1967                 :    21256184 :         dest = XEXP (dest, 0);
    1968                 :             : 
    1969                 :             :       /* If we have a PARALLEL, SET_DEST is a list of EXPR_LIST expressions,
    1970                 :             :          each of whose first operand is a register.  */
    1971                 :  4851577440 :       if (GET_CODE (dest) == PARALLEL)
    1972                 :             :         {
    1973                 :     1343101 :           for (i = XVECLEN (dest, 0) - 1; i >= 0; i--)
    1974                 :      856834 :             if (XEXP (XVECEXP (dest, 0, i), 0) != 0)
    1975                 :      856834 :               (*fun) (XEXP (XVECEXP (dest, 0, i), 0), x, data);
    1976                 :             :         }
    1977                 :             :       else
    1978                 :  4851091173 :         (*fun) (dest, x, data);
    1979                 :             :     }
    1980                 :             : 
    1981                 :  1657552995 :   else if (GET_CODE (x) == PARALLEL)
    1982                 :  2004031825 :     for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
    1983                 :  1351768220 :       note_pattern_stores (XVECEXP (x, 0, i), fun, data);
    1984                 :  6509130435 : }
    1985                 :             : 
    1986                 :             : /* Same, but for an instruction.  If the instruction is a call, include
    1987                 :             :    any CLOBBERs in its CALL_INSN_FUNCTION_USAGE.  */
    1988                 :             : 
    1989                 :             : void
    1990                 :  3153432570 : note_stores (const rtx_insn *insn,
    1991                 :             :              void (*fun) (rtx, const_rtx, void *), void *data)
    1992                 :             : {
    1993                 :  3153432570 :   if (CALL_P (insn))
    1994                 :   157093537 :     for (rtx link = CALL_INSN_FUNCTION_USAGE (insn);
    1995                 :   449283417 :          link; link = XEXP (link, 1))
    1996                 :   292189880 :       if (GET_CODE (XEXP (link, 0)) == CLOBBER)
    1997                 :    12045344 :         note_pattern_stores (XEXP (link, 0), fun, data);
    1998                 :  3153432570 :   note_pattern_stores (PATTERN (insn), fun, data);
    1999                 :  3153432570 : }
    2000                 :             : 
    2001                 :             : /* Like notes_stores, but call FUN for each expression that is being
    2002                 :             :    referenced in PBODY, a pointer to the PATTERN of an insn.  We only call
    2003                 :             :    FUN for each expression, not any interior subexpressions.  FUN receives a
    2004                 :             :    pointer to the expression and the DATA passed to this function.
    2005                 :             : 
    2006                 :             :    Note that this is not quite the same test as that done in reg_referenced_p
    2007                 :             :    since that considers something as being referenced if it is being
    2008                 :             :    partially set, while we do not.  */
    2009                 :             : 
    2010                 :             : void
    2011                 :  1007463346 : note_uses (rtx *pbody, void (*fun) (rtx *, void *), void *data)
    2012                 :             : {
    2013                 :  1007463346 :   rtx body = *pbody;
    2014                 :  1007463346 :   int i;
    2015                 :             : 
    2016                 :  1007463346 :   switch (GET_CODE (body))
    2017                 :             :     {
    2018                 :           0 :     case COND_EXEC:
    2019                 :           0 :       (*fun) (&COND_EXEC_TEST (body), data);
    2020                 :           0 :       note_uses (&COND_EXEC_CODE (body), fun, data);
    2021                 :           0 :       return;
    2022                 :             : 
    2023                 :    82557023 :     case PARALLEL:
    2024                 :   256383578 :       for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
    2025                 :   173826555 :         note_uses (&XVECEXP (body, 0, i), fun, data);
    2026                 :             :       return;
    2027                 :             : 
    2028                 :           0 :     case SEQUENCE:
    2029                 :           0 :       for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
    2030                 :           0 :         note_uses (&PATTERN (XVECEXP (body, 0, i)), fun, data);
    2031                 :             :       return;
    2032                 :             : 
    2033                 :     5261308 :     case USE:
    2034                 :     5261308 :       (*fun) (&XEXP (body, 0), data);
    2035                 :     5261308 :       return;
    2036                 :             : 
    2037                 :      253274 :     case ASM_OPERANDS:
    2038                 :      351550 :       for (i = ASM_OPERANDS_INPUT_LENGTH (body) - 1; i >= 0; i--)
    2039                 :       98276 :         (*fun) (&ASM_OPERANDS_INPUT (body, i), data);
    2040                 :             :       return;
    2041                 :             : 
    2042                 :      125492 :     case TRAP_IF:
    2043                 :      125492 :       (*fun) (&TRAP_CONDITION (body), data);
    2044                 :      125492 :       return;
    2045                 :             : 
    2046                 :       10617 :     case PREFETCH:
    2047                 :       10617 :       (*fun) (&XEXP (body, 0), data);
    2048                 :       10617 :       return;
    2049                 :             : 
    2050                 :     3197341 :     case UNSPEC:
    2051                 :     3197341 :     case UNSPEC_VOLATILE:
    2052                 :     6417676 :       for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
    2053                 :     3220335 :         (*fun) (&XVECEXP (body, 0, i), data);
    2054                 :             :       return;
    2055                 :             : 
    2056                 :    80240101 :     case CLOBBER:
    2057                 :    80240101 :       if (MEM_P (XEXP (body, 0)))
    2058                 :     3371477 :         (*fun) (&XEXP (XEXP (body, 0), 0), data);
    2059                 :             :       return;
    2060                 :             : 
    2061                 :   517015559 :     case SET:
    2062                 :   517015559 :       {
    2063                 :   517015559 :         rtx dest = SET_DEST (body);
    2064                 :             : 
    2065                 :             :         /* For sets we replace everything in source plus registers in memory
    2066                 :             :            expression in store and operands of a ZERO_EXTRACT.  */
    2067                 :   517015559 :         (*fun) (&SET_SRC (body), data);
    2068                 :             : 
    2069                 :   517015559 :         if (GET_CODE (dest) == ZERO_EXTRACT)
    2070                 :             :           {
    2071                 :       37585 :             (*fun) (&XEXP (dest, 1), data);
    2072                 :       37585 :             (*fun) (&XEXP (dest, 2), data);
    2073                 :             :           }
    2074                 :             : 
    2075                 :   519290198 :         while (GET_CODE (dest) == SUBREG || GET_CODE (dest) == STRICT_LOW_PART)
    2076                 :     2274639 :           dest = XEXP (dest, 0);
    2077                 :             : 
    2078                 :   517015559 :         if (MEM_P (dest))
    2079                 :    87366270 :           (*fun) (&XEXP (dest, 0), data);
    2080                 :             :       }
    2081                 :             :       return;
    2082                 :             : 
    2083                 :   318802631 :     default:
    2084                 :             :       /* All the other possibilities never store.  */
    2085                 :   318802631 :       (*fun) (pbody, data);
    2086                 :   318802631 :       return;
    2087                 :             :     }
    2088                 :             : }
    2089                 :             : 
    2090                 :             : /* Try to add a description of REG X to this object, stopping once
    2091                 :             :    the REF_END limit has been reached.  FLAGS is a bitmask of
    2092                 :             :    rtx_obj_reference flags that describe the context.  */
    2093                 :             : 
    2094                 :             : void
    2095                 :   500833859 : rtx_properties::try_to_add_reg (const_rtx x, unsigned int flags)
    2096                 :             : {
    2097                 :   500833859 :   if (REG_NREGS (x) != 1)
    2098                 :     1982920 :     flags |= rtx_obj_flags::IS_MULTIREG;
    2099                 :   500833859 :   machine_mode mode = GET_MODE (x);
    2100                 :   500833859 :   unsigned int start_regno = REGNO (x);
    2101                 :   500833859 :   unsigned int end_regno = END_REGNO (x);
    2102                 :  1003650638 :   for (unsigned int regno = start_regno; regno < end_regno; ++regno)
    2103                 :   502816779 :     if (ref_iter != ref_end)
    2104                 :   502745098 :       *ref_iter++ = rtx_obj_reference (regno, flags, mode,
    2105                 :   502745098 :                                        regno - start_regno);
    2106                 :   500833859 : }
    2107                 :             : 
    2108                 :             : /* Add a description of destination X to this object.  FLAGS is a bitmask
    2109                 :             :    of rtx_obj_reference flags that describe the context.
    2110                 :             : 
    2111                 :             :    This routine accepts all rtxes that can legitimately appear in a
    2112                 :             :    SET_DEST.  */
    2113                 :             : 
    2114                 :             : void
    2115                 :   255584751 : rtx_properties::try_to_add_dest (const_rtx x, unsigned int flags)
    2116                 :             : {
    2117                 :             :   /* If we have a PARALLEL, SET_DEST is a list of EXPR_LIST expressions,
    2118                 :             :      each of whose first operand is a register.  */
    2119                 :   255584751 :   if (UNLIKELY (GET_CODE (x) == PARALLEL))
    2120                 :             :     {
    2121                 :       81127 :       for (int i = XVECLEN (x, 0) - 1; i >= 0; --i)
    2122                 :       51468 :         if (rtx dest = XEXP (XVECEXP (x, 0, i), 0))
    2123                 :       51468 :           try_to_add_dest (dest, flags);
    2124                 :             :       return;
    2125                 :             :     }
    2126                 :             : 
    2127                 :   255555092 :   unsigned int base_flags = flags & rtx_obj_flags::STICKY_FLAGS;
    2128                 :   255555092 :   flags |= rtx_obj_flags::IS_WRITE;
    2129                 :   256443791 :   for (;;)
    2130                 :   256443791 :     if (GET_CODE (x) == ZERO_EXTRACT)
    2131                 :             :       {
    2132                 :        7733 :         try_to_add_src (XEXP (x, 1), base_flags);
    2133                 :        7733 :         try_to_add_src (XEXP (x, 2), base_flags);
    2134                 :        7733 :         flags |= rtx_obj_flags::IS_READ;
    2135                 :        7733 :         x = XEXP (x, 0);
    2136                 :             :       }
    2137                 :   256436058 :     else if (GET_CODE (x) == STRICT_LOW_PART)
    2138                 :             :       {
    2139                 :       18192 :         flags |= rtx_obj_flags::IS_READ;
    2140                 :       18192 :         x = XEXP (x, 0);
    2141                 :             :       }
    2142                 :   256417866 :     else if (GET_CODE (x) == SUBREG)
    2143                 :             :       {
    2144                 :      862774 :         flags |= rtx_obj_flags::IN_SUBREG;
    2145                 :      862774 :         if (read_modify_subreg_p (x))
    2146                 :      705312 :           flags |= rtx_obj_flags::IS_READ;
    2147                 :      862774 :         x = SUBREG_REG (x);
    2148                 :             :       }
    2149                 :             :     else
    2150                 :             :       break;
    2151                 :             : 
    2152                 :   255555092 :   if (MEM_P (x))
    2153                 :             :     {
    2154                 :    34155318 :       if (ref_iter != ref_end)
    2155                 :    34154284 :         *ref_iter++ = rtx_obj_reference (MEM_REGNO, flags, GET_MODE (x));
    2156                 :             : 
    2157                 :    34155318 :       unsigned int addr_flags = base_flags | rtx_obj_flags::IN_MEM_STORE;
    2158                 :    34155318 :       if (flags & rtx_obj_flags::IS_READ)
    2159                 :        1714 :         addr_flags |= rtx_obj_flags::IN_MEM_LOAD;
    2160                 :    34155318 :       try_to_add_src (XEXP (x, 0), addr_flags);
    2161                 :    34155318 :       return;
    2162                 :             :     }
    2163                 :             : 
    2164                 :   221399774 :   if (LIKELY (REG_P (x)))
    2165                 :             :     {
    2166                 :   201899545 :       if (REGNO (x) == STACK_POINTER_REGNUM)
    2167                 :             :         {
    2168                 :             :           /* Stack accesses are dependent on previous allocations and
    2169                 :             :              anti-dependent on later deallocations, so both types of
    2170                 :             :              stack operation are akin to a memory write.  */
    2171                 :    13811047 :           if (ref_iter != ref_end)
    2172                 :    13811047 :             *ref_iter++ = rtx_obj_reference (MEM_REGNO, flags, BLKmode);
    2173                 :             : 
    2174                 :             :           /* We want to keep sp alive everywhere - by making all
    2175                 :             :              writes to sp also use sp.  */
    2176                 :    13811047 :           flags |= rtx_obj_flags::IS_READ;
    2177                 :             :         }
    2178                 :   201899545 :       try_to_add_reg (x, flags);
    2179                 :   201899545 :       return;
    2180                 :             :     }
    2181                 :             : }
    2182                 :             : 
    2183                 :             : /* Try to add a description of source X to this object, stopping once
    2184                 :             :    the REF_END limit has been reached.  FLAGS is a bitmask of
    2185                 :             :    rtx_obj_reference flags that describe the context.
    2186                 :             : 
    2187                 :             :    This routine accepts all rtxes that can legitimately appear in a SET_SRC.  */
    2188                 :             : 
    2189                 :             : void
    2190                 :   539661501 : rtx_properties::try_to_add_src (const_rtx x, unsigned int flags)
    2191                 :             : {
    2192                 :   539661501 :   unsigned int base_flags = flags & rtx_obj_flags::STICKY_FLAGS;
    2193                 :   539661501 :   subrtx_iterator::array_type array;
    2194                 :  1677763449 :   FOR_EACH_SUBRTX (iter, array, x, NONCONST)
    2195                 :             :     {
    2196                 :  1138101948 :       const_rtx x = *iter;
    2197                 :  1138101948 :       rtx_code code = GET_CODE (x);
    2198                 :  1138101948 :       if (code == REG)
    2199                 :   298934314 :         try_to_add_reg (x, flags | rtx_obj_flags::IS_READ);
    2200                 :             :       else if (code == MEM)
    2201                 :             :         {
    2202                 :    61705456 :           if (MEM_VOLATILE_P (x))
    2203                 :     2065077 :             has_volatile_refs = true;
    2204                 :             : 
    2205                 :    61705456 :           if (!MEM_READONLY_P (x) && ref_iter != ref_end)
    2206                 :             :             {
    2207                 :    58671851 :               auto mem_flags = flags | rtx_obj_flags::IS_READ;
    2208                 :    58671851 :               *ref_iter++ = rtx_obj_reference (MEM_REGNO, mem_flags,
    2209                 :    58671851 :                                                GET_MODE (x));
    2210                 :             :             }
    2211                 :             : 
    2212                 :    61705456 :           try_to_add_src (XEXP (x, 0),
    2213                 :             :                           base_flags | rtx_obj_flags::IN_MEM_LOAD);
    2214                 :    61705456 :           iter.skip_subrtxes ();
    2215                 :             :         }
    2216                 :             :       else if (code == SUBREG)
    2217                 :             :         {
    2218                 :     5264939 :           try_to_add_src (SUBREG_REG (x), flags | rtx_obj_flags::IN_SUBREG);
    2219                 :     5264939 :           iter.skip_subrtxes ();
    2220                 :             :         }
    2221                 :             :       else if (code == UNSPEC_VOLATILE)
    2222                 :     1570499 :         has_volatile_refs = true;
    2223                 :             :       else if (code == ASM_INPUT || code == ASM_OPERANDS)
    2224                 :             :         {
    2225                 :      670425 :           has_asm = true;
    2226                 :      670425 :           if (MEM_VOLATILE_P (x))
    2227                 :      212537 :             has_volatile_refs = true;
    2228                 :             :         }
    2229                 :             :       else if (code == PRE_INC
    2230                 :             :                || code == PRE_DEC
    2231                 :             :                || code == POST_INC
    2232                 :             :                || code == POST_DEC
    2233                 :             :                || code == PRE_MODIFY
    2234                 :             :                || code == POST_MODIFY)
    2235                 :             :         {
    2236                 :     6732084 :           has_pre_post_modify = true;
    2237                 :             : 
    2238                 :     6732084 :           unsigned int addr_flags = (base_flags
    2239                 :             :                                      | rtx_obj_flags::IS_PRE_POST_MODIFY
    2240                 :             :                                      | rtx_obj_flags::IS_READ);
    2241                 :     6732084 :           try_to_add_dest (XEXP (x, 0), addr_flags);
    2242                 :     6732084 :           if (code == PRE_MODIFY || code == POST_MODIFY)
    2243                 :      305205 :             iter.substitute (XEXP (XEXP (x, 1), 1));
    2244                 :             :           else
    2245                 :     6426879 :             iter.skip_subrtxes ();
    2246                 :             :         }
    2247                 :             :       else if (code == CALL)
    2248                 :    17202235 :         has_call = true;
    2249                 :             :     }
    2250                 :   539661501 : }
    2251                 :             : 
    2252                 :             : /* Try to add a description of instruction pattern PAT to this object,
    2253                 :             :    stopping once the REF_END limit has been reached.  */
    2254                 :             : 
    2255                 :             : void
    2256                 :   423503877 : rtx_properties::try_to_add_pattern (const_rtx pat)
    2257                 :             : {
    2258                 :   455150092 :   switch (GET_CODE (pat))
    2259                 :             :     {
    2260                 :           0 :     case COND_EXEC:
    2261                 :           0 :       try_to_add_src (COND_EXEC_TEST (pat));
    2262                 :           0 :       try_to_add_pattern (COND_EXEC_CODE (pat));
    2263                 :           0 :       break;
    2264                 :             : 
    2265                 :    31646215 :     case PARALLEL:
    2266                 :    31646215 :       {
    2267                 :    31646215 :         int last = XVECLEN (pat, 0) - 1;
    2268                 :    65037343 :         for (int i = 0; i < last; ++i)
    2269                 :    33391128 :           try_to_add_pattern (XVECEXP (pat, 0, i));
    2270                 :    31646215 :         try_to_add_pattern (XVECEXP (pat, 0, last));
    2271                 :    31646215 :         break;
    2272                 :             :       }
    2273                 :             : 
    2274                 :      165529 :     case ASM_OPERANDS:
    2275                 :      204990 :       for (int i = 0, len = ASM_OPERANDS_INPUT_LENGTH (pat); i < len; ++i)
    2276                 :       39461 :         try_to_add_src (ASM_OPERANDS_INPUT (pat, i));
    2277                 :             :       break;
    2278                 :             : 
    2279                 :    31238511 :     case CLOBBER:
    2280                 :    31238511 :       try_to_add_dest (XEXP (pat, 0), rtx_obj_flags::IS_CLOBBER);
    2281                 :    31238511 :       break;
    2282                 :             : 
    2283                 :   215733180 :     case SET:
    2284                 :   215733180 :       try_to_add_dest (SET_DEST (pat));
    2285                 :   215733180 :       try_to_add_src (SET_SRC (pat));
    2286                 :   215733180 :       break;
    2287                 :             : 
    2288                 :   176366657 :     default:
    2289                 :             :       /* All the other possibilities never store and can use a normal
    2290                 :             :          rtx walk.  This includes:
    2291                 :             : 
    2292                 :             :          - USE
    2293                 :             :          - TRAP_IF
    2294                 :             :          - PREFETCH
    2295                 :             :          - UNSPEC
    2296                 :             :          - UNSPEC_VOLATILE.  */
    2297                 :   176366657 :       try_to_add_src (pat);
    2298                 :   176366657 :       break;
    2299                 :             :     }
    2300                 :   423503877 : }
    2301                 :             : 
    2302                 :             : /* Try to add a description of INSN to this object, stopping once
    2303                 :             :    the REF_END limit has been reached.  INCLUDE_NOTES is true if the
    2304                 :             :    description should include REG_EQUAL and REG_EQUIV notes; all such
    2305                 :             :    references will then be marked with rtx_obj_flags::IN_NOTE.
    2306                 :             : 
    2307                 :             :    For calls, this description includes all accesses in
    2308                 :             :    CALL_INSN_FUNCTION_USAGE.  It also include all implicit accesses
    2309                 :             :    to global registers by the target function.  However, it does not
    2310                 :             :    include clobbers performed by the target function; callers that want
    2311                 :             :    this information should instead use the function_abi interface.  */
    2312                 :             : 
    2313                 :             : void
    2314                 :   390112749 : rtx_properties::try_to_add_insn (const rtx_insn *insn, bool include_notes)
    2315                 :             : {
    2316                 :   390112749 :   if (CALL_P (insn))
    2317                 :             :     {
    2318                 :             :       /* Non-const functions can read from global registers.  Impure
    2319                 :             :          functions can also set them.
    2320                 :             : 
    2321                 :             :          Adding the global registers first removes a situation in which
    2322                 :             :          a fixed-form clobber of register R could come before a real set
    2323                 :             :          of register R.  */
    2324                 :    17202235 :       if (!hard_reg_set_empty_p (global_reg_set)
    2325                 :    17202235 :           && !RTL_CONST_CALL_P (insn))
    2326                 :             :         {
    2327                 :         356 :           unsigned int flags = rtx_obj_flags::IS_READ;
    2328                 :         356 :           if (!RTL_PURE_CALL_P (insn))
    2329                 :         324 :             flags |= rtx_obj_flags::IS_WRITE;
    2330                 :       33108 :           for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; ++regno)
    2331                 :             :             /* As a special case, the stack pointer is invariant across calls
    2332                 :             :                even if it has been marked global; see the corresponding
    2333                 :             :                handling in df_get_call_refs.  */
    2334                 :       32752 :             if (regno != STACK_POINTER_REGNUM
    2335                 :       32396 :                 && global_regs[regno]
    2336                 :         296 :                 && ref_iter != ref_end)
    2337                 :         296 :               *ref_iter++ = rtx_obj_reference (regno, flags,
    2338                 :         296 :                                                reg_raw_mode[regno], 0);
    2339                 :             :         }
    2340                 :             :       /* Untyped calls implicitly set all function value registers.
    2341                 :             :          Again, we add them first in case the main pattern contains
    2342                 :             :          a fixed-form clobber.  */
    2343                 :    17202235 :       if (find_reg_note (insn, REG_UNTYPED_CALL, NULL_RTX))
    2344                 :      143220 :         for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; ++regno)
    2345                 :      141680 :           if (targetm.calls.function_value_regno_p (regno)
    2346                 :      141680 :               && ref_iter != ref_end)
    2347                 :       12320 :             *ref_iter++ = rtx_obj_reference (regno, rtx_obj_flags::IS_WRITE,
    2348                 :       12320 :                                              reg_raw_mode[regno], 0);
    2349                 :    17202235 :       if (ref_iter != ref_end && !RTL_CONST_CALL_P (insn))
    2350                 :             :         {
    2351                 :    16633268 :           auto mem_flags = rtx_obj_flags::IS_READ;
    2352                 :    16633268 :           if (!RTL_PURE_CALL_P (insn))
    2353                 :    15502600 :             mem_flags |= rtx_obj_flags::IS_WRITE;
    2354                 :    16633268 :           *ref_iter++ = rtx_obj_reference (MEM_REGNO, mem_flags, BLKmode);
    2355                 :             :         }
    2356                 :    17202235 :       try_to_add_pattern (PATTERN (insn));
    2357                 :    50262389 :       for (rtx link = CALL_INSN_FUNCTION_USAGE (insn); link;
    2358                 :    33060154 :            link = XEXP (link, 1))
    2359                 :             :         {
    2360                 :    33060154 :           rtx x = XEXP (link, 0);
    2361                 :    33060154 :           if (GET_CODE (x) == CLOBBER)
    2362                 :     1829508 :             try_to_add_dest (XEXP (x, 0), rtx_obj_flags::IS_CLOBBER);
    2363                 :    31230646 :           else if (GET_CODE (x) == USE)
    2364                 :    31045681 :             try_to_add_src (XEXP (x, 0));
    2365                 :             :         }
    2366                 :             :     }
    2367                 :             :   else
    2368                 :   372910514 :     try_to_add_pattern (PATTERN (insn));
    2369                 :             : 
    2370                 :   390112749 :   if (include_notes)
    2371                 :   599787080 :     for (rtx note = REG_NOTES (insn); note; note = XEXP (note, 1))
    2372                 :   209675091 :       if (REG_NOTE_KIND (note) == REG_EQUAL
    2373                 :   209675091 :           || REG_NOTE_KIND (note) == REG_EQUIV)
    2374                 :    15335343 :         try_to_add_note (XEXP (note, 0));
    2375                 :   390112749 : }
    2376                 :             : 
    2377                 :             : /* Grow the storage by a bit while keeping the contents of the first
    2378                 :             :    START elements.  */
    2379                 :             : 
    2380                 :             : void
    2381                 :       12577 : vec_rtx_properties_base::grow (ptrdiff_t start)
    2382                 :             : {
    2383                 :             :   /* The same heuristic that vec uses.  */
    2384                 :       12577 :   ptrdiff_t new_elems = (ref_end - ref_begin) * 3 / 2;
    2385                 :       12577 :   if (ref_begin == m_storage)
    2386                 :             :     {
    2387                 :       10284 :       ref_begin = XNEWVEC (rtx_obj_reference, new_elems);
    2388                 :       10284 :       if (start)
    2389                 :           0 :         memcpy (ref_begin, m_storage, start * sizeof (rtx_obj_reference));
    2390                 :             :     }
    2391                 :             :   else
    2392                 :        2293 :     ref_begin = reinterpret_cast<rtx_obj_reference *>
    2393                 :        2293 :       (xrealloc (ref_begin, new_elems * sizeof (rtx_obj_reference)));
    2394                 :       12577 :   ref_iter = ref_begin + start;
    2395                 :       12577 :   ref_end = ref_begin + new_elems;
    2396                 :       12577 : }
    2397                 :             : 
    2398                 :             : /* Return true if X's old contents don't survive after INSN.
    2399                 :             :    This will be true if X is a register and X dies in INSN or because
    2400                 :             :    INSN entirely sets X.
    2401                 :             : 
    2402                 :             :    "Entirely set" means set directly and not through a SUBREG, or
    2403                 :             :    ZERO_EXTRACT, so no trace of the old contents remains.
    2404                 :             :    Likewise, REG_INC does not count.
    2405                 :             : 
    2406                 :             :    REG may be a hard or pseudo reg.  Renumbering is not taken into account,
    2407                 :             :    but for this use that makes no difference, since regs don't overlap
    2408                 :             :    during their lifetimes.  Therefore, this function may be used
    2409                 :             :    at any time after deaths have been computed.
    2410                 :             : 
    2411                 :             :    If REG is a hard reg that occupies multiple machine registers, this
    2412                 :             :    function will only return true if each of those registers will be replaced
    2413                 :             :    by INSN.  */
    2414                 :             : 
    2415                 :             : bool
    2416                 :   106902527 : dead_or_set_p (const rtx_insn *insn, const_rtx x)
    2417                 :             : {
    2418                 :   106902527 :   unsigned int regno, end_regno;
    2419                 :   106902527 :   unsigned int i;
    2420                 :             : 
    2421                 :   106902527 :   gcc_assert (REG_P (x));
    2422                 :             : 
    2423                 :   106902527 :   regno = REGNO (x);
    2424                 :   106902527 :   end_regno = END_REGNO (x);
    2425                 :   189913009 :   for (i = regno; i < end_regno; i++)
    2426                 :   106903569 :     if (! dead_or_set_regno_p (insn, i))
    2427                 :             :       return false;
    2428                 :             : 
    2429                 :             :   return true;
    2430                 :             : }
    2431                 :             : 
    2432                 :             : /* Return TRUE iff DEST is a register or subreg of a register, is a
    2433                 :             :    complete rather than read-modify-write destination, and contains
    2434                 :             :    register TEST_REGNO.  */
    2435                 :             : 
    2436                 :             : static bool
    2437                 :   189955327 : covers_regno_no_parallel_p (const_rtx dest, unsigned int test_regno)
    2438                 :             : {
    2439                 :   189955327 :   unsigned int regno, endregno;
    2440                 :             : 
    2441                 :   189955327 :   if (GET_CODE (dest) == SUBREG && !read_modify_subreg_p (dest))
    2442                 :      456661 :     dest = SUBREG_REG (dest);
    2443                 :             : 
    2444                 :   189955327 :   if (!REG_P (dest))
    2445                 :             :     return false;
    2446                 :             : 
    2447                 :   183367460 :   regno = REGNO (dest);
    2448                 :   183367460 :   endregno = END_REGNO (dest);
    2449                 :   183367460 :   return (test_regno >= regno && test_regno < endregno);
    2450                 :             : }
    2451                 :             : 
    2452                 :             : /* Like covers_regno_no_parallel_p, but also handles PARALLELs where
    2453                 :             :    any member matches the covers_regno_no_parallel_p criteria.  */
    2454                 :             : 
    2455                 :             : static bool
    2456                 :    89336365 : covers_regno_p (const_rtx dest, unsigned int test_regno)
    2457                 :             : {
    2458                 :    89336365 :   if (GET_CODE (dest) == PARALLEL)
    2459                 :             :     {
    2460                 :             :       /* Some targets place small structures in registers for return
    2461                 :             :          values of functions, and those registers are wrapped in
    2462                 :             :          PARALLELs that we may see as the destination of a SET.  */
    2463                 :         331 :       int i;
    2464                 :             : 
    2465                 :         880 :       for (i = XVECLEN (dest, 0) - 1; i >= 0; i--)
    2466                 :             :         {
    2467                 :         549 :           rtx inner = XEXP (XVECEXP (dest, 0, i), 0);
    2468                 :         549 :           if (inner != NULL_RTX
    2469                 :         549 :               && covers_regno_no_parallel_p (inner, test_regno))
    2470                 :             :             return true;
    2471                 :             :         }
    2472                 :             : 
    2473                 :             :       return false;
    2474                 :             :     }
    2475                 :             :   else
    2476                 :    89336034 :     return covers_regno_no_parallel_p (dest, test_regno);
    2477                 :             : }
    2478                 :             : 
    2479                 :             : /* Utility function for dead_or_set_p to check an individual register. */
    2480                 :             : 
    2481                 :             : bool
    2482                 :   108980676 : dead_or_set_regno_p (const rtx_insn *insn, unsigned int test_regno)
    2483                 :             : {
    2484                 :   108980676 :   const_rtx pattern;
    2485                 :             : 
    2486                 :             :   /* See if there is a death note for something that includes TEST_REGNO.  */
    2487                 :   108980676 :   if (find_regno_note (insn, REG_DEAD, test_regno))
    2488                 :             :     return true;
    2489                 :             : 
    2490                 :    70182124 :   if (CALL_P (insn)
    2491                 :    70182124 :       && find_regno_fusage (insn, CLOBBER, test_regno))
    2492                 :             :     return true;
    2493                 :             : 
    2494                 :    70182124 :   pattern = PATTERN (insn);
    2495                 :             : 
    2496                 :             :   /* If a COND_EXEC is not executed, the value survives.  */
    2497                 :    70182124 :   if (GET_CODE (pattern) == COND_EXEC)
    2498                 :             :     return false;
    2499                 :             : 
    2500                 :    70182124 :   if (GET_CODE (pattern) == SET || GET_CODE (pattern) == CLOBBER)
    2501                 :    50768242 :     return covers_regno_p (SET_DEST (pattern), test_regno);
    2502                 :    19413882 :   else if (GET_CODE (pattern) == PARALLEL)
    2503                 :             :     {
    2504                 :    19195819 :       int i;
    2505                 :             : 
    2506                 :    44871791 :       for (i = XVECLEN (pattern, 0) - 1; i >= 0; i--)
    2507                 :             :         {
    2508                 :    38866002 :           rtx body = XVECEXP (pattern, 0, i);
    2509                 :             : 
    2510                 :    38866002 :           if (GET_CODE (body) == COND_EXEC)
    2511                 :           0 :             body = COND_EXEC_CODE (body);
    2512                 :             : 
    2513                 :    19503493 :           if ((GET_CODE (body) == SET || GET_CODE (body) == CLOBBER)
    2514                 :    58071616 :               && covers_regno_p (SET_DEST (body), test_regno))
    2515                 :             :             return true;
    2516                 :             :         }
    2517                 :             :     }
    2518                 :             : 
    2519                 :             :   return false;
    2520                 :             : }
    2521                 :             : 
    2522                 :             : /* Return the reg-note of kind KIND in insn INSN, if there is one.
    2523                 :             :    If DATUM is nonzero, look for one whose datum is DATUM.  */
    2524                 :             : 
    2525                 :             : rtx
    2526                 :  7749730543 : find_reg_note (const_rtx insn, enum reg_note kind, const_rtx datum)
    2527                 :             : {
    2528                 :  7749730543 :   rtx link;
    2529                 :             : 
    2530                 :  7749730543 :   gcc_checking_assert (insn);
    2531                 :             : 
    2532                 :             :   /* Ignore anything that is not an INSN, JUMP_INSN or CALL_INSN.  */
    2533                 :  7749730543 :   if (! INSN_P (insn))
    2534                 :             :     return 0;
    2535                 :  7640726257 :   if (datum == 0)
    2536                 :             :     {
    2537                 : 14683429088 :       for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    2538                 :  8529903758 :         if (REG_NOTE_KIND (link) == kind)
    2539                 :             :           return link;
    2540                 :             :       return 0;
    2541                 :             :     }
    2542                 :             : 
    2543                 :   696279364 :   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    2544                 :   403432104 :     if (REG_NOTE_KIND (link) == kind && datum == XEXP (link, 0))
    2545                 :             :       return link;
    2546                 :             :   return 0;
    2547                 :             : }
    2548                 :             : 
    2549                 :             : /* Return the reg-note of kind KIND in insn INSN which applies to register
    2550                 :             :    number REGNO, if any.  Return 0 if there is no such reg-note.  Note that
    2551                 :             :    the REGNO of this NOTE need not be REGNO if REGNO is a hard register;
    2552                 :             :    it might be the case that the note overlaps REGNO.  */
    2553                 :             : 
    2554                 :             : rtx
    2555                 :   389577206 : find_regno_note (const_rtx insn, enum reg_note kind, unsigned int regno)
    2556                 :             : {
    2557                 :   389577206 :   rtx link;
    2558                 :             : 
    2559                 :             :   /* Ignore anything that is not an INSN, JUMP_INSN or CALL_INSN.  */
    2560                 :   389577206 :   if (! INSN_P (insn))
    2561                 :             :     return 0;
    2562                 :             : 
    2563                 :   582884795 :   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    2564                 :   362182629 :     if (REG_NOTE_KIND (link) == kind
    2565                 :             :         /* Verify that it is a register, so that scratch and MEM won't cause a
    2566                 :             :            problem here.  */
    2567                 :   243743385 :         && REG_P (XEXP (link, 0))
    2568                 :   243743385 :         && REGNO (XEXP (link, 0)) <= regno
    2569                 :   559185957 :         && END_REGNO (XEXP (link, 0)) > regno)
    2570                 :             :       return link;
    2571                 :             :   return 0;
    2572                 :             : }
    2573                 :             : 
    2574                 :             : /* Return a REG_EQUIV or REG_EQUAL note if insn has only a single set and
    2575                 :             :    has such a note.  */
    2576                 :             : 
    2577                 :             : rtx
    2578                 :  1617467528 : find_reg_equal_equiv_note (const_rtx insn)
    2579                 :             : {
    2580                 :  1617467528 :   rtx link;
    2581                 :             : 
    2582                 :  1617467528 :   if (!INSN_P (insn))
    2583                 :             :     return 0;
    2584                 :             : 
    2585                 :  2813735449 :   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    2586                 :  1288593853 :     if (REG_NOTE_KIND (link) == REG_EQUAL
    2587                 :  1288593853 :         || REG_NOTE_KIND (link) == REG_EQUIV)
    2588                 :             :       {
    2589                 :             :         /* FIXME: We should never have REG_EQUAL/REG_EQUIV notes on
    2590                 :             :            insns that have multiple sets.  Checking single_set to
    2591                 :             :            make sure of this is not the proper check, as explained
    2592                 :             :            in the comment in set_unique_reg_note.
    2593                 :             : 
    2594                 :             :            This should be changed into an assert.  */
    2595                 :    86483817 :         if (GET_CODE (PATTERN (insn)) == PARALLEL && multiple_sets (insn))
    2596                 :             :           return 0;
    2597                 :    86483817 :         return link;
    2598                 :             :       }
    2599                 :             :   return NULL;
    2600                 :             : }
    2601                 :             : 
    2602                 :             : /* Check whether INSN is a single_set whose source is known to be
    2603                 :             :    equivalent to a constant.  Return that constant if so, otherwise
    2604                 :             :    return null.  */
    2605                 :             : 
    2606                 :             : rtx
    2607                 :     2265018 : find_constant_src (const rtx_insn *insn)
    2608                 :             : {
    2609                 :     2265018 :   rtx note, set, x;
    2610                 :             : 
    2611                 :     2265018 :   set = single_set (insn);
    2612                 :     2265018 :   if (set)
    2613                 :             :     {
    2614                 :     2265018 :       x = avoid_constant_pool_reference (SET_SRC (set));
    2615                 :     2265018 :       if (CONSTANT_P (x))
    2616                 :             :         return x;
    2617                 :             :     }
    2618                 :             : 
    2619                 :     1577482 :   note = find_reg_equal_equiv_note (insn);
    2620                 :     1577482 :   if (note && CONSTANT_P (XEXP (note, 0)))
    2621                 :         634 :     return XEXP (note, 0);
    2622                 :             : 
    2623                 :             :   return NULL_RTX;
    2624                 :             : }
    2625                 :             : 
    2626                 :             : /* Return true if DATUM, or any overlap of DATUM, of kind CODE is found
    2627                 :             :    in the CALL_INSN_FUNCTION_USAGE information of INSN.  */
    2628                 :             : 
    2629                 :             : bool
    2630                 :    84594949 : find_reg_fusage (const_rtx insn, enum rtx_code code, const_rtx datum)
    2631                 :             : {
    2632                 :             :   /* If it's not a CALL_INSN, it can't possibly have a
    2633                 :             :      CALL_INSN_FUNCTION_USAGE field, so don't bother checking.  */
    2634                 :    84594949 :   if (!CALL_P (insn))
    2635                 :             :     return false;
    2636                 :             : 
    2637                 :    84594949 :   gcc_assert (datum);
    2638                 :             : 
    2639                 :    84594949 :   if (!REG_P (datum))
    2640                 :             :     {
    2641                 :       33103 :       rtx link;
    2642                 :             : 
    2643                 :       33103 :       for (link = CALL_INSN_FUNCTION_USAGE (insn);
    2644                 :       46692 :            link;
    2645                 :       13589 :            link = XEXP (link, 1))
    2646                 :       13589 :         if (GET_CODE (XEXP (link, 0)) == code
    2647                 :       13589 :             && rtx_equal_p (datum, XEXP (XEXP (link, 0), 0)))
    2648                 :             :           return true;
    2649                 :             :     }
    2650                 :             :   else
    2651                 :             :     {
    2652                 :    84561846 :       unsigned int regno = REGNO (datum);
    2653                 :             : 
    2654                 :             :       /* CALL_INSN_FUNCTION_USAGE information cannot contain references
    2655                 :             :          to pseudo registers, so don't bother checking.  */
    2656                 :             : 
    2657                 :    84561846 :       if (regno < FIRST_PSEUDO_REGISTER)
    2658                 :             :         {
    2659                 :    77828271 :           unsigned int end_regno = END_REGNO (datum);
    2660                 :    77828271 :           unsigned int i;
    2661                 :             : 
    2662                 :   136456767 :           for (i = regno; i < end_regno; i++)
    2663                 :    77828277 :             if (find_regno_fusage (insn, code, i))
    2664                 :             :               return true;
    2665                 :             :         }
    2666                 :             :     }
    2667                 :             : 
    2668                 :             :   return false;
    2669                 :             : }
    2670                 :             : 
    2671                 :             : /* Return true if REGNO, or any overlap of REGNO, of kind CODE is found
    2672                 :             :    in the CALL_INSN_FUNCTION_USAGE information of INSN.  */
    2673                 :             : 
    2674                 :             : bool
    2675                 :    78047474 : find_regno_fusage (const_rtx insn, enum rtx_code code, unsigned int regno)
    2676                 :             : {
    2677                 :    78047474 :   rtx link;
    2678                 :             : 
    2679                 :             :   /* CALL_INSN_FUNCTION_USAGE information cannot contain references
    2680                 :             :      to pseudo registers, so don't bother checking.  */
    2681                 :             : 
    2682                 :    78047474 :   if (regno >= FIRST_PSEUDO_REGISTER
    2683                 :    77984205 :       || !CALL_P (insn) )
    2684                 :             :     return false;
    2685                 :             : 
    2686                 :   218942666 :   for (link = CALL_INSN_FUNCTION_USAGE (insn); link; link = XEXP (link, 1))
    2687                 :             :     {
    2688                 :   160159780 :       rtx op, reg;
    2689                 :             : 
    2690                 :   160159780 :       if (GET_CODE (op = XEXP (link, 0)) == code
    2691                 :    49109352 :           && REG_P (reg = XEXP (op, 0))
    2692                 :    49106814 :           && REGNO (reg) <= regno
    2693                 :   192744033 :           && END_REGNO (reg) > regno)
    2694                 :             :         return true;
    2695                 :             :     }
    2696                 :             : 
    2697                 :             :   return false;
    2698                 :             : }
    2699                 :             : 
    2700                 :             : 
    2701                 :             : /* Return true if KIND is an integer REG_NOTE.  */
    2702                 :             : 
    2703                 :             : static bool
    2704                 :           0 : int_reg_note_p (enum reg_note kind)
    2705                 :             : {
    2706                 :           0 :   return kind == REG_BR_PROB;
    2707                 :             : }
    2708                 :             : 
    2709                 :             : /* Allocate a register note with kind KIND and datum DATUM.  LIST is
    2710                 :             :    stored as the pointer to the next register note.  */
    2711                 :             : 
    2712                 :             : rtx
    2713                 :   717564471 : alloc_reg_note (enum reg_note kind, rtx datum, rtx list)
    2714                 :             : {
    2715                 :   717564471 :   rtx note;
    2716                 :             : 
    2717                 :   717564471 :   gcc_checking_assert (!int_reg_note_p (kind));
    2718                 :   717564471 :   switch (kind)
    2719                 :             :     {
    2720                 :       25054 :     case REG_LABEL_TARGET:
    2721                 :       25054 :     case REG_LABEL_OPERAND:
    2722                 :       25054 :     case REG_TM:
    2723                 :             :       /* These types of register notes use an INSN_LIST rather than an
    2724                 :             :          EXPR_LIST, so that copying is done right and dumps look
    2725                 :             :          better.  */
    2726                 :       25054 :       note = alloc_INSN_LIST (datum, list);
    2727                 :       25054 :       PUT_REG_NOTE_KIND (note, kind);
    2728                 :       25054 :       break;
    2729                 :             : 
    2730                 :   717539417 :     default:
    2731                 :   717539417 :       note = alloc_EXPR_LIST (kind, datum, list);
    2732                 :   717539417 :       break;
    2733                 :             :     }
    2734                 :             : 
    2735                 :   717564471 :   return note;
    2736                 :             : }
    2737                 :             : 
    2738                 :             : /* Add register note with kind KIND and datum DATUM to INSN.  */
    2739                 :             : 
    2740                 :             : void
    2741                 :   711064081 : add_reg_note (rtx insn, enum reg_note kind, rtx datum)
    2742                 :             : {
    2743                 :   711064081 :   REG_NOTES (insn) = alloc_reg_note (kind, datum, REG_NOTES (insn));
    2744                 :   711064081 : }
    2745                 :             : 
    2746                 :             : /* Add an integer register note with kind KIND and datum DATUM to INSN.  */
    2747                 :             : 
    2748                 :             : void
    2749                 :     4825974 : add_int_reg_note (rtx_insn *insn, enum reg_note kind, int datum)
    2750                 :             : {
    2751                 :     4825974 :   gcc_checking_assert (int_reg_note_p (kind));
    2752                 :     4825974 :   REG_NOTES (insn) = gen_rtx_INT_LIST ((machine_mode) kind,
    2753                 :             :                                        datum, REG_NOTES (insn));
    2754                 :     4825974 : }
    2755                 :             : 
    2756                 :             : /* Add a REG_ARGS_SIZE note to INSN with value VALUE.  */
    2757                 :             : 
    2758                 :             : void
    2759                 :     5391068 : add_args_size_note (rtx_insn *insn, poly_int64 value)
    2760                 :             : {
    2761                 :     5391068 :   gcc_checking_assert (!find_reg_note (insn, REG_ARGS_SIZE, NULL_RTX));
    2762                 :     5391068 :   add_reg_note (insn, REG_ARGS_SIZE, gen_int_mode (value, Pmode));
    2763                 :     5391068 : }
    2764                 :             : 
    2765                 :             : /* Add a register note like NOTE to INSN.  */
    2766                 :             : 
    2767                 :             : void
    2768                 :           0 : add_shallow_copy_of_reg_note (rtx_insn *insn, rtx note)
    2769                 :             : {
    2770                 :           0 :   if (GET_CODE (note) == INT_LIST)
    2771                 :           0 :     add_int_reg_note (insn, REG_NOTE_KIND (note), XINT (note, 0));
    2772                 :             :   else
    2773                 :           0 :     add_reg_note (insn, REG_NOTE_KIND (note), XEXP (note, 0));
    2774                 :           0 : }
    2775                 :             : 
    2776                 :             : /* Duplicate NOTE and return the copy.  */
    2777                 :             : rtx
    2778                 :     2189078 : duplicate_reg_note (rtx note)
    2779                 :             : {
    2780                 :     2189078 :   reg_note kind = REG_NOTE_KIND (note);
    2781                 :             : 
    2782                 :     2189078 :   if (GET_CODE (note) == INT_LIST)
    2783                 :      279402 :     return gen_rtx_INT_LIST ((machine_mode) kind, XINT (note, 0), NULL_RTX);
    2784                 :     1909676 :   else if (GET_CODE (note) == EXPR_LIST)
    2785                 :     1909676 :     return alloc_reg_note (kind, copy_insn_1 (XEXP (note, 0)), NULL_RTX);
    2786                 :             :   else
    2787                 :           0 :     return alloc_reg_note (kind, XEXP (note, 0), NULL_RTX);
    2788                 :             : }
    2789                 :             : 
    2790                 :             : /* Remove register note NOTE from the REG_NOTES of INSN.  */
    2791                 :             : 
    2792                 :             : void
    2793                 :     7988766 : remove_note (rtx_insn *insn, const_rtx note)
    2794                 :             : {
    2795                 :     7988766 :   rtx link;
    2796                 :             : 
    2797                 :     7988766 :   if (note == NULL_RTX)
    2798                 :             :     return;
    2799                 :             : 
    2800                 :     7147477 :   if (REG_NOTES (insn) == note)
    2801                 :     6718314 :     REG_NOTES (insn) = XEXP (note, 1);
    2802                 :             :   else
    2803                 :      922465 :     for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    2804                 :      922465 :       if (XEXP (link, 1) == note)
    2805                 :             :         {
    2806                 :      429163 :           XEXP (link, 1) = XEXP (note, 1);
    2807                 :      429163 :           break;
    2808                 :             :         }
    2809                 :             : 
    2810                 :     7147477 :   switch (REG_NOTE_KIND (note))
    2811                 :             :     {
    2812                 :     2627166 :     case REG_EQUAL:
    2813                 :     2627166 :     case REG_EQUIV:
    2814                 :     2627166 :       df_notes_rescan (insn);
    2815                 :     2627166 :       break;
    2816                 :             :     default:
    2817                 :             :       break;
    2818                 :             :     }
    2819                 :             : }
    2820                 :             : 
    2821                 :             : /* Remove REG_EQUAL and/or REG_EQUIV notes if INSN has such notes.
    2822                 :             :    If NO_RESCAN is false and any notes were removed, call
    2823                 :             :    df_notes_rescan.  Return true if any note has been removed.  */
    2824                 :             : 
    2825                 :             : bool
    2826                 :       16361 : remove_reg_equal_equiv_notes (rtx_insn *insn, bool no_rescan)
    2827                 :             : {
    2828                 :       16361 :   rtx *loc;
    2829                 :       16361 :   bool ret = false;
    2830                 :             : 
    2831                 :       16361 :   loc = &REG_NOTES (insn);
    2832                 :       18125 :   while (*loc)
    2833                 :             :     {
    2834                 :        1764 :       enum reg_note kind = REG_NOTE_KIND (*loc);
    2835                 :        1764 :       if (kind == REG_EQUAL || kind == REG_EQUIV)
    2836                 :             :         {
    2837                 :         362 :           *loc = XEXP (*loc, 1);
    2838                 :         362 :           ret = true;
    2839                 :             :         }
    2840                 :             :       else
    2841                 :        1402 :         loc = &XEXP (*loc, 1);
    2842                 :             :     }
    2843                 :       16361 :   if (ret && !no_rescan)
    2844                 :         362 :     df_notes_rescan (insn);
    2845                 :       16361 :   return ret;
    2846                 :             : }
    2847                 :             : 
    2848                 :             : /* Remove all REG_EQUAL and REG_EQUIV notes referring to REGNO.  */
    2849                 :             : 
    2850                 :             : void
    2851                 :     3864475 : remove_reg_equal_equiv_notes_for_regno (unsigned int regno)
    2852                 :             : {
    2853                 :     3864475 :   df_ref eq_use;
    2854                 :             : 
    2855                 :     3864475 :   if (!df)
    2856                 :             :     return;
    2857                 :             : 
    2858                 :             :   /* This loop is a little tricky.  We cannot just go down the chain because
    2859                 :             :      it is being modified by some actions in the loop.  So we just iterate
    2860                 :             :      over the head.  We plan to drain the list anyway.  */
    2861                 :     4013511 :   while ((eq_use = DF_REG_EQ_USE_CHAIN (regno)) != NULL)
    2862                 :             :     {
    2863                 :      149036 :       rtx_insn *insn = DF_REF_INSN (eq_use);
    2864                 :      149036 :       rtx note = find_reg_equal_equiv_note (insn);
    2865                 :             : 
    2866                 :             :       /* This assert is generally triggered when someone deletes a REG_EQUAL
    2867                 :             :          or REG_EQUIV note by hacking the list manually rather than calling
    2868                 :             :          remove_note.  */
    2869                 :      149036 :       gcc_assert (note);
    2870                 :             : 
    2871                 :      149036 :       remove_note (insn, note);
    2872                 :             :     }
    2873                 :             : }
    2874                 :             : 
    2875                 :             : /* Search LISTP (an EXPR_LIST) for an entry whose first operand is NODE and
    2876                 :             :    return 1 if it is found.  A simple equality test is used to determine if
    2877                 :             :    NODE matches.  */
    2878                 :             : 
    2879                 :             : bool
    2880                 :          26 : in_insn_list_p (const rtx_insn_list *listp, const rtx_insn *node)
    2881                 :             : {
    2882                 :          26 :   const_rtx x;
    2883                 :             : 
    2884                 :          26 :   for (x = listp; x; x = XEXP (x, 1))
    2885                 :           0 :     if (node == XEXP (x, 0))
    2886                 :             :       return true;
    2887                 :             : 
    2888                 :             :   return false;
    2889                 :             : }
    2890                 :             : 
    2891                 :             : /* Search LISTP (an INSN_LIST) for an entry whose first operand is NODE and
    2892                 :             :    remove that entry from the list if it is found.
    2893                 :             : 
    2894                 :             :    A simple equality test is used to determine if NODE matches.  */
    2895                 :             : 
    2896                 :             : void
    2897                 :     7280204 : remove_node_from_insn_list (const rtx_insn *node, rtx_insn_list **listp)
    2898                 :             : {
    2899                 :     7280204 :   rtx_insn_list *temp = *listp;
    2900                 :     7280204 :   rtx_insn_list *prev = NULL;
    2901                 :             : 
    2902                 :     7296032 :   while (temp)
    2903                 :             :     {
    2904                 :       15854 :       if (node == temp->insn ())
    2905                 :             :         {
    2906                 :             :           /* Splice the node out of the list.  */
    2907                 :          26 :           if (prev)
    2908                 :           0 :             XEXP (prev, 1) = temp->next ();
    2909                 :             :           else
    2910                 :          26 :             *listp = temp->next ();
    2911                 :             : 
    2912                 :          26 :           gcc_checking_assert (!in_insn_list_p (temp->next (), node));
    2913                 :             :           return;
    2914                 :             :         }
    2915                 :             : 
    2916                 :       15828 :       prev = temp;
    2917                 :       15828 :       temp = temp->next ();
    2918                 :             :     }
    2919                 :             : }
    2920                 :             : 
    2921                 :             : /* Return true if X contains any volatile instructions.  These are instructions
    2922                 :             :    which may cause unpredictable machine state instructions, and thus no
    2923                 :             :    instructions or register uses should be moved or combined across them.
    2924                 :             :    This includes only volatile asms and UNSPEC_VOLATILE instructions.  */
    2925                 :             : 
    2926                 :             : bool
    2927                 :   636546153 : volatile_insn_p (const_rtx x)
    2928                 :             : {
    2929                 :   636546153 :   const RTX_CODE code = GET_CODE (x);
    2930                 :   636546153 :   switch (code)
    2931                 :             :     {
    2932                 :             :     case LABEL_REF:
    2933                 :             :     case SYMBOL_REF:
    2934                 :             :     case CONST:
    2935                 :             :     CASE_CONST_ANY:
    2936                 :             :     case PC:
    2937                 :             :     case REG:
    2938                 :             :     case SCRATCH:
    2939                 :             :     case CLOBBER:
    2940                 :             :     case ADDR_VEC:
    2941                 :             :     case ADDR_DIFF_VEC:
    2942                 :             :     case CALL:
    2943                 :             :     case MEM:
    2944                 :             :       return false;
    2945                 :             : 
    2946                 :             :     case UNSPEC_VOLATILE:
    2947                 :             :       return true;
    2948                 :             : 
    2949                 :      132085 :     case ASM_INPUT:
    2950                 :      132085 :     case ASM_OPERANDS:
    2951                 :      132085 :       if (MEM_VOLATILE_P (x))
    2952                 :             :         return true;
    2953                 :             : 
    2954                 :   294042212 :     default:
    2955                 :   294042212 :       break;
    2956                 :             :     }
    2957                 :             : 
    2958                 :             :   /* Recursively scan the operands of this expression.  */
    2959                 :             : 
    2960                 :   294042212 :   {
    2961                 :   294042212 :     const char *const fmt = GET_RTX_FORMAT (code);
    2962                 :   294042212 :     int i;
    2963                 :             : 
    2964                 :   805677787 :     for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    2965                 :             :       {
    2966                 :   511929650 :         if (fmt[i] == 'e')
    2967                 :             :           {
    2968                 :   405135152 :             if (volatile_insn_p (XEXP (x, i)))
    2969                 :             :               return true;
    2970                 :             :           }
    2971                 :   106794498 :         else if (fmt[i] == 'E')
    2972                 :             :           {
    2973                 :             :             int j;
    2974                 :    66659948 :             for (j = 0; j < XVECLEN (x, i); j++)
    2975                 :    45880892 :               if (volatile_insn_p (XVECEXP (x, i, j)))
    2976                 :             :                 return true;
    2977                 :             :           }
    2978                 :             :       }
    2979                 :             :   }
    2980                 :             :   return false;
    2981                 :             : }
    2982                 :             : 
    2983                 :             : /* Return true if X contains any volatile memory references
    2984                 :             :    UNSPEC_VOLATILE operations or volatile ASM_OPERANDS expressions.  */
    2985                 :             : 
    2986                 :             : bool
    2987                 :  4843648545 : volatile_refs_p (const_rtx x)
    2988                 :             : {
    2989                 :  4843648545 :   const RTX_CODE code = GET_CODE (x);
    2990                 :  4843648545 :   switch (code)
    2991                 :             :     {
    2992                 :             :     case LABEL_REF:
    2993                 :             :     case SYMBOL_REF:
    2994                 :             :     case CONST:
    2995                 :             :     CASE_CONST_ANY:
    2996                 :             :     case PC:
    2997                 :             :     case REG:
    2998                 :             :     case SCRATCH:
    2999                 :             :     case CLOBBER:
    3000                 :             :     case ADDR_VEC:
    3001                 :             :     case ADDR_DIFF_VEC:
    3002                 :             :       return false;
    3003                 :             : 
    3004                 :             :     case UNSPEC_VOLATILE:
    3005                 :             :       return true;
    3006                 :             : 
    3007                 :   366480875 :     case MEM:
    3008                 :   366480875 :     case ASM_INPUT:
    3009                 :   366480875 :     case ASM_OPERANDS:
    3010                 :   366480875 :       if (MEM_VOLATILE_P (x))
    3011                 :             :         return true;
    3012                 :             : 
    3013                 :  2062620887 :     default:
    3014                 :  2062620887 :       break;
    3015                 :             :     }
    3016                 :             : 
    3017                 :             :   /* Recursively scan the operands of this expression.  */
    3018                 :             : 
    3019                 :  2062620887 :   {
    3020                 :  2062620887 :     const char *const fmt = GET_RTX_FORMAT (code);
    3021                 :  2062620887 :     int i;
    3022                 :             : 
    3023                 :  6059144329 :     for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    3024                 :             :       {
    3025                 :  4011664777 :         if (fmt[i] == 'e')
    3026                 :             :           {
    3027                 :  3568843738 :             if (volatile_refs_p (XEXP (x, i)))
    3028                 :             :               return true;
    3029                 :             :           }
    3030                 :   442821039 :         else if (fmt[i] == 'E')
    3031                 :             :           {
    3032                 :             :             int j;
    3033                 :   150455737 :             for (j = 0; j < XVECLEN (x, i); j++)
    3034                 :   104278043 :               if (volatile_refs_p (XVECEXP (x, i, j)))
    3035                 :             :                 return true;
    3036                 :             :           }
    3037                 :             :       }
    3038                 :             :   }
    3039                 :             :   return false;
    3040                 :             : }
    3041                 :             : 
    3042                 :             : /* Similar to above, except that it also rejects register pre- and post-
    3043                 :             :    incrementing.  */
    3044                 :             : 
    3045                 :             : bool
    3046                 :  4971001597 : side_effects_p (const_rtx x)
    3047                 :             : {
    3048                 :  4971001597 :   const RTX_CODE code = GET_CODE (x);
    3049                 :  4971001597 :   switch (code)
    3050                 :             :     {
    3051                 :             :     case LABEL_REF:
    3052                 :             :     case SYMBOL_REF:
    3053                 :             :     case CONST:
    3054                 :             :     CASE_CONST_ANY:
    3055                 :             :     case PC:
    3056                 :             :     case REG:
    3057                 :             :     case SCRATCH:
    3058                 :             :     case ADDR_VEC:
    3059                 :             :     case ADDR_DIFF_VEC:
    3060                 :             :     case VAR_LOCATION:
    3061                 :             :       return false;
    3062                 :             : 
    3063                 :    58580377 :     case CLOBBER:
    3064                 :             :       /* Reject CLOBBER with a non-VOID mode.  These are made by combine.cc
    3065                 :             :          when some combination can't be done.  If we see one, don't think
    3066                 :             :          that we can simplify the expression.  */
    3067                 :    58580377 :       return (GET_MODE (x) != VOIDmode);
    3068                 :             : 
    3069                 :             :     case PRE_INC:
    3070                 :             :     case PRE_DEC:
    3071                 :             :     case POST_INC:
    3072                 :             :     case POST_DEC:
    3073                 :             :     case PRE_MODIFY:
    3074                 :             :     case POST_MODIFY:
    3075                 :             :     case CALL:
    3076                 :             :     case UNSPEC_VOLATILE:
    3077                 :             :       return true;
    3078                 :             : 
    3079                 :   304081914 :     case MEM:
    3080                 :   304081914 :     case ASM_INPUT:
    3081                 :   304081914 :     case ASM_OPERANDS:
    3082                 :   304081914 :       if (MEM_VOLATILE_P (x))
    3083                 :             :         return true;
    3084                 :             : 
    3085                 :  1758150558 :     default:
    3086                 :  1758150558 :       break;
    3087                 :             :     }
    3088                 :             : 
    3089                 :             :   /* Recursively scan the operands of this expression.  */
    3090                 :             : 
    3091                 :  1758150558 :   {
    3092                 :  1758150558 :     const char *fmt = GET_RTX_FORMAT (code);
    3093                 :  1758150558 :     int i;
    3094                 :             : 
    3095                 :  5222924574 :     for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    3096                 :             :       {
    3097                 :  3512568626 :         if (fmt[i] == 'e')
    3098                 :             :           {
    3099                 :  3106430255 :             if (side_effects_p (XEXP (x, i)))
    3100                 :             :               return true;
    3101                 :             :           }
    3102                 :   406138371 :         else if (fmt[i] == 'E')
    3103                 :             :           {
    3104                 :             :             int j;
    3105                 :   220443691 :             for (j = 0; j < XVECLEN (x, i); j++)
    3106                 :   148990044 :               if (side_effects_p (XVECEXP (x, i, j)))
    3107                 :             :                 return true;
    3108                 :             :           }
    3109                 :             :       }
    3110                 :             :   }
    3111                 :             :   return false;
    3112                 :             : }
    3113                 :             : 
    3114                 :             : /* Return true if evaluating rtx X might cause a trap.
    3115                 :             :    FLAGS controls how to consider MEMs.  A true means the context
    3116                 :             :    of the access may have changed from the original, such that the
    3117                 :             :    address may have become invalid.  */
    3118                 :             : 
    3119                 :             : bool
    3120                 :  8794805911 : may_trap_p_1 (const_rtx x, unsigned flags)
    3121                 :             : {
    3122                 :  8794805911 :   int i;
    3123                 :  8794805911 :   enum rtx_code code;
    3124                 :  8794805911 :   const char *fmt;
    3125                 :             : 
    3126                 :             :   /* We make no distinction currently, but this function is part of
    3127                 :             :      the internal target-hooks ABI so we keep the parameter as
    3128                 :             :      "unsigned flags".  */
    3129                 :  8794805911 :   bool code_changed = flags != 0;
    3130                 :             : 
    3131                 :  8794805911 :   if (x == 0)
    3132                 :             :     return false;
    3133                 :  8794803907 :   code = GET_CODE (x);
    3134                 :  8794803907 :   switch (code)
    3135                 :             :     {
    3136                 :             :       /* Handle these cases quickly.  */
    3137                 :             :     CASE_CONST_ANY:
    3138                 :             :     case SYMBOL_REF:
    3139                 :             :     case LABEL_REF:
    3140                 :             :     case CONST:
    3141                 :             :     case PC:
    3142                 :             :     case REG:
    3143                 :             :     case SCRATCH:
    3144                 :             :       return false;
    3145                 :             : 
    3146                 :     5684197 :     case UNSPEC:
    3147                 :     5684197 :       return targetm.unspec_may_trap_p (x, flags);
    3148                 :             : 
    3149                 :             :     case UNSPEC_VOLATILE:
    3150                 :             :     case ASM_INPUT:
    3151                 :             :     case TRAP_IF:
    3152                 :             :       return true;
    3153                 :             : 
    3154                 :      174810 :     case ASM_OPERANDS:
    3155                 :      174810 :       return MEM_VOLATILE_P (x);
    3156                 :             : 
    3157                 :             :       /* Memory ref can trap unless it's a static var or a stack slot.  */
    3158                 :  1033862968 :     case MEM:
    3159                 :             :       /* Recognize specific pattern of stack checking probes.  */
    3160                 :  1033862968 :       if (flag_stack_check
    3161                 :        7770 :           && MEM_VOLATILE_P (x)
    3162                 :  1033863756 :           && XEXP (x, 0) == stack_pointer_rtx)
    3163                 :             :         return true;
    3164                 :  1033862181 :       if (/* MEM_NOTRAP_P only relates to the actual position of the memory
    3165                 :             :              reference; moving it out of context such as when moving code
    3166                 :             :              when optimizing, might cause its address to become invalid.  */
    3167                 :             :           code_changed
    3168                 :  1033862181 :           || !MEM_NOTRAP_P (x))
    3169                 :             :         {
    3170                 :   482662757 :           poly_int64 size = MEM_SIZE_KNOWN_P (x) ? MEM_SIZE (x) : -1;
    3171                 :   424348446 :           return rtx_addr_can_trap_p_1 (XEXP (x, 0), 0, size,
    3172                 :   424348446 :                                         GET_MODE (x), code_changed);
    3173                 :             :         }
    3174                 :             : 
    3175                 :             :       return false;
    3176                 :             : 
    3177                 :             :       /* Division by a non-constant might trap.  */
    3178                 :      950776 :     case DIV:
    3179                 :      950776 :     case MOD:
    3180                 :      950776 :     case UDIV:
    3181                 :      950776 :     case UMOD:
    3182                 :      950776 :       if (HONOR_SNANS (x))
    3183                 :             :         return true;
    3184                 :      950076 :       if (FLOAT_MODE_P (GET_MODE (x)))
    3185                 :      403974 :         return flag_trapping_math;
    3186                 :      546102 :       if (!CONSTANT_P (XEXP (x, 1)) || (XEXP (x, 1) == const0_rtx))
    3187                 :             :         return true;
    3188                 :       63260 :       if (GET_CODE (XEXP (x, 1)) == CONST_VECTOR)
    3189                 :             :         {
    3190                 :             :           /* For CONST_VECTOR, return 1 if any element is or might be zero.  */
    3191                 :           0 :           unsigned int n_elts;
    3192                 :           0 :           rtx op = XEXP (x, 1);
    3193                 :           0 :           if (!GET_MODE_NUNITS (GET_MODE (op)).is_constant (&n_elts))
    3194                 :             :             {
    3195                 :             :               if (!CONST_VECTOR_DUPLICATE_P (op))
    3196                 :   270395357 :                 return true;
    3197                 :             :               for (unsigned i = 0; i < (unsigned int) XVECLEN (op, 0); i++)
    3198                 :             :                 if (CONST_VECTOR_ENCODED_ELT (op, i) == const0_rtx)
    3199                 :             :                   return true;
    3200                 :             :             }
    3201                 :             :           else
    3202                 :           0 :             for (unsigned i = 0; i < n_elts; i++)
    3203                 :           0 :               if (CONST_VECTOR_ELT (op, i) == const0_rtx)
    3204                 :             :                 return true;
    3205                 :             :         }
    3206                 :             :       break;
    3207                 :             : 
    3208                 :             :     case EXPR_LIST:
    3209                 :             :       /* An EXPR_LIST is used to represent a function call.  This
    3210                 :             :          certainly may trap.  */
    3211                 :             :       return true;
    3212                 :             : 
    3213                 :   178449909 :     case GE:
    3214                 :   178449909 :     case GT:
    3215                 :   178449909 :     case LE:
    3216                 :   178449909 :     case LT:
    3217                 :   178449909 :     case LTGT:
    3218                 :   178449909 :     case COMPARE:
    3219                 :             :     /* Treat min/max similar as comparisons.  */
    3220                 :   178449909 :     case SMIN:
    3221                 :   178449909 :     case SMAX:
    3222                 :             :       /* Some floating point comparisons may trap.  */
    3223                 :   178449909 :       if (!flag_trapping_math)
    3224                 :             :         break;
    3225                 :             :       /* ??? There is no machine independent way to check for tests that trap
    3226                 :             :          when COMPARE is used, though many targets do make this distinction.
    3227                 :             :          For instance, sparc uses CCFPE for compares which generate exceptions
    3228                 :             :          and CCFP for compares which do not generate exceptions.  */
    3229                 :   176882535 :       if (HONOR_NANS (x))
    3230                 :             :         return true;
    3231                 :             :       /* But often the compare has some CC mode, so check operand
    3232                 :             :          modes as well.  */
    3233                 :   176858225 :       if (HONOR_NANS (XEXP (x, 0))
    3234                 :   176858225 :           || HONOR_NANS (XEXP (x, 1)))
    3235                 :     2320280 :         return true;
    3236                 :             :       break;
    3237                 :             : 
    3238                 :    28268635 :     case EQ:
    3239                 :    28268635 :     case NE:
    3240                 :    28268635 :       if (HONOR_SNANS (x))
    3241                 :             :         return true;
    3242                 :             :       /* Often comparison is CC mode, so check operand modes.  */
    3243                 :    28268618 :       if (HONOR_SNANS (XEXP (x, 0))
    3244                 :    28268618 :           || HONOR_SNANS (XEXP (x, 1)))
    3245                 :           0 :         return true;
    3246                 :             :       break;
    3247                 :             : 
    3248                 :      360996 :     case FIX:
    3249                 :      360996 :     case UNSIGNED_FIX:
    3250                 :             :       /* Conversion of floating point might trap.  */
    3251                 :      360996 :       if (flag_trapping_math && HONOR_NANS (XEXP (x, 0)))
    3252                 :             :         return true;
    3253                 :             :       break;
    3254                 :             : 
    3255                 :             :     case NEG:
    3256                 :             :     case ABS:
    3257                 :             :     case SUBREG:
    3258                 :             :     case VEC_MERGE:
    3259                 :             :     case VEC_SELECT:
    3260                 :             :     case VEC_CONCAT:
    3261                 :             :     case VEC_DUPLICATE:
    3262                 :             :       /* These operations don't trap even with floating point.  */
    3263                 :             :       break;
    3264                 :             : 
    3265                 :  3302155679 :     default:
    3266                 :             :       /* Any floating arithmetic may trap.  */
    3267                 :  3302155679 :       if (FLOAT_MODE_P (GET_MODE (x)) && flag_trapping_math)
    3268                 :             :         return true;
    3269                 :             :     }
    3270                 :             : 
    3271                 :  3600449117 :   fmt = GET_RTX_FORMAT (code);
    3272                 :  9721008355 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    3273                 :             :     {
    3274                 :  6347578930 :       if (fmt[i] == 'e')
    3275                 :             :         {
    3276                 :  5912286901 :           if (may_trap_p_1 (XEXP (x, i), flags))
    3277                 :             :             return true;
    3278                 :             :         }
    3279                 :   435292029 :       else if (fmt[i] == 'E')
    3280                 :             :         {
    3281                 :             :           int j;
    3282                 :   951028500 :           for (j = 0; j < XVECLEN (x, i); j++)
    3283                 :   657232429 :             if (may_trap_p_1 (XVECEXP (x, i, j), flags))
    3284                 :             :               return true;
    3285                 :             :         }
    3286                 :             :     }
    3287                 :             :   return false;
    3288                 :             : }
    3289                 :             : 
    3290                 :             : /* Return true if evaluating rtx X might cause a trap.  */
    3291                 :             : 
    3292                 :             : bool
    3293                 :  2207933422 : may_trap_p (const_rtx x)
    3294                 :             : {
    3295                 :  2207933422 :   return may_trap_p_1 (x, 0);
    3296                 :             : }
    3297                 :             : 
    3298                 :             : /* Same as above, but additionally return true if evaluating rtx X might
    3299                 :             :    cause a fault.  We define a fault for the purpose of this function as a
    3300                 :             :    erroneous execution condition that cannot be encountered during the normal
    3301                 :             :    execution of a valid program; the typical example is an unaligned memory
    3302                 :             :    access on a strict alignment machine.  The compiler guarantees that it
    3303                 :             :    doesn't generate code that will fault from a valid program, but this
    3304                 :             :    guarantee doesn't mean anything for individual instructions.  Consider
    3305                 :             :    the following example:
    3306                 :             : 
    3307                 :             :       struct S { int d; union { char *cp; int *ip; }; };
    3308                 :             : 
    3309                 :             :       int foo(struct S *s)
    3310                 :             :       {
    3311                 :             :         if (s->d == 1)
    3312                 :             :           return *s->ip;
    3313                 :             :         else
    3314                 :             :           return *s->cp;
    3315                 :             :       }
    3316                 :             : 
    3317                 :             :    on a strict alignment machine.  In a valid program, foo will never be
    3318                 :             :    invoked on a structure for which d is equal to 1 and the underlying
    3319                 :             :    unique field of the union not aligned on a 4-byte boundary, but the
    3320                 :             :    expression *s->ip might cause a fault if considered individually.
    3321                 :             : 
    3322                 :             :    At the RTL level, potentially problematic expressions will almost always
    3323                 :             :    verify may_trap_p; for example, the above dereference can be emitted as
    3324                 :             :    (mem:SI (reg:P)) and this expression is may_trap_p for a generic register.
    3325                 :             :    However, suppose that foo is inlined in a caller that causes s->cp to
    3326                 :             :    point to a local character variable and guarantees that s->d is not set
    3327                 :             :    to 1; foo may have been effectively translated into pseudo-RTL as:
    3328                 :             : 
    3329                 :             :       if ((reg:SI) == 1)
    3330                 :             :         (set (reg:SI) (mem:SI (%fp - 7)))
    3331                 :             :       else
    3332                 :             :         (set (reg:QI) (mem:QI (%fp - 7)))
    3333                 :             : 
    3334                 :             :    Now (mem:SI (%fp - 7)) is considered as not may_trap_p since it is a
    3335                 :             :    memory reference to a stack slot, but it will certainly cause a fault
    3336                 :             :    on a strict alignment machine.  */
    3337                 :             : 
    3338                 :             : bool
    3339                 :    10194059 : may_trap_or_fault_p (const_rtx x)
    3340                 :             : {
    3341                 :    10194059 :   return may_trap_p_1 (x, 1);
    3342                 :             : }
    3343                 :             : 
    3344                 :             : /* Replace any occurrence of FROM in X with TO.  The function does
    3345                 :             :    not enter into CONST_DOUBLE for the replace.
    3346                 :             : 
    3347                 :             :    Note that copying is not done so X must not be shared unless all copies
    3348                 :             :    are to be modified.
    3349                 :             : 
    3350                 :             :    ALL_REGS is true if we want to replace all REGs equal to FROM, not just
    3351                 :             :    those pointer-equal ones.  */
    3352                 :             : 
    3353                 :             : rtx
    3354                 :     8800429 : replace_rtx (rtx x, rtx from, rtx to, bool all_regs)
    3355                 :             : {
    3356                 :     8800429 :   int i, j;
    3357                 :     8800429 :   const char *fmt;
    3358                 :             : 
    3359                 :     8800429 :   if (x == from)
    3360                 :             :     return to;
    3361                 :             : 
    3362                 :             :   /* Allow this function to make replacements in EXPR_LISTs.  */
    3363                 :     6395991 :   if (x == 0)
    3364                 :             :     return 0;
    3365                 :             : 
    3366                 :     6395991 :   if (all_regs
    3367                 :           0 :       && REG_P (x)
    3368                 :           0 :       && REG_P (from)
    3369                 :     6395991 :       && REGNO (x) == REGNO (from))
    3370                 :             :     {
    3371                 :           0 :       gcc_assert (GET_MODE (x) == GET_MODE (from));
    3372                 :             :       return to;
    3373                 :             :     }
    3374                 :     6395991 :   else if (GET_CODE (x) == SUBREG)
    3375                 :             :     {
    3376                 :       46982 :       rtx new_rtx = replace_rtx (SUBREG_REG (x), from, to, all_regs);
    3377                 :             : 
    3378                 :       46982 :       if (CONST_SCALAR_INT_P (new_rtx))
    3379                 :             :         {
    3380                 :          24 :           x = simplify_subreg (GET_MODE (x), new_rtx,
    3381                 :          12 :                                GET_MODE (SUBREG_REG (x)),
    3382                 :          12 :                                SUBREG_BYTE (x));
    3383                 :          12 :           gcc_assert (x);
    3384                 :             :         }
    3385                 :             :       else
    3386                 :       46970 :         SUBREG_REG (x) = new_rtx;
    3387                 :             : 
    3388                 :       46982 :       return x;
    3389                 :             :     }
    3390                 :     6349009 :   else if (GET_CODE (x) == ZERO_EXTEND)
    3391                 :             :     {
    3392                 :      193239 :       rtx new_rtx = replace_rtx (XEXP (x, 0), from, to, all_regs);
    3393                 :             : 
    3394                 :      193239 :       if (CONST_SCALAR_INT_P (new_rtx))
    3395                 :             :         {
    3396                 :          24 :           x = simplify_unary_operation (ZERO_EXTEND, GET_MODE (x),
    3397                 :          12 :                                         new_rtx, GET_MODE (XEXP (x, 0)));
    3398                 :          12 :           gcc_assert (x);
    3399                 :             :         }
    3400                 :             :       else
    3401                 :      193227 :         XEXP (x, 0) = new_rtx;
    3402                 :             : 
    3403                 :      193239 :       return x;
    3404                 :             :     }
    3405                 :             : 
    3406                 :     6155770 :   fmt = GET_RTX_FORMAT (GET_CODE (x));
    3407                 :    15267343 :   for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
    3408                 :             :     {
    3409                 :     9111573 :       if (fmt[i] == 'e')
    3410                 :     5961681 :         XEXP (x, i) = replace_rtx (XEXP (x, i), from, to, all_regs);
    3411                 :     3149892 :       else if (fmt[i] == 'E')
    3412                 :      130751 :         for (j = XVECLEN (x, i) - 1; j >= 0; j--)
    3413                 :      108141 :           XVECEXP (x, i, j) = replace_rtx (XVECEXP (x, i, j),
    3414                 :             :                                            from, to, all_regs);
    3415                 :             :     }
    3416                 :             : 
    3417                 :             :   return x;
    3418                 :             : }
    3419                 :             : 
    3420                 :             : /* Replace occurrences of the OLD_LABEL in *LOC with NEW_LABEL.  Also track
    3421                 :             :    the change in LABEL_NUSES if UPDATE_LABEL_NUSES.  */
    3422                 :             : 
    3423                 :             : void
    3424                 :        9697 : replace_label (rtx *loc, rtx old_label, rtx new_label, bool update_label_nuses)
    3425                 :             : {
    3426                 :             :   /* Handle jump tables specially, since ADDR_{DIFF_,}VECs can be long.  */
    3427                 :        9697 :   rtx x = *loc;
    3428                 :        9697 :   if (JUMP_TABLE_DATA_P (x))
    3429                 :             :     {
    3430                 :          15 :       x = PATTERN (x);
    3431                 :          15 :       rtvec vec = XVEC (x, GET_CODE (x) == ADDR_DIFF_VEC);
    3432                 :          15 :       int len = GET_NUM_ELEM (vec);
    3433                 :         300 :       for (int i = 0; i < len; ++i)
    3434                 :             :         {
    3435                 :         285 :           rtx ref = RTVEC_ELT (vec, i);
    3436                 :         285 :           if (XEXP (ref, 0) == old_label)
    3437                 :             :             {
    3438                 :           0 :               XEXP (ref, 0) = new_label;
    3439                 :           0 :               if (update_label_nuses)
    3440                 :             :                 {
    3441                 :           0 :                   ++LABEL_NUSES (new_label);
    3442                 :           0 :                   --LABEL_NUSES (old_label);
    3443                 :             :                 }
    3444                 :             :             }
    3445                 :             :         }
    3446                 :          15 :       return;
    3447                 :             :     }
    3448                 :             : 
    3449                 :             :   /* If this is a JUMP_INSN, then we also need to fix the JUMP_LABEL
    3450                 :             :      field.  This is not handled by the iterator because it doesn't
    3451                 :             :      handle unprinted ('0') fields.  */
    3452                 :        9682 :   if (JUMP_P (x) && JUMP_LABEL (x) == old_label)
    3453                 :          20 :     JUMP_LABEL (x) = new_label;
    3454                 :             : 
    3455                 :        9682 :   subrtx_ptr_iterator::array_type array;
    3456                 :       79662 :   FOR_EACH_SUBRTX_PTR (iter, array, loc, ALL)
    3457                 :             :     {
    3458                 :       69980 :       rtx *loc = *iter;
    3459                 :       69980 :       if (rtx x = *loc)
    3460                 :             :         {
    3461                 :       61056 :           if (GET_CODE (x) == SYMBOL_REF
    3462                 :       61056 :               && CONSTANT_POOL_ADDRESS_P (x))
    3463                 :             :             {
    3464                 :         338 :               rtx c = get_pool_constant (x);
    3465                 :         338 :               if (rtx_referenced_p (old_label, c))
    3466                 :             :                 {
    3467                 :             :                   /* Create a copy of constant C; replace the label inside
    3468                 :             :                      but do not update LABEL_NUSES because uses in constant pool
    3469                 :             :                      are not counted.  */
    3470                 :           0 :                   rtx new_c = copy_rtx (c);
    3471                 :           0 :                   replace_label (&new_c, old_label, new_label, false);
    3472                 :             : 
    3473                 :             :                   /* Add the new constant NEW_C to constant pool and replace
    3474                 :             :                      the old reference to constant by new reference.  */
    3475                 :           0 :                   rtx new_mem = force_const_mem (get_pool_mode (x), new_c);
    3476                 :           0 :                   *loc = replace_rtx (x, x, XEXP (new_mem, 0));
    3477                 :             :                 }
    3478                 :             :             }
    3479                 :             : 
    3480                 :       61056 :           if ((GET_CODE (x) == LABEL_REF
    3481                 :       60652 :                || GET_CODE (x) == INSN_LIST)
    3482                 :         424 :               && XEXP (x, 0) == old_label)
    3483                 :             :             {
    3484                 :          40 :               XEXP (x, 0) = new_label;
    3485                 :          40 :               if (update_label_nuses)
    3486                 :             :                 {
    3487                 :           0 :                   ++LABEL_NUSES (new_label);
    3488                 :           0 :                   --LABEL_NUSES (old_label);
    3489                 :             :                 }
    3490                 :             :             }
    3491                 :             :         }
    3492                 :             :     }
    3493                 :        9682 : }
    3494                 :             : 
    3495                 :             : void
    3496                 :        9697 : replace_label_in_insn (rtx_insn *insn, rtx_insn *old_label,
    3497                 :             :                        rtx_insn *new_label, bool update_label_nuses)
    3498                 :             : {
    3499                 :        9697 :   rtx insn_as_rtx = insn;
    3500                 :        9697 :   replace_label (&insn_as_rtx, old_label, new_label, update_label_nuses);
    3501                 :        9697 :   gcc_checking_assert (insn_as_rtx == insn);
    3502                 :        9697 : }
    3503                 :             : 
    3504                 :             : /* Return true if X is referenced in BODY.  */
    3505                 :             : 
    3506                 :             : bool
    3507                 :      352491 : rtx_referenced_p (const_rtx x, const_rtx body)
    3508                 :             : {
    3509                 :      352491 :   subrtx_iterator::array_type array;
    3510                 :     1653769 :   FOR_EACH_SUBRTX (iter, array, body, ALL)
    3511                 :     1323935 :     if (const_rtx y = *iter)
    3512                 :             :       {
    3513                 :             :         /* Check if a label_ref Y refers to label X.  */
    3514                 :     1322999 :         if (GET_CODE (y) == LABEL_REF
    3515                 :        1583 :             && LABEL_P (x)
    3516                 :     1324579 :             && label_ref_label (y) == x)
    3517                 :       22657 :           return true;
    3518                 :             : 
    3519                 :     1322999 :         if (rtx_equal_p (x, y))
    3520                 :             :           return true;
    3521                 :             : 
    3522                 :             :         /* If Y is a reference to pool constant traverse the constant.  */
    3523                 :     1300342 :         if (GET_CODE (y) == SYMBOL_REF
    3524                 :     1300342 :             && CONSTANT_POOL_ADDRESS_P (y))
    3525                 :        6405 :           iter.substitute (get_pool_constant (y));
    3526                 :             :       }
    3527                 :      329834 :   return false;
    3528                 :      352491 : }
    3529                 :             : 
    3530                 :             : /* If INSN is a tablejump return true and store the label (before jump table) to
    3531                 :             :    *LABELP and the jump table to *TABLEP.  LABELP and TABLEP may be NULL.  */
    3532                 :             : 
    3533                 :             : bool
    3534                 :   100946486 : tablejump_p (const rtx_insn *insn, rtx_insn **labelp,
    3535                 :             :              rtx_jump_table_data **tablep)
    3536                 :             : {
    3537                 :   100946486 :   if (!JUMP_P (insn))
    3538                 :             :     return false;
    3539                 :             : 
    3540                 :    76045243 :   rtx target = JUMP_LABEL (insn);
    3541                 :    76045243 :   if (target == NULL_RTX || ANY_RETURN_P (target))
    3542                 :             :     return false;
    3543                 :             : 
    3544                 :    72563555 :   rtx_insn *label = as_a<rtx_insn *> (target);
    3545                 :    72563555 :   rtx_insn *table = next_insn (label);
    3546                 :    72563555 :   if (table == NULL_RTX || !JUMP_TABLE_DATA_P (table))
    3547                 :             :     return false;
    3548                 :             : 
    3549                 :      139018 :   if (labelp)
    3550                 :       98273 :     *labelp = label;
    3551                 :      139018 :   if (tablep)
    3552                 :      134240 :     *tablep = as_a <rtx_jump_table_data *> (table);
    3553                 :             :   return true;
    3554                 :             : }
    3555                 :             : 
    3556                 :             : /* For INSN known to satisfy tablejump_p, determine if it actually is a
    3557                 :             :    CASESI.  Return the insn pattern if so, NULL_RTX otherwise.  */
    3558                 :             : 
    3559                 :             : rtx
    3560                 :       22259 : tablejump_casesi_pattern (const rtx_insn *insn)
    3561                 :             : {
    3562                 :       22259 :   rtx tmp;
    3563                 :             : 
    3564                 :       22259 :   if ((tmp = single_set (insn)) != NULL
    3565                 :       22259 :       && SET_DEST (tmp) == pc_rtx
    3566                 :       22259 :       && GET_CODE (SET_SRC (tmp)) == IF_THEN_ELSE
    3567                 :       22259 :       && GET_CODE (XEXP (SET_SRC (tmp), 2)) == LABEL_REF)
    3568                 :           0 :     return tmp;
    3569                 :             : 
    3570                 :             :   return NULL_RTX;
    3571                 :             : }
    3572                 :             : 
    3573                 :             : /* A subroutine of computed_jump_p, return true if X contains a REG or MEM or
    3574                 :             :    constant that is not in the constant pool and not in the condition
    3575                 :             :    of an IF_THEN_ELSE.  */
    3576                 :             : 
    3577                 :             : static bool
    3578                 :        1869 : computed_jump_p_1 (const_rtx x)
    3579                 :             : {
    3580                 :        1869 :   const enum rtx_code code = GET_CODE (x);
    3581                 :        1869 :   int i, j;
    3582                 :        1869 :   const char *fmt;
    3583                 :             : 
    3584                 :        1869 :   switch (code)
    3585                 :             :     {
    3586                 :             :     case LABEL_REF:
    3587                 :             :     case PC:
    3588                 :             :       return false;
    3589                 :             : 
    3590                 :             :     case CONST:
    3591                 :             :     CASE_CONST_ANY:
    3592                 :             :     case SYMBOL_REF:
    3593                 :             :     case REG:
    3594                 :             :       return true;
    3595                 :             : 
    3596                 :         317 :     case MEM:
    3597                 :         317 :       return ! (GET_CODE (XEXP (x, 0)) == SYMBOL_REF
    3598                 :          14 :                 && CONSTANT_POOL_ADDRESS_P (XEXP (x, 0)));
    3599                 :             : 
    3600                 :           0 :     case IF_THEN_ELSE:
    3601                 :           0 :       return (computed_jump_p_1 (XEXP (x, 1))
    3602                 :           0 :               || computed_jump_p_1 (XEXP (x, 2)));
    3603                 :             : 
    3604                 :           0 :     default:
    3605                 :           0 :       break;
    3606                 :             :     }
    3607                 :             : 
    3608                 :           0 :   fmt = GET_RTX_FORMAT (code);
    3609                 :           0 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    3610                 :             :     {
    3611                 :           0 :       if (fmt[i] == 'e'
    3612                 :           0 :           && computed_jump_p_1 (XEXP (x, i)))
    3613                 :             :         return true;
    3614                 :             : 
    3615                 :           0 :       else if (fmt[i] == 'E')
    3616                 :           0 :         for (j = 0; j < XVECLEN (x, i); j++)
    3617                 :           0 :           if (computed_jump_p_1 (XVECEXP (x, i, j)))
    3618                 :             :             return true;
    3619                 :             :     }
    3620                 :             : 
    3621                 :             :   return false;
    3622                 :             : }
    3623                 :             : 
    3624                 :             : /* Return true if INSN is an indirect jump (aka computed jump).
    3625                 :             : 
    3626                 :             :    Tablejumps and casesi insns are not considered indirect jumps;
    3627                 :             :    we can recognize them by a (use (label_ref)).  */
    3628                 :             : 
    3629                 :             : bool
    3630                 :    43223021 : computed_jump_p (const rtx_insn *insn)
    3631                 :             : {
    3632                 :    43223021 :   int i;
    3633                 :    43223021 :   if (JUMP_P (insn))
    3634                 :             :     {
    3635                 :    39524523 :       rtx pat = PATTERN (insn);
    3636                 :             : 
    3637                 :             :       /* If we have a JUMP_LABEL set, we're not a computed jump.  */
    3638                 :    39524523 :       if (JUMP_LABEL (insn) != NULL)
    3639                 :             :         return false;
    3640                 :             : 
    3641                 :        2383 :       if (GET_CODE (pat) == PARALLEL)
    3642                 :             :         {
    3643                 :         483 :           int len = XVECLEN (pat, 0);
    3644                 :         483 :           bool has_use_labelref = false;
    3645                 :             : 
    3646                 :        1449 :           for (i = len - 1; i >= 0; i--)
    3647                 :         966 :             if (GET_CODE (XVECEXP (pat, 0, i)) == USE
    3648                 :           0 :                 && (GET_CODE (XEXP (XVECEXP (pat, 0, i), 0))
    3649                 :             :                     == LABEL_REF))
    3650                 :             :               {
    3651                 :             :                 has_use_labelref = true;
    3652                 :             :                 break;
    3653                 :             :               }
    3654                 :             : 
    3655                 :         483 :           if (! has_use_labelref)
    3656                 :        1449 :             for (i = len - 1; i >= 0; i--)
    3657                 :         966 :               if (GET_CODE (XVECEXP (pat, 0, i)) == SET
    3658                 :           0 :                   && SET_DEST (XVECEXP (pat, 0, i)) == pc_rtx
    3659                 :         966 :                   && computed_jump_p_1 (SET_SRC (XVECEXP (pat, 0, i))))
    3660                 :             :                 return true;
    3661                 :             :         }
    3662                 :        1900 :       else if (GET_CODE (pat) == SET
    3663                 :        1869 :                && SET_DEST (pat) == pc_rtx
    3664                 :        3769 :                && computed_jump_p_1 (SET_SRC (pat)))
    3665                 :             :         return true;
    3666                 :             :     }
    3667                 :             :   return false;
    3668                 :             : }
    3669                 :             : 
    3670                 :             : 
    3671                 :             : 
    3672                 :             : /* MEM has a PRE/POST-INC/DEC/MODIFY address X.  Extract the operands of
    3673                 :             :    the equivalent add insn and pass the result to FN, using DATA as the
    3674                 :             :    final argument.  */
    3675                 :             : 
    3676                 :             : static int
    3677                 :    20035346 : for_each_inc_dec_find_inc_dec (rtx mem, for_each_inc_dec_fn fn, void *data)
    3678                 :             : {
    3679                 :    20035346 :   rtx x = XEXP (mem, 0);
    3680                 :    20035346 :   switch (GET_CODE (x))
    3681                 :             :     {
    3682                 :     2580302 :     case PRE_INC:
    3683                 :     2580302 :     case POST_INC:
    3684                 :     2580302 :       {
    3685                 :     5160604 :         poly_int64 size = GET_MODE_SIZE (GET_MODE (mem));
    3686                 :     2580302 :         rtx r1 = XEXP (x, 0);
    3687                 :     2580302 :         rtx c = gen_int_mode (size, GET_MODE (r1));
    3688                 :     2580302 :         return fn (mem, x, r1, r1, c, data);
    3689                 :             :       }
    3690                 :             : 
    3691                 :    16935747 :     case PRE_DEC:
    3692                 :    16935747 :     case POST_DEC:
    3693                 :    16935747 :       {
    3694                 :    33871494 :         poly_int64 size = GET_MODE_SIZE (GET_MODE (mem));
    3695                 :    16935747 :         rtx r1 = XEXP (x, 0);
    3696                 :    16935747 :         rtx c = gen_int_mode (-size, GET_MODE (r1));
    3697                 :    16935747 :         return fn (mem, x, r1, r1, c, data);
    3698                 :             :       }
    3699                 :             : 
    3700                 :      519297 :     case PRE_MODIFY:
    3701                 :      519297 :     case POST_MODIFY:
    3702                 :      519297 :       {
    3703                 :      519297 :         rtx r1 = XEXP (x, 0);
    3704                 :      519297 :         rtx add = XEXP (x, 1);
    3705                 :      519297 :         return fn (mem, x, r1, add, NULL, data);
    3706                 :             :       }
    3707                 :             : 
    3708                 :           0 :     default:
    3709                 :           0 :       gcc_unreachable ();
    3710                 :             :     }
    3711                 :             : }
    3712                 :             : 
    3713                 :             : /* Traverse *LOC looking for MEMs that have autoinc addresses.
    3714                 :             :    For each such autoinc operation found, call FN, passing it
    3715                 :             :    the innermost enclosing MEM, the operation itself, the RTX modified
    3716                 :             :    by the operation, two RTXs (the second may be NULL) that, once
    3717                 :             :    added, represent the value to be held by the modified RTX
    3718                 :             :    afterwards, and DATA.  FN is to return 0 to continue the
    3719                 :             :    traversal or any other value to have it returned to the caller of
    3720                 :             :    for_each_inc_dec.  */
    3721                 :             : 
    3722                 :             : int
    3723                 :   910631333 : for_each_inc_dec (rtx x,
    3724                 :             :                   for_each_inc_dec_fn fn,
    3725                 :             :                   void *data)
    3726                 :             : {
    3727                 :   910631333 :   subrtx_var_iterator::array_type array;
    3728                 :  4900065610 :   FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST)
    3729                 :             :     {
    3730                 :  3989434277 :       rtx mem = *iter;
    3731                 :  3989434277 :       if (mem
    3732                 :  3989434277 :           && MEM_P (mem)
    3733                 :   238400701 :           && GET_RTX_CLASS (GET_CODE (XEXP (mem, 0))) == RTX_AUTOINC)
    3734                 :             :         {
    3735                 :    20035346 :           int res = for_each_inc_dec_find_inc_dec (mem, fn, data);
    3736                 :    20035346 :           if (res != 0)
    3737                 :           0 :             return res;
    3738                 :    20035346 :           iter.skip_subrtxes ();
    3739                 :             :         }
    3740                 :             :     }
    3741                 :   910631333 :   return 0;
    3742                 :   910631333 : }
    3743                 :             : 
    3744                 :             : 
    3745                 :             : /* Searches X for any reference to REGNO, returning the rtx of the
    3746                 :             :    reference found if any.  Otherwise, returns NULL_RTX.  */
    3747                 :             : 
    3748                 :             : rtx
    3749                 :           0 : regno_use_in (unsigned int regno, rtx x)
    3750                 :             : {
    3751                 :           0 :   const char *fmt;
    3752                 :           0 :   int i, j;
    3753                 :           0 :   rtx tem;
    3754                 :             : 
    3755                 :           0 :   if (REG_P (x) && REGNO (x) == regno)
    3756                 :             :     return x;
    3757                 :             : 
    3758                 :           0 :   fmt = GET_RTX_FORMAT (GET_CODE (x));
    3759                 :           0 :   for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
    3760                 :             :     {
    3761                 :           0 :       if (fmt[i] == 'e')
    3762                 :             :         {
    3763                 :           0 :           if ((tem = regno_use_in (regno, XEXP (x, i))))
    3764                 :             :             return tem;
    3765                 :             :         }
    3766                 :           0 :       else if (fmt[i] == 'E')
    3767                 :           0 :         for (j = XVECLEN (x, i) - 1; j >= 0; j--)
    3768                 :           0 :           if ((tem = regno_use_in (regno , XVECEXP (x, i, j))))
    3769                 :             :             return tem;
    3770                 :             :     }
    3771                 :             : 
    3772                 :             :   return NULL_RTX;
    3773                 :             : }
    3774                 :             : 
    3775                 :             : /* Return a value indicating whether OP, an operand of a commutative
    3776                 :             :    operation, is preferred as the first or second operand.  The more
    3777                 :             :    positive the value, the stronger the preference for being the first
    3778                 :             :    operand.  */
    3779                 :             : 
    3780                 :             : int
    3781                 :  1994582520 : commutative_operand_precedence (rtx op)
    3782                 :             : {
    3783                 :  1994582520 :   enum rtx_code code = GET_CODE (op);
    3784                 :             : 
    3785                 :             :   /* Constants always become the second operand.  Prefer "nice" constants.  */
    3786                 :  1994582520 :   if (code == CONST_INT)
    3787                 :             :     return -10;
    3788                 :             :   if (code == CONST_WIDE_INT)
    3789                 :             :     return -9;
    3790                 :             :   if (code == CONST_POLY_INT)
    3791                 :             :     return -8;
    3792                 :             :   if (code == CONST_DOUBLE)
    3793                 :             :     return -8;
    3794                 :             :   if (code == CONST_FIXED)
    3795                 :             :     return -8;
    3796                 :  1179152227 :   op = avoid_constant_pool_reference (op);
    3797                 :  1179152227 :   code = GET_CODE (op);
    3798                 :             : 
    3799                 :  1179152227 :   switch (GET_RTX_CLASS (code))
    3800                 :             :     {
    3801                 :    23547193 :     case RTX_CONST_OBJ:
    3802                 :    23547193 :       if (code == CONST_INT)
    3803                 :             :         return -7;
    3804                 :             :       if (code == CONST_WIDE_INT)
    3805                 :             :         return -6;
    3806                 :             :       if (code == CONST_POLY_INT)
    3807                 :             :         return -5;
    3808                 :             :       if (code == CONST_DOUBLE)
    3809                 :             :         return -5;
    3810                 :             :       if (code == CONST_FIXED)
    3811                 :             :         return -5;
    3812                 :             :       return -4;
    3813                 :             : 
    3814                 :    40500108 :     case RTX_EXTRA:
    3815                 :             :       /* SUBREGs of objects should come second.  */
    3816                 :    40500108 :       if (code == SUBREG && OBJECT_P (SUBREG_REG (op)))
    3817                 :             :         return -3;
    3818                 :             :       return 0;
    3819                 :             : 
    3820                 :   870558243 :     case RTX_OBJ:
    3821                 :             :       /* Complex expressions should be the first, so decrease priority
    3822                 :             :          of objects.  Prefer pointer objects over non pointer objects.  */
    3823                 :   786416958 :       if ((REG_P (op) && REG_POINTER (op))
    3824                 :  1310459800 :           || (MEM_P (op) && MEM_POINTER (op)))
    3825                 :   362490303 :         return -1;
    3826                 :             :       return -2;
    3827                 :             : 
    3828                 :             :     case RTX_COMM_ARITH:
    3829                 :             :       /* Prefer operands that are themselves commutative to be first.
    3830                 :             :          This helps to make things linear.  In particular,
    3831                 :             :          (and (and (reg) (reg)) (not (reg))) is canonical.  */
    3832                 :             :       return 4;
    3833                 :             : 
    3834                 :    74264091 :     case RTX_BIN_ARITH:
    3835                 :             :       /* If only one operand is a binary expression, it will be the first
    3836                 :             :          operand.  In particular,  (plus (minus (reg) (reg)) (neg (reg)))
    3837                 :             :          is canonical, although it will usually be further simplified.  */
    3838                 :    74264091 :       return 2;
    3839                 :             : 
    3840                 :    22287416 :     case RTX_UNARY:
    3841                 :             :       /* Then prefer NEG and NOT.  */
    3842                 :    22287416 :       if (code == NEG || code == NOT)
    3843                 :             :         return 1;
    3844                 :             :       /* FALLTHRU */
    3845                 :             : 
    3846                 :             :     default:
    3847                 :             :       return 0;
    3848                 :             :     }
    3849                 :             : }
    3850                 :             : 
    3851                 :             : /* Return true iff it is necessary to swap operands of commutative operation
    3852                 :             :    in order to canonicalize expression.  */
    3853                 :             : 
    3854                 :             : bool
    3855                 :   885270949 : swap_commutative_operands_p (rtx x, rtx y)
    3856                 :             : {
    3857                 :   885270949 :   return (commutative_operand_precedence (x)
    3858                 :   885270949 :           < commutative_operand_precedence (y));
    3859                 :             : }
    3860                 :             : 
    3861                 :             : /* Return true if X is an autoincrement side effect and the register is
    3862                 :             :    not the stack pointer.  */
    3863                 :             : bool
    3864                 :           0 : auto_inc_p (const_rtx x)
    3865                 :             : {
    3866                 :           0 :   switch (GET_CODE (x))
    3867                 :             :     {
    3868                 :           0 :     case PRE_INC:
    3869                 :           0 :     case POST_INC:
    3870                 :           0 :     case PRE_DEC:
    3871                 :           0 :     case POST_DEC:
    3872                 :           0 :     case PRE_MODIFY:
    3873                 :           0 :     case POST_MODIFY:
    3874                 :             :       /* There are no REG_INC notes for SP.  */
    3875                 :           0 :       if (XEXP (x, 0) != stack_pointer_rtx)
    3876                 :           0 :         return true;
    3877                 :             :     default:
    3878                 :             :       break;
    3879                 :             :     }
    3880                 :             :   return false;
    3881                 :             : }
    3882                 :             : 
    3883                 :             : /* Return true if IN contains a piece of rtl that has the address LOC.  */
    3884                 :             : bool
    3885                 :     1002266 : loc_mentioned_in_p (rtx *loc, const_rtx in)
    3886                 :             : {
    3887                 :     1002266 :   enum rtx_code code;
    3888                 :     1002266 :   const char *fmt;
    3889                 :     1002266 :   int i, j;
    3890                 :             : 
    3891                 :     1002266 :   if (!in)
    3892                 :             :     return false;
    3893                 :             : 
    3894                 :     1002266 :   code = GET_CODE (in);
    3895                 :     1002266 :   fmt = GET_RTX_FORMAT (code);
    3896                 :     2003190 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    3897                 :             :     {
    3898                 :     1591623 :       if (fmt[i] == 'e')
    3899                 :             :         {
    3900                 :      982702 :           if (loc == &XEXP (in, i) || loc_mentioned_in_p (loc, XEXP (in, i)))
    3901                 :      589965 :             return true;
    3902                 :             :         }
    3903                 :      608921 :       else if (fmt[i] == 'E')
    3904                 :       24436 :         for (j = XVECLEN (in, i) - 1; j >= 0; j--)
    3905                 :       16722 :           if (loc == &XVECEXP (in, i, j)
    3906                 :       16722 :               || loc_mentioned_in_p (loc, XVECEXP (in, i, j)))
    3907                 :         734 :             return true;
    3908                 :             :     }
    3909                 :             :   return false;
    3910                 :             : }
    3911                 :             : 
    3912                 :             : /* Reinterpret a subreg as a bit extraction from an integer and return
    3913                 :             :    the position of the least significant bit of the extracted value.
    3914                 :             :    In other words, if the extraction were performed as a shift right
    3915                 :             :    and mask, return the number of bits to shift right.
    3916                 :             : 
    3917                 :             :    The outer value of the subreg has OUTER_BYTES bytes and starts at
    3918                 :             :    byte offset SUBREG_BYTE within an inner value of INNER_BYTES bytes.  */
    3919                 :             : 
    3920                 :             : poly_uint64
    3921                 :    43905950 : subreg_size_lsb (poly_uint64 outer_bytes,
    3922                 :             :                  poly_uint64 inner_bytes,
    3923                 :             :                  poly_uint64 subreg_byte)
    3924                 :             : {
    3925                 :    43905950 :   poly_uint64 subreg_end, trailing_bytes, byte_pos;
    3926                 :             : 
    3927                 :             :   /* A paradoxical subreg begins at bit position 0.  */
    3928                 :    43905950 :   gcc_checking_assert (ordered_p (outer_bytes, inner_bytes));
    3929                 :    43905950 :   if (maybe_gt (outer_bytes, inner_bytes))
    3930                 :             :     {
    3931                 :       40366 :       gcc_checking_assert (known_eq (subreg_byte, 0U));
    3932                 :       40366 :       return 0;
    3933                 :             :     }
    3934                 :             : 
    3935                 :    43865584 :   subreg_end = subreg_byte + outer_bytes;
    3936                 :    43865584 :   trailing_bytes = inner_bytes - subreg_end;
    3937                 :    43865584 :   if (WORDS_BIG_ENDIAN && BYTES_BIG_ENDIAN)
    3938                 :             :     byte_pos = trailing_bytes;
    3939                 :    43865584 :   else if (!WORDS_BIG_ENDIAN && !BYTES_BIG_ENDIAN)
    3940                 :    43865584 :     byte_pos = subreg_byte;
    3941                 :             :   else
    3942                 :             :     {
    3943                 :             :       /* When bytes and words have opposite endianness, we must be able
    3944                 :             :          to split offsets into words and bytes at compile time.  */
    3945                 :             :       poly_uint64 leading_word_part
    3946                 :             :         = force_align_down (subreg_byte, UNITS_PER_WORD);
    3947                 :             :       poly_uint64 trailing_word_part
    3948                 :             :         = force_align_down (trailing_bytes, UNITS_PER_WORD);
    3949                 :             :       /* If the subreg crosses a word boundary ensure that
    3950                 :             :          it also begins and ends on a word boundary.  */
    3951                 :             :       gcc_assert (known_le (subreg_end - leading_word_part,
    3952                 :             :                             (unsigned int) UNITS_PER_WORD)
    3953                 :             :                   || (known_eq (leading_word_part, subreg_byte)
    3954                 :             :                       && known_eq (trailing_word_part, trailing_bytes)));
    3955                 :             :       if (WORDS_BIG_ENDIAN)
    3956                 :             :         byte_pos = trailing_word_part + (subreg_byte - leading_word_part);
    3957                 :             :       else
    3958                 :             :         byte_pos = leading_word_part + (trailing_bytes - trailing_word_part);
    3959                 :             :     }
    3960                 :             : 
    3961                 :    43865584 :   return byte_pos * BITS_PER_UNIT;
    3962                 :             : }
    3963                 :             : 
    3964                 :             : /* Given a subreg X, return the bit offset where the subreg begins
    3965                 :             :    (counting from the least significant bit of the reg).  */
    3966                 :             : 
    3967                 :             : poly_uint64
    3968                 :     3020981 : subreg_lsb (const_rtx x)
    3969                 :             : {
    3970                 :     6041962 :   return subreg_lsb_1 (GET_MODE (x), GET_MODE (SUBREG_REG (x)),
    3971                 :     3020981 :                        SUBREG_BYTE (x));
    3972                 :             : }
    3973                 :             : 
    3974                 :             : /* Return the subreg byte offset for a subreg whose outer value has
    3975                 :             :    OUTER_BYTES bytes, whose inner value has INNER_BYTES bytes, and where
    3976                 :             :    there are LSB_SHIFT *bits* between the lsb of the outer value and the
    3977                 :             :    lsb of the inner value.  This is the inverse of the calculation
    3978                 :             :    performed by subreg_lsb_1 (which converts byte offsets to bit shifts).  */
    3979                 :             : 
    3980                 :             : poly_uint64
    3981                 :    37863256 : subreg_size_offset_from_lsb (poly_uint64 outer_bytes, poly_uint64 inner_bytes,
    3982                 :             :                              poly_uint64 lsb_shift)
    3983                 :             : {
    3984                 :             :   /* A paradoxical subreg begins at bit position 0.  */
    3985                 :    37863256 :   gcc_checking_assert (ordered_p (outer_bytes, inner_bytes));
    3986                 :    37863256 :   if (maybe_gt (outer_bytes, inner_bytes))
    3987                 :             :     {
    3988                 :           0 :       gcc_checking_assert (known_eq (lsb_shift, 0U));
    3989                 :           0 :       return 0;
    3990                 :             :     }
    3991                 :             : 
    3992                 :    37863256 :   poly_uint64 lower_bytes = exact_div (lsb_shift, BITS_PER_UNIT);
    3993                 :    37863256 :   poly_uint64 upper_bytes = inner_bytes - (lower_bytes + outer_bytes);
    3994                 :    37863256 :   if (WORDS_BIG_ENDIAN && BYTES_BIG_ENDIAN)
    3995                 :             :     return upper_bytes;
    3996                 :    37863256 :   else if (!WORDS_BIG_ENDIAN && !BYTES_BIG_ENDIAN)
    3997                 :    37863256 :     return lower_bytes;
    3998                 :             :   else
    3999                 :             :     {
    4000                 :             :       /* When bytes and words have opposite endianness, we must be able
    4001                 :             :          to split offsets into words and bytes at compile time.  */
    4002                 :             :       poly_uint64 lower_word_part = force_align_down (lower_bytes,
    4003                 :             :                                                       UNITS_PER_WORD);
    4004                 :             :       poly_uint64 upper_word_part = force_align_down (upper_bytes,
    4005                 :             :                                                       UNITS_PER_WORD);
    4006                 :             :       if (WORDS_BIG_ENDIAN)
    4007                 :             :         return upper_word_part + (lower_bytes - lower_word_part);
    4008                 :             :       else
    4009                 :             :         return lower_word_part + (upper_bytes - upper_word_part);
    4010                 :             :     }
    4011                 :             : }
    4012                 :             : 
    4013                 :             : /* Fill in information about a subreg of a hard register.
    4014                 :             :    xregno - A regno of an inner hard subreg_reg (or what will become one).
    4015                 :             :    xmode  - The mode of xregno.
    4016                 :             :    offset - The byte offset.
    4017                 :             :    ymode  - The mode of a top level SUBREG (or what may become one).
    4018                 :             :    info   - Pointer to structure to fill in.
    4019                 :             : 
    4020                 :             :    Rather than considering one particular inner register (and thus one
    4021                 :             :    particular "outer" register) in isolation, this function really uses
    4022                 :             :    XREGNO as a model for a sequence of isomorphic hard registers.  Thus the
    4023                 :             :    function does not check whether adding INFO->offset to XREGNO gives
    4024                 :             :    a valid hard register; even if INFO->offset + XREGNO is out of range,
    4025                 :             :    there might be another register of the same type that is in range.
    4026                 :             :    Likewise it doesn't check whether targetm.hard_regno_mode_ok accepts
    4027                 :             :    the new register, since that can depend on things like whether the final
    4028                 :             :    register number is even or odd.  Callers that want to check whether
    4029                 :             :    this particular subreg can be replaced by a simple (reg ...) should
    4030                 :             :    use simplify_subreg_regno.  */
    4031                 :             : 
    4032                 :             : void
    4033                 :    31151510 : subreg_get_info (unsigned int xregno, machine_mode xmode,
    4034                 :             :                  poly_uint64 offset, machine_mode ymode,
    4035                 :             :                  struct subreg_info *info)
    4036                 :             : {
    4037                 :    31151510 :   unsigned int nregs_xmode, nregs_ymode;
    4038                 :             : 
    4039                 :    31151510 :   gcc_assert (xregno < FIRST_PSEUDO_REGISTER);
    4040                 :             : 
    4041                 :    62303020 :   poly_uint64 xsize = GET_MODE_SIZE (xmode);
    4042                 :    62303020 :   poly_uint64 ysize = GET_MODE_SIZE (ymode);
    4043                 :             : 
    4044                 :    31151510 :   bool rknown = false;
    4045                 :             : 
    4046                 :             :   /* If the register representation of a non-scalar mode has holes in it,
    4047                 :             :      we expect the scalar units to be concatenated together, with the holes
    4048                 :             :      distributed evenly among the scalar units.  Each scalar unit must occupy
    4049                 :             :      at least one register.  */
    4050                 :    31151510 :   if (HARD_REGNO_NREGS_HAS_PADDING (xregno, xmode))
    4051                 :             :     {
    4052                 :             :       /* As a consequence, we must be dealing with a constant number of
    4053                 :             :          scalars, and thus a constant offset and number of units.  */
    4054                 :           0 :       HOST_WIDE_INT coffset = offset.to_constant ();
    4055                 :           0 :       HOST_WIDE_INT cysize = ysize.to_constant ();
    4056                 :           0 :       nregs_xmode = HARD_REGNO_NREGS_WITH_PADDING (xregno, xmode);
    4057                 :           0 :       unsigned int nunits = GET_MODE_NUNITS (xmode).to_constant ();
    4058                 :           0 :       scalar_mode xmode_unit = GET_MODE_INNER (xmode);
    4059                 :           0 :       gcc_assert (HARD_REGNO_NREGS_HAS_PADDING (xregno, xmode_unit));
    4060                 :           0 :       gcc_assert (nregs_xmode
    4061                 :             :                   == (nunits
    4062                 :             :                       * HARD_REGNO_NREGS_WITH_PADDING (xregno, xmode_unit)));
    4063                 :           0 :       gcc_assert (hard_regno_nregs (xregno, xmode)
    4064                 :             :                   == hard_regno_nregs (xregno, xmode_unit) * nunits);
    4065                 :             : 
    4066                 :             :       /* You can only ask for a SUBREG of a value with holes in the middle
    4067                 :             :          if you don't cross the holes.  (Such a SUBREG should be done by
    4068                 :             :          picking a different register class, or doing it in memory if
    4069                 :             :          necessary.)  An example of a value with holes is XCmode on 32-bit
    4070                 :             :          x86 with -m128bit-long-double; it's represented in 6 32-bit registers,
    4071                 :             :          3 for each part, but in memory it's two 128-bit parts.
    4072                 :             :          Padding is assumed to be at the end (not necessarily the 'high part')
    4073                 :             :          of each unit.  */
    4074                 :           0 :       if ((coffset / GET_MODE_SIZE (xmode_unit) + 1 < nunits)
    4075                 :           0 :           && (coffset / GET_MODE_SIZE (xmode_unit)
    4076                 :           0 :               != ((coffset + cysize - 1) / GET_MODE_SIZE (xmode_unit))))
    4077                 :             :         {
    4078                 :           0 :           info->representable_p = false;
    4079                 :           0 :           rknown = true;
    4080                 :             :         }
    4081                 :             :     }
    4082                 :             :   else
    4083                 :    31151510 :     nregs_xmode = hard_regno_nregs (xregno, xmode);
    4084                 :             : 
    4085                 :    31151510 :   nregs_ymode = hard_regno_nregs (xregno, ymode);
    4086                 :             : 
    4087                 :             :   /* Subreg sizes must be ordered, so that we can tell whether they are
    4088                 :             :      partial, paradoxical or complete.  */
    4089                 :    31151510 :   gcc_checking_assert (ordered_p (xsize, ysize));
    4090                 :             : 
    4091                 :             :   /* Paradoxical subregs are otherwise valid.  */
    4092                 :    31151510 :   if (!rknown && known_eq (offset, 0U) && maybe_gt (ysize, xsize))
    4093                 :             :     {
    4094                 :    11108384 :       info->representable_p = true;
    4095                 :             :       /* If this is a big endian paradoxical subreg, which uses more
    4096                 :             :          actual hard registers than the original register, we must
    4097                 :             :          return a negative offset so that we find the proper highpart
    4098                 :             :          of the register.
    4099                 :             : 
    4100                 :             :          We assume that the ordering of registers within a multi-register
    4101                 :             :          value has a consistent endianness: if bytes and register words
    4102                 :             :          have different endianness, the hard registers that make up a
    4103                 :             :          multi-register value must be at least word-sized.  */
    4104                 :    11108384 :       if (REG_WORDS_BIG_ENDIAN)
    4105                 :             :         info->offset = (int) nregs_xmode - (int) nregs_ymode;
    4106                 :             :       else
    4107                 :    11108384 :         info->offset = 0;
    4108                 :    11108384 :       info->nregs = nregs_ymode;
    4109                 :    11108384 :       return;
    4110                 :             :     }
    4111                 :             : 
    4112                 :             :   /* If registers store different numbers of bits in the different
    4113                 :             :      modes, we cannot generally form this subreg.  */
    4114                 :    20043126 :   poly_uint64 regsize_xmode, regsize_ymode;
    4115                 :    17219995 :   if (!HARD_REGNO_NREGS_HAS_PADDING (xregno, xmode)
    4116                 :           0 :       && !HARD_REGNO_NREGS_HAS_PADDING (xregno, ymode)
    4117                 :    20043126 :       && multiple_p (xsize, nregs_xmode, &regsize_xmode)
    4118                 :    20043126 :       && multiple_p (ysize, nregs_ymode, &regsize_ymode))
    4119                 :             :     {
    4120                 :    20043126 :       if (!rknown
    4121                 :    20043126 :           && ((nregs_ymode > 1 && maybe_gt (regsize_xmode, regsize_ymode))
    4122                 :    20043114 :               || (nregs_xmode > 1 && maybe_gt (regsize_ymode, regsize_xmode))))
    4123                 :             :         {
    4124                 :         119 :           info->representable_p = false;
    4125                 :         119 :           if (!can_div_away_from_zero_p (ysize, regsize_xmode, &info->nregs)
    4126                 :         119 :               || !can_div_trunc_p (offset, regsize_xmode, &info->offset))
    4127                 :             :             /* Checked by validate_subreg.  We must know at compile time
    4128                 :             :                which inner registers are being accessed.  */
    4129                 :             :             gcc_unreachable ();
    4130                 :    30690619 :           return;
    4131                 :             :         }
    4132                 :             :       /* It's not valid to extract a subreg of mode YMODE at OFFSET that
    4133                 :             :          would go outside of XMODE.  */
    4134                 :    20043007 :       if (!rknown && maybe_gt (ysize + offset, xsize))
    4135                 :             :         {
    4136                 :           0 :           info->representable_p = false;
    4137                 :           0 :           info->nregs = nregs_ymode;
    4138                 :           0 :           if (!can_div_trunc_p (offset, regsize_xmode, &info->offset))
    4139                 :             :             /* Checked by validate_subreg.  We must know at compile time
    4140                 :             :                which inner registers are being accessed.  */
    4141                 :             :             gcc_unreachable ();
    4142                 :           0 :           return;
    4143                 :             :         }
    4144                 :             :       /* Quick exit for the simple and common case of extracting whole
    4145                 :             :          subregisters from a multiregister value.  */
    4146                 :             :       /* ??? It would be better to integrate this into the code below,
    4147                 :             :          if we can generalize the concept enough and figure out how
    4148                 :             :          odd-sized modes can coexist with the other weird cases we support.  */
    4149                 :    20043007 :       HOST_WIDE_INT count;
    4150                 :    20043007 :       if (!rknown
    4151                 :             :           && WORDS_BIG_ENDIAN == REG_WORDS_BIG_ENDIAN
    4152                 :    20043007 :           && known_eq (regsize_xmode, regsize_ymode)
    4153                 :    20043007 :           && constant_multiple_p (offset, regsize_ymode, &count))
    4154                 :             :         {
    4155                 :    12379156 :           info->representable_p = true;
    4156                 :    12379156 :           info->nregs = nregs_ymode;
    4157                 :    12379156 :           info->offset = count;
    4158                 :    12379156 :           gcc_assert (info->offset + info->nregs <= (int) nregs_xmode);
    4159                 :             :           return;
    4160                 :             :         }
    4161                 :             :     }
    4162                 :             : 
    4163                 :             :   /* Lowpart subregs are otherwise valid.  */
    4164                 :     7663851 :   if (!rknown && known_eq (offset, subreg_lowpart_offset (ymode, xmode)))
    4165                 :             :     {
    4166                 :     7202960 :       info->representable_p = true;
    4167                 :     7202960 :       rknown = true;
    4168                 :             : 
    4169                 :     7202960 :       if (known_eq (offset, 0U) || nregs_xmode == nregs_ymode)
    4170                 :             :         {
    4171                 :     7202960 :           info->offset = 0;
    4172                 :     7202960 :           info->nregs = nregs_ymode;
    4173                 :     7202960 :           return;
    4174                 :             :         }
    4175                 :             :     }
    4176                 :             : 
    4177                 :             :   /* Set NUM_BLOCKS to the number of independently-representable YMODE
    4178                 :             :      values there are in (reg:XMODE XREGNO).  We can view the register
    4179                 :             :      as consisting of this number of independent "blocks", where each
    4180                 :             :      block occupies NREGS_YMODE registers and contains exactly one
    4181                 :             :      representable YMODE value.  */
    4182                 :      460891 :   gcc_assert ((nregs_xmode % nregs_ymode) == 0);
    4183                 :      460891 :   unsigned int num_blocks = nregs_xmode / nregs_ymode;
    4184                 :             : 
    4185                 :             :   /* Calculate the number of bytes in each block.  This must always
    4186                 :             :      be exact, otherwise we don't know how to verify the constraint.
    4187                 :             :      These conditions may be relaxed but subreg_regno_offset would
    4188                 :             :      need to be redesigned.  */
    4189                 :      460891 :   poly_uint64 bytes_per_block = exact_div (xsize, num_blocks);
    4190                 :             : 
    4191                 :             :   /* Get the number of the first block that contains the subreg and the byte
    4192                 :             :      offset of the subreg from the start of that block.  */
    4193                 :      460891 :   unsigned int block_number;
    4194                 :      460891 :   poly_uint64 subblock_offset;
    4195                 :      460891 :   if (!can_div_trunc_p (offset, bytes_per_block, &block_number,
    4196                 :             :                         &subblock_offset))
    4197                 :             :     /* Checked by validate_subreg.  We must know at compile time which
    4198                 :             :        inner registers are being accessed.  */
    4199                 :             :     gcc_unreachable ();
    4200                 :             : 
    4201                 :      460891 :   if (!rknown)
    4202                 :             :     {
    4203                 :             :       /* Only the lowpart of each block is representable.  */
    4204                 :      460891 :       info->representable_p
    4205                 :      460891 :         = known_eq (subblock_offset,
    4206                 :             :                     subreg_size_lowpart_offset (ysize, bytes_per_block));
    4207                 :      460891 :       rknown = true;
    4208                 :             :     }
    4209                 :             : 
    4210                 :             :   /* We assume that the ordering of registers within a multi-register
    4211                 :             :      value has a consistent endianness: if bytes and register words
    4212                 :             :      have different endianness, the hard registers that make up a
    4213                 :             :      multi-register value must be at least word-sized.  */
    4214                 :      460891 :   if (WORDS_BIG_ENDIAN != REG_WORDS_BIG_ENDIAN)
    4215                 :             :     /* The block number we calculated above followed memory endianness.
    4216                 :             :        Convert it to register endianness by counting back from the end.
    4217                 :             :        (Note that, because of the assumption above, each block must be
    4218                 :             :        at least word-sized.)  */
    4219                 :             :     info->offset = (num_blocks - block_number - 1) * nregs_ymode;
    4220                 :             :   else
    4221                 :      460891 :     info->offset = block_number * nregs_ymode;
    4222                 :      460891 :   info->nregs = nregs_ymode;
    4223                 :             : }
    4224                 :             : 
    4225                 :             : /* This function returns the regno offset of a subreg expression.
    4226                 :             :    xregno - A regno of an inner hard subreg_reg (or what will become one).
    4227                 :             :    xmode  - The mode of xregno.
    4228                 :             :    offset - The byte offset.
    4229                 :             :    ymode  - The mode of a top level SUBREG (or what may become one).
    4230                 :             :    RETURN - The regno offset which would be used.  */
    4231                 :             : unsigned int
    4232                 :     5328944 : subreg_regno_offset (unsigned int xregno, machine_mode xmode,
    4233                 :             :                      poly_uint64 offset, machine_mode ymode)
    4234                 :             : {
    4235                 :     5328944 :   struct subreg_info info;
    4236                 :     5328944 :   subreg_get_info (xregno, xmode, offset, ymode, &info);
    4237                 :     5328944 :   return info.offset;
    4238                 :             : }
    4239                 :             : 
    4240                 :             : /* This function returns true when the offset is representable via
    4241                 :             :    subreg_offset in the given regno.
    4242                 :             :    xregno - A regno of an inner hard subreg_reg (or what will become one).
    4243                 :             :    xmode  - The mode of xregno.
    4244                 :             :    offset - The byte offset.
    4245                 :             :    ymode  - The mode of a top level SUBREG (or what may become one).
    4246                 :             :    RETURN - Whether the offset is representable.  */
    4247                 :             : bool
    4248                 :      334883 : subreg_offset_representable_p (unsigned int xregno, machine_mode xmode,
    4249                 :             :                                poly_uint64 offset, machine_mode ymode)
    4250                 :             : {
    4251                 :      334883 :   struct subreg_info info;
    4252                 :      334883 :   subreg_get_info (xregno, xmode, offset, ymode, &info);
    4253                 :      334883 :   return info.representable_p;
    4254                 :             : }
    4255                 :             : 
    4256                 :             : /* Return the number of a YMODE register to which
    4257                 :             : 
    4258                 :             :        (subreg:YMODE (reg:XMODE XREGNO) OFFSET)
    4259                 :             : 
    4260                 :             :    can be simplified.  Return -1 if the subreg can't be simplified.
    4261                 :             : 
    4262                 :             :    XREGNO is a hard register number.  */
    4263                 :             : 
    4264                 :             : int
    4265                 :    26386157 : simplify_subreg_regno (unsigned int xregno, machine_mode xmode,
    4266                 :             :                        poly_uint64 offset, machine_mode ymode)
    4267                 :             : {
    4268                 :    26386157 :   struct subreg_info info;
    4269                 :    26386157 :   unsigned int yregno;
    4270                 :             : 
    4271                 :             :   /* Give the backend a chance to disallow the mode change.  */
    4272                 :    26386157 :   if (GET_MODE_CLASS (xmode) != MODE_COMPLEX_INT
    4273                 :    26386157 :       && GET_MODE_CLASS (xmode) != MODE_COMPLEX_FLOAT
    4274                 :    26386157 :       && !REG_CAN_CHANGE_MODE_P (xregno, xmode, ymode))
    4275                 :             :     return -1;
    4276                 :             : 
    4277                 :             :   /* We shouldn't simplify stack-related registers.  */
    4278                 :    25628199 :   if ((!reload_completed || frame_pointer_needed)
    4279                 :    22322082 :       && xregno == FRAME_POINTER_REGNUM)
    4280                 :             :     return -1;
    4281                 :             : 
    4282                 :    25519087 :   if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
    4283                 :             :       && xregno == ARG_POINTER_REGNUM)
    4284                 :             :     return -1;
    4285                 :             : 
    4286                 :    25414249 :   if (xregno == STACK_POINTER_REGNUM
    4287                 :             :       /* We should convert hard stack register in LRA if it is
    4288                 :             :          possible.  */
    4289                 :      105641 :       && ! lra_in_progress)
    4290                 :             :     return -1;
    4291                 :             : 
    4292                 :             :   /* Try to get the register offset.  */
    4293                 :    25310090 :   subreg_get_info (xregno, xmode, offset, ymode, &info);
    4294                 :    25310090 :   if (!info.representable_p)
    4295                 :             :     return -1;
    4296                 :             : 
    4297                 :             :   /* Make sure that the offsetted register value is in range.  */
    4298                 :    25077105 :   yregno = xregno + info.offset;
    4299                 :    25077105 :   if (!HARD_REGISTER_NUM_P (yregno))
    4300                 :             :     return -1;
    4301                 :             : 
    4302                 :             :   /* See whether (reg:YMODE YREGNO) is valid.
    4303                 :             : 
    4304                 :             :      ??? We allow invalid registers if (reg:XMODE XREGNO) is also invalid.
    4305                 :             :      This is a kludge to work around how complex FP arguments are passed
    4306                 :             :      on IA-64 and should be fixed.  See PR target/49226.  */
    4307                 :    25065507 :   if (!targetm.hard_regno_mode_ok (yregno, ymode)
    4308                 :    25065507 :       && targetm.hard_regno_mode_ok (xregno, xmode))
    4309                 :             :     return -1;
    4310                 :             : 
    4311                 :    24863260 :   return (int) yregno;
    4312                 :             : }
    4313                 :             : 
    4314                 :             : /* A wrapper around simplify_subreg_regno that uses subreg_lowpart_offset
    4315                 :             :    (xmode, ymode) as the offset.  */
    4316                 :             : 
    4317                 :             : int
    4318                 :           0 : lowpart_subreg_regno (unsigned int regno, machine_mode xmode,
    4319                 :             :                       machine_mode ymode)
    4320                 :             : {
    4321                 :           0 :   poly_uint64 offset = subreg_lowpart_offset (xmode, ymode);
    4322                 :           0 :   return simplify_subreg_regno (regno, xmode, offset, ymode);
    4323                 :             : }
    4324                 :             : 
    4325                 :             : /* Return the final regno that a subreg expression refers to.  */
    4326                 :             : unsigned int
    4327                 :       14624 : subreg_regno (const_rtx x)
    4328                 :             : {
    4329                 :       14624 :   unsigned int ret;
    4330                 :       14624 :   rtx subreg = SUBREG_REG (x);
    4331                 :       14624 :   int regno = REGNO (subreg);
    4332                 :             : 
    4333                 :       29248 :   ret = regno + subreg_regno_offset (regno,
    4334                 :       14624 :                                      GET_MODE (subreg),
    4335                 :       14624 :                                      SUBREG_BYTE (x),
    4336                 :       14624 :                                      GET_MODE (x));
    4337                 :       14624 :   return ret;
    4338                 :             : 
    4339                 :             : }
    4340                 :             : 
    4341                 :             : /* Return the number of registers that a subreg expression refers
    4342                 :             :    to.  */
    4343                 :             : unsigned int
    4344                 :      171042 : subreg_nregs (const_rtx x)
    4345                 :             : {
    4346                 :      171042 :   return subreg_nregs_with_regno (REGNO (SUBREG_REG (x)), x);
    4347                 :             : }
    4348                 :             : 
    4349                 :             : /* Return the number of registers that a subreg REG with REGNO
    4350                 :             :    expression refers to.  This is a copy of the rtlanal.cc:subreg_nregs
    4351                 :             :    changed so that the regno can be passed in. */
    4352                 :             : 
    4353                 :             : unsigned int
    4354                 :      171042 : subreg_nregs_with_regno (unsigned int regno, const_rtx x)
    4355                 :             : {
    4356                 :      171042 :   struct subreg_info info;
    4357                 :      171042 :   rtx subreg = SUBREG_REG (x);
    4358                 :             : 
    4359                 :      171042 :   subreg_get_info (regno, GET_MODE (subreg), SUBREG_BYTE (x), GET_MODE (x),
    4360                 :             :                    &info);
    4361                 :      171042 :   return info.nregs;
    4362                 :             : }
    4363                 :             : 
    4364                 :             : struct parms_set_data
    4365                 :             : {
    4366                 :             :   int nregs;
    4367                 :             :   HARD_REG_SET regs;
    4368                 :             : };
    4369                 :             : 
    4370                 :             : /* Helper function for noticing stores to parameter registers.  */
    4371                 :             : static void
    4372                 :       56015 : parms_set (rtx x, const_rtx pat ATTRIBUTE_UNUSED, void *data)
    4373                 :             : {
    4374                 :       56015 :   struct parms_set_data *const d = (struct parms_set_data *) data;
    4375                 :       56013 :   if (REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER
    4376                 :      112027 :       && TEST_HARD_REG_BIT (d->regs, REGNO (x)))
    4377                 :             :     {
    4378                 :       55689 :       CLEAR_HARD_REG_BIT (d->regs, REGNO (x));
    4379                 :       55689 :       d->nregs--;
    4380                 :             :     }
    4381                 :       56015 : }
    4382                 :             : 
    4383                 :             : /* Look backward for first parameter to be loaded.
    4384                 :             :    Note that loads of all parameters will not necessarily be
    4385                 :             :    found if CSE has eliminated some of them (e.g., an argument
    4386                 :             :    to the outer function is passed down as a parameter).
    4387                 :             :    Do not skip BOUNDARY.  */
    4388                 :             : rtx_insn *
    4389                 :       37517 : find_first_parameter_load (rtx_insn *call_insn, rtx_insn *boundary)
    4390                 :             : {
    4391                 :       37517 :   struct parms_set_data parm;
    4392                 :       37517 :   rtx p;
    4393                 :       37517 :   rtx_insn *before, *first_set;
    4394                 :             : 
    4395                 :             :   /* Since different machines initialize their parameter registers
    4396                 :             :      in different orders, assume nothing.  Collect the set of all
    4397                 :             :      parameter registers.  */
    4398                 :       37517 :   CLEAR_HARD_REG_SET (parm.regs);
    4399                 :       37517 :   parm.nregs = 0;
    4400                 :       95694 :   for (p = CALL_INSN_FUNCTION_USAGE (call_insn); p; p = XEXP (p, 1))
    4401                 :       58177 :     if (GET_CODE (XEXP (p, 0)) == USE
    4402                 :       57978 :         && REG_P (XEXP (XEXP (p, 0), 0))
    4403                 :      116155 :         && !STATIC_CHAIN_REG_P (XEXP (XEXP (p, 0), 0)))
    4404                 :             :       {
    4405                 :       57716 :         gcc_assert (REGNO (XEXP (XEXP (p, 0), 0)) < FIRST_PSEUDO_REGISTER);
    4406                 :             : 
    4407                 :             :         /* We only care about registers which can hold function
    4408                 :             :            arguments.  */
    4409                 :       57716 :         if (!FUNCTION_ARG_REGNO_P (REGNO (XEXP (XEXP (p, 0), 0))))
    4410                 :        1675 :           continue;
    4411                 :             : 
    4412                 :       56041 :         SET_HARD_REG_BIT (parm.regs, REGNO (XEXP (XEXP (p, 0), 0)));
    4413                 :       56041 :         parm.nregs++;
    4414                 :             :       }
    4415                 :             :   before = call_insn;
    4416                 :             :   first_set = call_insn;
    4417                 :             : 
    4418                 :             :   /* Search backward for the first set of a register in this set.  */
    4419                 :       93206 :   while (parm.nregs && before != boundary)
    4420                 :             :     {
    4421                 :       56015 :       before = PREV_INSN (before);
    4422                 :             : 
    4423                 :             :       /* It is possible that some loads got CSEed from one call to
    4424                 :             :          another.  Stop in that case.  */
    4425                 :       56015 :       if (CALL_P (before))
    4426                 :             :         break;
    4427                 :             : 
    4428                 :             :       /* Our caller needs either ensure that we will find all sets
    4429                 :             :          (in case code has not been optimized yet), or take care
    4430                 :             :          for possible labels in a way by setting boundary to preceding
    4431                 :             :          CODE_LABEL.  */
    4432                 :       56015 :       if (LABEL_P (before))
    4433                 :             :         {
    4434                 :           0 :           gcc_assert (before == boundary);
    4435                 :             :           break;
    4436                 :             :         }
    4437                 :             : 
    4438                 :       56015 :       if (INSN_P (before))
    4439                 :             :         {
    4440                 :       56015 :           int nregs_old = parm.nregs;
    4441                 :       56015 :           note_stores (before, parms_set, &parm);
    4442                 :             :           /* If we found something that did not set a parameter reg,
    4443                 :             :              we're done.  Do not keep going, as that might result
    4444                 :             :              in hoisting an insn before the setting of a pseudo
    4445                 :             :              that is used by the hoisted insn. */
    4446                 :       56015 :           if (nregs_old != parm.nregs)
    4447                 :             :             first_set = before;
    4448                 :             :           else
    4449                 :             :             break;
    4450                 :             :         }
    4451                 :             :     }
    4452                 :       37517 :   return first_set;
    4453                 :             : }
    4454                 :             : 
    4455                 :             : /* Return true if we should avoid inserting code between INSN and preceding
    4456                 :             :    call instruction.  */
    4457                 :             : 
    4458                 :             : bool
    4459                 :    10277630 : keep_with_call_p (const rtx_insn *insn)
    4460                 :             : {
    4461                 :    10277630 :   rtx set;
    4462                 :             : 
    4463                 :    10277630 :   if (INSN_P (insn) && (set = single_set (insn)) != NULL)
    4464                 :             :     {
    4465                 :     6901066 :       if (REG_P (SET_DEST (set))
    4466                 :     1858191 :           && REGNO (SET_DEST (set)) < FIRST_PSEUDO_REGISTER
    4467                 :     1858191 :           && fixed_regs[REGNO (SET_DEST (set))]
    4468                 :     7063753 :           && general_operand (SET_SRC (set), VOIDmode))
    4469                 :             :         return true;
    4470                 :     6900722 :       if (REG_P (SET_SRC (set))
    4471                 :      687943 :           && targetm.calls.function_value_regno_p (REGNO (SET_SRC (set)))
    4472                 :      458883 :           && REG_P (SET_DEST (set))
    4473                 :     7047576 :           && REGNO (SET_DEST (set)) >= FIRST_PSEUDO_REGISTER)
    4474                 :             :         return true;
    4475                 :             :       /* There may be a stack pop just after the call and before the store
    4476                 :             :          of the return register.  Search for the actual store when deciding
    4477                 :             :          if we can break or not.  */
    4478                 :     6900722 :       if (SET_DEST (set) == stack_pointer_rtx)
    4479                 :             :         {
    4480                 :             :           /* This CONST_CAST is okay because next_nonnote_insn just
    4481                 :             :              returns its argument and we assign it to a const_rtx
    4482                 :             :              variable.  */
    4483                 :      161265 :           const rtx_insn *i2
    4484                 :      161265 :             = next_nonnote_insn (const_cast<rtx_insn *> (insn));
    4485                 :      161265 :           if (i2 && keep_with_call_p (i2))
    4486                 :             :             return true;
    4487                 :             :         }
    4488                 :             :     }
    4489                 :             :   return false;
    4490                 :             : }
    4491                 :             : 
    4492                 :             : /* Return true if LABEL is a target of JUMP_INSN.  This applies only
    4493                 :             :    to non-complex jumps.  That is, direct unconditional, conditional,
    4494                 :             :    and tablejumps, but not computed jumps or returns.  It also does
    4495                 :             :    not apply to the fallthru case of a conditional jump.  */
    4496                 :             : 
    4497                 :             : bool
    4498                 :    22532316 : label_is_jump_target_p (const_rtx label, const rtx_insn *jump_insn)
    4499                 :             : {
    4500                 :    22532316 :   rtx tmp = JUMP_LABEL (jump_insn);
    4501                 :    22532316 :   rtx_jump_table_data *table;
    4502                 :             : 
    4503                 :    22532316 :   if (label == tmp)
    4504                 :             :     return true;
    4505                 :             : 
    4506                 :     4013474 :   if (tablejump_p (jump_insn, NULL, &table))
    4507                 :             :     {
    4508                 :           0 :       rtvec vec = table->get_labels ();
    4509                 :           0 :       int i, veclen = GET_NUM_ELEM (vec);
    4510                 :             : 
    4511                 :           0 :       for (i = 0; i < veclen; ++i)
    4512                 :           0 :         if (XEXP (RTVEC_ELT (vec, i), 0) == label)
    4513                 :             :           return true;
    4514                 :             :     }
    4515                 :             : 
    4516                 :     4013474 :   if (find_reg_note (jump_insn, REG_LABEL_TARGET, label))
    4517                 :             :     return true;
    4518                 :             : 
    4519                 :             :   return false;
    4520                 :             : }
    4521                 :             : 
    4522                 :             : 
    4523                 :             : /* Return an estimate of the cost of computing rtx X.
    4524                 :             :    One use is in cse, to decide which expression to keep in the hash table.
    4525                 :             :    Another is in rtl generation, to pick the cheapest way to multiply.
    4526                 :             :    Other uses like the latter are expected in the future.
    4527                 :             : 
    4528                 :             :    X appears as operand OPNO in an expression with code OUTER_CODE.
    4529                 :             :    SPEED specifies whether costs optimized for speed or size should
    4530                 :             :    be returned.  */
    4531                 :             : 
    4532                 :             : int
    4533                 : 12380771880 : rtx_cost (rtx x, machine_mode mode, enum rtx_code outer_code,
    4534                 :             :           int opno, bool speed)
    4535                 :             : {
    4536                 : 12380771880 :   int i, j;
    4537                 : 12380771880 :   enum rtx_code code;
    4538                 : 12380771880 :   const char *fmt;
    4539                 : 12380771880 :   int total;
    4540                 : 12380771880 :   int factor;
    4541                 : 12380771880 :   unsigned mode_size;
    4542                 :             : 
    4543                 : 12380771880 :   if (x == 0)
    4544                 :             :     return 0;
    4545                 :             : 
    4546                 : 12380771880 :   if (GET_CODE (x) == SET)
    4547                 :             :     /* A SET doesn't have a mode, so let's look at the SET_DEST to get
    4548                 :             :        the mode for the factor.  */
    4549                 :    48335472 :     mode = GET_MODE (SET_DEST (x));
    4550                 : 12332436408 :   else if (GET_MODE (x) != VOIDmode)
    4551                 :  9518285721 :     mode = GET_MODE (x);
    4552                 :             : 
    4553                 : 24761543760 :   mode_size = estimated_poly_value (GET_MODE_SIZE (mode));
    4554                 :             : 
    4555                 :             :   /* A size N times larger than UNITS_PER_WORD likely needs N times as
    4556                 :             :      many insns, taking N times as long.  */
    4557                 : 12884451874 :   factor = mode_size > UNITS_PER_WORD ? mode_size / UNITS_PER_WORD : 1;
    4558                 :             : 
    4559                 :             :   /* Compute the default costs of certain things.
    4560                 :             :      Note that targetm.rtx_costs can override the defaults.  */
    4561                 :             : 
    4562                 : 12380771880 :   code = GET_CODE (x);
    4563                 : 12380771880 :   switch (code)
    4564                 :             :     {
    4565                 :  1741851790 :     case MULT:
    4566                 :  1741851790 :     case FMA:
    4567                 :  1741851790 :     case SS_MULT:
    4568                 :  1741851790 :     case US_MULT:
    4569                 :  1741851790 :     case SMUL_HIGHPART:
    4570                 :  1741851790 :     case UMUL_HIGHPART:
    4571                 :             :       /* Multiplication has time-complexity O(N*N), where N is the
    4572                 :             :          number of units (translated from digits) when using
    4573                 :             :          schoolbook long multiplication.  */
    4574                 :  1741851790 :       total = factor * factor * COSTS_N_INSNS (5);
    4575                 :  1741851790 :       break;
    4576                 :    71717412 :     case DIV:
    4577                 :    71717412 :     case UDIV:
    4578                 :    71717412 :     case MOD:
    4579                 :    71717412 :     case UMOD:
    4580                 :    71717412 :     case SS_DIV:
    4581                 :    71717412 :     case US_DIV:
    4582                 :             :       /* Similarly, complexity for schoolbook long division.  */
    4583                 :    71717412 :       total = factor * factor * COSTS_N_INSNS (7);
    4584                 :    71717412 :       break;
    4585                 :           0 :     case USE:
    4586                 :             :       /* Used in combine.cc as a marker.  */
    4587                 :           0 :       total = 0;
    4588                 :           0 :       break;
    4589                 : 10567202678 :     default:
    4590                 : 10567202678 :       total = factor * COSTS_N_INSNS (1);
    4591                 :             :     }
    4592                 :             : 
    4593                 : 12380771880 :   switch (code)
    4594                 :             :     {
    4595                 :             :     case REG:
    4596                 :             :       return 0;
    4597                 :             : 
    4598                 :    10926643 :     case SUBREG:
    4599                 :    10926643 :       total = 0;
    4600                 :             :       /* If we can't tie these modes, make this expensive.  The larger
    4601                 :             :          the mode, the more expensive it is.  */
    4602                 :    10926643 :       if (!targetm.modes_tieable_p (mode, GET_MODE (SUBREG_REG (x))))
    4603                 :     4203234 :         return COSTS_N_INSNS (2 + factor);
    4604                 :             :       break;
    4605                 :             : 
    4606                 :    16733340 :     case TRUNCATE:
    4607                 :    16733340 :       if (targetm.modes_tieable_p (mode, GET_MODE (XEXP (x, 0))))
    4608                 :             :         {
    4609                 :     3721668 :           total = 0;
    4610                 :     3721668 :           break;
    4611                 :             :         }
    4612                 :             :       /* FALLTHRU */
    4613                 :  7571276707 :     default:
    4614                 :  7571276707 :       if (targetm.rtx_costs (x, mode, outer_code, opno, &total, speed))
    4615                 :  3457818771 :         return total;
    4616                 :             :       break;
    4617                 :             :     }
    4618                 :             : 
    4619                 :             :   /* Sum the costs of the sub-rtx's, plus cost of this operation,
    4620                 :             :      which is already in total.  */
    4621                 :             : 
    4622                 :  4123903013 :   fmt = GET_RTX_FORMAT (code);
    4623                 : 12286595792 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    4624                 :  8162692779 :     if (fmt[i] == 'e')
    4625                 :  8098496525 :       total += rtx_cost (XEXP (x, i), mode, code, i, speed);
    4626                 :    64196254 :     else if (fmt[i] == 'E')
    4627                 :    11393638 :       for (j = 0; j < XVECLEN (x, i); j++)
    4628                 :     6467309 :         total += rtx_cost (XVECEXP (x, i, j), mode, code, i, speed);
    4629                 :             : 
    4630                 :  4123903013 :   return total;
    4631                 :             : }
    4632                 :             : 
    4633                 :             : /* Fill in the structure C with information about both speed and size rtx
    4634                 :             :    costs for X, which is operand OPNO in an expression with code OUTER.  */
    4635                 :             : 
    4636                 :             : void
    4637                 :     2179563 : get_full_rtx_cost (rtx x, machine_mode mode, enum rtx_code outer, int opno,
    4638                 :             :                    struct full_rtx_costs *c)
    4639                 :             : {
    4640                 :     2179563 :   c->speed = rtx_cost (x, mode, outer, opno, true);
    4641                 :     2179563 :   c->size = rtx_cost (x, mode, outer, opno, false);
    4642                 :     2179563 : }
    4643                 :             : 
    4644                 :             : 
    4645                 :             : /* Return cost of address expression X.
    4646                 :             :    Expect that X is properly formed address reference.
    4647                 :             : 
    4648                 :             :    SPEED parameter specify whether costs optimized for speed or size should
    4649                 :             :    be returned.  */
    4650                 :             : 
    4651                 :             : int
    4652                 :     9540405 : address_cost (rtx x, machine_mode mode, addr_space_t as, bool speed)
    4653                 :             : {
    4654                 :             :   /* We may be asked for cost of various unusual addresses, such as operands
    4655                 :             :      of push instruction.  It is not worthwhile to complicate writing
    4656                 :             :      of the target hook by such cases.  */
    4657                 :             : 
    4658                 :     9540405 :   if (!memory_address_addr_space_p (mode, x, as))
    4659                 :             :     return 1000;
    4660                 :             : 
    4661                 :     9455882 :   return targetm.address_cost (x, mode, as, speed);
    4662                 :             : }
    4663                 :             : 
    4664                 :             : /* If the target doesn't override, compute the cost as with arithmetic.  */
    4665                 :             : 
    4666                 :             : int
    4667                 :           0 : default_address_cost (rtx x, machine_mode, addr_space_t, bool speed)
    4668                 :             : {
    4669                 :           0 :   return rtx_cost (x, Pmode, MEM, 0, speed);
    4670                 :             : }
    4671                 :             : 
    4672                 :             : 
    4673                 :             : unsigned HOST_WIDE_INT
    4674                 :   653914953 : nonzero_bits (const_rtx x, machine_mode mode)
    4675                 :             : {
    4676                 :   653914953 :   if (mode == VOIDmode)
    4677                 :           0 :     mode = GET_MODE (x);
    4678                 :   653914953 :   scalar_int_mode int_mode;
    4679                 :   653914953 :   if (!is_a <scalar_int_mode> (mode, &int_mode))
    4680                 :    18940712 :     return GET_MODE_MASK (mode);
    4681                 :   634974241 :   return cached_nonzero_bits (x, int_mode, NULL_RTX, VOIDmode, 0);
    4682                 :             : }
    4683                 :             : 
    4684                 :             : unsigned int
    4685                 :   233908279 : num_sign_bit_copies (const_rtx x, machine_mode mode)
    4686                 :             : {
    4687                 :   233908279 :   if (mode == VOIDmode)
    4688                 :           1 :     mode = GET_MODE (x);
    4689                 :   233908279 :   scalar_int_mode int_mode;
    4690                 :   233908279 :   if (!is_a <scalar_int_mode> (mode, &int_mode))
    4691                 :             :     return 1;
    4692                 :   215262200 :   return cached_num_sign_bit_copies (x, int_mode, NULL_RTX, VOIDmode, 0);
    4693                 :             : }
    4694                 :             : 
    4695                 :             : /* Return true if nonzero_bits1 might recurse into both operands
    4696                 :             :    of X.  */
    4697                 :             : 
    4698                 :             : static inline bool
    4699                 :  1350658773 : nonzero_bits_binary_arith_p (const_rtx x)
    4700                 :             : {
    4701                 :  1350658773 :   if (!ARITHMETIC_P (x))
    4702                 :             :     return false;
    4703                 :   239786420 :   switch (GET_CODE (x))
    4704                 :             :     {
    4705                 :             :     case AND:
    4706                 :             :     case XOR:
    4707                 :             :     case IOR:
    4708                 :             :     case UMIN:
    4709                 :             :     case UMAX:
    4710                 :             :     case SMIN:
    4711                 :             :     case SMAX:
    4712                 :             :     case PLUS:
    4713                 :             :     case MINUS:
    4714                 :             :     case MULT:
    4715                 :             :     case DIV:
    4716                 :             :     case UDIV:
    4717                 :             :     case MOD:
    4718                 :             :     case UMOD:
    4719                 :             :       return true;
    4720                 :             :     default:
    4721                 :             :       return false;
    4722                 :             :     }
    4723                 :             : }
    4724                 :             : 
    4725                 :             : /* The function cached_nonzero_bits is a wrapper around nonzero_bits1.
    4726                 :             :    It avoids exponential behavior in nonzero_bits1 when X has
    4727                 :             :    identical subexpressions on the first or the second level.  */
    4728                 :             : 
    4729                 :             : static unsigned HOST_WIDE_INT
    4730                 :  1085688995 : cached_nonzero_bits (const_rtx x, scalar_int_mode mode, const_rtx known_x,
    4731                 :             :                      machine_mode known_mode,
    4732                 :             :                      unsigned HOST_WIDE_INT known_ret)
    4733                 :             : {
    4734                 :  1085688995 :   if (x == known_x && mode == known_mode)
    4735                 :             :     return known_ret;
    4736                 :             : 
    4737                 :             :   /* Try to find identical subexpressions.  If found call
    4738                 :             :      nonzero_bits1 on X with the subexpressions as KNOWN_X and the
    4739                 :             :      precomputed value for the subexpression as KNOWN_RET.  */
    4740                 :             : 
    4741                 :  1083556239 :   if (nonzero_bits_binary_arith_p (x))
    4742                 :             :     {
    4743                 :   134103894 :       rtx x0 = XEXP (x, 0);
    4744                 :   134103894 :       rtx x1 = XEXP (x, 1);
    4745                 :             : 
    4746                 :             :       /* Check the first level.  */
    4747                 :   134103894 :       if (x0 == x1)
    4748                 :       48153 :         return nonzero_bits1 (x, mode, x0, mode,
    4749                 :             :                               cached_nonzero_bits (x0, mode, known_x,
    4750                 :       48153 :                                                    known_mode, known_ret));
    4751                 :             : 
    4752                 :             :       /* Check the second level.  */
    4753                 :   134055741 :       if (nonzero_bits_binary_arith_p (x0)
    4754                 :   134055741 :           && (x1 == XEXP (x0, 0) || x1 == XEXP (x0, 1)))
    4755                 :     1008948 :         return nonzero_bits1 (x, mode, x1, mode,
    4756                 :             :                               cached_nonzero_bits (x1, mode, known_x,
    4757                 :     1008948 :                                                    known_mode, known_ret));
    4758                 :             : 
    4759                 :   133046793 :       if (nonzero_bits_binary_arith_p (x1)
    4760                 :   133046793 :           && (x0 == XEXP (x1, 0) || x0 == XEXP (x1, 1)))
    4761                 :        5169 :         return nonzero_bits1 (x, mode, x0, mode,
    4762                 :             :                               cached_nonzero_bits (x0, mode, known_x,
    4763                 :        5169 :                                                    known_mode, known_ret));
    4764                 :             :     }
    4765                 :             : 
    4766                 :  1082493969 :   return nonzero_bits1 (x, mode, known_x, known_mode, known_ret);
    4767                 :             : }
    4768                 :             : 
    4769                 :             : /* We let num_sign_bit_copies recur into nonzero_bits as that is useful.
    4770                 :             :    We don't let nonzero_bits recur into num_sign_bit_copies, because that
    4771                 :             :    is less useful.  We can't allow both, because that results in exponential
    4772                 :             :    run time recursion.  There is a nullstone testcase that triggered
    4773                 :             :    this.  This macro avoids accidental uses of num_sign_bit_copies.  */
    4774                 :             : #define cached_num_sign_bit_copies sorry_i_am_preventing_exponential_behavior
    4775                 :             : 
    4776                 :             : /* Given an expression, X, compute which bits in X can be nonzero.
    4777                 :             :    We don't care about bits outside of those defined in MODE.
    4778                 :             : 
    4779                 :             :    For most X this is simply GET_MODE_MASK (GET_MODE (X)), but if X is
    4780                 :             :    an arithmetic operation, we can do better.  */
    4781                 :             : 
    4782                 :             : static unsigned HOST_WIDE_INT
    4783                 :  1083556239 : nonzero_bits1 (const_rtx x, scalar_int_mode mode, const_rtx known_x,
    4784                 :             :                machine_mode known_mode,
    4785                 :             :                unsigned HOST_WIDE_INT known_ret)
    4786                 :             : {
    4787                 :  1083556239 :   unsigned HOST_WIDE_INT nonzero = GET_MODE_MASK (mode);
    4788                 :  1083556239 :   unsigned HOST_WIDE_INT inner_nz;
    4789                 :  1083556239 :   enum rtx_code code = GET_CODE (x);
    4790                 :  1083556239 :   machine_mode inner_mode;
    4791                 :  1083556239 :   unsigned int inner_width;
    4792                 :  1083556239 :   scalar_int_mode xmode;
    4793                 :             : 
    4794                 :  1083556239 :   unsigned int mode_width = GET_MODE_PRECISION (mode);
    4795                 :             : 
    4796                 :  1083556239 :   if (CONST_INT_P (x))
    4797                 :             :     {
    4798                 :   112205993 :       if (SHORT_IMMEDIATES_SIGN_EXTEND
    4799                 :             :           && INTVAL (x) > 0
    4800                 :             :           && mode_width < BITS_PER_WORD
    4801                 :             :           && (UINTVAL (x) & (HOST_WIDE_INT_1U << (mode_width - 1))) != 0)
    4802                 :             :         return UINTVAL (x) | (HOST_WIDE_INT_M1U << mode_width);
    4803                 :             : 
    4804                 :   112205993 :       return UINTVAL (x);
    4805                 :             :     }
    4806                 :             : 
    4807                 :   971350246 :   if (!is_a <scalar_int_mode> (GET_MODE (x), &xmode))
    4808                 :             :     return nonzero;
    4809                 :   970980087 :   unsigned int xmode_width = GET_MODE_PRECISION (xmode);
    4810                 :             : 
    4811                 :             :   /* If X is wider than MODE, use its mode instead.  */
    4812                 :   970980087 :   if (xmode_width > mode_width)
    4813                 :             :     {
    4814                 :    22804731 :       mode = xmode;
    4815                 :    22804731 :       nonzero = GET_MODE_MASK (mode);
    4816                 :    22804731 :       mode_width = xmode_width;
    4817                 :             :     }
    4818                 :             : 
    4819                 :   970980087 :   if (mode_width > HOST_BITS_PER_WIDE_INT)
    4820                 :             :     /* Our only callers in this case look for single bit values.  So
    4821                 :             :        just return the mode mask.  Those tests will then be false.  */
    4822                 :             :     return nonzero;
    4823                 :             : 
    4824                 :             :   /* If MODE is wider than X, but both are a single word for both the host
    4825                 :             :      and target machines, we can compute this from which bits of the object
    4826                 :             :      might be nonzero in its own mode, taking into account the fact that, on
    4827                 :             :      CISC machines, accessing an object in a wider mode generally causes the
    4828                 :             :      high-order bits to become undefined, so they are not known to be zero.
    4829                 :             :      We extend this reasoning to RISC machines for operations that might not
    4830                 :             :      operate on the full registers.  */
    4831                 :   969479253 :   if (mode_width > xmode_width
    4832                 :   104937189 :       && xmode_width <= BITS_PER_WORD
    4833                 :             :       && xmode_width <= HOST_BITS_PER_WIDE_INT
    4834                 :             :       && !(WORD_REGISTER_OPERATIONS && word_register_operation_p (x)))
    4835                 :             :     {
    4836                 :    89007156 :       nonzero &= cached_nonzero_bits (x, xmode,
    4837                 :             :                                       known_x, known_mode, known_ret);
    4838                 :    89007156 :       nonzero |= GET_MODE_MASK (mode) & ~GET_MODE_MASK (xmode);
    4839                 :    89007156 :       return nonzero;
    4840                 :             :     }
    4841                 :             : 
    4842                 :             :   /* Please keep nonzero_bits_binary_arith_p above in sync with
    4843                 :             :      the code in the switch below.  */
    4844                 :   880472097 :   switch (code)
    4845                 :             :     {
    4846                 :   484967465 :     case REG:
    4847                 :             : #if defined(POINTERS_EXTEND_UNSIGNED)
    4848                 :             :       /* If pointers extend unsigned and this is a pointer in Pmode, say that
    4849                 :             :          all the bits above ptr_mode are known to be zero.  */
    4850                 :             :       /* As we do not know which address space the pointer is referring to,
    4851                 :             :          we can do this only if the target does not support different pointer
    4852                 :             :          or address modes depending on the address space.  */
    4853                 :   484967465 :       if (target_default_pointer_address_modes_p ()
    4854                 :             :           && POINTERS_EXTEND_UNSIGNED
    4855                 :   484967465 :           && xmode == Pmode
    4856                 :   299530478 :           && REG_POINTER (x)
    4857                 :   563611637 :           && !targetm.have_ptr_extend ())
    4858                 :    78644172 :         nonzero &= GET_MODE_MASK (ptr_mode);
    4859                 :             : #endif
    4860                 :             : 
    4861                 :             :       /* Include declared information about alignment of pointers.  */
    4862                 :             :       /* ??? We don't properly preserve REG_POINTER changes across
    4863                 :             :          pointer-to-integer casts, so we can't trust it except for
    4864                 :             :          things that we know must be pointers.  See execute/960116-1.c.  */
    4865                 :   484967465 :       if ((x == stack_pointer_rtx
    4866                 :   484054921 :            || x == frame_pointer_rtx
    4867                 :   470324678 :            || x == arg_pointer_rtx)
    4868                 :   499235453 :           && REGNO_POINTER_ALIGN (REGNO (x)))
    4869                 :             :         {
    4870                 :    15180532 :           unsigned HOST_WIDE_INT alignment
    4871                 :    15180532 :             = REGNO_POINTER_ALIGN (REGNO (x)) / BITS_PER_UNIT;
    4872                 :             : 
    4873                 :             : #ifdef PUSH_ROUNDING
    4874                 :             :           /* If PUSH_ROUNDING is defined, it is possible for the
    4875                 :             :              stack to be momentarily aligned only to that amount,
    4876                 :             :              so we pick the least alignment.  */
    4877                 :    15180532 :           if (x == stack_pointer_rtx && targetm.calls.push_argument (0))
    4878                 :             :             {
    4879                 :      689043 :               poly_uint64 rounded_1 = PUSH_ROUNDING (poly_int64 (1));
    4880                 :      689043 :               alignment = MIN (known_alignment (rounded_1), alignment);
    4881                 :             :             }
    4882                 :             : #endif
    4883                 :             : 
    4884                 :    15180532 :           nonzero &= ~(alignment - 1);
    4885                 :             :         }
    4886                 :             : 
    4887                 :   484967465 :       {
    4888                 :   484967465 :         unsigned HOST_WIDE_INT nonzero_for_hook = nonzero;
    4889                 :   484967465 :         rtx new_rtx = rtl_hooks.reg_nonzero_bits (x, xmode, mode,
    4890                 :             :                                                   &nonzero_for_hook);
    4891                 :             : 
    4892                 :   484967465 :         if (new_rtx)
    4893                 :           6 :           nonzero_for_hook &= cached_nonzero_bits (new_rtx, mode, known_x,
    4894                 :             :                                                    known_mode, known_ret);
    4895                 :             : 
    4896                 :   484967465 :         return nonzero_for_hook;
    4897                 :             :       }
    4898                 :             : 
    4899                 :             :     case MEM:
    4900                 :             :       /* In many, if not most, RISC machines, reading a byte from memory
    4901                 :             :          zeros the rest of the register.  Noticing that fact saves a lot
    4902                 :             :          of extra zero-extends.  */
    4903                 :             :       if (load_extend_op (xmode) == ZERO_EXTEND)
    4904                 :             :         nonzero &= GET_MODE_MASK (xmode);
    4905                 :             :       break;
    4906                 :             : 
    4907                 :     8053085 :     case EQ:  case NE:
    4908                 :     8053085 :     case UNEQ:  case LTGT:
    4909                 :     8053085 :     case GT:  case GTU:  case UNGT:
    4910                 :     8053085 :     case LT:  case LTU:  case UNLT:
    4911                 :     8053085 :     case GE:  case GEU:  case UNGE:
    4912                 :     8053085 :     case LE:  case LEU:  case UNLE:
    4913                 :     8053085 :     case UNORDERED: case ORDERED:
    4914                 :             :       /* If this produces an integer result, we know which bits are set.
    4915                 :             :          Code here used to clear bits outside the mode of X, but that is
    4916                 :             :          now done above.  */
    4917                 :             :       /* Mind that MODE is the mode the caller wants to look at this
    4918                 :             :          operation in, and not the actual operation mode.  We can wind
    4919                 :             :          up with (subreg:DI (gt:V4HI x y)), and we don't have anything
    4920                 :             :          that describes the results of a vector compare.  */
    4921                 :     8053085 :       if (GET_MODE_CLASS (xmode) == MODE_INT
    4922                 :     8053085 :           && mode_width <= HOST_BITS_PER_WIDE_INT)
    4923                 :  1083556239 :         nonzero = STORE_FLAG_VALUE;
    4924                 :             :       break;
    4925                 :             : 
    4926                 :      910494 :     case NEG:
    4927                 :             : #if 0
    4928                 :             :       /* Disabled to avoid exponential mutual recursion between nonzero_bits
    4929                 :             :          and num_sign_bit_copies.  */
    4930                 :             :       if (num_sign_bit_copies (XEXP (x, 0), xmode) == xmode_width)
    4931                 :             :         nonzero = 1;
    4932                 :             : #endif
    4933                 :             : 
    4934                 :      910494 :       if (xmode_width < mode_width)
    4935                 :           0 :         nonzero |= (GET_MODE_MASK (mode) & ~GET_MODE_MASK (xmode));
    4936                 :             :       break;
    4937                 :             : 
    4938                 :             :     case ABS:
    4939                 :             : #if 0
    4940                 :             :       /* Disabled to avoid exponential mutual recursion between nonzero_bits
    4941                 :             :          and num_sign_bit_copies.  */
    4942                 :             :       if (num_sign_bit_copies (XEXP (x, 0), xmode) == xmode_width)
    4943                 :             :         nonzero = 1;
    4944                 :             : #endif
    4945                 :             :       break;
    4946                 :             : 
    4947                 :       10486 :     case TRUNCATE:
    4948                 :       10486 :       nonzero &= (cached_nonzero_bits (XEXP (x, 0), mode,
    4949                 :             :                                        known_x, known_mode, known_ret)
    4950                 :       10486 :                   & GET_MODE_MASK (mode));
    4951                 :       10486 :       break;
    4952                 :             : 
    4953                 :     6021957 :     case ZERO_EXTEND:
    4954                 :     6021957 :       nonzero &= cached_nonzero_bits (XEXP (x, 0), mode,
    4955                 :             :                                       known_x, known_mode, known_ret);
    4956                 :     6021957 :       if (GET_MODE (XEXP (x, 0)) != VOIDmode)
    4957                 :     6021957 :         nonzero &= GET_MODE_MASK (GET_MODE (XEXP (x, 0)));
    4958                 :             :       break;
    4959                 :             : 
    4960                 :     1882484 :     case SIGN_EXTEND:
    4961                 :             :       /* If the sign bit is known clear, this is the same as ZERO_EXTEND.
    4962                 :             :          Otherwise, show all the bits in the outer mode but not the inner
    4963                 :             :          may be nonzero.  */
    4964                 :     1882484 :       inner_nz = cached_nonzero_bits (XEXP (x, 0), mode,
    4965                 :             :                                       known_x, known_mode, known_ret);
    4966                 :     1882484 :       if (GET_MODE (XEXP (x, 0)) != VOIDmode)
    4967                 :             :         {
    4968                 :     1882484 :           inner_nz &= GET_MODE_MASK (GET_MODE (XEXP (x, 0)));
    4969                 :     1882484 :           if (val_signbit_known_set_p (GET_MODE (XEXP (x, 0)), inner_nz))
    4970                 :     1826040 :             inner_nz |= (GET_MODE_MASK (mode)
    4971                 :     1826040 :                          & ~GET_MODE_MASK (GET_MODE (XEXP (x, 0))));
    4972                 :             :         }
    4973                 :             : 
    4974                 :     1882484 :       nonzero &= inner_nz;
    4975                 :     1882484 :       break;
    4976                 :             : 
    4977                 :    15459130 :     case AND:
    4978                 :    15459130 :       nonzero &= cached_nonzero_bits (XEXP (x, 0), mode,
    4979                 :             :                                        known_x, known_mode, known_ret)
    4980                 :    15459130 :                  & cached_nonzero_bits (XEXP (x, 1), mode,
    4981                 :             :                                         known_x, known_mode, known_ret);
    4982                 :    15459130 :       break;
    4983                 :             : 
    4984                 :     9732175 :     case XOR:   case IOR:
    4985                 :     9732175 :     case UMIN:  case UMAX:  case SMIN:  case SMAX:
    4986                 :     9732175 :       {
    4987                 :     9732175 :         unsigned HOST_WIDE_INT nonzero0
    4988                 :     9732175 :            = cached_nonzero_bits (XEXP (x, 0), mode,
    4989                 :             :                                   known_x, known_mode, known_ret);
    4990                 :             : 
    4991                 :             :         /* Don't call nonzero_bits for the second time if it cannot change
    4992                 :             :            anything.  */
    4993                 :     9732175 :         if ((nonzero & nonzero0) != nonzero)
    4994                 :     9400432 :           nonzero &= nonzero0
    4995                 :     4700216 :                      | cached_nonzero_bits (XEXP (x, 1), mode,
    4996                 :             :                                             known_x, known_mode, known_ret);
    4997                 :             :       }
    4998                 :             :       break;
    4999                 :             : 
    5000                 :    89572782 :     case PLUS:  case MINUS:
    5001                 :    89572782 :     case MULT:
    5002                 :    89572782 :     case DIV:   case UDIV:
    5003                 :    89572782 :     case MOD:   case UMOD:
    5004                 :             :       /* We can apply the rules of arithmetic to compute the number of
    5005                 :             :          high- and low-order zero bits of these operations.  We start by
    5006                 :             :          computing the width (position of the highest-order nonzero bit)
    5007                 :             :          and the number of low-order zero bits for each value.  */
    5008                 :    89572782 :       {
    5009                 :    89572782 :         unsigned HOST_WIDE_INT nz0
    5010                 :    89572782 :           = cached_nonzero_bits (XEXP (x, 0), mode,
    5011                 :             :                                  known_x, known_mode, known_ret);
    5012                 :    89572782 :         unsigned HOST_WIDE_INT nz1
    5013                 :    89572782 :           = cached_nonzero_bits (XEXP (x, 1), mode,
    5014                 :             :                                  known_x, known_mode, known_ret);
    5015                 :    89572782 :         int sign_index = xmode_width - 1;
    5016                 :    89572782 :         int width0 = floor_log2 (nz0) + 1;
    5017                 :    89572782 :         int width1 = floor_log2 (nz1) + 1;
    5018                 :    89572782 :         int low0 = ctz_or_zero (nz0);
    5019                 :    89572782 :         int low1 = ctz_or_zero (nz1);
    5020                 :    89572782 :         unsigned HOST_WIDE_INT op0_maybe_minusp
    5021                 :    89572782 :           = nz0 & (HOST_WIDE_INT_1U << sign_index);
    5022                 :    89572782 :         unsigned HOST_WIDE_INT op1_maybe_minusp
    5023                 :             :           = nz1 & (HOST_WIDE_INT_1U << sign_index);
    5024                 :    89572782 :         unsigned int result_width = mode_width;
    5025                 :    89572782 :         int result_low = 0;
    5026                 :             : 
    5027                 :    89572782 :         switch (code)
    5028                 :             :           {
    5029                 :    66846062 :           case PLUS:
    5030                 :    66846062 :             result_width = MAX (width0, width1) + 1;
    5031                 :    66846062 :             result_low = MIN (low0, low1);
    5032                 :             :             break;
    5033                 :    13594761 :           case MINUS:
    5034                 :    13594761 :             result_low = MIN (low0, low1);
    5035                 :             :             break;
    5036                 :     7572057 :           case MULT:
    5037                 :     7572057 :             result_width = width0 + width1;
    5038                 :     7572057 :             result_low = low0 + low1;
    5039                 :     7572057 :             break;
    5040                 :      572753 :           case DIV:
    5041                 :      572753 :             if (width1 == 0)
    5042                 :             :               break;
    5043                 :      563369 :             if (!op0_maybe_minusp && !op1_maybe_minusp)
    5044                 :       23497 :               result_width = width0;
    5045                 :             :             break;
    5046                 :      260850 :           case UDIV:
    5047                 :      260850 :             if (width1 == 0)
    5048                 :             :               break;
    5049                 :      260040 :             result_width = width0;
    5050                 :      260040 :             break;
    5051                 :      364634 :           case MOD:
    5052                 :      364634 :             if (width1 == 0)
    5053                 :             :               break;
    5054                 :      357388 :             if (!op0_maybe_minusp && !op1_maybe_minusp)
    5055                 :       30876 :               result_width = MIN (width0, width1);
    5056                 :      357388 :             result_low = MIN (low0, low1);
    5057                 :             :             break;
    5058                 :      361665 :           case UMOD:
    5059                 :      361665 :             if (width1 == 0)
    5060                 :             :               break;
    5061                 :      361552 :             result_width = MIN (width0, width1);
    5062                 :      361552 :             result_low = MIN (low0, low1);
    5063                 :             :             break;
    5064                 :           0 :           default:
    5065                 :           0 :             gcc_unreachable ();
    5066                 :             :           }
    5067                 :             : 
    5068                 :             :         /* Note that mode_width <= HOST_BITS_PER_WIDE_INT, see above.  */
    5069                 :    89572782 :         if (result_width < mode_width)
    5070                 :     3908115 :           nonzero &= (HOST_WIDE_INT_1U << result_width) - 1;
    5071                 :             : 
    5072                 :    89572782 :         if (result_low > 0)
    5073                 :             :           {
    5074                 :     7379847 :             if (result_low < HOST_BITS_PER_WIDE_INT)
    5075                 :     7379835 :               nonzero &= ~((HOST_WIDE_INT_1U << result_low) - 1);
    5076                 :             :             else
    5077                 :             :               nonzero = 0;
    5078                 :             :           }
    5079                 :             :       }
    5080                 :             :       break;
    5081                 :             : 
    5082                 :     1020082 :     case ZERO_EXTRACT:
    5083                 :     1020082 :       if (CONST_INT_P (XEXP (x, 1))
    5084                 :     1019705 :           && INTVAL (XEXP (x, 1)) < HOST_BITS_PER_WIDE_INT)
    5085                 :     1019548 :         nonzero &= (HOST_WIDE_INT_1U << INTVAL (XEXP (x, 1))) - 1;
    5086                 :             :       break;
    5087                 :             : 
    5088                 :    74488993 :     case SUBREG:
    5089                 :             :       /* If this is a SUBREG formed for a promoted variable that has
    5090                 :             :          been zero-extended, we know that at least the high-order bits
    5091                 :             :          are zero, though others might be too.  */
    5092                 :    74488993 :       if (SUBREG_PROMOTED_VAR_P (x) && SUBREG_PROMOTED_UNSIGNED_P (x))
    5093                 :       62275 :         nonzero = GET_MODE_MASK (xmode)
    5094                 :       62275 :                   & cached_nonzero_bits (SUBREG_REG (x), xmode,
    5095                 :             :                                          known_x, known_mode, known_ret);
    5096                 :             : 
    5097                 :             :       /* If the inner mode is a single word for both the host and target
    5098                 :             :          machines, we can compute this from which bits of the inner
    5099                 :             :          object might be nonzero.  */
    5100                 :    74488993 :       inner_mode = GET_MODE (SUBREG_REG (x));
    5101                 :    74488993 :       if (GET_MODE_PRECISION (inner_mode).is_constant (&inner_width)
    5102                 :    79211775 :           && inner_width <= BITS_PER_WORD
    5103                 :             :           && inner_width <= HOST_BITS_PER_WIDE_INT)
    5104                 :             :         {
    5105                 :    70474566 :           nonzero &= cached_nonzero_bits (SUBREG_REG (x), mode,
    5106                 :             :                                           known_x, known_mode, known_ret);
    5107                 :             : 
    5108                 :             :           /* On a typical CISC machine, accessing an object in a wider mode
    5109                 :             :              causes the high-order bits to become undefined.  So they are
    5110                 :             :              not known to be zero.
    5111                 :             : 
    5112                 :             :              On a typical RISC machine, we only have to worry about the way
    5113                 :             :              loads are extended.  Otherwise, if we get a reload for the inner
    5114                 :             :              part, it may be loaded from the stack, and then we may lose all
    5115                 :             :              the zero bits that existed before the store to the stack.  */
    5116                 :    70474566 :           rtx_code extend_op;
    5117                 :    70474566 :           if ((!WORD_REGISTER_OPERATIONS
    5118                 :             :                || ((extend_op = load_extend_op (inner_mode)) == SIGN_EXTEND
    5119                 :             :                    ? val_signbit_known_set_p (inner_mode, nonzero)
    5120                 :             :                    : extend_op != ZERO_EXTEND)
    5121                 :             :                || !MEM_P (SUBREG_REG (x)))
    5122                 :             :               && xmode_width > inner_width)
    5123                 :    49995057 :             nonzero
    5124                 :    49995057 :               |= (GET_MODE_MASK (GET_MODE (x)) & ~GET_MODE_MASK (inner_mode));
    5125                 :             :         }
    5126                 :             :       break;
    5127                 :             : 
    5128                 :    54628241 :     case ASHIFT:
    5129                 :    54628241 :     case ASHIFTRT:
    5130                 :    54628241 :     case LSHIFTRT:
    5131                 :    54628241 :     case ROTATE:
    5132                 :    54628241 :     case ROTATERT:
    5133                 :             :       /* The nonzero bits are in two classes: any bits within MODE
    5134                 :             :          that aren't in xmode are always significant.  The rest of the
    5135                 :             :          nonzero bits are those that are significant in the operand of
    5136                 :             :          the shift when shifted the appropriate number of bits.  This
    5137                 :             :          shows that high-order bits are cleared by the right shift and
    5138                 :             :          low-order bits by left shifts.  */
    5139                 :    54628241 :       if (CONST_INT_P (XEXP (x, 1))
    5140                 :    53218318 :           && INTVAL (XEXP (x, 1)) >= 0
    5141                 :    53218244 :           && INTVAL (XEXP (x, 1)) < HOST_BITS_PER_WIDE_INT
    5142                 :    53218156 :           && INTVAL (XEXP (x, 1)) < xmode_width)
    5143                 :             :         {
    5144                 :    53218090 :           int count = INTVAL (XEXP (x, 1));
    5145                 :    53218090 :           unsigned HOST_WIDE_INT mode_mask = GET_MODE_MASK (xmode);
    5146                 :    53218090 :           unsigned HOST_WIDE_INT op_nonzero
    5147                 :    53218090 :             = cached_nonzero_bits (XEXP (x, 0), mode,
    5148                 :             :                                    known_x, known_mode, known_ret);
    5149                 :    53218090 :           unsigned HOST_WIDE_INT inner = op_nonzero & mode_mask;
    5150                 :    53218090 :           unsigned HOST_WIDE_INT outer = 0;
    5151                 :             : 
    5152                 :    53218090 :           if (mode_width > xmode_width)
    5153                 :           0 :             outer = (op_nonzero & nonzero & ~mode_mask);
    5154                 :             : 
    5155                 :    53218090 :           switch (code)
    5156                 :             :             {
    5157                 :    30697490 :             case ASHIFT:
    5158                 :    30697490 :               inner <<= count;
    5159                 :    30697490 :               break;
    5160                 :             : 
    5161                 :    14314750 :             case LSHIFTRT:
    5162                 :    14314750 :               inner >>= count;
    5163                 :    14314750 :               break;
    5164                 :             : 
    5165                 :     8099211 :             case ASHIFTRT:
    5166                 :     8099211 :               inner >>= count;
    5167                 :             : 
    5168                 :             :               /* If the sign bit may have been nonzero before the shift, we
    5169                 :             :                  need to mark all the places it could have been copied to
    5170                 :             :                  by the shift as possibly nonzero.  */
    5171                 :     8099211 :               if (inner & (HOST_WIDE_INT_1U << (xmode_width - 1 - count)))
    5172                 :     8083991 :                 inner |= (((HOST_WIDE_INT_1U << count) - 1)
    5173                 :     8083991 :                           << (xmode_width - count));
    5174                 :             :               break;
    5175                 :             : 
    5176                 :       66040 :             case ROTATE:
    5177                 :       66040 :               inner = (inner << (count % xmode_width)
    5178                 :       66040 :                        | (inner >> (xmode_width - (count % xmode_width))))
    5179                 :             :                       & mode_mask;
    5180                 :       66040 :               break;
    5181                 :             : 
    5182                 :       40599 :             case ROTATERT:
    5183                 :       40599 :               inner = (inner >> (count % xmode_width)
    5184                 :       40599 :                        | (inner << (xmode_width - (count % xmode_width))))
    5185                 :             :                       & mode_mask;
    5186                 :       40599 :               break;
    5187                 :             : 
    5188                 :             :             default:
    5189                 :             :               gcc_unreachable ();
    5190                 :             :             }
    5191                 :             : 
    5192                 :    53218090 :           nonzero &= (outer | inner);
    5193                 :             :         }
    5194                 :             :       break;
    5195                 :             : 
    5196                 :        3348 :     case FFS:
    5197                 :        3348 :     case POPCOUNT:
    5198                 :             :       /* This is at most the number of bits in the mode.  */
    5199                 :        3348 :       nonzero = (HOST_WIDE_INT_UC (2) << (floor_log2 (mode_width))) - 1;
    5200                 :        3348 :       break;
    5201                 :             : 
    5202                 :      569528 :     case CLZ:
    5203                 :             :       /* If CLZ has a known value at zero, then the nonzero bits are
    5204                 :             :          that value, plus the number of bits in the mode minus one.  */
    5205                 :     1139056 :       if (CLZ_DEFINED_VALUE_AT_ZERO (mode, nonzero))
    5206                 :        1143 :         nonzero
    5207                 :        2286 :           |= (HOST_WIDE_INT_1U << (floor_log2 (mode_width))) - 1;
    5208                 :             :       else
    5209                 :             :         nonzero = -1;
    5210                 :             :       break;
    5211                 :             : 
    5212                 :       33140 :     case CTZ:
    5213                 :             :       /* If CTZ has a known value at zero, then the nonzero bits are
    5214                 :             :          that value, plus the number of bits in the mode minus one.  */
    5215                 :       66280 :       if (CTZ_DEFINED_VALUE_AT_ZERO (mode, nonzero))
    5216                 :        1795 :         nonzero
    5217                 :        3590 :           |= (HOST_WIDE_INT_1U << (floor_log2 (mode_width))) - 1;
    5218                 :             :       else
    5219                 :             :         nonzero = -1;
    5220                 :             :       break;
    5221                 :             : 
    5222                 :           8 :     case CLRSB:
    5223                 :             :       /* This is at most the number of bits in the mode minus 1.  */
    5224                 :           8 :       nonzero = (HOST_WIDE_INT_1U << (floor_log2 (mode_width))) - 1;
    5225                 :           8 :       break;
    5226                 :             : 
    5227                 :             :     case PARITY:
    5228                 :  1083556239 :       nonzero = 1;
    5229                 :             :       break;
    5230                 :             : 
    5231                 :     3114610 :     case IF_THEN_ELSE:
    5232                 :     3114610 :       {
    5233                 :     3114610 :         unsigned HOST_WIDE_INT nonzero_true
    5234                 :     3114610 :           = cached_nonzero_bits (XEXP (x, 1), mode,
    5235                 :             :                                  known_x, known_mode, known_ret);
    5236                 :             : 
    5237                 :             :         /* Don't call nonzero_bits for the second time if it cannot change
    5238                 :             :            anything.  */
    5239                 :     3114610 :         if ((nonzero & nonzero_true) != nonzero)
    5240                 :     2729278 :           nonzero &= nonzero_true
    5241                 :     1364639 :                      | cached_nonzero_bits (XEXP (x, 2), mode,
    5242                 :             :                                             known_x, known_mode, known_ret);
    5243                 :             :       }
    5244                 :             :       break;
    5245                 :             : 
    5246                 :             :     default:
    5247                 :             :       break;
    5248                 :             :     }
    5249                 :             : 
    5250                 :             :   return nonzero;
    5251                 :             : }
    5252                 :             : 
    5253                 :             : /* See the macro definition above.  */
    5254                 :             : #undef cached_num_sign_bit_copies
    5255                 :             : 
    5256                 :             : 
    5257                 :             : /* Return true if num_sign_bit_copies1 might recurse into both operands
    5258                 :             :    of X.  */
    5259                 :             : 
    5260                 :             : static inline bool
    5261                 :   422060484 : num_sign_bit_copies_binary_arith_p (const_rtx x)
    5262                 :             : {
    5263                 :   422060484 :   if (!ARITHMETIC_P (x))
    5264                 :             :     return false;
    5265                 :    77686025 :   switch (GET_CODE (x))
    5266                 :             :     {
    5267                 :             :     case IOR:
    5268                 :             :     case AND:
    5269                 :             :     case XOR:
    5270                 :             :     case SMIN:
    5271                 :             :     case SMAX:
    5272                 :             :     case UMIN:
    5273                 :             :     case UMAX:
    5274                 :             :     case PLUS:
    5275                 :             :     case MINUS:
    5276                 :             :     case MULT:
    5277                 :             :       return true;
    5278                 :             :     default:
    5279                 :             :       return false;
    5280                 :             :     }
    5281                 :             : }
    5282                 :             : 
    5283                 :             : /* The function cached_num_sign_bit_copies is a wrapper around
    5284                 :             :    num_sign_bit_copies1.  It avoids exponential behavior in
    5285                 :             :    num_sign_bit_copies1 when X has identical subexpressions on the
    5286                 :             :    first or the second level.  */
    5287                 :             : 
    5288                 :             : static unsigned int
    5289                 :   331569000 : cached_num_sign_bit_copies (const_rtx x, scalar_int_mode mode,
    5290                 :             :                             const_rtx known_x, machine_mode known_mode,
    5291                 :             :                             unsigned int known_ret)
    5292                 :             : {
    5293                 :   331569000 :   if (x == known_x && mode == known_mode)
    5294                 :             :     return known_ret;
    5295                 :             : 
    5296                 :             :   /* Try to find identical subexpressions.  If found call
    5297                 :             :      num_sign_bit_copies1 on X with the subexpressions as KNOWN_X and
    5298                 :             :      the precomputed value for the subexpression as KNOWN_RET.  */
    5299                 :             : 
    5300                 :   329809052 :   if (num_sign_bit_copies_binary_arith_p (x))
    5301                 :             :     {
    5302                 :    46515878 :       rtx x0 = XEXP (x, 0);
    5303                 :    46515878 :       rtx x1 = XEXP (x, 1);
    5304                 :             : 
    5305                 :             :       /* Check the first level.  */
    5306                 :    46515878 :       if (x0 == x1)
    5307                 :       14305 :         return
    5308                 :       14305 :           num_sign_bit_copies1 (x, mode, x0, mode,
    5309                 :             :                                 cached_num_sign_bit_copies (x0, mode, known_x,
    5310                 :             :                                                             known_mode,
    5311                 :       14305 :                                                             known_ret));
    5312                 :             : 
    5313                 :             :       /* Check the second level.  */
    5314                 :    46501573 :       if (num_sign_bit_copies_binary_arith_p (x0)
    5315                 :    46501573 :           && (x1 == XEXP (x0, 0) || x1 == XEXP (x0, 1)))
    5316                 :      751714 :         return
    5317                 :      751714 :           num_sign_bit_copies1 (x, mode, x1, mode,
    5318                 :             :                                 cached_num_sign_bit_copies (x1, mode, known_x,
    5319                 :             :                                                             known_mode,
    5320                 :      751714 :                                                             known_ret));
    5321                 :             : 
    5322                 :    45749859 :       if (num_sign_bit_copies_binary_arith_p (x1)
    5323                 :    45749859 :           && (x0 == XEXP (x1, 0) || x0 == XEXP (x1, 1)))
    5324                 :          67 :         return
    5325                 :          67 :           num_sign_bit_copies1 (x, mode, x0, mode,
    5326                 :             :                                 cached_num_sign_bit_copies (x0, mode, known_x,
    5327                 :             :                                                             known_mode,
    5328                 :          67 :                                                             known_ret));
    5329                 :             :     }
    5330                 :             : 
    5331                 :   329042966 :   return num_sign_bit_copies1 (x, mode, known_x, known_mode, known_ret);
    5332                 :             : }
    5333                 :             : 
    5334                 :             : /* Return the number of bits at the high-order end of X that are known to
    5335                 :             :    be equal to the sign bit.  X will be used in mode MODE.  The returned
    5336                 :             :    value will always be between 1 and the number of bits in MODE.  */
    5337                 :             : 
    5338                 :             : static unsigned int
    5339                 :   329809052 : num_sign_bit_copies1 (const_rtx x, scalar_int_mode mode, const_rtx known_x,
    5340                 :             :                       machine_mode known_mode,
    5341                 :             :                       unsigned int known_ret)
    5342                 :             : {
    5343                 :   329809052 :   enum rtx_code code = GET_CODE (x);
    5344                 :   329809052 :   unsigned int bitwidth = GET_MODE_PRECISION (mode);
    5345                 :   329809052 :   int num0, num1, result;
    5346                 :   329809052 :   unsigned HOST_WIDE_INT nonzero;
    5347                 :             : 
    5348                 :   329809052 :   if (CONST_INT_P (x))
    5349                 :             :     {
    5350                 :             :       /* If the constant is negative, take its 1's complement and remask.
    5351                 :             :          Then see how many zero bits we have.  */
    5352                 :    42641783 :       nonzero = UINTVAL (x) & GET_MODE_MASK (mode);
    5353                 :    42641783 :       if (bitwidth <= HOST_BITS_PER_WIDE_INT
    5354                 :    42331907 :           && (nonzero & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0)
    5355                 :    18935181 :         nonzero = (~nonzero) & GET_MODE_MASK (mode);
    5356                 :             : 
    5357                 :    42641783 :       return (nonzero == 0 ? bitwidth : bitwidth - floor_log2 (nonzero) - 1);
    5358                 :             :     }
    5359                 :             : 
    5360                 :   287167269 :   scalar_int_mode xmode, inner_mode;
    5361                 :   482908696 :   if (!is_a <scalar_int_mode> (GET_MODE (x), &xmode))
    5362                 :             :     return 1;
    5363                 :             : 
    5364                 :   286821850 :   unsigned int xmode_width = GET_MODE_PRECISION (xmode);
    5365                 :             : 
    5366                 :             :   /* For a smaller mode, just ignore the high bits.  */
    5367                 :   286821850 :   if (bitwidth < xmode_width)
    5368                 :             :     {
    5369                 :      159812 :       num0 = cached_num_sign_bit_copies (x, xmode,
    5370                 :             :                                          known_x, known_mode, known_ret);
    5371                 :      159812 :       return MAX (1, num0 - (int) (xmode_width - bitwidth));
    5372                 :             :     }
    5373                 :             : 
    5374                 :   286662038 :   if (bitwidth > xmode_width)
    5375                 :             :     {
    5376                 :             :       /* If this machine does not do all register operations on the entire
    5377                 :             :          register and MODE is wider than the mode of X, we can say nothing
    5378                 :             :          at all about the high-order bits.  We extend this reasoning to RISC
    5379                 :             :          machines for operations that might not operate on full registers.  */
    5380                 :             :       if (!(WORD_REGISTER_OPERATIONS && word_register_operation_p (x)))
    5381                 :             :         return 1;
    5382                 :             : 
    5383                 :             :       /* Likewise on machines that do, if the mode of the object is smaller
    5384                 :             :          than a word and loads of that size don't sign extend, we can say
    5385                 :             :          nothing about the high order bits.  */
    5386                 :             :       if (xmode_width < BITS_PER_WORD
    5387                 :             :           && load_extend_op (xmode) != SIGN_EXTEND)
    5388                 :             :         return 1;
    5389                 :             :     }
    5390                 :             : 
    5391                 :             :   /* Please keep num_sign_bit_copies_binary_arith_p above in sync with
    5392                 :             :      the code in the switch below.  */
    5393                 :   286662016 :   switch (code)
    5394                 :             :     {
    5395                 :   148810079 :     case REG:
    5396                 :             : 
    5397                 :             : #if defined(POINTERS_EXTEND_UNSIGNED)
    5398                 :             :       /* If pointers extend signed and this is a pointer in Pmode, say that
    5399                 :             :          all the bits above ptr_mode are known to be sign bit copies.  */
    5400                 :             :       /* As we do not know which address space the pointer is referring to,
    5401                 :             :          we can do this only if the target does not support different pointer
    5402                 :             :          or address modes depending on the address space.  */
    5403                 :   148810079 :       if (target_default_pointer_address_modes_p ()
    5404                 :             :           && ! POINTERS_EXTEND_UNSIGNED && xmode == Pmode
    5405                 :             :           && mode == Pmode && REG_POINTER (x)
    5406                 :             :           && !targetm.have_ptr_extend ())
    5407                 :             :         return GET_MODE_PRECISION (Pmode) - GET_MODE_PRECISION (ptr_mode) + 1;
    5408                 :             : #endif
    5409                 :             : 
    5410                 :   148810079 :       {
    5411                 :   148810079 :         unsigned int copies_for_hook = 1, copies = 1;
    5412                 :   148810079 :         rtx new_rtx = rtl_hooks.reg_num_sign_bit_copies (x, xmode, mode,
    5413                 :             :                                                          &copies_for_hook);
    5414                 :             : 
    5415                 :   148810079 :         if (new_rtx)
    5416                 :           5 :           copies = cached_num_sign_bit_copies (new_rtx, mode, known_x,
    5417                 :             :                                                known_mode, known_ret);
    5418                 :             : 
    5419                 :   148810079 :         if (copies > 1 || copies_for_hook > 1)
    5420                 :    21674662 :           return MAX (copies, copies_for_hook);
    5421                 :             : 
    5422                 :             :         /* Else, use nonzero_bits to guess num_sign_bit_copies (see below).  */
    5423                 :             :       }
    5424                 :   127135417 :       break;
    5425                 :             : 
    5426                 :             :     case MEM:
    5427                 :             :       /* Some RISC machines sign-extend all loads of smaller than a word.  */
    5428                 :             :       if (load_extend_op (xmode) == SIGN_EXTEND)
    5429                 :             :         return MAX (1, ((int) bitwidth - (int) xmode_width + 1));
    5430                 :             :       break;
    5431                 :             : 
    5432                 :    20517009 :     case SUBREG:
    5433                 :             :       /* If this is a SUBREG for a promoted object that is sign-extended
    5434                 :             :          and we are looking at it in a wider mode, we know that at least the
    5435                 :             :          high-order bits are known to be sign bit copies.  */
    5436                 :             : 
    5437                 :    20517009 :       if (SUBREG_PROMOTED_VAR_P (x) && SUBREG_PROMOTED_SIGNED_P (x))
    5438                 :             :         {
    5439                 :           0 :           num0 = cached_num_sign_bit_copies (SUBREG_REG (x), mode,
    5440                 :             :                                              known_x, known_mode, known_ret);
    5441                 :           0 :           return MAX ((int) bitwidth - (int) xmode_width + 1, num0);
    5442                 :             :         }
    5443                 :             : 
    5444                 :    20517009 :       if (is_a <scalar_int_mode> (GET_MODE (SUBREG_REG (x)), &inner_mode))
    5445                 :             :         {
    5446                 :             :           /* For a smaller object, just ignore the high bits.  */
    5447                 :    20308161 :           if (bitwidth <= GET_MODE_PRECISION (inner_mode))
    5448                 :             :             {
    5449                 :     7062889 :               num0 = cached_num_sign_bit_copies (SUBREG_REG (x), inner_mode,
    5450                 :             :                                                  known_x, known_mode,
    5451                 :             :                                                  known_ret);
    5452                 :     7062889 :               return MAX (1, num0 - (int) (GET_MODE_PRECISION (inner_mode)
    5453                 :             :                                            - bitwidth));
    5454                 :             :             }
    5455                 :             : 
    5456                 :             :           /* For paradoxical SUBREGs on machines where all register operations
    5457                 :             :              affect the entire register, just look inside.  Note that we are
    5458                 :             :              passing MODE to the recursive call, so the number of sign bit
    5459                 :             :              copies will remain relative to that mode, not the inner mode.
    5460                 :             : 
    5461                 :             :              This works only if loads sign extend.  Otherwise, if we get a
    5462                 :             :              reload for the inner part, it may be loaded from the stack, and
    5463                 :             :              then we lose all sign bit copies that existed before the store
    5464                 :             :              to the stack.  */
    5465                 :             :           if (WORD_REGISTER_OPERATIONS
    5466                 :             :               && load_extend_op (inner_mode) == SIGN_EXTEND
    5467                 :             :               && paradoxical_subreg_p (x)
    5468                 :             :               && MEM_P (SUBREG_REG (x)))
    5469                 :             :             return cached_num_sign_bit_copies (SUBREG_REG (x), mode,
    5470                 :             :                                                known_x, known_mode, known_ret);
    5471                 :             :         }
    5472                 :             :       break;
    5473                 :             : 
    5474                 :        2620 :     case SIGN_EXTRACT:
    5475                 :        2620 :       if (CONST_INT_P (XEXP (x, 1)))
    5476                 :        2620 :         return MAX (1, (int) bitwidth - INTVAL (XEXP (x, 1)));
    5477                 :             :       break;
    5478                 :             : 
    5479                 :     1875445 :     case SIGN_EXTEND:
    5480                 :     1875445 :       if (is_a <scalar_int_mode> (GET_MODE (XEXP (x, 0)), &inner_mode))
    5481                 :     1875445 :         return (bitwidth - GET_MODE_PRECISION (inner_mode)
    5482                 :     1875445 :                 + cached_num_sign_bit_copies (XEXP (x, 0), inner_mode,
    5483                 :     1875445 :                                               known_x, known_mode, known_ret));
    5484                 :             :       break;
    5485                 :             : 
    5486                 :         122 :     case TRUNCATE:
    5487                 :             :       /* For a smaller object, just ignore the high bits.  */
    5488                 :         122 :       inner_mode = as_a <scalar_int_mode> (GET_MODE (XEXP (x, 0)));
    5489                 :         122 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), inner_mode,
    5490                 :             :                                          known_x, known_mode, known_ret);
    5491                 :         122 :       return MAX (1, (num0 - (int) (GET_MODE_PRECISION (inner_mode)
    5492                 :             :                                     - bitwidth)));
    5493                 :             : 
    5494                 :      960927 :     case NOT:
    5495                 :      960927 :       return cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5496                 :      960927 :                                          known_x, known_mode, known_ret);
    5497                 :             : 
    5498                 :       20147 :     case ROTATE:       case ROTATERT:
    5499                 :             :       /* If we are rotating left by a number of bits less than the number
    5500                 :             :          of sign bit copies, we can just subtract that amount from the
    5501                 :             :          number.  */
    5502                 :       20147 :       if (CONST_INT_P (XEXP (x, 1))
    5503                 :       11309 :           && INTVAL (XEXP (x, 1)) >= 0
    5504                 :       11306 :           && INTVAL (XEXP (x, 1)) < (int) bitwidth)
    5505                 :             :         {
    5506                 :       11306 :           num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5507                 :             :                                              known_x, known_mode, known_ret);
    5508                 :       11306 :           return MAX (1, num0 - (code == ROTATE ? INTVAL (XEXP (x, 1))
    5509                 :             :                                  : (int) bitwidth - INTVAL (XEXP (x, 1))));
    5510                 :             :         }
    5511                 :             :       break;
    5512                 :             : 
    5513                 :      696699 :     case NEG:
    5514                 :             :       /* In general, this subtracts one sign bit copy.  But if the value
    5515                 :             :          is known to be positive, the number of sign bit copies is the
    5516                 :             :          same as that of the input.  Finally, if the input has just one bit
    5517                 :             :          that might be nonzero, all the bits are copies of the sign bit.  */
    5518                 :      696699 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5519                 :             :                                          known_x, known_mode, known_ret);
    5520                 :      696699 :       if (bitwidth > HOST_BITS_PER_WIDE_INT)
    5521                 :       26576 :         return num0 > 1 ? num0 - 1 : 1;
    5522                 :             : 
    5523                 :      670123 :       nonzero = nonzero_bits (XEXP (x, 0), mode);
    5524                 :      670123 :       if (nonzero == 1)
    5525                 :             :         return bitwidth;
    5526                 :             : 
    5527                 :      326522 :       if (num0 > 1
    5528                 :       82838 :           && ((HOST_WIDE_INT_1U << (bitwidth - 1)) & nonzero))
    5529                 :       45484 :         num0--;
    5530                 :             : 
    5531                 :      326522 :       return num0;
    5532                 :             : 
    5533                 :     5617900 :     case IOR:   case AND:   case XOR:
    5534                 :     5617900 :     case SMIN:  case SMAX:  case UMIN:  case UMAX:
    5535                 :             :       /* Logical operations will preserve the number of sign-bit copies.
    5536                 :             :          MIN and MAX operations always return one of the operands.  */
    5537                 :     5617900 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5538                 :             :                                          known_x, known_mode, known_ret);
    5539                 :     5617900 :       num1 = cached_num_sign_bit_copies (XEXP (x, 1), mode,
    5540                 :             :                                          known_x, known_mode, known_ret);
    5541                 :             : 
    5542                 :             :       /* If num1 is clearing some of the top bits then regardless of
    5543                 :             :          the other term, we are guaranteed to have at least that many
    5544                 :             :          high-order zero bits.  */
    5545                 :     5617900 :       if (code == AND
    5546                 :     5617900 :           && num1 > 1
    5547                 :     2219885 :           && bitwidth <= HOST_BITS_PER_WIDE_INT
    5548                 :     2208056 :           && CONST_INT_P (XEXP (x, 1))
    5549                 :     2030422 :           && (UINTVAL (XEXP (x, 1))
    5550                 :     2030422 :               & (HOST_WIDE_INT_1U << (bitwidth - 1))) == 0)
    5551                 :             :         return num1;
    5552                 :             : 
    5553                 :             :       /* Similarly for IOR when setting high-order bits.  */
    5554                 :     4204286 :       if (code == IOR
    5555                 :     4204286 :           && num1 > 1
    5556                 :      454852 :           && bitwidth <= HOST_BITS_PER_WIDE_INT
    5557                 :      453010 :           && CONST_INT_P (XEXP (x, 1))
    5558                 :      135497 :           && (UINTVAL (XEXP (x, 1))
    5559                 :      135497 :               & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0)
    5560                 :             :         return num1;
    5561                 :             : 
    5562                 :     4199779 :       return MIN (num0, num1);
    5563                 :             : 
    5564                 :    39653817 :     case PLUS:  case MINUS:
    5565                 :             :       /* For addition and subtraction, we can have a 1-bit carry.  However,
    5566                 :             :          if we are subtracting 1 from a positive number, there will not
    5567                 :             :          be such a carry.  Furthermore, if the positive number is known to
    5568                 :             :          be 0 or 1, we know the result is either -1 or 0.  */
    5569                 :             : 
    5570                 :    39653817 :       if (code == PLUS && XEXP (x, 1) == constm1_rtx
    5571                 :     1199932 :           && bitwidth <= HOST_BITS_PER_WIDE_INT)
    5572                 :             :         {
    5573                 :     1195560 :           nonzero = nonzero_bits (XEXP (x, 0), mode);
    5574                 :     1195560 :           if (((HOST_WIDE_INT_1U << (bitwidth - 1)) & nonzero) == 0)
    5575                 :       63818 :             return (nonzero == 1 || nonzero == 0 ? bitwidth
    5576                 :       59440 :                     : bitwidth - floor_log2 (nonzero) - 1);
    5577                 :             :         }
    5578                 :             : 
    5579                 :    39589999 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5580                 :             :                                          known_x, known_mode, known_ret);
    5581                 :    39589999 :       num1 = cached_num_sign_bit_copies (XEXP (x, 1), mode,
    5582                 :             :                                          known_x, known_mode, known_ret);
    5583                 :    39589999 :       result = MAX (1, MIN (num0, num1) - 1);
    5584                 :             : 
    5585                 :    39589999 :       return result;
    5586                 :             : 
    5587                 :     1243993 :     case MULT:
    5588                 :             :       /* The number of bits of the product is the sum of the number of
    5589                 :             :          bits of both terms.  However, unless one of the terms if known
    5590                 :             :          to be positive, we must allow for an additional bit since negating
    5591                 :             :          a negative number can remove one sign bit copy.  */
    5592                 :             : 
    5593                 :     1243993 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5594                 :             :                                          known_x, known_mode, known_ret);
    5595                 :     1243993 :       num1 = cached_num_sign_bit_copies (XEXP (x, 1), mode,
    5596                 :             :                                          known_x, known_mode, known_ret);
    5597                 :             : 
    5598                 :     1243993 :       result = bitwidth - (bitwidth - num0) - (bitwidth - num1);
    5599                 :     1243993 :       if (result > 0
    5600                 :     1243993 :           && (bitwidth > HOST_BITS_PER_WIDE_INT
    5601                 :      389489 :               || (((nonzero_bits (XEXP (x, 0), mode)
    5602                 :      389489 :                     & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0)
    5603                 :      203982 :                   && ((nonzero_bits (XEXP (x, 1), mode)
    5604                 :             :                        & (HOST_WIDE_INT_1U << (bitwidth - 1)))
    5605                 :      203982 :                       != 0))))
    5606                 :       31568 :         result--;
    5607                 :             : 
    5608                 :     1243993 :       return MAX (1, result);
    5609                 :             : 
    5610                 :      113569 :     case UDIV:
    5611                 :             :       /* The result must be <= the first operand.  If the first operand
    5612                 :             :          has the high bit set, we know nothing about the number of sign
    5613                 :             :          bit copies.  */
    5614                 :      113569 :       if (bitwidth > HOST_BITS_PER_WIDE_INT)
    5615                 :             :         return 1;
    5616                 :      113569 :       else if ((nonzero_bits (XEXP (x, 0), mode)
    5617                 :      113569 :                 & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0)
    5618                 :             :         return 1;
    5619                 :             :       else
    5620                 :       19228 :         return cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5621                 :       19228 :                                            known_x, known_mode, known_ret);
    5622                 :             : 
    5623                 :      106688 :     case UMOD:
    5624                 :             :       /* The result must be <= the second operand.  If the second operand
    5625                 :             :          has (or just might have) the high bit set, we know nothing about
    5626                 :             :          the number of sign bit copies.  */
    5627                 :      106688 :       if (bitwidth > HOST_BITS_PER_WIDE_INT)
    5628                 :             :         return 1;
    5629                 :      106688 :       else if ((nonzero_bits (XEXP (x, 1), mode)
    5630                 :      106688 :                 & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0)
    5631                 :             :         return 1;
    5632                 :             :       else
    5633                 :       27692 :         return cached_num_sign_bit_copies (XEXP (x, 1), mode,
    5634                 :       27692 :                                            known_x, known_mode, known_ret);
    5635                 :             : 
    5636                 :      165289 :     case DIV:
    5637                 :             :       /* Similar to unsigned division, except that we have to worry about
    5638                 :             :          the case where the divisor is negative, in which case we have
    5639                 :             :          to add 1.  */
    5640                 :      165289 :       result = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5641                 :             :                                            known_x, known_mode, known_ret);
    5642                 :      165289 :       if (result > 1
    5643                 :      165289 :           && (bitwidth > HOST_BITS_PER_WIDE_INT
    5644                 :       17644 :               || (nonzero_bits (XEXP (x, 1), mode)
    5645                 :       17644 :                   & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0))
    5646                 :       14694 :         result--;
    5647                 :             : 
    5648                 :      165289 :       return result;
    5649                 :             : 
    5650                 :      113831 :     case MOD:
    5651                 :      113831 :       result = cached_num_sign_bit_copies (XEXP (x, 1), mode,
    5652                 :             :                                            known_x, known_mode, known_ret);
    5653                 :      113831 :       if (result > 1
    5654                 :      113831 :           && (bitwidth > HOST_BITS_PER_WIDE_INT
    5655                 :       22539 :               || (nonzero_bits (XEXP (x, 1), mode)
    5656                 :       22539 :                   & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0))
    5657                 :        9492 :         result--;
    5658                 :             : 
    5659                 :      113831 :       return result;
    5660                 :             : 
    5661                 :      851205 :     case ASHIFTRT:
    5662                 :             :       /* Shifts by a constant add to the number of bits equal to the
    5663                 :             :          sign bit.  */
    5664                 :      851205 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5665                 :             :                                          known_x, known_mode, known_ret);
    5666                 :      851205 :       if (CONST_INT_P (XEXP (x, 1))
    5667                 :      815656 :           && INTVAL (XEXP (x, 1)) > 0
    5668                 :      815656 :           && INTVAL (XEXP (x, 1)) < xmode_width)
    5669                 :      815656 :         num0 = MIN ((int) bitwidth, num0 + INTVAL (XEXP (x, 1)));
    5670                 :             : 
    5671                 :      851205 :       return num0;
    5672                 :             : 
    5673                 :     9599385 :     case ASHIFT:
    5674                 :             :       /* Left shifts destroy copies.  */
    5675                 :     9599385 :       if (!CONST_INT_P (XEXP (x, 1))
    5676                 :     9433441 :           || INTVAL (XEXP (x, 1)) < 0
    5677                 :     9433434 :           || INTVAL (XEXP (x, 1)) >= (int) bitwidth
    5678                 :     9433392 :           || INTVAL (XEXP (x, 1)) >= xmode_width)
    5679                 :             :         return 1;
    5680                 :             : 
    5681                 :     9433392 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5682                 :             :                                          known_x, known_mode, known_ret);
    5683                 :     9433392 :       return MAX (1, num0 - INTVAL (XEXP (x, 1)));
    5684                 :             : 
    5685                 :      629544 :     case IF_THEN_ELSE:
    5686                 :      629544 :       num0 = cached_num_sign_bit_copies (XEXP (x, 1), mode,
    5687                 :             :                                          known_x, known_mode, known_ret);
    5688                 :      629544 :       num1 = cached_num_sign_bit_copies (XEXP (x, 2), mode,
    5689                 :             :                                          known_x, known_mode, known_ret);
    5690                 :      629544 :       return MIN (num0, num1);
    5691                 :             : 
    5692                 :     2158305 :     case EQ:  case NE:  case GE:  case GT:  case LE:  case LT:
    5693                 :     2158305 :     case UNEQ:  case LTGT:  case UNGE:  case UNGT:  case UNLE:  case UNLT:
    5694                 :     2158305 :     case GEU: case GTU: case LEU: case LTU:
    5695                 :     2158305 :     case UNORDERED: case ORDERED:
    5696                 :             :       /* If the constant is negative, take its 1's complement and remask.
    5697                 :             :          Then see how many zero bits we have.  */
    5698                 :     2158305 :       nonzero = STORE_FLAG_VALUE;
    5699                 :     2158305 :       if (bitwidth <= HOST_BITS_PER_WIDE_INT
    5700                 :     2158305 :           && (nonzero & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0)
    5701                 :           0 :         nonzero = (~nonzero) & GET_MODE_MASK (mode);
    5702                 :             : 
    5703                 :     2158305 :       return (nonzero == 0 ? bitwidth : bitwidth - floor_log2 (nonzero) - 1);
    5704                 :             : 
    5705                 :             :     default:
    5706                 :             :       break;
    5707                 :             :     }
    5708                 :             : 
    5709                 :             :   /* If we haven't been able to figure it out by one of the above rules,
    5710                 :             :      see if some of the high-order bits are known to be zero.  If so,
    5711                 :             :      count those bits and return one less than that amount.  If we can't
    5712                 :             :      safely compute the mask for this mode, always return BITWIDTH.  */
    5713                 :             : 
    5714                 :   194123820 :   bitwidth = GET_MODE_PRECISION (mode);
    5715                 :   194123820 :   if (bitwidth > HOST_BITS_PER_WIDE_INT)
    5716                 :             :     return 1;
    5717                 :             : 
    5718                 :   188305529 :   nonzero = nonzero_bits (x, mode);
    5719                 :   188305529 :   return nonzero & (HOST_WIDE_INT_1U << (bitwidth - 1))
    5720                 :   193112407 :          ? 1 : bitwidth - floor_log2 (nonzero) - 1;
    5721                 :             : }
    5722                 :             : 
    5723                 :             : /* Calculate the rtx_cost of a single instruction pattern.  A return value of
    5724                 :             :    zero indicates an instruction pattern without a known cost.  */
    5725                 :             : 
    5726                 :             : int
    5727                 :   137242676 : pattern_cost (rtx pat, bool speed)
    5728                 :             : {
    5729                 :   137242676 :   int i, cost;
    5730                 :   137242676 :   rtx set;
    5731                 :             : 
    5732                 :             :   /* Extract the single set rtx from the instruction pattern.  We
    5733                 :             :      can't use single_set since we only have the pattern.  We also
    5734                 :             :      consider PARALLELs of a normal set and a single comparison.  In
    5735                 :             :      that case we use the cost of the non-comparison SET operation,
    5736                 :             :      which is most-likely to be the real cost of this operation.  */
    5737                 :   137242676 :   if (GET_CODE (pat) == SET)
    5738                 :             :     set = pat;
    5739                 :    58019427 :   else if (GET_CODE (pat) == PARALLEL)
    5740                 :             :     {
    5741                 :             :       set = NULL_RTX;
    5742                 :             :       rtx comparison = NULL_RTX;
    5743                 :             : 
    5744                 :    43505056 :       for (i = 0; i < XVECLEN (pat, 0); i++)
    5745                 :             :         {
    5746                 :    29301640 :           rtx x = XVECEXP (pat, 0, i);
    5747                 :    29301640 :           if (GET_CODE (x) == SET)
    5748                 :             :             {
    5749                 :    14797713 :               if (GET_CODE (SET_SRC (x)) == COMPARE)
    5750                 :             :                 {
    5751                 :      264730 :                   if (comparison)
    5752                 :             :                     return 0;
    5753                 :             :                   comparison = x;
    5754                 :             :                 }
    5755                 :             :               else
    5756                 :             :                 {
    5757                 :    14532983 :                   if (set)
    5758                 :             :                     return 0;
    5759                 :             :                   set = x;
    5760                 :             :                 }
    5761                 :             :             }
    5762                 :             :         }
    5763                 :             : 
    5764                 :    14203416 :       if (!set && comparison)
    5765                 :             :         set = comparison;
    5766                 :             : 
    5767                 :    14075055 :       if (!set)
    5768                 :             :         return 0;
    5769                 :             :     }
    5770                 :             :   else
    5771                 :             :     return 0;
    5772                 :             : 
    5773                 :    93353145 :   cost = set_src_cost (SET_SRC (set), GET_MODE (SET_DEST (set)), speed);
    5774                 :    93353145 :   return cost > 0 ? cost : COSTS_N_INSNS (1);
    5775                 :             : }
    5776                 :             : 
    5777                 :             : /* Calculate the cost of a single instruction.  A return value of zero
    5778                 :             :    indicates an instruction pattern without a known cost.  */
    5779                 :             : 
    5780                 :             : int
    5781                 :   135210604 : insn_cost (rtx_insn *insn, bool speed)
    5782                 :             : {
    5783                 :   135210604 :   if (targetm.insn_cost)
    5784                 :   135210604 :     return targetm.insn_cost (insn, speed);
    5785                 :             : 
    5786                 :           0 :   return pattern_cost (PATTERN (insn), speed);
    5787                 :             : }
    5788                 :             : 
    5789                 :             : /* Returns estimate on cost of computing SEQ.  */
    5790                 :             : 
    5791                 :             : unsigned
    5792                 :     1709961 : seq_cost (const rtx_insn *seq, bool speed)
    5793                 :             : {
    5794                 :     1709961 :   unsigned cost = 0;
    5795                 :     1709961 :   rtx set;
    5796                 :             : 
    5797                 :     4898221 :   for (; seq; seq = NEXT_INSN (seq))
    5798                 :             :     {
    5799                 :     3188260 :       set = single_set (seq);
    5800                 :     3188260 :       if (set)
    5801                 :     3178979 :         cost += set_rtx_cost (set, speed);
    5802                 :        9281 :       else if (NONDEBUG_INSN_P (seq))
    5803                 :             :         {
    5804                 :        9079 :           int this_cost = insn_cost (CONST_CAST_RTX_INSN (seq), speed);
    5805                 :        9079 :           if (this_cost > 0)
    5806                 :        3981 :             cost += this_cost;
    5807                 :             :           else
    5808                 :        5098 :             cost++;
    5809                 :             :         }
    5810                 :             :     }
    5811                 :             : 
    5812                 :     1709961 :   return cost;
    5813                 :             : }
    5814                 :             : 
    5815                 :             : /* Given an insn INSN and condition COND, return the condition in a
    5816                 :             :    canonical form to simplify testing by callers.  Specifically:
    5817                 :             : 
    5818                 :             :    (1) The code will always be a comparison operation (EQ, NE, GT, etc.).
    5819                 :             :    (2) Both operands will be machine operands.
    5820                 :             :    (3) If an operand is a constant, it will be the second operand.
    5821                 :             :    (4) (LE x const) will be replaced with (LT x <const+1>) and similarly
    5822                 :             :        for GE, GEU, and LEU.
    5823                 :             : 
    5824                 :             :    If the condition cannot be understood, or is an inequality floating-point
    5825                 :             :    comparison which needs to be reversed, 0 will be returned.
    5826                 :             : 
    5827                 :             :    If REVERSE is nonzero, then reverse the condition prior to canonizing it.
    5828                 :             : 
    5829                 :             :    If EARLIEST is nonzero, it is a pointer to a place where the earliest
    5830                 :             :    insn used in locating the condition was found.  If a replacement test
    5831                 :             :    of the condition is desired, it should be placed in front of that
    5832                 :             :    insn and we will be sure that the inputs are still valid.
    5833                 :             : 
    5834                 :             :    If WANT_REG is nonzero, we wish the condition to be relative to that
    5835                 :             :    register, if possible.  Therefore, do not canonicalize the condition
    5836                 :             :    further.  If ALLOW_CC_MODE is nonzero, allow the condition returned
    5837                 :             :    to be a compare to a CC mode register.
    5838                 :             : 
    5839                 :             :    If VALID_AT_INSN_P, the condition must be valid at both *EARLIEST
    5840                 :             :    and at INSN.  */
    5841                 :             : 
    5842                 :             : rtx
    5843                 :    34552163 : canonicalize_condition (rtx_insn *insn, rtx cond, int reverse,
    5844                 :             :                         rtx_insn **earliest,
    5845                 :             :                         rtx want_reg, int allow_cc_mode, int valid_at_insn_p)
    5846                 :             : {
    5847                 :    34552163 :   enum rtx_code code;
    5848                 :    34552163 :   rtx_insn *prev = insn;
    5849                 :    34552163 :   const_rtx set;
    5850                 :    34552163 :   rtx tem;
    5851                 :    34552163 :   rtx op0, op1;
    5852                 :    34552163 :   int reverse_code = 0;
    5853                 :    34552163 :   machine_mode mode;
    5854                 :    34552163 :   basic_block bb = BLOCK_FOR_INSN (insn);
    5855                 :             : 
    5856                 :    34552163 :   code = GET_CODE (cond);
    5857                 :    34552163 :   mode = GET_MODE (cond);
    5858                 :    34552163 :   op0 = XEXP (cond, 0);
    5859                 :    34552163 :   op1 = XEXP (cond, 1);
    5860                 :             : 
    5861                 :    34552163 :   if (reverse)
    5862                 :     1811915 :     code = reversed_comparison_code (cond, insn);
    5863                 :    34552163 :   if (code == UNKNOWN)
    5864                 :             :     return 0;
    5865                 :             : 
    5866                 :    34552163 :   if (earliest)
    5867                 :    16616962 :     *earliest = insn;
    5868                 :             : 
    5869                 :             :   /* If we are comparing a register with zero, see if the register is set
    5870                 :             :      in the previous insn to a COMPARE or a comparison operation.  Perform
    5871                 :             :      the same tests as a function of STORE_FLAG_VALUE as find_comparison_args
    5872                 :             :      in cse.cc  */
    5873                 :             : 
    5874                 :    73446835 :   while ((GET_RTX_CLASS (code) == RTX_COMPARE
    5875                 :             :           || GET_RTX_CLASS (code) == RTX_COMM_COMPARE)
    5876                 :    73446835 :          && op1 == CONST0_RTX (GET_MODE (op0))
    5877                 :   129457834 :          && op0 != want_reg)
    5878                 :             :     {
    5879                 :             :       /* Set nonzero when we find something of interest.  */
    5880                 :    56010999 :       rtx x = 0;
    5881                 :             : 
    5882                 :             :       /* If this is a COMPARE, pick up the two things being compared.  */
    5883                 :    56010999 :       if (GET_CODE (op0) == COMPARE)
    5884                 :             :         {
    5885                 :           0 :           op1 = XEXP (op0, 1);
    5886                 :           0 :           op0 = XEXP (op0, 0);
    5887                 :           0 :           continue;
    5888                 :             :         }
    5889                 :    56010999 :       else if (!REG_P (op0))
    5890                 :             :         break;
    5891                 :             : 
    5892                 :             :       /* Go back to the previous insn.  Stop if it is not an INSN.  We also
    5893                 :             :          stop if it isn't a single set or if it has a REG_INC note because
    5894                 :             :          we don't want to bother dealing with it.  */
    5895                 :             : 
    5896                 :    51145569 :       prev = prev_nonnote_nondebug_insn (prev);
    5897                 :             : 
    5898                 :    51145569 :       if (prev == 0
    5899                 :    51048606 :           || !NONJUMP_INSN_P (prev)
    5900                 :             :           || FIND_REG_INC_NOTE (prev, NULL_RTX)
    5901                 :             :           /* In cfglayout mode, there do not have to be labels at the
    5902                 :             :              beginning of a block, or jumps at the end, so the previous
    5903                 :             :              conditions would not stop us when we reach bb boundary.  */
    5904                 :    97524894 :           || BLOCK_FOR_INSN (prev) != bb)
    5905                 :             :         break;
    5906                 :             : 
    5907                 :    46282480 :       set = set_of (op0, prev);
    5908                 :             : 
    5909                 :    46282480 :       if (set
    5910                 :    46282480 :           && (GET_CODE (set) != SET
    5911                 :    40240989 :               || !rtx_equal_p (SET_DEST (set), op0)))
    5912                 :             :         break;
    5913                 :             : 
    5914                 :             :       /* If this is setting OP0, get what it sets it to if it looks
    5915                 :             :          relevant.  */
    5916                 :    46187928 :       if (set)
    5917                 :             :         {
    5918                 :    40146437 :           machine_mode inner_mode = GET_MODE (SET_DEST (set));
    5919                 :             : #ifdef FLOAT_STORE_FLAG_VALUE
    5920                 :             :           REAL_VALUE_TYPE fsfv;
    5921                 :             : #endif
    5922                 :             : 
    5923                 :             :           /* ??? We may not combine comparisons done in a CCmode with
    5924                 :             :              comparisons not done in a CCmode.  This is to aid targets
    5925                 :             :              like Alpha that have an IEEE compliant EQ instruction, and
    5926                 :             :              a non-IEEE compliant BEQ instruction.  The use of CCmode is
    5927                 :             :              actually artificial, simply to prevent the combination, but
    5928                 :             :              should not affect other platforms.
    5929                 :             : 
    5930                 :             :              However, we must allow VOIDmode comparisons to match either
    5931                 :             :              CCmode or non-CCmode comparison, because some ports have
    5932                 :             :              modeless comparisons inside branch patterns.
    5933                 :             : 
    5934                 :             :              ??? This mode check should perhaps look more like the mode check
    5935                 :             :              in simplify_comparison in combine.  */
    5936                 :    40146437 :           if (((GET_MODE_CLASS (mode) == MODE_CC)
    5937                 :    40146437 :                != (GET_MODE_CLASS (inner_mode) == MODE_CC))
    5938                 :    33930257 :               && mode != VOIDmode
    5939                 :           0 :               && inner_mode != VOIDmode)
    5940                 :             :             break;
    5941                 :    40146437 :           if (GET_CODE (SET_SRC (set)) == COMPARE
    5942                 :    40146437 :               || (((code == NE
    5943                 :     4530812 :                     || (code == LT
    5944                 :      146428 :                         && val_signbit_known_set_p (inner_mode,
    5945                 :             :                                                     STORE_FLAG_VALUE))
    5946                 :             : #ifdef FLOAT_STORE_FLAG_VALUE
    5947                 :             :                     || (code == LT
    5948                 :             :                         && SCALAR_FLOAT_MODE_P (inner_mode)
    5949                 :             :                         && (fsfv = FLOAT_STORE_FLAG_VALUE (inner_mode),
    5950                 :             :                             REAL_VALUE_NEGATIVE (fsfv)))
    5951                 :             : #endif
    5952                 :             :                     ))
    5953                 :     2706644 :                   && COMPARISON_P (SET_SRC (set))))
    5954                 :    33237736 :             x = SET_SRC (set);
    5955                 :     6908701 :           else if (((code == EQ
    5956                 :     3822159 :                      || (code == GE
    5957                 :      130095 :                          && val_signbit_known_set_p (inner_mode,
    5958                 :             :                                                      STORE_FLAG_VALUE))
    5959                 :             : #ifdef FLOAT_STORE_FLAG_VALUE
    5960                 :             :                      || (code == GE
    5961                 :             :                          && SCALAR_FLOAT_MODE_P (inner_mode)
    5962                 :             :                          && (fsfv = FLOAT_STORE_FLAG_VALUE (inner_mode),
    5963                 :             :                              REAL_VALUE_NEGATIVE (fsfv)))
    5964                 :             : #endif
    5965                 :             :                      ))
    5966                 :     6908701 :                    && COMPARISON_P (SET_SRC (set)))
    5967                 :             :             {
    5968                 :             :               reverse_code = 1;
    5969                 :             :               x = SET_SRC (set);
    5970                 :             :             }
    5971                 :     6570333 :           else if ((code == EQ || code == NE)
    5972                 :     5126063 :                    && GET_CODE (SET_SRC (set)) == XOR)
    5973                 :             :             /* Handle sequences like:
    5974                 :             : 
    5975                 :             :                (set op0 (xor X Y))
    5976                 :             :                ...(eq|ne op0 (const_int 0))...
    5977                 :             : 
    5978                 :             :                in which case:
    5979                 :             : 
    5980                 :             :                (eq op0 (const_int 0)) reduces to (eq X Y)
    5981                 :             :                (ne op0 (const_int 0)) reduces to (ne X Y)
    5982                 :             : 
    5983                 :             :                This is the form used by MIPS16, for example.  */
    5984                 :             :             x = SET_SRC (set);
    5985                 :             :           else
    5986                 :             :             break;
    5987                 :             :         }
    5988                 :             : 
    5989                 :     6041491 :       else if (reg_set_p (op0, prev))
    5990                 :             :         /* If this sets OP0, but not directly, we have to give up.  */
    5991                 :             :         break;
    5992                 :             : 
    5993                 :    39627133 :       if (x)
    5994                 :             :         {
    5995                 :             :           /* If the caller is expecting the condition to be valid at INSN,
    5996                 :             :              make sure X doesn't change before INSN.  */
    5997                 :    33585642 :           if (valid_at_insn_p)
    5998                 :    21635531 :             if (modified_in_p (x, prev) || modified_between_p (x, prev, insn))
    5999                 :             :               break;
    6000                 :    32853181 :           if (COMPARISON_P (x))
    6001                 :      135549 :             code = GET_CODE (x);
    6002                 :    32853181 :           if (reverse_code)
    6003                 :             :             {
    6004                 :       87259 :               code = reversed_comparison_code (x, prev);
    6005                 :       87259 :               if (code == UNKNOWN)
    6006                 :             :                 return 0;
    6007                 :             :               reverse_code = 0;
    6008                 :             :             }
    6009                 :             : 
    6010                 :    32853181 :           op0 = XEXP (x, 0), op1 = XEXP (x, 1);
    6011                 :    32853181 :           if (earliest)
    6012                 :    16053181 :             *earliest = prev;
    6013                 :             :         }
    6014                 :             :     }
    6015                 :             : 
    6016                 :             :   /* If constant is first, put it last.  */
    6017                 :    34552163 :   if (CONSTANT_P (op0))
    6018                 :           0 :     code = swap_condition (code), tem = op0, op0 = op1, op1 = tem;
    6019                 :             : 
    6020                 :             :   /* If OP0 is the result of a comparison, we weren't able to find what
    6021                 :             :      was really being compared, so fail.  */
    6022                 :    34552163 :   if (!allow_cc_mode
    6023                 :    18631994 :       && GET_MODE_CLASS (GET_MODE (op0)) == MODE_CC)
    6024                 :             :     return 0;
    6025                 :             : 
    6026                 :             :   /* Canonicalize any ordered comparison with integers involving equality
    6027                 :             :      if we can do computations in the relevant mode and we do not
    6028                 :             :      overflow.  */
    6029                 :             : 
    6030                 :    33367300 :   scalar_int_mode op0_mode;
    6031                 :    33367300 :   if (CONST_INT_P (op1)
    6032                 :    22989718 :       && is_a <scalar_int_mode> (GET_MODE (op0), &op0_mode)
    6033                 :    55790143 :       && GET_MODE_PRECISION (op0_mode) <= HOST_BITS_PER_WIDE_INT)
    6034                 :             :     {
    6035                 :    22397366 :       HOST_WIDE_INT const_val = INTVAL (op1);
    6036                 :    22397366 :       unsigned HOST_WIDE_INT uconst_val = const_val;
    6037                 :    22397366 :       unsigned HOST_WIDE_INT max_val
    6038                 :    22397366 :         = (unsigned HOST_WIDE_INT) GET_MODE_MASK (op0_mode);
    6039                 :             : 
    6040                 :    22397366 :       switch (code)
    6041                 :             :         {
    6042                 :      786773 :         case LE:
    6043                 :      786773 :           if ((unsigned HOST_WIDE_INT) const_val != max_val >> 1)
    6044                 :      786773 :             code = LT, op1 = gen_int_mode (const_val + 1, op0_mode);
    6045                 :             :           break;
    6046                 :             : 
    6047                 :             :         /* When cross-compiling, const_val might be sign-extended from
    6048                 :             :            BITS_PER_WORD to HOST_BITS_PER_WIDE_INT */
    6049                 :      303970 :         case GE:
    6050                 :      303970 :           if ((const_val & max_val)
    6051                 :      303970 :               != (HOST_WIDE_INT_1U << (GET_MODE_PRECISION (op0_mode) - 1)))
    6052                 :      303970 :             code = GT, op1 = gen_int_mode (const_val - 1, op0_mode);
    6053                 :             :           break;
    6054                 :             : 
    6055                 :      541305 :         case LEU:
    6056                 :      541305 :           if (uconst_val < max_val)
    6057                 :      528623 :             code = LTU, op1 = gen_int_mode (uconst_val + 1, op0_mode);
    6058                 :             :           break;
    6059                 :             : 
    6060                 :       58708 :         case GEU:
    6061                 :       58708 :           if (uconst_val != 0)
    6062                 :       58708 :             code = GTU, op1 = gen_int_mode (uconst_val - 1, op0_mode);
    6063                 :             :           break;
    6064                 :             : 
    6065                 :             :         default:
    6066                 :             :           break;
    6067                 :             :         }
    6068                 :             :     }
    6069                 :             : 
    6070                 :             :   /* We promised to return a comparison.  */
    6071                 :    33367300 :   rtx ret = gen_rtx_fmt_ee (code, VOIDmode, op0, op1);
    6072                 :    33367300 :   if (COMPARISON_P (ret))
    6073                 :             :     return ret;
    6074                 :             :   return 0;
    6075                 :             : }
    6076                 :             : 
    6077                 :             : /* Given a jump insn JUMP, return the condition that will cause it to branch
    6078                 :             :    to its JUMP_LABEL.  If the condition cannot be understood, or is an
    6079                 :             :    inequality floating-point comparison which needs to be reversed, 0 will
    6080                 :             :    be returned.
    6081                 :             : 
    6082                 :             :    If EARLIEST is nonzero, it is a pointer to a place where the earliest
    6083                 :             :    insn used in locating the condition was found.  If a replacement test
    6084                 :             :    of the condition is desired, it should be placed in front of that
    6085                 :             :    insn and we will be sure that the inputs are still valid.  If EARLIEST
    6086                 :             :    is null, the returned condition will be valid at INSN.
    6087                 :             : 
    6088                 :             :    If ALLOW_CC_MODE is nonzero, allow the condition returned to be a
    6089                 :             :    compare CC mode register.
    6090                 :             : 
    6091                 :             :    VALID_AT_INSN_P is the same as for canonicalize_condition.  */
    6092                 :             : 
    6093                 :             : rtx
    6094                 :    33993239 : get_condition (rtx_insn *jump, rtx_insn **earliest, int allow_cc_mode,
    6095                 :             :                int valid_at_insn_p)
    6096                 :             : {
    6097                 :    33993239 :   rtx cond;
    6098                 :    33993239 :   int reverse;
    6099                 :    33993239 :   rtx set;
    6100                 :             : 
    6101                 :             :   /* If this is not a standard conditional jump, we can't parse it.  */
    6102                 :    33993239 :   if (!JUMP_P (jump)
    6103                 :    33993239 :       || ! any_condjump_p (jump))
    6104                 :     3740171 :     return 0;
    6105                 :    30253068 :   set = pc_set (jump);
    6106                 :             : 
    6107                 :    30253068 :   cond = XEXP (SET_SRC (set), 0);
    6108                 :             : 
    6109                 :             :   /* If this branches to JUMP_LABEL when the condition is false, reverse
    6110                 :             :      the condition.  */
    6111                 :    30253068 :   reverse
    6112                 :    60506136 :     = GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF
    6113                 :    30253068 :       && label_ref_label (XEXP (SET_SRC (set), 2)) == JUMP_LABEL (jump);
    6114                 :             : 
    6115                 :    30253068 :   return canonicalize_condition (jump, cond, reverse, earliest, NULL_RTX,
    6116                 :    30253068 :                                  allow_cc_mode, valid_at_insn_p);
    6117                 :             : }
    6118                 :             : 
    6119                 :             : /* Initialize the table NUM_SIGN_BIT_COPIES_IN_REP based on
    6120                 :             :    TARGET_MODE_REP_EXTENDED.
    6121                 :             : 
    6122                 :             :    Note that we assume that the property of
    6123                 :             :    TARGET_MODE_REP_EXTENDED(B, C) is sticky to the integral modes
    6124                 :             :    narrower than mode B.  I.e., if A is a mode narrower than B then in
    6125                 :             :    order to be able to operate on it in mode B, mode A needs to
    6126                 :             :    satisfy the requirements set by the representation of mode B.  */
    6127                 :             : 
    6128                 :             : static void
    6129                 :      274512 : init_num_sign_bit_copies_in_rep (void)
    6130                 :             : {
    6131                 :      274512 :   opt_scalar_int_mode in_mode_iter;
    6132                 :      274512 :   scalar_int_mode mode;
    6133                 :             : 
    6134                 :     2196096 :   FOR_EACH_MODE_IN_CLASS (in_mode_iter, MODE_INT)
    6135                 :     7686336 :     FOR_EACH_MODE_UNTIL (mode, in_mode_iter.require ())
    6136                 :             :       {
    6137                 :     5764752 :         scalar_int_mode in_mode = in_mode_iter.require ();
    6138                 :     5764752 :         scalar_int_mode i;
    6139                 :             : 
    6140                 :             :         /* Currently, it is assumed that TARGET_MODE_REP_EXTENDED
    6141                 :             :            extends to the next widest mode.  */
    6142                 :     5764752 :         gcc_assert (targetm.mode_rep_extended (mode, in_mode) == UNKNOWN
    6143                 :             :                     || GET_MODE_WIDER_MODE (mode).require () == in_mode);
    6144                 :             : 
    6145                 :             :         /* We are in in_mode.  Count how many bits outside of mode
    6146                 :             :            have to be copies of the sign-bit.  */
    6147                 :    21137424 :         FOR_EACH_MODE (i, mode, in_mode)
    6148                 :             :           {
    6149                 :             :             /* This must always exist (for the last iteration it will be
    6150                 :             :                IN_MODE).  */
    6151                 :    15372672 :             scalar_int_mode wider = GET_MODE_WIDER_MODE (i).require ();
    6152                 :             : 
    6153                 :    15372672 :             if (targetm.mode_rep_extended (i, wider) == SIGN_EXTEND
    6154                 :             :                 /* We can only check sign-bit copies starting from the
    6155                 :             :                    top-bit.  In order to be able to check the bits we
    6156                 :             :                    have already seen we pretend that subsequent bits
    6157                 :             :                    have to be sign-bit copies too.  */
    6158                 :    15372672 :                 || num_sign_bit_copies_in_rep [in_mode][mode])
    6159                 :           0 :               num_sign_bit_copies_in_rep [in_mode][mode]
    6160                 :           0 :                 += GET_MODE_PRECISION (wider) - GET_MODE_PRECISION (i);
    6161                 :             :           }
    6162                 :             :       }
    6163                 :      274512 : }
    6164                 :             : 
    6165                 :             : /* Suppose that truncation from the machine mode of X to MODE is not a
    6166                 :             :    no-op.  See if there is anything special about X so that we can
    6167                 :             :    assume it already contains a truncated value of MODE.  */
    6168                 :             : 
    6169                 :             : bool
    6170                 :           0 : truncated_to_mode (machine_mode mode, const_rtx x)
    6171                 :             : {
    6172                 :             :   /* This register has already been used in MODE without explicit
    6173                 :             :      truncation.  */
    6174                 :           0 :   if (REG_P (x) && rtl_hooks.reg_truncated_to_mode (mode, x))
    6175                 :             :     return true;
    6176                 :             : 
    6177                 :             :   /* See if we already satisfy the requirements of MODE.  If yes we
    6178                 :             :      can just switch to MODE.  */
    6179                 :           0 :   if (num_sign_bit_copies_in_rep[GET_MODE (x)][mode]
    6180                 :           0 :       && (num_sign_bit_copies (x, GET_MODE (x))
    6181                 :           0 :           >= num_sign_bit_copies_in_rep[GET_MODE (x)][mode] + 1))
    6182                 :             :     return true;
    6183                 :             : 
    6184                 :             :   return false;
    6185                 :             : }
    6186                 :             : 
    6187                 :             : /* Return true if RTX code CODE has a single sequence of zero or more
    6188                 :             :    "e" operands and no rtvec operands.  Initialize its rtx_all_subrtx_bounds
    6189                 :             :    entry in that case.  */
    6190                 :             : 
    6191                 :             : static bool
    6192                 :    42274848 : setup_reg_subrtx_bounds (unsigned int code)
    6193                 :             : {
    6194                 :    42274848 :   const char *format = GET_RTX_FORMAT ((enum rtx_code) code);
    6195                 :    42274848 :   unsigned int i = 0;
    6196                 :    59569104 :   for (; format[i] != 'e'; ++i)
    6197                 :             :     {
    6198                 :    26627664 :       if (!format[i])
    6199                 :             :         /* No subrtxes.  Leave start and count as 0.  */
    6200                 :             :         return true;
    6201                 :    19490352 :       if (format[i] == 'E' || format[i] == 'V')
    6202                 :             :         return false;
    6203                 :             :     }
    6204                 :             : 
    6205                 :             :   /* Record the sequence of 'e's.  */
    6206                 :    32941440 :   rtx_all_subrtx_bounds[code].start = i;
    6207                 :    53529840 :   do
    6208                 :    53529840 :     ++i;
    6209                 :    53529840 :   while (format[i] == 'e');
    6210                 :    32941440 :   rtx_all_subrtx_bounds[code].count = i - rtx_all_subrtx_bounds[code].start;
    6211                 :             :   /* rtl-iter.h relies on this.  */
    6212                 :    32941440 :   gcc_checking_assert (rtx_all_subrtx_bounds[code].count <= 3);
    6213                 :             : 
    6214                 :    36784608 :   for (; format[i]; ++i)
    6215                 :     5215728 :     if (format[i] == 'E' || format[i] == 'V' || format[i] == 'e')
    6216                 :             :       return false;
    6217                 :             : 
    6218                 :             :   return true;
    6219                 :             : }
    6220                 :             : 
    6221                 :             : /* Initialize rtx_all_subrtx_bounds.  */
    6222                 :             : void
    6223                 :      274512 : init_rtlanal (void)
    6224                 :             : {
    6225                 :      274512 :   int i;
    6226                 :    42549360 :   for (i = 0; i < NUM_RTX_CODE; i++)
    6227                 :             :     {
    6228                 :    42274848 :       if (!setup_reg_subrtx_bounds (i))
    6229                 :     3568656 :         rtx_all_subrtx_bounds[i].count = UCHAR_MAX;
    6230                 :    42274848 :       if (GET_RTX_CLASS (i) != RTX_CONST_OBJ)
    6231                 :    39529728 :         rtx_nonconst_subrtx_bounds[i] = rtx_all_subrtx_bounds[i];
    6232                 :             :     }
    6233                 :             : 
    6234                 :      274512 :   init_num_sign_bit_copies_in_rep ();
    6235                 :      274512 : }
    6236                 :             : 
    6237                 :             : /* Check whether this is a constant pool constant.  */
    6238                 :             : bool
    6239                 :       11658 : constant_pool_constant_p (rtx x)
    6240                 :             : {
    6241                 :       11658 :   x = avoid_constant_pool_reference (x);
    6242                 :       11658 :   return CONST_DOUBLE_P (x);
    6243                 :             : }
    6244                 :             : 
    6245                 :             : /* If M is a bitmask that selects a field of low-order bits within an item but
    6246                 :             :    not the entire word, return the length of the field.  Return -1 otherwise.
    6247                 :             :    M is used in machine mode MODE.  */
    6248                 :             : 
    6249                 :             : int
    6250                 :       24671 : low_bitmask_len (machine_mode mode, unsigned HOST_WIDE_INT m)
    6251                 :             : {
    6252                 :       24671 :   if (mode != VOIDmode)
    6253                 :             :     {
    6254                 :       24671 :       if (!HWI_COMPUTABLE_MODE_P (mode))
    6255                 :             :         return -1;
    6256                 :       24671 :       m &= GET_MODE_MASK (mode);
    6257                 :             :     }
    6258                 :             : 
    6259                 :       24671 :   return exact_log2 (m + 1);
    6260                 :             : }
    6261                 :             : 
    6262                 :             : /* Return the mode of MEM's address.  */
    6263                 :             : 
    6264                 :             : scalar_int_mode
    6265                 :   166699151 : get_address_mode (rtx mem)
    6266                 :             : {
    6267                 :   166699151 :   machine_mode mode;
    6268                 :             : 
    6269                 :   166699151 :   gcc_assert (MEM_P (mem));
    6270                 :   166699151 :   mode = GET_MODE (XEXP (mem, 0));
    6271                 :   166699151 :   if (mode != VOIDmode)
    6272                 :   166198531 :     return as_a <scalar_int_mode> (mode);
    6273                 :      518983 :   return targetm.addr_space.address_mode (MEM_ADDR_SPACE (mem));
    6274                 :             : }
    6275                 :             : 
    6276                 :             : /* Split up a CONST_DOUBLE or integer constant rtx
    6277                 :             :    into two rtx's for single words,
    6278                 :             :    storing in *FIRST the word that comes first in memory in the target
    6279                 :             :    and in *SECOND the other.
    6280                 :             : 
    6281                 :             :    TODO: This function needs to be rewritten to work on any size
    6282                 :             :    integer.  */
    6283                 :             : 
    6284                 :             : void
    6285                 :           0 : split_double (rtx value, rtx *first, rtx *second)
    6286                 :             : {
    6287                 :           0 :   if (CONST_INT_P (value))
    6288                 :             :     {
    6289                 :           0 :       if (HOST_BITS_PER_WIDE_INT >= (2 * BITS_PER_WORD))
    6290                 :             :         {
    6291                 :             :           /* In this case the CONST_INT holds both target words.
    6292                 :             :              Extract the bits from it into two word-sized pieces.
    6293                 :             :              Sign extend each half to HOST_WIDE_INT.  */
    6294                 :           0 :           unsigned HOST_WIDE_INT low, high;
    6295                 :           0 :           unsigned HOST_WIDE_INT mask, sign_bit, sign_extend;
    6296                 :           0 :           unsigned bits_per_word = BITS_PER_WORD;
    6297                 :             : 
    6298                 :             :           /* Set sign_bit to the most significant bit of a word.  */
    6299                 :           0 :           sign_bit = 1;
    6300                 :           0 :           sign_bit <<= bits_per_word - 1;
    6301                 :             : 
    6302                 :             :           /* Set mask so that all bits of the word are set.  We could
    6303                 :             :              have used 1 << BITS_PER_WORD instead of basing the
    6304                 :             :              calculation on sign_bit.  However, on machines where
    6305                 :             :              HOST_BITS_PER_WIDE_INT == BITS_PER_WORD, it could cause a
    6306                 :             :              compiler warning, even though the code would never be
    6307                 :             :              executed.  */
    6308                 :           0 :           mask = sign_bit << 1;
    6309                 :           0 :           mask--;
    6310                 :             : 
    6311                 :             :           /* Set sign_extend as any remaining bits.  */
    6312                 :           0 :           sign_extend = ~mask;
    6313                 :             : 
    6314                 :             :           /* Pick the lower word and sign-extend it.  */
    6315                 :           0 :           low = INTVAL (value);
    6316                 :           0 :           low &= mask;
    6317                 :           0 :           if (low & sign_bit)
    6318                 :           0 :             low |= sign_extend;
    6319                 :             : 
    6320                 :             :           /* Pick the higher word, shifted to the least significant
    6321                 :             :              bits, and sign-extend it.  */
    6322                 :           0 :           high = INTVAL (value);
    6323                 :           0 :           high >>= bits_per_word - 1;
    6324                 :           0 :           high >>= 1;
    6325                 :           0 :           high &= mask;
    6326                 :           0 :           if (high & sign_bit)
    6327                 :           0 :             high |= sign_extend;
    6328                 :             : 
    6329                 :             :           /* Store the words in the target machine order.  */
    6330                 :           0 :           if (WORDS_BIG_ENDIAN)
    6331                 :             :             {
    6332                 :             :               *first = GEN_INT (high);
    6333                 :             :               *second = GEN_INT (low);
    6334                 :             :             }
    6335                 :             :           else
    6336                 :             :             {
    6337                 :           0 :               *first = GEN_INT (low);
    6338                 :           0 :               *second = GEN_INT (high);
    6339                 :             :             }
    6340                 :             :         }
    6341                 :             :       else
    6342                 :             :         {
    6343                 :             :           /* The rule for using CONST_INT for a wider mode
    6344                 :             :              is that we regard the value as signed.
    6345                 :             :              So sign-extend it.  */
    6346                 :           0 :           rtx high = (INTVAL (value) < 0 ? constm1_rtx : const0_rtx);
    6347                 :           0 :           if (WORDS_BIG_ENDIAN)
    6348                 :             :             {
    6349                 :             :               *first = high;
    6350                 :             :               *second = value;
    6351                 :             :             }
    6352                 :             :           else
    6353                 :             :             {
    6354                 :           0 :               *first = value;
    6355                 :           0 :               *second = high;
    6356                 :             :             }
    6357                 :             :         }
    6358                 :             :     }
    6359                 :           0 :   else if (GET_CODE (value) == CONST_WIDE_INT)
    6360                 :             :     {
    6361                 :             :       /* All of this is scary code and needs to be converted to
    6362                 :             :          properly work with any size integer.  */
    6363                 :           0 :       gcc_assert (CONST_WIDE_INT_NUNITS (value) == 2);
    6364                 :           0 :       if (WORDS_BIG_ENDIAN)
    6365                 :             :         {
    6366                 :             :           *first = GEN_INT (CONST_WIDE_INT_ELT (value, 1));
    6367                 :             :           *second = GEN_INT (CONST_WIDE_INT_ELT (value, 0));
    6368                 :             :         }
    6369                 :             :       else
    6370                 :             :         {
    6371                 :           0 :           *first = GEN_INT (CONST_WIDE_INT_ELT (value, 0));
    6372                 :           0 :           *second = GEN_INT (CONST_WIDE_INT_ELT (value, 1));
    6373                 :             :         }
    6374                 :             :     }
    6375                 :           0 :   else if (!CONST_DOUBLE_P (value))
    6376                 :             :     {
    6377                 :           0 :       if (WORDS_BIG_ENDIAN)
    6378                 :             :         {
    6379                 :             :           *first = const0_rtx;
    6380                 :             :           *second = value;
    6381                 :             :         }
    6382                 :             :       else
    6383                 :             :         {
    6384                 :           0 :           *first = value;
    6385                 :           0 :           *second = const0_rtx;
    6386                 :             :         }
    6387                 :             :     }
    6388                 :           0 :   else if (GET_MODE (value) == VOIDmode
    6389                 :             :            /* This is the old way we did CONST_DOUBLE integers.  */
    6390                 :           0 :            || GET_MODE_CLASS (GET_MODE (value)) == MODE_INT)
    6391                 :             :     {
    6392                 :             :       /* In an integer, the words are defined as most and least significant.
    6393                 :             :          So order them by the target's convention.  */
    6394                 :           0 :       if (WORDS_BIG_ENDIAN)
    6395                 :             :         {
    6396                 :             :           *first = GEN_INT (CONST_DOUBLE_HIGH (value));
    6397                 :             :           *second = GEN_INT (CONST_DOUBLE_LOW (value));
    6398                 :             :         }
    6399                 :             :       else
    6400                 :             :         {
    6401                 :           0 :           *first = GEN_INT (CONST_DOUBLE_LOW (value));
    6402                 :           0 :           *second = GEN_INT (CONST_DOUBLE_HIGH (value));
    6403                 :             :         }
    6404                 :             :     }
    6405                 :             :   else
    6406                 :             :     {
    6407                 :           0 :       long l[2];
    6408                 :             : 
    6409                 :             :       /* Note, this converts the REAL_VALUE_TYPE to the target's
    6410                 :             :          format, splits up the floating point double and outputs
    6411                 :             :          exactly 32 bits of it into each of l[0] and l[1] --
    6412                 :             :          not necessarily BITS_PER_WORD bits.  */
    6413                 :           0 :       REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (value), l);
    6414                 :             : 
    6415                 :             :       /* If 32 bits is an entire word for the target, but not for the host,
    6416                 :             :          then sign-extend on the host so that the number will look the same
    6417                 :             :          way on the host that it would on the target.  See for instance
    6418                 :             :          simplify_unary_operation.  The #if is needed to avoid compiler
    6419                 :             :          warnings.  */
    6420                 :             : 
    6421                 :             : #if HOST_BITS_PER_LONG > 32
    6422                 :           0 :       if (BITS_PER_WORD < HOST_BITS_PER_LONG && BITS_PER_WORD == 32)
    6423                 :             :         {
    6424                 :           0 :           if (l[0] & ((long) 1 << 31))
    6425                 :           0 :             l[0] |= ((unsigned long) (-1) << 32);
    6426                 :           0 :           if (l[1] & ((long) 1 << 31))
    6427                 :           0 :             l[1] |= ((unsigned long) (-1) << 32);
    6428                 :             :         }
    6429                 :             : #endif
    6430                 :             : 
    6431                 :           0 :       *first = GEN_INT (l[0]);
    6432                 :           0 :       *second = GEN_INT (l[1]);
    6433                 :             :     }
    6434                 :           0 : }
    6435                 :             : 
    6436                 :             : /* Return true if X is a sign_extract or zero_extract from the least
    6437                 :             :    significant bit.  */
    6438                 :             : 
    6439                 :             : static bool
    6440                 :   201497262 : lsb_bitfield_op_p (rtx x)
    6441                 :             : {
    6442                 :           0 :   if (GET_RTX_CLASS (GET_CODE (x)) == RTX_BITFIELD_OPS)
    6443                 :             :     {
    6444                 :           0 :       machine_mode mode = GET_MODE (XEXP (x, 0));
    6445                 :           0 :       HOST_WIDE_INT len = INTVAL (XEXP (x, 1));
    6446                 :           0 :       HOST_WIDE_INT pos = INTVAL (XEXP (x, 2));
    6447                 :           0 :       poly_int64 remaining_bits = GET_MODE_PRECISION (mode) - len;
    6448                 :             : 
    6449                 :           0 :       return known_eq (pos, BITS_BIG_ENDIAN ? remaining_bits : 0);
    6450                 :             :     }
    6451                 :             :   return false;
    6452                 :             : }
    6453                 :             : 
    6454                 :             : /* Strip outer address "mutations" from LOC and return a pointer to the
    6455                 :             :    inner value.  If OUTER_CODE is nonnull, store the code of the innermost
    6456                 :             :    stripped expression there.
    6457                 :             : 
    6458                 :             :    "Mutations" either convert between modes or apply some kind of
    6459                 :             :    extension, truncation or alignment.  */
    6460                 :             : 
    6461                 :             : rtx *
    6462                 :   201495764 : strip_address_mutations (rtx *loc, enum rtx_code *outer_code)
    6463                 :             : {
    6464                 :   201547277 :   for (;;)
    6465                 :             :     {
    6466                 :   201547277 :       enum rtx_code code = GET_CODE (*loc);
    6467                 :   201547277 :       if (GET_RTX_CLASS (code) == RTX_UNARY)
    6468                 :             :         /* Things like SIGN_EXTEND, ZERO_EXTEND and TRUNCATE can be
    6469                 :             :            used to convert between pointer sizes.  */
    6470                 :       50015 :         loc = &XEXP (*loc, 0);
    6471                 :   201497262 :       else if (lsb_bitfield_op_p (*loc))
    6472                 :             :         /* A [SIGN|ZERO]_EXTRACT from the least significant bit effectively
    6473                 :             :            acts as a combined truncation and extension.  */
    6474                 :           0 :         loc = &XEXP (*loc, 0);
    6475                 :   201497262 :       else if (code == AND && CONST_INT_P (XEXP (*loc, 1)))
    6476                 :             :         /* (and ... (const_int -X)) is used to align to X bytes.  */
    6477                 :        1486 :         loc = &XEXP (*loc, 0);
    6478                 :   201495776 :       else if (code == SUBREG
    6479                 :       26288 :                && (!OBJECT_P (SUBREG_REG (*loc))
    6480                 :       26286 :                    || CONSTANT_P (SUBREG_REG (*loc)))
    6481                 :   201495788 :                && subreg_lowpart_p (*loc))
    6482                 :             :         /* (subreg (operator ...) ...) inside AND is used for mode
    6483                 :             :            conversion too.  It is also used for load-address operations
    6484                 :             :            in which an extension can be done for free, such as:
    6485                 :             : 
    6486                 :             :              (zero_extend:DI
    6487                 :             :                (subreg:SI (plus:DI (reg:DI R) (symbol_ref:DI "foo") 0)))
    6488                 :             : 
    6489                 :             :            The latter usage also covers subregs of plain "displacements",
    6490                 :             :            such as:
    6491                 :             : 
    6492                 :             :              (zero_extend:DI (subreg:SI (symbol_ref:DI "foo") 0))
    6493                 :             : 
    6494                 :             :            The inner address should then be the symbol_ref, not the subreg,
    6495                 :             :            similarly to the plus case above.
    6496                 :             : 
    6497                 :             :            In contrast, the subreg in:
    6498                 :             : 
    6499                 :             :              (zero_extend:DI (subreg:SI (reg:DI R) 0))
    6500                 :             : 
    6501                 :             :            should be treated as the base, since it should be replaced by
    6502                 :             :            an SImode hard register during register allocation.  */
    6503                 :          12 :         loc = &SUBREG_REG (*loc);
    6504                 :             :       else
    6505                 :   201495764 :         return loc;
    6506                 :       51513 :       if (outer_code)
    6507                 :       51513 :         *outer_code = code;
    6508                 :             :     }
    6509                 :             : }
    6510                 :             : 
    6511                 :             : /* Return true if CODE applies some kind of scale.  The scaled value is
    6512                 :             :    is the first operand and the scale is the second.  */
    6513                 :             : 
    6514                 :             : static bool
    6515                 :    62744857 : binary_scale_code_p (enum rtx_code code)
    6516                 :             : {
    6517                 :    62744857 :   return (code == MULT
    6518                 :    62744857 :           || code == ASHIFT
    6519                 :             :           /* Needed by ARM targets.  */
    6520                 :             :           || code == ASHIFTRT
    6521                 :             :           || code == LSHIFTRT
    6522                 :    60731346 :           || code == ROTATE
    6523                 :    60731346 :           || code == ROTATERT);
    6524                 :             : }
    6525                 :             : 
    6526                 :             : /* Return true if X appears to be a valid base or index term.  */
    6527                 :             : static bool
    6528                 :   125489714 : valid_base_or_index_term_p (rtx x)
    6529                 :             : {
    6530                 :   125489714 :   if (GET_CODE (x) == SCRATCH)
    6531                 :             :     return true;
    6532                 :             :   /* Handle what appear to be eliminated forms of a register.  If we reach
    6533                 :             :      here, the elimination occurs outside of the outermost PLUS tree,
    6534                 :             :      and so the elimination offset cannot be treated as a displacement
    6535                 :             :      of the main address.  Instead, we need to treat the whole PLUS as
    6536                 :             :      the base or index term.  The address can only be made legitimate by
    6537                 :             :      reloading the PLUS.  */
    6538                 :   125489714 :   if (GET_CODE (x) == PLUS && CONST_SCALAR_INT_P (XEXP (x, 1)))
    6539                 :           0 :     x = XEXP (x, 0);
    6540                 :   125489714 :   if (GET_CODE (x) == SUBREG)
    6541                 :       41058 :     x = SUBREG_REG (x);
    6542                 :   125489714 :   return REG_P (x) || MEM_P (x);
    6543                 :             : }
    6544                 :             : 
    6545                 :             : /* If *INNER can be interpreted as a base, return a pointer to the inner term
    6546                 :             :    (see address_info).  Return null otherwise.  */
    6547                 :             : 
    6548                 :             : static rtx *
    6549                 :    62744857 : get_base_term (rtx *inner)
    6550                 :             : {
    6551                 :    62744857 :   if (GET_CODE (*inner) == LO_SUM)
    6552                 :           0 :     inner = strip_address_mutations (&XEXP (*inner, 0));
    6553                 :    62744857 :   if (valid_base_or_index_term_p (*inner))
    6554                 :    60731346 :     return inner;
    6555                 :             :   return 0;
    6556                 :             : }
    6557                 :             : 
    6558                 :             : /* If *INNER can be interpreted as an index, return a pointer to the inner term
    6559                 :             :    (see address_info).  Return null otherwise.  */
    6560                 :             : 
    6561                 :             : static rtx *
    6562                 :    62744857 : get_index_term (rtx *inner)
    6563                 :             : {
    6564                 :             :   /* At present, only constant scales are allowed.  */
    6565                 :    62744857 :   if (binary_scale_code_p (GET_CODE (*inner)) && CONSTANT_P (XEXP (*inner, 1)))
    6566                 :     2013511 :     inner = strip_address_mutations (&XEXP (*inner, 0));
    6567                 :    62744857 :   if (valid_base_or_index_term_p (*inner))
    6568                 :    62744857 :     return inner;
    6569                 :             :   return 0;
    6570                 :             : }
    6571                 :             : 
    6572                 :             : /* Set the segment part of address INFO to LOC, given that INNER is the
    6573                 :             :    unmutated value.  */
    6574                 :             : 
    6575                 :             : static void
    6576                 :          17 : set_address_segment (struct address_info *info, rtx *loc, rtx *inner)
    6577                 :             : {
    6578                 :          17 :   gcc_assert (!info->segment);
    6579                 :          17 :   info->segment = loc;
    6580                 :          17 :   info->segment_term = inner;
    6581                 :          17 : }
    6582                 :             : 
    6583                 :             : /* Set the base part of address INFO to LOC, given that INNER is the
    6584                 :             :    unmutated value.  */
    6585                 :             : 
    6586                 :             : static void
    6587                 :    61666351 : set_address_base (struct address_info *info, rtx *loc, rtx *inner)
    6588                 :             : {
    6589                 :    61666351 :   gcc_assert (!info->base);
    6590                 :    61666351 :   info->base = loc;
    6591                 :    61666351 :   info->base_term = inner;
    6592                 :    61666351 : }
    6593                 :             : 
    6594                 :             : /* Set the index part of address INFO to LOC, given that INNER is the
    6595                 :             :    unmutated value.  */
    6596                 :             : 
    6597                 :             : static void
    6598                 :     3159622 : set_address_index (struct address_info *info, rtx *loc, rtx *inner)
    6599                 :             : {
    6600                 :     3159622 :   gcc_assert (!info->index);
    6601                 :     3159622 :   info->index = loc;
    6602                 :     3159622 :   info->index_term = inner;
    6603                 :     3159622 : }
    6604                 :             : 
    6605                 :             : /* Set the displacement part of address INFO to LOC, given that INNER
    6606                 :             :    is the constant term.  */
    6607                 :             : 
    6608                 :             : static void
    6609                 :    63002548 : set_address_disp (struct address_info *info, rtx *loc, rtx *inner)
    6610                 :             : {
    6611                 :    63002548 :   gcc_assert (!info->disp);
    6612                 :    63002548 :   info->disp = loc;
    6613                 :    63002548 :   info->disp_term = inner;
    6614                 :    63002548 : }
    6615                 :             : 
    6616                 :             : /* INFO->INNER describes a {PRE,POST}_{INC,DEC} address.  Set up the
    6617                 :             :    rest of INFO accordingly.  */
    6618                 :             : 
    6619                 :             : static void
    6620                 :     1964808 : decompose_incdec_address (struct address_info *info)
    6621                 :             : {
    6622                 :     1964808 :   info->autoinc_p = true;
    6623                 :             : 
    6624                 :     1964808 :   rtx *base = &XEXP (*info->inner, 0);
    6625                 :     1964808 :   set_address_base (info, base, base);
    6626                 :     1964808 :   gcc_checking_assert (info->base == info->base_term);
    6627                 :             : 
    6628                 :             :   /* These addresses are only valid when the size of the addressed
    6629                 :             :      value is known.  */
    6630                 :     1964808 :   gcc_checking_assert (info->mode != VOIDmode);
    6631                 :     1964808 : }
    6632                 :             : 
    6633                 :             : /* INFO->INNER describes a {PRE,POST}_MODIFY address.  Set up the rest
    6634                 :             :    of INFO accordingly.  */
    6635                 :             : 
    6636                 :             : static void
    6637                 :      116308 : decompose_automod_address (struct address_info *info)
    6638                 :             : {
    6639                 :      116308 :   info->autoinc_p = true;
    6640                 :             : 
    6641                 :      116308 :   rtx *base = &XEXP (*info->inner, 0);
    6642                 :      116308 :   set_address_base (info, base, base);
    6643                 :      116308 :   gcc_checking_assert (info->base == info->base_term);
    6644                 :             : 
    6645                 :      116308 :   rtx plus = XEXP (*info->inner, 1);
    6646                 :      116308 :   gcc_assert (GET_CODE (plus) == PLUS);
    6647                 :             : 
    6648                 :      116308 :   info->base_term2 = &XEXP (plus, 0);
    6649                 :      116308 :   gcc_checking_assert (rtx_equal_p (*info->base_term, *info->base_term2));
    6650                 :             : 
    6651                 :      116308 :   rtx *step = &XEXP (plus, 1);
    6652                 :      116308 :   rtx *inner_step = strip_address_mutations (step);
    6653                 :      116308 :   if (CONSTANT_P (*inner_step))
    6654                 :      116308 :     set_address_disp (info, step, inner_step);
    6655                 :             :   else
    6656                 :           0 :     set_address_index (info, step, inner_step);
    6657                 :      116308 : }
    6658                 :             : 
    6659                 :             : /* Treat *LOC as a tree of PLUS operands and store pointers to the summed
    6660                 :             :    values in [PTR, END).  Return a pointer to the end of the used array.  */
    6661                 :             : 
    6662                 :             : static rtx **
    6663                 :   125631114 : extract_plus_operands (rtx *loc, rtx **ptr, rtx **end)
    6664                 :             : {
    6665                 :   179608513 :   rtx x = *loc;
    6666                 :   179608513 :   if (GET_CODE (x) == PLUS)
    6667                 :             :     {
    6668                 :    53977399 :       ptr = extract_plus_operands (&XEXP (x, 0), ptr, end);
    6669                 :    53977399 :       ptr = extract_plus_operands (&XEXP (x, 1), ptr, end);
    6670                 :             :     }
    6671                 :             :   else
    6672                 :             :     {
    6673                 :   125631114 :       gcc_assert (ptr != end);
    6674                 :   125631114 :       *ptr++ = loc;
    6675                 :             :     }
    6676                 :   125631114 :   return ptr;
    6677                 :             : }
    6678                 :             : 
    6679                 :             : /* Evaluate the likelihood of X being a base or index value, returning
    6680                 :             :    positive if it is likely to be a base, negative if it is likely to be
    6681                 :             :    an index, and 0 if we can't tell.  Make the magnitude of the return
    6682                 :             :    value reflect the amount of confidence we have in the answer.
    6683                 :             : 
    6684                 :             :    MODE, AS, OUTER_CODE and INDEX_CODE are as for ok_for_base_p_1.  */
    6685                 :             : 
    6686                 :             : static int
    6687                 :     2292222 : baseness (rtx x, machine_mode mode, addr_space_t as,
    6688                 :             :           enum rtx_code outer_code, enum rtx_code index_code)
    6689                 :             : {
    6690                 :             :   /* Believe *_POINTER unless the address shape requires otherwise.  */
    6691                 :     2292222 :   if (REG_P (x) && REG_POINTER (x))
    6692                 :             :     return 2;
    6693                 :     1319343 :   if (MEM_P (x) && MEM_POINTER (x))
    6694                 :             :     return 2;
    6695                 :             : 
    6696                 :     1319343 :   if (REG_P (x) && HARD_REGISTER_P (x))
    6697                 :             :     {
    6698                 :             :       /* X is a hard register.  If it only fits one of the base
    6699                 :             :          or index classes, choose that interpretation.  */
    6700                 :          12 :       int regno = REGNO (x);
    6701                 :          12 :       bool base_p = ok_for_base_p_1 (regno, mode, as, outer_code, index_code);
    6702                 :          12 :       bool index_p = REGNO_OK_FOR_INDEX_P (regno);
    6703                 :          12 :       if (base_p != index_p)
    6704                 :           0 :         return base_p ? 1 : -1;
    6705                 :             :     }
    6706                 :             :   return 0;
    6707                 :             : }
    6708                 :             : 
    6709                 :             : /* INFO->INNER describes a normal, non-automodified address.
    6710                 :             :    Fill in the rest of INFO accordingly.  */
    6711                 :             : 
    6712                 :             : static void
    6713                 :    71653715 : decompose_normal_address (struct address_info *info)
    6714                 :             : {
    6715                 :             :   /* Treat the address as the sum of up to four values.  */
    6716                 :    71653715 :   rtx *ops[4];
    6717                 :    71653715 :   size_t n_ops = extract_plus_operands (info->inner, ops,
    6718                 :    71653715 :                                         ops + ARRAY_SIZE (ops)) - ops;
    6719                 :             : 
    6720                 :             :   /* If there is more than one component, any base component is in a PLUS.  */
    6721                 :    71653715 :   if (n_ops > 1)
    6722                 :    52910450 :     info->base_outer_code = PLUS;
    6723                 :             : 
    6724                 :             :   /* Try to classify each sum operand now.  Leave those that could be
    6725                 :             :      either a base or an index in OPS.  */
    6726                 :             :   rtx *inner_ops[4];
    6727                 :             :   size_t out = 0;
    6728                 :   197284829 :   for (size_t in = 0; in < n_ops; ++in)
    6729                 :             :     {
    6730                 :   125631114 :       rtx *loc = ops[in];
    6731                 :   125631114 :       rtx *inner = strip_address_mutations (loc);
    6732                 :   125631114 :       if (CONSTANT_P (*inner))
    6733                 :    62886240 :         set_address_disp (info, loc, inner);
    6734                 :    62744874 :       else if (GET_CODE (*inner) == UNSPEC)
    6735                 :          17 :         set_address_segment (info, loc, inner);
    6736                 :             :       else
    6737                 :             :         {
    6738                 :             :           /* The only other possibilities are a base or an index.  */
    6739                 :    62744857 :           rtx *base_term = get_base_term (inner);
    6740                 :    62744857 :           rtx *index_term = get_index_term (inner);
    6741                 :    62744857 :           gcc_assert (base_term || index_term);
    6742                 :    62744857 :           if (!base_term)
    6743                 :     2013511 :             set_address_index (info, loc, index_term);
    6744                 :    60731346 :           else if (!index_term)
    6745                 :           0 :             set_address_base (info, loc, base_term);
    6746                 :             :           else
    6747                 :             :             {
    6748                 :    60731346 :               gcc_assert (base_term == index_term);
    6749                 :    60731346 :               ops[out] = loc;
    6750                 :    60731346 :               inner_ops[out] = base_term;
    6751                 :    60731346 :               ++out;
    6752                 :             :             }
    6753                 :             :         }
    6754                 :             :     }
    6755                 :             : 
    6756                 :             :   /* Classify the remaining OPS members as bases and indexes.  */
    6757                 :    71653715 :   if (out == 1)
    6758                 :             :     {
    6759                 :             :       /* If we haven't seen a base or an index yet, assume that this is
    6760                 :             :          the base.  If we were confident that another term was the base
    6761                 :             :          or index, treat the remaining operand as the other kind.  */
    6762                 :    58439124 :       if (!info->base)
    6763                 :    58439124 :         set_address_base (info, ops[0], inner_ops[0]);
    6764                 :             :       else
    6765                 :           0 :         set_address_index (info, ops[0], inner_ops[0]);
    6766                 :             :     }
    6767                 :    13214591 :   else if (out == 2)
    6768                 :             :     {
    6769                 :     1146111 :       auto address_mode = targetm.addr_space.address_mode (info->as);
    6770                 :     1146111 :       rtx inner_op0 = *inner_ops[0];
    6771                 :     1146111 :       rtx inner_op1 = *inner_ops[1];
    6772                 :     1146111 :       int base;
    6773                 :             :       /* If one inner operand has the expected mode for a base and the other
    6774                 :             :          doesn't, assume that the other one is the index.  This is useful
    6775                 :             :          for addresses such as:
    6776                 :             : 
    6777                 :             :            (plus (zero_extend X) Y)
    6778                 :             : 
    6779                 :             :          zero_extend is not in itself enough to assume an index, since bases
    6780                 :             :          can be zero-extended on POINTERS_EXTEND_UNSIGNED targets.  But if
    6781                 :             :          Y has address mode and X doesn't, there should be little doubt that
    6782                 :             :          Y is the base.  */
    6783                 :     1146111 :       if (GET_MODE (inner_op0) == address_mode
    6784                 :     1146111 :           && GET_MODE (inner_op1) != address_mode)
    6785                 :             :         base = 0;
    6786                 :     1146111 :       else if (GET_MODE (inner_op1) == address_mode
    6787                 :     1146111 :                && GET_MODE (inner_op0) != address_mode)
    6788                 :             :         base = 1;
    6789                 :             :       /* In the event of a tie, assume the base comes first.  */
    6790                 :     1146111 :       else if (baseness (inner_op0, info->mode, info->as, PLUS,
    6791                 :     1146111 :                          GET_CODE (*ops[1]))
    6792                 :     1146111 :                >= baseness (inner_op1, info->mode, info->as, PLUS,
    6793                 :     1146111 :                             GET_CODE (*ops[0])))
    6794                 :             :         base = 0;
    6795                 :             :       else
    6796                 :        6975 :         base = 1;
    6797                 :     1146111 :       set_address_base (info, ops[base], inner_ops[base]);
    6798                 :     1146111 :       set_address_index (info, ops[1 - base], inner_ops[1 - base]);
    6799                 :             :     }
    6800                 :             :   else
    6801                 :    12068480 :     gcc_assert (out == 0);
    6802                 :    71653715 : }
    6803                 :             : 
    6804                 :             : /* Describe address *LOC in *INFO.  MODE is the mode of the addressed value,
    6805                 :             :    or VOIDmode if not known.  AS is the address space associated with LOC.
    6806                 :             :    OUTER_CODE is MEM if *LOC is a MEM address and ADDRESS otherwise.  */
    6807                 :             : 
    6808                 :             : void
    6809                 :    73734831 : decompose_address (struct address_info *info, rtx *loc, machine_mode mode,
    6810                 :             :                    addr_space_t as, enum rtx_code outer_code)
    6811                 :             : {
    6812                 :    73734831 :   memset (info, 0, sizeof (*info));
    6813                 :    73734831 :   info->mode = mode;
    6814                 :    73734831 :   info->as = as;
    6815                 :    73734831 :   info->addr_outer_code = outer_code;
    6816                 :    73734831 :   info->outer = loc;
    6817                 :    73734831 :   info->inner = strip_address_mutations (loc, &outer_code);
    6818                 :    73734831 :   info->base_outer_code = outer_code;
    6819                 :    73734831 :   switch (GET_CODE (*info->inner))
    6820                 :             :     {
    6821                 :     1964808 :     case PRE_DEC:
    6822                 :     1964808 :     case PRE_INC:
    6823                 :     1964808 :     case POST_DEC:
    6824                 :     1964808 :     case POST_INC:
    6825                 :     1964808 :       decompose_incdec_address (info);
    6826                 :     1964808 :       break;
    6827                 :             : 
    6828                 :      116308 :     case PRE_MODIFY:
    6829                 :      116308 :     case POST_MODIFY:
    6830                 :      116308 :       decompose_automod_address (info);
    6831                 :      116308 :       break;
    6832                 :             : 
    6833                 :    71653715 :     default:
    6834                 :    71653715 :       decompose_normal_address (info);
    6835                 :    71653715 :       break;
    6836                 :             :     }
    6837                 :    73734831 : }
    6838                 :             : 
    6839                 :             : /* Describe address operand LOC in INFO.  */
    6840                 :             : 
    6841                 :             : void
    6842                 :     3169339 : decompose_lea_address (struct address_info *info, rtx *loc)
    6843                 :             : {
    6844                 :     3169339 :   decompose_address (info, loc, VOIDmode, ADDR_SPACE_GENERIC, ADDRESS);
    6845                 :     3169339 : }
    6846                 :             : 
    6847                 :             : /* Describe the address of MEM X in INFO.  */
    6848                 :             : 
    6849                 :             : void
    6850                 :    70557229 : decompose_mem_address (struct address_info *info, rtx x)
    6851                 :             : {
    6852                 :    70557229 :   gcc_assert (MEM_P (x));
    6853                 :    70557229 :   decompose_address (info, &XEXP (x, 0), GET_MODE (x),
    6854                 :    70557229 :                      MEM_ADDR_SPACE (x), MEM);
    6855                 :    70557229 : }
    6856                 :             : 
    6857                 :             : /* Update INFO after a change to the address it describes.  */
    6858                 :             : 
    6859                 :             : void
    6860                 :        8263 : update_address (struct address_info *info)
    6861                 :             : {
    6862                 :        8263 :   decompose_address (info, info->outer, info->mode, info->as,
    6863                 :             :                      info->addr_outer_code);
    6864                 :        8263 : }
    6865                 :             : 
    6866                 :             : /* Return the scale applied to *INFO->INDEX_TERM, or 0 if the index is
    6867                 :             :    more complicated than that.  */
    6868                 :             : 
    6869                 :             : HOST_WIDE_INT
    6870                 :           0 : get_index_scale (const struct address_info *info)
    6871                 :             : {
    6872                 :           0 :   rtx index = *info->index;
    6873                 :           0 :   if (GET_CODE (index) == MULT
    6874                 :           0 :       && CONST_INT_P (XEXP (index, 1))
    6875                 :           0 :       && info->index_term == &XEXP (index, 0))
    6876                 :           0 :     return INTVAL (XEXP (index, 1));
    6877                 :             : 
    6878                 :           0 :   if (GET_CODE (index) == ASHIFT
    6879                 :           0 :       && CONST_INT_P (XEXP (index, 1))
    6880                 :           0 :       && info->index_term == &XEXP (index, 0))
    6881                 :           0 :     return HOST_WIDE_INT_1 << INTVAL (XEXP (index, 1));
    6882                 :             : 
    6883                 :           0 :   if (info->index == info->index_term)
    6884                 :           0 :     return 1;
    6885                 :             : 
    6886                 :             :   return 0;
    6887                 :             : }
    6888                 :             : 
    6889                 :             : /* Return the "index code" of INFO, in the form required by
    6890                 :             :    ok_for_base_p_1.  */
    6891                 :             : 
    6892                 :             : enum rtx_code
    6893                 :    31863612 : get_index_code (const struct address_info *info)
    6894                 :             : {
    6895                 :    31863612 :   if (info->index)
    6896                 :     1233805 :     return GET_CODE (*info->index);
    6897                 :             : 
    6898                 :    30629807 :   if (info->disp)
    6899                 :    25042812 :     return GET_CODE (*info->disp);
    6900                 :             : 
    6901                 :             :   return SCRATCH;
    6902                 :             : }
    6903                 :             : 
    6904                 :             : /* Return true if RTL X contains a SYMBOL_REF.  */
    6905                 :             : 
    6906                 :             : bool
    6907                 :      731988 : contains_symbol_ref_p (const_rtx x)
    6908                 :             : {
    6909                 :      731988 :   subrtx_iterator::array_type array;
    6910                 :     3001761 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
    6911                 :     2344731 :     if (SYMBOL_REF_P (*iter))
    6912                 :       74958 :       return true;
    6913                 :             : 
    6914                 :      657030 :   return false;
    6915                 :      731988 : }
    6916                 :             : 
    6917                 :             : /* Return true if RTL X contains a SYMBOL_REF or LABEL_REF.  */
    6918                 :             : 
    6919                 :             : bool
    6920                 :      334091 : contains_symbolic_reference_p (const_rtx x)
    6921                 :             : {
    6922                 :      334091 :   subrtx_iterator::array_type array;
    6923                 :      797327 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
    6924                 :      467004 :     if (SYMBOL_REF_P (*iter) || GET_CODE (*iter) == LABEL_REF)
    6925                 :        3768 :       return true;
    6926                 :             : 
    6927                 :      330323 :   return false;
    6928                 :      334091 : }
    6929                 :             : 
    6930                 :             : /* Return true if RTL X contains a constant pool address.  */
    6931                 :             : 
    6932                 :             : bool
    6933                 :           0 : contains_constant_pool_address_p (const_rtx x)
    6934                 :             : {
    6935                 :           0 :   subrtx_iterator::array_type array;
    6936                 :           0 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
    6937                 :           0 :     if (SYMBOL_REF_P (*iter) && CONSTANT_POOL_ADDRESS_P (*iter))
    6938                 :           0 :       return true;
    6939                 :             : 
    6940                 :           0 :   return false;
    6941                 :           0 : }
    6942                 :             : 
    6943                 :             : 
    6944                 :             : /* Return true if X contains a thread-local symbol.  */
    6945                 :             : 
    6946                 :             : bool
    6947                 :           0 : tls_referenced_p (const_rtx x)
    6948                 :             : {
    6949                 :           0 :   if (!targetm.have_tls)
    6950                 :             :     return false;
    6951                 :             : 
    6952                 :           0 :   subrtx_iterator::array_type array;
    6953                 :           0 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
    6954                 :           0 :     if (GET_CODE (*iter) == SYMBOL_REF && SYMBOL_REF_TLS_MODEL (*iter) != 0)
    6955                 :           0 :       return true;
    6956                 :           0 :   return false;
    6957                 :           0 : }
    6958                 :             : 
    6959                 :             : /* Process recursively X of INSN and add REG_INC notes if necessary.  */
    6960                 :             : void
    6961                 :           0 : add_auto_inc_notes (rtx_insn *insn, rtx x)
    6962                 :             : {
    6963                 :           0 :   enum rtx_code code = GET_CODE (x);
    6964                 :           0 :   const char *fmt;
    6965                 :           0 :   int i, j;
    6966                 :             : 
    6967                 :           0 :   if (code == MEM && auto_inc_p (XEXP (x, 0)))
    6968                 :             :     {
    6969                 :           0 :       add_reg_note (insn, REG_INC, XEXP (XEXP (x, 0), 0));
    6970                 :           0 :       return;
    6971                 :             :     }
    6972                 :             : 
    6973                 :             :   /* Scan all X sub-expressions.  */
    6974                 :           0 :   fmt = GET_RTX_FORMAT (code);
    6975                 :           0 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    6976                 :             :     {
    6977                 :           0 :       if (fmt[i] == 'e')
    6978                 :           0 :         add_auto_inc_notes (insn, XEXP (x, i));
    6979                 :           0 :       else if (fmt[i] == 'E')
    6980                 :           0 :         for (j = XVECLEN (x, i) - 1; j >= 0; j--)
    6981                 :           0 :           add_auto_inc_notes (insn, XVECEXP (x, i, j));
    6982                 :             :     }
    6983                 :             : }
    6984                 :             : 
    6985                 :             : /* Return true if X is register asm.  */
    6986                 :             : 
    6987                 :             : bool
    6988                 :    16102792 : register_asm_p (const_rtx x)
    6989                 :             : {
    6990                 :    16102792 :   return (REG_P (x)
    6991                 :    16102792 :           && REG_EXPR (x) != NULL_TREE
    6992                 :     7195720 :           && HAS_DECL_ASSEMBLER_NAME_P (REG_EXPR (x))
    6993                 :     2103847 :           && DECL_ASSEMBLER_NAME_SET_P (REG_EXPR (x))
    6994                 :    16146439 :           && DECL_REGISTER (REG_EXPR (x)));
    6995                 :             : }
    6996                 :             : 
    6997                 :             : /* Return true if, for all OP of mode OP_MODE:
    6998                 :             : 
    6999                 :             :      (vec_select:RESULT_MODE OP SEL)
    7000                 :             : 
    7001                 :             :    is equivalent to the highpart RESULT_MODE of OP.  */
    7002                 :             : 
    7003                 :             : bool
    7004                 :           0 : vec_series_highpart_p (machine_mode result_mode, machine_mode op_mode, rtx sel)
    7005                 :             : {
    7006                 :           0 :   int nunits;
    7007                 :           0 :   if (GET_MODE_NUNITS (op_mode).is_constant (&nunits)
    7008                 :           0 :       && targetm.can_change_mode_class (op_mode, result_mode, ALL_REGS))
    7009                 :             :     {
    7010                 :           0 :       int offset = BYTES_BIG_ENDIAN ? 0 : nunits - XVECLEN (sel, 0);
    7011                 :           0 :       return rtvec_series_p (XVEC (sel, 0), offset);
    7012                 :             :     }
    7013                 :             :   return false;
    7014                 :             : }
    7015                 :             : 
    7016                 :             : /* Return true if, for all OP of mode OP_MODE:
    7017                 :             : 
    7018                 :             :      (vec_select:RESULT_MODE OP SEL)
    7019                 :             : 
    7020                 :             :    is equivalent to the lowpart RESULT_MODE of OP.  */
    7021                 :             : 
    7022                 :             : bool
    7023                 :     4836725 : vec_series_lowpart_p (machine_mode result_mode, machine_mode op_mode, rtx sel)
    7024                 :             : {
    7025                 :     4836725 :   int nunits;
    7026                 :     4836725 :   if (GET_MODE_NUNITS (op_mode).is_constant (&nunits)
    7027                 :     4836725 :       && targetm.can_change_mode_class (op_mode, result_mode, ALL_REGS))
    7028                 :             :     {
    7029                 :      582117 :       int offset = BYTES_BIG_ENDIAN ? nunits - XVECLEN (sel, 0) : 0;
    7030                 :      582117 :       return rtvec_series_p (XVEC (sel, 0), offset);
    7031                 :             :     }
    7032                 :             :   return false;
    7033                 :             : }
    7034                 :             : 
    7035                 :             : /* Return true if X contains a paradoxical subreg.  */
    7036                 :             : 
    7037                 :             : bool
    7038                 :     1127914 : contains_paradoxical_subreg_p (rtx x)
    7039                 :             : {
    7040                 :     1127914 :   subrtx_var_iterator::array_type array;
    7041                 :     4767625 :   FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST)
    7042                 :             :     {
    7043                 :     3659392 :       x = *iter;
    7044                 :     3659392 :       if (SUBREG_P (x) && paradoxical_subreg_p (x))
    7045                 :       19681 :         return true;
    7046                 :             :     }
    7047                 :     1108233 :   return false;
    7048                 :     1127914 : }
        

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