LCOV - code coverage report
Current view: top level - gcc - value-relation.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 91.3 % 69 63
Test Date: 2026-10-17 16:30:31 Functions: 66.7 % 15 10
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Header file for the value range relational processing.
       2              :    Copyright (C) 2020-2026 Free Software Foundation, Inc.
       3              :    Contributed by Andrew MacLeod <amacleod@redhat.com>
       4              : 
       5              : This file is part of GCC.
       6              : 
       7              : GCC is free software; you can redistribute it and/or modify it under
       8              : the terms of the GNU General Public License as published by the Free
       9              : Software Foundation; either version 3, or (at your option) any later
      10              : version.
      11              : 
      12              : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      13              : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      14              : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      15              :  for more details.
      16              : 
      17              : You should have received a copy of the GNU General Public License
      18              : along with GCC; see the file COPYING3.  If not see
      19              : <http://www.gnu.org/licenses/>.  */
      20              : 
      21              : #ifndef GCC_VALUE_RELATION_H
      22              : #define GCC_VALUE_RELATION_H
      23              : 
      24              : 
      25              : // This file provides access to a relation oracle which can be used to
      26              : // maintain and query relations and equivalences between SSA_NAMES.
      27              : //
      28              : // The general range_query object provided in value-query.h provides
      29              : // access to an oracle, if one is available, via the oracle() method.
      30              : // There are also a couple of access routines provided, which even if there is
      31              : // no oracle, will return the default VREL_VARYING no relation.
      32              : //
      33              : // Typically, when a ranger object is active, there will be an oracle, and
      34              : // any information available can be directly queried.  Ranger also sets and
      35              : // utilizes the relation information to enhance it's range calculations, this
      36              : // is totally transparent to the client, and they are free to make queries.
      37              : //
      38              : // relation_kind is a new enum which represents the different relations,
      39              : // often with a direct mapping to tree codes. ie VREL_EQ is equivalent to
      40              : // EQ_EXPR.
      41              : //
      42              : // A query is made requesting the relation between SSA1 and SSA@ in a basic
      43              : // block, or on an edge, the possible return values are:
      44              : //
      45              : //  VREL_EQ, VREL_NE, VREL_LT, VREL_LE, VREL_GT, and VREL_GE mean the same.
      46              : //  VREL_VARYING : No relation between the 2 names.
      47              : //  VREL_UNDEFINED : Impossible relation (ie, A < B && A > B)
      48              : //
      49              : // The oracle maintains VREL_EQ relations with equivalency sets, so if a
      50              : // relation comes back VREL_EQ, it is also possible to query the set of
      51              : // equivalencies.  These are basically bitmaps over ssa_names.  An iterator is
      52              : // provided later for this activity.
      53              : //
      54              : // Relations are maintained via the dominance trees and are optimized assuming
      55              : // they are registered in dominance order.   When a new relation is added, it
      56              : // is intersected with whatever existing relation exists in the dominance tree
      57              : // and registered at the specified block.
      58              : 
      59              : 
      60              : // These codes are arranged such that VREL_VARYING is the first code, and all
      61              : // the rest are contiguous.
      62              : 
      63              : typedef enum relation_kind_t
      64              : {
      65              :   VREL_VARYING = 0,     // No known relation,  AKA varying.
      66              :   VREL_UNDEFINED,       // Impossible relation, ie (r1 < r2) && (r2 > r1)
      67              :   VREL_LT,              // r1 < r2
      68              :   VREL_LE,              // r1 <= r2
      69              :   VREL_GT,              // r1 > r2
      70              :   VREL_GE,              // r1 >= r2
      71              :   VREL_EQ,              // r1 == r2
      72              :   VREL_NE,              // r1 != r2
      73              :   VREL_PE8,             // 8 bit partial equivalency
      74              :   VREL_PE16,            // 16 bit partial equivalency
      75              :   VREL_PE32,            // 32 bit partial equivalency
      76              :   VREL_PE64,            // 64 bit partial equivalency
      77              :   VREL_LAST             // terminate, not a real relation.
      78              : } relation_kind;
      79              : 
      80              : // General relation kind transformations.
      81              : relation_kind relation_union (relation_kind r1, relation_kind r2);
      82              : relation_kind relation_intersect (relation_kind r1, relation_kind r2);
      83              : relation_kind relation_negate (relation_kind r);
      84              : relation_kind relation_swap (relation_kind r);
      85      8348349 : inline bool relation_lt_le_gt_ge_p (relation_kind r)
      86      8348349 :                       { return (r >= VREL_LT && r <= VREL_GE); }
      87    265230508 : inline bool relation_partial_equiv_p (relation_kind r)
      88    174763757 :                       { return (r >= VREL_PE8 && r <= VREL_PE64); }
      89    203631765 : inline bool relation_equiv_p (relation_kind r)
      90    203631781 :                       { return r == VREL_EQ || relation_partial_equiv_p (r); }
      91              : 
      92              : void print_relation (FILE *f, relation_kind rel);
      93              : 
      94              : // Adjust range as an equivalence.
      95              : void adjust_equivalence_range (vrange &range);
      96              : 
      97              : class relation_oracle
      98              : {
      99              : public:
     100     37308179 :   relation_oracle () { m_lhs_equiv_set_p = NULL; }
     101     37601545 :   virtual ~relation_oracle () { }
     102              : 
     103              :   // register a relation between 2 ssa names.
     104              :   bool record (gimple *, relation_kind, tree, tree);
     105              :   bool record (edge, relation_kind, tree, tree);
     106      1054068 :   virtual bool record (basic_block, relation_kind, tree, tree) { return false; }
     107              : 
     108              :   // Query if there is any relation between SSA1 and SSA2.
     109              :   relation_kind query (gimple *s, tree ssa1, tree ssa2);
     110              :   relation_kind query (edge e, tree ssa1, tree ssa2);
     111     10885080 :   virtual relation_kind query (basic_block, tree, tree) { return VREL_VARYING; }
     112              : 
     113              :   // Remove relations for an SSA_NAME
     114      7660319 :   virtual void clear (tree) { }
     115              : 
     116            0 :   virtual void dump (FILE *, basic_block) const { }
     117            0 :   virtual void dump (FILE *) const  { }
     118              :   void debug () const;
     119              : protected:
     120              :   friend class equiv_relation_iterator;
     121              :   friend class block_relation_iterator;
     122            0 :   virtual class relation_chain *next_relation (basic_block,
     123              :                                                relation_chain *,
     124              :                                                tree) const
     125            0 :     { return NULL; }
     126              :   // Return equivalency set for an SSA name in a basic block.
     127            1 :   virtual const_bitmap equiv_set (tree, basic_block) { return NULL; }
     128              :   // Return partial equivalency record for an SSA name.
     129            1 :   virtual const class pe_slice *partial_equiv_set (tree) { return NULL; }
     130              :   void valid_equivs (bitmap b, const_bitmap equivs, basic_block bb);
     131              :   // Query for a relation between two equivalency sets in a basic block.
     132            0 :   virtual relation_kind query (basic_block, const_bitmap, const_bitmap)
     133            0 :     { return VREL_VARYING; }
     134              :   friend class path_oracle;
     135              :   // Used to Avoid registering multiple eqiuvalences from the same statement.
     136              :   bitmap m_lhs_equiv_set_p;
     137              : };
     138              : 
     139              : // Instance with no storage used for default queries with no active oracle.
     140              : extern relation_oracle default_relation_oracle;
     141              : 
     142              : // This class represents an equivalency set, and contains a link to the next
     143              : // one in the list to be searched.
     144              : 
     145              : class equiv_chain
     146              : {
     147              : public:
     148              :   bitmap m_names;               // ssa-names in equiv set.
     149              :   basic_block m_bb;             // Block this belongs to
     150              :   equiv_chain *m_next;          // Next in block list.
     151              :   void dump (FILE *f) const;    // Show names in this list.
     152              :   equiv_chain *find (unsigned ssa);
     153              : };
     154              : 
     155              : class pe_slice
     156              : {
     157              : public:
     158              :   tree ssa_base;        // Slice of this name.
     159              :   relation_kind code;   // bits that are equivalent.
     160              :   bitmap members;       // Other members in the partial equivalency.
     161              : };
     162              : 
     163              : // The equivalency oracle maintains equivalencies using the dominator tree.
     164              : // Equivalencies apply to an entire basic block.  Equivalencies on edges
     165              : // can be represented only on edges whose destination is a single-pred block,
     166              : // and the equivalence is simply applied to that successor block.
     167              : 
     168              : class equiv_oracle : public relation_oracle
     169              : {
     170              : public:
     171              :   equiv_oracle ();
     172              :   ~equiv_oracle ();
     173              : 
     174              :   const_bitmap equiv_set (tree ssa, basic_block bb) final override;
     175              :   bool record (basic_block bb, relation_kind k, tree ssa1, tree ssa2) override;
     176              : 
     177              :   relation_kind partial_equiv (tree ssa1, tree ssa2, tree *base = NULL) const;
     178              :   relation_kind query (basic_block, tree, tree) override;
     179              :   relation_kind query (basic_block, const_bitmap, const_bitmap) override;
     180              : 
     181              :   void clear (tree name) override;
     182              :   void dump (FILE *f, basic_block bb) const override;
     183              :   void dump (FILE *f) const override;
     184              : 
     185              : protected:
     186              :   bool add_partial_equiv (relation_kind, tree, tree);
     187              :   const pe_slice *partial_equiv_set (tree name) final override;
     188     98991612 :   inline bool has_equiv_p (unsigned v) { return bitmap_bit_p (m_equiv_set, v); }
     189              :   bitmap_obstack m_bitmaps;
     190              :   struct obstack m_chain_obstack;
     191              : private:
     192              :   bitmap m_equiv_set;   // Index by ssa-name. true if an equivalence exists.
     193              :   vec <equiv_chain *> m_equiv;    // Index by BB.  list of equivalences.
     194              :   class name_info
     195              :   {
     196              :   public:
     197              :     bitmap m_self_equiv;        // Self equivalency set.
     198              :     bitmap m_block_list;        // BB's name occurs in equivalencies.
     199              :   };
     200              :   vec <name_info> m_name_info;    // Index by ssa-name.
     201              :   vec <pe_slice> m_partial;  // Partial equivalencies.
     202              : 
     203              :   void limit_check (basic_block bb = NULL);
     204              :   equiv_chain *find_equiv_block (unsigned ssa, int bb) const;
     205              :   equiv_chain *find_equiv_dom (tree name, basic_block bb) const;
     206              : 
     207              :   bitmap register_equiv (basic_block bb, unsigned v, equiv_chain *equiv_1);
     208              :   bitmap register_equiv (basic_block bb, equiv_chain *equiv_1,
     209              :                          equiv_chain *equiv_2);
     210              : 
     211              :   void register_equiv_block (unsigned v, unsigned bbi);
     212              :   void register_equiv_block (const_bitmap equiv, basic_block bb);
     213              : 
     214              :   void register_initial_def (tree ssa);
     215              :   void add_equiv_to_block (basic_block bb, bitmap equiv);
     216              : };
     217              : 
     218              : // Summary block header for relations.
     219              : 
     220              : class relation_chain_head
     221              : {
     222              : public:
     223              :   bitmap m_names;               // ssa_names with relations in this block.
     224              :   class relation_chain *m_head; // List of relations in block.
     225              :   int m_num_relations;          // Number of relations in block.
     226              :   relation_kind find_relation (const_bitmap b1, const_bitmap b2) const;
     227              :   void clear (tree name);
     228              : };
     229              : 
     230              : 
     231              : // This class tracks what is known on one side of a frontier search.
     232              : // It represents the relation that root has to each other name.
     233              : // All relations are M_ROOT <REL> ssa_name (v).
     234              : // The m_rhs flag indicates if this is the LHS or RHS of a relation search.
     235              : // This is used to determine if the relation needs to be swapped in order
     236              : // to perform a transitive operation:  TRANS (LHS op X , X op RHS).
     237              : // m_visited is also used to efficiently clear the structure.
     238              : // All relations default to VREL_VARYING.
     239              : 
     240              : class frontier_data {
     241              : public:
     242              :   frontier_data (bitmap_obstack *obstack, bool rhs);
     243     27831547 :   ~frontier_data () { m_known.release (); }
     244              : 
     245              :   void clear_search ();
     246     46634001 :   bool visited_p (unsigned v) const { return bitmap_bit_p (m_visited, v); }
     247              :   relation_kind known_relation (unsigned v) const;
     248              :   void set_known (unsigned v, relation_kind rel);
     249              : 
     250              :   bitmap m_visited;
     251              :   vec<relation_kind> m_known;
     252              :   tree m_root;
     253              :   bool m_rhs;           // True if rooted at the RHS of the query.
     254              : };
     255              : 
     256              : // A relation oracle maintains a set of relations between ssa_names using the
     257              : // dominator tree structures.  Equivalencies are considered a subset of
     258              : // a general relation and maintained by an equivalence oracle by transparently
     259              : // passing any EQ_EXPR relations to it.
     260              : // Relations are handled at the basic block level.  All relations apply to
     261              : // an entire block, and are thus kept in a summary index by block.
     262              : // Similar to the equivalence oracle, edges are handled by applying the
     263              : // relation to the destination block of the edge, but ONLY if that block
     264              : // has a single successor.  For now.
     265              : 
     266              : class dom_oracle : public equiv_oracle
     267              : {
     268              : public:
     269              :   dom_oracle ();
     270              :   ~dom_oracle ();
     271              : 
     272              :   bool record (basic_block bb, relation_kind k, tree op1, tree op2)
     273              :     final override;
     274              : 
     275              :   relation_kind query (basic_block bb, tree ssa1, tree ssa2) final override;
     276              :   relation_kind query (basic_block bb, const_bitmap b1, const_bitmap b2)
     277              :     final override;
     278              : 
     279              :   void clear (tree name) override;
     280              : 
     281              :   void dump (FILE *f, basic_block bb) const final override;
     282              :   void dump (FILE *f) const final override;
     283              : protected:
     284              :   virtual relation_chain *next_relation (basic_block, relation_chain *,
     285              :                                          tree) const override;
     286              :   bitmap m_tmp, m_tmp2;
     287              :   bitmap m_relation_set;  // Index by ssa-name. True if a relation exists
     288              :   vec <relation_chain_head> m_relations;  // Index by BB, list of relations.
     289              :   vec <bitmap> m_block_list;      // Index by ssa-name.  Blocks with relations.
     290              :   relation_kind find_relation_block (unsigned bb, const_bitmap b1,
     291              :                                      const_bitmap b2) const;
     292              :   relation_kind find_relation_block (int bb, tree ssa1, tree ssa2,
     293              :                                      relation_chain **obj = NULL) const;
     294              :   relation_kind find_relation_dom (basic_block bb, tree ssa1, tree ssa2) const;
     295              :   relation_chain *create_relation_in_bb (basic_block bb, relation_kind k,
     296              :                                          tree op1, tree op2);
     297              :   relation_chain *search_and_merge_relation (basic_block bb, relation_kind k,
     298              :                                              tree op1, tree op2);
     299              :   void record_relation_block (unsigned v, unsigned bbi);
     300              :   relation_kind recomputed_relation (basic_block, tree, tree) const;
     301              :   basic_block nearest_relations (tree name, basic_block bb);
     302              :   relation_kind relation_search (basic_block, tree, const_bitmap, tree,
     303              :                                  const_bitmap);
     304              :   void cache_relation (basic_block, relation_kind, tree, tree);
     305              : 
     306              :   // NAME is related to the requested ssa name via REL in block BB
     307              :   // nearest_relations () calls will fill this vector.
     308              :   struct related {
     309              :     relation_kind rel;
     310              :     tree name;
     311              :     basic_block bb;
     312              :   };
     313              :   vec<struct related> m_near;
     314              : 
     315              :   frontier_data m_lhs_search;
     316              :   frontier_data m_rhs_search;
     317              : 
     318              :   // One element waiting to be expanded from the frontier.
     319              :   // "implied root <REL> NAME" is the known relation, found in BB.
     320              :   // RHS indicates if root is the LHS or RHS operand of the original request.
     321              :   struct frontier_element {
     322              :     relation_kind rel;
     323              :     tree name;
     324              :     basic_block bb;
     325              :     bool rhs;
     326              :   };
     327              : 
     328              :   // Both LHS and RHS frontiers share a single worklist, so whichever side
     329              :   // has work outstanding is processed.
     330              :   // M_WL_IX is the next entry to expand; everything before it is done.
     331              :   vec<struct frontier_element> m_worklist;
     332              :   unsigned m_wl_ix;
     333              : 
     334              :   void start_search (frontier_data &side, tree root, const_bitmap equiv,
     335              :                      basic_block bb);
     336              :   void add_to_frontier (frontier_data &side, tree name, relation_kind rel,
     337              :                         basic_block bb);
     338              :   bool expand_frontier (frontier_element w, basic_block bb,
     339              :                         relation_kind &result);
     340              : };
     341              : 
     342              : // A path_oracle implements relations in a list.  The only sense of ordering
     343              : // is the latest registered relation is the first found during a search.
     344              : // It can be constructed with an optional "root" oracle which will be used
     345              : // to look up any relations not found in the list.
     346              : // This allows the client to walk paths starting at some block and register
     347              : // and query relations along that path, ignoring other edges.
     348              : //
     349              : // For registering a relation, a query if made of the root oracle if there is
     350              : // any known relationship at block BB, and it is combined with this new
     351              : // relation and entered in the list.
     352              : //
     353              : // Queries are resolved by looking first in the list, and only if nothing is
     354              : // found is the root oracle queried at block BB.
     355              : //
     356              : // reset_path is used to clear all locally registered paths to initial state.
     357              : 
     358              : class path_oracle : public relation_oracle
     359              : {
     360              : public:
     361              :   path_oracle (relation_oracle *oracle = NULL);
     362              :   ~path_oracle ();
     363              :   const_bitmap equiv_set (tree, basic_block) final override;
     364              :   bool record (basic_block, relation_kind, tree, tree) final override;
     365              :   void killing_def (tree);
     366              :   relation_kind query (basic_block, tree, tree) final override;
     367              :   relation_kind query (basic_block, const_bitmap, const_bitmap) final override;
     368              :   void reset_path (relation_oracle *oracle = NULL);
     369     50245998 :   void set_root_oracle (relation_oracle *oracle) { m_root = oracle; }
     370              : 
     371              :   void clear (tree name) override;
     372              : 
     373              :   void dump (FILE *, basic_block) const final override;
     374              :   void dump (FILE *) const final override;
     375              : private:
     376              :   bool register_equiv (basic_block bb, tree ssa1, tree ssa2);
     377              :   equiv_chain m_equiv;
     378              :   relation_chain_head m_relations;
     379              :   relation_oracle *m_root;
     380              :   bitmap m_killed_defs;
     381              : 
     382              :   bitmap_obstack m_bitmaps;
     383              :   struct obstack m_chain_obstack;
     384              : };
     385              : 
     386              : // Used to assist with iterating over the equivalence list.
     387              : class equiv_relation_iterator {
     388              : public:
     389              :   equiv_relation_iterator (relation_oracle *oracle, basic_block bb, tree name,
     390              :                            bool full = true, bool partial = false);
     391              :   void next ();
     392              :   tree get_name (relation_kind *rel = NULL);
     393              : protected:
     394              :   relation_oracle *m_oracle;
     395              :   const_bitmap m_bm;
     396              :   const pe_slice *m_pe;
     397              :   bitmap_iterator m_bi;
     398              :   unsigned m_y;
     399              :   tree m_name;
     400              : };
     401              : 
     402              : #define FOR_EACH_EQUIVALENCE(oracle, bb, name, equiv_name)              \
     403              :   for (equiv_relation_iterator iter (oracle, bb, name, true, false);    \
     404              :        ((equiv_name) = iter.get_name ());                               \
     405              :        iter.next ())
     406              : 
     407              : #define FOR_EACH_PARTIAL_EQUIV(oracle, bb, name, equiv_name, equiv_rel) \
     408              :   for (equiv_relation_iterator iter (oracle, bb, name, false, true);    \
     409              :        ((equiv_name) = iter.get_name (&equiv_rel));                 \
     410              :        iter.next ())
     411              : 
     412              : #define FOR_EACH_PARTIAL_AND_FULL_EQUIV(oracle, bb, name, equiv_name,   \
     413              :                                                       equiv_rel)        \
     414              :   for (equiv_relation_iterator iter (oracle, bb, name, true, true);     \
     415              :        ((equiv_name) = iter.get_name (&equiv_rel));                 \
     416              :        iter.next ())
     417              : 
     418              : // -----------------------------------------------------------------------
     419              : 
     420              : // Range-ops deals with a LHS and 2 operands. A relation trio is a set of
     421              : // 3 potential relations packed into a single unsigned value.
     422              : //  1 - LHS relation OP1
     423              : //  2 - LHS relation OP2
     424              : //  3 - OP1 relation OP2
     425              : //  VREL_VARYING is a value of 0, and is the default for each position.
     426              : class relation_trio
     427              : {
     428              : public:
     429              :   relation_trio ();
     430              :   relation_trio (relation_kind lhs_op1, relation_kind lhs_op2,
     431              :                  relation_kind op1_op2);
     432              :   relation_kind lhs_op1 ();
     433              :   relation_kind lhs_op2 ();
     434              :   relation_kind op1_op2 ();
     435              :   relation_trio swap_op1_op2 ();
     436              : 
     437              :   static relation_trio lhs_op1 (relation_kind k);
     438              :   static relation_trio lhs_op2 (relation_kind k);
     439              :   static relation_trio op1_op2 (relation_kind k);
     440              : 
     441              : protected:
     442              :   unsigned m_val;
     443              : };
     444              : 
     445              : //  Default VREL_VARYING for all 3 relations.
     446              : #define TRIO_VARYING    relation_trio ()
     447              : 
     448              : #define TRIO_SHIFT      4
     449              : #define TRIO_MASK       0x000F
     450              : 
     451              : // These 3 classes are shortcuts for when a caller has a single relation to
     452              : // pass as a trio, it can simply construct the appropriate one.  The other
     453              : // unspecified relations will be VREL_VARYING.
     454              : 
     455    314119316 : inline relation_trio::relation_trio ()
     456              : {
     457    314119316 :   STATIC_ASSERT (VREL_LAST <= (1 << TRIO_SHIFT));
     458    314119316 :   m_val = 0;
     459              : }
     460              : 
     461    265476731 : inline relation_trio::relation_trio (relation_kind lhs_op1,
     462              :                                      relation_kind lhs_op2,
     463              :                                      relation_kind op1_op2)
     464              : {
     465    265476731 :   STATIC_ASSERT (VREL_LAST <= (1 << TRIO_SHIFT));
     466    265476731 :   unsigned i1 = (unsigned) lhs_op1;
     467    265476731 :   unsigned i2 = ((unsigned) lhs_op2) << TRIO_SHIFT;
     468    265476731 :   unsigned i3 = ((unsigned) op1_op2) << (TRIO_SHIFT * 2);
     469    265348036 :   m_val = i1 | i2 | i3;
     470              : }
     471              : 
     472              : inline relation_trio
     473      1076230 : relation_trio::lhs_op1 (relation_kind k)
     474              : {
     475      1076230 :   return relation_trio (k, VREL_VARYING, VREL_VARYING);
     476              : }
     477              : inline relation_trio
     478      1418514 : relation_trio::lhs_op2 (relation_kind k)
     479              : {
     480      1418514 :   return relation_trio (VREL_VARYING, k, VREL_VARYING);
     481              : }
     482              : inline relation_trio
     483    179871779 : relation_trio::op1_op2 (relation_kind k)
     484              : {
     485    179871779 :   return relation_trio (VREL_VARYING, VREL_VARYING, k);
     486              : }
     487              : 
     488              : inline relation_kind
     489     30718756 : relation_trio::lhs_op1 ()
     490              : {
     491     17623904 :   return (relation_kind) (m_val & TRIO_MASK);
     492              : }
     493              : 
     494              : inline relation_kind
     495     13366028 : relation_trio::lhs_op2 ()
     496              : {
     497     13508508 :   return (relation_kind) ((m_val >> TRIO_SHIFT) & TRIO_MASK);
     498              : }
     499              : 
     500              : inline relation_kind
     501    366370491 : relation_trio::op1_op2 ()
     502              : {
     503    353004464 :   return (relation_kind) ((m_val >> (TRIO_SHIFT * 2)) & TRIO_MASK);
     504              : }
     505              : 
     506              : inline relation_trio
     507     13366027 : relation_trio::swap_op1_op2 ()
     508              : {
     509     13366027 :   return relation_trio (lhs_op2 (), lhs_op1 (), relation_swap (op1_op2 ()));
     510              : }
     511              : 
     512              : // -----------------------------------------------------------------------
     513              : 
     514              : // The value-relation class is used to encapsulate the representation of an
     515              : // individual relation between 2 ssa-names, and to facilitate operating on
     516              : // the relation.
     517              : 
     518              : class value_relation
     519              : {
     520              : public:
     521              :   value_relation ();
     522              :   value_relation (relation_kind kind, tree n1, tree n2);
     523              :   void set_relation (relation_kind kind, tree n1, tree n2);
     524              : 
     525    155903605 :   inline relation_kind kind () const { return related; }
     526    256763329 :   inline tree op1 () const { return name1; }
     527    290660247 :   inline tree op2 () const { return name2; }
     528              : 
     529              :   relation_trio create_trio (tree lhs, tree op1, tree op2);
     530              :   bool union_ (value_relation &p);
     531              :   bool intersect (value_relation &p);
     532              :   void swap ();
     533              :   bool apply_transitive (const value_relation &rel);
     534              : 
     535              :   void dump (FILE *f) const;
     536              : private:
     537              :   relation_kind related;
     538              :   tree name1, name2;
     539              : };
     540              : 
     541              : // Set relation R between ssa_name N1 and N2.
     542              : 
     543              : inline void
     544    209184365 : value_relation::set_relation (relation_kind r, tree n1, tree n2)
     545              : {
     546    209184365 :   gcc_checking_assert (TREE_CODE (n1) == SSA_NAME
     547              :                        && TREE_CODE (n2) == SSA_NAME);
     548    209184365 :   related = r;
     549    209184365 :   name1 = n1;
     550    209184365 :   name2 = n2;
     551    209184365 : }
     552              : 
     553              : // Default constructor.
     554              : 
     555              : inline
     556    154893452 : value_relation::value_relation ()
     557              : {
     558    154893452 :   related = VREL_VARYING;
     559    154893452 :   name1 = NULL_TREE;
     560    154893452 :   name2 = NULL_TREE;
     561              : }
     562              : 
     563              : // Constructor for relation R between SSA version N1 and N2.
     564              : 
     565              : inline
     566    121880706 : value_relation::value_relation (relation_kind kind, tree n1, tree n2)
     567              : {
     568    121880706 :   set_relation (kind, n1, n2);
     569              : }
     570              : 
     571              : 
     572              : class block_relation_iterator {
     573              : public:
     574              :   block_relation_iterator (const relation_oracle *oracle, basic_block bb,
     575              :                            value_relation &, tree name = NULL);
     576              :   void get_next_relation (value_relation &vr);
     577              :   const relation_oracle *m_oracle;
     578              :   basic_block m_bb;
     579              :   relation_chain *m_ptr;
     580              :   bool m_done;
     581              :   tree m_name;
     582              : };
     583              : 
     584              : #define FOR_EACH_RELATION_BB(oracle, bb, vr)                    \
     585              :   for (block_relation_iterator iter (oracle, bb, vr);           \
     586              :        !iter.m_done;                                            \
     587              :        iter.get_next_relation (vr))
     588              : 
     589              : #define FOR_EACH_RELATION_NAME(oracle, bb, name, vr)            \
     590              :   for (block_relation_iterator iter (oracle, bb, vr, name);     \
     591              :        !iter.m_done;                                            \
     592              :        iter.get_next_relation (vr))
     593              : 
     594              : 
     595              : // Return the number of bits associated with partial equivalency T.
     596              : // Return 0 if this is not a supported partial equivalency relation.
     597              : 
     598              : inline int
     599     18841301 : pe_to_bits (relation_kind t)
     600              : {
     601     18841301 :   switch (t)
     602              :   {
     603              :     case VREL_PE8:
     604              :       return 8;
     605              :     case VREL_PE16:
     606              :       return 16;
     607              :     case VREL_PE32:
     608              :       return 32;
     609              :     case VREL_PE64:
     610              :       return 64;
     611              :     default:
     612              :       return 0;
     613              :   }
     614              : }
     615              : 
     616              : // Return the partial equivalency code associated with the number of BITS.
     617              : // return VREL_VARYING if there is no exact match.
     618              : 
     619              : inline relation_kind
     620     39982614 : bits_to_pe (int bits)
     621              : {
     622     39982614 :   switch (bits)
     623              :   {
     624              :     case 8:
     625              :       return VREL_PE8;
     626              :     case 16:
     627              :       return VREL_PE16;
     628              :     case 32:
     629              :       return VREL_PE32;
     630              :     case 64:
     631              :       return VREL_PE64;
     632              :     default:
     633              :       return VREL_VARYING;
     634              :   }
     635              : }
     636              : 
     637              : // Given partial equivalencies T1 and T2, return the smallest kind.
     638              : 
     639              : inline relation_kind
     640      9126278 : pe_min (relation_kind t1, relation_kind t2)
     641              : {
     642      9126278 :   gcc_checking_assert (relation_partial_equiv_p (t1));
     643      9126278 :   gcc_checking_assert (relation_partial_equiv_p (t2));
     644              :   // VREL_PE are declared small to large, so simple min will suffice.
     645      9126278 :   return MIN (t1, t2);
     646              : }
     647              : #endif  /* GCC_VALUE_RELATION_H */
        

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