Remove not needed __builtin_expect due to malloc predictor.
[official-gcc.git] / gcc / wide-int-range.h
blob4421bc8aecad90a1718b4e94ff67153ec1b390f9
1 /* Support routines for range operations on wide ints.
2 Copyright (C) 2018 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef GCC_WIDE_INT_RANGE_H
21 #define GCC_WIDE_INT_RANGE_H
23 extern bool wide_int_range_cross_product (wide_int &res_lb, wide_int &res_ub,
24 enum tree_code code, signop sign,
25 const wide_int &, const wide_int &,
26 const wide_int &, const wide_int &,
27 bool overflow_undefined);
28 extern bool wide_int_range_mult_wrapping (wide_int &res_lb,
29 wide_int &res_ub,
30 signop sign,
31 unsigned prec,
32 const wide_int &min0_,
33 const wide_int &max0_,
34 const wide_int &min1_,
35 const wide_int &max1_);
36 extern bool wide_int_range_multiplicative_op (wide_int &res_lb,
37 wide_int &res_ub,
38 enum tree_code code,
39 signop sign,
40 unsigned prec,
41 const wide_int &vr0_lb,
42 const wide_int &vr0_ub,
43 const wide_int &vr1_lb,
44 const wide_int &vr1_ub,
45 bool overflow_undefined,
46 bool overflow_wraps);
47 extern bool wide_int_range_lshift (wide_int &res_lb, wide_int &res_ub,
48 signop sign, unsigned prec,
49 const wide_int &, const wide_int &,
50 const wide_int &, const wide_int &,
51 bool overflow_undefined,
52 bool overflow_wraps);
53 extern void wide_int_range_set_zero_nonzero_bits (signop,
54 const wide_int &lb,
55 const wide_int &ub,
56 wide_int &may_be_nonzero,
57 wide_int &must_be_nonzero);
58 extern bool wide_int_range_can_optimize_bit_op (tree_code,
59 const wide_int &lb,
60 const wide_int &ub,
61 const wide_int &mask);
62 extern bool wide_int_range_bit_xor (wide_int &wmin, wide_int &wmax,
63 signop sign,
64 unsigned prec,
65 const wide_int &must_be_nonzero0,
66 const wide_int &may_be_nonzero0,
67 const wide_int &must_be_nonzero1,
68 const wide_int &may_be_nonzero1);
69 extern bool wide_int_range_bit_ior (wide_int &wmin, wide_int &wmax,
70 signop sign,
71 const wide_int &vr0_min,
72 const wide_int &vr0_max,
73 const wide_int &vr1_min,
74 const wide_int &vr1_max,
75 const wide_int &must_be_nonzero0,
76 const wide_int &may_be_nonzero0,
77 const wide_int &must_be_nonzero1,
78 const wide_int &may_be_nonzero1);
79 extern bool wide_int_range_bit_and (wide_int &wmin, wide_int &wmax,
80 signop sign,
81 unsigned prec,
82 const wide_int &vr0_min,
83 const wide_int &vr0_max,
84 const wide_int &vr1_min,
85 const wide_int &vr1_max,
86 const wide_int &must_be_nonzero0,
87 const wide_int &may_be_nonzero0,
88 const wide_int &must_be_nonzero1,
89 const wide_int &may_be_nonzero1);
90 extern void wide_int_range_trunc_mod (wide_int &wmin, wide_int &wmax,
91 signop sign,
92 unsigned prec,
93 const wide_int &vr0_min,
94 const wide_int &vr0_max,
95 const wide_int &vr1_min,
96 const wide_int &vr1_max);
98 /* Return TRUE if shifting by range [MIN, MAX] is undefined behavior. */
100 inline bool
101 wide_int_range_shift_undefined_p (signop sign, unsigned prec,
102 const wide_int &min, const wide_int &max)
104 /* ?? Note: The original comment said this only applied to
105 RSHIFT_EXPR, but it was being applied to both left and right
106 shifts. */
108 /* Shifting by any values outside [0..prec-1], gets undefined
109 behavior from the shift operation. We cannot even trust
110 SHIFT_COUNT_TRUNCATED at this stage, because that applies to rtl
111 shifts, and the operation at the tree level may be widened. */
112 return wi::lt_p (min, 0, sign) || wi::ge_p (max, prec, sign);
115 #endif /* GCC_WIDE_INT_RANGE_H */