]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gimple-range-infer.h
tree-optimization/114736 - SLP DFS walk issue
[thirdparty/gcc.git] / gcc / gimple-range-infer.h
CommitLineData
156d7d8d 1/* Header file for gimple range inference.
a945c346 2 Copyright (C) 2022-2024 Free Software Foundation, Inc.
b7501739
AM
3 Contributed by Andrew MacLeod <amacleod@redhat.com>.
4
5This file is part of GCC.
6
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
10version.
11
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.
16
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/>. */
20
21#ifndef GCC_GIMPLE_RANGE_SIDE_H
22#define GCC_GIMPLE_RANGE_SIDE_H
23
156d7d8d
AM
24// Inferred ranges are ranges which are applied to use operands as a by product
25// of executing an operation.
b7501739 26
156d7d8d
AM
27// This class manages an on-demand summary of inferred ranges for a statement.
28// It can be instantiated as required and provides a list of inferred ranges.
761cc32e 29// New inferred ranges should be added in the constructor of this class.
b7501739 30
156d7d8d 31class gimple_infer_range
b7501739
AM
32{
33public:
156d7d8d 34 gimple_infer_range (gimple *s);
b7501739
AM
35 inline unsigned num () const { return num_args; }
36 inline tree name (unsigned index) const
37 { gcc_checking_assert (index < num_args); return m_names[index]; }
45c8523d 38 inline const vrange& range (unsigned index) const
b7501739 39 { gcc_checking_assert (index < num_args); return m_ranges[index]; }
45c8523d 40 void add_range (tree name, vrange &range);
b7501739
AM
41 void add_nonzero (tree name);
42private:
53e6d7a3 43 void check_assume_func (gcall *call);
b7501739
AM
44 unsigned num_args;
45 static const int size_limit = 10;
46 tree m_names[size_limit];
45c8523d 47 Value_Range m_ranges[size_limit];
b7501739
AM
48 inline void bump_index () { if (num_args < size_limit - 1) num_args++; }
49};
50
156d7d8d
AM
51// This class manages a list of inferred ranges for each basic block.
52// As inferences are made, they can be registered to a block and later
761cc32e 53// queried. When constructed with a TRUE flag, immediate uses chains are
b7501739 54// followed the first time a name is referenced and block populated if
156d7d8d 55// there are any inferred ranges.
b7501739 56
156d7d8d 57class infer_range_manager
b7501739
AM
58{
59public:
156d7d8d
AM
60 infer_range_manager (bool do_search);
61 ~infer_range_manager ();
45c8523d 62 void add_range (tree name, basic_block bb, const vrange &r);
b7501739
AM
63 void add_nonzero (tree name, basic_block bb);
64 bool has_range_p (tree name, basic_block bb);
c8381199 65 bool has_range_p (basic_block bb);
45c8523d 66 bool maybe_adjust_range (vrange &r, tree name, basic_block bb);
b7501739
AM
67private:
68 class exit_range_head
69 {
70 public:
71 bitmap m_names; // list of names with an outgoing range.
72 class exit_range *head;
73 int m_num_ranges;
74 exit_range *find_ptr (tree name);
75 };
76 void register_all_uses (tree name);
77 vec <exit_range_head> m_on_exit;
45c8523d
AH
78 const vrange &get_nonzero (tree name);
79 vec <vrange *> m_nonzero;
b7501739
AM
80 bitmap m_seen;
81 bitmap_obstack m_bitmaps;
82 struct obstack m_list_obstack;
e1366a7e 83 class vrange_allocator *m_range_allocator;
b7501739
AM
84};
85
86#endif // GCC_GIMPLE_RANGE_SIDE_H