GCC Middle and Back End API Reference
Go to the documentation of this file.
1/* Header file for gimple range phi analysis.
2 Copyright (C) 2023-2024 Free Software Foundation, Inc.
3 Contributed by Andrew MacLeod <amacleod@redhat.com>.
5This file is part of GCC.
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
24// -------------------------------------------------------------------------
26// A PHI_GROUP consists of a set of SSA_NAMES which are all PHI_DEFS, and
27// their arguemnts contain nothing but other PHI defintions, with at most
28// 2 exceptions:
29// 1 - An initial value. This is either a constant, or another non-phi name
30// with a single incoming edge to the cycle group
31// 2 - A modifier statement which adjusts the value. ie, name2 = phi_name + 1
32// The initial range is used to create one bound and the modifier is examined
33// to determine the other bound.
34// All members of the PHI cycle will be given the same range.
36// For example, given the follwoing sequences:
37// qa_20 = qa_10 + 1;
38// qa_9 = PHI <qa_10(3), qa_20(4)>
39// qa_10 = PHI <0(2), qa_9(5)>
41// We can determine the following group:
43// PHI cycle members qa_9, qa_10
44// Initial value : 0
45// modifier stmt: qa_20 = qa_10 + 1;
47// Based on just this analysis, We can project that qa_9 and qa_10 will have
48// a range of [0, +INF].
53 phi_group (bitmap bm, irange &init_range, gimple *mod, range_query *q);
54 phi_group (const phi_group &g);
55 const_bitmap group () const { return m_group; }
56 const vrange &range () const { return m_vr; }
57 gimple *modifier_stmt () const { return m_modifier; }
58 void dump (FILE *);
62 static unsigned is_modifier_p (gimple *s, const bitmap bm);
64 gimple *m_modifier; // Single stmt which modifies phi group.
65 unsigned m_modifier_op; // Operand of group member in modifier stmt.
67 friend class phi_analyzer;
70// The phi anlyzer will return the group that name belongs to.
71// If inforamtion is not known about a name yet, analysis is conducted by
72// looking at the arguments to PHIS and following them to their defs to
73// determine whether the conditions are met to form a new group.
81 void dump (FILE *f);
83 phi_group *group (tree name) const;
84 void process_phi (gphi *phi);
88 bitmap m_simple; // Processed, not part of a group.
89 bitmap m_current; // Potential group currently being analyzed.
95// These are the APIs to start and stop a phi analyzerin a SCEV like manner.
96// There can only be one operating at any given time.
97// When initialized, a range-query if provided to do lookups of values for
98// PHIs and to evaluate modifier and initial value statements.
99// To avoid problems, this should be some form of constant query, like
100// global_range_query or better yet a const_query from a functioning ranger.
107#endif // GCC_SSA_RANGE_PHI_H
Definition value-range.h:273
Definition gimple-range-phi.h:76
vec< phi_group * > m_tab
Definition gimple-range-phi.h:91
phi_group * group(tree name) const
Definition gimple-range-phi.cc:284
vec< phi_group * > m_phi_groups
Definition gimple-range-phi.h:90
phi_analyzer(range_query &)
Definition gimple-range-phi.cc:257
bitmap m_simple
Definition gimple-range-phi.h:88
bitmap_obstack m_bitmaps
Definition gimple-range-phi.h:92
bitmap m_current
Definition gimple-range-phi.h:89
void process_phi(gphi *phi)
Definition gimple-range-phi.cc:331
void dump(FILE *f)
Definition gimple-range-phi.cc:511
phi_group * operator[](tree name)
Definition gimple-range-phi.cc:300
Definition gimple-range-phi.cc:271
range_query & m_global
Definition gimple-range-phi.h:85
vec< tree > m_work
Definition gimple-range-phi.h:86
Definition gimple-range-phi.h:51
phi_group(bitmap bm, irange &init_range, gimple *mod, range_query *q)
Definition gimple-range-phi.cc:91
bool calculate_using_modifier(range_query *q)
Definition gimple-range-phi.cc:136
gimple * m_modifier
Definition gimple-range-phi.h:64
const_bitmap group() const
Definition gimple-range-phi.h:55
bitmap m_group
Definition gimple-range-phi.h:63
unsigned m_modifier_op
Definition gimple-range-phi.h:65
void dump(FILE *)
Definition gimple-range-phi.cc:233
gimple * modifier_stmt() const
Definition gimple-range-phi.h:57
int_range_max m_vr
Definition gimple-range-phi.h:66
bool refine_using_relation(relation_kind k)
Definition gimple-range-phi.cc:189
const vrange & range() const
Definition gimple-range-phi.h:56
static unsigned is_modifier_p(gimple *s, const bitmap bm)
Definition gimple-range-phi.cc:115
Definition value-query.h:55
Definition value-range.h:78
gcc::context * g
Definition context.cc:29
const class bitmap_head * const_bitmap
Definition coretypes.h:52
class bitmap_head * bitmap
Definition coretypes.h:51
union tree_node * tree
Definition coretypes.h:97
void phi_analysis_initialize(range_query &)
Definition gimple-range-phi.cc:46
bool phi_analysis_available_p()
Definition gimple-range-phi.cc:64
void phi_analysis_finalize()
Definition gimple-range-phi.cc:55
phi_analyzer & phi_analysis()
Definition gimple-range-phi.cc:71
Definition bitmap.h:294
Definition gimple.h:225
Definition gimple.h:462
Definition vec.h:450
enum relation_kind_t relation_kind