public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/104334] [12 Regression] Ranger/dom miscompilation since r12-4694-gcb153222404e2e
Date: Wed, 02 Feb 2022 12:46:32 +0000	[thread overview]
Message-ID: <bug-104334-4-G4doCBRFBj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104334-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104334

--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
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.

  parent reply	other threads:[~2022-02-02 12:46 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01 20:35 [Bug tree-optimization/104334] New: Ranger/dom miscompilation jakub at gcc dot gnu.org
2022-02-01 20:35 ` [Bug tree-optimization/104334] [12 Regression] " jakub at gcc dot gnu.org
2022-02-01 20:48 ` jakub at gcc dot gnu.org
2022-02-02  1:27 ` pinskia at gcc dot gnu.org
2022-02-02 10:18 ` marxin at gcc dot gnu.org
2022-02-02 10:19 ` marxin at gcc dot gnu.org
2022-02-02 10:29 ` pinskia at gcc dot gnu.org
2022-02-02 10:37 ` jakub at gcc dot gnu.org
2022-02-02 12:06 ` jakub at gcc dot gnu.org
2022-02-02 12:13 ` jakub at gcc dot gnu.org
2022-02-02 12:26 ` rsandifo at gcc dot gnu.org
2022-02-02 12:30 ` rguenther at suse dot de
2022-02-02 12:31 ` jakub at gcc dot gnu.org
2022-02-02 12:38 ` [Bug tree-optimization/104334] [12 Regression] Ranger/dom miscompilation since r12-4694-gcb153222404e2e marxin at gcc dot gnu.org
2022-02-02 12:46 ` jakub at gcc dot gnu.org [this message]
2022-02-02 12:51 ` marxin at gcc dot gnu.org
2022-02-02 13:39 ` jakub at gcc dot gnu.org
2022-02-02 13:50 ` amacleod at redhat dot com
2022-02-02 13:56 ` rguenther at suse dot de
2022-02-02 14:00 ` jakub at gcc dot gnu.org
2022-02-02 14:12 ` jakub at gcc dot gnu.org
2022-02-02 15:07 ` rsandifo at gcc dot gnu.org
2022-02-03  8:46 ` cvs-commit at gcc dot gnu.org
2022-02-03  8:46 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-104334-4-G4doCBRFBj@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).