(if (TYPE_OVERFLOW_UNDEFINED (type))
@0
#if GIMPLE
- (if (TREE_CODE (@0) == SSA_NAME
- && (TREE_CODE (@1) == SSA_NAME || TREE_CODE (@1) == INTEGER_CST))
- (with
- {
- bool overflowed = true;
- wide_int wmin0, wmax0;
- if (get_range_info (@0, &wmin0, &wmax0) == VR_RANGE)
- {
- /* If the multiplication can't overflow/wrap around, then
- it can be optimized too. */
- wide_int wmin1, wmax1;
- wi::overflow_type min_ovf, max_ovf;
- if (TREE_CODE (@1) == INTEGER_CST)
- {
- wmin1 = wi::to_wide (@1);
- wi::mul (wmin0, wmin1, TYPE_SIGN (type), &min_ovf);
- wi::mul (wmax0, wmin1, TYPE_SIGN (type), &max_ovf);
- if (min_ovf == wi::OVF_NONE && max_ovf == wi::OVF_NONE)
- overflowed = false;
- }
- else if (get_range_info (@1, &wmin1, &wmax1) == VR_RANGE)
- {
- wi::mul (wmin0, wmin1, TYPE_SIGN (type), &min_ovf);
- wi::mul (wmax0, wmax1, TYPE_SIGN (type), &max_ovf);
- if (min_ovf == wi::OVF_NONE && max_ovf == wi::OVF_NONE)
- {
- wi::mul (wmin0, wmax1, TYPE_SIGN (type), &min_ovf);
- wi::mul (wmax0, wmin1, TYPE_SIGN (type), &max_ovf);
- if (min_ovf == wi::OVF_NONE && max_ovf == wi::OVF_NONE)
- overflowed = false;
- }
- }
- }
- }
- (if (!overflowed)
- @0)))
+ (with
+ {
+ bool overflowed = true;
+ wide_int wmin0, wmax0, wmin1, wmax1;
+ if (INTEGRAL_TYPE_P (type)
+ && get_range_info (@0, &wmin0, &wmax0) == VR_RANGE
+ && get_range_info (@1, &wmin1, &wmax1) == VR_RANGE)
+ {
+ /* If the multiplication can't overflow/wrap around, then
+ it can be optimized too. */
+ wi::overflow_type min_ovf, max_ovf;
+ wi::mul (wmin0, wmin1, TYPE_SIGN (type), &min_ovf);
+ wi::mul (wmax0, wmax1, TYPE_SIGN (type), &max_ovf);
+ if (min_ovf == wi::OVF_NONE && max_ovf == wi::OVF_NONE)
+ {
+ wi::mul (wmin0, wmax1, TYPE_SIGN (type), &min_ovf);
+ wi::mul (wmax0, wmin1, TYPE_SIGN (type), &max_ovf);
+ if (min_ovf == wi::OVF_NONE && max_ovf == wi::OVF_NONE)
+ overflowed = false;
+ }
+ }
+ }
+ (if (!overflowed)
+ @0))
#endif
))))
if (integer_zerop (step))
return false;
- if (TREE_CODE (base) == INTEGER_CST)
- base_min = base_max = wi::to_wide (base);
- else if (TREE_CODE (base) == SSA_NAME
- && INTEGRAL_TYPE_P (TREE_TYPE (base))
- && get_range_info (base, &base_min, &base_max) == VR_RANGE)
- ;
- else
+ if (!INTEGRAL_TYPE_P (TREE_TYPE (base))
+ || get_range_info (base, &base_min, &base_max) != VR_RANGE)
return true;
- if (TREE_CODE (step) == INTEGER_CST)
- step_min = step_max = wi::to_wide (step);
- else if (TREE_CODE (step) == SSA_NAME
- && INTEGRAL_TYPE_P (TREE_TYPE (step))
- && get_range_info (step, &step_min, &step_max) == VR_RANGE)
- ;
- else
+ if (!INTEGRAL_TYPE_P (TREE_TYPE (step))
+ || get_range_info (step, &step_min, &step_max) != VR_RANGE)
return true;
if (!get_max_loop_iterations (loop, &nit))
wide_int cntrange[2];
- if (TREE_CODE (cnt) == INTEGER_CST)
- cntrange[0] = cntrange[1] = wi::to_wide (cnt);
- else if (TREE_CODE (cnt) == SSA_NAME)
+ // FIXME: Use range_query instead of global ranges.
+ enum value_range_kind rng = get_range_info (cnt, cntrange, cntrange + 1);
+ if (rng == VR_RANGE)
+ ;
+ else if (rng == VR_ANTI_RANGE)
{
- // FIXME: Use range_query instead of global ranges.
- enum value_range_kind rng = get_range_info (cnt, cntrange, cntrange + 1);
- if (rng == VR_RANGE)
- ;
- else if (rng == VR_ANTI_RANGE)
- {
- wide_int maxobjsize = wi::to_wide (TYPE_MAX_VALUE (ptrdiff_type_node));
+ wide_int maxobjsize = wi::to_wide (TYPE_MAX_VALUE (ptrdiff_type_node));
- if (wi::ltu_p (cntrange[1], maxobjsize))
- {
- cntrange[0] = cntrange[1] + 1;
- cntrange[1] = maxobjsize;
- }
- else
- {
- cntrange[1] = cntrange[0] - 1;
- cntrange[0] = wi::zero (TYPE_PRECISION (TREE_TYPE (cnt)));
- }
+ if (wi::ltu_p (cntrange[1], maxobjsize))
+ {
+ cntrange[0] = cntrange[1] + 1;
+ cntrange[1] = maxobjsize;
}
else
- return false;
+ {
+ cntrange[1] = cntrange[0] - 1;
+ cntrange[0] = wi::zero (TYPE_PRECISION (TREE_TYPE (cnt)));
+ }
}
else
return false;
is used to determine if MIN and MAX are valid values. */
enum value_range_kind
-get_range_info (const_tree name, wide_int *min, wide_int *max)
+get_range_info (const_tree expr, wide_int *min, wide_int *max)
{
- gcc_assert (!POINTER_TYPE_P (TREE_TYPE (name)));
+ gcc_assert (!POINTER_TYPE_P (TREE_TYPE (expr)));
gcc_assert (min && max);
- range_info_def *ri = SSA_NAME_RANGE_INFO (name);
+ if (TREE_CODE (expr) == INTEGER_CST)
+ {
+ *min = wi::to_wide (expr);
+ *max = *min;
+ return VR_RANGE;
+ }
+ if (TREE_CODE (expr) != SSA_NAME)
+ return VR_VARYING;
+
+ range_info_def *ri = SSA_NAME_RANGE_INFO (expr);
/* Return VR_VARYING for SSA_NAMEs with NULL RANGE_INFO or SSA_NAMEs
with integral types width > 2 * HOST_BITS_PER_WIDE_INT precision. */
- if (!ri || (GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (TREE_TYPE (name)))
+ if (!ri || (GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (TREE_TYPE (expr)))
> 2 * HOST_BITS_PER_WIDE_INT))
return VR_VARYING;
*min = ri->get_min ();
*max = ri->get_max ();
- return SSA_NAME_RANGE_TYPE (name);
+ return SSA_NAME_RANGE_TYPE (expr);
}
/* Gets range information corresponding to ssa_name NAME and stores it