]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/range.cc
1 /* Misc range functions.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 Contributed by Aldy Hernandez <aldyh@redhat.com>.
5 This file is part of GCC.
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
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
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/>. */
23 #include "coretypes.h"
27 #include "gimple-pretty-print.h"
28 #include "fold-const.h"
33 range_intersect (const value_range
&r1
, const value_range
&r2
)
41 range_invert (const value_range
&r1
)
49 range_union (const value_range
&r1
, const value_range
&r2
)
57 range_zero (tree type
)
59 return value_range (build_zero_cst (type
), build_zero_cst (type
));
63 range_nonzero (tree type
)
65 return value_range (build_zero_cst (type
), build_zero_cst (type
),
70 range_positives (tree type
)
72 unsigned prec
= TYPE_PRECISION (type
);
73 signop sign
= TYPE_SIGN (type
);
74 return value_range (type
, wi::zero (prec
), wi::max_value (prec
, sign
));
78 range_negatives (tree type
)
80 unsigned prec
= TYPE_PRECISION (type
);
81 signop sign
= TYPE_SIGN (type
);
86 r
= value_range (type
, wi::min_value (prec
, sign
), wi::minus_one (prec
));