[Bug tree-optimization/104334] [12 Regression] Ranger/dom miscompilation since r12-4694-gcb153222404e2e
amacleod at redhat dot com
gcc-bugzilla@gcc.gnu.org
Wed Feb 2 13:50:36 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104334
--- Comment #16 from Andrew Macleod <amacleod at redhat dot com> ---
(In reply to Jakub Jelinek from comment #13)
> So, I think one way is to punt on these small precision types, like:
> --- range-op.cc.jj1 2022-01-13 22:29:15.345831749 +0100
> +++ range-op.cc 2022-02-02 13:44:05.813637820 +0100
> @@ -148,11 +148,13 @@ range_operator::wi_fold_in_parts (irange
> int_range_max tmp;
> wide_int rh_range = wi::sub (rh_ub, rh_lb, TYPE_SIGN (type), &ov_rh);
> wide_int lh_range = wi::sub (lh_ub, lh_lb, TYPE_SIGN (type), &ov_lh);
> - signop sign = TYPE_SIGN (type);;
> + signop sign = TYPE_SIGN (type);
> // If there are 2, 3, or 4 values in the RH range, do them separately.
> // Call wi_fold_in_parts to check the RH side.
> - if (wi::gt_p (rh_range, 0, sign) && wi::lt_p (rh_range, 4, sign)
> - && ov_rh == wi::OVF_NONE)
> + if (wi::min_precision (4, sign) <= wi::get_precision (rh_range)
> + && ov_rh == wi::OVF_NONE
> + && wi::gt_p (rh_range, 0, sign)
> + && wi::lt_p (rh_range, 4, sign))
> {
> wi_fold_in_parts (r, type, lh_lb, lh_ub, rh_lb, rh_lb);
> if (wi::gt_p (rh_range, 1, sign))
> @@ -170,8 +172,10 @@ range_operator::wi_fold_in_parts (irange
> }
> // Otherise check for 2, 3, or 4 values in the LH range and split them up.
> // The RH side has been checked, so no recursion needed.
> - else if (wi::gt_p (lh_range, 0, sign) && wi::lt_p (lh_range, 4, sign)
> - && ov_lh == wi::OVF_NONE)
> + else if (wi::min_precision (4, sign) <= wi::get_precision (lh_range)
> + && ov_lh == wi::OVF_NONE
> + && wi::gt_p (lh_range, 0, sign)
> + && wi::lt_p (lh_range, 4, sign))
> {
> wi_fold (r, type, lh_lb, lh_lb, rh_lb, rh_ub);
> if (wi::gt_p (lh_range, 1, sign))
> i.e. only optimize if 4 is representable in the given wide_int.
> The other option is to be extra careful.
yes, I think if the precision is small, simply don't try to break it up. We
special case 1 bit all over the place for this reason.
Like you did, or simply this way. Either amounts to the same thing and wi_fold
get called on the range.
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 19bdf30911a..a88fb7b8932 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -149,6 +149,11 @@ range_operator::wi_fold_in_parts (irange &r, tree type,
wide_int rh_range = wi::sub (rh_ub, rh_lb, TYPE_SIGN (type), &ov_rh);
wide_int lh_range = wi::sub (lh_ub, lh_lb, TYPE_SIGN (type), &ov_lh);
signop sign = TYPE_SIGN (type);;
+
+ // If precision of the type is too small, don't bother trying to split it
up.
+ if (TYPE_PRECISION (type) <= 3)
+ wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub);
+ else
// If there are 2, 3, or 4 values in the RH range, do them separately.
// Call wi_fold_in_parts to check the RH side.
if (wi::gt_p (rh_range, 0, sign) && wi::lt_p (rh_range, 4, sign)
More information about the Gcc-bugs
mailing list