Line data Source code
1 : /* Misc range functions.
2 : Copyright (C) 2017-2026 Free Software Foundation, Inc.
3 : Contributed by Aldy Hernandez <aldyh@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 : #include "config.h"
22 : #include "system.h"
23 : #include "coretypes.h"
24 : #include "backend.h"
25 : #include "tree.h"
26 : #include "gimple.h"
27 : #include "gimple-pretty-print.h"
28 : #include "fold-const.h"
29 : #include "ssa.h"
30 : #include "range.h"
31 :
32 : int_range<2>
33 59988 : range_positives (tree type)
34 : {
35 59988 : unsigned prec = TYPE_PRECISION (type);
36 59988 : signop sign = TYPE_SIGN (type);
37 59988 : return int_range<2> (type, wi::zero (prec), wi::max_value (prec, sign));
38 : }
39 :
40 : int_range<2>
41 3663463 : range_negatives (tree type)
42 : {
43 3663463 : unsigned prec = TYPE_PRECISION (type);
44 3663463 : signop sign = TYPE_SIGN (type);
45 3663463 : int_range<2> r;
46 3663463 : if (sign == UNSIGNED)
47 0 : r.set_undefined ();
48 : else
49 3663529 : r.set (type, wi::min_value (prec, sign), wi::minus_one (prec));
50 3663463 : return r;
51 : }
|