LCOV - code coverage report
Current view: top level - gcc - rtlanal.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 86.0 % 2773 2384
Test Date: 2025-06-14 16:15:35 Functions: 88.2 % 170 150
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                 :     8177557 : generic_subrtx_iterator <T>::add_single_to_queue (array_type &array,
      87                 :             :                                                   value_type *base,
      88                 :             :                                                   size_t i, value_type x)
      89                 :             : {
      90                 :     8177557 :   if (base == array.stack)
      91                 :             :     {
      92                 :     4266349 :       if (i < LOCAL_ELEMS)
      93                 :             :         {
      94                 :     3991124 :           base[i] = x;
      95                 :     3991124 :           return base;
      96                 :             :         }
      97                 :      275225 :       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                 :      275225 :       if (vec_safe_length (array.heap) <= i)
     101                 :      275225 :         vec_safe_grow (array.heap, i + 1, true);
     102                 :      275225 :       base = array.heap->address ();
     103                 :      275225 :       memcpy (base, array.stack, sizeof (array.stack));
     104                 :      275225 :       base[LOCAL_ELEMS] = x;
     105                 :      275225 :       return base;
     106                 :             :     }
     107                 :     3911208 :   unsigned int length = array.heap->length ();
     108                 :     3911208 :   if (length > i)
     109                 :             :     {
     110                 :     1162399 :       gcc_checking_assert (base == array.heap->address ());
     111                 :     1162399 :       base[i] = x;
     112                 :     1162399 :       return base;
     113                 :             :     }
     114                 :             :   else
     115                 :             :     {
     116                 :     2748809 :       gcc_checking_assert (i == length);
     117                 :     2748809 :       vec_safe_push (array.heap, x);
     118                 :     2748809 :       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                 :   323592425 : generic_subrtx_iterator <T>::add_subrtxes_to_queue (array_type &array,
     128                 :             :                                                     value_type *base,
     129                 :             :                                                     size_t end, rtx_type x)
     130                 :             : {
     131                 :   323592425 :   enum rtx_code code = GET_CODE (x);
     132                 :   323592425 :   const char *format = GET_RTX_FORMAT (code);
     133                 :   323592425 :   size_t orig_end = end;
     134                 :   323592425 :   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                 :       83560 :       for (int i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; --i)
     140                 :       73494 :         if (format[i] == 'e')
     141                 :             :           {
     142                 :       20854 :             value_type subx = T::get_value (x->u.fld[i].rt_rtx);
     143                 :       20854 :             if (LIKELY (end < LOCAL_ELEMS))
     144                 :       20854 :               base[end++] = subx;
     145                 :             :             else
     146                 :           0 :               base = add_single_to_queue (array, base, end++, subx);
     147                 :             :           }
     148                 :             :     }
     149                 :             :   else
     150                 :   701574094 :     for (int i = 0; format[i]; ++i)
     151                 :   377991735 :       if (format[i] == 'e')
     152                 :             :         {
     153                 :      511647 :           value_type subx = T::get_value (x->u.fld[i].rt_rtx);
     154                 :      511647 :           if (LIKELY (end < LOCAL_ELEMS))
     155                 :           0 :             base[end++] = subx;
     156                 :             :           else
     157                 :      511647 :             base = add_single_to_queue (array, base, end++, subx);
     158                 :             :         }
     159                 :   377480088 :       else if (format[i] == 'E')
     160                 :             :         {
     161                 :   329286479 :           unsigned int length = GET_NUM_ELEM (x->u.fld[i].rt_rtvec);
     162                 :   329286479 :           rtx *vec = x->u.fld[i].rt_rtvec->elem;
     163                 :   329286479 :           if (LIKELY (end + length <= LOCAL_ELEMS))
     164                 :  1006270725 :             for (unsigned int j = 0; j < length; j++)
     165                 :   677342070 :               base[end++] = T::get_value (vec[j]);
     166                 :             :           else
     167                 :     8023734 :             for (unsigned int j = 0; j < length; j++)
     168                 :     7665910 :               base = add_single_to_queue (array, base, end++,
     169                 :     7665910 :                                           T::get_value (vec[j]));
     170                 :   329286479 :           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                 :   323592425 :   return end - orig_end;
     184                 :             : }
     185                 :             : 
     186                 :             : template <typename T>
     187                 :             : void
     188                 :      275225 : generic_subrtx_iterator <T>::free_array (array_type &array)
     189                 :             : {
     190                 :      275225 :   vec_free (array.heap);
     191                 :      275225 : }
     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                 :   494580564 : rtx_varies_p (const_rtx x, bool for_alias)
     273                 :             : {
     274                 :   494580564 :   RTX_CODE code;
     275                 :   494580564 :   int i;
     276                 :   494580564 :   const char *fmt;
     277                 :             : 
     278                 :   494580564 :   if (!x)
     279                 :             :     return false;
     280                 :             : 
     281                 :   494580564 :   code = GET_CODE (x);
     282                 :   494580564 :   switch (code)
     283                 :             :     {
     284                 :    90949131 :     case MEM:
     285                 :    90949131 :       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                 :   160065623 :     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                 :   160065623 :       if (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
     299                 :             :           /* The arg pointer varies if it is not a fixed register.  */
     300                 :   141636091 :           || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM]))
     301                 :             :         return false;
     302                 :   141408449 :       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                 :       90042 :     case ASM_OPERANDS:
     319                 :       90042 :       if (MEM_VOLATILE_P (x))
     320                 :             :         return true;
     321                 :             : 
     322                 :             :       /* Fall through.  */
     323                 :             : 
     324                 :   137361858 :     default:
     325                 :   137361858 :       break;
     326                 :             :     }
     327                 :             : 
     328                 :   137361858 :   fmt = GET_RTX_FORMAT (code);
     329                 :   241706453 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
     330                 :   218920012 :     if (fmt[i] == 'e')
     331                 :             :       {
     332                 :   201016091 :         if (rtx_varies_p (XEXP (x, i), for_alias))
     333                 :             :           return true;
     334                 :             :       }
     335                 :    17903921 :     else if (fmt[i] == 'E')
     336                 :             :       {
     337                 :             :         int j;
     338                 :    18710862 :         for (j = 0; j < XVECLEN (x, i); j++)
     339                 :    14735473 :           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                 :   235112901 : get_initial_register_offset (int from, int to)
     352                 :             : {
     353                 :   235112901 :   static const struct elim_table_t
     354                 :             :   {
     355                 :             :     const int from;
     356                 :             :     const int to;
     357                 :             :   } table[] = ELIMINABLE_REGS;
     358                 :   235112901 :   poly_int64 offset1, offset2;
     359                 :   235112901 :   unsigned int i, j;
     360                 :             : 
     361                 :   235112901 :   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                 :   235112901 :   if (!epilogue_completed)
     368                 :             :     {
     369                 :   129492537 :       offset1 = crtl->outgoing_args_size + get_frame_size ();
     370                 :             : #if !STACK_GROWS_DOWNWARD
     371                 :             :       offset1 = - offset1;
     372                 :             : #endif
     373                 :   129492537 :       if (to == STACK_POINTER_REGNUM)
     374                 :   129007783 :         return offset1;
     375                 :      484754 :       else if (from == STACK_POINTER_REGNUM)
     376                 :      242377 :         return - offset1;
     377                 :             :       else
     378                 :      242377 :         return 0;
     379                 :             :      }
     380                 :             : 
     381                 :   106699322 :   for (i = 0; i < ARRAY_SIZE (table); i++)
     382                 :   106699322 :       if (table[i].from == from)
     383                 :             :         {
     384                 :   105620364 :           if (table[i].to == to)
     385                 :             :             {
     386                 :   104541406 :               INITIAL_ELIMINATION_OFFSET (table[i].from, table[i].to,
     387                 :             :                                           offset1);
     388                 :   104541406 :               return offset1;
     389                 :             :             }
     390                 :     5394790 :           for (j = 0; j < ARRAY_SIZE (table); j++)
     391                 :             :             {
     392                 :     4315832 :               if (table[j].to == to
     393                 :     2157916 :                   && 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                 :     4315832 :               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                 :     1078958 :       else if (table[i].to == from)
     413                 :             :         {
     414                 :     1078958 :           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                 :     2157916 :           for (j = 0; j < ARRAY_SIZE (table); j++)
     421                 :             :             {
     422                 :     2157916 :               if (table[j].to == to
     423                 :     1078958 :                   && table[j].from == table[i].from)
     424                 :             :                 {
     425                 :     1078958 :                   INITIAL_ELIMINATION_OFFSET (table[i].from, table[i].to,
     426                 :             :                                               offset1);
     427                 :     1078958 :                   INITIAL_ELIMINATION_OFFSET (table[j].from, table[j].to,
     428                 :             :                                               offset2);
     429                 :     1078958 :                   return - offset1 + offset2;
     430                 :             :                 }
     431                 :     1078958 :               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                 :   777943274 : rtx_addr_can_trap_p_1 (const_rtx x, poly_int64 offset, poly_int64 size,
     464                 :             :                        machine_mode mode, bool unaligned_mems)
     465                 :             : {
     466                 :   777943274 :   enum rtx_code code = GET_CODE (x);
     467                 :   777943274 :   gcc_checking_assert (mode == BLKmode
     468                 :             :                        || mode == VOIDmode
     469                 :             :                        || known_size_p (size));
     470                 :   777943274 :   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                 :   777943274 :   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                 :   777943274 :   switch (code)
     495                 :             :     {
     496                 :     6012823 :     case SYMBOL_REF:
     497                 :     6012823 :       if (SYMBOL_REF_WEAK (x))
     498                 :             :         return true;
     499                 :     5676075 :       if (!CONSTANT_POOL_ADDRESS_P (x) && !SYMBOL_REF_FUNCTION_P (x))
     500                 :             :         {
     501                 :      690014 :           tree decl;
     502                 :      690014 :           poly_int64 decl_size;
     503                 :             : 
     504                 :      690014 :           if (maybe_lt (offset, 0))
     505                 :             :             return true;
     506                 :      688974 :           if (!known_size_p (size))
     507                 :         661 :             return maybe_ne (offset, 0);
     508                 :             : 
     509                 :             :           /* If the size of the access or of the symbol is unknown,
     510                 :             :              assume the worst.  */
     511                 :      688313 :           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                 :      688313 :           if (!decl)
     516                 :      239826 :             decl_size = -1;
     517                 :      448487 :           else if (DECL_P (decl) && DECL_SIZE_UNIT (decl))
     518                 :             :             {
     519                 :      440632 :               if (!poly_int_tree_p (DECL_SIZE_UNIT (decl), &decl_size))
     520                 :           0 :                 decl_size = -1;
     521                 :             :             }
     522                 :        7855 :           else if (TREE_CODE (decl) == STRING_CST)
     523                 :           0 :             decl_size = TREE_STRING_LENGTH (decl);
     524                 :        7855 :           else if (TYPE_SIZE_UNIT (TREE_TYPE (decl)))
     525                 :           0 :             decl_size = int_size_in_bytes (TREE_TYPE (decl));
     526                 :             :           else
     527                 :        7855 :             decl_size = -1;
     528                 :             : 
     529                 :      688313 :           return (!known_size_p (decl_size) || known_eq (decl_size, 0)
     530                 :      689189 :                   ? maybe_ne (offset, 0)
     531                 :      688313 :                   : !known_subrange_p (offset, size, 0, decl_size));
     532                 :             :         }
     533                 :             : 
     534                 :             :       return false;
     535                 :             : 
     536                 :             :     case LABEL_REF:
     537                 :             :       return false;
     538                 :             : 
     539                 :   391440433 :     case REG:
     540                 :             :       /* Stack references are assumed not to trap, but we need to deal with
     541                 :             :          nonsensical offsets.  */
     542                 :   391440433 :       if (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
     543                 :   383666521 :          || x == stack_pointer_rtx
     544                 :             :          /* The arg pointer varies if it is not a fixed register.  */
     545                 :   151193332 :          || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM]))
     546                 :             :         {
     547                 :             : #ifdef RED_ZONE_SIZE
     548                 :   240332559 :           poly_int64 red_zone_size = RED_ZONE_SIZE;
     549                 :             : #else
     550                 :             :           poly_int64 red_zone_size = 0;
     551                 :             : #endif
     552                 :   240332559 :           poly_int64 stack_boundary = PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT;
     553                 :   240332559 :           poly_int64 low_bound, high_bound;
     554                 :             : 
     555                 :   240332559 :           if (!known_size_p (size))
     556                 :             :             return true;
     557                 :             : 
     558                 :   240328567 :           if (x == frame_pointer_rtx)
     559                 :             :             {
     560                 :     6451543 :               if (FRAME_GROWS_DOWNWARD)
     561                 :             :                 {
     562                 :     6451543 :                   high_bound = targetm.starting_frame_offset ();
     563                 :     6451543 :                   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                 :   233877024 :           else if (x == hard_frame_pointer_rtx)
     572                 :             :             {
     573                 :     1321335 :               poly_int64 sp_offset
     574                 :     1321335 :                 = get_initial_register_offset (STACK_POINTER_REGNUM,
     575                 :             :                                                HARD_FRAME_POINTER_REGNUM);
     576                 :     1321335 :               poly_int64 ap_offset
     577                 :     1321335 :                 = get_initial_register_offset (ARG_POINTER_REGNUM,
     578                 :             :                                                HARD_FRAME_POINTER_REGNUM);
     579                 :             : 
     580                 :             : #if STACK_GROWS_DOWNWARD
     581                 :     1321335 :               low_bound  = sp_offset - red_zone_size - stack_boundary;
     582                 :     1321335 :               high_bound = ap_offset
     583                 :     1321335 :                            + FIRST_PARM_OFFSET (current_function_decl)
     584                 :             : #if !ARGS_GROW_DOWNWARD
     585                 :     1321335 :                            + crtl->args.size
     586                 :             : #endif
     587                 :     1321335 :                            + 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                 :   232555689 :           else if (x == stack_pointer_rtx)
     599                 :             :             {
     600                 :   232470231 :               poly_int64 ap_offset
     601                 :   232470231 :                 = get_initial_register_offset (ARG_POINTER_REGNUM,
     602                 :             :                                                STACK_POINTER_REGNUM);
     603                 :             : 
     604                 :             : #if STACK_GROWS_DOWNWARD
     605                 :   232470231 :               low_bound  = - red_zone_size - stack_boundary;
     606                 :   232470231 :               high_bound = ap_offset
     607                 :   232470231 :                            + FIRST_PARM_OFFSET (current_function_decl)
     608                 :             : #if !ARGS_GROW_DOWNWARD
     609                 :   232470231 :                            + crtl->args.size
     610                 :             : #endif
     611                 :   232470231 :                            + 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                 :       85458 :               low_bound  = FIRST_PARM_OFFSET (current_function_decl)
     634                 :       85458 :                            - stack_boundary;
     635                 :       85458 :               high_bound = FIRST_PARM_OFFSET (current_function_decl)
     636                 :       85458 :                            + crtl->args.size + stack_boundary;
     637                 :             : #endif
     638                 :             :             }
     639                 :             : 
     640                 :   240328567 :           if (known_ge (offset, low_bound)
     641                 :   240328567 :               && known_le (offset, high_bound - size))
     642                 :             :             return false;
     643                 :             :           return true;
     644                 :             :         }
     645                 :             :       /* All of the virtual frame registers are stack references.  */
     646                 :   151107874 :       if (VIRTUAL_REGISTER_P (x))
     647                 :             :         return false;
     648                 :             :       return true;
     649                 :             : 
     650                 :      288002 :     case CONST:
     651                 :      288002 :       return rtx_addr_can_trap_p_1 (XEXP (x, 0), offset, size,
     652                 :      288002 :                                     mode, unaligned_mems);
     653                 :             : 
     654                 :   160581639 :     case PLUS:
     655                 :             :       /* An address is assumed not to trap if:
     656                 :             :          - it is the pic register plus a const unspec without offset.  */
     657                 :   160581639 :       if (XEXP (x, 0) == pic_offset_table_rtx
     658                 :       38316 :           && GET_CODE (XEXP (x, 1)) == CONST
     659                 :       38282 :           && GET_CODE (XEXP (XEXP (x, 1), 0)) == UNSPEC
     660                 :   160616772 :           && known_eq (offset, 0))
     661                 :             :         return false;
     662                 :             : 
     663                 :             :       /* - or it is an address that can't trap plus a constant integer.  */
     664                 :   160546506 :       if (poly_int_rtx_p (XEXP (x, 1), &const_x1)
     665                 :   136201263 :           && !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                 :      409848 :     case LO_SUM:
     672                 :      409848 :     case PRE_MODIFY:
     673                 :      409848 :       return rtx_addr_can_trap_p_1 (XEXP (x, 1), offset, size,
     674                 :      409848 :                                     mode, unaligned_mems);
     675                 :             : 
     676                 :   193417888 :     case PRE_DEC:
     677                 :   193417888 :     case PRE_INC:
     678                 :   193417888 :     case POST_DEC:
     679                 :   193417888 :     case POST_INC:
     680                 :   193417888 :     case POST_MODIFY:
     681                 :   193417888 :       return rtx_addr_can_trap_p_1 (XEXP (x, 0), offset, size,
     682                 :   193417888 :                                     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                 :    13649002 : rtx_addr_can_trap_p (const_rtx x)
     696                 :             : {
     697                 :    13649002 :   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                 :    22032887 : contains_mem_rtx_p (rtx x)
     704                 :             : {
     705                 :    22032887 :   subrtx_iterator::array_type array;
     706                 :    68532770 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
     707                 :    53601396 :     if (MEM_P (*iter))
     708                 :     7101513 :       return true;
     709                 :             : 
     710                 :    14931374 :   return false;
     711                 :    22032887 : }
     712                 :             : 
     713                 :             : /* Return true if X is an address that is known to not be zero.  */
     714                 :             : 
     715                 :             : bool
     716                 :    55319858 : nonzero_address_p (const_rtx x)
     717                 :             : {
     718                 :    55322378 :   const enum rtx_code code = GET_CODE (x);
     719                 :             : 
     720                 :    55322378 :   switch (code)
     721                 :             :     {
     722                 :        3532 :     case SYMBOL_REF:
     723                 :        3532 :       return flag_delete_null_pointer_checks && !SYMBOL_REF_WEAK (x);
     724                 :             : 
     725                 :             :     case LABEL_REF:
     726                 :             :       return true;
     727                 :             : 
     728                 :    26631922 :     case REG:
     729                 :             :       /* As in rtx_varies_p, we have to use the actual rtx, not reg number.  */
     730                 :    26631922 :       if (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
     731                 :    26631816 :           || x == stack_pointer_rtx
     732                 :    26631816 :           || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM]))
     733                 :             :         return true;
     734                 :             :       /* All of the virtual frame registers are stack references.  */
     735                 :    26631816 :       if (VIRTUAL_REGISTER_P (x))
     736                 :             :         return true;
     737                 :             :       return false;
     738                 :             : 
     739                 :        2520 :     case CONST:
     740                 :        2520 :       return nonzero_address_p (XEXP (x, 0));
     741                 :             : 
     742                 :    11854793 :     case PLUS:
     743                 :             :       /* Handle PIC references.  */
     744                 :    11854793 :       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                 :             : /* Get the declaration of the function called by INSN.  */
     817                 :             : 
     818                 :             : tree
     819                 :   292391776 : get_call_fndecl (const rtx_insn *insn)
     820                 :             : {
     821                 :   292391776 :   rtx note, datum;
     822                 :             : 
     823                 :   292391776 :   note = find_reg_note (insn, REG_CALL_DECL, NULL_RTX);
     824                 :   292391776 :   if (note == NULL_RTX)
     825                 :             :     return NULL_TREE;
     826                 :             : 
     827                 :   289501086 :   datum = XEXP (note, 0);
     828                 :   289501086 :   if (datum != NULL_RTX)
     829                 :   278758407 :     return SYMBOL_REF_DECL (datum);
     830                 :             : 
     831                 :             :   return NULL_TREE;
     832                 :             : }
     833                 :             : 
     834                 :             : /* Return the value of the integer term in X, if one is apparent;
     835                 :             :    otherwise return 0.
     836                 :             :    Only obvious integer terms are detected.
     837                 :             :    This is used in cse.cc with the `related_value' field.  */
     838                 :             : 
     839                 :             : HOST_WIDE_INT
     840                 :      486930 : get_integer_term (const_rtx x)
     841                 :             : {
     842                 :      486930 :   if (GET_CODE (x) == CONST)
     843                 :      274151 :     x = XEXP (x, 0);
     844                 :             : 
     845                 :      486930 :   if (GET_CODE (x) == MINUS
     846                 :           0 :       && CONST_INT_P (XEXP (x, 1)))
     847                 :           0 :     return - INTVAL (XEXP (x, 1));
     848                 :      486930 :   if (GET_CODE (x) == PLUS
     849                 :      274151 :       && CONST_INT_P (XEXP (x, 1)))
     850                 :      274151 :     return INTVAL (XEXP (x, 1));
     851                 :             :   return 0;
     852                 :             : }
     853                 :             : 
     854                 :             : /* If X is a constant, return the value sans apparent integer term;
     855                 :             :    otherwise return 0.
     856                 :             :    Only obvious integer terms are detected.  */
     857                 :             : 
     858                 :             : rtx
     859                 :     1378733 : get_related_value (const_rtx x)
     860                 :             : {
     861                 :     1378733 :   if (GET_CODE (x) != CONST)
     862                 :             :     return 0;
     863                 :     1378733 :   x = XEXP (x, 0);
     864                 :     1378733 :   if (GET_CODE (x) == PLUS
     865                 :     1350970 :       && CONST_INT_P (XEXP (x, 1)))
     866                 :     1350970 :     return XEXP (x, 0);
     867                 :       27763 :   else if (GET_CODE (x) == MINUS
     868                 :           0 :            && CONST_INT_P (XEXP (x, 1)))
     869                 :           0 :     return XEXP (x, 0);
     870                 :             :   return 0;
     871                 :             : }
     872                 :             : 
     873                 :             : /* Return true if SYMBOL is a SYMBOL_REF and OFFSET + SYMBOL points
     874                 :             :    to somewhere in the same object or object_block as SYMBOL.  */
     875                 :             : 
     876                 :             : bool
     877                 :           0 : offset_within_block_p (const_rtx symbol, HOST_WIDE_INT offset)
     878                 :             : {
     879                 :           0 :   tree decl;
     880                 :             : 
     881                 :           0 :   if (GET_CODE (symbol) != SYMBOL_REF)
     882                 :             :     return false;
     883                 :             : 
     884                 :           0 :   if (offset == 0)
     885                 :             :     return true;
     886                 :             : 
     887                 :           0 :   if (offset > 0)
     888                 :             :     {
     889                 :           0 :       if (CONSTANT_POOL_ADDRESS_P (symbol)
     890                 :           0 :           && offset < (int) GET_MODE_SIZE (get_pool_mode (symbol)))
     891                 :           0 :         return true;
     892                 :             : 
     893                 :           0 :       decl = SYMBOL_REF_DECL (symbol);
     894                 :           0 :       if (decl && offset < int_size_in_bytes (TREE_TYPE (decl)))
     895                 :             :         return true;
     896                 :             :     }
     897                 :             : 
     898                 :           0 :   if (SYMBOL_REF_HAS_BLOCK_INFO_P (symbol)
     899                 :           0 :       && SYMBOL_REF_BLOCK (symbol)
     900                 :           0 :       && SYMBOL_REF_BLOCK_OFFSET (symbol) >= 0
     901                 :           0 :       && ((unsigned HOST_WIDE_INT) offset + SYMBOL_REF_BLOCK_OFFSET (symbol)
     902                 :           0 :           < (unsigned HOST_WIDE_INT) SYMBOL_REF_BLOCK (symbol)->size))
     903                 :             :     return true;
     904                 :             : 
     905                 :             :   return false;
     906                 :             : }
     907                 :             : 
     908                 :             : /* Split X into a base and a constant offset, storing them in *BASE_OUT
     909                 :             :    and *OFFSET_OUT respectively.  */
     910                 :             : 
     911                 :             : void
     912                 :           0 : split_const (rtx x, rtx *base_out, rtx *offset_out)
     913                 :             : {
     914                 :           0 :   if (GET_CODE (x) == CONST)
     915                 :             :     {
     916                 :           0 :       x = XEXP (x, 0);
     917                 :           0 :       if (GET_CODE (x) == PLUS && CONST_INT_P (XEXP (x, 1)))
     918                 :             :         {
     919                 :           0 :           *base_out = XEXP (x, 0);
     920                 :           0 :           *offset_out = XEXP (x, 1);
     921                 :           0 :           return;
     922                 :             :         }
     923                 :             :     }
     924                 :           0 :   *base_out = x;
     925                 :           0 :   *offset_out = const0_rtx;
     926                 :             : }
     927                 :             : 
     928                 :             : /* Express integer value X as some value Y plus a polynomial offset,
     929                 :             :    where Y is either const0_rtx, X or something within X (as opposed
     930                 :             :    to a new rtx).  Return the Y and store the offset in *OFFSET_OUT.  */
     931                 :             : 
     932                 :             : rtx
     933                 :   394795354 : strip_offset (rtx x, poly_int64 *offset_out)
     934                 :             : {
     935                 :   394795354 :   rtx base = const0_rtx;
     936                 :   394795354 :   rtx test = x;
     937                 :   394795354 :   if (GET_CODE (test) == CONST)
     938                 :     8540651 :     test = XEXP (test, 0);
     939                 :   394795354 :   if (GET_CODE (test) == PLUS)
     940                 :             :     {
     941                 :   299801838 :       base = XEXP (test, 0);
     942                 :   299801838 :       test = XEXP (test, 1);
     943                 :             :     }
     944                 :   394795354 :   if (poly_int_rtx_p (test, offset_out))
     945                 :   281230328 :     return base;
     946                 :   113565026 :   *offset_out = 0;
     947                 :   113565026 :   return x;
     948                 :             : }
     949                 :             : 
     950                 :             : /* Return the argument size in REG_ARGS_SIZE note X.  */
     951                 :             : 
     952                 :             : poly_int64
     953                 :     5254740 : get_args_size (const_rtx x)
     954                 :             : {
     955                 :     5254740 :   gcc_checking_assert (REG_NOTE_KIND (x) == REG_ARGS_SIZE);
     956                 :     5254740 :   return rtx_to_poly_int64 (XEXP (x, 0));
     957                 :             : }
     958                 :             : 
     959                 :             : /* Return the number of places FIND appears within X.  If COUNT_DEST is
     960                 :             :    zero, we do not count occurrences inside the destination of a SET.  */
     961                 :             : 
     962                 :             : int
     963                 :     8910213 : count_occurrences (const_rtx x, const_rtx find, int count_dest)
     964                 :             : {
     965                 :     8910213 :   int i, j;
     966                 :     8910213 :   enum rtx_code code;
     967                 :     8910213 :   const char *format_ptr;
     968                 :     8910213 :   int count;
     969                 :             : 
     970                 :     8910213 :   if (x == find)
     971                 :             :     return 1;
     972                 :             : 
     973                 :     6511175 :   code = GET_CODE (x);
     974                 :             : 
     975                 :     6511175 :   switch (code)
     976                 :             :     {
     977                 :             :     case REG:
     978                 :             :     CASE_CONST_ANY:
     979                 :             :     case SYMBOL_REF:
     980                 :             :     case CODE_LABEL:
     981                 :             :     case PC:
     982                 :             :       return 0;
     983                 :             : 
     984                 :           0 :     case EXPR_LIST:
     985                 :           0 :       count = count_occurrences (XEXP (x, 0), find, count_dest);
     986                 :           0 :       if (XEXP (x, 1))
     987                 :           0 :         count += count_occurrences (XEXP (x, 1), find, count_dest);
     988                 :             :       return count;
     989                 :             : 
     990                 :       72836 :     case MEM:
     991                 :       72836 :       if (MEM_P (find) && rtx_equal_p (x, find))
     992                 :             :         return 1;
     993                 :             :       break;
     994                 :             : 
     995                 :           0 :     case SET:
     996                 :           0 :       if (SET_DEST (x) == find && ! count_dest)
     997                 :           0 :         return count_occurrences (SET_SRC (x), find, count_dest);
     998                 :             :       break;
     999                 :             : 
    1000                 :             :     default:
    1001                 :             :       break;
    1002                 :             :     }
    1003                 :             : 
    1004                 :     3307658 :   format_ptr = GET_RTX_FORMAT (code);
    1005                 :     3307658 :   count = 0;
    1006                 :             : 
    1007                 :     9781194 :   for (i = 0; i < GET_RTX_LENGTH (code); i++)
    1008                 :             :     {
    1009                 :     6473536 :       switch (*format_ptr++)
    1010                 :             :         {
    1011                 :     6313543 :         case 'e':
    1012                 :     6313543 :           count += count_occurrences (XEXP (x, i), find, count_dest);
    1013                 :     6313543 :           break;
    1014                 :             : 
    1015                 :             :         case 'E':
    1016                 :      130648 :           for (j = 0; j < XVECLEN (x, i); j++)
    1017                 :      108062 :             count += count_occurrences (XVECEXP (x, i, j), find, count_dest);
    1018                 :             :           break;
    1019                 :             :         }
    1020                 :             :     }
    1021                 :             :   return count;
    1022                 :             : }
    1023                 :             : 
    1024                 :             : 
    1025                 :             : /* Return TRUE if OP is a register or subreg of a register that
    1026                 :             :    holds an unsigned quantity.  Otherwise, return FALSE.  */
    1027                 :             : 
    1028                 :             : bool
    1029                 :           0 : unsigned_reg_p (rtx op)
    1030                 :             : {
    1031                 :           0 :   if (REG_P (op)
    1032                 :           0 :       && REG_EXPR (op)
    1033                 :           0 :       && TYPE_UNSIGNED (TREE_TYPE (REG_EXPR (op))))
    1034                 :             :     return true;
    1035                 :             : 
    1036                 :           0 :   if (GET_CODE (op) == SUBREG
    1037                 :           0 :       && SUBREG_PROMOTED_SIGN (op))
    1038                 :           0 :     return true;
    1039                 :             : 
    1040                 :             :   return false;
    1041                 :             : }
    1042                 :             : 
    1043                 :             : 
    1044                 :             : /* Return true if register REG appears somewhere within IN.
    1045                 :             :    Also works if REG is not a register; in this case it checks
    1046                 :             :    for a subexpression of IN that is Lisp "equal" to REG.  */
    1047                 :             : 
    1048                 :             : bool
    1049                 :   422690856 : reg_mentioned_p (const_rtx reg, const_rtx in)
    1050                 :             : {
    1051                 :   422690856 :   const char *fmt;
    1052                 :   422690856 :   int i;
    1053                 :   422690856 :   enum rtx_code code;
    1054                 :             : 
    1055                 :   422690856 :   if (in == 0)
    1056                 :             :     return false;
    1057                 :             : 
    1058                 :   417630386 :   if (reg == in)
    1059                 :             :     return true;
    1060                 :             : 
    1061                 :   405845564 :   if (GET_CODE (in) == LABEL_REF)
    1062                 :     6017726 :     return reg == label_ref_label (in);
    1063                 :             : 
    1064                 :   399827838 :   code = GET_CODE (in);
    1065                 :             : 
    1066                 :   399827838 :   switch (code)
    1067                 :             :     {
    1068                 :             :       /* Compare registers by number.  */
    1069                 :   147666485 :     case REG:
    1070                 :   147666485 :       return REG_P (reg) && REGNO (in) == REGNO (reg);
    1071                 :             : 
    1072                 :             :       /* These codes have no constituent expressions
    1073                 :             :          and are unique.  */
    1074                 :             :     case SCRATCH:
    1075                 :             :     case PC:
    1076                 :             :       return false;
    1077                 :             : 
    1078                 :             :     CASE_CONST_ANY:
    1079                 :             :       /* These are kept unique for a given value.  */
    1080                 :             :       return false;
    1081                 :             : 
    1082                 :   152628304 :     default:
    1083                 :   152628304 :       break;
    1084                 :             :     }
    1085                 :             : 
    1086                 :   152628304 :   if (GET_CODE (reg) == code && rtx_equal_p (reg, in))
    1087                 :             :     return true;
    1088                 :             : 
    1089                 :   152464279 :   fmt = GET_RTX_FORMAT (code);
    1090                 :             : 
    1091                 :   405507408 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    1092                 :             :     {
    1093                 :   291019724 :       if (fmt[i] == 'E')
    1094                 :             :         {
    1095                 :     3001811 :           int j;
    1096                 :    10355843 :           for (j = XVECLEN (in, i) - 1; j >= 0; j--)
    1097                 :     7577882 :             if (reg_mentioned_p (reg, XVECEXP (in, i, j)))
    1098                 :             :               return true;
    1099                 :             :         }
    1100                 :   288017913 :       else if (fmt[i] == 'e'
    1101                 :   288017913 :                && reg_mentioned_p (reg, XEXP (in, i)))
    1102                 :             :         return true;
    1103                 :             :     }
    1104                 :             :   return false;
    1105                 :             : }
    1106                 :             : 
    1107                 :             : /* Return true if in between BEG and END, exclusive of BEG and END, there is
    1108                 :             :    no CODE_LABEL insn.  */
    1109                 :             : 
    1110                 :             : bool
    1111                 :           0 : no_labels_between_p (const rtx_insn *beg, const rtx_insn *end)
    1112                 :             : {
    1113                 :           0 :   rtx_insn *p;
    1114                 :           0 :   if (beg == end)
    1115                 :             :     return false;
    1116                 :           0 :   for (p = NEXT_INSN (beg); p != end; p = NEXT_INSN (p))
    1117                 :           0 :     if (LABEL_P (p))
    1118                 :             :       return false;
    1119                 :             :   return true;
    1120                 :             : }
    1121                 :             : 
    1122                 :             : /* Return true if register REG is used in an insn between
    1123                 :             :    FROM_INSN and TO_INSN (exclusive of those two).  */
    1124                 :             : 
    1125                 :             : bool
    1126                 :    23097033 : reg_used_between_p (const_rtx reg, const rtx_insn *from_insn,
    1127                 :             :                     const rtx_insn *to_insn)
    1128                 :             : {
    1129                 :    23097033 :   rtx_insn *insn;
    1130                 :             : 
    1131                 :    23097033 :   if (from_insn == to_insn)
    1132                 :             :     return false;
    1133                 :             : 
    1134                 :   173092904 :   for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
    1135                 :   127238341 :     if (NONDEBUG_INSN_P (insn)
    1136                 :   127238341 :         && (reg_overlap_mentioned_p (reg, PATTERN (insn))
    1137                 :    67880395 :            || (CALL_P (insn) && find_reg_fusage (insn, USE, reg))))
    1138                 :      339503 :       return true;
    1139                 :             :   return false;
    1140                 :             : }
    1141                 :             : 
    1142                 :             : /* Return true if the old value of X, a register, is referenced in BODY.  If X
    1143                 :             :    is entirely replaced by a new value and the only use is as a SET_DEST,
    1144                 :             :    we do not consider it a reference.  */
    1145                 :             : 
    1146                 :             : bool
    1147                 :   124212536 : reg_referenced_p (const_rtx x, const_rtx body)
    1148                 :             : {
    1149                 :   124212536 :   int i;
    1150                 :             : 
    1151                 :   124212536 :   switch (GET_CODE (body))
    1152                 :             :     {
    1153                 :    88968369 :     case SET:
    1154                 :    88968369 :       if (reg_overlap_mentioned_p (x, SET_SRC (body)))
    1155                 :             :         return true;
    1156                 :             : 
    1157                 :             :       /* If the destination is anything other than PC, a REG or a SUBREG
    1158                 :             :          of a REG that occupies all of the REG, the insn references X if
    1159                 :             :          it is mentioned in the destination.  */
    1160                 :    62348148 :       if (GET_CODE (SET_DEST (body)) != PC
    1161                 :    62348148 :           && !REG_P (SET_DEST (body))
    1162                 :     2765401 :           && ! (GET_CODE (SET_DEST (body)) == SUBREG
    1163                 :      521374 :                 && REG_P (SUBREG_REG (SET_DEST (body)))
    1164                 :      521374 :                 && !read_modify_subreg_p (SET_DEST (body)))
    1165                 :    64253114 :           && reg_overlap_mentioned_p (x, SET_DEST (body)))
    1166                 :             :         return true;
    1167                 :             :       return false;
    1168                 :             : 
    1169                 :        6724 :     case ASM_OPERANDS:
    1170                 :       15853 :       for (i = ASM_OPERANDS_INPUT_LENGTH (body) - 1; i >= 0; i--)
    1171                 :       14621 :         if (reg_overlap_mentioned_p (x, ASM_OPERANDS_INPUT (body, i)))
    1172                 :             :           return true;
    1173                 :             :       return false;
    1174                 :             : 
    1175                 :      747071 :     case CALL:
    1176                 :      747071 :     case USE:
    1177                 :      747071 :     case IF_THEN_ELSE:
    1178                 :      747071 :       return reg_overlap_mentioned_p (x, body);
    1179                 :             : 
    1180                 :           0 :     case TRAP_IF:
    1181                 :           0 :       return reg_overlap_mentioned_p (x, TRAP_CONDITION (body));
    1182                 :             : 
    1183                 :        2088 :     case PREFETCH:
    1184                 :        2088 :       return reg_overlap_mentioned_p (x, XEXP (body, 0));
    1185                 :             : 
    1186                 :       20075 :     case UNSPEC:
    1187                 :       20075 :     case UNSPEC_VOLATILE:
    1188                 :       40132 :       for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
    1189                 :       22668 :         if (reg_overlap_mentioned_p (x, XVECEXP (body, 0, i)))
    1190                 :             :           return true;
    1191                 :             :       return false;
    1192                 :             : 
    1193                 :    17758401 :     case PARALLEL:
    1194                 :    50969690 :       for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
    1195                 :    36641935 :         if (reg_referenced_p (x, XVECEXP (body, 0, i)))
    1196                 :             :           return true;
    1197                 :             :       return false;
    1198                 :             : 
    1199                 :    16703801 :     case CLOBBER:
    1200                 :    16703801 :       if (MEM_P (XEXP (body, 0)))
    1201                 :       11819 :         if (reg_overlap_mentioned_p (x, XEXP (XEXP (body, 0), 0)))
    1202                 :             :           return true;
    1203                 :             :       return false;
    1204                 :             : 
    1205                 :           0 :     case COND_EXEC:
    1206                 :           0 :       if (reg_overlap_mentioned_p (x, COND_EXEC_TEST (body)))
    1207                 :             :         return true;
    1208                 :           0 :       return reg_referenced_p (x, COND_EXEC_CODE (body));
    1209                 :             : 
    1210                 :             :     default:
    1211                 :             :       return false;
    1212                 :             :     }
    1213                 :             : }
    1214                 :             : 
    1215                 :             : /* Return true if register REG is set or clobbered in an insn between
    1216                 :             :    FROM_INSN and TO_INSN (exclusive of those two).  */
    1217                 :             : 
    1218                 :             : bool
    1219                 :    58866066 : reg_set_between_p (const_rtx reg, const rtx_insn *from_insn,
    1220                 :             :                    const rtx_insn *to_insn)
    1221                 :             : {
    1222                 :    58866066 :   const rtx_insn *insn;
    1223                 :             : 
    1224                 :    58866066 :   if (from_insn == to_insn)
    1225                 :             :     return false;
    1226                 :             : 
    1227                 :   297423232 :   for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
    1228                 :   183187958 :     if (INSN_P (insn) && reg_set_p (reg, insn))
    1229                 :             :       return true;
    1230                 :             :   return false;
    1231                 :             : }
    1232                 :             : 
    1233                 :             : /* Return true if REG is set or clobbered inside INSN.  */
    1234                 :             : 
    1235                 :             : bool
    1236                 :  1133651746 : reg_set_p (const_rtx reg, const_rtx insn)
    1237                 :             : {
    1238                 :             :   /* After delay slot handling, call and branch insns might be in a
    1239                 :             :      sequence.  Check all the elements there.  */
    1240                 :  1133651746 :   if (INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE)
    1241                 :             :     {
    1242                 :           0 :       for (int i = 0; i < XVECLEN (PATTERN (insn), 0); ++i)
    1243                 :           0 :         if (reg_set_p (reg, XVECEXP (PATTERN (insn), 0, i)))
    1244                 :             :           return true;
    1245                 :             : 
    1246                 :             :       return false;
    1247                 :             :     }
    1248                 :             : 
    1249                 :             :   /* We can be passed an insn or part of one.  If we are passed an insn,
    1250                 :             :      check if a side-effect of the insn clobbers REG.  */
    1251                 :  1133651746 :   if (INSN_P (insn)
    1252                 :  1133651746 :       && (FIND_REG_INC_NOTE (insn, reg)
    1253                 :             :           || (CALL_P (insn)
    1254                 :    66493440 :               && ((REG_P (reg)
    1255                 :    66493440 :                    && REGNO (reg) < FIRST_PSEUDO_REGISTER
    1256                 :    62277808 :                    && (insn_callee_abi (as_a<const rtx_insn *> (insn))
    1257                 :    62277808 :                        .clobbers_reg_p (GET_MODE (reg), REGNO (reg))))
    1258                 :    65486030 :                   || MEM_P (reg)
    1259                 :    65486030 :                   || find_reg_fusage (insn, CLOBBER, reg)))))
    1260                 :     1007546 :     return true;
    1261                 :             : 
    1262                 :             :   /* There are no REG_INC notes for SP autoinc.  */
    1263                 :  1132644200 :   if (reg == stack_pointer_rtx && INSN_P (insn))
    1264                 :             :     {
    1265                 :     6240336 :       subrtx_var_iterator::array_type array;
    1266                 :    50654537 :       FOR_EACH_SUBRTX_VAR (iter, array, PATTERN (insn), NONCONST)
    1267                 :             :         {
    1268                 :    45118012 :           rtx mem = *iter;
    1269                 :    45118012 :           if (mem
    1270                 :    45118012 :               && MEM_P (mem)
    1271                 :     4991805 :               && GET_RTX_CLASS (GET_CODE (XEXP (mem, 0))) == RTX_AUTOINC)
    1272                 :             :             {
    1273                 :      703811 :               if (XEXP (XEXP (mem, 0), 0) == stack_pointer_rtx)
    1274                 :      703811 :                 return true;
    1275                 :           0 :               iter.skip_subrtxes ();
    1276                 :             :             }
    1277                 :             :         }
    1278                 :     6240336 :     }
    1279                 :             : 
    1280                 :  1131940389 :   return set_of (reg, insn) != NULL_RTX;
    1281                 :             : }
    1282                 :             : 
    1283                 :             : /* Similar to reg_set_between_p, but check all registers in X.  Return false
    1284                 :             :    only if none of them are modified between START and END.  Return true if
    1285                 :             :    X contains a MEM; this routine does use memory aliasing.  */
    1286                 :             : 
    1287                 :             : bool
    1288                 :   152570887 : modified_between_p (const_rtx x, const rtx_insn *start, const rtx_insn *end)
    1289                 :             : {
    1290                 :   152570887 :   const enum rtx_code code = GET_CODE (x);
    1291                 :   152570887 :   const char *fmt;
    1292                 :   152570887 :   int i, j;
    1293                 :   152570887 :   rtx_insn *insn;
    1294                 :             : 
    1295                 :   152570887 :   if (start == end)
    1296                 :             :     return false;
    1297                 :             : 
    1298                 :   152570887 :   switch (code)
    1299                 :             :     {
    1300                 :             :     CASE_CONST_ANY:
    1301                 :             :     case CONST:
    1302                 :             :     case SYMBOL_REF:
    1303                 :             :     case LABEL_REF:
    1304                 :             :       return false;
    1305                 :             : 
    1306                 :             :     case PC:
    1307                 :             :       return true;
    1308                 :             : 
    1309                 :    10367297 :     case MEM:
    1310                 :    10367297 :       if (modified_between_p (XEXP (x, 0), start, end))
    1311                 :             :         return true;
    1312                 :    10358567 :       if (MEM_READONLY_P (x))
    1313                 :             :         return false;
    1314                 :    55641165 :       for (insn = NEXT_INSN (start); insn != end; insn = NEXT_INSN (insn))
    1315                 :    35825032 :         if (memory_modified_in_insn_p (x, insn))
    1316                 :             :           return true;
    1317                 :             :       return false;
    1318                 :             : 
    1319                 :    55664872 :     case REG:
    1320                 :    55664872 :       return reg_set_between_p (x, start, end);
    1321                 :             : 
    1322                 :    49572589 :     default:
    1323                 :    49572589 :       break;
    1324                 :             :     }
    1325                 :             : 
    1326                 :    49572589 :   fmt = GET_RTX_FORMAT (code);
    1327                 :   145526743 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    1328                 :             :     {
    1329                 :    97265756 :       if (fmt[i] == 'e' && modified_between_p (XEXP (x, i), start, end))
    1330                 :             :         return true;
    1331                 :             : 
    1332                 :    95954827 :       else if (fmt[i] == 'E')
    1333                 :     3628553 :         for (j = XVECLEN (x, i) - 1; j >= 0; j--)
    1334                 :     2630166 :           if (modified_between_p (XVECEXP (x, i, j), start, end))
    1335                 :             :             return true;
    1336                 :             :     }
    1337                 :             : 
    1338                 :             :   return false;
    1339                 :             : }
    1340                 :             : 
    1341                 :             : /* Similar to reg_set_p, but check all registers in X.  Return false only if
    1342                 :             :    none of them are modified in INSN.  Return true if X contains a MEM; this
    1343                 :             :    routine does use memory aliasing.  */
    1344                 :             : 
    1345                 :             : bool
    1346                 :  1049382325 : modified_in_p (const_rtx x, const_rtx insn)
    1347                 :             : {
    1348                 :  1049382325 :   const enum rtx_code code = GET_CODE (x);
    1349                 :  1049382325 :   const char *fmt;
    1350                 :  1049382325 :   int i, j;
    1351                 :             : 
    1352                 :  1049382325 :   switch (code)
    1353                 :             :     {
    1354                 :             :     CASE_CONST_ANY:
    1355                 :             :     case CONST:
    1356                 :             :     case SYMBOL_REF:
    1357                 :             :     case LABEL_REF:
    1358                 :             :       return false;
    1359                 :             : 
    1360                 :             :     case PC:
    1361                 :             :       return true;
    1362                 :             : 
    1363                 :     8089449 :     case MEM:
    1364                 :     8089449 :       if (modified_in_p (XEXP (x, 0), insn))
    1365                 :             :         return true;
    1366                 :     8048854 :       if (MEM_READONLY_P (x))
    1367                 :             :         return false;
    1368                 :     7831678 :       if (memory_modified_in_insn_p (x, insn))
    1369                 :             :         return true;
    1370                 :             :       return false;
    1371                 :             : 
    1372                 :   915199894 :     case REG:
    1373                 :   915199894 :       return reg_set_p (x, insn);
    1374                 :             : 
    1375                 :    70835833 :     default:
    1376                 :    70835833 :       break;
    1377                 :             :     }
    1378                 :             : 
    1379                 :    70835833 :   fmt = GET_RTX_FORMAT (code);
    1380                 :   203633910 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    1381                 :             :     {
    1382                 :   138872711 :       if (fmt[i] == 'e' && modified_in_p (XEXP (x, i), insn))
    1383                 :             :         return true;
    1384                 :             : 
    1385                 :   132806634 :       else if (fmt[i] == 'E')
    1386                 :     1320948 :         for (j = XVECLEN (x, i) - 1; j >= 0; j--)
    1387                 :      681500 :           if (modified_in_p (XVECEXP (x, i, j), insn))
    1388                 :             :             return true;
    1389                 :             :     }
    1390                 :             : 
    1391                 :             :   return false;
    1392                 :             : }
    1393                 :             : 
    1394                 :             : /* Return true if X is a SUBREG and if storing a value to X would
    1395                 :             :    preserve some of its SUBREG_REG.  For example, on a normal 32-bit
    1396                 :             :    target, using a SUBREG to store to one half of a DImode REG would
    1397                 :             :    preserve the other half.  */
    1398                 :             : 
    1399                 :             : bool
    1400                 :   141949962 : read_modify_subreg_p (const_rtx x)
    1401                 :             : {
    1402                 :   141949962 :   if (GET_CODE (x) != SUBREG)
    1403                 :             :     return false;
    1404                 :    47729884 :   poly_uint64 isize = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)));
    1405                 :    47729884 :   poly_uint64 osize = GET_MODE_SIZE (GET_MODE (x));
    1406                 :    23864942 :   poly_uint64 regsize = REGMODE_NATURAL_SIZE (GET_MODE (SUBREG_REG (x)));
    1407                 :             :   /* The inner and outer modes of a subreg must be ordered, so that we
    1408                 :             :      can tell whether they're paradoxical or partial.  */
    1409                 :    23864942 :   gcc_checking_assert (ordered_p (isize, osize));
    1410                 :    23864942 :   return (maybe_gt (isize, osize) && maybe_gt (isize, regsize));
    1411                 :             : }
    1412                 :             : 
    1413                 :             : /* Helper function for set_of.  */
    1414                 :             : struct set_of_data
    1415                 :             :   {
    1416                 :             :     const_rtx found;
    1417                 :             :     const_rtx pat;
    1418                 :             :   };
    1419                 :             : 
    1420                 :             : static void
    1421                 :  1204012078 : set_of_1 (rtx x, const_rtx pat, void *data1)
    1422                 :             : {
    1423                 :  1204012078 :   struct set_of_data *const data = (struct set_of_data *) (data1);
    1424                 :  1204012078 :   if (rtx_equal_p (x, data->pat)
    1425                 :  1204012078 :       || (!MEM_P (x) && reg_overlap_mentioned_p (data->pat, x)))
    1426                 :    61616259 :     data->found = pat;
    1427                 :  1204012078 : }
    1428                 :             : 
    1429                 :             : /* Give an INSN, return a SET or CLOBBER expression that does modify PAT
    1430                 :             :    (either directly or via STRICT_LOW_PART and similar modifiers).  */
    1431                 :             : const_rtx
    1432                 :  1181906515 : set_of (const_rtx pat, const_rtx insn)
    1433                 :             : {
    1434                 :  1181906515 :   struct set_of_data data;
    1435                 :  1181906515 :   data.found = NULL_RTX;
    1436                 :  1181906515 :   data.pat = pat;
    1437                 :  1181906515 :   note_pattern_stores (INSN_P (insn) ? PATTERN (insn) : insn, set_of_1, &data);
    1438                 :  1181906515 :   return data.found;
    1439                 :             : }
    1440                 :             : 
    1441                 :             : /* Check whether instruction pattern PAT contains a SET with the following
    1442                 :             :    properties:
    1443                 :             : 
    1444                 :             :    - the SET is executed unconditionally; and
    1445                 :             :    - either:
    1446                 :             :      - the destination of the SET is a REG that contains REGNO; or
    1447                 :             :      - both:
    1448                 :             :        - the destination of the SET is a SUBREG of such a REG; and
    1449                 :             :        - writing to the subreg clobbers all of the SUBREG_REG
    1450                 :             :          (in other words, read_modify_subreg_p is false).
    1451                 :             : 
    1452                 :             :    If PAT does have a SET like that, return the set, otherwise return null.
    1453                 :             : 
    1454                 :             :    This is intended to be an alternative to single_set for passes that
    1455                 :             :    can handle patterns with multiple_sets.  */
    1456                 :             : rtx
    1457                 :   128745242 : simple_regno_set (rtx pat, unsigned int regno)
    1458                 :             : {
    1459                 :   128745242 :   if (GET_CODE (pat) == PARALLEL)
    1460                 :             :     {
    1461                 :    21687048 :       int last = XVECLEN (pat, 0) - 1;
    1462                 :    21687162 :       for (int i = 0; i < last; ++i)
    1463                 :    21687048 :         if (rtx set = simple_regno_set (XVECEXP (pat, 0, i), regno))
    1464                 :             :           return set;
    1465                 :             : 
    1466                 :         114 :       pat = XVECEXP (pat, 0, last);
    1467                 :             :     }
    1468                 :             : 
    1469                 :   107058308 :   if (GET_CODE (pat) == SET
    1470                 :   107058308 :       && covers_regno_no_parallel_p (SET_DEST (pat), regno))
    1471                 :             :     return pat;
    1472                 :             : 
    1473                 :             :   return nullptr;
    1474                 :             : }
    1475                 :             : 
    1476                 :             : /* Add all hard register in X to *PSET.  */
    1477                 :             : void
    1478                 :     3905621 : find_all_hard_regs (const_rtx x, HARD_REG_SET *pset)
    1479                 :             : {
    1480                 :     3905621 :   subrtx_iterator::array_type array;
    1481                 :    10591006 :   FOR_EACH_SUBRTX (iter, array, x, NONCONST)
    1482                 :             :     {
    1483                 :     6685385 :       const_rtx x = *iter;
    1484                 :     6685385 :       if (REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER)
    1485                 :     3315885 :         add_to_hard_reg_set (pset, GET_MODE (x), REGNO (x));
    1486                 :             :     }
    1487                 :     3905621 : }
    1488                 :             : 
    1489                 :             : /* This function, called through note_stores, collects sets and
    1490                 :             :    clobbers of hard registers in a HARD_REG_SET, which is pointed to
    1491                 :             :    by DATA.  */
    1492                 :             : void
    1493                 :    22399145 : record_hard_reg_sets (rtx x, const_rtx pat ATTRIBUTE_UNUSED, void *data)
    1494                 :             : {
    1495                 :    22399145 :   HARD_REG_SET *pset = (HARD_REG_SET *)data;
    1496                 :    22399145 :   if (REG_P (x) && HARD_REGISTER_P (x))
    1497                 :    14820584 :     add_to_hard_reg_set (pset, GET_MODE (x), REGNO (x));
    1498                 :    22399145 : }
    1499                 :             : 
    1500                 :             : /* Examine INSN, and compute the set of hard registers written by it.
    1501                 :             :    Store it in *PSET.  Should only be called after reload.
    1502                 :             : 
    1503                 :             :    IMPLICIT is true if we should include registers that are fully-clobbered
    1504                 :             :    by calls.  This should be used with caution, since it doesn't include
    1505                 :             :    partially-clobbered registers.  */
    1506                 :             : void
    1507                 :    17220008 : find_all_hard_reg_sets (const rtx_insn *insn, HARD_REG_SET *pset, bool implicit)
    1508                 :             : {
    1509                 :    17220008 :   rtx link;
    1510                 :             : 
    1511                 :    17220008 :   CLEAR_HARD_REG_SET (*pset);
    1512                 :    17220008 :   note_stores (insn, record_hard_reg_sets, pset);
    1513                 :    17220008 :   if (CALL_P (insn) && implicit)
    1514                 :           0 :     *pset |= insn_callee_abi (insn).full_reg_clobbers ();
    1515                 :    33751361 :   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    1516                 :    16531353 :     if (REG_NOTE_KIND (link) == REG_INC)
    1517                 :           0 :       record_hard_reg_sets (XEXP (link, 0), NULL, pset);
    1518                 :    17220008 : }
    1519                 :             : 
    1520                 :             : /* Like record_hard_reg_sets, but called through note_uses.  */
    1521                 :             : void
    1522                 :     3905621 : record_hard_reg_uses (rtx *px, void *data)
    1523                 :             : {
    1524                 :     3905621 :   find_all_hard_regs (*px, (HARD_REG_SET *) data);
    1525                 :     3905621 : }
    1526                 :             : 
    1527                 :             : /* Given an INSN, return a SET expression if this insn has only a single SET.
    1528                 :             :    It may also have CLOBBERs, USEs, or SET whose output
    1529                 :             :    will not be used, which we ignore.  */
    1530                 :             : 
    1531                 :             : rtx
    1532                 :  1898587424 : single_set_2 (const rtx_insn *insn, const_rtx pat)
    1533                 :             : {
    1534                 :  1898587424 :   rtx set = NULL;
    1535                 :  1898587424 :   int set_verified = 1;
    1536                 :  1898587424 :   int i;
    1537                 :             : 
    1538                 :  1898587424 :   if (GET_CODE (pat) == PARALLEL)
    1539                 :             :     {
    1540                 :  2170079846 :       for (i = 0; i < XVECLEN (pat, 0); i++)
    1541                 :             :         {
    1542                 :  1477412894 :           rtx sub = XVECEXP (pat, 0, i);
    1543                 :  1477412894 :           switch (GET_CODE (sub))
    1544                 :             :             {
    1545                 :             :             case USE:
    1546                 :             :             case CLOBBER:
    1547                 :             :               break;
    1548                 :             : 
    1549                 :   744493319 :             case SET:
    1550                 :             :               /* We can consider insns having multiple sets, where all
    1551                 :             :                  but one are dead as single set insns.  In common case
    1552                 :             :                  only single set is present in the pattern so we want
    1553                 :             :                  to avoid checking for REG_UNUSED notes unless necessary.
    1554                 :             : 
    1555                 :             :                  When we reach set first time, we just expect this is
    1556                 :             :                  the single set we are looking for and only when more
    1557                 :             :                  sets are found in the insn, we check them.  */
    1558                 :   744493319 :               if (!set_verified)
    1559                 :             :                 {
    1560                 :    32408925 :                   if (find_reg_note (insn, REG_UNUSED, SET_DEST (set))
    1561                 :    32408925 :                       && !side_effects_p (set))
    1562                 :             :                     set = NULL;
    1563                 :             :                   else
    1564                 :             :                     set_verified = 1;
    1565                 :             :                 }
    1566                 :   744493319 :               if (!set)
    1567                 :             :                 set = sub, set_verified = 0;
    1568                 :    23435348 :               else if (!find_reg_note (insn, REG_UNUSED, SET_DEST (sub))
    1569                 :    23435348 :                        || side_effects_p (sub))
    1570                 :    18970895 :                 return NULL_RTX;
    1571                 :             :               break;
    1572                 :             : 
    1573                 :             :             default:
    1574                 :             :               return NULL_RTX;
    1575                 :             :             }
    1576                 :             :         }
    1577                 :             :     }
    1578                 :             :   return set;
    1579                 :             : }
    1580                 :             : 
    1581                 :             : /* Given an INSN, return true if it has more than one SET, else return
    1582                 :             :    false.  */
    1583                 :             : 
    1584                 :             : bool
    1585                 :   282938740 : multiple_sets (const_rtx insn)
    1586                 :             : {
    1587                 :   282938740 :   bool found;
    1588                 :   282938740 :   int i;
    1589                 :             : 
    1590                 :             :   /* INSN must be an insn.  */
    1591                 :   282938740 :   if (! INSN_P (insn))
    1592                 :             :     return false;
    1593                 :             : 
    1594                 :             :   /* Only a PARALLEL can have multiple SETs.  */
    1595                 :   282938740 :   if (GET_CODE (PATTERN (insn)) == PARALLEL)
    1596                 :             :     {
    1597                 :   262311969 :       for (i = 0, found = false; i < XVECLEN (PATTERN (insn), 0); i++)
    1598                 :   176878700 :         if (GET_CODE (XVECEXP (PATTERN (insn), 0, i)) == SET)
    1599                 :             :           {
    1600                 :             :             /* If we have already found a SET, then return now.  */
    1601                 :    89237627 :             if (found)
    1602                 :             :               return true;
    1603                 :             :             else
    1604                 :             :               found = true;
    1605                 :             :           }
    1606                 :             :     }
    1607                 :             : 
    1608                 :             :   /* Either zero or one SET.  */
    1609                 :             :   return false;
    1610                 :             : }
    1611                 :             : 
    1612                 :             : /* Return true if the destination of SET equals the source
    1613                 :             :    and there are no side effects.  */
    1614                 :             : 
    1615                 :             : bool
    1616                 :  1668258361 : set_noop_p (const_rtx set)
    1617                 :             : {
    1618                 :  1668258361 :   rtx src = SET_SRC (set);
    1619                 :  1668258361 :   rtx dst = SET_DEST (set);
    1620                 :             : 
    1621                 :  1668258361 :   if (dst == pc_rtx && src == pc_rtx)
    1622                 :             :     return true;
    1623                 :             : 
    1624                 :  1668250012 :   if (MEM_P (dst) && MEM_P (src))
    1625                 :     8969702 :     return (rtx_equal_p (dst, src)
    1626                 :        4890 :             && !side_effects_p (dst)
    1627                 :     8974455 :             && !side_effects_p (src));
    1628                 :             : 
    1629                 :  1659280310 :   if (GET_CODE (dst) == ZERO_EXTRACT)
    1630                 :      111923 :     return (rtx_equal_p (XEXP (dst, 0), src)
    1631                 :        6171 :             && !BITS_BIG_ENDIAN && XEXP (dst, 2) == const0_rtx
    1632                 :           0 :             && !side_effects_p (src)
    1633                 :      111923 :             && !side_effects_p (XEXP (dst, 0)));
    1634                 :             : 
    1635                 :  1659168387 :   if (GET_CODE (dst) == STRICT_LOW_PART)
    1636                 :      258453 :     dst = XEXP (dst, 0);
    1637                 :             : 
    1638                 :  1659168387 :   if (GET_CODE (src) == SUBREG && GET_CODE (dst) == SUBREG)
    1639                 :             :     {
    1640                 :      847624 :       if (maybe_ne (SUBREG_BYTE (src), SUBREG_BYTE (dst)))
    1641                 :             :         return false;
    1642                 :      800701 :       src = SUBREG_REG (src);
    1643                 :      800701 :       dst = SUBREG_REG (dst);
    1644                 :      800701 :       if (GET_MODE (src) != GET_MODE (dst))
    1645                 :             :         /* It is hard to tell whether subregs refer to the same bits, so act
    1646                 :             :            conservatively and return false.  */
    1647                 :             :         return false;
    1648                 :             :     }
    1649                 :             : 
    1650                 :             :   /* It is a NOOP if destination overlaps with selected src vector
    1651                 :             :      elements.  */
    1652                 :  1659056549 :   if (GET_CODE (src) == VEC_SELECT
    1653                 :     7552869 :       && REG_P (XEXP (src, 0)) && REG_P (dst)
    1654                 :     2564989 :       && HARD_REGISTER_P (XEXP (src, 0))
    1655                 :  1659582075 :       && HARD_REGISTER_P (dst))
    1656                 :             :     {
    1657                 :      525290 :       int i;
    1658                 :      525290 :       rtx par = XEXP (src, 1);
    1659                 :      525290 :       rtx src0 = XEXP (src, 0);
    1660                 :      525290 :       poly_int64 c0;
    1661                 :      525290 :       if (!poly_int_rtx_p (XVECEXP (par, 0, 0), &c0))
    1662                 :             :         return false;
    1663                 :     1050580 :       poly_int64 offset = GET_MODE_UNIT_SIZE (GET_MODE (src0)) * c0;
    1664                 :             : 
    1665                 :      887673 :       for (i = 1; i < XVECLEN (par, 0); i++)
    1666                 :             :         {
    1667                 :      565383 :           poly_int64 c0i;
    1668                 :      565383 :           if (!poly_int_rtx_p (XVECEXP (par, 0, i), &c0i)
    1669                 :      565383 :               || maybe_ne (c0i, c0 + i))
    1670                 :  1667644295 :             return false;
    1671                 :             :         }
    1672                 :      322290 :       return
    1673                 :      322290 :         REG_CAN_CHANGE_MODE_P (REGNO (dst), GET_MODE (src0), GET_MODE (dst))
    1674                 :      322290 :         && validate_subreg (GET_MODE (dst), GET_MODE (src0), src0, offset)
    1675                 :      754879 :         && simplify_subreg_regno (REGNO (src0), GET_MODE (src0),
    1676                 :      124770 :                                   offset, GET_MODE (dst)) == (int) REGNO (dst);
    1677                 :             :     }
    1678                 :             : 
    1679                 :   419011447 :   return (REG_P (src) && REG_P (dst)
    1680                 :  1894449929 :           && REGNO (src) == REGNO (dst));
    1681                 :             : }
    1682                 :             : 
    1683                 :             : /* Return true if an insn consists only of SETs, each of which only sets a
    1684                 :             :    value to itself.  */
    1685                 :             : 
    1686                 :             : bool
    1687                 :  1139113587 : noop_move_p (const rtx_insn *insn)
    1688                 :             : {
    1689                 :  1139113587 :   rtx pat = PATTERN (insn);
    1690                 :             : 
    1691                 :  1139113587 :   if (INSN_CODE (insn) == NOOP_MOVE_INSN_CODE)
    1692                 :             :     return true;
    1693                 :             : 
    1694                 :             :   /* Check the code to be executed for COND_EXEC.  */
    1695                 :  1139106905 :   if (GET_CODE (pat) == COND_EXEC)
    1696                 :           0 :     pat = COND_EXEC_CODE (pat);
    1697                 :             : 
    1698                 :  1139106905 :   if (GET_CODE (pat) == SET && set_noop_p (pat))
    1699                 :             :     return true;
    1700                 :             : 
    1701                 :  1139076078 :   if (GET_CODE (pat) == PARALLEL)
    1702                 :             :     {
    1703                 :             :       int i;
    1704                 :             :       /* If nothing but SETs of registers to themselves,
    1705                 :             :          this insn can also be deleted.  */
    1706                 :   158437138 :       for (i = 0; i < XVECLEN (pat, 0); i++)
    1707                 :             :         {
    1708                 :   158437041 :           rtx tem = XVECEXP (pat, 0, i);
    1709                 :             : 
    1710                 :   158437041 :           if (GET_CODE (tem) == USE || GET_CODE (tem) == CLOBBER)
    1711                 :       21404 :             continue;
    1712                 :             : 
    1713                 :   158415637 :           if (GET_CODE (tem) != SET || ! set_noop_p (tem))
    1714                 :   158415502 :             return false;
    1715                 :             :         }
    1716                 :             : 
    1717                 :             :       return true;
    1718                 :             :     }
    1719                 :             :   return false;
    1720                 :             : }
    1721                 :             : 
    1722                 :             : 
    1723                 :             : /* Return true if register in range [REGNO, ENDREGNO)
    1724                 :             :    appears either explicitly or implicitly in X
    1725                 :             :    other than being stored into.
    1726                 :             : 
    1727                 :             :    References contained within the substructure at LOC do not count.
    1728                 :             :    LOC may be zero, meaning don't ignore anything.  */
    1729                 :             : 
    1730                 :             : bool
    1731                 :  2146563988 : refers_to_regno_p (unsigned int regno, unsigned int endregno, const_rtx x,
    1732                 :             :                    rtx *loc)
    1733                 :             : {
    1734                 :  2849877034 :   int i;
    1735                 :  2849877034 :   unsigned int x_regno;
    1736                 :  2849877034 :   RTX_CODE code;
    1737                 :  2849877034 :   const char *fmt;
    1738                 :             : 
    1739                 :  2849877034 :  repeat:
    1740                 :             :   /* The contents of a REG_NONNEG note is always zero, so we must come here
    1741                 :             :      upon repeat in case the last REG_NOTE is a REG_NONNEG note.  */
    1742                 :  2849877034 :   if (x == 0)
    1743                 :             :     return false;
    1744                 :             : 
    1745                 :  2849877034 :   code = GET_CODE (x);
    1746                 :             : 
    1747                 :  2849877034 :   switch (code)
    1748                 :             :     {
    1749                 :  1569236124 :     case REG:
    1750                 :  1569236124 :       x_regno = REGNO (x);
    1751                 :             : 
    1752                 :             :       /* If we modifying the stack, frame, or argument pointer, it will
    1753                 :             :          clobber a virtual register.  In fact, we could be more precise,
    1754                 :             :          but it isn't worth it.  */
    1755                 :  1569236124 :       if ((x_regno == STACK_POINTER_REGNUM
    1756                 :  1569236124 :            || (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
    1757                 :  1569236124 :                && x_regno == ARG_POINTER_REGNUM)
    1758                 :             :            || x_regno == FRAME_POINTER_REGNUM)
    1759                 :   126387623 :           && VIRTUAL_REGISTER_NUM_P (regno))
    1760                 :             :         return true;
    1761                 :             : 
    1762                 :  1569236122 :       return endregno > x_regno && regno < END_REGNO (x);
    1763                 :             : 
    1764                 :    32795872 :     case SUBREG:
    1765                 :             :       /* If this is a SUBREG of a hard reg, we can see exactly which
    1766                 :             :          registers are being modified.  Otherwise, handle normally.  */
    1767                 :    32795872 :       if (REG_P (SUBREG_REG (x))
    1768                 :    32795872 :           && REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER)
    1769                 :             :         {
    1770                 :        6515 :           unsigned int inner_regno = subreg_regno (x);
    1771                 :        6515 :           unsigned int inner_endregno
    1772                 :             :             = inner_regno + (inner_regno < FIRST_PSEUDO_REGISTER
    1773                 :        6515 :                              ? subreg_nregs (x) : 1);
    1774                 :             : 
    1775                 :        6515 :           return endregno > inner_regno && regno < inner_endregno;
    1776                 :             :         }
    1777                 :             :       break;
    1778                 :             : 
    1779                 :    97108398 :     case CLOBBER:
    1780                 :    97108398 :     case SET:
    1781                 :    97108398 :       if (&SET_DEST (x) != loc
    1782                 :             :           /* Note setting a SUBREG counts as referring to the REG it is in for
    1783                 :             :              a pseudo but not for hard registers since we can
    1784                 :             :              treat each word individually.  */
    1785                 :    97108398 :           && ((GET_CODE (SET_DEST (x)) == SUBREG
    1786                 :      692463 :                && loc != &SUBREG_REG (SET_DEST (x))
    1787                 :      692463 :                && REG_P (SUBREG_REG (SET_DEST (x)))
    1788                 :      692463 :                && REGNO (SUBREG_REG (SET_DEST (x))) >= FIRST_PSEUDO_REGISTER
    1789                 :      692463 :                && refers_to_regno_p (regno, endregno,
    1790                 :             :                                      SUBREG_REG (SET_DEST (x)), loc))
    1791                 :    97087535 :               || (!REG_P (SET_DEST (x))
    1792                 :    10151507 :                   && refers_to_regno_p (regno, endregno, SET_DEST (x), loc))))
    1793                 :      127091 :         return true;
    1794                 :             : 
    1795                 :    96981307 :       if (code == CLOBBER || loc == &SET_SRC (x))
    1796                 :             :         return false;
    1797                 :    80691338 :       x = SET_SRC (x);
    1798                 :    80691338 :       goto repeat;
    1799                 :             : 
    1800                 :             :     default:
    1801                 :             :       break;
    1802                 :             :     }
    1803                 :             : 
    1804                 :             :   /* X does not match, so try its subexpressions.  */
    1805                 :             : 
    1806                 :  1183525997 :   fmt = GET_RTX_FORMAT (code);
    1807                 :  2303997579 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    1808                 :             :     {
    1809                 :  1749939880 :       if (fmt[i] == 'e' && loc != &XEXP (x, i))
    1810                 :             :         {
    1811                 :  1074935959 :           if (i == 0)
    1812                 :             :             {
    1813                 :   622621708 :               x = XEXP (x, 0);
    1814                 :   622621708 :               goto repeat;
    1815                 :             :             }
    1816                 :             :           else
    1817                 :   452314251 :             if (refers_to_regno_p (regno, endregno, XEXP (x, i), loc))
    1818                 :             :               return true;
    1819                 :             :         }
    1820                 :   675003921 :       else if (fmt[i] == 'E')
    1821                 :             :         {
    1822                 :    43300268 :           int j;
    1823                 :   158922758 :           for (j = XVECLEN (x, i) - 1; j >= 0; j--)
    1824                 :   117189382 :             if (loc != &XVECEXP (x, i, j)
    1825                 :   117189382 :                 && refers_to_regno_p (regno, endregno, XVECEXP (x, i, j), loc))
    1826                 :             :               return true;
    1827                 :             :         }
    1828                 :             :     }
    1829                 :             :   return false;
    1830                 :             : }
    1831                 :             : 
    1832                 :             : /* Rreturn true if modifying X will affect IN.  If X is a register or a SUBREG,
    1833                 :             :    we check if any register number in X conflicts with the relevant register
    1834                 :             :    numbers.  If X is a constant, return false.  If X is a MEM, return true iff
    1835                 :             :    IN contains a MEM (we don't bother checking for memory addresses that can't
    1836                 :             :    conflict because we expect this to be a rare case.  */
    1837                 :             : 
    1838                 :             : bool
    1839                 :  1455358180 : reg_overlap_mentioned_p (const_rtx x, const_rtx in)
    1840                 :             : {
    1841                 :  1455358180 :   unsigned int regno, endregno;
    1842                 :             : 
    1843                 :             :   /* If either argument is a constant, then modifying X cannot
    1844                 :             :      affect IN.  Here we look at IN, we can profitably combine
    1845                 :             :      CONSTANT_P (x) with the switch statement below.  */
    1846                 :  1455358180 :   if (CONSTANT_P (in))
    1847                 :             :     return false;
    1848                 :             : 
    1849                 :  1425890148 :  recurse:
    1850                 :  1425893601 :   switch (GET_CODE (x))
    1851                 :             :     {
    1852                 :        3453 :     case CLOBBER:
    1853                 :        3453 :     case STRICT_LOW_PART:
    1854                 :        3453 :     case ZERO_EXTRACT:
    1855                 :        3453 :     case SIGN_EXTRACT:
    1856                 :             :       /* Overly conservative.  */
    1857                 :        3453 :       x = XEXP (x, 0);
    1858                 :        3453 :       goto recurse;
    1859                 :             : 
    1860                 :     1364392 :     case SUBREG:
    1861                 :     1364392 :       regno = REGNO (SUBREG_REG (x));
    1862                 :     1364392 :       if (regno < FIRST_PSEUDO_REGISTER)
    1863                 :           0 :         regno = subreg_regno (x);
    1864                 :     1364392 :       endregno = regno + (regno < FIRST_PSEUDO_REGISTER
    1865                 :           0 :                           ? subreg_nregs (x) : 1);
    1866                 :     1364392 :       goto do_reg;
    1867                 :             : 
    1868                 :  1420849939 :     case REG:
    1869                 :  1420849939 :       regno = REGNO (x);
    1870                 :  1420849939 :       endregno = END_REGNO (x);
    1871                 :  1422214331 :     do_reg:
    1872                 :  1422214331 :       return refers_to_regno_p (regno, endregno, in, (rtx*) 0);
    1873                 :             : 
    1874                 :     1757545 :     case MEM:
    1875                 :     1757545 :       {
    1876                 :     1757545 :         const char *fmt;
    1877                 :     1757545 :         int i;
    1878                 :             : 
    1879                 :     1757545 :         if (MEM_P (in))
    1880                 :             :           return true;
    1881                 :             : 
    1882                 :     1614486 :         fmt = GET_RTX_FORMAT (GET_CODE (in));
    1883                 :     3410598 :         for (i = GET_RTX_LENGTH (GET_CODE (in)) - 1; i >= 0; i--)
    1884                 :     1848900 :           if (fmt[i] == 'e')
    1885                 :             :             {
    1886                 :      447456 :               if (reg_overlap_mentioned_p (x, XEXP (in, i)))
    1887                 :             :                 return true;
    1888                 :             :             }
    1889                 :     1401444 :           else if (fmt[i] == 'E')
    1890                 :             :             {
    1891                 :       13598 :               int j;
    1892                 :       48197 :               for (j = XVECLEN (in, i) - 1; j >= 0; --j)
    1893                 :       40857 :                 if (reg_overlap_mentioned_p (x, XVECEXP (in, i, j)))
    1894                 :             :                   return true;
    1895                 :             :             }
    1896                 :             : 
    1897                 :             :         return false;
    1898                 :             :       }
    1899                 :             : 
    1900                 :     1787638 :     case SCRATCH:
    1901                 :     1787638 :     case PC:
    1902                 :     1787638 :       return reg_mentioned_p (x, in);
    1903                 :             : 
    1904                 :         282 :     case PARALLEL:
    1905                 :         282 :       {
    1906                 :         282 :         int i;
    1907                 :             : 
    1908                 :             :         /* If any register in here refers to it we return true.  */
    1909                 :         560 :         for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
    1910                 :         556 :           if (XEXP (XVECEXP (x, 0, i), 0) != 0
    1911                 :         556 :               && reg_overlap_mentioned_p (XEXP (XVECEXP (x, 0, i), 0), in))
    1912                 :             :             return true;
    1913                 :             :         return false;
    1914                 :             :       }
    1915                 :             : 
    1916                 :      130352 :     default:
    1917                 :      130352 :       gcc_assert (CONSTANT_P (x));
    1918                 :             :       return false;
    1919                 :             :     }
    1920                 :             : }
    1921                 :             : 
    1922                 :             : /* Call FUN on each register or MEM that is stored into or clobbered by X.
    1923                 :             :    (X would be the pattern of an insn).  DATA is an arbitrary pointer,
    1924                 :             :    ignored by note_stores, but passed to FUN.
    1925                 :             : 
    1926                 :             :    FUN receives three arguments:
    1927                 :             :    1. the REG, MEM or PC being stored in or clobbered,
    1928                 :             :    2. the SET or CLOBBER rtx that does the store,
    1929                 :             :    3. the pointer DATA provided to note_stores.
    1930                 :             : 
    1931                 :             :   If the item being stored in or clobbered is a SUBREG of a hard register,
    1932                 :             :   the SUBREG will be passed.  */
    1933                 :             : 
    1934                 :             : void
    1935                 :  7049908090 : note_pattern_stores (const_rtx x,
    1936                 :             :                      void (*fun) (rtx, const_rtx, void *), void *data)
    1937                 :             : {
    1938                 :  7049908090 :   int i;
    1939                 :             : 
    1940                 :  7049908090 :   if (GET_CODE (x) == COND_EXEC)
    1941                 :           0 :     x = COND_EXEC_CODE (x);
    1942                 :             : 
    1943                 :  7049908090 :   if (GET_CODE (x) == SET || GET_CODE (x) == CLOBBER)
    1944                 :             :     {
    1945                 :  5194545247 :       rtx dest = SET_DEST (x);
    1946                 :             : 
    1947                 :  5194545247 :       while ((GET_CODE (dest) == SUBREG
    1948                 :    20346904 :               && (!REG_P (SUBREG_REG (dest))
    1949                 :    20346904 :                   || REGNO (SUBREG_REG (dest)) >= FIRST_PSEUDO_REGISTER))
    1950                 :  5195491258 :              || GET_CODE (dest) == ZERO_EXTRACT
    1951                 : 10411024837 :              || GET_CODE (dest) == STRICT_LOW_PART)
    1952                 :    21265642 :         dest = XEXP (dest, 0);
    1953                 :             : 
    1954                 :             :       /* If we have a PARALLEL, SET_DEST is a list of EXPR_LIST expressions,
    1955                 :             :          each of whose first operand is a register.  */
    1956                 :  5194545247 :       if (GET_CODE (dest) == PARALLEL)
    1957                 :             :         {
    1958                 :     1442282 :           for (i = XVECLEN (dest, 0) - 1; i >= 0; i--)
    1959                 :      917851 :             if (XEXP (XVECEXP (dest, 0, i), 0) != 0)
    1960                 :      917851 :               (*fun) (XEXP (XVECEXP (dest, 0, i), 0), x, data);
    1961                 :             :         }
    1962                 :             :       else
    1963                 :  5194020816 :         (*fun) (dest, x, data);
    1964                 :             :     }
    1965                 :             : 
    1966                 :  1855362843 :   else if (GET_CODE (x) == PARALLEL)
    1967                 :  2157710989 :     for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
    1968                 :  1454992597 :       note_pattern_stores (XVECEXP (x, 0, i), fun, data);
    1969                 :  7049908090 : }
    1970                 :             : 
    1971                 :             : /* Same, but for an instruction.  If the instruction is a call, include
    1972                 :             :    any CLOBBERs in its CALL_INSN_FUNCTION_USAGE.  */
    1973                 :             : 
    1974                 :             : void
    1975                 :  3424933055 : note_stores (const rtx_insn *insn,
    1976                 :             :              void (*fun) (rtx, const_rtx, void *), void *data)
    1977                 :             : {
    1978                 :  3424933055 :   if (CALL_P (insn))
    1979                 :   165185119 :     for (rtx link = CALL_INSN_FUNCTION_USAGE (insn);
    1980                 :   477189721 :          link; link = XEXP (link, 1))
    1981                 :   312004602 :       if (GET_CODE (XEXP (link, 0)) == CLOBBER)
    1982                 :    12045847 :         note_pattern_stores (XEXP (link, 0), fun, data);
    1983                 :  3424933055 :   note_pattern_stores (PATTERN (insn), fun, data);
    1984                 :  3424933055 : }
    1985                 :             : 
    1986                 :             : /* Like notes_stores, but call FUN for each expression that is being
    1987                 :             :    referenced in PBODY, a pointer to the PATTERN of an insn.  We only call
    1988                 :             :    FUN for each expression, not any interior subexpressions.  FUN receives a
    1989                 :             :    pointer to the expression and the DATA passed to this function.
    1990                 :             : 
    1991                 :             :    Note that this is not quite the same test as that done in reg_referenced_p
    1992                 :             :    since that considers something as being referenced if it is being
    1993                 :             :    partially set, while we do not.  */
    1994                 :             : 
    1995                 :             : void
    1996                 :  1105094320 : note_uses (rtx *pbody, void (*fun) (rtx *, void *), void *data)
    1997                 :             : {
    1998                 :  1105094320 :   rtx body = *pbody;
    1999                 :  1105094320 :   int i;
    2000                 :             : 
    2001                 :  1105094320 :   switch (GET_CODE (body))
    2002                 :             :     {
    2003                 :           0 :     case COND_EXEC:
    2004                 :           0 :       (*fun) (&COND_EXEC_TEST (body), data);
    2005                 :           0 :       note_uses (&COND_EXEC_CODE (body), fun, data);
    2006                 :           0 :       return;
    2007                 :             : 
    2008                 :    87489135 :     case PARALLEL:
    2009                 :   271409916 :       for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
    2010                 :   183920781 :         note_uses (&XVECEXP (body, 0, i), fun, data);
    2011                 :             :       return;
    2012                 :             : 
    2013                 :           0 :     case SEQUENCE:
    2014                 :           0 :       for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
    2015                 :           0 :         note_uses (&PATTERN (XVECEXP (body, 0, i)), fun, data);
    2016                 :             :       return;
    2017                 :             : 
    2018                 :     5449690 :     case USE:
    2019                 :     5449690 :       (*fun) (&XEXP (body, 0), data);
    2020                 :     5449690 :       return;
    2021                 :             : 
    2022                 :      253540 :     case ASM_OPERANDS:
    2023                 :      352468 :       for (i = ASM_OPERANDS_INPUT_LENGTH (body) - 1; i >= 0; i--)
    2024                 :       98928 :         (*fun) (&ASM_OPERANDS_INPUT (body, i), data);
    2025                 :             :       return;
    2026                 :             : 
    2027                 :      127486 :     case TRAP_IF:
    2028                 :      127486 :       (*fun) (&TRAP_CONDITION (body), data);
    2029                 :      127486 :       return;
    2030                 :             : 
    2031                 :       10927 :     case PREFETCH:
    2032                 :       10927 :       (*fun) (&XEXP (body, 0), data);
    2033                 :       10927 :       return;
    2034                 :             : 
    2035                 :     3203465 :     case UNSPEC:
    2036                 :     3203465 :     case UNSPEC_VOLATILE:
    2037                 :     6429628 :       for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
    2038                 :     3226163 :         (*fun) (&XVECEXP (body, 0, i), data);
    2039                 :             :       return;
    2040                 :             : 
    2041                 :    84958494 :     case CLOBBER:
    2042                 :    84958494 :       if (MEM_P (XEXP (body, 0)))
    2043                 :     3444966 :         (*fun) (&XEXP (XEXP (body, 0), 0), data);
    2044                 :             :       return;
    2045                 :             : 
    2046                 :   549333881 :     case SET:
    2047                 :   549333881 :       {
    2048                 :   549333881 :         rtx dest = SET_DEST (body);
    2049                 :             : 
    2050                 :             :         /* For sets we replace everything in source plus registers in memory
    2051                 :             :            expression in store and operands of a ZERO_EXTRACT.  */
    2052                 :   549333881 :         (*fun) (&SET_SRC (body), data);
    2053                 :             : 
    2054                 :   549333881 :         if (GET_CODE (dest) == ZERO_EXTRACT)
    2055                 :             :           {
    2056                 :       33985 :             (*fun) (&XEXP (dest, 1), data);
    2057                 :       33985 :             (*fun) (&XEXP (dest, 2), data);
    2058                 :             :           }
    2059                 :             : 
    2060                 :   551601643 :         while (GET_CODE (dest) == SUBREG || GET_CODE (dest) == STRICT_LOW_PART)
    2061                 :     2267762 :           dest = XEXP (dest, 0);
    2062                 :             : 
    2063                 :   549333881 :         if (MEM_P (dest))
    2064                 :    92292226 :           (*fun) (&XEXP (dest, 0), data);
    2065                 :             :       }
    2066                 :             :       return;
    2067                 :             : 
    2068                 :   374267702 :     default:
    2069                 :             :       /* All the other possibilities never store.  */
    2070                 :   374267702 :       (*fun) (pbody, data);
    2071                 :   374267702 :       return;
    2072                 :             :     }
    2073                 :             : }
    2074                 :             : 
    2075                 :             : /* Try to add a description of REG X to this object, stopping once
    2076                 :             :    the REF_END limit has been reached.  FLAGS is a bitmask of
    2077                 :             :    rtx_obj_reference flags that describe the context.  */
    2078                 :             : 
    2079                 :             : void
    2080                 :   572884912 : rtx_properties::try_to_add_reg (const_rtx x, unsigned int flags)
    2081                 :             : {
    2082                 :   572884912 :   if (REG_NREGS (x) != 1)
    2083                 :     2147104 :     flags |= rtx_obj_flags::IS_MULTIREG;
    2084                 :   572884912 :   machine_mode mode = GET_MODE (x);
    2085                 :   572884912 :   unsigned int start_regno = REGNO (x);
    2086                 :   572884912 :   unsigned int end_regno = END_REGNO (x);
    2087                 :  1147916928 :   for (unsigned int regno = start_regno; regno < end_regno; ++regno)
    2088                 :   575032016 :     if (ref_iter != ref_end)
    2089                 :   574959570 :       *ref_iter++ = rtx_obj_reference (regno, flags, mode,
    2090                 :   574959570 :                                        regno - start_regno);
    2091                 :   572884912 : }
    2092                 :             : 
    2093                 :             : /* Add a description of destination X to this object.  FLAGS is a bitmask
    2094                 :             :    of rtx_obj_reference flags that describe the context.
    2095                 :             : 
    2096                 :             :    This routine accepts all rtxes that can legitimately appear in a
    2097                 :             :    SET_DEST.  */
    2098                 :             : 
    2099                 :             : void
    2100                 :   290786086 : rtx_properties::try_to_add_dest (const_rtx x, unsigned int flags)
    2101                 :             : {
    2102                 :             :   /* If we have a PARALLEL, SET_DEST is a list of EXPR_LIST expressions,
    2103                 :             :      each of whose first operand is a register.  */
    2104                 :   290786086 :   if (UNLIKELY (GET_CODE (x) == PARALLEL))
    2105                 :             :     {
    2106                 :       87705 :       for (int i = XVECLEN (x, 0) - 1; i >= 0; --i)
    2107                 :       55520 :         if (rtx dest = XEXP (XVECEXP (x, 0, i), 0))
    2108                 :       55520 :           try_to_add_dest (dest, flags);
    2109                 :             :       return;
    2110                 :             :     }
    2111                 :             : 
    2112                 :   290753901 :   unsigned int base_flags = flags & rtx_obj_flags::STICKY_FLAGS;
    2113                 :   290753901 :   flags |= rtx_obj_flags::IS_WRITE;
    2114                 :   291654959 :   for (;;)
    2115                 :   291654959 :     if (GET_CODE (x) == ZERO_EXTRACT)
    2116                 :             :       {
    2117                 :        6791 :         try_to_add_src (XEXP (x, 1), base_flags);
    2118                 :        6791 :         try_to_add_src (XEXP (x, 2), base_flags);
    2119                 :        6791 :         flags |= rtx_obj_flags::IS_READ;
    2120                 :        6791 :         x = XEXP (x, 0);
    2121                 :             :       }
    2122                 :   291648168 :     else if (GET_CODE (x) == STRICT_LOW_PART)
    2123                 :             :       {
    2124                 :       17380 :         flags |= rtx_obj_flags::IS_READ;
    2125                 :       17380 :         x = XEXP (x, 0);
    2126                 :             :       }
    2127                 :   291630788 :     else if (GET_CODE (x) == SUBREG)
    2128                 :             :       {
    2129                 :      876887 :         flags |= rtx_obj_flags::IN_SUBREG;
    2130                 :      876887 :         if (read_modify_subreg_p (x))
    2131                 :      709304 :           flags |= rtx_obj_flags::IS_READ;
    2132                 :      876887 :         x = SUBREG_REG (x);
    2133                 :             :       }
    2134                 :             :     else
    2135                 :             :       break;
    2136                 :             : 
    2137                 :   290753901 :   if (MEM_P (x))
    2138                 :             :     {
    2139                 :    38211353 :       if (ref_iter != ref_end)
    2140                 :    38210211 :         *ref_iter++ = rtx_obj_reference (MEM_REGNO, flags, GET_MODE (x));
    2141                 :             : 
    2142                 :    38211353 :       unsigned int addr_flags = base_flags | rtx_obj_flags::IN_MEM_STORE;
    2143                 :    38211353 :       if (flags & rtx_obj_flags::IS_READ)
    2144                 :        1720 :         addr_flags |= rtx_obj_flags::IN_MEM_LOAD;
    2145                 :    38211353 :       try_to_add_src (XEXP (x, 0), addr_flags);
    2146                 :    38211353 :       return;
    2147                 :             :     }
    2148                 :             : 
    2149                 :   252542548 :   if (LIKELY (REG_P (x)))
    2150                 :             :     {
    2151                 :   231497448 :       if (REGNO (x) == STACK_POINTER_REGNUM)
    2152                 :             :         {
    2153                 :             :           /* Stack accesses are dependent on previous allocations and
    2154                 :             :              anti-dependent on later deallocations, so both types of
    2155                 :             :              stack operation are akin to a memory write.  */
    2156                 :    13848948 :           if (ref_iter != ref_end)
    2157                 :    13848948 :             *ref_iter++ = rtx_obj_reference (MEM_REGNO, flags, BLKmode);
    2158                 :             : 
    2159                 :             :           /* We want to keep sp alive everywhere - by making all
    2160                 :             :              writes to sp also use sp.  */
    2161                 :    13848948 :           flags |= rtx_obj_flags::IS_READ;
    2162                 :             :         }
    2163                 :   231497448 :       try_to_add_reg (x, flags);
    2164                 :   231497448 :       return;
    2165                 :             :     }
    2166                 :             : }
    2167                 :             : 
    2168                 :             : /* Try to add a description of source X to this object, stopping once
    2169                 :             :    the REF_END limit has been reached.  FLAGS is a bitmask of
    2170                 :             :    rtx_obj_reference flags that describe the context.
    2171                 :             : 
    2172                 :             :    This routine accepts all rtxes that can legitimately appear in a SET_SRC.  */
    2173                 :             : 
    2174                 :             : void
    2175                 :   613621726 : rtx_properties::try_to_add_src (const_rtx x, unsigned int flags)
    2176                 :             : {
    2177                 :   613621726 :   unsigned int base_flags = flags & rtx_obj_flags::STICKY_FLAGS;
    2178                 :   613621726 :   subrtx_iterator::array_type array;
    2179                 :  1923914186 :   FOR_EACH_SUBRTX (iter, array, x, NONCONST)
    2180                 :             :     {
    2181                 :  1310292460 :       const_rtx x = *iter;
    2182                 :  1310292460 :       rtx_code code = GET_CODE (x);
    2183                 :  1310292460 :       if (code == REG)
    2184                 :   341387464 :         try_to_add_reg (x, flags | rtx_obj_flags::IS_READ);
    2185                 :             :       else if (code == MEM)
    2186                 :             :         {
    2187                 :    68478907 :           if (MEM_VOLATILE_P (x))
    2188                 :     2095193 :             has_volatile_refs = true;
    2189                 :             : 
    2190                 :    68478907 :           if (!MEM_READONLY_P (x) && ref_iter != ref_end)
    2191                 :             :             {
    2192                 :    65210470 :               auto mem_flags = flags | rtx_obj_flags::IS_READ;
    2193                 :    65210470 :               *ref_iter++ = rtx_obj_reference (MEM_REGNO, mem_flags,
    2194                 :    65210470 :                                                GET_MODE (x));
    2195                 :             :             }
    2196                 :             : 
    2197                 :    68478907 :           try_to_add_src (XEXP (x, 0),
    2198                 :             :                           base_flags | rtx_obj_flags::IN_MEM_LOAD);
    2199                 :    68478907 :           iter.skip_subrtxes ();
    2200                 :             :         }
    2201                 :             :       else if (code == SUBREG)
    2202                 :             :         {
    2203                 :     6326400 :           try_to_add_src (SUBREG_REG (x), flags | rtx_obj_flags::IN_SUBREG);
    2204                 :     6326400 :           iter.skip_subrtxes ();
    2205                 :             :         }
    2206                 :             :       else if (code == UNSPEC_VOLATILE)
    2207                 :     1579826 :         has_volatile_refs = true;
    2208                 :             :       else if (code == ASM_INPUT || code == ASM_OPERANDS)
    2209                 :             :         {
    2210                 :      694941 :           has_asm = true;
    2211                 :      694941 :           if (MEM_VOLATILE_P (x))
    2212                 :      214357 :             has_volatile_refs = true;
    2213                 :             :         }
    2214                 :             :       else if (code == PRE_INC
    2215                 :             :                || code == PRE_DEC
    2216                 :             :                || code == POST_INC
    2217                 :             :                || code == POST_DEC
    2218                 :             :                || code == PRE_MODIFY
    2219                 :             :                || code == POST_MODIFY)
    2220                 :             :         {
    2221                 :     6749125 :           has_pre_post_modify = true;
    2222                 :             : 
    2223                 :     6749125 :           unsigned int addr_flags = (flags
    2224                 :             :                                      | rtx_obj_flags::IS_PRE_POST_MODIFY
    2225                 :             :                                      | rtx_obj_flags::IS_READ);
    2226                 :     6749125 :           try_to_add_dest (XEXP (x, 0), addr_flags);
    2227                 :     6749125 :           if (code == PRE_MODIFY || code == POST_MODIFY)
    2228                 :      240952 :             iter.substitute (XEXP (XEXP (x, 1), 1));
    2229                 :             :           else
    2230                 :     6508173 :             iter.skip_subrtxes ();
    2231                 :             :         }
    2232                 :             :       else if (code == CALL)
    2233                 :    18072089 :         has_call = true;
    2234                 :             :     }
    2235                 :   613621726 : }
    2236                 :             : 
    2237                 :             : /* Try to add a description of instruction pattern PAT to this object,
    2238                 :             :    stopping once the REF_END limit has been reached.  */
    2239                 :             : 
    2240                 :             : void
    2241                 :   489130190 : rtx_properties::try_to_add_pattern (const_rtx pat)
    2242                 :             : {
    2243                 :   527224313 :   switch (GET_CODE (pat))
    2244                 :             :     {
    2245                 :           0 :     case COND_EXEC:
    2246                 :           0 :       try_to_add_src (COND_EXEC_TEST (pat));
    2247                 :           0 :       try_to_add_pattern (COND_EXEC_CODE (pat));
    2248                 :           0 :       break;
    2249                 :             : 
    2250                 :    38094123 :     case PARALLEL:
    2251                 :    38094123 :       {
    2252                 :    38094123 :         int last = XVECLEN (pat, 0) - 1;
    2253                 :    78275966 :         for (int i = 0; i < last; ++i)
    2254                 :    40181843 :           try_to_add_pattern (XVECEXP (pat, 0, i));
    2255                 :    38094123 :         try_to_add_pattern (XVECEXP (pat, 0, last));
    2256                 :    38094123 :         break;
    2257                 :             :       }
    2258                 :             : 
    2259                 :      167560 :     case ASM_OPERANDS:
    2260                 :      212573 :       for (int i = 0, len = ASM_OPERANDS_INPUT_LENGTH (pat); i < len; ++i)
    2261                 :       45013 :         try_to_add_src (ASM_OPERANDS_INPUT (pat, i));
    2262                 :             :       break;
    2263                 :             : 
    2264                 :    37673562 :     case CLOBBER:
    2265                 :    37673562 :       try_to_add_dest (XEXP (pat, 0), rtx_obj_flags::IS_CLOBBER);
    2266                 :    37673562 :       break;
    2267                 :             : 
    2268                 :   244478123 :     case SET:
    2269                 :   244478123 :       try_to_add_dest (SET_DEST (pat));
    2270                 :   244478123 :       try_to_add_src (SET_SRC (pat));
    2271                 :   244478123 :       break;
    2272                 :             : 
    2273                 :   206810945 :     default:
    2274                 :             :       /* All the other possibilities never store and can use a normal
    2275                 :             :          rtx walk.  This includes:
    2276                 :             : 
    2277                 :             :          - USE
    2278                 :             :          - TRAP_IF
    2279                 :             :          - PREFETCH
    2280                 :             :          - UNSPEC
    2281                 :             :          - UNSPEC_VOLATILE.  */
    2282                 :   206810945 :       try_to_add_src (pat);
    2283                 :   206810945 :       break;
    2284                 :             :     }
    2285                 :   489130190 : }
    2286                 :             : 
    2287                 :             : /* Try to add a description of INSN to this object, stopping once
    2288                 :             :    the REF_END limit has been reached.  INCLUDE_NOTES is true if the
    2289                 :             :    description should include REG_EQUAL and REG_EQUIV notes; all such
    2290                 :             :    references will then be marked with rtx_obj_flags::IN_NOTE.
    2291                 :             : 
    2292                 :             :    For calls, this description includes all accesses in
    2293                 :             :    CALL_INSN_FUNCTION_USAGE.  It also include all implicit accesses
    2294                 :             :    to global registers by the target function.  However, it does not
    2295                 :             :    include clobbers performed by the target function; callers that want
    2296                 :             :    this information should instead use the function_abi interface.  */
    2297                 :             : 
    2298                 :             : void
    2299                 :   432107328 : rtx_properties::try_to_add_insn (const rtx_insn *insn, bool include_notes)
    2300                 :             : {
    2301                 :   432107328 :   if (CALL_P (insn))
    2302                 :             :     {
    2303                 :             :       /* Non-const functions can read from global registers.  Impure
    2304                 :             :          functions can also set them.
    2305                 :             : 
    2306                 :             :          Adding the global registers first removes a situation in which
    2307                 :             :          a fixed-form clobber of register R could come before a real set
    2308                 :             :          of register R.  */
    2309                 :    18054463 :       if (!hard_reg_set_empty_p (global_reg_set)
    2310                 :    18054463 :           && !RTL_CONST_CALL_P (insn))
    2311                 :             :         {
    2312                 :         356 :           unsigned int flags = rtx_obj_flags::IS_READ;
    2313                 :         356 :           if (!RTL_PURE_CALL_P (insn))
    2314                 :         324 :             flags |= rtx_obj_flags::IS_WRITE;
    2315                 :       33108 :           for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; ++regno)
    2316                 :             :             /* As a special case, the stack pointer is invariant across calls
    2317                 :             :                even if it has been marked global; see the corresponding
    2318                 :             :                handling in df_get_call_refs.  */
    2319                 :       32752 :             if (regno != STACK_POINTER_REGNUM
    2320                 :       32396 :                 && global_regs[regno]
    2321                 :         296 :                 && ref_iter != ref_end)
    2322                 :         296 :               *ref_iter++ = rtx_obj_reference (regno, flags,
    2323                 :         296 :                                                reg_raw_mode[regno], 0);
    2324                 :             :         }
    2325                 :             :       /* Untyped calls implicitly set all function value registers.
    2326                 :             :          Again, we add them first in case the main pattern contains
    2327                 :             :          a fixed-form clobber.  */
    2328                 :    18054463 :       if (find_reg_note (insn, REG_UNTYPED_CALL, NULL_RTX))
    2329                 :      143592 :         for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; ++regno)
    2330                 :      142048 :           if (targetm.calls.function_value_regno_p (regno)
    2331                 :      142048 :               && ref_iter != ref_end)
    2332                 :       12352 :             *ref_iter++ = rtx_obj_reference (regno, rtx_obj_flags::IS_WRITE,
    2333                 :       12352 :                                              reg_raw_mode[regno], 0);
    2334                 :    18054463 :       if (ref_iter != ref_end && !RTL_CONST_CALL_P (insn))
    2335                 :             :         {
    2336                 :    17437049 :           auto mem_flags = rtx_obj_flags::IS_READ;
    2337                 :    17437049 :           if (!RTL_PURE_CALL_P (insn))
    2338                 :    16247834 :             mem_flags |= rtx_obj_flags::IS_WRITE;
    2339                 :    17437049 :           *ref_iter++ = rtx_obj_reference (MEM_REGNO, mem_flags, BLKmode);
    2340                 :             :         }
    2341                 :    18054463 :       try_to_add_pattern (PATTERN (insn));
    2342                 :    53209219 :       for (rtx link = CALL_INSN_FUNCTION_USAGE (insn); link;
    2343                 :    35154756 :            link = XEXP (link, 1))
    2344                 :             :         {
    2345                 :    35154756 :           rtx x = XEXP (link, 0);
    2346                 :    35154756 :           if (GET_CODE (x) == CLOBBER)
    2347                 :     1829756 :             try_to_add_dest (XEXP (x, 0), rtx_obj_flags::IS_CLOBBER);
    2348                 :    33325000 :           else if (GET_CODE (x) == USE)
    2349                 :    33114408 :             try_to_add_src (XEXP (x, 0));
    2350                 :             :         }
    2351                 :             :     }
    2352                 :             :   else
    2353                 :   414052865 :     try_to_add_pattern (PATTERN (insn));
    2354                 :             : 
    2355                 :   432107328 :   if (include_notes)
    2356                 :   653603292 :     for (rtx note = REG_NOTES (insn); note; note = XEXP (note, 1))
    2357                 :   221496847 :       if (REG_NOTE_KIND (note) == REG_EQUAL
    2358                 :   221496847 :           || REG_NOTE_KIND (note) == REG_EQUIV)
    2359                 :    16142995 :         try_to_add_note (XEXP (note, 0));
    2360                 :   432107328 : }
    2361                 :             : 
    2362                 :             : /* Grow the storage by a bit while keeping the contents of the first
    2363                 :             :    START elements.  */
    2364                 :             : 
    2365                 :             : void
    2366                 :       12730 : vec_rtx_properties_base::grow (ptrdiff_t start)
    2367                 :             : {
    2368                 :             :   /* The same heuristic that vec uses.  */
    2369                 :       12730 :   ptrdiff_t new_elems = (ref_end - ref_begin) * 3 / 2;
    2370                 :       12730 :   if (ref_begin == m_storage)
    2371                 :             :     {
    2372                 :       10422 :       ref_begin = XNEWVEC (rtx_obj_reference, new_elems);
    2373                 :       10422 :       if (start)
    2374                 :           0 :         memcpy (ref_begin, m_storage, start * sizeof (rtx_obj_reference));
    2375                 :             :     }
    2376                 :             :   else
    2377                 :        2308 :     ref_begin = reinterpret_cast<rtx_obj_reference *>
    2378                 :        2308 :       (xrealloc (ref_begin, new_elems * sizeof (rtx_obj_reference)));
    2379                 :       12730 :   ref_iter = ref_begin + start;
    2380                 :       12730 :   ref_end = ref_begin + new_elems;
    2381                 :       12730 : }
    2382                 :             : 
    2383                 :             : /* Return true if X's old contents don't survive after INSN.
    2384                 :             :    This will be true if X is a register and X dies in INSN or because
    2385                 :             :    INSN entirely sets X.
    2386                 :             : 
    2387                 :             :    "Entirely set" means set directly and not through a SUBREG, or
    2388                 :             :    ZERO_EXTRACT, so no trace of the old contents remains.
    2389                 :             :    Likewise, REG_INC does not count.
    2390                 :             : 
    2391                 :             :    REG may be a hard or pseudo reg.  Renumbering is not taken into account,
    2392                 :             :    but for this use that makes no difference, since regs don't overlap
    2393                 :             :    during their lifetimes.  Therefore, this function may be used
    2394                 :             :    at any time after deaths have been computed.
    2395                 :             : 
    2396                 :             :    If REG is a hard reg that occupies multiple machine registers, this
    2397                 :             :    function will only return true if each of those registers will be replaced
    2398                 :             :    by INSN.  */
    2399                 :             : 
    2400                 :             : bool
    2401                 :   113659553 : dead_or_set_p (const rtx_insn *insn, const_rtx x)
    2402                 :             : {
    2403                 :   113659553 :   unsigned int regno, end_regno;
    2404                 :   113659553 :   unsigned int i;
    2405                 :             : 
    2406                 :   113659553 :   gcc_assert (REG_P (x));
    2407                 :             : 
    2408                 :   113659553 :   regno = REGNO (x);
    2409                 :   113659553 :   end_regno = END_REGNO (x);
    2410                 :   201918807 :   for (i = regno; i < end_regno; i++)
    2411                 :   113660595 :     if (! dead_or_set_regno_p (insn, i))
    2412                 :             :       return false;
    2413                 :             : 
    2414                 :             :   return true;
    2415                 :             : }
    2416                 :             : 
    2417                 :             : /* Return TRUE iff DEST is a register or subreg of a register, is a
    2418                 :             :    complete rather than read-modify-write destination, and contains
    2419                 :             :    register TEST_REGNO.  */
    2420                 :             : 
    2421                 :             : static bool
    2422                 :   202615050 : covers_regno_no_parallel_p (const_rtx dest, unsigned int test_regno)
    2423                 :             : {
    2424                 :   202615050 :   unsigned int regno, endregno;
    2425                 :             : 
    2426                 :   202615050 :   if (GET_CODE (dest) == SUBREG && !read_modify_subreg_p (dest))
    2427                 :      522201 :     dest = SUBREG_REG (dest);
    2428                 :             : 
    2429                 :   202615050 :   if (!REG_P (dest))
    2430                 :             :     return false;
    2431                 :             : 
    2432                 :   195517212 :   regno = REGNO (dest);
    2433                 :   195517212 :   endregno = END_REGNO (dest);
    2434                 :   195517212 :   return (test_regno >= regno && test_regno < endregno);
    2435                 :             : }
    2436                 :             : 
    2437                 :             : /* Like covers_regno_no_parallel_p, but also handles PARALLELs where
    2438                 :             :    any member matches the covers_regno_no_parallel_p criteria.  */
    2439                 :             : 
    2440                 :             : static bool
    2441                 :    95556638 : covers_regno_p (const_rtx dest, unsigned int test_regno)
    2442                 :             : {
    2443                 :    95556638 :   if (GET_CODE (dest) == PARALLEL)
    2444                 :             :     {
    2445                 :             :       /* Some targets place small structures in registers for return
    2446                 :             :          values of functions, and those registers are wrapped in
    2447                 :             :          PARALLELs that we may see as the destination of a SET.  */
    2448                 :         311 :       int i;
    2449                 :             : 
    2450                 :         840 :       for (i = XVECLEN (dest, 0) - 1; i >= 0; i--)
    2451                 :             :         {
    2452                 :         529 :           rtx inner = XEXP (XVECEXP (dest, 0, i), 0);
    2453                 :         529 :           if (inner != NULL_RTX
    2454                 :         529 :               && covers_regno_no_parallel_p (inner, test_regno))
    2455                 :             :             return true;
    2456                 :             :         }
    2457                 :             : 
    2458                 :             :       return false;
    2459                 :             :     }
    2460                 :             :   else
    2461                 :    95556327 :     return covers_regno_no_parallel_p (dest, test_regno);
    2462                 :             : }
    2463                 :             : 
    2464                 :             : /* Utility function for dead_or_set_p to check an individual register. */
    2465                 :             : 
    2466                 :             : bool
    2467                 :   115796112 : dead_or_set_regno_p (const rtx_insn *insn, unsigned int test_regno)
    2468                 :             : {
    2469                 :   115796112 :   const_rtx pattern;
    2470                 :             : 
    2471                 :             :   /* See if there is a death note for something that includes TEST_REGNO.  */
    2472                 :   115796112 :   if (find_regno_note (insn, REG_DEAD, test_regno))
    2473                 :             :     return true;
    2474                 :             : 
    2475                 :    74485098 :   if (CALL_P (insn)
    2476                 :    74485098 :       && find_regno_fusage (insn, CLOBBER, test_regno))
    2477                 :             :     return true;
    2478                 :             : 
    2479                 :    74485098 :   pattern = PATTERN (insn);
    2480                 :             : 
    2481                 :             :   /* If a COND_EXEC is not executed, the value survives.  */
    2482                 :    74485098 :   if (GET_CODE (pattern) == COND_EXEC)
    2483                 :             :     return false;
    2484                 :             : 
    2485                 :    74485098 :   if (GET_CODE (pattern) == SET || GET_CODE (pattern) == CLOBBER)
    2486                 :    53175103 :     return covers_regno_p (SET_DEST (pattern), test_regno);
    2487                 :    21309995 :   else if (GET_CODE (pattern) == PARALLEL)
    2488                 :             :     {
    2489                 :    21080550 :       int i;
    2490                 :             : 
    2491                 :    49242106 :       for (i = XVECLEN (pattern, 0) - 1; i >= 0; i--)
    2492                 :             :         {
    2493                 :    42697373 :           rtx body = XVECEXP (pattern, 0, i);
    2494                 :             : 
    2495                 :    42697373 :           if (GET_CODE (body) == COND_EXEC)
    2496                 :           0 :             body = COND_EXEC_CODE (body);
    2497                 :             : 
    2498                 :    21440518 :           if ((GET_CODE (body) == SET || GET_CODE (body) == CLOBBER)
    2499                 :    63822053 :               && covers_regno_p (SET_DEST (body), test_regno))
    2500                 :             :             return true;
    2501                 :             :         }
    2502                 :             :     }
    2503                 :             : 
    2504                 :             :   return false;
    2505                 :             : }
    2506                 :             : 
    2507                 :             : /* Return the reg-note of kind KIND in insn INSN, if there is one.
    2508                 :             :    If DATUM is nonzero, look for one whose datum is DATUM.  */
    2509                 :             : 
    2510                 :             : rtx
    2511                 :  8088900822 : find_reg_note (const_rtx insn, enum reg_note kind, const_rtx datum)
    2512                 :             : {
    2513                 :  8088900822 :   rtx link;
    2514                 :             : 
    2515                 :  8088900822 :   gcc_checking_assert (insn);
    2516                 :             : 
    2517                 :             :   /* Ignore anything that is not an INSN, JUMP_INSN or CALL_INSN.  */
    2518                 :  8088900822 :   if (! INSN_P (insn))
    2519                 :             :     return 0;
    2520                 :  7974284054 :   if (datum == 0)
    2521                 :             :     {
    2522                 : 15908167824 :       for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    2523                 :  9509279155 :         if (REG_NOTE_KIND (link) == kind)
    2524                 :             :           return link;
    2525                 :             :       return 0;
    2526                 :             :     }
    2527                 :             : 
    2528                 :   736315688 :   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    2529                 :   425139128 :     if (REG_NOTE_KIND (link) == kind && datum == XEXP (link, 0))
    2530                 :             :       return link;
    2531                 :             :   return 0;
    2532                 :             : }
    2533                 :             : 
    2534                 :             : /* Return the reg-note of kind KIND in insn INSN which applies to register
    2535                 :             :    number REGNO, if any.  Return 0 if there is no such reg-note.  Note that
    2536                 :             :    the REGNO of this NOTE need not be REGNO if REGNO is a hard register;
    2537                 :             :    it might be the case that the note overlaps REGNO.  */
    2538                 :             : 
    2539                 :             : rtx
    2540                 :   405877818 : find_regno_note (const_rtx insn, enum reg_note kind, unsigned int regno)
    2541                 :             : {
    2542                 :   405877818 :   rtx link;
    2543                 :             : 
    2544                 :             :   /* Ignore anything that is not an INSN, JUMP_INSN or CALL_INSN.  */
    2545                 :   405877818 :   if (! INSN_P (insn))
    2546                 :             :     return 0;
    2547                 :             : 
    2548                 :   608235211 :   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    2549                 :   377483452 :     if (REG_NOTE_KIND (link) == kind
    2550                 :             :         /* Verify that it is a register, so that scratch and MEM won't cause a
    2551                 :             :            problem here.  */
    2552                 :   253949984 :         && REG_P (XEXP (link, 0))
    2553                 :   253949984 :         && REGNO (XEXP (link, 0)) <= regno
    2554                 :   582377177 :         && END_REGNO (XEXP (link, 0)) > regno)
    2555                 :             :       return link;
    2556                 :             :   return 0;
    2557                 :             : }
    2558                 :             : 
    2559                 :             : /* Return a REG_EQUIV or REG_EQUAL note if insn has only a single set and
    2560                 :             :    has such a note.  */
    2561                 :             : 
    2562                 :             : rtx
    2563                 :  1746707328 : find_reg_equal_equiv_note (const_rtx insn)
    2564                 :             : {
    2565                 :  1746707328 :   rtx link;
    2566                 :             : 
    2567                 :  1746707328 :   if (!INSN_P (insn))
    2568                 :             :     return 0;
    2569                 :             : 
    2570                 :  3029656045 :   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    2571                 :  1381582623 :     if (REG_NOTE_KIND (link) == REG_EQUAL
    2572                 :  1381582623 :         || REG_NOTE_KIND (link) == REG_EQUIV)
    2573                 :             :       {
    2574                 :             :         /* FIXME: We should never have REG_EQUAL/REG_EQUIV notes on
    2575                 :             :            insns that have multiple sets.  Checking single_set to
    2576                 :             :            make sure of this is not the proper check, as explained
    2577                 :             :            in the comment in set_unique_reg_note.
    2578                 :             : 
    2579                 :             :            This should be changed into an assert.  */
    2580                 :    92332015 :         if (GET_CODE (PATTERN (insn)) == PARALLEL && multiple_sets (insn))
    2581                 :             :           return 0;
    2582                 :    92332015 :         return link;
    2583                 :             :       }
    2584                 :             :   return NULL;
    2585                 :             : }
    2586                 :             : 
    2587                 :             : /* Check whether INSN is a single_set whose source is known to be
    2588                 :             :    equivalent to a constant.  Return that constant if so, otherwise
    2589                 :             :    return null.  */
    2590                 :             : 
    2591                 :             : rtx
    2592                 :     2291439 : find_constant_src (const rtx_insn *insn)
    2593                 :             : {
    2594                 :     2291439 :   rtx note, set, x;
    2595                 :             : 
    2596                 :     2291439 :   set = single_set (insn);
    2597                 :     2291439 :   if (set)
    2598                 :             :     {
    2599                 :     2291439 :       x = avoid_constant_pool_reference (SET_SRC (set));
    2600                 :     2291439 :       if (CONSTANT_P (x))
    2601                 :             :         return x;
    2602                 :             :     }
    2603                 :             : 
    2604                 :     1593390 :   note = find_reg_equal_equiv_note (insn);
    2605                 :     1593390 :   if (note && CONSTANT_P (XEXP (note, 0)))
    2606                 :         621 :     return XEXP (note, 0);
    2607                 :             : 
    2608                 :             :   return NULL_RTX;
    2609                 :             : }
    2610                 :             : 
    2611                 :             : /* Return true if DATUM, or any overlap of DATUM, of kind CODE is found
    2612                 :             :    in the CALL_INSN_FUNCTION_USAGE information of INSN.  */
    2613                 :             : 
    2614                 :             : bool
    2615                 :    88885587 : find_reg_fusage (const_rtx insn, enum rtx_code code, const_rtx datum)
    2616                 :             : {
    2617                 :             :   /* If it's not a CALL_INSN, it can't possibly have a
    2618                 :             :      CALL_INSN_FUNCTION_USAGE field, so don't bother checking.  */
    2619                 :    88885587 :   if (!CALL_P (insn))
    2620                 :             :     return false;
    2621                 :             : 
    2622                 :    88885587 :   gcc_assert (datum);
    2623                 :             : 
    2624                 :    88885587 :   if (!REG_P (datum))
    2625                 :             :     {
    2626                 :       32643 :       rtx link;
    2627                 :             : 
    2628                 :       32643 :       for (link = CALL_INSN_FUNCTION_USAGE (insn);
    2629                 :       46156 :            link;
    2630                 :       13513 :            link = XEXP (link, 1))
    2631                 :       13513 :         if (GET_CODE (XEXP (link, 0)) == code
    2632                 :       13513 :             && rtx_equal_p (datum, XEXP (XEXP (link, 0), 0)))
    2633                 :             :           return true;
    2634                 :             :     }
    2635                 :             :   else
    2636                 :             :     {
    2637                 :    88852944 :       unsigned int regno = REGNO (datum);
    2638                 :             : 
    2639                 :             :       /* CALL_INSN_FUNCTION_USAGE information cannot contain references
    2640                 :             :          to pseudo registers, so don't bother checking.  */
    2641                 :             : 
    2642                 :    88852944 :       if (regno < FIRST_PSEUDO_REGISTER)
    2643                 :             :         {
    2644                 :    81921262 :           unsigned int end_regno = END_REGNO (datum);
    2645                 :    81921262 :           unsigned int i;
    2646                 :             : 
    2647                 :   143220929 :           for (i = regno; i < end_regno; i++)
    2648                 :    81921262 :             if (find_regno_fusage (insn, code, i))
    2649                 :             :               return true;
    2650                 :             :         }
    2651                 :             :     }
    2652                 :             : 
    2653                 :             :   return false;
    2654                 :             : }
    2655                 :             : 
    2656                 :             : /* Return true if REGNO, or any overlap of REGNO, of kind CODE is found
    2657                 :             :    in the CALL_INSN_FUNCTION_USAGE information of INSN.  */
    2658                 :             : 
    2659                 :             : bool
    2660                 :    82156808 : find_regno_fusage (const_rtx insn, enum rtx_code code, unsigned int regno)
    2661                 :             : {
    2662                 :    82156808 :   rtx link;
    2663                 :             : 
    2664                 :             :   /* CALL_INSN_FUNCTION_USAGE information cannot contain references
    2665                 :             :      to pseudo registers, so don't bother checking.  */
    2666                 :             : 
    2667                 :    82156808 :   if (regno >= FIRST_PSEUDO_REGISTER
    2668                 :    82086742 :       || !CALL_P (insn) )
    2669                 :             :     return false;
    2670                 :             : 
    2671                 :   231829834 :   for (link = CALL_INSN_FUNCTION_USAGE (insn); link; link = XEXP (link, 1))
    2672                 :             :     {
    2673                 :   170366237 :       rtx op, reg;
    2674                 :             : 
    2675                 :   170366237 :       if (GET_CODE (op = XEXP (link, 0)) == code
    2676                 :    52720850 :           && REG_P (reg = XEXP (op, 0))
    2677                 :    52718316 :           && REGNO (reg) <= regno
    2678                 :   205579359 :           && END_REGNO (reg) > regno)
    2679                 :             :         return true;
    2680                 :             :     }
    2681                 :             : 
    2682                 :             :   return false;
    2683                 :             : }
    2684                 :             : 
    2685                 :             : 
    2686                 :             : /* Return true if KIND is an integer REG_NOTE.  */
    2687                 :             : 
    2688                 :             : static bool
    2689                 :           0 : int_reg_note_p (enum reg_note kind)
    2690                 :             : {
    2691                 :           0 :   return kind == REG_BR_PROB;
    2692                 :             : }
    2693                 :             : 
    2694                 :             : /* Allocate a register note with kind KIND and datum DATUM.  LIST is
    2695                 :             :    stored as the pointer to the next register note.  */
    2696                 :             : 
    2697                 :             : rtx
    2698                 :   758665720 : alloc_reg_note (enum reg_note kind, rtx datum, rtx list)
    2699                 :             : {
    2700                 :   758665720 :   rtx note;
    2701                 :             : 
    2702                 :   758665720 :   gcc_checking_assert (!int_reg_note_p (kind));
    2703                 :   758665720 :   switch (kind)
    2704                 :             :     {
    2705                 :       31737 :     case REG_LABEL_TARGET:
    2706                 :       31737 :     case REG_LABEL_OPERAND:
    2707                 :       31737 :     case REG_TM:
    2708                 :             :       /* These types of register notes use an INSN_LIST rather than an
    2709                 :             :          EXPR_LIST, so that copying is done right and dumps look
    2710                 :             :          better.  */
    2711                 :       31737 :       note = alloc_INSN_LIST (datum, list);
    2712                 :       31737 :       PUT_REG_NOTE_KIND (note, kind);
    2713                 :       31737 :       break;
    2714                 :             : 
    2715                 :   758633983 :     default:
    2716                 :   758633983 :       note = alloc_EXPR_LIST (kind, datum, list);
    2717                 :   758633983 :       break;
    2718                 :             :     }
    2719                 :             : 
    2720                 :   758665720 :   return note;
    2721                 :             : }
    2722                 :             : 
    2723                 :             : /* Add register note with kind KIND and datum DATUM to INSN.  */
    2724                 :             : 
    2725                 :             : void
    2726                 :   751769974 : add_reg_note (rtx insn, enum reg_note kind, rtx datum)
    2727                 :             : {
    2728                 :   751769974 :   REG_NOTES (insn) = alloc_reg_note (kind, datum, REG_NOTES (insn));
    2729                 :   751769974 : }
    2730                 :             : 
    2731                 :             : /* Add an integer register note with kind KIND and datum DATUM to INSN.  */
    2732                 :             : 
    2733                 :             : void
    2734                 :     5154412 : add_int_reg_note (rtx_insn *insn, enum reg_note kind, int datum)
    2735                 :             : {
    2736                 :     5154412 :   gcc_checking_assert (int_reg_note_p (kind));
    2737                 :     5154412 :   REG_NOTES (insn) = gen_rtx_INT_LIST ((machine_mode) kind,
    2738                 :             :                                        datum, REG_NOTES (insn));
    2739                 :     5154412 : }
    2740                 :             : 
    2741                 :             : /* Add a REG_ARGS_SIZE note to INSN with value VALUE.  */
    2742                 :             : 
    2743                 :             : void
    2744                 :     5441454 : add_args_size_note (rtx_insn *insn, poly_int64 value)
    2745                 :             : {
    2746                 :     5441454 :   gcc_checking_assert (!find_reg_note (insn, REG_ARGS_SIZE, NULL_RTX));
    2747                 :     5441454 :   add_reg_note (insn, REG_ARGS_SIZE, gen_int_mode (value, Pmode));
    2748                 :     5441454 : }
    2749                 :             : 
    2750                 :             : /* Add a register note like NOTE to INSN.  */
    2751                 :             : 
    2752                 :             : void
    2753                 :           0 : add_shallow_copy_of_reg_note (rtx_insn *insn, rtx note)
    2754                 :             : {
    2755                 :           0 :   if (GET_CODE (note) == INT_LIST)
    2756                 :           0 :     add_int_reg_note (insn, REG_NOTE_KIND (note), XINT (note, 0));
    2757                 :             :   else
    2758                 :           0 :     add_reg_note (insn, REG_NOTE_KIND (note), XEXP (note, 0));
    2759                 :           0 : }
    2760                 :             : 
    2761                 :             : /* Duplicate NOTE and return the copy.  */
    2762                 :             : rtx
    2763                 :     2265293 : duplicate_reg_note (rtx note)
    2764                 :             : {
    2765                 :     2265293 :   reg_note kind = REG_NOTE_KIND (note);
    2766                 :             : 
    2767                 :     2265293 :   if (GET_CODE (note) == INT_LIST)
    2768                 :      285220 :     return gen_rtx_INT_LIST ((machine_mode) kind, XINT (note, 0), NULL_RTX);
    2769                 :     1980073 :   else if (GET_CODE (note) == EXPR_LIST)
    2770                 :     1980073 :     return alloc_reg_note (kind, copy_insn_1 (XEXP (note, 0)), NULL_RTX);
    2771                 :             :   else
    2772                 :           0 :     return alloc_reg_note (kind, XEXP (note, 0), NULL_RTX);
    2773                 :             : }
    2774                 :             : 
    2775                 :             : /* Remove register note NOTE from the REG_NOTES of INSN.  */
    2776                 :             : 
    2777                 :             : void
    2778                 :     8378954 : remove_note (rtx_insn *insn, const_rtx note)
    2779                 :             : {
    2780                 :     8378954 :   rtx link;
    2781                 :             : 
    2782                 :     8378954 :   if (note == NULL_RTX)
    2783                 :             :     return;
    2784                 :             : 
    2785                 :     7511721 :   if (REG_NOTES (insn) == note)
    2786                 :     7000389 :     REG_NOTES (insn) = XEXP (note, 1);
    2787                 :             :   else
    2788                 :     1008854 :     for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    2789                 :     1008854 :       if (XEXP (link, 1) == note)
    2790                 :             :         {
    2791                 :      511332 :           XEXP (link, 1) = XEXP (note, 1);
    2792                 :      511332 :           break;
    2793                 :             :         }
    2794                 :             : 
    2795                 :     7511721 :   switch (REG_NOTE_KIND (note))
    2796                 :             :     {
    2797                 :     2677116 :     case REG_EQUAL:
    2798                 :     2677116 :     case REG_EQUIV:
    2799                 :     2677116 :       df_notes_rescan (insn);
    2800                 :     2677116 :       break;
    2801                 :             :     default:
    2802                 :             :       break;
    2803                 :             :     }
    2804                 :             : }
    2805                 :             : 
    2806                 :             : /* Remove REG_EQUAL and/or REG_EQUIV notes if INSN has such notes.
    2807                 :             :    If NO_RESCAN is false and any notes were removed, call
    2808                 :             :    df_notes_rescan.  Return true if any note has been removed.  */
    2809                 :             : 
    2810                 :             : bool
    2811                 :       18639 : remove_reg_equal_equiv_notes (rtx_insn *insn, bool no_rescan)
    2812                 :             : {
    2813                 :       18639 :   rtx *loc;
    2814                 :       18639 :   bool ret = false;
    2815                 :             : 
    2816                 :       18639 :   loc = &REG_NOTES (insn);
    2817                 :       20566 :   while (*loc)
    2818                 :             :     {
    2819                 :        1927 :       enum reg_note kind = REG_NOTE_KIND (*loc);
    2820                 :        1927 :       if (kind == REG_EQUAL || kind == REG_EQUIV)
    2821                 :             :         {
    2822                 :         419 :           *loc = XEXP (*loc, 1);
    2823                 :         419 :           ret = true;
    2824                 :             :         }
    2825                 :             :       else
    2826                 :        1508 :         loc = &XEXP (*loc, 1);
    2827                 :             :     }
    2828                 :       18639 :   if (ret && !no_rescan)
    2829                 :         419 :     df_notes_rescan (insn);
    2830                 :       18639 :   return ret;
    2831                 :             : }
    2832                 :             : 
    2833                 :             : /* Remove all REG_EQUAL and REG_EQUIV notes referring to REGNO.  */
    2834                 :             : 
    2835                 :             : void
    2836                 :     4082750 : remove_reg_equal_equiv_notes_for_regno (unsigned int regno)
    2837                 :             : {
    2838                 :     4082750 :   df_ref eq_use;
    2839                 :             : 
    2840                 :     4082750 :   if (!df)
    2841                 :             :     return;
    2842                 :             : 
    2843                 :             :   /* This loop is a little tricky.  We cannot just go down the chain because
    2844                 :             :      it is being modified by some actions in the loop.  So we just iterate
    2845                 :             :      over the head.  We plan to drain the list anyway.  */
    2846                 :     4221897 :   while ((eq_use = DF_REG_EQ_USE_CHAIN (regno)) != NULL)
    2847                 :             :     {
    2848                 :      139147 :       rtx_insn *insn = DF_REF_INSN (eq_use);
    2849                 :      139147 :       rtx note = find_reg_equal_equiv_note (insn);
    2850                 :             : 
    2851                 :             :       /* This assert is generally triggered when someone deletes a REG_EQUAL
    2852                 :             :          or REG_EQUIV note by hacking the list manually rather than calling
    2853                 :             :          remove_note.  */
    2854                 :      139147 :       gcc_assert (note);
    2855                 :             : 
    2856                 :      139147 :       remove_note (insn, note);
    2857                 :             :     }
    2858                 :             : }
    2859                 :             : 
    2860                 :             : /* Search LISTP (an EXPR_LIST) for an entry whose first operand is NODE and
    2861                 :             :    return 1 if it is found.  A simple equality test is used to determine if
    2862                 :             :    NODE matches.  */
    2863                 :             : 
    2864                 :             : bool
    2865                 :          26 : in_insn_list_p (const rtx_insn_list *listp, const rtx_insn *node)
    2866                 :             : {
    2867                 :          26 :   const_rtx x;
    2868                 :             : 
    2869                 :          26 :   for (x = listp; x; x = XEXP (x, 1))
    2870                 :           0 :     if (node == XEXP (x, 0))
    2871                 :             :       return true;
    2872                 :             : 
    2873                 :             :   return false;
    2874                 :             : }
    2875                 :             : 
    2876                 :             : /* Search LISTP (an INSN_LIST) for an entry whose first operand is NODE and
    2877                 :             :    remove that entry from the list if it is found.
    2878                 :             : 
    2879                 :             :    A simple equality test is used to determine if NODE matches.  */
    2880                 :             : 
    2881                 :             : void
    2882                 :     7684419 : remove_node_from_insn_list (const rtx_insn *node, rtx_insn_list **listp)
    2883                 :             : {
    2884                 :     7684419 :   rtx_insn_list *temp = *listp;
    2885                 :     7684419 :   rtx_insn_list *prev = NULL;
    2886                 :             : 
    2887                 :     7700679 :   while (temp)
    2888                 :             :     {
    2889                 :       16286 :       if (node == temp->insn ())
    2890                 :             :         {
    2891                 :             :           /* Splice the node out of the list.  */
    2892                 :          26 :           if (prev)
    2893                 :           0 :             XEXP (prev, 1) = temp->next ();
    2894                 :             :           else
    2895                 :          26 :             *listp = temp->next ();
    2896                 :             : 
    2897                 :          26 :           gcc_checking_assert (!in_insn_list_p (temp->next (), node));
    2898                 :             :           return;
    2899                 :             :         }
    2900                 :             : 
    2901                 :       16260 :       prev = temp;
    2902                 :       16260 :       temp = temp->next ();
    2903                 :             :     }
    2904                 :             : }
    2905                 :             : 
    2906                 :             : /* Return true if X contains any volatile instructions.  These are instructions
    2907                 :             :    which may cause unpredictable machine state instructions, and thus no
    2908                 :             :    instructions or register uses should be moved or combined across them.
    2909                 :             :    This includes only volatile asms and UNSPEC_VOLATILE instructions.  */
    2910                 :             : 
    2911                 :             : bool
    2912                 :   694949018 : volatile_insn_p (const_rtx x)
    2913                 :             : {
    2914                 :   694949018 :   const RTX_CODE code = GET_CODE (x);
    2915                 :   694949018 :   switch (code)
    2916                 :             :     {
    2917                 :             :     case LABEL_REF:
    2918                 :             :     case SYMBOL_REF:
    2919                 :             :     case CONST:
    2920                 :             :     CASE_CONST_ANY:
    2921                 :             :     case PC:
    2922                 :             :     case REG:
    2923                 :             :     case SCRATCH:
    2924                 :             :     case CLOBBER:
    2925                 :             :     case ADDR_VEC:
    2926                 :             :     case ADDR_DIFF_VEC:
    2927                 :             :     case CALL:
    2928                 :             :     case MEM:
    2929                 :             :       return false;
    2930                 :             : 
    2931                 :             :     case UNSPEC_VOLATILE:
    2932                 :             :       return true;
    2933                 :             : 
    2934                 :      132253 :     case ASM_INPUT:
    2935                 :      132253 :     case ASM_OPERANDS:
    2936                 :      132253 :       if (MEM_VOLATILE_P (x))
    2937                 :             :         return true;
    2938                 :             : 
    2939                 :   327278645 :     default:
    2940                 :   327278645 :       break;
    2941                 :             :     }
    2942                 :             : 
    2943                 :             :   /* Recursively scan the operands of this expression.  */
    2944                 :             : 
    2945                 :   327278645 :   {
    2946                 :   327278645 :     const char *const fmt = GET_RTX_FORMAT (code);
    2947                 :   327278645 :     int i;
    2948                 :             : 
    2949                 :   891882319 :     for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    2950                 :             :       {
    2951                 :   564898329 :         if (fmt[i] == 'e')
    2952                 :             :           {
    2953                 :   439544779 :             if (volatile_insn_p (XEXP (x, i)))
    2954                 :             :               return true;
    2955                 :             :           }
    2956                 :   125353550 :         else if (fmt[i] == 'E')
    2957                 :             :           {
    2958                 :             :             int j;
    2959                 :    69183484 :             for (j = 0; j < XVECLEN (x, i); j++)
    2960                 :    47599988 :               if (volatile_insn_p (XVECEXP (x, i, j)))
    2961                 :             :                 return true;
    2962                 :             :           }
    2963                 :             :       }
    2964                 :             :   }
    2965                 :             :   return false;
    2966                 :             : }
    2967                 :             : 
    2968                 :             : /* Return true if X contains any volatile memory references
    2969                 :             :    UNSPEC_VOLATILE operations or volatile ASM_OPERANDS expressions.  */
    2970                 :             : 
    2971                 :             : bool
    2972                 :  5154232018 : volatile_refs_p (const_rtx x)
    2973                 :             : {
    2974                 :  5154232018 :   const RTX_CODE code = GET_CODE (x);
    2975                 :  5154232018 :   switch (code)
    2976                 :             :     {
    2977                 :             :     case LABEL_REF:
    2978                 :             :     case SYMBOL_REF:
    2979                 :             :     case CONST:
    2980                 :             :     CASE_CONST_ANY:
    2981                 :             :     case PC:
    2982                 :             :     case REG:
    2983                 :             :     case SCRATCH:
    2984                 :             :     case CLOBBER:
    2985                 :             :     case ADDR_VEC:
    2986                 :             :     case ADDR_DIFF_VEC:
    2987                 :             :       return false;
    2988                 :             : 
    2989                 :             :     case UNSPEC_VOLATILE:
    2990                 :             :       return true;
    2991                 :             : 
    2992                 :   385830796 :     case MEM:
    2993                 :   385830796 :     case ASM_INPUT:
    2994                 :   385830796 :     case ASM_OPERANDS:
    2995                 :   385830796 :       if (MEM_VOLATILE_P (x))
    2996                 :             :         return true;
    2997                 :             : 
    2998                 :  2191056331 :     default:
    2999                 :  2191056331 :       break;
    3000                 :             :     }
    3001                 :             : 
    3002                 :             :   /* Recursively scan the operands of this expression.  */
    3003                 :             : 
    3004                 :  2191056331 :   {
    3005                 :  2191056331 :     const char *const fmt = GET_RTX_FORMAT (code);
    3006                 :  2191056331 :     int i;
    3007                 :             : 
    3008                 :  6438194108 :     for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    3009                 :             :       {
    3010                 :  4262406053 :         if (fmt[i] == 'e')
    3011                 :             :           {
    3012                 :  3797162923 :             if (volatile_refs_p (XEXP (x, i)))
    3013                 :             :               return true;
    3014                 :             :           }
    3015                 :   465243130 :         else if (fmt[i] == 'E')
    3016                 :             :           {
    3017                 :             :             int j;
    3018                 :   158762576 :             for (j = 0; j < XVECLEN (x, i); j++)
    3019                 :   109997218 :               if (volatile_refs_p (XVECEXP (x, i, j)))
    3020                 :             :                 return true;
    3021                 :             :           }
    3022                 :             :       }
    3023                 :             :   }
    3024                 :             :   return false;
    3025                 :             : }
    3026                 :             : 
    3027                 :             : /* Similar to above, except that it also rejects register pre- and post-
    3028                 :             :    incrementing.  */
    3029                 :             : 
    3030                 :             : bool
    3031                 :  5273826318 : side_effects_p (const_rtx x)
    3032                 :             : {
    3033                 :  5273826318 :   const RTX_CODE code = GET_CODE (x);
    3034                 :  5273826318 :   switch (code)
    3035                 :             :     {
    3036                 :             :     case LABEL_REF:
    3037                 :             :     case SYMBOL_REF:
    3038                 :             :     case CONST:
    3039                 :             :     CASE_CONST_ANY:
    3040                 :             :     case PC:
    3041                 :             :     case REG:
    3042                 :             :     case SCRATCH:
    3043                 :             :     case ADDR_VEC:
    3044                 :             :     case ADDR_DIFF_VEC:
    3045                 :             :     case VAR_LOCATION:
    3046                 :             :       return false;
    3047                 :             : 
    3048                 :    62393451 :     case CLOBBER:
    3049                 :             :       /* Reject CLOBBER with a non-VOID mode.  These are made by combine.cc
    3050                 :             :          when some combination can't be done.  If we see one, don't think
    3051                 :             :          that we can simplify the expression.  */
    3052                 :    62393451 :       return (GET_MODE (x) != VOIDmode);
    3053                 :             : 
    3054                 :             :     case PRE_INC:
    3055                 :             :     case PRE_DEC:
    3056                 :             :     case POST_INC:
    3057                 :             :     case POST_DEC:
    3058                 :             :     case PRE_MODIFY:
    3059                 :             :     case POST_MODIFY:
    3060                 :             :     case CALL:
    3061                 :             :     case UNSPEC_VOLATILE:
    3062                 :             :       return true;
    3063                 :             : 
    3064                 :   316669161 :     case MEM:
    3065                 :   316669161 :     case ASM_INPUT:
    3066                 :   316669161 :     case ASM_OPERANDS:
    3067                 :   316669161 :       if (MEM_VOLATILE_P (x))
    3068                 :             :         return true;
    3069                 :             : 
    3070                 :  1860762093 :     default:
    3071                 :  1860762093 :       break;
    3072                 :             :     }
    3073                 :             : 
    3074                 :             :   /* Recursively scan the operands of this expression.  */
    3075                 :             : 
    3076                 :  1860762093 :   {
    3077                 :  1860762093 :     const char *fmt = GET_RTX_FORMAT (code);
    3078                 :  1860762093 :     int i;
    3079                 :             : 
    3080                 :  5531628247 :     for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    3081                 :             :       {
    3082                 :  3719615129 :         if (fmt[i] == 'e')
    3083                 :             :           {
    3084                 :  3296987277 :             if (side_effects_p (XEXP (x, i)))
    3085                 :             :               return true;
    3086                 :             :           }
    3087                 :   422627852 :         else if (fmt[i] == 'E')
    3088                 :             :           {
    3089                 :             :             int j;
    3090                 :   232297462 :             for (j = 0; j < XVECLEN (x, i); j++)
    3091                 :   156957218 :               if (side_effects_p (XVECEXP (x, i, j)))
    3092                 :             :                 return true;
    3093                 :             :           }
    3094                 :             :       }
    3095                 :             :   }
    3096                 :             :   return false;
    3097                 :             : }
    3098                 :             : 
    3099                 :             : /* Return true if evaluating rtx X might cause a trap.
    3100                 :             :    FLAGS controls how to consider MEMs.  A true means the context
    3101                 :             :    of the access may have changed from the original, such that the
    3102                 :             :    address may have become invalid.  */
    3103                 :             : 
    3104                 :             : bool
    3105                 :  8846067436 : may_trap_p_1 (const_rtx x, unsigned flags)
    3106                 :             : {
    3107                 :  8846067436 :   int i;
    3108                 :  8846067436 :   enum rtx_code code;
    3109                 :  8846067436 :   const char *fmt;
    3110                 :             : 
    3111                 :             :   /* We make no distinction currently, but this function is part of
    3112                 :             :      the internal target-hooks ABI so we keep the parameter as
    3113                 :             :      "unsigned flags".  */
    3114                 :  8846067436 :   bool code_changed = flags != 0;
    3115                 :             : 
    3116                 :  8846067436 :   if (x == 0)
    3117                 :             :     return false;
    3118                 :  8846065432 :   code = GET_CODE (x);
    3119                 :  8846065432 :   switch (code)
    3120                 :             :     {
    3121                 :             :       /* Handle these cases quickly.  */
    3122                 :             :     CASE_CONST_ANY:
    3123                 :             :     case SYMBOL_REF:
    3124                 :             :     case LABEL_REF:
    3125                 :             :     case CONST:
    3126                 :             :     case PC:
    3127                 :             :     case REG:
    3128                 :             :     case SCRATCH:
    3129                 :             :       return false;
    3130                 :             : 
    3131                 :     5657444 :     case UNSPEC:
    3132                 :     5657444 :       return targetm.unspec_may_trap_p (x, flags);
    3133                 :             : 
    3134                 :             :     case UNSPEC_VOLATILE:
    3135                 :             :     case ASM_INPUT:
    3136                 :             :     case TRAP_IF:
    3137                 :             :       return true;
    3138                 :             : 
    3139                 :      176248 :     case ASM_OPERANDS:
    3140                 :      176248 :       return MEM_VOLATILE_P (x);
    3141                 :             : 
    3142                 :             :       /* Memory ref can trap unless it's a static var or a stack slot.  */
    3143                 :  1039111573 :     case MEM:
    3144                 :             :       /* Recognize specific pattern of stack checking probes.  */
    3145                 :  1039111573 :       if (flag_stack_check
    3146                 :        7456 :           && MEM_VOLATILE_P (x)
    3147                 :  1039112359 :           && XEXP (x, 0) == stack_pointer_rtx)
    3148                 :             :         return true;
    3149                 :  1039110788 :       if (/* MEM_NOTRAP_P only relates to the actual position of the memory
    3150                 :             :              reference; moving it out of context such as when moving code
    3151                 :             :              when optimizing, might cause its address to become invalid.  */
    3152                 :             :           code_changed
    3153                 :  1039110788 :           || !MEM_NOTRAP_P (x))
    3154                 :             :         {
    3155                 :   494570434 :           poly_int64 size = MEM_SIZE_KNOWN_P (x) ? MEM_SIZE (x) : -1;
    3156                 :   433977271 :           return rtx_addr_can_trap_p_1 (XEXP (x, 0), 0, size,
    3157                 :   433977271 :                                         GET_MODE (x), code_changed);
    3158                 :             :         }
    3159                 :             : 
    3160                 :             :       return false;
    3161                 :             : 
    3162                 :             :       /* Division by a non-constant might trap.  */
    3163                 :     1010501 :     case DIV:
    3164                 :     1010501 :     case MOD:
    3165                 :     1010501 :     case UDIV:
    3166                 :     1010501 :     case UMOD:
    3167                 :     1010501 :       if (HONOR_SNANS (x))
    3168                 :             :         return true;
    3169                 :     1009805 :       if (FLOAT_MODE_P (GET_MODE (x)))
    3170                 :      421923 :         return flag_trapping_math;
    3171                 :      587882 :       if (!CONSTANT_P (XEXP (x, 1)) || (XEXP (x, 1) == const0_rtx))
    3172                 :             :         return true;
    3173                 :       98664 :       if (GET_CODE (XEXP (x, 1)) == CONST_VECTOR)
    3174                 :             :         {
    3175                 :             :           /* For CONST_VECTOR, return 1 if any element is or might be zero.  */
    3176                 :           0 :           unsigned int n_elts;
    3177                 :           0 :           rtx op = XEXP (x, 1);
    3178                 :           0 :           if (!GET_MODE_NUNITS (GET_MODE (op)).is_constant (&n_elts))
    3179                 :             :             {
    3180                 :             :               if (!CONST_VECTOR_DUPLICATE_P (op))
    3181                 :   279513335 :                 return true;
    3182                 :             :               for (unsigned i = 0; i < (unsigned int) XVECLEN (op, 0); i++)
    3183                 :             :                 if (CONST_VECTOR_ENCODED_ELT (op, i) == const0_rtx)
    3184                 :             :                   return true;
    3185                 :             :             }
    3186                 :             :           else
    3187                 :           0 :             for (unsigned i = 0; i < n_elts; i++)
    3188                 :           0 :               if (CONST_VECTOR_ELT (op, i) == const0_rtx)
    3189                 :             :                 return true;
    3190                 :             :         }
    3191                 :             :       break;
    3192                 :             : 
    3193                 :             :     case EXPR_LIST:
    3194                 :             :       /* An EXPR_LIST is used to represent a function call.  This
    3195                 :             :          certainly may trap.  */
    3196                 :             :       return true;
    3197                 :             : 
    3198                 :   180366205 :     case GE:
    3199                 :   180366205 :     case GT:
    3200                 :   180366205 :     case LE:
    3201                 :   180366205 :     case LT:
    3202                 :   180366205 :     case LTGT:
    3203                 :   180366205 :     case COMPARE:
    3204                 :             :     /* Treat min/max similar as comparisons.  */
    3205                 :   180366205 :     case SMIN:
    3206                 :   180366205 :     case SMAX:
    3207                 :             :       /* Some floating point comparisons may trap.  */
    3208                 :   180366205 :       if (!flag_trapping_math)
    3209                 :             :         break;
    3210                 :             :       /* ??? There is no machine independent way to check for tests that trap
    3211                 :             :          when COMPARE is used, though many targets do make this distinction.
    3212                 :             :          For instance, sparc uses CCFPE for compares which generate exceptions
    3213                 :             :          and CCFP for compares which do not generate exceptions.  */
    3214                 :   178793348 :       if (HONOR_NANS (x))
    3215                 :             :         return true;
    3216                 :             :       /* But often the compare has some CC mode, so check operand
    3217                 :             :          modes as well.  */
    3218                 :   178768007 :       if (HONOR_NANS (XEXP (x, 0))
    3219                 :   178768007 :           || HONOR_NANS (XEXP (x, 1)))
    3220                 :     2185049 :         return true;
    3221                 :             :       break;
    3222                 :             : 
    3223                 :    28161793 :     case EQ:
    3224                 :    28161793 :     case NE:
    3225                 :    28161793 :       if (HONOR_SNANS (x))
    3226                 :             :         return true;
    3227                 :             :       /* Often comparison is CC mode, so check operand modes.  */
    3228                 :    28161776 :       if (HONOR_SNANS (XEXP (x, 0))
    3229                 :    28161776 :           || HONOR_SNANS (XEXP (x, 1)))
    3230                 :           0 :         return true;
    3231                 :             :       break;
    3232                 :             : 
    3233                 :      359746 :     case FIX:
    3234                 :      359746 :     case UNSIGNED_FIX:
    3235                 :             :       /* Conversion of floating point might trap.  */
    3236                 :      359746 :       if (flag_trapping_math && HONOR_NANS (XEXP (x, 0)))
    3237                 :             :         return true;
    3238                 :             :       break;
    3239                 :             : 
    3240                 :             :     case PARALLEL:
    3241                 :             :     case NEG:
    3242                 :             :     case ABS:
    3243                 :             :     case SUBREG:
    3244                 :             :     case VEC_MERGE:
    3245                 :             :     case VEC_SELECT:
    3246                 :             :     case VEC_CONCAT:
    3247                 :             :     case VEC_DUPLICATE:
    3248                 :             :       /* These operations don't trap even with floating point.  */
    3249                 :             :       break;
    3250                 :             : 
    3251                 :  3011515708 :     default:
    3252                 :             :       /* Any floating arithmetic may trap.  */
    3253                 :  3011515708 :       if (FLOAT_MODE_P (GET_MODE (x)) && flag_trapping_math)
    3254                 :             :         return true;
    3255                 :             :     }
    3256                 :             : 
    3257                 :  3627256730 :   fmt = GET_RTX_FORMAT (code);
    3258                 :  9774319536 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    3259                 :             :     {
    3260                 :  6383257793 :       if (fmt[i] == 'e')
    3261                 :             :         {
    3262                 :  5940668298 :           if (may_trap_p_1 (XEXP (x, i), flags))
    3263                 :             :             return true;
    3264                 :             :         }
    3265                 :   442589495 :       else if (fmt[i] == 'E')
    3266                 :             :         {
    3267                 :             :           int j;
    3268                 :   957819190 :           for (j = 0; j < XVECLEN (x, i); j++)
    3269                 :   661862327 :             if (may_trap_p_1 (XVECEXP (x, i, j), flags))
    3270                 :             :               return true;
    3271                 :             :         }
    3272                 :             :     }
    3273                 :             :   return false;
    3274                 :             : }
    3275                 :             : 
    3276                 :             : /* Return true if evaluating rtx X might cause a trap.  */
    3277                 :             : 
    3278                 :             : bool
    3279                 :  2225837503 : may_trap_p (const_rtx x)
    3280                 :             : {
    3281                 :  2225837503 :   return may_trap_p_1 (x, 0);
    3282                 :             : }
    3283                 :             : 
    3284                 :             : /* Same as above, but additionally return true if evaluating rtx X might
    3285                 :             :    cause a fault.  We define a fault for the purpose of this function as a
    3286                 :             :    erroneous execution condition that cannot be encountered during the normal
    3287                 :             :    execution of a valid program; the typical example is an unaligned memory
    3288                 :             :    access on a strict alignment machine.  The compiler guarantees that it
    3289                 :             :    doesn't generate code that will fault from a valid program, but this
    3290                 :             :    guarantee doesn't mean anything for individual instructions.  Consider
    3291                 :             :    the following example:
    3292                 :             : 
    3293                 :             :       struct S { int d; union { char *cp; int *ip; }; };
    3294                 :             : 
    3295                 :             :       int foo(struct S *s)
    3296                 :             :       {
    3297                 :             :         if (s->d == 1)
    3298                 :             :           return *s->ip;
    3299                 :             :         else
    3300                 :             :           return *s->cp;
    3301                 :             :       }
    3302                 :             : 
    3303                 :             :    on a strict alignment machine.  In a valid program, foo will never be
    3304                 :             :    invoked on a structure for which d is equal to 1 and the underlying
    3305                 :             :    unique field of the union not aligned on a 4-byte boundary, but the
    3306                 :             :    expression *s->ip might cause a fault if considered individually.
    3307                 :             : 
    3308                 :             :    At the RTL level, potentially problematic expressions will almost always
    3309                 :             :    verify may_trap_p; for example, the above dereference can be emitted as
    3310                 :             :    (mem:SI (reg:P)) and this expression is may_trap_p for a generic register.
    3311                 :             :    However, suppose that foo is inlined in a caller that causes s->cp to
    3312                 :             :    point to a local character variable and guarantees that s->d is not set
    3313                 :             :    to 1; foo may have been effectively translated into pseudo-RTL as:
    3314                 :             : 
    3315                 :             :       if ((reg:SI) == 1)
    3316                 :             :         (set (reg:SI) (mem:SI (%fp - 7)))
    3317                 :             :       else
    3318                 :             :         (set (reg:QI) (mem:QI (%fp - 7)))
    3319                 :             : 
    3320                 :             :    Now (mem:SI (%fp - 7)) is considered as not may_trap_p since it is a
    3321                 :             :    memory reference to a stack slot, but it will certainly cause a fault
    3322                 :             :    on a strict alignment machine.  */
    3323                 :             : 
    3324                 :             : bool
    3325                 :    10608164 : may_trap_or_fault_p (const_rtx x)
    3326                 :             : {
    3327                 :    10608164 :   return may_trap_p_1 (x, 1);
    3328                 :             : }
    3329                 :             : 
    3330                 :             : /* Replace any occurrence of FROM in X with TO.  The function does
    3331                 :             :    not enter into CONST_DOUBLE for the replace.
    3332                 :             : 
    3333                 :             :    Note that copying is not done so X must not be shared unless all copies
    3334                 :             :    are to be modified.
    3335                 :             : 
    3336                 :             :    ALL_REGS is true if we want to replace all REGs equal to FROM, not just
    3337                 :             :    those pointer-equal ones.  */
    3338                 :             : 
    3339                 :             : rtx
    3340                 :     8943860 : replace_rtx (rtx x, rtx from, rtx to, bool all_regs)
    3341                 :             : {
    3342                 :     8943860 :   int i, j;
    3343                 :     8943860 :   const char *fmt;
    3344                 :             : 
    3345                 :     8943860 :   if (x == from)
    3346                 :             :     return to;
    3347                 :             : 
    3348                 :             :   /* Allow this function to make replacements in EXPR_LISTs.  */
    3349                 :     6518520 :   if (x == 0)
    3350                 :             :     return 0;
    3351                 :             : 
    3352                 :     6518520 :   if (all_regs
    3353                 :           0 :       && REG_P (x)
    3354                 :           0 :       && REG_P (from)
    3355                 :     6518520 :       && REGNO (x) == REGNO (from))
    3356                 :             :     {
    3357                 :           0 :       gcc_assert (GET_MODE (x) == GET_MODE (from));
    3358                 :             :       return to;
    3359                 :             :     }
    3360                 :     6518520 :   else if (GET_CODE (x) == SUBREG)
    3361                 :             :     {
    3362                 :       49039 :       rtx new_rtx = replace_rtx (SUBREG_REG (x), from, to, all_regs);
    3363                 :             : 
    3364                 :       49039 :       if (CONST_SCALAR_INT_P (new_rtx))
    3365                 :             :         {
    3366                 :           6 :           x = simplify_subreg (GET_MODE (x), new_rtx,
    3367                 :           3 :                                GET_MODE (SUBREG_REG (x)),
    3368                 :           3 :                                SUBREG_BYTE (x));
    3369                 :           3 :           gcc_assert (x);
    3370                 :             :         }
    3371                 :             :       else
    3372                 :       49036 :         SUBREG_REG (x) = new_rtx;
    3373                 :             : 
    3374                 :       49039 :       return x;
    3375                 :             :     }
    3376                 :     6469481 :   else if (GET_CODE (x) == ZERO_EXTEND)
    3377                 :             :     {
    3378                 :      207175 :       rtx new_rtx = replace_rtx (XEXP (x, 0), from, to, all_regs);
    3379                 :             : 
    3380                 :      207175 :       if (CONST_SCALAR_INT_P (new_rtx))
    3381                 :             :         {
    3382                 :           6 :           x = simplify_unary_operation (ZERO_EXTEND, GET_MODE (x),
    3383                 :           3 :                                         new_rtx, GET_MODE (XEXP (x, 0)));
    3384                 :           3 :           gcc_assert (x);
    3385                 :             :         }
    3386                 :             :       else
    3387                 :      207172 :         XEXP (x, 0) = new_rtx;
    3388                 :             : 
    3389                 :      207175 :       return x;
    3390                 :             :     }
    3391                 :             : 
    3392                 :     6262306 :   fmt = GET_RTX_FORMAT (GET_CODE (x));
    3393                 :    15529801 :   for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
    3394                 :             :     {
    3395                 :     9267495 :       if (fmt[i] == 'e')
    3396                 :     6063955 :         XEXP (x, i) = replace_rtx (XEXP (x, i), from, to, all_regs);
    3397                 :     3203540 :       else if (fmt[i] == 'E')
    3398                 :      130672 :         for (j = XVECLEN (x, i) - 1; j >= 0; j--)
    3399                 :      108080 :           XVECEXP (x, i, j) = replace_rtx (XVECEXP (x, i, j),
    3400                 :             :                                            from, to, all_regs);
    3401                 :             :     }
    3402                 :             : 
    3403                 :             :   return x;
    3404                 :             : }
    3405                 :             : 
    3406                 :             : /* Replace occurrences of the OLD_LABEL in *LOC with NEW_LABEL.  Also track
    3407                 :             :    the change in LABEL_NUSES if UPDATE_LABEL_NUSES.  */
    3408                 :             : 
    3409                 :             : void
    3410                 :        9687 : replace_label (rtx *loc, rtx old_label, rtx new_label, bool update_label_nuses)
    3411                 :             : {
    3412                 :             :   /* Handle jump tables specially, since ADDR_{DIFF_,}VECs can be long.  */
    3413                 :        9687 :   rtx x = *loc;
    3414                 :        9687 :   if (JUMP_TABLE_DATA_P (x))
    3415                 :             :     {
    3416                 :          15 :       x = PATTERN (x);
    3417                 :          15 :       rtvec vec = XVEC (x, GET_CODE (x) == ADDR_DIFF_VEC);
    3418                 :          15 :       int len = GET_NUM_ELEM (vec);
    3419                 :         207 :       for (int i = 0; i < len; ++i)
    3420                 :             :         {
    3421                 :         192 :           rtx ref = RTVEC_ELT (vec, i);
    3422                 :         192 :           if (XEXP (ref, 0) == old_label)
    3423                 :             :             {
    3424                 :           0 :               XEXP (ref, 0) = new_label;
    3425                 :           0 :               if (update_label_nuses)
    3426                 :             :                 {
    3427                 :           0 :                   ++LABEL_NUSES (new_label);
    3428                 :           0 :                   --LABEL_NUSES (old_label);
    3429                 :             :                 }
    3430                 :             :             }
    3431                 :             :         }
    3432                 :          15 :       return;
    3433                 :             :     }
    3434                 :             : 
    3435                 :             :   /* If this is a JUMP_INSN, then we also need to fix the JUMP_LABEL
    3436                 :             :      field.  This is not handled by the iterator because it doesn't
    3437                 :             :      handle unprinted ('0') fields.  */
    3438                 :        9672 :   if (JUMP_P (x) && JUMP_LABEL (x) == old_label)
    3439                 :          20 :     JUMP_LABEL (x) = new_label;
    3440                 :             : 
    3441                 :        9672 :   subrtx_ptr_iterator::array_type array;
    3442                 :       79423 :   FOR_EACH_SUBRTX_PTR (iter, array, loc, ALL)
    3443                 :             :     {
    3444                 :       69751 :       rtx *loc = *iter;
    3445                 :       69751 :       if (rtx x = *loc)
    3446                 :             :         {
    3447                 :       60884 :           if (GET_CODE (x) == SYMBOL_REF
    3448                 :       60884 :               && CONSTANT_POOL_ADDRESS_P (x))
    3449                 :             :             {
    3450                 :         338 :               rtx c = get_pool_constant (x);
    3451                 :         338 :               if (rtx_referenced_p (old_label, c))
    3452                 :             :                 {
    3453                 :             :                   /* Create a copy of constant C; replace the label inside
    3454                 :             :                      but do not update LABEL_NUSES because uses in constant pool
    3455                 :             :                      are not counted.  */
    3456                 :           0 :                   rtx new_c = copy_rtx (c);
    3457                 :           0 :                   replace_label (&new_c, old_label, new_label, false);
    3458                 :             : 
    3459                 :             :                   /* Add the new constant NEW_C to constant pool and replace
    3460                 :             :                      the old reference to constant by new reference.  */
    3461                 :           0 :                   rtx new_mem = force_const_mem (get_pool_mode (x), new_c);
    3462                 :           0 :                   *loc = replace_rtx (x, x, XEXP (new_mem, 0));
    3463                 :             :                 }
    3464                 :             :             }
    3465                 :             : 
    3466                 :       60884 :           if ((GET_CODE (x) == LABEL_REF
    3467                 :       60451 :                || GET_CODE (x) == INSN_LIST)
    3468                 :         453 :               && XEXP (x, 0) == old_label)
    3469                 :             :             {
    3470                 :          40 :               XEXP (x, 0) = new_label;
    3471                 :          40 :               if (update_label_nuses)
    3472                 :             :                 {
    3473                 :           0 :                   ++LABEL_NUSES (new_label);
    3474                 :           0 :                   --LABEL_NUSES (old_label);
    3475                 :             :                 }
    3476                 :             :             }
    3477                 :             :         }
    3478                 :             :     }
    3479                 :        9672 : }
    3480                 :             : 
    3481                 :             : void
    3482                 :        9687 : replace_label_in_insn (rtx_insn *insn, rtx_insn *old_label,
    3483                 :             :                        rtx_insn *new_label, bool update_label_nuses)
    3484                 :             : {
    3485                 :        9687 :   rtx insn_as_rtx = insn;
    3486                 :        9687 :   replace_label (&insn_as_rtx, old_label, new_label, update_label_nuses);
    3487                 :        9687 :   gcc_checking_assert (insn_as_rtx == insn);
    3488                 :        9687 : }
    3489                 :             : 
    3490                 :             : /* Return true if X is referenced in BODY.  */
    3491                 :             : 
    3492                 :             : bool
    3493                 :      355659 : rtx_referenced_p (const_rtx x, const_rtx body)
    3494                 :             : {
    3495                 :      355659 :   subrtx_iterator::array_type array;
    3496                 :     1674744 :   FOR_EACH_SUBRTX (iter, array, body, ALL)
    3497                 :     1344398 :     if (const_rtx y = *iter)
    3498                 :             :       {
    3499                 :             :         /* Check if a label_ref Y refers to label X.  */
    3500                 :     1342500 :         if (GET_CODE (y) == LABEL_REF
    3501                 :        3559 :             && LABEL_P (x)
    3502                 :     1346056 :             && label_ref_label (y) == x)
    3503                 :       25313 :           return true;
    3504                 :             : 
    3505                 :     1342500 :         if (rtx_equal_p (x, y))
    3506                 :             :           return true;
    3507                 :             : 
    3508                 :             :         /* If Y is a reference to pool constant traverse the constant.  */
    3509                 :     1317187 :         if (GET_CODE (y) == SYMBOL_REF
    3510                 :     1317187 :             && CONSTANT_POOL_ADDRESS_P (y))
    3511                 :        6561 :           iter.substitute (get_pool_constant (y));
    3512                 :             :       }
    3513                 :      330346 :   return false;
    3514                 :      355659 : }
    3515                 :             : 
    3516                 :             : /* If INSN is a tablejump return true and store the label (before jump table) to
    3517                 :             :    *LABELP and the jump table to *TABLEP.  LABELP and TABLEP may be NULL.  */
    3518                 :             : 
    3519                 :             : bool
    3520                 :   107337747 : tablejump_p (const rtx_insn *insn, rtx_insn **labelp,
    3521                 :             :              rtx_jump_table_data **tablep)
    3522                 :             : {
    3523                 :   107337747 :   if (!JUMP_P (insn))
    3524                 :             :     return false;
    3525                 :             : 
    3526                 :    81145252 :   rtx target = JUMP_LABEL (insn);
    3527                 :    81145252 :   if (target == NULL_RTX || ANY_RETURN_P (target))
    3528                 :             :     return false;
    3529                 :             : 
    3530                 :    77580984 :   rtx_insn *label = as_a<rtx_insn *> (target);
    3531                 :    77580984 :   rtx_insn *table = next_insn (label);
    3532                 :    77580984 :   if (table == NULL_RTX || !JUMP_TABLE_DATA_P (table))
    3533                 :             :     return false;
    3534                 :             : 
    3535                 :      191589 :   if (labelp)
    3536                 :      138187 :     *labelp = label;
    3537                 :      191589 :   if (tablep)
    3538                 :      185844 :     *tablep = as_a <rtx_jump_table_data *> (table);
    3539                 :             :   return true;
    3540                 :             : }
    3541                 :             : 
    3542                 :             : /* For INSN known to satisfy tablejump_p, determine if it actually is a
    3543                 :             :    CASESI.  Return the insn pattern if so, NULL_RTX otherwise.  */
    3544                 :             : 
    3545                 :             : rtx
    3546                 :       30165 : tablejump_casesi_pattern (const rtx_insn *insn)
    3547                 :             : {
    3548                 :       30165 :   rtx tmp;
    3549                 :             : 
    3550                 :       30165 :   if ((tmp = single_set (insn)) != NULL
    3551                 :       30165 :       && SET_DEST (tmp) == pc_rtx
    3552                 :       30165 :       && GET_CODE (SET_SRC (tmp)) == IF_THEN_ELSE
    3553                 :       30165 :       && GET_CODE (XEXP (SET_SRC (tmp), 2)) == LABEL_REF)
    3554                 :           0 :     return tmp;
    3555                 :             : 
    3556                 :             :   return NULL_RTX;
    3557                 :             : }
    3558                 :             : 
    3559                 :             : /* A subroutine of computed_jump_p, return true if X contains a REG or MEM or
    3560                 :             :    constant that is not in the constant pool and not in the condition
    3561                 :             :    of an IF_THEN_ELSE.  */
    3562                 :             : 
    3563                 :             : static bool
    3564                 :        1870 : computed_jump_p_1 (const_rtx x)
    3565                 :             : {
    3566                 :        1870 :   const enum rtx_code code = GET_CODE (x);
    3567                 :        1870 :   int i, j;
    3568                 :        1870 :   const char *fmt;
    3569                 :             : 
    3570                 :        1870 :   switch (code)
    3571                 :             :     {
    3572                 :             :     case LABEL_REF:
    3573                 :             :     case PC:
    3574                 :             :       return false;
    3575                 :             : 
    3576                 :             :     case CONST:
    3577                 :             :     CASE_CONST_ANY:
    3578                 :             :     case SYMBOL_REF:
    3579                 :             :     case REG:
    3580                 :             :       return true;
    3581                 :             : 
    3582                 :         317 :     case MEM:
    3583                 :         317 :       return ! (GET_CODE (XEXP (x, 0)) == SYMBOL_REF
    3584                 :          14 :                 && CONSTANT_POOL_ADDRESS_P (XEXP (x, 0)));
    3585                 :             : 
    3586                 :           0 :     case IF_THEN_ELSE:
    3587                 :           0 :       return (computed_jump_p_1 (XEXP (x, 1))
    3588                 :           0 :               || computed_jump_p_1 (XEXP (x, 2)));
    3589                 :             : 
    3590                 :           0 :     default:
    3591                 :           0 :       break;
    3592                 :             :     }
    3593                 :             : 
    3594                 :           0 :   fmt = GET_RTX_FORMAT (code);
    3595                 :           0 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    3596                 :             :     {
    3597                 :           0 :       if (fmt[i] == 'e'
    3598                 :           0 :           && computed_jump_p_1 (XEXP (x, i)))
    3599                 :             :         return true;
    3600                 :             : 
    3601                 :           0 :       else if (fmt[i] == 'E')
    3602                 :           0 :         for (j = 0; j < XVECLEN (x, i); j++)
    3603                 :           0 :           if (computed_jump_p_1 (XVECEXP (x, i, j)))
    3604                 :             :             return true;
    3605                 :             :     }
    3606                 :             : 
    3607                 :             :   return false;
    3608                 :             : }
    3609                 :             : 
    3610                 :             : /* Return true if INSN is an indirect jump (aka computed jump).
    3611                 :             : 
    3612                 :             :    Tablejumps and casesi insns are not considered indirect jumps;
    3613                 :             :    we can recognize them by a (use (label_ref)).  */
    3614                 :             : 
    3615                 :             : bool
    3616                 :    45773923 : computed_jump_p (const rtx_insn *insn)
    3617                 :             : {
    3618                 :    45773923 :   int i;
    3619                 :    45773923 :   if (JUMP_P (insn))
    3620                 :             :     {
    3621                 :    41795936 :       rtx pat = PATTERN (insn);
    3622                 :             : 
    3623                 :             :       /* If we have a JUMP_LABEL set, we're not a computed jump.  */
    3624                 :    41795936 :       if (JUMP_LABEL (insn) != NULL)
    3625                 :             :         return false;
    3626                 :             : 
    3627                 :        2384 :       if (GET_CODE (pat) == PARALLEL)
    3628                 :             :         {
    3629                 :         483 :           int len = XVECLEN (pat, 0);
    3630                 :         483 :           bool has_use_labelref = false;
    3631                 :             : 
    3632                 :        1449 :           for (i = len - 1; i >= 0; i--)
    3633                 :         966 :             if (GET_CODE (XVECEXP (pat, 0, i)) == USE
    3634                 :           0 :                 && (GET_CODE (XEXP (XVECEXP (pat, 0, i), 0))
    3635                 :             :                     == LABEL_REF))
    3636                 :             :               {
    3637                 :             :                 has_use_labelref = true;
    3638                 :             :                 break;
    3639                 :             :               }
    3640                 :             : 
    3641                 :         483 :           if (! has_use_labelref)
    3642                 :        1449 :             for (i = len - 1; i >= 0; i--)
    3643                 :         966 :               if (GET_CODE (XVECEXP (pat, 0, i)) == SET
    3644                 :           0 :                   && SET_DEST (XVECEXP (pat, 0, i)) == pc_rtx
    3645                 :         966 :                   && computed_jump_p_1 (SET_SRC (XVECEXP (pat, 0, i))))
    3646                 :             :                 return true;
    3647                 :             :         }
    3648                 :        1901 :       else if (GET_CODE (pat) == SET
    3649                 :        1870 :                && SET_DEST (pat) == pc_rtx
    3650                 :        3771 :                && computed_jump_p_1 (SET_SRC (pat)))
    3651                 :             :         return true;
    3652                 :             :     }
    3653                 :             :   return false;
    3654                 :             : }
    3655                 :             : 
    3656                 :             : 
    3657                 :             : 
    3658                 :             : /* MEM has a PRE/POST-INC/DEC/MODIFY address X.  Extract the operands of
    3659                 :             :    the equivalent add insn and pass the result to FN, using DATA as the
    3660                 :             :    final argument.  */
    3661                 :             : 
    3662                 :             : static int
    3663                 :    20770817 : for_each_inc_dec_find_inc_dec (rtx mem, for_each_inc_dec_fn fn, void *data)
    3664                 :             : {
    3665                 :    20770817 :   rtx x = XEXP (mem, 0);
    3666                 :    20770817 :   switch (GET_CODE (x))
    3667                 :             :     {
    3668                 :     2973099 :     case PRE_INC:
    3669                 :     2973099 :     case POST_INC:
    3670                 :     2973099 :       {
    3671                 :     5946198 :         poly_int64 size = GET_MODE_SIZE (GET_MODE (mem));
    3672                 :     2973099 :         rtx r1 = XEXP (x, 0);
    3673                 :     2973099 :         rtx c = gen_int_mode (size, GET_MODE (r1));
    3674                 :     2973099 :         return fn (mem, x, r1, r1, c, data);
    3675                 :             :       }
    3676                 :             : 
    3677                 :    17412358 :     case PRE_DEC:
    3678                 :    17412358 :     case POST_DEC:
    3679                 :    17412358 :       {
    3680                 :    34824716 :         poly_int64 size = GET_MODE_SIZE (GET_MODE (mem));
    3681                 :    17412358 :         rtx r1 = XEXP (x, 0);
    3682                 :    17412358 :         rtx c = gen_int_mode (-size, GET_MODE (r1));
    3683                 :    17412358 :         return fn (mem, x, r1, r1, c, data);
    3684                 :             :       }
    3685                 :             : 
    3686                 :      385360 :     case PRE_MODIFY:
    3687                 :      385360 :     case POST_MODIFY:
    3688                 :      385360 :       {
    3689                 :      385360 :         rtx r1 = XEXP (x, 0);
    3690                 :      385360 :         rtx add = XEXP (x, 1);
    3691                 :      385360 :         return fn (mem, x, r1, add, NULL, data);
    3692                 :             :       }
    3693                 :             : 
    3694                 :           0 :     default:
    3695                 :           0 :       gcc_unreachable ();
    3696                 :             :     }
    3697                 :             : }
    3698                 :             : 
    3699                 :             : /* Traverse *LOC looking for MEMs that have autoinc addresses.
    3700                 :             :    For each such autoinc operation found, call FN, passing it
    3701                 :             :    the innermost enclosing MEM, the operation itself, the RTX modified
    3702                 :             :    by the operation, two RTXs (the second may be NULL) that, once
    3703                 :             :    added, represent the value to be held by the modified RTX
    3704                 :             :    afterwards, and DATA.  FN is to return 0 to continue the
    3705                 :             :    traversal or any other value to have it returned to the caller of
    3706                 :             :    for_each_inc_dec.  */
    3707                 :             : 
    3708                 :             : int
    3709                 :  1011738680 : for_each_inc_dec (rtx x,
    3710                 :             :                   for_each_inc_dec_fn fn,
    3711                 :             :                   void *data)
    3712                 :             : {
    3713                 :  1011738680 :   subrtx_var_iterator::array_type array;
    3714                 :  5363344775 :   FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST)
    3715                 :             :     {
    3716                 :  4351606095 :       rtx mem = *iter;
    3717                 :  4351606095 :       if (mem
    3718                 :  4351606095 :           && MEM_P (mem)
    3719                 :   250491696 :           && GET_RTX_CLASS (GET_CODE (XEXP (mem, 0))) == RTX_AUTOINC)
    3720                 :             :         {
    3721                 :    20770817 :           int res = for_each_inc_dec_find_inc_dec (mem, fn, data);
    3722                 :    20770817 :           if (res != 0)
    3723                 :           0 :             return res;
    3724                 :    20770817 :           iter.skip_subrtxes ();
    3725                 :             :         }
    3726                 :             :     }
    3727                 :  1011738680 :   return 0;
    3728                 :  1011738680 : }
    3729                 :             : 
    3730                 :             : 
    3731                 :             : /* Searches X for any reference to REGNO, returning the rtx of the
    3732                 :             :    reference found if any.  Otherwise, returns NULL_RTX.  */
    3733                 :             : 
    3734                 :             : rtx
    3735                 :           0 : regno_use_in (unsigned int regno, rtx x)
    3736                 :             : {
    3737                 :           0 :   const char *fmt;
    3738                 :           0 :   int i, j;
    3739                 :           0 :   rtx tem;
    3740                 :             : 
    3741                 :           0 :   if (REG_P (x) && REGNO (x) == regno)
    3742                 :             :     return x;
    3743                 :             : 
    3744                 :           0 :   fmt = GET_RTX_FORMAT (GET_CODE (x));
    3745                 :           0 :   for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
    3746                 :             :     {
    3747                 :           0 :       if (fmt[i] == 'e')
    3748                 :             :         {
    3749                 :           0 :           if ((tem = regno_use_in (regno, XEXP (x, i))))
    3750                 :             :             return tem;
    3751                 :             :         }
    3752                 :           0 :       else if (fmt[i] == 'E')
    3753                 :           0 :         for (j = XVECLEN (x, i) - 1; j >= 0; j--)
    3754                 :           0 :           if ((tem = regno_use_in (regno , XVECEXP (x, i, j))))
    3755                 :             :             return tem;
    3756                 :             :     }
    3757                 :             : 
    3758                 :             :   return NULL_RTX;
    3759                 :             : }
    3760                 :             : 
    3761                 :             : /* Return a value indicating whether OP, an operand of a commutative
    3762                 :             :    operation, is preferred as the first or second operand.  The more
    3763                 :             :    positive the value, the stronger the preference for being the first
    3764                 :             :    operand.  */
    3765                 :             : 
    3766                 :             : int
    3767                 :  2135111262 : commutative_operand_precedence (rtx op)
    3768                 :             : {
    3769                 :  2135111262 :   enum rtx_code code = GET_CODE (op);
    3770                 :             : 
    3771                 :             :   /* Constants always become the second operand.  Prefer "nice" constants.  */
    3772                 :  2135111262 :   if (code == CONST_INT)
    3773                 :             :     return -10;
    3774                 :             :   if (code == CONST_WIDE_INT)
    3775                 :             :     return -9;
    3776                 :             :   if (code == CONST_POLY_INT)
    3777                 :             :     return -8;
    3778                 :             :   if (code == CONST_DOUBLE)
    3779                 :             :     return -8;
    3780                 :             :   if (code == CONST_FIXED)
    3781                 :             :     return -8;
    3782                 :  1261111251 :   op = avoid_constant_pool_reference (op);
    3783                 :  1261111251 :   code = GET_CODE (op);
    3784                 :             : 
    3785                 :  1261111251 :   switch (GET_RTX_CLASS (code))
    3786                 :             :     {
    3787                 :    25059387 :     case RTX_CONST_OBJ:
    3788                 :    25059387 :       if (code == CONST_INT)
    3789                 :             :         return -7;
    3790                 :             :       if (code == CONST_WIDE_INT)
    3791                 :             :         return -6;
    3792                 :             :       if (code == CONST_POLY_INT)
    3793                 :             :         return -5;
    3794                 :             :       if (code == CONST_DOUBLE)
    3795                 :             :         return -5;
    3796                 :             :       if (code == CONST_FIXED)
    3797                 :             :         return -5;
    3798                 :             :       return -4;
    3799                 :             : 
    3800                 :    45147605 :     case RTX_EXTRA:
    3801                 :             :       /* SUBREGs of objects should come second.  */
    3802                 :    45147605 :       if (code == SUBREG && OBJECT_P (SUBREG_REG (op)))
    3803                 :             :         return -3;
    3804                 :             :       return 0;
    3805                 :             : 
    3806                 :   926859587 :     case RTX_OBJ:
    3807                 :             :       /* Complex expressions should be the first, so decrease priority
    3808                 :             :          of objects.  Prefer pointer objects over non pointer objects.  */
    3809                 :   839110199 :       if ((REG_P (op) && REG_POINTER (op))
    3810                 :  1395848407 :           || (MEM_P (op) && MEM_POINTER (op)))
    3811                 :   386882908 :         return -1;
    3812                 :             :       return -2;
    3813                 :             : 
    3814                 :             :     case RTX_COMM_ARITH:
    3815                 :             :       /* Prefer operands that are themselves commutative to be first.
    3816                 :             :          This helps to make things linear.  In particular,
    3817                 :             :          (and (and (reg) (reg)) (not (reg))) is canonical.  */
    3818                 :             :       return 4;
    3819                 :             : 
    3820                 :    81872238 :     case RTX_BIN_ARITH:
    3821                 :             :       /* If only one operand is a binary expression, it will be the first
    3822                 :             :          operand.  In particular,  (plus (minus (reg) (reg)) (neg (reg)))
    3823                 :             :          is canonical, although it will usually be further simplified.  */
    3824                 :    81872238 :       return 2;
    3825                 :             : 
    3826                 :    24215396 :     case RTX_UNARY:
    3827                 :             :       /* Then prefer NEG and NOT.  */
    3828                 :    24215396 :       if (code == NEG || code == NOT)
    3829                 :             :         return 1;
    3830                 :             :       /* FALLTHRU */
    3831                 :             : 
    3832                 :             :     default:
    3833                 :             :       return 0;
    3834                 :             :     }
    3835                 :             : }
    3836                 :             : 
    3837                 :             : /* Return true iff it is necessary to swap operands of commutative operation
    3838                 :             :    in order to canonicalize expression.  */
    3839                 :             : 
    3840                 :             : bool
    3841                 :   948150158 : swap_commutative_operands_p (rtx x, rtx y)
    3842                 :             : {
    3843                 :   948150158 :   return (commutative_operand_precedence (x)
    3844                 :   948150158 :           < commutative_operand_precedence (y));
    3845                 :             : }
    3846                 :             : 
    3847                 :             : /* Return true if X is an autoincrement side effect and the register is
    3848                 :             :    not the stack pointer.  */
    3849                 :             : bool
    3850                 :           0 : auto_inc_p (const_rtx x)
    3851                 :             : {
    3852                 :           0 :   switch (GET_CODE (x))
    3853                 :             :     {
    3854                 :           0 :     case PRE_INC:
    3855                 :           0 :     case POST_INC:
    3856                 :           0 :     case PRE_DEC:
    3857                 :           0 :     case POST_DEC:
    3858                 :           0 :     case PRE_MODIFY:
    3859                 :           0 :     case POST_MODIFY:
    3860                 :             :       /* There are no REG_INC notes for SP.  */
    3861                 :           0 :       if (XEXP (x, 0) != stack_pointer_rtx)
    3862                 :           0 :         return true;
    3863                 :             :     default:
    3864                 :             :       break;
    3865                 :             :     }
    3866                 :             :   return false;
    3867                 :             : }
    3868                 :             : 
    3869                 :             : /* Return true if IN contains a piece of rtl that has the address LOC.  */
    3870                 :             : bool
    3871                 :     1098417 : loc_mentioned_in_p (rtx *loc, const_rtx in)
    3872                 :             : {
    3873                 :     1098417 :   enum rtx_code code;
    3874                 :     1098417 :   const char *fmt;
    3875                 :     1098417 :   int i, j;
    3876                 :             : 
    3877                 :     1098417 :   if (!in)
    3878                 :             :     return false;
    3879                 :             : 
    3880                 :     1098417 :   code = GET_CODE (in);
    3881                 :     1098417 :   fmt = GET_RTX_FORMAT (code);
    3882                 :     2193306 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    3883                 :             :     {
    3884                 :     1743651 :       if (fmt[i] == 'e')
    3885                 :             :         {
    3886                 :     1079071 :           if (loc == &XEXP (in, i) || loc_mentioned_in_p (loc, XEXP (in, i)))
    3887                 :      647978 :             return true;
    3888                 :             :         }
    3889                 :      664580 :       else if (fmt[i] == 'E')
    3890                 :       25871 :         for (j = XVECLEN (in, i) - 1; j >= 0; j--)
    3891                 :       17599 :           if (loc == &XVECEXP (in, i, j)
    3892                 :       17599 :               || loc_mentioned_in_p (loc, XVECEXP (in, i, j)))
    3893                 :         784 :             return true;
    3894                 :             :     }
    3895                 :             :   return false;
    3896                 :             : }
    3897                 :             : 
    3898                 :             : /* Reinterpret a subreg as a bit extraction from an integer and return
    3899                 :             :    the position of the least significant bit of the extracted value.
    3900                 :             :    In other words, if the extraction were performed as a shift right
    3901                 :             :    and mask, return the number of bits to shift right.
    3902                 :             : 
    3903                 :             :    The outer value of the subreg has OUTER_BYTES bytes and starts at
    3904                 :             :    byte offset SUBREG_BYTE within an inner value of INNER_BYTES bytes.  */
    3905                 :             : 
    3906                 :             : poly_uint64
    3907                 :    47831459 : subreg_size_lsb (poly_uint64 outer_bytes,
    3908                 :             :                  poly_uint64 inner_bytes,
    3909                 :             :                  poly_uint64 subreg_byte)
    3910                 :             : {
    3911                 :    47831459 :   poly_uint64 subreg_end, trailing_bytes, byte_pos;
    3912                 :             : 
    3913                 :             :   /* A paradoxical subreg begins at bit position 0.  */
    3914                 :    47831459 :   gcc_checking_assert (ordered_p (outer_bytes, inner_bytes));
    3915                 :    47831459 :   if (maybe_gt (outer_bytes, inner_bytes))
    3916                 :             :     {
    3917                 :       40724 :       gcc_checking_assert (known_eq (subreg_byte, 0U));
    3918                 :       40724 :       return 0;
    3919                 :             :     }
    3920                 :             : 
    3921                 :    47790735 :   subreg_end = subreg_byte + outer_bytes;
    3922                 :    47790735 :   trailing_bytes = inner_bytes - subreg_end;
    3923                 :    47790735 :   if (WORDS_BIG_ENDIAN && BYTES_BIG_ENDIAN)
    3924                 :             :     byte_pos = trailing_bytes;
    3925                 :    47790735 :   else if (!WORDS_BIG_ENDIAN && !BYTES_BIG_ENDIAN)
    3926                 :    47790735 :     byte_pos = subreg_byte;
    3927                 :             :   else
    3928                 :             :     {
    3929                 :             :       /* When bytes and words have opposite endianness, we must be able
    3930                 :             :          to split offsets into words and bytes at compile time.  */
    3931                 :             :       poly_uint64 leading_word_part
    3932                 :             :         = force_align_down (subreg_byte, UNITS_PER_WORD);
    3933                 :             :       poly_uint64 trailing_word_part
    3934                 :             :         = force_align_down (trailing_bytes, UNITS_PER_WORD);
    3935                 :             :       /* If the subreg crosses a word boundary ensure that
    3936                 :             :          it also begins and ends on a word boundary.  */
    3937                 :             :       gcc_assert (known_le (subreg_end - leading_word_part,
    3938                 :             :                             (unsigned int) UNITS_PER_WORD)
    3939                 :             :                   || (known_eq (leading_word_part, subreg_byte)
    3940                 :             :                       && known_eq (trailing_word_part, trailing_bytes)));
    3941                 :             :       if (WORDS_BIG_ENDIAN)
    3942                 :             :         byte_pos = trailing_word_part + (subreg_byte - leading_word_part);
    3943                 :             :       else
    3944                 :             :         byte_pos = leading_word_part + (trailing_bytes - trailing_word_part);
    3945                 :             :     }
    3946                 :             : 
    3947                 :    47790735 :   return byte_pos * BITS_PER_UNIT;
    3948                 :             : }
    3949                 :             : 
    3950                 :             : /* Given a subreg X, return the bit offset where the subreg begins
    3951                 :             :    (counting from the least significant bit of the reg).  */
    3952                 :             : 
    3953                 :             : poly_uint64
    3954                 :     3006236 : subreg_lsb (const_rtx x)
    3955                 :             : {
    3956                 :     6012472 :   return subreg_lsb_1 (GET_MODE (x), GET_MODE (SUBREG_REG (x)),
    3957                 :     3006236 :                        SUBREG_BYTE (x));
    3958                 :             : }
    3959                 :             : 
    3960                 :             : /* Return the subreg byte offset for a subreg whose outer value has
    3961                 :             :    OUTER_BYTES bytes, whose inner value has INNER_BYTES bytes, and where
    3962                 :             :    there are LSB_SHIFT *bits* between the lsb of the outer value and the
    3963                 :             :    lsb of the inner value.  This is the inverse of the calculation
    3964                 :             :    performed by subreg_lsb_1 (which converts byte offsets to bit shifts).  */
    3965                 :             : 
    3966                 :             : poly_uint64
    3967                 :    42344315 : subreg_size_offset_from_lsb (poly_uint64 outer_bytes, poly_uint64 inner_bytes,
    3968                 :             :                              poly_uint64 lsb_shift)
    3969                 :             : {
    3970                 :             :   /* A paradoxical subreg begins at bit position 0.  */
    3971                 :    42344315 :   gcc_checking_assert (ordered_p (outer_bytes, inner_bytes));
    3972                 :    42344315 :   if (maybe_gt (outer_bytes, inner_bytes))
    3973                 :             :     {
    3974                 :           0 :       gcc_checking_assert (known_eq (lsb_shift, 0U));
    3975                 :           0 :       return 0;
    3976                 :             :     }
    3977                 :             : 
    3978                 :    42344315 :   poly_uint64 lower_bytes = exact_div (lsb_shift, BITS_PER_UNIT);
    3979                 :    42344315 :   poly_uint64 upper_bytes = inner_bytes - (lower_bytes + outer_bytes);
    3980                 :    42344315 :   if (WORDS_BIG_ENDIAN && BYTES_BIG_ENDIAN)
    3981                 :             :     return upper_bytes;
    3982                 :    42344315 :   else if (!WORDS_BIG_ENDIAN && !BYTES_BIG_ENDIAN)
    3983                 :    42344315 :     return lower_bytes;
    3984                 :             :   else
    3985                 :             :     {
    3986                 :             :       /* When bytes and words have opposite endianness, we must be able
    3987                 :             :          to split offsets into words and bytes at compile time.  */
    3988                 :             :       poly_uint64 lower_word_part = force_align_down (lower_bytes,
    3989                 :             :                                                       UNITS_PER_WORD);
    3990                 :             :       poly_uint64 upper_word_part = force_align_down (upper_bytes,
    3991                 :             :                                                       UNITS_PER_WORD);
    3992                 :             :       if (WORDS_BIG_ENDIAN)
    3993                 :             :         return upper_word_part + (lower_bytes - lower_word_part);
    3994                 :             :       else
    3995                 :             :         return lower_word_part + (upper_bytes - upper_word_part);
    3996                 :             :     }
    3997                 :             : }
    3998                 :             : 
    3999                 :             : /* Fill in information about a subreg of a hard register.
    4000                 :             :    xregno - A regno of an inner hard subreg_reg (or what will become one).
    4001                 :             :    xmode  - The mode of xregno.
    4002                 :             :    offset - The byte offset.
    4003                 :             :    ymode  - The mode of a top level SUBREG (or what may become one).
    4004                 :             :    info   - Pointer to structure to fill in.
    4005                 :             : 
    4006                 :             :    Rather than considering one particular inner register (and thus one
    4007                 :             :    particular "outer" register) in isolation, this function really uses
    4008                 :             :    XREGNO as a model for a sequence of isomorphic hard registers.  Thus the
    4009                 :             :    function does not check whether adding INFO->offset to XREGNO gives
    4010                 :             :    a valid hard register; even if INFO->offset + XREGNO is out of range,
    4011                 :             :    there might be another register of the same type that is in range.
    4012                 :             :    Likewise it doesn't check whether targetm.hard_regno_mode_ok accepts
    4013                 :             :    the new register, since that can depend on things like whether the final
    4014                 :             :    register number is even or odd.  Callers that want to check whether
    4015                 :             :    this particular subreg can be replaced by a simple (reg ...) should
    4016                 :             :    use simplify_subreg_regno.  */
    4017                 :             : 
    4018                 :             : void
    4019                 :    33804914 : subreg_get_info (unsigned int xregno, machine_mode xmode,
    4020                 :             :                  poly_uint64 offset, machine_mode ymode,
    4021                 :             :                  struct subreg_info *info)
    4022                 :             : {
    4023                 :    33804914 :   unsigned int nregs_xmode, nregs_ymode;
    4024                 :             : 
    4025                 :    33804914 :   gcc_assert (xregno < FIRST_PSEUDO_REGISTER);
    4026                 :             : 
    4027                 :    67609828 :   poly_uint64 xsize = GET_MODE_SIZE (xmode);
    4028                 :    67609828 :   poly_uint64 ysize = GET_MODE_SIZE (ymode);
    4029                 :             : 
    4030                 :    33804914 :   bool rknown = false;
    4031                 :             : 
    4032                 :             :   /* If the register representation of a non-scalar mode has holes in it,
    4033                 :             :      we expect the scalar units to be concatenated together, with the holes
    4034                 :             :      distributed evenly among the scalar units.  Each scalar unit must occupy
    4035                 :             :      at least one register.  */
    4036                 :    33804914 :   if (HARD_REGNO_NREGS_HAS_PADDING (xregno, xmode))
    4037                 :             :     {
    4038                 :             :       /* As a consequence, we must be dealing with a constant number of
    4039                 :             :          scalars, and thus a constant offset and number of units.  */
    4040                 :           0 :       HOST_WIDE_INT coffset = offset.to_constant ();
    4041                 :           0 :       HOST_WIDE_INT cysize = ysize.to_constant ();
    4042                 :           0 :       nregs_xmode = HARD_REGNO_NREGS_WITH_PADDING (xregno, xmode);
    4043                 :           0 :       unsigned int nunits = GET_MODE_NUNITS (xmode).to_constant ();
    4044                 :           0 :       scalar_mode xmode_unit = GET_MODE_INNER (xmode);
    4045                 :           0 :       gcc_assert (HARD_REGNO_NREGS_HAS_PADDING (xregno, xmode_unit));
    4046                 :           0 :       gcc_assert (nregs_xmode
    4047                 :             :                   == (nunits
    4048                 :             :                       * HARD_REGNO_NREGS_WITH_PADDING (xregno, xmode_unit)));
    4049                 :           0 :       gcc_assert (hard_regno_nregs (xregno, xmode)
    4050                 :             :                   == hard_regno_nregs (xregno, xmode_unit) * nunits);
    4051                 :             : 
    4052                 :             :       /* You can only ask for a SUBREG of a value with holes in the middle
    4053                 :             :          if you don't cross the holes.  (Such a SUBREG should be done by
    4054                 :             :          picking a different register class, or doing it in memory if
    4055                 :             :          necessary.)  An example of a value with holes is XCmode on 32-bit
    4056                 :             :          x86 with -m128bit-long-double; it's represented in 6 32-bit registers,
    4057                 :             :          3 for each part, but in memory it's two 128-bit parts.
    4058                 :             :          Padding is assumed to be at the end (not necessarily the 'high part')
    4059                 :             :          of each unit.  */
    4060                 :           0 :       if ((coffset / GET_MODE_SIZE (xmode_unit) + 1 < nunits)
    4061                 :           0 :           && (coffset / GET_MODE_SIZE (xmode_unit)
    4062                 :           0 :               != ((coffset + cysize - 1) / GET_MODE_SIZE (xmode_unit))))
    4063                 :             :         {
    4064                 :           0 :           info->representable_p = false;
    4065                 :           0 :           rknown = true;
    4066                 :             :         }
    4067                 :             :     }
    4068                 :             :   else
    4069                 :    33804914 :     nregs_xmode = hard_regno_nregs (xregno, xmode);
    4070                 :             : 
    4071                 :    33804914 :   nregs_ymode = hard_regno_nregs (xregno, ymode);
    4072                 :             : 
    4073                 :             :   /* Subreg sizes must be ordered, so that we can tell whether they are
    4074                 :             :      partial, paradoxical or complete.  */
    4075                 :    33804914 :   gcc_checking_assert (ordered_p (xsize, ysize));
    4076                 :             : 
    4077                 :             :   /* Paradoxical subregs are otherwise valid.  */
    4078                 :    33804914 :   if (!rknown && known_eq (offset, 0U) && maybe_gt (ysize, xsize))
    4079                 :             :     {
    4080                 :    13610963 :       info->representable_p = true;
    4081                 :             :       /* If this is a big endian paradoxical subreg, which uses more
    4082                 :             :          actual hard registers than the original register, we must
    4083                 :             :          return a negative offset so that we find the proper highpart
    4084                 :             :          of the register.
    4085                 :             : 
    4086                 :             :          We assume that the ordering of registers within a multi-register
    4087                 :             :          value has a consistent endianness: if bytes and register words
    4088                 :             :          have different endianness, the hard registers that make up a
    4089                 :             :          multi-register value must be at least word-sized.  */
    4090                 :    13610963 :       if (REG_WORDS_BIG_ENDIAN)
    4091                 :             :         info->offset = (int) nregs_xmode - (int) nregs_ymode;
    4092                 :             :       else
    4093                 :    13610963 :         info->offset = 0;
    4094                 :    13610963 :       info->nregs = nregs_ymode;
    4095                 :    13610963 :       return;
    4096                 :             :     }
    4097                 :             : 
    4098                 :             :   /* If registers store different numbers of bits in the different
    4099                 :             :      modes, we cannot generally form this subreg.  */
    4100                 :    20193951 :   poly_uint64 regsize_xmode, regsize_ymode;
    4101                 :    17333151 :   if (!HARD_REGNO_NREGS_HAS_PADDING (xregno, xmode)
    4102                 :           0 :       && !HARD_REGNO_NREGS_HAS_PADDING (xregno, ymode)
    4103                 :    20193951 :       && multiple_p (xsize, nregs_xmode, &regsize_xmode)
    4104                 :    20193951 :       && multiple_p (ysize, nregs_ymode, &regsize_ymode))
    4105                 :             :     {
    4106                 :    20193951 :       if (!rknown
    4107                 :    20193951 :           && ((nregs_ymode > 1 && maybe_gt (regsize_xmode, regsize_ymode))
    4108                 :    20193939 :               || (nregs_xmode > 1 && maybe_gt (regsize_ymode, regsize_xmode))))
    4109                 :             :         {
    4110                 :         118 :           info->representable_p = false;
    4111                 :         118 :           if (!can_div_away_from_zero_p (ysize, regsize_xmode, &info->nregs)
    4112                 :         118 :               || !can_div_trunc_p (offset, regsize_xmode, &info->offset))
    4113                 :             :             /* Checked by validate_subreg.  We must know at compile time
    4114                 :             :                which inner registers are being accessed.  */
    4115                 :             :             gcc_unreachable ();
    4116                 :    33303119 :           return;
    4117                 :             :         }
    4118                 :             :       /* It's not valid to extract a subreg of mode YMODE at OFFSET that
    4119                 :             :          would go outside of XMODE.  */
    4120                 :    20193833 :       if (!rknown && maybe_gt (ysize + offset, xsize))
    4121                 :             :         {
    4122                 :           0 :           info->representable_p = false;
    4123                 :           0 :           info->nregs = nregs_ymode;
    4124                 :           0 :           if (!can_div_trunc_p (offset, regsize_xmode, &info->offset))
    4125                 :             :             /* Checked by validate_subreg.  We must know at compile time
    4126                 :             :                which inner registers are being accessed.  */
    4127                 :             :             gcc_unreachable ();
    4128                 :           0 :           return;
    4129                 :             :         }
    4130                 :             :       /* Quick exit for the simple and common case of extracting whole
    4131                 :             :          subregisters from a multiregister value.  */
    4132                 :             :       /* ??? It would be better to integrate this into the code below,
    4133                 :             :          if we can generalize the concept enough and figure out how
    4134                 :             :          odd-sized modes can coexist with the other weird cases we support.  */
    4135                 :    20193833 :       HOST_WIDE_INT count;
    4136                 :    20193833 :       if (!rknown
    4137                 :             :           && WORDS_BIG_ENDIAN == REG_WORDS_BIG_ENDIAN
    4138                 :    20193833 :           && known_eq (regsize_xmode, regsize_ymode)
    4139                 :    20193833 :           && constant_multiple_p (offset, regsize_ymode, &count))
    4140                 :             :         {
    4141                 :    12869667 :           info->representable_p = true;
    4142                 :    12869667 :           info->nregs = nregs_ymode;
    4143                 :    12869667 :           info->offset = count;
    4144                 :    12869667 :           gcc_assert (info->offset + info->nregs <= (int) nregs_xmode);
    4145                 :             :           return;
    4146                 :             :         }
    4147                 :             :     }
    4148                 :             : 
    4149                 :             :   /* Lowpart subregs are otherwise valid.  */
    4150                 :     7324166 :   if (!rknown && known_eq (offset, subreg_lowpart_offset (ymode, xmode)))
    4151                 :             :     {
    4152                 :     6822371 :       info->representable_p = true;
    4153                 :     6822371 :       rknown = true;
    4154                 :             : 
    4155                 :     6822371 :       if (known_eq (offset, 0U) || nregs_xmode == nregs_ymode)
    4156                 :             :         {
    4157                 :     6822371 :           info->offset = 0;
    4158                 :     6822371 :           info->nregs = nregs_ymode;
    4159                 :     6822371 :           return;
    4160                 :             :         }
    4161                 :             :     }
    4162                 :             : 
    4163                 :             :   /* Set NUM_BLOCKS to the number of independently-representable YMODE
    4164                 :             :      values there are in (reg:XMODE XREGNO).  We can view the register
    4165                 :             :      as consisting of this number of independent "blocks", where each
    4166                 :             :      block occupies NREGS_YMODE registers and contains exactly one
    4167                 :             :      representable YMODE value.  */
    4168                 :      501795 :   gcc_assert ((nregs_xmode % nregs_ymode) == 0);
    4169                 :      501795 :   unsigned int num_blocks = nregs_xmode / nregs_ymode;
    4170                 :             : 
    4171                 :             :   /* Calculate the number of bytes in each block.  This must always
    4172                 :             :      be exact, otherwise we don't know how to verify the constraint.
    4173                 :             :      These conditions may be relaxed but subreg_regno_offset would
    4174                 :             :      need to be redesigned.  */
    4175                 :      501795 :   poly_uint64 bytes_per_block = exact_div (xsize, num_blocks);
    4176                 :             : 
    4177                 :             :   /* Get the number of the first block that contains the subreg and the byte
    4178                 :             :      offset of the subreg from the start of that block.  */
    4179                 :      501795 :   unsigned int block_number;
    4180                 :      501795 :   poly_uint64 subblock_offset;
    4181                 :      501795 :   if (!can_div_trunc_p (offset, bytes_per_block, &block_number,
    4182                 :             :                         &subblock_offset))
    4183                 :             :     /* Checked by validate_subreg.  We must know at compile time which
    4184                 :             :        inner registers are being accessed.  */
    4185                 :             :     gcc_unreachable ();
    4186                 :             : 
    4187                 :      501795 :   if (!rknown)
    4188                 :             :     {
    4189                 :             :       /* Only the lowpart of each block is representable.  */
    4190                 :      501795 :       info->representable_p
    4191                 :      501795 :         = known_eq (subblock_offset,
    4192                 :             :                     subreg_size_lowpart_offset (ysize, bytes_per_block));
    4193                 :      501795 :       rknown = true;
    4194                 :             :     }
    4195                 :             : 
    4196                 :             :   /* We assume that the ordering of registers within a multi-register
    4197                 :             :      value has a consistent endianness: if bytes and register words
    4198                 :             :      have different endianness, the hard registers that make up a
    4199                 :             :      multi-register value must be at least word-sized.  */
    4200                 :      501795 :   if (WORDS_BIG_ENDIAN != REG_WORDS_BIG_ENDIAN)
    4201                 :             :     /* The block number we calculated above followed memory endianness.
    4202                 :             :        Convert it to register endianness by counting back from the end.
    4203                 :             :        (Note that, because of the assumption above, each block must be
    4204                 :             :        at least word-sized.)  */
    4205                 :             :     info->offset = (num_blocks - block_number - 1) * nregs_ymode;
    4206                 :             :   else
    4207                 :      501795 :     info->offset = block_number * nregs_ymode;
    4208                 :      501795 :   info->nregs = nregs_ymode;
    4209                 :             : }
    4210                 :             : 
    4211                 :             : /* This function returns the regno offset of a subreg expression.
    4212                 :             :    xregno - A regno of an inner hard subreg_reg (or what will become one).
    4213                 :             :    xmode  - The mode of xregno.
    4214                 :             :    offset - The byte offset.
    4215                 :             :    ymode  - The mode of a top level SUBREG (or what may become one).
    4216                 :             :    RETURN - The regno offset which would be used.  */
    4217                 :             : unsigned int
    4218                 :     5368776 : subreg_regno_offset (unsigned int xregno, machine_mode xmode,
    4219                 :             :                      poly_uint64 offset, machine_mode ymode)
    4220                 :             : {
    4221                 :     5368776 :   struct subreg_info info;
    4222                 :     5368776 :   subreg_get_info (xregno, xmode, offset, ymode, &info);
    4223                 :     5368776 :   return info.offset;
    4224                 :             : }
    4225                 :             : 
    4226                 :             : /* This function returns true when the offset is representable via
    4227                 :             :    subreg_offset in the given regno.
    4228                 :             :    xregno - A regno of an inner hard subreg_reg (or what will become one).
    4229                 :             :    xmode  - The mode of xregno.
    4230                 :             :    offset - The byte offset.
    4231                 :             :    ymode  - The mode of a top level SUBREG (or what may become one).
    4232                 :             :    RETURN - Whether the offset is representable.  */
    4233                 :             : bool
    4234                 :      344043 : subreg_offset_representable_p (unsigned int xregno, machine_mode xmode,
    4235                 :             :                                poly_uint64 offset, machine_mode ymode)
    4236                 :             : {
    4237                 :      344043 :   struct subreg_info info;
    4238                 :      344043 :   subreg_get_info (xregno, xmode, offset, ymode, &info);
    4239                 :      344043 :   return info.representable_p;
    4240                 :             : }
    4241                 :             : 
    4242                 :             : /* Return the number of a YMODE register to which
    4243                 :             : 
    4244                 :             :        (subreg:YMODE (reg:XMODE XREGNO) OFFSET)
    4245                 :             : 
    4246                 :             :    can be simplified.  Return -1 if the subreg can't be simplified.
    4247                 :             : 
    4248                 :             :    XREGNO is a hard register number.  */
    4249                 :             : 
    4250                 :             : int
    4251                 :    28847525 : simplify_subreg_regno (unsigned int xregno, machine_mode xmode,
    4252                 :             :                        poly_uint64 offset, machine_mode ymode)
    4253                 :             : {
    4254                 :    28847525 :   struct subreg_info info;
    4255                 :    28847525 :   unsigned int yregno;
    4256                 :             : 
    4257                 :             :   /* Give the backend a chance to disallow the mode change.  */
    4258                 :    28847525 :   if (GET_MODE_CLASS (xmode) != MODE_COMPLEX_INT
    4259                 :    28847525 :       && GET_MODE_CLASS (xmode) != MODE_COMPLEX_FLOAT
    4260                 :    28847525 :       && !REG_CAN_CHANGE_MODE_P (xregno, xmode, ymode))
    4261                 :             :     return -1;
    4262                 :             : 
    4263                 :             :   /* We shouldn't simplify stack-related registers.  */
    4264                 :    28197221 :   if ((!reload_completed || frame_pointer_needed)
    4265                 :    24641893 :       && xregno == FRAME_POINTER_REGNUM)
    4266                 :             :     return -1;
    4267                 :             : 
    4268                 :    28092457 :   if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
    4269                 :             :       && xregno == ARG_POINTER_REGNUM)
    4270                 :             :     return -1;
    4271                 :             : 
    4272                 :    27992034 :   if (xregno == STACK_POINTER_REGNUM
    4273                 :             :       /* We should convert hard stack register in LRA if it is
    4274                 :             :          possible.  */
    4275                 :      101936 :       && ! lra_in_progress)
    4276                 :             :     return -1;
    4277                 :             : 
    4278                 :             :   /* Try to get the register offset.  */
    4279                 :    27892264 :   subreg_get_info (xregno, xmode, offset, ymode, &info);
    4280                 :    27892264 :   if (!info.representable_p)
    4281                 :             :     return -1;
    4282                 :             : 
    4283                 :             :   /* Make sure that the offsetted register value is in range.  */
    4284                 :    27651554 :   yregno = xregno + info.offset;
    4285                 :    27651554 :   if (!HARD_REGISTER_NUM_P (yregno))
    4286                 :             :     return -1;
    4287                 :             : 
    4288                 :             :   /* See whether (reg:YMODE YREGNO) is valid.
    4289                 :             : 
    4290                 :             :      ??? We allow invalid registers if (reg:XMODE XREGNO) is also invalid.
    4291                 :             :      This is a kludge to work around how complex FP arguments are passed
    4292                 :             :      on IA-64 and should be fixed.  See PR target/49226.  */
    4293                 :    27639687 :   if (!targetm.hard_regno_mode_ok (yregno, ymode)
    4294                 :    27639687 :       && targetm.hard_regno_mode_ok (xregno, xmode))
    4295                 :             :     return -1;
    4296                 :             : 
    4297                 :    27436278 :   return (int) yregno;
    4298                 :             : }
    4299                 :             : 
    4300                 :             : /* A wrapper around simplify_subreg_regno that uses subreg_lowpart_offset
    4301                 :             :    (xmode, ymode) as the offset.  */
    4302                 :             : 
    4303                 :             : int
    4304                 :           0 : lowpart_subreg_regno (unsigned int regno, machine_mode xmode,
    4305                 :             :                       machine_mode ymode)
    4306                 :             : {
    4307                 :           0 :   poly_uint64 offset = subreg_lowpart_offset (xmode, ymode);
    4308                 :           0 :   return simplify_subreg_regno (regno, xmode, offset, ymode);
    4309                 :             : }
    4310                 :             : 
    4311                 :             : /* Return the final regno that a subreg expression refers to.  */
    4312                 :             : unsigned int
    4313                 :       15125 : subreg_regno (const_rtx x)
    4314                 :             : {
    4315                 :       15125 :   unsigned int ret;
    4316                 :       15125 :   rtx subreg = SUBREG_REG (x);
    4317                 :       15125 :   int regno = REGNO (subreg);
    4318                 :             : 
    4319                 :       30250 :   ret = regno + subreg_regno_offset (regno,
    4320                 :       15125 :                                      GET_MODE (subreg),
    4321                 :       15125 :                                      SUBREG_BYTE (x),
    4322                 :       15125 :                                      GET_MODE (x));
    4323                 :       15125 :   return ret;
    4324                 :             : 
    4325                 :             : }
    4326                 :             : 
    4327                 :             : /* Return the number of registers that a subreg expression refers
    4328                 :             :    to.  */
    4329                 :             : unsigned int
    4330                 :      193815 : subreg_nregs (const_rtx x)
    4331                 :             : {
    4332                 :      193815 :   return subreg_nregs_with_regno (REGNO (SUBREG_REG (x)), x);
    4333                 :             : }
    4334                 :             : 
    4335                 :             : /* Return the number of registers that a subreg REG with REGNO
    4336                 :             :    expression refers to.  This is a copy of the rtlanal.cc:subreg_nregs
    4337                 :             :    changed so that the regno can be passed in. */
    4338                 :             : 
    4339                 :             : unsigned int
    4340                 :      193815 : subreg_nregs_with_regno (unsigned int regno, const_rtx x)
    4341                 :             : {
    4342                 :      193815 :   struct subreg_info info;
    4343                 :      193815 :   rtx subreg = SUBREG_REG (x);
    4344                 :             : 
    4345                 :      193815 :   subreg_get_info (regno, GET_MODE (subreg), SUBREG_BYTE (x), GET_MODE (x),
    4346                 :             :                    &info);
    4347                 :      193815 :   return info.nregs;
    4348                 :             : }
    4349                 :             : 
    4350                 :             : struct parms_set_data
    4351                 :             : {
    4352                 :             :   int nregs;
    4353                 :             :   HARD_REG_SET regs;
    4354                 :             : };
    4355                 :             : 
    4356                 :             : /* Helper function for noticing stores to parameter registers.  */
    4357                 :             : static void
    4358                 :       64085 : parms_set (rtx x, const_rtx pat ATTRIBUTE_UNUSED, void *data)
    4359                 :             : {
    4360                 :       64085 :   struct parms_set_data *const d = (struct parms_set_data *) data;
    4361                 :       64083 :   if (REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER
    4362                 :      128167 :       && TEST_HARD_REG_BIT (d->regs, REGNO (x)))
    4363                 :             :     {
    4364                 :       63755 :       CLEAR_HARD_REG_BIT (d->regs, REGNO (x));
    4365                 :       63755 :       d->nregs--;
    4366                 :             :     }
    4367                 :       64085 : }
    4368                 :             : 
    4369                 :             : /* Look backward for first parameter to be loaded.
    4370                 :             :    Note that loads of all parameters will not necessarily be
    4371                 :             :    found if CSE has eliminated some of them (e.g., an argument
    4372                 :             :    to the outer function is passed down as a parameter).
    4373                 :             :    Do not skip BOUNDARY.  */
    4374                 :             : rtx_insn *
    4375                 :       38945 : find_first_parameter_load (rtx_insn *call_insn, rtx_insn *boundary)
    4376                 :             : {
    4377                 :       38945 :   struct parms_set_data parm;
    4378                 :       38945 :   rtx p;
    4379                 :       38945 :   rtx_insn *before, *first_set;
    4380                 :             : 
    4381                 :             :   /* Since different machines initialize their parameter registers
    4382                 :             :      in different orders, assume nothing.  Collect the set of all
    4383                 :             :      parameter registers.  */
    4384                 :       38945 :   CLEAR_HARD_REG_SET (parm.regs);
    4385                 :       38945 :   parm.nregs = 0;
    4386                 :      105208 :   for (p = CALL_INSN_FUNCTION_USAGE (call_insn); p; p = XEXP (p, 1))
    4387                 :       66263 :     if (GET_CODE (XEXP (p, 0)) == USE
    4388                 :       66101 :         && REG_P (XEXP (XEXP (p, 0), 0))
    4389                 :      132364 :         && !STATIC_CHAIN_REG_P (XEXP (XEXP (p, 0), 0)))
    4390                 :             :       {
    4391                 :       65848 :         gcc_assert (REGNO (XEXP (XEXP (p, 0), 0)) < FIRST_PSEUDO_REGISTER);
    4392                 :             : 
    4393                 :             :         /* We only care about registers which can hold function
    4394                 :             :            arguments.  */
    4395                 :       65848 :         if (!FUNCTION_ARG_REGNO_P (REGNO (XEXP (XEXP (p, 0), 0))))
    4396                 :        1733 :           continue;
    4397                 :             : 
    4398                 :       64115 :         SET_HARD_REG_BIT (parm.regs, REGNO (XEXP (XEXP (p, 0), 0)));
    4399                 :       64115 :         parm.nregs++;
    4400                 :             :       }
    4401                 :             :   before = call_insn;
    4402                 :             :   first_set = call_insn;
    4403                 :             : 
    4404                 :             :   /* Search backward for the first set of a register in this set.  */
    4405                 :      102700 :   while (parm.nregs && before != boundary)
    4406                 :             :     {
    4407                 :       64085 :       before = PREV_INSN (before);
    4408                 :             : 
    4409                 :             :       /* It is possible that some loads got CSEed from one call to
    4410                 :             :          another.  Stop in that case.  */
    4411                 :       64085 :       if (CALL_P (before))
    4412                 :             :         break;
    4413                 :             : 
    4414                 :             :       /* Our caller needs either ensure that we will find all sets
    4415                 :             :          (in case code has not been optimized yet), or take care
    4416                 :             :          for possible labels in a way by setting boundary to preceding
    4417                 :             :          CODE_LABEL.  */
    4418                 :       64085 :       if (LABEL_P (before))
    4419                 :             :         {
    4420                 :           0 :           gcc_assert (before == boundary);
    4421                 :             :           break;
    4422                 :             :         }
    4423                 :             : 
    4424                 :       64085 :       if (INSN_P (before))
    4425                 :             :         {
    4426                 :       64085 :           int nregs_old = parm.nregs;
    4427                 :       64085 :           note_stores (before, parms_set, &parm);
    4428                 :             :           /* If we found something that did not set a parameter reg,
    4429                 :             :              we're done.  Do not keep going, as that might result
    4430                 :             :              in hoisting an insn before the setting of a pseudo
    4431                 :             :              that is used by the hoisted insn. */
    4432                 :       64085 :           if (nregs_old != parm.nregs)
    4433                 :             :             first_set = before;
    4434                 :             :           else
    4435                 :             :             break;
    4436                 :             :         }
    4437                 :             :     }
    4438                 :       38945 :   return first_set;
    4439                 :             : }
    4440                 :             : 
    4441                 :             : /* Return true if we should avoid inserting code between INSN and preceding
    4442                 :             :    call instruction.  */
    4443                 :             : 
    4444                 :             : bool
    4445                 :    11104002 : keep_with_call_p (const rtx_insn *insn)
    4446                 :             : {
    4447                 :    11104002 :   rtx set;
    4448                 :             : 
    4449                 :    11104002 :   if (INSN_P (insn) && (set = single_set (insn)) != NULL)
    4450                 :             :     {
    4451                 :     7389545 :       if (REG_P (SET_DEST (set))
    4452                 :     2001864 :           && REGNO (SET_DEST (set)) < FIRST_PSEUDO_REGISTER
    4453                 :     2001864 :           && fixed_regs[REGNO (SET_DEST (set))]
    4454                 :     7556916 :           && general_operand (SET_SRC (set), VOIDmode))
    4455                 :             :         return true;
    4456                 :     7389188 :       if (REG_P (SET_SRC (set))
    4457                 :      757707 :           && targetm.calls.function_value_regno_p (REGNO (SET_SRC (set)))
    4458                 :      494090 :           && REG_P (SET_DEST (set))
    4459                 :     7563927 :           && REGNO (SET_DEST (set)) >= FIRST_PSEUDO_REGISTER)
    4460                 :             :         return true;
    4461                 :             :       /* There may be a stack pop just after the call and before the store
    4462                 :             :          of the return register.  Search for the actual store when deciding
    4463                 :             :          if we can break or not.  */
    4464                 :     7389188 :       if (SET_DEST (set) == stack_pointer_rtx)
    4465                 :             :         {
    4466                 :             :           /* This CONST_CAST is okay because next_nonnote_insn just
    4467                 :             :              returns its argument and we assign it to a const_rtx
    4468                 :             :              variable.  */
    4469                 :      165925 :           const rtx_insn *i2
    4470                 :      165925 :             = next_nonnote_insn (const_cast<rtx_insn *> (insn));
    4471                 :      165925 :           if (i2 && keep_with_call_p (i2))
    4472                 :             :             return true;
    4473                 :             :         }
    4474                 :             :     }
    4475                 :             :   return false;
    4476                 :             : }
    4477                 :             : 
    4478                 :             : /* Return true if LABEL is a target of JUMP_INSN.  This applies only
    4479                 :             :    to non-complex jumps.  That is, direct unconditional, conditional,
    4480                 :             :    and tablejumps, but not computed jumps or returns.  It also does
    4481                 :             :    not apply to the fallthru case of a conditional jump.  */
    4482                 :             : 
    4483                 :             : bool
    4484                 :    24102375 : label_is_jump_target_p (const_rtx label, const rtx_insn *jump_insn)
    4485                 :             : {
    4486                 :    24102375 :   rtx tmp = JUMP_LABEL (jump_insn);
    4487                 :    24102375 :   rtx_jump_table_data *table;
    4488                 :             : 
    4489                 :    24102375 :   if (label == tmp)
    4490                 :             :     return true;
    4491                 :             : 
    4492                 :     4277172 :   if (tablejump_p (jump_insn, NULL, &table))
    4493                 :             :     {
    4494                 :           0 :       rtvec vec = table->get_labels ();
    4495                 :           0 :       int i, veclen = GET_NUM_ELEM (vec);
    4496                 :             : 
    4497                 :           0 :       for (i = 0; i < veclen; ++i)
    4498                 :           0 :         if (XEXP (RTVEC_ELT (vec, i), 0) == label)
    4499                 :             :           return true;
    4500                 :             :     }
    4501                 :             : 
    4502                 :     4277172 :   if (find_reg_note (jump_insn, REG_LABEL_TARGET, label))
    4503                 :             :     return true;
    4504                 :             : 
    4505                 :             :   return false;
    4506                 :             : }
    4507                 :             : 
    4508                 :             : 
    4509                 :             : /* Return an estimate of the cost of computing rtx X.
    4510                 :             :    One use is in cse, to decide which expression to keep in the hash table.
    4511                 :             :    Another is in rtl generation, to pick the cheapest way to multiply.
    4512                 :             :    Other uses like the latter are expected in the future.
    4513                 :             : 
    4514                 :             :    X appears as operand OPNO in an expression with code OUTER_CODE.
    4515                 :             :    SPEED specifies whether costs optimized for speed or size should
    4516                 :             :    be returned.  */
    4517                 :             : 
    4518                 :             : int
    4519                 : 12688102432 : rtx_cost (rtx x, machine_mode mode, enum rtx_code outer_code,
    4520                 :             :           int opno, bool speed)
    4521                 :             : {
    4522                 : 12688102432 :   int i, j;
    4523                 : 12688102432 :   enum rtx_code code;
    4524                 : 12688102432 :   const char *fmt;
    4525                 : 12688102432 :   int total;
    4526                 : 12688102432 :   int factor;
    4527                 : 12688102432 :   unsigned mode_size;
    4528                 :             : 
    4529                 : 12688102432 :   if (x == 0)
    4530                 :             :     return 0;
    4531                 :             : 
    4532                 : 12688102432 :   if (GET_CODE (x) == SET)
    4533                 :             :     /* A SET doesn't have a mode, so let's look at the SET_DEST to get
    4534                 :             :        the mode for the factor.  */
    4535                 :    50387033 :     mode = GET_MODE (SET_DEST (x));
    4536                 : 12637715399 :   else if (GET_MODE (x) != VOIDmode)
    4537                 :  9749726915 :     mode = GET_MODE (x);
    4538                 :             : 
    4539                 : 25376204864 :   mode_size = estimated_poly_value (GET_MODE_SIZE (mode));
    4540                 :             : 
    4541                 :             :   /* A size N times larger than UNITS_PER_WORD likely needs N times as
    4542                 :             :      many insns, taking N times as long.  */
    4543                 : 13194755970 :   factor = mode_size > UNITS_PER_WORD ? mode_size / UNITS_PER_WORD : 1;
    4544                 :             : 
    4545                 :             :   /* Compute the default costs of certain things.
    4546                 :             :      Note that targetm.rtx_costs can override the defaults.  */
    4547                 :             : 
    4548                 : 12688102432 :   code = GET_CODE (x);
    4549                 : 12688102432 :   switch (code)
    4550                 :             :     {
    4551                 :  1778821480 :     case MULT:
    4552                 :  1778821480 :     case FMA:
    4553                 :  1778821480 :     case SS_MULT:
    4554                 :  1778821480 :     case US_MULT:
    4555                 :  1778821480 :     case SMUL_HIGHPART:
    4556                 :  1778821480 :     case UMUL_HIGHPART:
    4557                 :             :       /* Multiplication has time-complexity O(N*N), where N is the
    4558                 :             :          number of units (translated from digits) when using
    4559                 :             :          schoolbook long multiplication.  */
    4560                 :  1778821480 :       total = factor * factor * COSTS_N_INSNS (5);
    4561                 :  1778821480 :       break;
    4562                 :    73415341 :     case DIV:
    4563                 :    73415341 :     case UDIV:
    4564                 :    73415341 :     case MOD:
    4565                 :    73415341 :     case UMOD:
    4566                 :    73415341 :     case SS_DIV:
    4567                 :    73415341 :     case US_DIV:
    4568                 :             :       /* Similarly, complexity for schoolbook long division.  */
    4569                 :    73415341 :       total = factor * factor * COSTS_N_INSNS (7);
    4570                 :    73415341 :       break;
    4571                 :           0 :     case USE:
    4572                 :             :       /* Used in combine.cc as a marker.  */
    4573                 :           0 :       total = 0;
    4574                 :           0 :       break;
    4575                 : 10835865611 :     default:
    4576                 : 10835865611 :       total = factor * COSTS_N_INSNS (1);
    4577                 :             :     }
    4578                 :             : 
    4579                 : 12688102432 :   switch (code)
    4580                 :             :     {
    4581                 :             :     case REG:
    4582                 :             :       return 0;
    4583                 :             : 
    4584                 :    11337972 :     case SUBREG:
    4585                 :    11337972 :       total = 0;
    4586                 :             :       /* If we can't tie these modes, make this expensive.  The larger
    4587                 :             :          the mode, the more expensive it is.  */
    4588                 :    11337972 :       if (!targetm.modes_tieable_p (mode, GET_MODE (SUBREG_REG (x))))
    4589                 :     4348203 :         return COSTS_N_INSNS (2 + factor);
    4590                 :             :       break;
    4591                 :             : 
    4592                 :    17080809 :     case TRUNCATE:
    4593                 :    17080809 :       if (targetm.modes_tieable_p (mode, GET_MODE (XEXP (x, 0))))
    4594                 :             :         {
    4595                 :     3808129 :           total = 0;
    4596                 :     3808129 :           break;
    4597                 :             :         }
    4598                 :             :       /* FALLTHRU */
    4599                 :  7760172296 :     default:
    4600                 :  7760172296 :       if (targetm.rtx_costs (x, mode, outer_code, opno, &total, speed))
    4601                 :  3546574420 :         return total;
    4602                 :             :       break;
    4603                 :             :     }
    4604                 :             : 
    4605                 :             :   /* Sum the costs of the sub-rtx's, plus cost of this operation,
    4606                 :             :      which is already in total.  */
    4607                 :             : 
    4608                 :  4224395774 :   fmt = GET_RTX_FORMAT (code);
    4609                 : 12584160586 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    4610                 :  8359764812 :     if (fmt[i] == 'e')
    4611                 :  8293188697 :       total += rtx_cost (XEXP (x, i), mode, code, i, speed);
    4612                 :    66576115 :     else if (fmt[i] == 'E')
    4613                 :    11327202 :       for (j = 0; j < XVECLEN (x, i); j++)
    4614                 :     6418040 :         total += rtx_cost (XVECEXP (x, i, j), mode, code, i, speed);
    4615                 :             : 
    4616                 :  4224395774 :   return total;
    4617                 :             : }
    4618                 :             : 
    4619                 :             : /* Fill in the structure C with information about both speed and size rtx
    4620                 :             :    costs for X, which is operand OPNO in an expression with code OUTER.  */
    4621                 :             : 
    4622                 :             : void
    4623                 :     2305793 : get_full_rtx_cost (rtx x, machine_mode mode, enum rtx_code outer, int opno,
    4624                 :             :                    struct full_rtx_costs *c)
    4625                 :             : {
    4626                 :     2305793 :   c->speed = rtx_cost (x, mode, outer, opno, true);
    4627                 :     2305793 :   c->size = rtx_cost (x, mode, outer, opno, false);
    4628                 :     2305793 : }
    4629                 :             : 
    4630                 :             : 
    4631                 :             : /* Return cost of address expression X.
    4632                 :             :    Expect that X is properly formed address reference.
    4633                 :             : 
    4634                 :             :    SPEED parameter specify whether costs optimized for speed or size should
    4635                 :             :    be returned.  */
    4636                 :             : 
    4637                 :             : int
    4638                 :    10171644 : address_cost (rtx x, machine_mode mode, addr_space_t as, bool speed)
    4639                 :             : {
    4640                 :             :   /* We may be asked for cost of various unusual addresses, such as operands
    4641                 :             :      of push instruction.  It is not worthwhile to complicate writing
    4642                 :             :      of the target hook by such cases.  */
    4643                 :             : 
    4644                 :    10171644 :   if (!memory_address_addr_space_p (mode, x, as))
    4645                 :             :     return 1000;
    4646                 :             : 
    4647                 :    10082366 :   return targetm.address_cost (x, mode, as, speed);
    4648                 :             : }
    4649                 :             : 
    4650                 :             : /* If the target doesn't override, compute the cost as with arithmetic.  */
    4651                 :             : 
    4652                 :             : int
    4653                 :           0 : default_address_cost (rtx x, machine_mode, addr_space_t, bool speed)
    4654                 :             : {
    4655                 :           0 :   return rtx_cost (x, Pmode, MEM, 0, speed);
    4656                 :             : }
    4657                 :             : 
    4658                 :             : 
    4659                 :             : unsigned HOST_WIDE_INT
    4660                 :   703966988 : nonzero_bits (const_rtx x, machine_mode mode)
    4661                 :             : {
    4662                 :   703966988 :   if (mode == VOIDmode)
    4663                 :           0 :     mode = GET_MODE (x);
    4664                 :   703966988 :   scalar_int_mode int_mode;
    4665                 :   703966988 :   if (!is_a <scalar_int_mode> (mode, &int_mode))
    4666                 :    19741853 :     return GET_MODE_MASK (mode);
    4667                 :   684225135 :   return cached_nonzero_bits (x, int_mode, NULL_RTX, VOIDmode, 0);
    4668                 :             : }
    4669                 :             : 
    4670                 :             : unsigned int
    4671                 :   249038486 : num_sign_bit_copies (const_rtx x, machine_mode mode)
    4672                 :             : {
    4673                 :   249038486 :   if (mode == VOIDmode)
    4674                 :           1 :     mode = GET_MODE (x);
    4675                 :   249038486 :   scalar_int_mode int_mode;
    4676                 :   249038486 :   if (!is_a <scalar_int_mode> (mode, &int_mode))
    4677                 :             :     return 1;
    4678                 :   229610330 :   return cached_num_sign_bit_copies (x, int_mode, NULL_RTX, VOIDmode, 0);
    4679                 :             : }
    4680                 :             : 
    4681                 :             : /* Return true if nonzero_bits1 might recurse into both operands
    4682                 :             :    of X.  */
    4683                 :             : 
    4684                 :             : static inline bool
    4685                 :  1477122177 : nonzero_bits_binary_arith_p (const_rtx x)
    4686                 :             : {
    4687                 :  1477122177 :   if (!ARITHMETIC_P (x))
    4688                 :             :     return false;
    4689                 :   265855906 :   switch (GET_CODE (x))
    4690                 :             :     {
    4691                 :             :     case AND:
    4692                 :             :     case XOR:
    4693                 :             :     case IOR:
    4694                 :             :     case UMIN:
    4695                 :             :     case UMAX:
    4696                 :             :     case SMIN:
    4697                 :             :     case SMAX:
    4698                 :             :     case PLUS:
    4699                 :             :     case MINUS:
    4700                 :             :     case MULT:
    4701                 :             :     case DIV:
    4702                 :             :     case UDIV:
    4703                 :             :     case MOD:
    4704                 :             :     case UMOD:
    4705                 :             :       return true;
    4706                 :             :     default:
    4707                 :             :       return false;
    4708                 :             :     }
    4709                 :             : }
    4710                 :             : 
    4711                 :             : /* The function cached_nonzero_bits is a wrapper around nonzero_bits1.
    4712                 :             :    It avoids exponential behavior in nonzero_bits1 when X has
    4713                 :             :    identical subexpressions on the first or the second level.  */
    4714                 :             : 
    4715                 :             : static unsigned HOST_WIDE_INT
    4716                 :  1181824166 : cached_nonzero_bits (const_rtx x, scalar_int_mode mode, const_rtx known_x,
    4717                 :             :                      machine_mode known_mode,
    4718                 :             :                      unsigned HOST_WIDE_INT known_ret)
    4719                 :             : {
    4720                 :  1181824166 :   if (x == known_x && mode == known_mode)
    4721                 :             :     return known_ret;
    4722                 :             : 
    4723                 :             :   /* Try to find identical subexpressions.  If found call
    4724                 :             :      nonzero_bits1 on X with the subexpressions as KNOWN_X and the
    4725                 :             :      precomputed value for the subexpression as KNOWN_RET.  */
    4726                 :             : 
    4727                 :  1179575832 :   if (nonzero_bits_binary_arith_p (x))
    4728                 :             :     {
    4729                 :   149391372 :       rtx x0 = XEXP (x, 0);
    4730                 :   149391372 :       rtx x1 = XEXP (x, 1);
    4731                 :             : 
    4732                 :             :       /* Check the first level.  */
    4733                 :   149391372 :       if (x0 == x1)
    4734                 :       54352 :         return nonzero_bits1 (x, mode, x0, mode,
    4735                 :             :                               cached_nonzero_bits (x0, mode, known_x,
    4736                 :       54352 :                                                    known_mode, known_ret));
    4737                 :             : 
    4738                 :             :       /* Check the second level.  */
    4739                 :   149337020 :       if (nonzero_bits_binary_arith_p (x0)
    4740                 :   149337020 :           && (x1 == XEXP (x0, 0) || x1 == XEXP (x0, 1)))
    4741                 :     1127695 :         return nonzero_bits1 (x, mode, x1, mode,
    4742                 :             :                               cached_nonzero_bits (x1, mode, known_x,
    4743                 :     1127695 :                                                    known_mode, known_ret));
    4744                 :             : 
    4745                 :   148209325 :       if (nonzero_bits_binary_arith_p (x1)
    4746                 :   148209325 :           && (x0 == XEXP (x1, 0) || x0 == XEXP (x1, 1)))
    4747                 :        4021 :         return nonzero_bits1 (x, mode, x0, mode,
    4748                 :             :                               cached_nonzero_bits (x0, mode, known_x,
    4749                 :        4021 :                                                    known_mode, known_ret));
    4750                 :             :     }
    4751                 :             : 
    4752                 :  1178389764 :   return nonzero_bits1 (x, mode, known_x, known_mode, known_ret);
    4753                 :             : }
    4754                 :             : 
    4755                 :             : /* We let num_sign_bit_copies recur into nonzero_bits as that is useful.
    4756                 :             :    We don't let nonzero_bits recur into num_sign_bit_copies, because that
    4757                 :             :    is less useful.  We can't allow both, because that results in exponential
    4758                 :             :    run time recursion.  There is a nullstone testcase that triggered
    4759                 :             :    this.  This macro avoids accidental uses of num_sign_bit_copies.  */
    4760                 :             : #define cached_num_sign_bit_copies sorry_i_am_preventing_exponential_behavior
    4761                 :             : 
    4762                 :             : /* Given an expression, X, compute which bits in X can be nonzero.
    4763                 :             :    We don't care about bits outside of those defined in MODE.
    4764                 :             : 
    4765                 :             :    For most X this is simply GET_MODE_MASK (GET_MODE (X)), but if X is
    4766                 :             :    an arithmetic operation, we can do better.  */
    4767                 :             : 
    4768                 :             : static unsigned HOST_WIDE_INT
    4769                 :  1179575832 : nonzero_bits1 (const_rtx x, scalar_int_mode mode, const_rtx known_x,
    4770                 :             :                machine_mode known_mode,
    4771                 :             :                unsigned HOST_WIDE_INT known_ret)
    4772                 :             : {
    4773                 :  1179575832 :   unsigned HOST_WIDE_INT nonzero = GET_MODE_MASK (mode);
    4774                 :  1179575832 :   unsigned HOST_WIDE_INT inner_nz;
    4775                 :  1179575832 :   enum rtx_code code = GET_CODE (x);
    4776                 :  1179575832 :   machine_mode inner_mode;
    4777                 :  1179575832 :   unsigned int inner_width;
    4778                 :  1179575832 :   scalar_int_mode xmode;
    4779                 :             : 
    4780                 :  1179575832 :   unsigned int mode_width = GET_MODE_PRECISION (mode);
    4781                 :             : 
    4782                 :  1179575832 :   if (CONST_INT_P (x))
    4783                 :             :     {
    4784                 :   124145378 :       if (SHORT_IMMEDIATES_SIGN_EXTEND
    4785                 :             :           && INTVAL (x) > 0
    4786                 :             :           && mode_width < BITS_PER_WORD
    4787                 :             :           && (UINTVAL (x) & (HOST_WIDE_INT_1U << (mode_width - 1))) != 0)
    4788                 :             :         return UINTVAL (x) | (HOST_WIDE_INT_M1U << mode_width);
    4789                 :             : 
    4790                 :   124145378 :       return UINTVAL (x);
    4791                 :             :     }
    4792                 :             : 
    4793                 :  1055430454 :   if (!is_a <scalar_int_mode> (GET_MODE (x), &xmode))
    4794                 :             :     return nonzero;
    4795                 :  1055049729 :   unsigned int xmode_width = GET_MODE_PRECISION (xmode);
    4796                 :             : 
    4797                 :             :   /* If X is wider than MODE, use its mode instead.  */
    4798                 :  1055049729 :   if (xmode_width > mode_width)
    4799                 :             :     {
    4800                 :    24047129 :       mode = xmode;
    4801                 :    24047129 :       nonzero = GET_MODE_MASK (mode);
    4802                 :    24047129 :       mode_width = xmode_width;
    4803                 :             :     }
    4804                 :             : 
    4805                 :  1055049729 :   if (mode_width > HOST_BITS_PER_WIDE_INT)
    4806                 :             :     /* Our only callers in this case look for single bit values.  So
    4807                 :             :        just return the mode mask.  Those tests will then be false.  */
    4808                 :             :     return nonzero;
    4809                 :             : 
    4810                 :             :   /* If MODE is wider than X, but both are a single word for both the host
    4811                 :             :      and target machines, we can compute this from which bits of the object
    4812                 :             :      might be nonzero in its own mode, taking into account the fact that, on
    4813                 :             :      CISC machines, accessing an object in a wider mode generally causes the
    4814                 :             :      high-order bits to become undefined, so they are not known to be zero.
    4815                 :             :      We extend this reasoning to RISC machines for operations that might not
    4816                 :             :      operate on the full registers.  */
    4817                 :  1053418562 :   if (mode_width > xmode_width
    4818                 :   114421806 :       && xmode_width <= BITS_PER_WORD
    4819                 :             :       && xmode_width <= HOST_BITS_PER_WIDE_INT
    4820                 :             :       && !(WORD_REGISTER_OPERATIONS && word_register_operation_p (x)))
    4821                 :             :     {
    4822                 :    98592606 :       nonzero &= cached_nonzero_bits (x, xmode,
    4823                 :             :                                       known_x, known_mode, known_ret);
    4824                 :    98592606 :       nonzero |= GET_MODE_MASK (mode) & ~GET_MODE_MASK (xmode);
    4825                 :    98592606 :       return nonzero;
    4826                 :             :     }
    4827                 :             : 
    4828                 :             :   /* Please keep nonzero_bits_binary_arith_p above in sync with
    4829                 :             :      the code in the switch below.  */
    4830                 :   954825956 :   switch (code)
    4831                 :             :     {
    4832                 :   524215373 :     case REG:
    4833                 :             : #if defined(POINTERS_EXTEND_UNSIGNED)
    4834                 :             :       /* If pointers extend unsigned and this is a pointer in Pmode, say that
    4835                 :             :          all the bits above ptr_mode are known to be zero.  */
    4836                 :             :       /* As we do not know which address space the pointer is referring to,
    4837                 :             :          we can do this only if the target does not support different pointer
    4838                 :             :          or address modes depending on the address space.  */
    4839                 :   524215373 :       if (target_default_pointer_address_modes_p ()
    4840                 :             :           && POINTERS_EXTEND_UNSIGNED
    4841                 :   524215373 :           && xmode == Pmode
    4842                 :   325560025 :           && REG_POINTER (x)
    4843                 :   608955477 :           && !targetm.have_ptr_extend ())
    4844                 :    84740104 :         nonzero &= GET_MODE_MASK (ptr_mode);
    4845                 :             : #endif
    4846                 :             : 
    4847                 :             :       /* Include declared information about alignment of pointers.  */
    4848                 :             :       /* ??? We don't properly preserve REG_POINTER changes across
    4849                 :             :          pointer-to-integer casts, so we can't trust it except for
    4850                 :             :          things that we know must be pointers.  See execute/960116-1.c.  */
    4851                 :   524215373 :       if ((x == stack_pointer_rtx
    4852                 :   523286477 :            || x == frame_pointer_rtx
    4853                 :   508419648 :            || x == arg_pointer_rtx)
    4854                 :   539627329 :           && REGNO_POINTER_ALIGN (REGNO (x)))
    4855                 :             :         {
    4856                 :    16340852 :           unsigned HOST_WIDE_INT alignment
    4857                 :    16340852 :             = REGNO_POINTER_ALIGN (REGNO (x)) / BITS_PER_UNIT;
    4858                 :             : 
    4859                 :             : #ifdef PUSH_ROUNDING
    4860                 :             :           /* If PUSH_ROUNDING is defined, it is possible for the
    4861                 :             :              stack to be momentarily aligned only to that amount,
    4862                 :             :              so we pick the least alignment.  */
    4863                 :    16340852 :           if (x == stack_pointer_rtx && targetm.calls.push_argument (0))
    4864                 :             :             {
    4865                 :      704429 :               poly_uint64 rounded_1 = PUSH_ROUNDING (poly_int64 (1));
    4866                 :      704429 :               alignment = MIN (known_alignment (rounded_1), alignment);
    4867                 :             :             }
    4868                 :             : #endif
    4869                 :             : 
    4870                 :    16340852 :           nonzero &= ~(alignment - 1);
    4871                 :             :         }
    4872                 :             : 
    4873                 :   524215373 :       {
    4874                 :   524215373 :         unsigned HOST_WIDE_INT nonzero_for_hook = nonzero;
    4875                 :   524215373 :         rtx new_rtx = rtl_hooks.reg_nonzero_bits (x, xmode, mode,
    4876                 :             :                                                   &nonzero_for_hook);
    4877                 :             : 
    4878                 :   524215373 :         if (new_rtx)
    4879                 :           6 :           nonzero_for_hook &= cached_nonzero_bits (new_rtx, mode, known_x,
    4880                 :             :                                                    known_mode, known_ret);
    4881                 :             : 
    4882                 :   524215373 :         return nonzero_for_hook;
    4883                 :             :       }
    4884                 :             : 
    4885                 :             :     case MEM:
    4886                 :             :       /* In many, if not most, RISC machines, reading a byte from memory
    4887                 :             :          zeros the rest of the register.  Noticing that fact saves a lot
    4888                 :             :          of extra zero-extends.  */
    4889                 :             :       if (load_extend_op (xmode) == ZERO_EXTEND)
    4890                 :             :         nonzero &= GET_MODE_MASK (xmode);
    4891                 :             :       break;
    4892                 :             : 
    4893                 :     8655472 :     case EQ:  case NE:
    4894                 :     8655472 :     case UNEQ:  case LTGT:
    4895                 :     8655472 :     case GT:  case GTU:  case UNGT:
    4896                 :     8655472 :     case LT:  case LTU:  case UNLT:
    4897                 :     8655472 :     case GE:  case GEU:  case UNGE:
    4898                 :     8655472 :     case LE:  case LEU:  case UNLE:
    4899                 :     8655472 :     case UNORDERED: case ORDERED:
    4900                 :             :       /* If this produces an integer result, we know which bits are set.
    4901                 :             :          Code here used to clear bits outside the mode of X, but that is
    4902                 :             :          now done above.  */
    4903                 :             :       /* Mind that MODE is the mode the caller wants to look at this
    4904                 :             :          operation in, and not the actual operation mode.  We can wind
    4905                 :             :          up with (subreg:DI (gt:V4HI x y)), and we don't have anything
    4906                 :             :          that describes the results of a vector compare.  */
    4907                 :     8655472 :       if (GET_MODE_CLASS (xmode) == MODE_INT
    4908                 :     8655472 :           && mode_width <= HOST_BITS_PER_WIDE_INT)
    4909                 :  1179575832 :         nonzero = STORE_FLAG_VALUE;
    4910                 :             :       break;
    4911                 :             : 
    4912                 :     1001265 :     case NEG:
    4913                 :             : #if 0
    4914                 :             :       /* Disabled to avoid exponential mutual recursion between nonzero_bits
    4915                 :             :          and num_sign_bit_copies.  */
    4916                 :             :       if (num_sign_bit_copies (XEXP (x, 0), xmode) == xmode_width)
    4917                 :             :         nonzero = 1;
    4918                 :             : #endif
    4919                 :             : 
    4920                 :     1001265 :       if (xmode_width < mode_width)
    4921                 :           0 :         nonzero |= (GET_MODE_MASK (mode) & ~GET_MODE_MASK (xmode));
    4922                 :             :       break;
    4923                 :             : 
    4924                 :             :     case ABS:
    4925                 :             : #if 0
    4926                 :             :       /* Disabled to avoid exponential mutual recursion between nonzero_bits
    4927                 :             :          and num_sign_bit_copies.  */
    4928                 :             :       if (num_sign_bit_copies (XEXP (x, 0), xmode) == xmode_width)
    4929                 :             :         nonzero = 1;
    4930                 :             : #endif
    4931                 :             :       break;
    4932                 :             : 
    4933                 :       10746 :     case TRUNCATE:
    4934                 :       10746 :       nonzero &= (cached_nonzero_bits (XEXP (x, 0), mode,
    4935                 :             :                                        known_x, known_mode, known_ret)
    4936                 :       10746 :                   & GET_MODE_MASK (mode));
    4937                 :       10746 :       break;
    4938                 :             : 
    4939                 :     6898375 :     case ZERO_EXTEND:
    4940                 :     6898375 :       nonzero &= cached_nonzero_bits (XEXP (x, 0), mode,
    4941                 :             :                                       known_x, known_mode, known_ret);
    4942                 :     6898375 :       if (GET_MODE (XEXP (x, 0)) != VOIDmode)
    4943                 :     6898375 :         nonzero &= GET_MODE_MASK (GET_MODE (XEXP (x, 0)));
    4944                 :             :       break;
    4945                 :             : 
    4946                 :     1845748 :     case SIGN_EXTEND:
    4947                 :             :       /* If the sign bit is known clear, this is the same as ZERO_EXTEND.
    4948                 :             :          Otherwise, show all the bits in the outer mode but not the inner
    4949                 :             :          may be nonzero.  */
    4950                 :     1845748 :       inner_nz = cached_nonzero_bits (XEXP (x, 0), mode,
    4951                 :             :                                       known_x, known_mode, known_ret);
    4952                 :     1845748 :       if (GET_MODE (XEXP (x, 0)) != VOIDmode)
    4953                 :             :         {
    4954                 :     1845748 :           inner_nz &= GET_MODE_MASK (GET_MODE (XEXP (x, 0)));
    4955                 :     1845748 :           if (val_signbit_known_set_p (GET_MODE (XEXP (x, 0)), inner_nz))
    4956                 :     1803733 :             inner_nz |= (GET_MODE_MASK (mode)
    4957                 :     1803733 :                          & ~GET_MODE_MASK (GET_MODE (XEXP (x, 0))));
    4958                 :             :         }
    4959                 :             : 
    4960                 :     1845748 :       nonzero &= inner_nz;
    4961                 :     1845748 :       break;
    4962                 :             : 
    4963                 :    17336009 :     case AND:
    4964                 :    17336009 :       nonzero &= cached_nonzero_bits (XEXP (x, 0), mode,
    4965                 :             :                                        known_x, known_mode, known_ret)
    4966                 :    17336009 :                  & cached_nonzero_bits (XEXP (x, 1), mode,
    4967                 :             :                                         known_x, known_mode, known_ret);
    4968                 :    17336009 :       break;
    4969                 :             : 
    4970                 :    11732192 :     case XOR:   case IOR:
    4971                 :    11732192 :     case UMIN:  case UMAX:  case SMIN:  case SMAX:
    4972                 :    11732192 :       {
    4973                 :    11732192 :         unsigned HOST_WIDE_INT nonzero0
    4974                 :    11732192 :            = cached_nonzero_bits (XEXP (x, 0), mode,
    4975                 :             :                                   known_x, known_mode, known_ret);
    4976                 :             : 
    4977                 :             :         /* Don't call nonzero_bits for the second time if it cannot change
    4978                 :             :            anything.  */
    4979                 :    11732192 :         if ((nonzero & nonzero0) != nonzero)
    4980                 :    10498570 :           nonzero &= nonzero0
    4981                 :     5249285 :                      | cached_nonzero_bits (XEXP (x, 1), mode,
    4982                 :             :                                             known_x, known_mode, known_ret);
    4983                 :             :       }
    4984                 :             :       break;
    4985                 :             : 
    4986                 :    98090647 :     case PLUS:  case MINUS:
    4987                 :    98090647 :     case MULT:
    4988                 :    98090647 :     case DIV:   case UDIV:
    4989                 :    98090647 :     case MOD:   case UMOD:
    4990                 :             :       /* We can apply the rules of arithmetic to compute the number of
    4991                 :             :          high- and low-order zero bits of these operations.  We start by
    4992                 :             :          computing the width (position of the highest-order nonzero bit)
    4993                 :             :          and the number of low-order zero bits for each value.  */
    4994                 :    98090647 :       {
    4995                 :    98090647 :         unsigned HOST_WIDE_INT nz0
    4996                 :    98090647 :           = cached_nonzero_bits (XEXP (x, 0), mode,
    4997                 :             :                                  known_x, known_mode, known_ret);
    4998                 :    98090647 :         unsigned HOST_WIDE_INT nz1
    4999                 :    98090647 :           = cached_nonzero_bits (XEXP (x, 1), mode,
    5000                 :             :                                  known_x, known_mode, known_ret);
    5001                 :    98090647 :         int sign_index = xmode_width - 1;
    5002                 :    98090647 :         int width0 = floor_log2 (nz0) + 1;
    5003                 :    98090647 :         int width1 = floor_log2 (nz1) + 1;
    5004                 :    98090647 :         int low0 = ctz_or_zero (nz0);
    5005                 :    98090647 :         int low1 = ctz_or_zero (nz1);
    5006                 :    98090647 :         unsigned HOST_WIDE_INT op0_maybe_minusp
    5007                 :    98090647 :           = nz0 & (HOST_WIDE_INT_1U << sign_index);
    5008                 :    98090647 :         unsigned HOST_WIDE_INT op1_maybe_minusp
    5009                 :             :           = nz1 & (HOST_WIDE_INT_1U << sign_index);
    5010                 :    98090647 :         unsigned int result_width = mode_width;
    5011                 :    98090647 :         int result_low = 0;
    5012                 :             : 
    5013                 :    98090647 :         switch (code)
    5014                 :             :           {
    5015                 :    70755460 :           case PLUS:
    5016                 :    70755460 :             result_width = MAX (width0, width1) + 1;
    5017                 :    70755460 :             result_low = MIN (low0, low1);
    5018                 :             :             break;
    5019                 :    16671202 :           case MINUS:
    5020                 :    16671202 :             result_low = MIN (low0, low1);
    5021                 :             :             break;
    5022                 :     9003039 :           case MULT:
    5023                 :     9003039 :             result_width = width0 + width1;
    5024                 :     9003039 :             result_low = low0 + low1;
    5025                 :     9003039 :             break;
    5026                 :      625291 :           case DIV:
    5027                 :      625291 :             if (width1 == 0)
    5028                 :             :               break;
    5029                 :      615645 :             if (!op0_maybe_minusp && !op1_maybe_minusp)
    5030                 :       23114 :               result_width = width0;
    5031                 :             :             break;
    5032                 :      283063 :           case UDIV:
    5033                 :      283063 :             if (width1 == 0)
    5034                 :             :               break;
    5035                 :      282280 :             result_width = width0;
    5036                 :      282280 :             break;
    5037                 :      366314 :           case MOD:
    5038                 :      366314 :             if (width1 == 0)
    5039                 :             :               break;
    5040                 :      358986 :             if (!op0_maybe_minusp && !op1_maybe_minusp)
    5041                 :       21919 :               result_width = MIN (width0, width1);
    5042                 :      358986 :             result_low = MIN (low0, low1);
    5043                 :             :             break;
    5044                 :      386278 :           case UMOD:
    5045                 :      386278 :             if (width1 == 0)
    5046                 :             :               break;
    5047                 :      386174 :             result_width = MIN (width0, width1);
    5048                 :      386174 :             result_low = MIN (low0, low1);
    5049                 :             :             break;
    5050                 :           0 :           default:
    5051                 :           0 :             gcc_unreachable ();
    5052                 :             :           }
    5053                 :             : 
    5054                 :             :         /* Note that mode_width <= HOST_BITS_PER_WIDE_INT, see above.  */
    5055                 :    98090647 :         if (result_width < mode_width)
    5056                 :     4709519 :           nonzero &= (HOST_WIDE_INT_1U << result_width) - 1;
    5057                 :             : 
    5058                 :    98090647 :         if (result_low > 0)
    5059                 :             :           {
    5060                 :     7449550 :             if (result_low < HOST_BITS_PER_WIDE_INT)
    5061                 :     7449538 :               nonzero &= ~((HOST_WIDE_INT_1U << result_low) - 1);
    5062                 :             :             else
    5063                 :             :               nonzero = 0;
    5064                 :             :           }
    5065                 :             :       }
    5066                 :             :       break;
    5067                 :             : 
    5068                 :     1097898 :     case ZERO_EXTRACT:
    5069                 :     1097898 :       if (CONST_INT_P (XEXP (x, 1))
    5070                 :     1097521 :           && INTVAL (XEXP (x, 1)) < HOST_BITS_PER_WIDE_INT)
    5071                 :     1097364 :         nonzero &= (HOST_WIDE_INT_1U << INTVAL (XEXP (x, 1))) - 1;
    5072                 :             :       break;
    5073                 :             : 
    5074                 :    82560842 :     case SUBREG:
    5075                 :             :       /* If this is a SUBREG formed for a promoted variable that has
    5076                 :             :          been zero-extended, we know that at least the high-order bits
    5077                 :             :          are zero, though others might be too.  */
    5078                 :    82560842 :       if (SUBREG_PROMOTED_VAR_P (x) && SUBREG_PROMOTED_UNSIGNED_P (x))
    5079                 :       60931 :         nonzero = GET_MODE_MASK (xmode)
    5080                 :       60931 :                   & cached_nonzero_bits (SUBREG_REG (x), xmode,
    5081                 :             :                                          known_x, known_mode, known_ret);
    5082                 :             : 
    5083                 :             :       /* If the inner mode is a single word for both the host and target
    5084                 :             :          machines, we can compute this from which bits of the inner
    5085                 :             :          object might be nonzero.  */
    5086                 :    82560842 :       inner_mode = GET_MODE (SUBREG_REG (x));
    5087                 :    82560842 :       if (GET_MODE_PRECISION (inner_mode).is_constant (&inner_width)
    5088                 :    87284517 :           && inner_width <= BITS_PER_WORD
    5089                 :             :           && inner_width <= HOST_BITS_PER_WIDE_INT)
    5090                 :             :         {
    5091                 :    78359423 :           nonzero &= cached_nonzero_bits (SUBREG_REG (x), mode,
    5092                 :             :                                           known_x, known_mode, known_ret);
    5093                 :             : 
    5094                 :             :           /* On a typical CISC machine, accessing an object in a wider mode
    5095                 :             :              causes the high-order bits to become undefined.  So they are
    5096                 :             :              not known to be zero.
    5097                 :             : 
    5098                 :             :              On a typical RISC machine, we only have to worry about the way
    5099                 :             :              loads are extended.  Otherwise, if we get a reload for the inner
    5100                 :             :              part, it may be loaded from the stack, and then we may lose all
    5101                 :             :              the zero bits that existed before the store to the stack.  */
    5102                 :    78359423 :           rtx_code extend_op;
    5103                 :    78359423 :           if ((!WORD_REGISTER_OPERATIONS
    5104                 :             :                || ((extend_op = load_extend_op (inner_mode)) == SIGN_EXTEND
    5105                 :             :                    ? val_signbit_known_set_p (inner_mode, nonzero)
    5106                 :             :                    : extend_op != ZERO_EXTEND)
    5107                 :             :                || !MEM_P (SUBREG_REG (x)))
    5108                 :             :               && xmode_width > inner_width)
    5109                 :    56696770 :             nonzero
    5110                 :    56696770 :               |= (GET_MODE_MASK (GET_MODE (x)) & ~GET_MODE_MASK (inner_mode));
    5111                 :             :         }
    5112                 :             :       break;
    5113                 :             : 
    5114                 :    59704607 :     case ASHIFT:
    5115                 :    59704607 :     case ASHIFTRT:
    5116                 :    59704607 :     case LSHIFTRT:
    5117                 :    59704607 :     case ROTATE:
    5118                 :    59704607 :     case ROTATERT:
    5119                 :             :       /* The nonzero bits are in two classes: any bits within MODE
    5120                 :             :          that aren't in xmode are always significant.  The rest of the
    5121                 :             :          nonzero bits are those that are significant in the operand of
    5122                 :             :          the shift when shifted the appropriate number of bits.  This
    5123                 :             :          shows that high-order bits are cleared by the right shift and
    5124                 :             :          low-order bits by left shifts.  */
    5125                 :    59704607 :       if (CONST_INT_P (XEXP (x, 1))
    5126                 :    58138769 :           && INTVAL (XEXP (x, 1)) >= 0
    5127                 :    58138623 :           && INTVAL (XEXP (x, 1)) < HOST_BITS_PER_WIDE_INT
    5128                 :    58138535 :           && INTVAL (XEXP (x, 1)) < xmode_width)
    5129                 :             :         {
    5130                 :    58138469 :           int count = INTVAL (XEXP (x, 1));
    5131                 :    58138469 :           unsigned HOST_WIDE_INT mode_mask = GET_MODE_MASK (xmode);
    5132                 :    58138469 :           unsigned HOST_WIDE_INT op_nonzero
    5133                 :    58138469 :             = cached_nonzero_bits (XEXP (x, 0), mode,
    5134                 :             :                                    known_x, known_mode, known_ret);
    5135                 :    58138469 :           unsigned HOST_WIDE_INT inner = op_nonzero & mode_mask;
    5136                 :    58138469 :           unsigned HOST_WIDE_INT outer = 0;
    5137                 :             : 
    5138                 :    58138469 :           if (mode_width > xmode_width)
    5139                 :           0 :             outer = (op_nonzero & nonzero & ~mode_mask);
    5140                 :             : 
    5141                 :    58138469 :           switch (code)
    5142                 :             :             {
    5143                 :    33554454 :             case ASHIFT:
    5144                 :    33554454 :               inner <<= count;
    5145                 :    33554454 :               break;
    5146                 :             : 
    5147                 :    16005886 :             case LSHIFTRT:
    5148                 :    16005886 :               inner >>= count;
    5149                 :    16005886 :               break;
    5150                 :             : 
    5151                 :     8471092 :             case ASHIFTRT:
    5152                 :     8471092 :               inner >>= count;
    5153                 :             : 
    5154                 :             :               /* If the sign bit may have been nonzero before the shift, we
    5155                 :             :                  need to mark all the places it could have been copied to
    5156                 :             :                  by the shift as possibly nonzero.  */
    5157                 :     8471092 :               if (inner & (HOST_WIDE_INT_1U << (xmode_width - 1 - count)))
    5158                 :     8456646 :                 inner |= (((HOST_WIDE_INT_1U << count) - 1)
    5159                 :     8456646 :                           << (xmode_width - count));
    5160                 :             :               break;
    5161                 :             : 
    5162                 :       67027 :             case ROTATE:
    5163                 :       67027 :               inner = (inner << (count % xmode_width)
    5164                 :       67027 :                        | (inner >> (xmode_width - (count % xmode_width))))
    5165                 :             :                       & mode_mask;
    5166                 :       67027 :               break;
    5167                 :             : 
    5168                 :       40010 :             case ROTATERT:
    5169                 :       40010 :               inner = (inner >> (count % xmode_width)
    5170                 :       40010 :                        | (inner << (xmode_width - (count % xmode_width))))
    5171                 :             :                       & mode_mask;
    5172                 :       40010 :               break;
    5173                 :             : 
    5174                 :             :             default:
    5175                 :             :               gcc_unreachable ();
    5176                 :             :             }
    5177                 :             : 
    5178                 :    58138469 :           nonzero &= (outer | inner);
    5179                 :             :         }
    5180                 :             :       break;
    5181                 :             : 
    5182                 :        3292 :     case FFS:
    5183                 :        3292 :     case POPCOUNT:
    5184                 :             :       /* This is at most the number of bits in the mode.  */
    5185                 :        3292 :       nonzero = (HOST_WIDE_INT_UC (2) << (floor_log2 (mode_width))) - 1;
    5186                 :        3292 :       break;
    5187                 :             : 
    5188                 :     1056764 :     case CLZ:
    5189                 :             :       /* If CLZ has a known value at zero, then the nonzero bits are
    5190                 :             :          that value, plus the number of bits in the mode minus one.  */
    5191                 :     2113528 :       if (CLZ_DEFINED_VALUE_AT_ZERO (mode, nonzero))
    5192                 :        1187 :         nonzero
    5193                 :        2374 :           |= (HOST_WIDE_INT_1U << (floor_log2 (mode_width))) - 1;
    5194                 :             :       else
    5195                 :             :         nonzero = -1;
    5196                 :             :       break;
    5197                 :             : 
    5198                 :       34994 :     case CTZ:
    5199                 :             :       /* If CTZ has a known value at zero, then the nonzero bits are
    5200                 :             :          that value, plus the number of bits in the mode minus one.  */
    5201                 :       69988 :       if (CTZ_DEFINED_VALUE_AT_ZERO (mode, nonzero))
    5202                 :        1798 :         nonzero
    5203                 :        3596 :           |= (HOST_WIDE_INT_1U << (floor_log2 (mode_width))) - 1;
    5204                 :             :       else
    5205                 :             :         nonzero = -1;
    5206                 :             :       break;
    5207                 :             : 
    5208                 :           8 :     case CLRSB:
    5209                 :             :       /* This is at most the number of bits in the mode minus 1.  */
    5210                 :           8 :       nonzero = (HOST_WIDE_INT_1U << (floor_log2 (mode_width))) - 1;
    5211                 :           8 :       break;
    5212                 :             : 
    5213                 :             :     case PARITY:
    5214                 :  1179575832 :       nonzero = 1;
    5215                 :             :       break;
    5216                 :             : 
    5217                 :     3265303 :     case IF_THEN_ELSE:
    5218                 :     3265303 :       {
    5219                 :     3265303 :         unsigned HOST_WIDE_INT nonzero_true
    5220                 :     3265303 :           = cached_nonzero_bits (XEXP (x, 1), mode,
    5221                 :             :                                  known_x, known_mode, known_ret);
    5222                 :             : 
    5223                 :             :         /* Don't call nonzero_bits for the second time if it cannot change
    5224                 :             :            anything.  */
    5225                 :     3265303 :         if ((nonzero & nonzero_true) != nonzero)
    5226                 :     2813134 :           nonzero &= nonzero_true
    5227                 :     1406567 :                      | cached_nonzero_bits (XEXP (x, 2), mode,
    5228                 :             :                                             known_x, known_mode, known_ret);
    5229                 :             :       }
    5230                 :             :       break;
    5231                 :             : 
    5232                 :             :     default:
    5233                 :             :       break;
    5234                 :             :     }
    5235                 :             : 
    5236                 :             :   return nonzero;
    5237                 :             : }
    5238                 :             : 
    5239                 :             : /* See the macro definition above.  */
    5240                 :             : #undef cached_num_sign_bit_copies
    5241                 :             : 
    5242                 :             : 
    5243                 :             : /* Return true if num_sign_bit_copies1 might recurse into both operands
    5244                 :             :    of X.  */
    5245                 :             : 
    5246                 :             : static inline bool
    5247                 :   445114453 : num_sign_bit_copies_binary_arith_p (const_rtx x)
    5248                 :             : {
    5249                 :   445114453 :   if (!ARITHMETIC_P (x))
    5250                 :             :     return false;
    5251                 :    79932381 :   switch (GET_CODE (x))
    5252                 :             :     {
    5253                 :             :     case IOR:
    5254                 :             :     case AND:
    5255                 :             :     case XOR:
    5256                 :             :     case SMIN:
    5257                 :             :     case SMAX:
    5258                 :             :     case UMIN:
    5259                 :             :     case UMAX:
    5260                 :             :     case PLUS:
    5261                 :             :     case MINUS:
    5262                 :             :     case MULT:
    5263                 :             :       return true;
    5264                 :             :     default:
    5265                 :             :       return false;
    5266                 :             :     }
    5267                 :             : }
    5268                 :             : 
    5269                 :             : /* The function cached_num_sign_bit_copies is a wrapper around
    5270                 :             :    num_sign_bit_copies1.  It avoids exponential behavior in
    5271                 :             :    num_sign_bit_copies1 when X has identical subexpressions on the
    5272                 :             :    first or the second level.  */
    5273                 :             : 
    5274                 :             : static unsigned int
    5275                 :   350003028 : cached_num_sign_bit_copies (const_rtx x, scalar_int_mode mode,
    5276                 :             :                             const_rtx known_x, machine_mode known_mode,
    5277                 :             :                             unsigned int known_ret)
    5278                 :             : {
    5279                 :   350003028 :   if (x == known_x && mode == known_mode)
    5280                 :             :     return known_ret;
    5281                 :             : 
    5282                 :             :   /* Try to find identical subexpressions.  If found call
    5283                 :             :      num_sign_bit_copies1 on X with the subexpressions as KNOWN_X and
    5284                 :             :      the precomputed value for the subexpression as KNOWN_RET.  */
    5285                 :             : 
    5286                 :   348279003 :   if (num_sign_bit_copies_binary_arith_p (x))
    5287                 :             :     {
    5288                 :    48799208 :       rtx x0 = XEXP (x, 0);
    5289                 :    48799208 :       rtx x1 = XEXP (x, 1);
    5290                 :             : 
    5291                 :             :       /* Check the first level.  */
    5292                 :    48799208 :       if (x0 == x1)
    5293                 :       15140 :         return
    5294                 :       15140 :           num_sign_bit_copies1 (x, mode, x0, mode,
    5295                 :             :                                 cached_num_sign_bit_copies (x0, mode, known_x,
    5296                 :             :                                                             known_mode,
    5297                 :       15140 :                                                             known_ret));
    5298                 :             : 
    5299                 :             :       /* Check the second level.  */
    5300                 :    48784068 :       if (num_sign_bit_copies_binary_arith_p (x0)
    5301                 :    48784068 :           && (x1 == XEXP (x0, 0) || x1 == XEXP (x0, 1)))
    5302                 :      732686 :         return
    5303                 :      732686 :           num_sign_bit_copies1 (x, mode, x1, mode,
    5304                 :             :                                 cached_num_sign_bit_copies (x1, mode, known_x,
    5305                 :             :                                                             known_mode,
    5306                 :      732686 :                                                             known_ret));
    5307                 :             : 
    5308                 :    48051382 :       if (num_sign_bit_copies_binary_arith_p (x1)
    5309                 :    48051382 :           && (x0 == XEXP (x1, 0) || x0 == XEXP (x1, 1)))
    5310                 :          67 :         return
    5311                 :          67 :           num_sign_bit_copies1 (x, mode, x0, mode,
    5312                 :             :                                 cached_num_sign_bit_copies (x0, mode, known_x,
    5313                 :             :                                                             known_mode,
    5314                 :          67 :                                                             known_ret));
    5315                 :             :     }
    5316                 :             : 
    5317                 :   347531110 :   return num_sign_bit_copies1 (x, mode, known_x, known_mode, known_ret);
    5318                 :             : }
    5319                 :             : 
    5320                 :             : /* Return the number of bits at the high-order end of X that are known to
    5321                 :             :    be equal to the sign bit.  X will be used in mode MODE.  The returned
    5322                 :             :    value will always be between 1 and the number of bits in MODE.  */
    5323                 :             : 
    5324                 :             : static unsigned int
    5325                 :   348279003 : num_sign_bit_copies1 (const_rtx x, scalar_int_mode mode, const_rtx known_x,
    5326                 :             :                       machine_mode known_mode,
    5327                 :             :                       unsigned int known_ret)
    5328                 :             : {
    5329                 :   348279003 :   enum rtx_code code = GET_CODE (x);
    5330                 :   348279003 :   unsigned int bitwidth = GET_MODE_PRECISION (mode);
    5331                 :   348279003 :   int num0, num1, result;
    5332                 :   348279003 :   unsigned HOST_WIDE_INT nonzero;
    5333                 :             : 
    5334                 :   348279003 :   if (CONST_INT_P (x))
    5335                 :             :     {
    5336                 :             :       /* If the constant is negative, take its 1's complement and remask.
    5337                 :             :          Then see how many zero bits we have.  */
    5338                 :    44505367 :       nonzero = UINTVAL (x) & GET_MODE_MASK (mode);
    5339                 :    44505367 :       if (bitwidth <= HOST_BITS_PER_WIDE_INT
    5340                 :    44184866 :           && (nonzero & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0)
    5341                 :    19440777 :         nonzero = (~nonzero) & GET_MODE_MASK (mode);
    5342                 :             : 
    5343                 :    44505367 :       return (nonzero == 0 ? bitwidth : bitwidth - floor_log2 (nonzero) - 1);
    5344                 :             :     }
    5345                 :             : 
    5346                 :   303773636 :   scalar_int_mode xmode, inner_mode;
    5347                 :   510615074 :   if (!is_a <scalar_int_mode> (GET_MODE (x), &xmode))
    5348                 :             :     return 1;
    5349                 :             : 
    5350                 :   303423650 :   unsigned int xmode_width = GET_MODE_PRECISION (xmode);
    5351                 :             : 
    5352                 :             :   /* For a smaller mode, just ignore the high bits.  */
    5353                 :   303423650 :   if (bitwidth < xmode_width)
    5354                 :             :     {
    5355                 :       40844 :       num0 = cached_num_sign_bit_copies (x, xmode,
    5356                 :             :                                          known_x, known_mode, known_ret);
    5357                 :       40844 :       return MAX (1, num0 - (int) (xmode_width - bitwidth));
    5358                 :             :     }
    5359                 :             : 
    5360                 :   303382806 :   if (bitwidth > xmode_width)
    5361                 :             :     {
    5362                 :             :       /* If this machine does not do all register operations on the entire
    5363                 :             :          register and MODE is wider than the mode of X, we can say nothing
    5364                 :             :          at all about the high-order bits.  We extend this reasoning to RISC
    5365                 :             :          machines for operations that might not operate on full registers.  */
    5366                 :             :       if (!(WORD_REGISTER_OPERATIONS && word_register_operation_p (x)))
    5367                 :             :         return 1;
    5368                 :             : 
    5369                 :             :       /* Likewise on machines that do, if the mode of the object is smaller
    5370                 :             :          than a word and loads of that size don't sign extend, we can say
    5371                 :             :          nothing about the high order bits.  */
    5372                 :             :       if (xmode_width < BITS_PER_WORD
    5373                 :             :           && load_extend_op (xmode) != SIGN_EXTEND)
    5374                 :             :         return 1;
    5375                 :             :     }
    5376                 :             : 
    5377                 :             :   /* Please keep num_sign_bit_copies_binary_arith_p above in sync with
    5378                 :             :      the code in the switch below.  */
    5379                 :   303382796 :   switch (code)
    5380                 :             :     {
    5381                 :   159940030 :     case REG:
    5382                 :             : 
    5383                 :             : #if defined(POINTERS_EXTEND_UNSIGNED)
    5384                 :             :       /* If pointers extend signed and this is a pointer in Pmode, say that
    5385                 :             :          all the bits above ptr_mode are known to be sign bit copies.  */
    5386                 :             :       /* As we do not know which address space the pointer is referring to,
    5387                 :             :          we can do this only if the target does not support different pointer
    5388                 :             :          or address modes depending on the address space.  */
    5389                 :   159940030 :       if (target_default_pointer_address_modes_p ()
    5390                 :             :           && ! POINTERS_EXTEND_UNSIGNED && xmode == Pmode
    5391                 :             :           && mode == Pmode && REG_POINTER (x)
    5392                 :             :           && !targetm.have_ptr_extend ())
    5393                 :             :         return GET_MODE_PRECISION (Pmode) - GET_MODE_PRECISION (ptr_mode) + 1;
    5394                 :             : #endif
    5395                 :             : 
    5396                 :   159940030 :       {
    5397                 :   159940030 :         unsigned int copies_for_hook = 1, copies = 1;
    5398                 :   159940030 :         rtx new_rtx = rtl_hooks.reg_num_sign_bit_copies (x, xmode, mode,
    5399                 :             :                                                          &copies_for_hook);
    5400                 :             : 
    5401                 :   159940030 :         if (new_rtx)
    5402                 :           5 :           copies = cached_num_sign_bit_copies (new_rtx, mode, known_x,
    5403                 :             :                                                known_mode, known_ret);
    5404                 :             : 
    5405                 :   159940030 :         if (copies > 1 || copies_for_hook > 1)
    5406                 :    24420085 :           return MAX (copies, copies_for_hook);
    5407                 :             : 
    5408                 :             :         /* Else, use nonzero_bits to guess num_sign_bit_copies (see below).  */
    5409                 :             :       }
    5410                 :   135519945 :       break;
    5411                 :             : 
    5412                 :             :     case MEM:
    5413                 :             :       /* Some RISC machines sign-extend all loads of smaller than a word.  */
    5414                 :             :       if (load_extend_op (xmode) == SIGN_EXTEND)
    5415                 :             :         return MAX (1, ((int) bitwidth - (int) xmode_width + 1));
    5416                 :             :       break;
    5417                 :             : 
    5418                 :    20914357 :     case SUBREG:
    5419                 :             :       /* If this is a SUBREG for a promoted object that is sign-extended
    5420                 :             :          and we are looking at it in a wider mode, we know that at least the
    5421                 :             :          high-order bits are known to be sign bit copies.  */
    5422                 :             : 
    5423                 :    20914357 :       if (SUBREG_PROMOTED_VAR_P (x) && SUBREG_PROMOTED_SIGNED_P (x))
    5424                 :             :         {
    5425                 :           0 :           num0 = cached_num_sign_bit_copies (SUBREG_REG (x), mode,
    5426                 :             :                                              known_x, known_mode, known_ret);
    5427                 :           0 :           return MAX ((int) bitwidth - (int) xmode_width + 1, num0);
    5428                 :             :         }
    5429                 :             : 
    5430                 :    20914357 :       if (is_a <scalar_int_mode> (GET_MODE (SUBREG_REG (x)), &inner_mode))
    5431                 :             :         {
    5432                 :             :           /* For a smaller object, just ignore the high bits.  */
    5433                 :    20706192 :           if (bitwidth <= GET_MODE_PRECISION (inner_mode))
    5434                 :             :             {
    5435                 :     7277449 :               num0 = cached_num_sign_bit_copies (SUBREG_REG (x), inner_mode,
    5436                 :             :                                                  known_x, known_mode,
    5437                 :             :                                                  known_ret);
    5438                 :     7277449 :               return MAX (1, num0 - (int) (GET_MODE_PRECISION (inner_mode)
    5439                 :             :                                            - bitwidth));
    5440                 :             :             }
    5441                 :             : 
    5442                 :             :           /* For paradoxical SUBREGs on machines where all register operations
    5443                 :             :              affect the entire register, just look inside.  Note that we are
    5444                 :             :              passing MODE to the recursive call, so the number of sign bit
    5445                 :             :              copies will remain relative to that mode, not the inner mode.
    5446                 :             : 
    5447                 :             :              This works only if loads sign extend.  Otherwise, if we get a
    5448                 :             :              reload for the inner part, it may be loaded from the stack, and
    5449                 :             :              then we lose all sign bit copies that existed before the store
    5450                 :             :              to the stack.  */
    5451                 :             :           if (WORD_REGISTER_OPERATIONS
    5452                 :             :               && load_extend_op (inner_mode) == SIGN_EXTEND
    5453                 :             :               && paradoxical_subreg_p (x)
    5454                 :             :               && MEM_P (SUBREG_REG (x)))
    5455                 :             :             return cached_num_sign_bit_copies (SUBREG_REG (x), mode,
    5456                 :             :                                                known_x, known_mode, known_ret);
    5457                 :             :         }
    5458                 :             :       break;
    5459                 :             : 
    5460                 :        2749 :     case SIGN_EXTRACT:
    5461                 :        2749 :       if (CONST_INT_P (XEXP (x, 1)))
    5462                 :        2749 :         return MAX (1, (int) bitwidth - INTVAL (XEXP (x, 1)));
    5463                 :             :       break;
    5464                 :             : 
    5465                 :     1868089 :     case SIGN_EXTEND:
    5466                 :     1868089 :       if (is_a <scalar_int_mode> (GET_MODE (XEXP (x, 0)), &inner_mode))
    5467                 :     1868089 :         return (bitwidth - GET_MODE_PRECISION (inner_mode)
    5468                 :     1868089 :                 + cached_num_sign_bit_copies (XEXP (x, 0), inner_mode,
    5469                 :     1868089 :                                               known_x, known_mode, known_ret));
    5470                 :             :       break;
    5471                 :             : 
    5472                 :         306 :     case TRUNCATE:
    5473                 :             :       /* For a smaller object, just ignore the high bits.  */
    5474                 :         306 :       inner_mode = as_a <scalar_int_mode> (GET_MODE (XEXP (x, 0)));
    5475                 :         306 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), inner_mode,
    5476                 :             :                                          known_x, known_mode, known_ret);
    5477                 :         306 :       return MAX (1, (num0 - (int) (GET_MODE_PRECISION (inner_mode)
    5478                 :             :                                     - bitwidth)));
    5479                 :             : 
    5480                 :     1045772 :     case NOT:
    5481                 :     1045772 :       return cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5482                 :     1045772 :                                          known_x, known_mode, known_ret);
    5483                 :             : 
    5484                 :       20668 :     case ROTATE:       case ROTATERT:
    5485                 :             :       /* If we are rotating left by a number of bits less than the number
    5486                 :             :          of sign bit copies, we can just subtract that amount from the
    5487                 :             :          number.  */
    5488                 :       20668 :       if (CONST_INT_P (XEXP (x, 1))
    5489                 :       11429 :           && INTVAL (XEXP (x, 1)) >= 0
    5490                 :       11426 :           && INTVAL (XEXP (x, 1)) < (int) bitwidth)
    5491                 :             :         {
    5492                 :       11426 :           num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5493                 :             :                                              known_x, known_mode, known_ret);
    5494                 :       11426 :           return MAX (1, num0 - (code == ROTATE ? INTVAL (XEXP (x, 1))
    5495                 :             :                                  : (int) bitwidth - INTVAL (XEXP (x, 1))));
    5496                 :             :         }
    5497                 :             :       break;
    5498                 :             : 
    5499                 :      720589 :     case NEG:
    5500                 :             :       /* In general, this subtracts one sign bit copy.  But if the value
    5501                 :             :          is known to be positive, the number of sign bit copies is the
    5502                 :             :          same as that of the input.  Finally, if the input has just one bit
    5503                 :             :          that might be nonzero, all the bits are copies of the sign bit.  */
    5504                 :      720589 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5505                 :             :                                          known_x, known_mode, known_ret);
    5506                 :      720589 :       if (bitwidth > HOST_BITS_PER_WIDE_INT)
    5507                 :       30521 :         return num0 > 1 ? num0 - 1 : 1;
    5508                 :             : 
    5509                 :      690068 :       nonzero = nonzero_bits (XEXP (x, 0), mode);
    5510                 :      690068 :       if (nonzero == 1)
    5511                 :             :         return bitwidth;
    5512                 :             : 
    5513                 :      344035 :       if (num0 > 1
    5514                 :       82089 :           && ((HOST_WIDE_INT_1U << (bitwidth - 1)) & nonzero))
    5515                 :       43888 :         num0--;
    5516                 :             : 
    5517                 :      344035 :       return num0;
    5518                 :             : 
    5519                 :     5909820 :     case IOR:   case AND:   case XOR:
    5520                 :     5909820 :     case SMIN:  case SMAX:  case UMIN:  case UMAX:
    5521                 :             :       /* Logical operations will preserve the number of sign-bit copies.
    5522                 :             :          MIN and MAX operations always return one of the operands.  */
    5523                 :     5909820 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5524                 :             :                                          known_x, known_mode, known_ret);
    5525                 :     5909820 :       num1 = cached_num_sign_bit_copies (XEXP (x, 1), mode,
    5526                 :             :                                          known_x, known_mode, known_ret);
    5527                 :             : 
    5528                 :             :       /* If num1 is clearing some of the top bits then regardless of
    5529                 :             :          the other term, we are guaranteed to have at least that many
    5530                 :             :          high-order zero bits.  */
    5531                 :     5909820 :       if (code == AND
    5532                 :     5909820 :           && num1 > 1
    5533                 :     2552306 :           && bitwidth <= HOST_BITS_PER_WIDE_INT
    5534                 :     2536999 :           && CONST_INT_P (XEXP (x, 1))
    5535                 :     2347907 :           && (UINTVAL (XEXP (x, 1))
    5536                 :     2347907 :               & (HOST_WIDE_INT_1U << (bitwidth - 1))) == 0)
    5537                 :             :         return num1;
    5538                 :             : 
    5539                 :             :       /* Similarly for IOR when setting high-order bits.  */
    5540                 :     4205592 :       if (code == IOR
    5541                 :     4205592 :           && num1 > 1
    5542                 :      488014 :           && bitwidth <= HOST_BITS_PER_WIDE_INT
    5543                 :      486172 :           && CONST_INT_P (XEXP (x, 1))
    5544                 :      148816 :           && (UINTVAL (XEXP (x, 1))
    5545                 :      148816 :               & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0)
    5546                 :             :         return num1;
    5547                 :             : 
    5548                 :     4199223 :       return MIN (num0, num1);
    5549                 :             : 
    5550                 :    41440710 :     case PLUS:  case MINUS:
    5551                 :             :       /* For addition and subtraction, we can have a 1-bit carry.  However,
    5552                 :             :          if we are subtracting 1 from a positive number, there will not
    5553                 :             :          be such a carry.  Furthermore, if the positive number is known to
    5554                 :             :          be 0 or 1, we know the result is either -1 or 0.  */
    5555                 :             : 
    5556                 :    41440710 :       if (code == PLUS && XEXP (x, 1) == constm1_rtx
    5557                 :     1313452 :           && bitwidth <= HOST_BITS_PER_WIDE_INT)
    5558                 :             :         {
    5559                 :     1308964 :           nonzero = nonzero_bits (XEXP (x, 0), mode);
    5560                 :     1308964 :           if (((HOST_WIDE_INT_1U << (bitwidth - 1)) & nonzero) == 0)
    5561                 :      136798 :             return (nonzero == 1 || nonzero == 0 ? bitwidth
    5562                 :      132405 :                     : bitwidth - floor_log2 (nonzero) - 1);
    5563                 :             :         }
    5564                 :             : 
    5565                 :    41303912 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5566                 :             :                                          known_x, known_mode, known_ret);
    5567                 :    41303912 :       num1 = cached_num_sign_bit_copies (XEXP (x, 1), mode,
    5568                 :             :                                          known_x, known_mode, known_ret);
    5569                 :    41303912 :       result = MAX (1, MIN (num0, num1) - 1);
    5570                 :             : 
    5571                 :    41303912 :       return result;
    5572                 :             : 
    5573                 :     1448504 :     case MULT:
    5574                 :             :       /* The number of bits of the product is the sum of the number of
    5575                 :             :          bits of both terms.  However, unless one of the terms if known
    5576                 :             :          to be positive, we must allow for an additional bit since negating
    5577                 :             :          a negative number can remove one sign bit copy.  */
    5578                 :             : 
    5579                 :     1448504 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5580                 :             :                                          known_x, known_mode, known_ret);
    5581                 :     1448504 :       num1 = cached_num_sign_bit_copies (XEXP (x, 1), mode,
    5582                 :             :                                          known_x, known_mode, known_ret);
    5583                 :             : 
    5584                 :     1448504 :       result = bitwidth - (bitwidth - num0) - (bitwidth - num1);
    5585                 :     1448504 :       if (result > 0
    5586                 :     1448504 :           && (bitwidth > HOST_BITS_PER_WIDE_INT
    5587                 :      485568 :               || (((nonzero_bits (XEXP (x, 0), mode)
    5588                 :      485568 :                     & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0)
    5589                 :      203565 :                   && ((nonzero_bits (XEXP (x, 1), mode)
    5590                 :             :                        & (HOST_WIDE_INT_1U << (bitwidth - 1)))
    5591                 :      203565 :                       != 0))))
    5592                 :       29158 :         result--;
    5593                 :             : 
    5594                 :     1448504 :       return MAX (1, result);
    5595                 :             : 
    5596                 :      125286 :     case UDIV:
    5597                 :             :       /* The result must be <= the first operand.  If the first operand
    5598                 :             :          has the high bit set, we know nothing about the number of sign
    5599                 :             :          bit copies.  */
    5600                 :      125286 :       if (bitwidth > HOST_BITS_PER_WIDE_INT)
    5601                 :             :         return 1;
    5602                 :      125286 :       else if ((nonzero_bits (XEXP (x, 0), mode)
    5603                 :      125286 :                 & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0)
    5604                 :             :         return 1;
    5605                 :             :       else
    5606                 :       21935 :         return cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5607                 :       21935 :                                            known_x, known_mode, known_ret);
    5608                 :             : 
    5609                 :      112441 :     case UMOD:
    5610                 :             :       /* The result must be <= the second operand.  If the second operand
    5611                 :             :          has (or just might have) the high bit set, we know nothing about
    5612                 :             :          the number of sign bit copies.  */
    5613                 :      112441 :       if (bitwidth > HOST_BITS_PER_WIDE_INT)
    5614                 :             :         return 1;
    5615                 :      112441 :       else if ((nonzero_bits (XEXP (x, 1), mode)
    5616                 :      112441 :                 & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0)
    5617                 :             :         return 1;
    5618                 :             :       else
    5619                 :       29107 :         return cached_num_sign_bit_copies (XEXP (x, 1), mode,
    5620                 :       29107 :                                            known_x, known_mode, known_ret);
    5621                 :             : 
    5622                 :      186715 :     case DIV:
    5623                 :             :       /* Similar to unsigned division, except that we have to worry about
    5624                 :             :          the case where the divisor is negative, in which case we have
    5625                 :             :          to add 1.  */
    5626                 :      186715 :       result = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5627                 :             :                                            known_x, known_mode, known_ret);
    5628                 :      186715 :       if (result > 1
    5629                 :      186715 :           && (bitwidth > HOST_BITS_PER_WIDE_INT
    5630                 :       17578 :               || (nonzero_bits (XEXP (x, 1), mode)
    5631                 :       17578 :                   & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0))
    5632                 :       14751 :         result--;
    5633                 :             : 
    5634                 :      186715 :       return result;
    5635                 :             : 
    5636                 :      113926 :     case MOD:
    5637                 :      113926 :       result = cached_num_sign_bit_copies (XEXP (x, 1), mode,
    5638                 :             :                                            known_x, known_mode, known_ret);
    5639                 :      113926 :       if (result > 1
    5640                 :      113926 :           && (bitwidth > HOST_BITS_PER_WIDE_INT
    5641                 :       22421 :               || (nonzero_bits (XEXP (x, 1), mode)
    5642                 :       22421 :                   & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0))
    5643                 :        9503 :         result--;
    5644                 :             : 
    5645                 :      113926 :       return result;
    5646                 :             : 
    5647                 :      970437 :     case ASHIFTRT:
    5648                 :             :       /* Shifts by a constant add to the number of bits equal to the
    5649                 :             :          sign bit.  */
    5650                 :      970437 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5651                 :             :                                          known_x, known_mode, known_ret);
    5652                 :      970437 :       if (CONST_INT_P (XEXP (x, 1))
    5653                 :      934627 :           && INTVAL (XEXP (x, 1)) > 0
    5654                 :      934627 :           && INTVAL (XEXP (x, 1)) < xmode_width)
    5655                 :      934627 :         num0 = MIN ((int) bitwidth, num0 + INTVAL (XEXP (x, 1)));
    5656                 :             : 
    5657                 :      970437 :       return num0;
    5658                 :             : 
    5659                 :     8890732 :     case ASHIFT:
    5660                 :             :       /* Left shifts destroy copies.  */
    5661                 :     8890732 :       if (!CONST_INT_P (XEXP (x, 1))
    5662                 :     8726417 :           || INTVAL (XEXP (x, 1)) < 0
    5663                 :     8726273 :           || INTVAL (XEXP (x, 1)) >= (int) bitwidth
    5664                 :     8726231 :           || INTVAL (XEXP (x, 1)) >= xmode_width)
    5665                 :             :         return 1;
    5666                 :             : 
    5667                 :     8726231 :       num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode,
    5668                 :             :                                          known_x, known_mode, known_ret);
    5669                 :     8726231 :       return MAX (1, num0 - INTVAL (XEXP (x, 1)));
    5670                 :             : 
    5671                 :      653751 :     case IF_THEN_ELSE:
    5672                 :      653751 :       num0 = cached_num_sign_bit_copies (XEXP (x, 1), mode,
    5673                 :             :                                          known_x, known_mode, known_ret);
    5674                 :      653751 :       num1 = cached_num_sign_bit_copies (XEXP (x, 2), mode,
    5675                 :             :                                          known_x, known_mode, known_ret);
    5676                 :      653751 :       return MIN (num0, num1);
    5677                 :             : 
    5678                 :     2272549 :     case EQ:  case NE:  case GE:  case GT:  case LE:  case LT:
    5679                 :     2272549 :     case UNEQ:  case LTGT:  case UNGE:  case UNGT:  case UNLE:  case UNLT:
    5680                 :     2272549 :     case GEU: case GTU: case LEU: case LTU:
    5681                 :     2272549 :     case UNORDERED: case ORDERED:
    5682                 :             :       /* If the constant is negative, take its 1's complement and remask.
    5683                 :             :          Then see how many zero bits we have.  */
    5684                 :     2272549 :       nonzero = STORE_FLAG_VALUE;
    5685                 :     2272549 :       if (bitwidth <= HOST_BITS_PER_WIDE_INT
    5686                 :     2272549 :           && (nonzero & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0)
    5687                 :           0 :         nonzero = (~nonzero) & GET_MODE_MASK (mode);
    5688                 :             : 
    5689                 :     2272549 :       return (nonzero == 0 ? bitwidth : bitwidth - floor_log2 (nonzero) - 1);
    5690                 :             : 
    5691                 :             :     default:
    5692                 :             :       break;
    5693                 :             :     }
    5694                 :             : 
    5695                 :             :   /* If we haven't been able to figure it out by one of the above rules,
    5696                 :             :      see if some of the high-order bits are known to be zero.  If so,
    5697                 :             :      count those bits and return one less than that amount.  If we can't
    5698                 :             :      safely compute the mask for this mode, always return BITWIDTH.  */
    5699                 :             : 
    5700                 :   205911460 :   bitwidth = GET_MODE_PRECISION (mode);
    5701                 :   205911460 :   if (bitwidth > HOST_BITS_PER_WIDE_INT)
    5702                 :             :     return 1;
    5703                 :             : 
    5704                 :   199593319 :   nonzero = nonzero_bits (x, mode);
    5705                 :   199593319 :   return nonzero & (HOST_WIDE_INT_1U << (bitwidth - 1))
    5706                 :   205067659 :          ? 1 : bitwidth - floor_log2 (nonzero) - 1;
    5707                 :             : }
    5708                 :             : 
    5709                 :             : /* Calculate the rtx_cost of a single instruction pattern.  A return value of
    5710                 :             :    zero indicates an instruction pattern without a known cost.  */
    5711                 :             : 
    5712                 :             : int
    5713                 :   147361459 : pattern_cost (rtx pat, bool speed)
    5714                 :             : {
    5715                 :   147361459 :   int i, cost;
    5716                 :   147361459 :   rtx set;
    5717                 :             : 
    5718                 :             :   /* Extract the single set rtx from the instruction pattern.  We
    5719                 :             :      can't use single_set since we only have the pattern.  We also
    5720                 :             :      consider PARALLELs of a normal set and a single comparison.  In
    5721                 :             :      that case we use the cost of the non-comparison SET operation,
    5722                 :             :      which is most-likely to be the real cost of this operation.  */
    5723                 :   147361459 :   if (GET_CODE (pat) == SET)
    5724                 :             :     set = pat;
    5725                 :    66486326 :   else if (GET_CODE (pat) == PARALLEL)
    5726                 :             :     {
    5727                 :             :       set = NULL_RTX;
    5728                 :             :       rtx comparison = NULL_RTX;
    5729                 :             : 
    5730                 :    46271775 :       for (i = 0; i < XVECLEN (pat, 0); i++)
    5731                 :             :         {
    5732                 :    31149987 :           rtx x = XVECEXP (pat, 0, i);
    5733                 :    31149987 :           if (GET_CODE (x) == SET)
    5734                 :             :             {
    5735                 :    15736903 :               if (GET_CODE (SET_SRC (x)) == COMPARE)
    5736                 :             :                 {
    5737                 :      266735 :                   if (comparison)
    5738                 :             :                     return 0;
    5739                 :             :                   comparison = x;
    5740                 :             :                 }
    5741                 :             :               else
    5742                 :             :                 {
    5743                 :    15470168 :                   if (set)
    5744                 :             :                     return 0;
    5745                 :             :                   set = x;
    5746                 :             :                 }
    5747                 :             :             }
    5748                 :             :         }
    5749                 :             : 
    5750                 :    15121788 :       if (!set && comparison)
    5751                 :             :         set = comparison;
    5752                 :             : 
    5753                 :    15000413 :       if (!set)
    5754                 :             :         return 0;
    5755                 :             :     }
    5756                 :             :   else
    5757                 :             :     return 0;
    5758                 :             : 
    5759                 :    95925948 :   cost = set_src_cost (SET_SRC (set), GET_MODE (SET_DEST (set)), speed);
    5760                 :    95925948 :   return MAX (COSTS_N_INSNS (1), cost);
    5761                 :             : }
    5762                 :             : 
    5763                 :             : /* Calculate the cost of a single instruction.  A return value of zero
    5764                 :             :    indicates an instruction pattern without a known cost.  */
    5765                 :             : 
    5766                 :             : int
    5767                 :   145161514 : insn_cost (rtx_insn *insn, bool speed)
    5768                 :             : {
    5769                 :   145161514 :   if (targetm.insn_cost)
    5770                 :   145161514 :     return targetm.insn_cost (insn, speed);
    5771                 :             : 
    5772                 :           0 :   return pattern_cost (PATTERN (insn), speed);
    5773                 :             : }
    5774                 :             : 
    5775                 :             : /* Returns estimate on cost of computing SEQ.  */
    5776                 :             : 
    5777                 :             : unsigned
    5778                 :     2165951 : seq_cost (const rtx_insn *seq, bool speed)
    5779                 :             : {
    5780                 :     2165951 :   unsigned cost = 0;
    5781                 :     2165951 :   rtx set;
    5782                 :             : 
    5783                 :     5946256 :   for (; seq; seq = NEXT_INSN (seq))
    5784                 :             :     {
    5785                 :     3780305 :       set = single_set (seq);
    5786                 :     3780305 :       if (set)
    5787                 :     3768880 :         cost += set_rtx_cost (set, speed);
    5788                 :       11425 :       else if (NONDEBUG_INSN_P (seq))
    5789                 :             :         {
    5790                 :       11176 :           int this_cost = insn_cost (CONST_CAST_RTX_INSN (seq), speed);
    5791                 :       11176 :           if (this_cost > 0)
    5792                 :        4107 :             cost += this_cost;
    5793                 :             :           else
    5794                 :        7069 :             cost++;
    5795                 :             :         }
    5796                 :             :     }
    5797                 :             : 
    5798                 :     2165951 :   return cost;
    5799                 :             : }
    5800                 :             : 
    5801                 :             : /* Given an insn INSN and condition COND, return the condition in a
    5802                 :             :    canonical form to simplify testing by callers.  Specifically:
    5803                 :             : 
    5804                 :             :    (1) The code will always be a comparison operation (EQ, NE, GT, etc.).
    5805                 :             :    (2) Both operands will be machine operands.
    5806                 :             :    (3) If an operand is a constant, it will be the second operand.
    5807                 :             :    (4) (LE x const) will be replaced with (LT x <const+1>) and similarly
    5808                 :             :        for GE, GEU, and LEU.
    5809                 :             : 
    5810                 :             :    If the condition cannot be understood, or is an inequality floating-point
    5811                 :             :    comparison which needs to be reversed, 0 will be returned.
    5812                 :             : 
    5813                 :             :    If REVERSE is nonzero, then reverse the condition prior to canonizing it.
    5814                 :             : 
    5815                 :             :    If EARLIEST is nonzero, it is a pointer to a place where the earliest
    5816                 :             :    insn used in locating the condition was found.  If a replacement test
    5817                 :             :    of the condition is desired, it should be placed in front of that
    5818                 :             :    insn and we will be sure that the inputs are still valid.
    5819                 :             : 
    5820                 :             :    If WANT_REG is nonzero, we wish the condition to be relative to that
    5821                 :             :    register, if possible.  Therefore, do not canonicalize the condition
    5822                 :             :    further.  If ALLOW_CC_MODE is nonzero, allow the condition returned
    5823                 :             :    to be a compare to a CC mode register.
    5824                 :             : 
    5825                 :             :    If VALID_AT_INSN_P, the condition must be valid at both *EARLIEST
    5826                 :             :    and at INSN.  */
    5827                 :             : 
    5828                 :             : rtx
    5829                 :    37349382 : canonicalize_condition (rtx_insn *insn, rtx cond, int reverse,
    5830                 :             :                         rtx_insn **earliest,
    5831                 :             :                         rtx want_reg, int allow_cc_mode, int valid_at_insn_p)
    5832                 :             : {
    5833                 :    37349382 :   enum rtx_code code;
    5834                 :    37349382 :   rtx_insn *prev = insn;
    5835                 :    37349382 :   const_rtx set;
    5836                 :    37349382 :   rtx tem;
    5837                 :    37349382 :   rtx op0, op1;
    5838                 :    37349382 :   int reverse_code = 0;
    5839                 :    37349382 :   machine_mode mode;
    5840                 :    37349382 :   basic_block bb = BLOCK_FOR_INSN (insn);
    5841                 :             : 
    5842                 :    37349382 :   code = GET_CODE (cond);
    5843                 :    37349382 :   mode = GET_MODE (cond);
    5844                 :    37349382 :   op0 = XEXP (cond, 0);
    5845                 :    37349382 :   op1 = XEXP (cond, 1);
    5846                 :             : 
    5847                 :    37349382 :   if (reverse)
    5848                 :     1920416 :     code = reversed_comparison_code (cond, insn);
    5849                 :    37349382 :   if (code == UNKNOWN)
    5850                 :             :     return 0;
    5851                 :             : 
    5852                 :    37349382 :   if (earliest)
    5853                 :    18050518 :     *earliest = insn;
    5854                 :             : 
    5855                 :             :   /* If we are comparing a register with zero, see if the register is set
    5856                 :             :      in the previous insn to a COMPARE or a comparison operation.  Perform
    5857                 :             :      the same tests as a function of STORE_FLAG_VALUE as find_comparison_args
    5858                 :             :      in cse.cc  */
    5859                 :             : 
    5860                 :    79417598 :   while ((GET_RTX_CLASS (code) == RTX_COMPARE
    5861                 :             :           || GET_RTX_CLASS (code) == RTX_COMM_COMPARE)
    5862                 :    79417598 :          && op1 == CONST0_RTX (GET_MODE (op0))
    5863                 :   139559329 :          && op0 != want_reg)
    5864                 :             :     {
    5865                 :             :       /* Set nonzero when we find something of interest.  */
    5866                 :    60141731 :       rtx x = 0;
    5867                 :             : 
    5868                 :             :       /* If this is a COMPARE, pick up the two things being compared.  */
    5869                 :    60141731 :       if (GET_CODE (op0) == COMPARE)
    5870                 :             :         {
    5871                 :           0 :           op1 = XEXP (op0, 1);
    5872                 :           0 :           op0 = XEXP (op0, 0);
    5873                 :           0 :           continue;
    5874                 :             :         }
    5875                 :    60141731 :       else if (!REG_P (op0))
    5876                 :             :         break;
    5877                 :             : 
    5878                 :             :       /* Go back to the previous insn.  Stop if it is not an INSN.  We also
    5879                 :             :          stop if it isn't a single set or if it has a REG_INC note because
    5880                 :             :          we don't want to bother dealing with it.  */
    5881                 :             : 
    5882                 :    55107846 :       prev = prev_nonnote_nondebug_insn (prev);
    5883                 :             : 
    5884                 :    55107846 :       if (prev == 0
    5885                 :    55008912 :           || !NONJUMP_INSN_P (prev)
    5886                 :             :           || FIND_REG_INC_NOTE (prev, NULL_RTX)
    5887                 :             :           /* In cfglayout mode, there do not have to be labels at the
    5888                 :             :              beginning of a block, or jumps at the end, so the previous
    5889                 :             :              conditions would not stop us when we reach bb boundary.  */
    5890                 :   105031103 :           || BLOCK_FOR_INSN (prev) != bb)
    5891                 :             :         break;
    5892                 :             : 
    5893                 :    49819026 :       set = set_of (op0, prev);
    5894                 :             : 
    5895                 :    49819026 :       if (set
    5896                 :    49819026 :           && (GET_CODE (set) != SET
    5897                 :    43345835 :               || !rtx_equal_p (SET_DEST (set), op0)))
    5898                 :             :         break;
    5899                 :             : 
    5900                 :             :       /* If this is setting OP0, get what it sets it to if it looks
    5901                 :             :          relevant.  */
    5902                 :    49720292 :       if (set)
    5903                 :             :         {
    5904                 :    43247101 :           machine_mode inner_mode = GET_MODE (SET_DEST (set));
    5905                 :             : #ifdef FLOAT_STORE_FLAG_VALUE
    5906                 :             :           REAL_VALUE_TYPE fsfv;
    5907                 :             : #endif
    5908                 :             : 
    5909                 :             :           /* ??? We may not combine comparisons done in a CCmode with
    5910                 :             :              comparisons not done in a CCmode.  This is to aid targets
    5911                 :             :              like Alpha that have an IEEE compliant EQ instruction, and
    5912                 :             :              a non-IEEE compliant BEQ instruction.  The use of CCmode is
    5913                 :             :              actually artificial, simply to prevent the combination, but
    5914                 :             :              should not affect other platforms.
    5915                 :             : 
    5916                 :             :              However, we must allow VOIDmode comparisons to match either
    5917                 :             :              CCmode or non-CCmode comparison, because some ports have
    5918                 :             :              modeless comparisons inside branch patterns.
    5919                 :             : 
    5920                 :             :              ??? This mode check should perhaps look more like the mode check
    5921                 :             :              in simplify_comparison in combine.  */
    5922                 :    43247101 :           if (((GET_MODE_CLASS (mode) == MODE_CC)
    5923                 :    43247101 :                != (GET_MODE_CLASS (inner_mode) == MODE_CC))
    5924                 :    36707630 :               && mode != VOIDmode
    5925                 :           0 :               && inner_mode != VOIDmode)
    5926                 :             :             break;
    5927                 :    43247101 :           if (GET_CODE (SET_SRC (set)) == COMPARE
    5928                 :    43247101 :               || (((code == NE
    5929                 :     4715021 :                     || (code == LT
    5930                 :      158440 :                         && val_signbit_known_set_p (inner_mode,
    5931                 :             :                                                     STORE_FLAG_VALUE))
    5932                 :             : #ifdef FLOAT_STORE_FLAG_VALUE
    5933                 :             :                     || (code == LT
    5934                 :             :                         && SCALAR_FLOAT_MODE_P (inner_mode)
    5935                 :             :                         && (fsfv = FLOAT_STORE_FLAG_VALUE (inner_mode),
    5936                 :             :                             REAL_VALUE_NEGATIVE (fsfv)))
    5937                 :             : #endif
    5938                 :             :                     ))
    5939                 :     2861979 :                   && COMPARISON_P (SET_SRC (set))))
    5940                 :    36012159 :             x = SET_SRC (set);
    5941                 :     7234942 :           else if (((code == EQ
    5942                 :     4004824 :                      || (code == GE
    5943                 :      135800 :                          && val_signbit_known_set_p (inner_mode,
    5944                 :             :                                                      STORE_FLAG_VALUE))
    5945                 :             : #ifdef FLOAT_STORE_FLAG_VALUE
    5946                 :             :                      || (code == GE
    5947                 :             :                          && SCALAR_FLOAT_MODE_P (inner_mode)
    5948                 :             :                          && (fsfv = FLOAT_STORE_FLAG_VALUE (inner_mode),
    5949                 :             :                              REAL_VALUE_NEGATIVE (fsfv)))
    5950                 :             : #endif
    5951                 :             :                      ))
    5952                 :     7234942 :                    && COMPARISON_P (SET_SRC (set)))
    5953                 :             :             {
    5954                 :             :               reverse_code = 1;
    5955                 :             :               x = SET_SRC (set);
    5956                 :             :             }
    5957                 :     6878064 :           else if ((code == EQ || code == NE)
    5958                 :     5393161 :                    && GET_CODE (SET_SRC (set)) == XOR)
    5959                 :             :             /* Handle sequences like:
    5960                 :             : 
    5961                 :             :                (set op0 (xor X Y))
    5962                 :             :                ...(eq|ne op0 (const_int 0))...
    5963                 :             : 
    5964                 :             :                in which case:
    5965                 :             : 
    5966                 :             :                (eq op0 (const_int 0)) reduces to (eq X Y)
    5967                 :             :                (ne op0 (const_int 0)) reduces to (ne X Y)
    5968                 :             : 
    5969                 :             :                This is the form used by MIPS16, for example.  */
    5970                 :             :             x = SET_SRC (set);
    5971                 :             :           else
    5972                 :             :             break;
    5973                 :             :         }
    5974                 :             : 
    5975                 :     6473191 :       else if (reg_set_p (op0, prev))
    5976                 :             :         /* If this sets OP0, but not directly, we have to give up.  */
    5977                 :             :         break;
    5978                 :             : 
    5979                 :    42852260 :       if (x)
    5980                 :             :         {
    5981                 :             :           /* If the caller is expecting the condition to be valid at INSN,
    5982                 :             :              make sure X doesn't change before INSN.  */
    5983                 :    36379069 :           if (valid_at_insn_p)
    5984                 :    23263094 :             if (modified_in_p (x, prev) || modified_between_p (x, prev, insn))
    5985                 :             :               break;
    5986                 :    35595025 :           if (COMPARISON_P (x))
    5987                 :      137247 :             code = GET_CODE (x);
    5988                 :    35595025 :           if (reverse_code)
    5989                 :             :             {
    5990                 :       88683 :               code = reversed_comparison_code (x, prev);
    5991                 :       88683 :               if (code == UNKNOWN)
    5992                 :             :                 return 0;
    5993                 :             :               reverse_code = 0;
    5994                 :             :             }
    5995                 :             : 
    5996                 :    35595025 :           op0 = XEXP (x, 0), op1 = XEXP (x, 1);
    5997                 :    35595025 :           if (earliest)
    5998                 :    17458293 :             *earliest = prev;
    5999                 :             :         }
    6000                 :             :     }
    6001                 :             : 
    6002                 :             :   /* If constant is first, put it last.  */
    6003                 :    37349382 :   if (CONSTANT_P (op0))
    6004                 :       25407 :     code = swap_condition (code), tem = op0, op0 = op1, op1 = tem;
    6005                 :             : 
    6006                 :             :   /* If OP0 is the result of a comparison, we weren't able to find what
    6007                 :             :      was really being compared, so fail.  */
    6008                 :    37349382 :   if (!allow_cc_mode
    6009                 :    20057747 :       && GET_MODE_CLASS (GET_MODE (op0)) == MODE_CC)
    6010                 :             :     return 0;
    6011                 :             : 
    6012                 :             :   /* Canonicalize any ordered comparison with integers involving equality
    6013                 :             :      if we can do computations in the relevant mode and we do not
    6014                 :             :      overflow.  */
    6015                 :             : 
    6016                 :    36136153 :   scalar_int_mode op0_mode;
    6017                 :    36136153 :   if (CONST_INT_P (op1)
    6018                 :    24745425 :       && is_a <scalar_int_mode> (GET_MODE (op0), &op0_mode)
    6019                 :    60286949 :       && GET_MODE_PRECISION (op0_mode) <= HOST_BITS_PER_WIDE_INT)
    6020                 :             :     {
    6021                 :    24119830 :       HOST_WIDE_INT const_val = INTVAL (op1);
    6022                 :    24119830 :       unsigned HOST_WIDE_INT uconst_val = const_val;
    6023                 :    24119830 :       unsigned HOST_WIDE_INT max_val
    6024                 :    24119830 :         = (unsigned HOST_WIDE_INT) GET_MODE_MASK (op0_mode);
    6025                 :             : 
    6026                 :    24119830 :       switch (code)
    6027                 :             :         {
    6028                 :      818553 :         case LE:
    6029                 :      818553 :           if ((unsigned HOST_WIDE_INT) const_val != max_val >> 1)
    6030                 :      818553 :             code = LT, op1 = gen_int_mode (const_val + 1, op0_mode);
    6031                 :             :           break;
    6032                 :             : 
    6033                 :             :         /* When cross-compiling, const_val might be sign-extended from
    6034                 :             :            BITS_PER_WORD to HOST_BITS_PER_WIDE_INT */
    6035                 :      314245 :         case GE:
    6036                 :      314245 :           if ((const_val & max_val)
    6037                 :      314245 :               != (HOST_WIDE_INT_1U << (GET_MODE_PRECISION (op0_mode) - 1)))
    6038                 :      314245 :             code = GT, op1 = gen_int_mode (const_val - 1, op0_mode);
    6039                 :             :           break;
    6040                 :             : 
    6041                 :      611387 :         case LEU:
    6042                 :      611387 :           if (uconst_val < max_val)
    6043                 :      596052 :             code = LTU, op1 = gen_int_mode (uconst_val + 1, op0_mode);
    6044                 :             :           break;
    6045                 :             : 
    6046                 :       65990 :         case GEU:
    6047                 :       65990 :           if (uconst_val != 0)
    6048                 :       65990 :             code = GTU, op1 = gen_int_mode (uconst_val - 1, op0_mode);
    6049                 :             :           break;
    6050                 :             : 
    6051                 :             :         default:
    6052                 :             :           break;
    6053                 :             :         }
    6054                 :             :     }
    6055                 :             : 
    6056                 :             :   /* We promised to return a comparison.  */
    6057                 :    36136153 :   rtx ret = gen_rtx_fmt_ee (code, VOIDmode, op0, op1);
    6058                 :    36136153 :   if (COMPARISON_P (ret))
    6059                 :             :     return ret;
    6060                 :             :   return 0;
    6061                 :             : }
    6062                 :             : 
    6063                 :             : /* Given a jump insn JUMP, return the condition that will cause it to branch
    6064                 :             :    to its JUMP_LABEL.  If the condition cannot be understood, or is an
    6065                 :             :    inequality floating-point comparison which needs to be reversed, 0 will
    6066                 :             :    be returned.
    6067                 :             : 
    6068                 :             :    If EARLIEST is nonzero, it is a pointer to a place where the earliest
    6069                 :             :    insn used in locating the condition was found.  If a replacement test
    6070                 :             :    of the condition is desired, it should be placed in front of that
    6071                 :             :    insn and we will be sure that the inputs are still valid.  If EARLIEST
    6072                 :             :    is null, the returned condition will be valid at INSN.
    6073                 :             : 
    6074                 :             :    If ALLOW_CC_MODE is nonzero, allow the condition returned to be a
    6075                 :             :    compare CC mode register.
    6076                 :             : 
    6077                 :             :    VALID_AT_INSN_P is the same as for canonicalize_condition.  */
    6078                 :             : 
    6079                 :             : rtx
    6080                 :    36769408 : get_condition (rtx_insn *jump, rtx_insn **earliest, int allow_cc_mode,
    6081                 :             :                int valid_at_insn_p)
    6082                 :             : {
    6083                 :    36769408 :   rtx cond;
    6084                 :    36769408 :   int reverse;
    6085                 :    36769408 :   rtx set;
    6086                 :             : 
    6087                 :             :   /* If this is not a standard conditional jump, we can't parse it.  */
    6088                 :    36769408 :   if (!JUMP_P (jump)
    6089                 :    36769408 :       || ! any_condjump_p (jump))
    6090                 :     3971743 :     return 0;
    6091                 :    32797665 :   set = pc_set (jump);
    6092                 :             : 
    6093                 :    32797665 :   cond = XEXP (SET_SRC (set), 0);
    6094                 :             : 
    6095                 :             :   /* If this branches to JUMP_LABEL when the condition is false, reverse
    6096                 :             :      the condition.  */
    6097                 :    32797665 :   reverse
    6098                 :    65595330 :     = GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF
    6099                 :    32797665 :       && label_ref_label (XEXP (SET_SRC (set), 2)) == JUMP_LABEL (jump);
    6100                 :             : 
    6101                 :    32797665 :   return canonicalize_condition (jump, cond, reverse, earliest, NULL_RTX,
    6102                 :    32797665 :                                  allow_cc_mode, valid_at_insn_p);
    6103                 :             : }
    6104                 :             : 
    6105                 :             : /* Initialize the table NUM_SIGN_BIT_COPIES_IN_REP based on
    6106                 :             :    TARGET_MODE_REP_EXTENDED.
    6107                 :             : 
    6108                 :             :    Note that we assume that the property of
    6109                 :             :    TARGET_MODE_REP_EXTENDED(B, C) is sticky to the integral modes
    6110                 :             :    narrower than mode B.  I.e., if A is a mode narrower than B then in
    6111                 :             :    order to be able to operate on it in mode B, mode A needs to
    6112                 :             :    satisfy the requirements set by the representation of mode B.  */
    6113                 :             : 
    6114                 :             : static void
    6115                 :      281080 : init_num_sign_bit_copies_in_rep (void)
    6116                 :             : {
    6117                 :      281080 :   opt_scalar_int_mode in_mode_iter;
    6118                 :      281080 :   scalar_int_mode mode;
    6119                 :             : 
    6120                 :     2248640 :   FOR_EACH_MODE_IN_CLASS (in_mode_iter, MODE_INT)
    6121                 :     7870240 :     FOR_EACH_MODE_UNTIL (mode, in_mode_iter.require ())
    6122                 :             :       {
    6123                 :     5902680 :         scalar_int_mode in_mode = in_mode_iter.require ();
    6124                 :     5902680 :         scalar_int_mode i;
    6125                 :             : 
    6126                 :             :         /* Currently, it is assumed that TARGET_MODE_REP_EXTENDED
    6127                 :             :            extends to the next widest mode.  */
    6128                 :     5902680 :         gcc_assert (targetm.mode_rep_extended (mode, in_mode) == UNKNOWN
    6129                 :             :                     || GET_MODE_WIDER_MODE (mode).require () == in_mode);
    6130                 :             : 
    6131                 :             :         /* We are in in_mode.  Count how many bits outside of mode
    6132                 :             :            have to be copies of the sign-bit.  */
    6133                 :    21643160 :         FOR_EACH_MODE (i, mode, in_mode)
    6134                 :             :           {
    6135                 :             :             /* This must always exist (for the last iteration it will be
    6136                 :             :                IN_MODE).  */
    6137                 :    15740480 :             scalar_int_mode wider = GET_MODE_WIDER_MODE (i).require ();
    6138                 :             : 
    6139                 :    15740480 :             if (targetm.mode_rep_extended (i, wider) == SIGN_EXTEND
    6140                 :             :                 /* We can only check sign-bit copies starting from the
    6141                 :             :                    top-bit.  In order to be able to check the bits we
    6142                 :             :                    have already seen we pretend that subsequent bits
    6143                 :             :                    have to be sign-bit copies too.  */
    6144                 :    15740480 :                 || num_sign_bit_copies_in_rep [in_mode][mode])
    6145                 :           0 :               num_sign_bit_copies_in_rep [in_mode][mode]
    6146                 :           0 :                 += GET_MODE_PRECISION (wider) - GET_MODE_PRECISION (i);
    6147                 :             :           }
    6148                 :             :       }
    6149                 :      281080 : }
    6150                 :             : 
    6151                 :             : /* Suppose that truncation from the machine mode of X to MODE is not a
    6152                 :             :    no-op.  See if there is anything special about X so that we can
    6153                 :             :    assume it already contains a truncated value of MODE.  */
    6154                 :             : 
    6155                 :             : bool
    6156                 :           0 : truncated_to_mode (machine_mode mode, const_rtx x)
    6157                 :             : {
    6158                 :             :   /* This register has already been used in MODE without explicit
    6159                 :             :      truncation.  */
    6160                 :           0 :   if (REG_P (x) && rtl_hooks.reg_truncated_to_mode (mode, x))
    6161                 :             :     return true;
    6162                 :             : 
    6163                 :             :   /* See if we already satisfy the requirements of MODE.  If yes we
    6164                 :             :      can just switch to MODE.  */
    6165                 :           0 :   if (num_sign_bit_copies_in_rep[GET_MODE (x)][mode]
    6166                 :           0 :       && (num_sign_bit_copies (x, GET_MODE (x))
    6167                 :           0 :           >= num_sign_bit_copies_in_rep[GET_MODE (x)][mode] + 1))
    6168                 :             :     return true;
    6169                 :             : 
    6170                 :             :   return false;
    6171                 :             : }
    6172                 :             : 
    6173                 :             : /* Return true if RTX code CODE has a single sequence of zero or more
    6174                 :             :    "e" operands and no rtvec operands.  Initialize its rtx_all_subrtx_bounds
    6175                 :             :    entry in that case.  */
    6176                 :             : 
    6177                 :             : static bool
    6178                 :    43286320 : setup_reg_subrtx_bounds (unsigned int code)
    6179                 :             : {
    6180                 :    43286320 :   const char *format = GET_RTX_FORMAT ((enum rtx_code) code);
    6181                 :    43286320 :   unsigned int i = 0;
    6182                 :    60994360 :   for (; format[i] != 'e'; ++i)
    6183                 :             :     {
    6184                 :    27264760 :       if (!format[i])
    6185                 :             :         /* No subrtxes.  Leave start and count as 0.  */
    6186                 :             :         return true;
    6187                 :    19956680 :       if (format[i] == 'E' || format[i] == 'V')
    6188                 :             :         return false;
    6189                 :             :     }
    6190                 :             : 
    6191                 :             :   /* Record the sequence of 'e's.  */
    6192                 :    33729600 :   rtx_all_subrtx_bounds[code].start = i;
    6193                 :    54810600 :   do
    6194                 :    54810600 :     ++i;
    6195                 :    54810600 :   while (format[i] == 'e');
    6196                 :    33729600 :   rtx_all_subrtx_bounds[code].count = i - rtx_all_subrtx_bounds[code].start;
    6197                 :             :   /* rtl-iter.h relies on this.  */
    6198                 :    33729600 :   gcc_checking_assert (rtx_all_subrtx_bounds[code].count <= 3);
    6199                 :             : 
    6200                 :    37664720 :   for (; format[i]; ++i)
    6201                 :     5340520 :     if (format[i] == 'E' || format[i] == 'V' || format[i] == 'e')
    6202                 :             :       return false;
    6203                 :             : 
    6204                 :             :   return true;
    6205                 :             : }
    6206                 :             : 
    6207                 :             : /* Initialize rtx_all_subrtx_bounds.  */
    6208                 :             : void
    6209                 :      281080 : init_rtlanal (void)
    6210                 :             : {
    6211                 :      281080 :   int i;
    6212                 :    43567400 :   for (i = 0; i < NUM_RTX_CODE; i++)
    6213                 :             :     {
    6214                 :    43286320 :       if (!setup_reg_subrtx_bounds (i))
    6215                 :     3654040 :         rtx_all_subrtx_bounds[i].count = UCHAR_MAX;
    6216                 :    43286320 :       if (GET_RTX_CLASS (i) != RTX_CONST_OBJ)
    6217                 :    40475520 :         rtx_nonconst_subrtx_bounds[i] = rtx_all_subrtx_bounds[i];
    6218                 :             :     }
    6219                 :             : 
    6220                 :      281080 :   init_num_sign_bit_copies_in_rep ();
    6221                 :      281080 : }
    6222                 :             : 
    6223                 :             : /* Check whether this is a constant pool constant.  */
    6224                 :             : bool
    6225                 :       11672 : constant_pool_constant_p (rtx x)
    6226                 :             : {
    6227                 :       11672 :   x = avoid_constant_pool_reference (x);
    6228                 :       11672 :   return CONST_DOUBLE_P (x);
    6229                 :             : }
    6230                 :             : 
    6231                 :             : /* If M is a bitmask that selects a field of low-order bits within an item but
    6232                 :             :    not the entire word, return the length of the field.  Return -1 otherwise.
    6233                 :             :    M is used in machine mode MODE.  */
    6234                 :             : 
    6235                 :             : int
    6236                 :        8482 : low_bitmask_len (machine_mode mode, unsigned HOST_WIDE_INT m)
    6237                 :             : {
    6238                 :        8482 :   if (mode != VOIDmode)
    6239                 :             :     {
    6240                 :        8482 :       if (!HWI_COMPUTABLE_MODE_P (mode))
    6241                 :             :         return -1;
    6242                 :        8482 :       m &= GET_MODE_MASK (mode);
    6243                 :             :     }
    6244                 :             : 
    6245                 :        8482 :   return exact_log2 (m + 1);
    6246                 :             : }
    6247                 :             : 
    6248                 :             : /* Return the mode of MEM's address.  */
    6249                 :             : 
    6250                 :             : scalar_int_mode
    6251                 :   174161205 : get_address_mode (rtx mem)
    6252                 :             : {
    6253                 :   174161205 :   machine_mode mode;
    6254                 :             : 
    6255                 :   174161205 :   gcc_assert (MEM_P (mem));
    6256                 :   174161205 :   mode = GET_MODE (XEXP (mem, 0));
    6257                 :   174161205 :   if (mode != VOIDmode)
    6258                 :   173659258 :     return as_a <scalar_int_mode> (mode);
    6259                 :      520659 :   return targetm.addr_space.address_mode (MEM_ADDR_SPACE (mem));
    6260                 :             : }
    6261                 :             : 
    6262                 :             : /* Split up a CONST_DOUBLE or integer constant rtx
    6263                 :             :    into two rtx's for single words,
    6264                 :             :    storing in *FIRST the word that comes first in memory in the target
    6265                 :             :    and in *SECOND the other.
    6266                 :             : 
    6267                 :             :    TODO: This function needs to be rewritten to work on any size
    6268                 :             :    integer.  */
    6269                 :             : 
    6270                 :             : void
    6271                 :           0 : split_double (rtx value, rtx *first, rtx *second)
    6272                 :             : {
    6273                 :           0 :   if (CONST_INT_P (value))
    6274                 :             :     {
    6275                 :           0 :       if (HOST_BITS_PER_WIDE_INT >= (2 * BITS_PER_WORD))
    6276                 :             :         {
    6277                 :             :           /* In this case the CONST_INT holds both target words.
    6278                 :             :              Extract the bits from it into two word-sized pieces.
    6279                 :             :              Sign extend each half to HOST_WIDE_INT.  */
    6280                 :           0 :           unsigned HOST_WIDE_INT low, high;
    6281                 :           0 :           unsigned HOST_WIDE_INT mask, sign_bit, sign_extend;
    6282                 :           0 :           unsigned bits_per_word = BITS_PER_WORD;
    6283                 :             : 
    6284                 :             :           /* Set sign_bit to the most significant bit of a word.  */
    6285                 :           0 :           sign_bit = 1;
    6286                 :           0 :           sign_bit <<= bits_per_word - 1;
    6287                 :             : 
    6288                 :             :           /* Set mask so that all bits of the word are set.  We could
    6289                 :             :              have used 1 << BITS_PER_WORD instead of basing the
    6290                 :             :              calculation on sign_bit.  However, on machines where
    6291                 :             :              HOST_BITS_PER_WIDE_INT == BITS_PER_WORD, it could cause a
    6292                 :             :              compiler warning, even though the code would never be
    6293                 :             :              executed.  */
    6294                 :           0 :           mask = sign_bit << 1;
    6295                 :           0 :           mask--;
    6296                 :             : 
    6297                 :             :           /* Set sign_extend as any remaining bits.  */
    6298                 :           0 :           sign_extend = ~mask;
    6299                 :             : 
    6300                 :             :           /* Pick the lower word and sign-extend it.  */
    6301                 :           0 :           low = INTVAL (value);
    6302                 :           0 :           low &= mask;
    6303                 :           0 :           if (low & sign_bit)
    6304                 :           0 :             low |= sign_extend;
    6305                 :             : 
    6306                 :             :           /* Pick the higher word, shifted to the least significant
    6307                 :             :              bits, and sign-extend it.  */
    6308                 :           0 :           high = INTVAL (value);
    6309                 :           0 :           high >>= bits_per_word - 1;
    6310                 :           0 :           high >>= 1;
    6311                 :           0 :           high &= mask;
    6312                 :           0 :           if (high & sign_bit)
    6313                 :           0 :             high |= sign_extend;
    6314                 :             : 
    6315                 :             :           /* Store the words in the target machine order.  */
    6316                 :           0 :           if (WORDS_BIG_ENDIAN)
    6317                 :             :             {
    6318                 :             :               *first = GEN_INT (high);
    6319                 :             :               *second = GEN_INT (low);
    6320                 :             :             }
    6321                 :             :           else
    6322                 :             :             {
    6323                 :           0 :               *first = GEN_INT (low);
    6324                 :           0 :               *second = GEN_INT (high);
    6325                 :             :             }
    6326                 :             :         }
    6327                 :             :       else
    6328                 :             :         {
    6329                 :             :           /* The rule for using CONST_INT for a wider mode
    6330                 :             :              is that we regard the value as signed.
    6331                 :             :              So sign-extend it.  */
    6332                 :           0 :           rtx high = (INTVAL (value) < 0 ? constm1_rtx : const0_rtx);
    6333                 :           0 :           if (WORDS_BIG_ENDIAN)
    6334                 :             :             {
    6335                 :             :               *first = high;
    6336                 :             :               *second = value;
    6337                 :             :             }
    6338                 :             :           else
    6339                 :             :             {
    6340                 :           0 :               *first = value;
    6341                 :           0 :               *second = high;
    6342                 :             :             }
    6343                 :             :         }
    6344                 :             :     }
    6345                 :           0 :   else if (GET_CODE (value) == CONST_WIDE_INT)
    6346                 :             :     {
    6347                 :             :       /* All of this is scary code and needs to be converted to
    6348                 :             :          properly work with any size integer.  */
    6349                 :           0 :       gcc_assert (CONST_WIDE_INT_NUNITS (value) == 2);
    6350                 :           0 :       if (WORDS_BIG_ENDIAN)
    6351                 :             :         {
    6352                 :             :           *first = GEN_INT (CONST_WIDE_INT_ELT (value, 1));
    6353                 :             :           *second = GEN_INT (CONST_WIDE_INT_ELT (value, 0));
    6354                 :             :         }
    6355                 :             :       else
    6356                 :             :         {
    6357                 :           0 :           *first = GEN_INT (CONST_WIDE_INT_ELT (value, 0));
    6358                 :           0 :           *second = GEN_INT (CONST_WIDE_INT_ELT (value, 1));
    6359                 :             :         }
    6360                 :             :     }
    6361                 :           0 :   else if (!CONST_DOUBLE_P (value))
    6362                 :             :     {
    6363                 :           0 :       if (WORDS_BIG_ENDIAN)
    6364                 :             :         {
    6365                 :             :           *first = const0_rtx;
    6366                 :             :           *second = value;
    6367                 :             :         }
    6368                 :             :       else
    6369                 :             :         {
    6370                 :           0 :           *first = value;
    6371                 :           0 :           *second = const0_rtx;
    6372                 :             :         }
    6373                 :             :     }
    6374                 :           0 :   else if (GET_MODE (value) == VOIDmode
    6375                 :             :            /* This is the old way we did CONST_DOUBLE integers.  */
    6376                 :           0 :            || GET_MODE_CLASS (GET_MODE (value)) == MODE_INT)
    6377                 :             :     {
    6378                 :             :       /* In an integer, the words are defined as most and least significant.
    6379                 :             :          So order them by the target's convention.  */
    6380                 :           0 :       if (WORDS_BIG_ENDIAN)
    6381                 :             :         {
    6382                 :             :           *first = GEN_INT (CONST_DOUBLE_HIGH (value));
    6383                 :             :           *second = GEN_INT (CONST_DOUBLE_LOW (value));
    6384                 :             :         }
    6385                 :             :       else
    6386                 :             :         {
    6387                 :           0 :           *first = GEN_INT (CONST_DOUBLE_LOW (value));
    6388                 :           0 :           *second = GEN_INT (CONST_DOUBLE_HIGH (value));
    6389                 :             :         }
    6390                 :             :     }
    6391                 :             :   else
    6392                 :             :     {
    6393                 :           0 :       long l[2];
    6394                 :             : 
    6395                 :             :       /* Note, this converts the REAL_VALUE_TYPE to the target's
    6396                 :             :          format, splits up the floating point double and outputs
    6397                 :             :          exactly 32 bits of it into each of l[0] and l[1] --
    6398                 :             :          not necessarily BITS_PER_WORD bits.  */
    6399                 :           0 :       REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (value), l);
    6400                 :             : 
    6401                 :             :       /* If 32 bits is an entire word for the target, but not for the host,
    6402                 :             :          then sign-extend on the host so that the number will look the same
    6403                 :             :          way on the host that it would on the target.  See for instance
    6404                 :             :          simplify_unary_operation.  The #if is needed to avoid compiler
    6405                 :             :          warnings.  */
    6406                 :             : 
    6407                 :             : #if HOST_BITS_PER_LONG > 32
    6408                 :           0 :       if (BITS_PER_WORD < HOST_BITS_PER_LONG && BITS_PER_WORD == 32)
    6409                 :             :         {
    6410                 :           0 :           if (l[0] & ((long) 1 << 31))
    6411                 :           0 :             l[0] |= ((unsigned long) (-1) << 32);
    6412                 :           0 :           if (l[1] & ((long) 1 << 31))
    6413                 :           0 :             l[1] |= ((unsigned long) (-1) << 32);
    6414                 :             :         }
    6415                 :             : #endif
    6416                 :             : 
    6417                 :           0 :       *first = GEN_INT (l[0]);
    6418                 :           0 :       *second = GEN_INT (l[1]);
    6419                 :             :     }
    6420                 :           0 : }
    6421                 :             : 
    6422                 :             : /* Return true if X is a sign_extract or zero_extract from the least
    6423                 :             :    significant bit.  */
    6424                 :             : 
    6425                 :             : static bool
    6426                 :   207393995 : lsb_bitfield_op_p (rtx x)
    6427                 :             : {
    6428                 :           0 :   if (GET_RTX_CLASS (GET_CODE (x)) == RTX_BITFIELD_OPS)
    6429                 :             :     {
    6430                 :           0 :       machine_mode mode = GET_MODE (XEXP (x, 0));
    6431                 :           0 :       HOST_WIDE_INT len = INTVAL (XEXP (x, 1));
    6432                 :           0 :       HOST_WIDE_INT pos = INTVAL (XEXP (x, 2));
    6433                 :           0 :       poly_int64 remaining_bits = GET_MODE_PRECISION (mode) - len;
    6434                 :             : 
    6435                 :           0 :       return known_eq (pos, BITS_BIG_ENDIAN ? remaining_bits : 0);
    6436                 :             :     }
    6437                 :             :   return false;
    6438                 :             : }
    6439                 :             : 
    6440                 :             : /* Strip outer address "mutations" from LOC and return a pointer to the
    6441                 :             :    inner value.  If OUTER_CODE is nonnull, store the code of the innermost
    6442                 :             :    stripped expression there.
    6443                 :             : 
    6444                 :             :    "Mutations" either convert between modes or apply some kind of
    6445                 :             :    extension, truncation or alignment.  */
    6446                 :             : 
    6447                 :             : rtx *
    6448                 :   207386432 : strip_address_mutations (rtx *loc, enum rtx_code *outer_code)
    6449                 :             : {
    6450                 :   207471518 :   for (;;)
    6451                 :             :     {
    6452                 :   207471518 :       enum rtx_code code = GET_CODE (*loc);
    6453                 :   207471518 :       if (GET_RTX_CLASS (code) == RTX_UNARY)
    6454                 :             :         /* Things like SIGN_EXTEND, ZERO_EXTEND and TRUNCATE can be
    6455                 :             :            used to convert between pointer sizes.  */
    6456                 :       77523 :         loc = &XEXP (*loc, 0);
    6457                 :   207393995 :       else if (lsb_bitfield_op_p (*loc))
    6458                 :             :         /* A [SIGN|ZERO]_EXTRACT from the least significant bit effectively
    6459                 :             :            acts as a combined truncation and extension.  */
    6460                 :           0 :         loc = &XEXP (*loc, 0);
    6461                 :   207393995 :       else if (code == AND && CONST_INT_P (XEXP (*loc, 1)))
    6462                 :             :         /* (and ... (const_int -X)) is used to align to X bytes.  */
    6463                 :        7549 :         loc = &XEXP (*loc, 0);
    6464                 :   207386446 :       else if (code == SUBREG
    6465                 :       39152 :                && (!OBJECT_P (SUBREG_REG (*loc))
    6466                 :       39148 :                    || CONSTANT_P (SUBREG_REG (*loc)))
    6467                 :   207386460 :                && subreg_lowpart_p (*loc))
    6468                 :             :         /* (subreg (operator ...) ...) inside AND is used for mode
    6469                 :             :            conversion too.  It is also used for load-address operations
    6470                 :             :            in which an extension can be done for free, such as:
    6471                 :             : 
    6472                 :             :              (zero_extend:DI
    6473                 :             :                (subreg:SI (plus:DI (reg:DI R) (symbol_ref:DI "foo") 0)))
    6474                 :             : 
    6475                 :             :            The latter usage also covers subregs of plain "displacements",
    6476                 :             :            such as:
    6477                 :             : 
    6478                 :             :              (zero_extend:DI (subreg:SI (symbol_ref:DI "foo") 0))
    6479                 :             : 
    6480                 :             :            The inner address should then be the symbol_ref, not the subreg,
    6481                 :             :            similarly to the plus case above.
    6482                 :             : 
    6483                 :             :            In contrast, the subreg in:
    6484                 :             : 
    6485                 :             :              (zero_extend:DI (subreg:SI (reg:DI R) 0))
    6486                 :             : 
    6487                 :             :            should be treated as the base, since it should be replaced by
    6488                 :             :            an SImode hard register during register allocation.  */
    6489                 :          14 :         loc = &SUBREG_REG (*loc);
    6490                 :             :       else
    6491                 :   207386432 :         return loc;
    6492                 :       85086 :       if (outer_code)
    6493                 :       85086 :         *outer_code = code;
    6494                 :             :     }
    6495                 :             : }
    6496                 :             : 
    6497                 :             : /* Return true if CODE applies some kind of scale.  The scaled value is
    6498                 :             :    is the first operand and the scale is the second.  */
    6499                 :             : 
    6500                 :             : static bool
    6501                 :    64743120 : binary_scale_code_p (enum rtx_code code)
    6502                 :             : {
    6503                 :    64743120 :   return (code == MULT
    6504                 :    64743120 :           || code == ASHIFT
    6505                 :             :           /* Needed by ARM targets.  */
    6506                 :             :           || code == ASHIFTRT
    6507                 :             :           || code == LSHIFTRT
    6508                 :    62572256 :           || code == ROTATE
    6509                 :    62572256 :           || code == ROTATERT);
    6510                 :             : }
    6511                 :             : 
    6512                 :             : /* Return true if X appears to be a valid base or index term.  */
    6513                 :             : static bool
    6514                 :   129486240 : valid_base_or_index_term_p (rtx x)
    6515                 :             : {
    6516                 :   129486240 :   if (GET_CODE (x) == SCRATCH)
    6517                 :             :     return true;
    6518                 :             :   /* Handle what appear to be eliminated forms of a register.  If we reach
    6519                 :             :      here, the elimination occurs outside of the outermost PLUS tree,
    6520                 :             :      and so the elimination offset cannot be treated as a displacement
    6521                 :             :      of the main address.  Instead, we need to treat the whole PLUS as
    6522                 :             :      the base or index term.  The address can only be made legitimate by
    6523                 :             :      reloading the PLUS.  */
    6524                 :   129486240 :   if (GET_CODE (x) == PLUS && CONST_SCALAR_INT_P (XEXP (x, 1)))
    6525                 :           0 :     x = XEXP (x, 0);
    6526                 :   129486240 :   if (GET_CODE (x) == SUBREG)
    6527                 :       60268 :     x = SUBREG_REG (x);
    6528                 :   129486240 :   return REG_P (x) || MEM_P (x);
    6529                 :             : }
    6530                 :             : 
    6531                 :             : /* If *INNER can be interpreted as a base, return a pointer to the inner term
    6532                 :             :    (see address_info).  Return null otherwise.  */
    6533                 :             : 
    6534                 :             : static rtx *
    6535                 :    64743120 : get_base_term (rtx *inner)
    6536                 :             : {
    6537                 :    64743120 :   if (GET_CODE (*inner) == LO_SUM)
    6538                 :           0 :     inner = strip_address_mutations (&XEXP (*inner, 0));
    6539                 :    64743120 :   if (valid_base_or_index_term_p (*inner))
    6540                 :    62572256 :     return inner;
    6541                 :             :   return 0;
    6542                 :             : }
    6543                 :             : 
    6544                 :             : /* If *INNER can be interpreted as an index, return a pointer to the inner term
    6545                 :             :    (see address_info).  Return null otherwise.  */
    6546                 :             : 
    6547                 :             : static rtx *
    6548                 :    64743120 : get_index_term (rtx *inner)
    6549                 :             : {
    6550                 :             :   /* At present, only constant scales are allowed.  */
    6551                 :    64743120 :   if (binary_scale_code_p (GET_CODE (*inner)) && CONSTANT_P (XEXP (*inner, 1)))
    6552                 :     2170864 :     inner = strip_address_mutations (&XEXP (*inner, 0));
    6553                 :    64743120 :   if (valid_base_or_index_term_p (*inner))
    6554                 :    64743120 :     return inner;
    6555                 :             :   return 0;
    6556                 :             : }
    6557                 :             : 
    6558                 :             : /* Set the segment part of address INFO to LOC, given that INNER is the
    6559                 :             :    unmutated value.  */
    6560                 :             : 
    6561                 :             : static void
    6562                 :          17 : set_address_segment (struct address_info *info, rtx *loc, rtx *inner)
    6563                 :             : {
    6564                 :          17 :   gcc_assert (!info->segment);
    6565                 :          17 :   info->segment = loc;
    6566                 :          17 :   info->segment_term = inner;
    6567                 :          17 : }
    6568                 :             : 
    6569                 :             : /* Set the base part of address INFO to LOC, given that INNER is the
    6570                 :             :    unmutated value.  */
    6571                 :             : 
    6572                 :             : static void
    6573                 :    63465139 : set_address_base (struct address_info *info, rtx *loc, rtx *inner)
    6574                 :             : {
    6575                 :    63465139 :   gcc_assert (!info->base);
    6576                 :    63465139 :   info->base = loc;
    6577                 :    63465139 :   info->base_term = inner;
    6578                 :    63465139 : }
    6579                 :             : 
    6580                 :             : /* Set the index part of address INFO to LOC, given that INNER is the
    6581                 :             :    unmutated value.  */
    6582                 :             : 
    6583                 :             : static void
    6584                 :     3359132 : set_address_index (struct address_info *info, rtx *loc, rtx *inner)
    6585                 :             : {
    6586                 :     3359132 :   gcc_assert (!info->index);
    6587                 :     3359132 :   info->index = loc;
    6588                 :     3359132 :   info->index_term = inner;
    6589                 :     3359132 : }
    6590                 :             : 
    6591                 :             : /* Set the displacement part of address INFO to LOC, given that INNER
    6592                 :             :    is the constant term.  */
    6593                 :             : 
    6594                 :             : static void
    6595                 :    64710263 : set_address_disp (struct address_info *info, rtx *loc, rtx *inner)
    6596                 :             : {
    6597                 :    64710263 :   gcc_assert (!info->disp);
    6598                 :    64710263 :   info->disp = loc;
    6599                 :    64710263 :   info->disp_term = inner;
    6600                 :    64710263 : }
    6601                 :             : 
    6602                 :             : /* INFO->INNER describes a {PRE,POST}_{INC,DEC} address.  Set up the
    6603                 :             :    rest of INFO accordingly.  */
    6604                 :             : 
    6605                 :             : static void
    6606                 :     1979498 : decompose_incdec_address (struct address_info *info)
    6607                 :             : {
    6608                 :     1979498 :   info->autoinc_p = true;
    6609                 :             : 
    6610                 :     1979498 :   rtx *base = &XEXP (*info->inner, 0);
    6611                 :     1979498 :   set_address_base (info, base, base);
    6612                 :     1979498 :   gcc_checking_assert (info->base == info->base_term);
    6613                 :             : 
    6614                 :             :   /* These addresses are only valid when the size of the addressed
    6615                 :             :      value is known.  */
    6616                 :     1979498 :   gcc_checking_assert (info->mode != VOIDmode);
    6617                 :     1979498 : }
    6618                 :             : 
    6619                 :             : /* INFO->INNER describes a {PRE,POST}_MODIFY address.  Set up the rest
    6620                 :             :    of INFO accordingly.  */
    6621                 :             : 
    6622                 :             : static void
    6623                 :      101653 : decompose_automod_address (struct address_info *info)
    6624                 :             : {
    6625                 :      101653 :   info->autoinc_p = true;
    6626                 :             : 
    6627                 :      101653 :   rtx *base = &XEXP (*info->inner, 0);
    6628                 :      101653 :   set_address_base (info, base, base);
    6629                 :      101653 :   gcc_checking_assert (info->base == info->base_term);
    6630                 :             : 
    6631                 :      101653 :   rtx plus = XEXP (*info->inner, 1);
    6632                 :      101653 :   gcc_assert (GET_CODE (plus) == PLUS);
    6633                 :             : 
    6634                 :      101653 :   info->base_term2 = &XEXP (plus, 0);
    6635                 :      101653 :   gcc_checking_assert (rtx_equal_p (*info->base_term, *info->base_term2));
    6636                 :             : 
    6637                 :      101653 :   rtx *step = &XEXP (plus, 1);
    6638                 :      101653 :   rtx *inner_step = strip_address_mutations (step);
    6639                 :      101653 :   if (CONSTANT_P (*inner_step))
    6640                 :      101653 :     set_address_disp (info, step, inner_step);
    6641                 :             :   else
    6642                 :           0 :     set_address_index (info, step, inner_step);
    6643                 :      101653 : }
    6644                 :             : 
    6645                 :             : /* Treat *LOC as a tree of PLUS operands and store pointers to the summed
    6646                 :             :    values in [PTR, END).  Return a pointer to the end of the used array.  */
    6647                 :             : 
    6648                 :             : static rtx **
    6649                 :   129351747 : extract_plus_operands (rtx *loc, rtx **ptr, rtx **end)
    6650                 :             : {
    6651                 :   185022477 :   rtx x = *loc;
    6652                 :   185022477 :   if (GET_CODE (x) == PLUS)
    6653                 :             :     {
    6654                 :    55670730 :       ptr = extract_plus_operands (&XEXP (x, 0), ptr, end);
    6655                 :    55670730 :       ptr = extract_plus_operands (&XEXP (x, 1), ptr, end);
    6656                 :             :     }
    6657                 :             :   else
    6658                 :             :     {
    6659                 :   129351747 :       gcc_assert (ptr != end);
    6660                 :   129351747 :       *ptr++ = loc;
    6661                 :             :     }
    6662                 :   129351747 :   return ptr;
    6663                 :             : }
    6664                 :             : 
    6665                 :             : /* Evaluate the likelihood of X being a base or index value, returning
    6666                 :             :    positive if it is likely to be a base, negative if it is likely to be
    6667                 :             :    an index, and 0 if we can't tell.  Make the magnitude of the return
    6668                 :             :    value reflect the amount of confidence we have in the answer.
    6669                 :             : 
    6670                 :             :    MODE, AS, OUTER_CODE and INDEX_CODE are as for ok_for_base_p_1.  */
    6671                 :             : 
    6672                 :             : static int
    6673                 :     2376536 : baseness (rtx x, machine_mode mode, addr_space_t as,
    6674                 :             :           enum rtx_code outer_code, enum rtx_code index_code)
    6675                 :             : {
    6676                 :             :   /* Believe *_POINTER unless the address shape requires otherwise.  */
    6677                 :     2376536 :   if (REG_P (x) && REG_POINTER (x))
    6678                 :             :     return 2;
    6679                 :     1367184 :   if (MEM_P (x) && MEM_POINTER (x))
    6680                 :             :     return 2;
    6681                 :             : 
    6682                 :     1367184 :   if (REG_P (x) && HARD_REGISTER_P (x))
    6683                 :             :     {
    6684                 :             :       /* X is a hard register.  If it only fits one of the base
    6685                 :             :          or index classes, choose that interpretation.  */
    6686                 :          12 :       int regno = REGNO (x);
    6687                 :          12 :       bool base_p = ok_for_base_p_1 (regno, mode, as, outer_code, index_code);
    6688                 :          12 :       bool index_p = REGNO_OK_FOR_INDEX_P (regno);
    6689                 :          12 :       if (base_p != index_p)
    6690                 :           0 :         return base_p ? 1 : -1;
    6691                 :             :     }
    6692                 :             :   return 0;
    6693                 :             : }
    6694                 :             : 
    6695                 :             : /* INFO->INNER describes a normal, non-automodified address.
    6696                 :             :    Fill in the rest of INFO accordingly.  */
    6697                 :             : 
    6698                 :             : static void
    6699                 :    73681017 : decompose_normal_address (struct address_info *info)
    6700                 :             : {
    6701                 :             :   /* Treat the address as the sum of up to four values.  */
    6702                 :    73681017 :   rtx *ops[4];
    6703                 :    73681017 :   size_t n_ops = extract_plus_operands (info->inner, ops,
    6704                 :    73681017 :                                         ops + ARRAY_SIZE (ops)) - ops;
    6705                 :             : 
    6706                 :             :   /* If there is more than one component, any base component is in a PLUS.  */
    6707                 :    73681017 :   if (n_ops > 1)
    6708                 :    54543597 :     info->base_outer_code = PLUS;
    6709                 :             : 
    6710                 :             :   /* Try to classify each sum operand now.  Leave those that could be
    6711                 :             :      either a base or an index in OPS.  */
    6712                 :             :   rtx *inner_ops[4];
    6713                 :             :   size_t out = 0;
    6714                 :   203032764 :   for (size_t in = 0; in < n_ops; ++in)
    6715                 :             :     {
    6716                 :   129351747 :       rtx *loc = ops[in];
    6717                 :   129351747 :       rtx *inner = strip_address_mutations (loc);
    6718                 :   129351747 :       if (CONSTANT_P (*inner))
    6719                 :    64608610 :         set_address_disp (info, loc, inner);
    6720                 :    64743137 :       else if (GET_CODE (*inner) == UNSPEC)
    6721                 :          17 :         set_address_segment (info, loc, inner);
    6722                 :             :       else
    6723                 :             :         {
    6724                 :             :           /* The only other possibilities are a base or an index.  */
    6725                 :    64743120 :           rtx *base_term = get_base_term (inner);
    6726                 :    64743120 :           rtx *index_term = get_index_term (inner);
    6727                 :    64743120 :           gcc_assert (base_term || index_term);
    6728                 :    64743120 :           if (!base_term)
    6729                 :     2170864 :             set_address_index (info, loc, index_term);
    6730                 :    62572256 :           else if (!index_term)
    6731                 :           0 :             set_address_base (info, loc, base_term);
    6732                 :             :           else
    6733                 :             :             {
    6734                 :    62572256 :               gcc_assert (base_term == index_term);
    6735                 :    62572256 :               ops[out] = loc;
    6736                 :    62572256 :               inner_ops[out] = base_term;
    6737                 :    62572256 :               ++out;
    6738                 :             :             }
    6739                 :             :         }
    6740                 :             :     }
    6741                 :             : 
    6742                 :             :   /* Classify the remaining OPS members as bases and indexes.  */
    6743                 :    73681017 :   if (out == 1)
    6744                 :             :     {
    6745                 :             :       /* If we haven't seen a base or an index yet, assume that this is
    6746                 :             :          the base.  If we were confident that another term was the base
    6747                 :             :          or index, treat the remaining operand as the other kind.  */
    6748                 :    60195720 :       if (!info->base)
    6749                 :    60195720 :         set_address_base (info, ops[0], inner_ops[0]);
    6750                 :             :       else
    6751                 :           0 :         set_address_index (info, ops[0], inner_ops[0]);
    6752                 :             :     }
    6753                 :    13485297 :   else if (out == 2)
    6754                 :             :     {
    6755                 :     1188268 :       auto address_mode = targetm.addr_space.address_mode (info->as);
    6756                 :     1188268 :       rtx inner_op0 = *inner_ops[0];
    6757                 :     1188268 :       rtx inner_op1 = *inner_ops[1];
    6758                 :     1188268 :       int base;
    6759                 :             :       /* If one inner operand has the expected mode for a base and the other
    6760                 :             :          doesn't, assume that the other one is the index.  This is useful
    6761                 :             :          for addresses such as:
    6762                 :             : 
    6763                 :             :            (plus (zero_extend X) Y)
    6764                 :             : 
    6765                 :             :          zero_extend is not in itself enough to assume an index, since bases
    6766                 :             :          can be zero-extended on POINTERS_EXTEND_UNSIGNED targets.  But if
    6767                 :             :          Y has address mode and X doesn't, there should be little doubt that
    6768                 :             :          Y is the base.  */
    6769                 :     1188268 :       if (GET_MODE (inner_op0) == address_mode
    6770                 :     1188268 :           && GET_MODE (inner_op1) != address_mode)
    6771                 :             :         base = 0;
    6772                 :     1188268 :       else if (GET_MODE (inner_op1) == address_mode
    6773                 :     1188268 :                && GET_MODE (inner_op0) != address_mode)
    6774                 :             :         base = 1;
    6775                 :             :       /* In the event of a tie, assume the base comes first.  */
    6776                 :     1188268 :       else if (baseness (inner_op0, info->mode, info->as, PLUS,
    6777                 :     1188268 :                          GET_CODE (*ops[1]))
    6778                 :     1188268 :                >= baseness (inner_op1, info->mode, info->as, PLUS,
    6779                 :     1188268 :                             GET_CODE (*ops[0])))
    6780                 :             :         base = 0;
    6781                 :             :       else
    6782                 :        7221 :         base = 1;
    6783                 :     1188268 :       set_address_base (info, ops[base], inner_ops[base]);
    6784                 :     1188268 :       set_address_index (info, ops[1 - base], inner_ops[1 - base]);
    6785                 :             :     }
    6786                 :             :   else
    6787                 :    12297029 :     gcc_assert (out == 0);
    6788                 :    73681017 : }
    6789                 :             : 
    6790                 :             : /* Describe address *LOC in *INFO.  MODE is the mode of the addressed value,
    6791                 :             :    or VOIDmode if not known.  AS is the address space associated with LOC.
    6792                 :             :    OUTER_CODE is MEM if *LOC is a MEM address and ADDRESS otherwise.  */
    6793                 :             : 
    6794                 :             : void
    6795                 :    75762168 : decompose_address (struct address_info *info, rtx *loc, machine_mode mode,
    6796                 :             :                    addr_space_t as, enum rtx_code outer_code)
    6797                 :             : {
    6798                 :    75762168 :   memset (info, 0, sizeof (*info));
    6799                 :    75762168 :   info->mode = mode;
    6800                 :    75762168 :   info->as = as;
    6801                 :    75762168 :   info->addr_outer_code = outer_code;
    6802                 :    75762168 :   info->outer = loc;
    6803                 :    75762168 :   info->inner = strip_address_mutations (loc, &outer_code);
    6804                 :    75762168 :   info->base_outer_code = outer_code;
    6805                 :    75762168 :   switch (GET_CODE (*info->inner))
    6806                 :             :     {
    6807                 :     1979498 :     case PRE_DEC:
    6808                 :     1979498 :     case PRE_INC:
    6809                 :     1979498 :     case POST_DEC:
    6810                 :     1979498 :     case POST_INC:
    6811                 :     1979498 :       decompose_incdec_address (info);
    6812                 :     1979498 :       break;
    6813                 :             : 
    6814                 :      101653 :     case PRE_MODIFY:
    6815                 :      101653 :     case POST_MODIFY:
    6816                 :      101653 :       decompose_automod_address (info);
    6817                 :      101653 :       break;
    6818                 :             : 
    6819                 :    73681017 :     default:
    6820                 :    73681017 :       decompose_normal_address (info);
    6821                 :    73681017 :       break;
    6822                 :             :     }
    6823                 :    75762168 : }
    6824                 :             : 
    6825                 :             : /* Describe address operand LOC in INFO.  */
    6826                 :             : 
    6827                 :             : void
    6828                 :     3418011 : decompose_lea_address (struct address_info *info, rtx *loc)
    6829                 :             : {
    6830                 :     3418011 :   decompose_address (info, loc, VOIDmode, ADDR_SPACE_GENERIC, ADDRESS);
    6831                 :     3418011 : }
    6832                 :             : 
    6833                 :             : /* Describe the address of MEM X in INFO.  */
    6834                 :             : 
    6835                 :             : void
    6836                 :    72335541 : decompose_mem_address (struct address_info *info, rtx x)
    6837                 :             : {
    6838                 :    72335541 :   gcc_assert (MEM_P (x));
    6839                 :    72335541 :   decompose_address (info, &XEXP (x, 0), GET_MODE (x),
    6840                 :    72335541 :                      MEM_ADDR_SPACE (x), MEM);
    6841                 :    72335541 : }
    6842                 :             : 
    6843                 :             : /* Update INFO after a change to the address it describes.  */
    6844                 :             : 
    6845                 :             : void
    6846                 :        8616 : update_address (struct address_info *info)
    6847                 :             : {
    6848                 :        8616 :   decompose_address (info, info->outer, info->mode, info->as,
    6849                 :             :                      info->addr_outer_code);
    6850                 :        8616 : }
    6851                 :             : 
    6852                 :             : /* Return the scale applied to *INFO->INDEX_TERM, or 0 if the index is
    6853                 :             :    more complicated than that.  */
    6854                 :             : 
    6855                 :             : HOST_WIDE_INT
    6856                 :           0 : get_index_scale (const struct address_info *info)
    6857                 :             : {
    6858                 :           0 :   rtx index = *info->index;
    6859                 :           0 :   if (GET_CODE (index) == MULT
    6860                 :           0 :       && CONST_INT_P (XEXP (index, 1))
    6861                 :           0 :       && info->index_term == &XEXP (index, 0))
    6862                 :           0 :     return INTVAL (XEXP (index, 1));
    6863                 :             : 
    6864                 :           0 :   if (GET_CODE (index) == ASHIFT
    6865                 :           0 :       && CONST_INT_P (XEXP (index, 1))
    6866                 :           0 :       && info->index_term == &XEXP (index, 0))
    6867                 :           0 :     return HOST_WIDE_INT_1 << INTVAL (XEXP (index, 1));
    6868                 :             : 
    6869                 :           0 :   if (info->index == info->index_term)
    6870                 :           0 :     return 1;
    6871                 :             : 
    6872                 :             :   return 0;
    6873                 :             : }
    6874                 :             : 
    6875                 :             : /* Return the "index code" of INFO, in the form required by
    6876                 :             :    ok_for_base_p_1.  */
    6877                 :             : 
    6878                 :             : enum rtx_code
    6879                 :    32724596 : get_index_code (const struct address_info *info)
    6880                 :             : {
    6881                 :    32724596 :   if (info->index)
    6882                 :     1311652 :     return GET_CODE (*info->index);
    6883                 :             : 
    6884                 :    31412944 :   if (info->disp)
    6885                 :    25723119 :     return GET_CODE (*info->disp);
    6886                 :             : 
    6887                 :             :   return SCRATCH;
    6888                 :             : }
    6889                 :             : 
    6890                 :             : /* Return true if RTL X contains a SYMBOL_REF.  */
    6891                 :             : 
    6892                 :             : bool
    6893                 :      766045 : contains_symbol_ref_p (const_rtx x)
    6894                 :             : {
    6895                 :      766045 :   subrtx_iterator::array_type array;
    6896                 :     3139416 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
    6897                 :     2449412 :     if (SYMBOL_REF_P (*iter))
    6898                 :       76041 :       return true;
    6899                 :             : 
    6900                 :      690004 :   return false;
    6901                 :      766045 : }
    6902                 :             : 
    6903                 :             : /* Return true if RTL X contains a SYMBOL_REF or LABEL_REF.  */
    6904                 :             : 
    6905                 :             : bool
    6906                 :      364897 : contains_symbolic_reference_p (const_rtx x)
    6907                 :             : {
    6908                 :      364897 :   subrtx_iterator::array_type array;
    6909                 :      855602 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
    6910                 :      494727 :     if (SYMBOL_REF_P (*iter) || GET_CODE (*iter) == LABEL_REF)
    6911                 :        4022 :       return true;
    6912                 :             : 
    6913                 :      360875 :   return false;
    6914                 :      364897 : }
    6915                 :             : 
    6916                 :             : /* Return true if RTL X contains a constant pool address.  */
    6917                 :             : 
    6918                 :             : bool
    6919                 :           0 : contains_constant_pool_address_p (const_rtx x)
    6920                 :             : {
    6921                 :           0 :   subrtx_iterator::array_type array;
    6922                 :           0 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
    6923                 :           0 :     if (SYMBOL_REF_P (*iter) && CONSTANT_POOL_ADDRESS_P (*iter))
    6924                 :           0 :       return true;
    6925                 :             : 
    6926                 :           0 :   return false;
    6927                 :           0 : }
    6928                 :             : 
    6929                 :             : 
    6930                 :             : /* Return true if X contains a thread-local symbol.  */
    6931                 :             : 
    6932                 :             : bool
    6933                 :           0 : tls_referenced_p (const_rtx x)
    6934                 :             : {
    6935                 :           0 :   if (!targetm.have_tls)
    6936                 :             :     return false;
    6937                 :             : 
    6938                 :           0 :   subrtx_iterator::array_type array;
    6939                 :           0 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
    6940                 :           0 :     if (GET_CODE (*iter) == SYMBOL_REF && SYMBOL_REF_TLS_MODEL (*iter) != 0)
    6941                 :           0 :       return true;
    6942                 :           0 :   return false;
    6943                 :           0 : }
    6944                 :             : 
    6945                 :             : /* Process recursively X of INSN and add REG_INC notes if necessary.  */
    6946                 :             : void
    6947                 :           0 : add_auto_inc_notes (rtx_insn *insn, rtx x)
    6948                 :             : {
    6949                 :           0 :   enum rtx_code code = GET_CODE (x);
    6950                 :           0 :   const char *fmt;
    6951                 :           0 :   int i, j;
    6952                 :             : 
    6953                 :           0 :   if (code == MEM && auto_inc_p (XEXP (x, 0)))
    6954                 :             :     {
    6955                 :           0 :       add_reg_note (insn, REG_INC, XEXP (XEXP (x, 0), 0));
    6956                 :           0 :       return;
    6957                 :             :     }
    6958                 :             : 
    6959                 :             :   /* Scan all X sub-expressions.  */
    6960                 :           0 :   fmt = GET_RTX_FORMAT (code);
    6961                 :           0 :   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    6962                 :             :     {
    6963                 :           0 :       if (fmt[i] == 'e')
    6964                 :           0 :         add_auto_inc_notes (insn, XEXP (x, i));
    6965                 :           0 :       else if (fmt[i] == 'E')
    6966                 :           0 :         for (j = XVECLEN (x, i) - 1; j >= 0; j--)
    6967                 :           0 :           add_auto_inc_notes (insn, XVECEXP (x, i, j));
    6968                 :             :     }
    6969                 :             : }
    6970                 :             : 
    6971                 :             : /* Return true if X is register asm.  */
    6972                 :             : 
    6973                 :             : bool
    6974                 :    16737468 : register_asm_p (const_rtx x)
    6975                 :             : {
    6976                 :    16737468 :   return (REG_P (x)
    6977                 :    16737468 :           && REG_EXPR (x) != NULL_TREE
    6978                 :     7415543 :           && HAS_DECL_ASSEMBLER_NAME_P (REG_EXPR (x))
    6979                 :     2090368 :           && DECL_ASSEMBLER_NAME_SET_P (REG_EXPR (x))
    6980                 :    16782908 :           && DECL_REGISTER (REG_EXPR (x)));
    6981                 :             : }
    6982                 :             : 
    6983                 :             : /* Return true if, for all OP of mode OP_MODE:
    6984                 :             : 
    6985                 :             :      (vec_select:RESULT_MODE OP SEL)
    6986                 :             : 
    6987                 :             :    is equivalent to the highpart RESULT_MODE of OP.  */
    6988                 :             : 
    6989                 :             : bool
    6990                 :           0 : vec_series_highpart_p (machine_mode result_mode, machine_mode op_mode, rtx sel)
    6991                 :             : {
    6992                 :           0 :   int nunits;
    6993                 :           0 :   if (GET_MODE_NUNITS (op_mode).is_constant (&nunits)
    6994                 :           0 :       && targetm.can_change_mode_class (op_mode, result_mode, ALL_REGS))
    6995                 :             :     {
    6996                 :           0 :       int offset = BYTES_BIG_ENDIAN ? 0 : nunits - XVECLEN (sel, 0);
    6997                 :           0 :       return rtvec_series_p (XVEC (sel, 0), offset);
    6998                 :             :     }
    6999                 :             :   return false;
    7000                 :             : }
    7001                 :             : 
    7002                 :             : /* Return true if, for all OP of mode OP_MODE:
    7003                 :             : 
    7004                 :             :      (vec_select:RESULT_MODE OP SEL)
    7005                 :             : 
    7006                 :             :    is equivalent to the lowpart RESULT_MODE of OP.  */
    7007                 :             : 
    7008                 :             : bool
    7009                 :     4897330 : vec_series_lowpart_p (machine_mode result_mode, machine_mode op_mode, rtx sel)
    7010                 :             : {
    7011                 :     4897330 :   int nunits;
    7012                 :     4897330 :   if (GET_MODE_NUNITS (op_mode).is_constant (&nunits)
    7013                 :     4897330 :       && targetm.can_change_mode_class (op_mode, result_mode, ALL_REGS))
    7014                 :             :     {
    7015                 :      591803 :       int offset = BYTES_BIG_ENDIAN ? nunits - XVECLEN (sel, 0) : 0;
    7016                 :      591803 :       return rtvec_series_p (XVEC (sel, 0), offset);
    7017                 :             :     }
    7018                 :             :   return false;
    7019                 :             : }
    7020                 :             : 
    7021                 :             : /* Return true if X contains a paradoxical subreg.  */
    7022                 :             : 
    7023                 :             : bool
    7024                 :     1156340 : contains_paradoxical_subreg_p (rtx x)
    7025                 :             : {
    7026                 :     1156340 :   subrtx_var_iterator::array_type array;
    7027                 :     4921938 :   FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST)
    7028                 :             :     {
    7029                 :     3785330 :       x = *iter;
    7030                 :     3785330 :       if (SUBREG_P (x) && paradoxical_subreg_p (x))
    7031                 :       19732 :         return true;
    7032                 :             :     }
    7033                 :     1136608 :   return false;
    7034                 :     1156340 : }
        

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.