public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "guojiufu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/102087] [12 Regression] ICE on valid code at -O3 on x86_64-linux-gnu: in determine_exit_conditions, at tree-ssa-loop-manip.c:1049 since r12-3136-g3673dcf6d6baeb67
Date: Fri, 27 Aug 2021 13:27:38 +0000	[thread overview]
Message-ID: <bug-102087-4-mA6uir4sAM@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102087-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
Drafting patch to calculate three items: control, bound and cmp.
----
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 7af92d1c893..c6e4b24fd83 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -1482,7 +1482,7 @@ number_of_iterations_until_wrap (class loop *, tree type,
affine_iv *iv0,
                                 affine_iv *iv1, class tree_niter_desc *niter)
 {
   tree niter_type = unsigned_type_for (type);
-  tree step, num, assumptions, may_be_zero;
+  tree step, num, assumptions, may_be_zero, span;
   wide_int high, low, max, min;

   may_be_zero = fold_build2 (LE_EXPR, boolean_type_node, iv1->base,
iv0->base);
@@ -1513,6 +1513,8 @@ number_of_iterations_until_wrap (class loop *, tree type,
affine_iv *iv0,
        low = wi::to_wide (iv0->base);
       else
        low = min;
+
+      niter->control = *iv1;
     }
   /* {base, -C} < n.  */
   else if (tree_int_cst_sign_bit (iv0->step) && integer_zerop (iv1->step))
@@ -1533,6 +1535,8 @@ number_of_iterations_until_wrap (class loop *, tree type,
affine_iv *iv0,
        high = wi::to_wide (iv1->base);
       else
        high = max;
+
+      niter->control = *iv0;
     }
   else
     return false;
@@ -1556,6 +1560,14 @@ number_of_iterations_until_wrap (class loop *, tree
type, affine_iv *iv0,
                                      niter->assumptions, assumptions);

   niter->control.no_overflow = false;
+  tree niter_m1 = fold_build2 (MINUS_EXPR, niter_type, niter->niter,
+                             build_int_cst (niter_type, 1));
+  span = fold_build2 (MULT_EXPR, niter_type, niter_m1,
+                     fold_convert (niter_type, niter->control.step));
+  niter->bound = fold_build2 (PLUS_EXPR, niter_type, span,
+                             fold_convert (niter_type, niter->control.base));
+  niter->bound = fold_convert (type, niter->bound);
+  niter->cmp = NE_EXPR;

   return true;
 }
------------------------

While this code may generate complicated niter->bound if the step is not +-1.

  parent reply	other threads:[~2021-08-27 13:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26 20:35 [Bug tree-optimization/102087] New: ICE on valid code at -O3 on x86_64-linux-gnu: in determine_exit_conditions, at tree-ssa-loop-manip.c:1049 zhendong.su at inf dot ethz.ch
2021-08-27  7:05 ` [Bug tree-optimization/102087] [12 Regression] " rguenth at gcc dot gnu.org
2021-08-27  7:55 ` [Bug tree-optimization/102087] [12 Regression] ICE on valid code at -O3 on x86_64-linux-gnu: in determine_exit_conditions, at tree-ssa-loop-manip.c:1049 since r12-3136-g3673dcf6d6baeb67 marxin at gcc dot gnu.org
2021-08-27  7:55 ` marxin at gcc dot gnu.org
2021-08-27 10:04 ` guojiufu at gcc dot gnu.org
2021-08-27 12:52 ` hjl.tools at gmail dot com
2021-08-27 12:53 ` hjl.tools at gmail dot com
2021-08-27 13:27 ` guojiufu at gcc dot gnu.org [this message]
2021-08-27 14:08 ` guojiufu at gcc dot gnu.org
2021-08-28 20:32 ` dcb314 at hotmail dot com
2021-08-28 20:41 ` dcb314 at hotmail dot com
2021-08-30  3:26 ` guojiufu at gcc dot gnu.org
2021-09-02  9:22 ` pinskia at gcc dot gnu.org
2021-09-22 13:03 ` cvs-commit at gcc dot gnu.org
2021-09-24  7:58 ` dcb314 at hotmail dot com
2021-09-24 12:15 ` rguenth at gcc dot gnu.org
2021-09-24 17:47 ` dcb314 at hotmail dot com
2021-10-09  5:51 ` guojiufu at gcc dot gnu.org
2021-12-06 15:42 ` asolokha at gmx dot com
2021-12-06 17:43 ` dcb314 at hotmail dot com
2021-12-16  1:47 ` guojiufu at gcc dot gnu.org
2022-01-18  9:27 ` dcb314 at hotmail dot com
2022-01-18  9:37 ` marxin at gcc dot gnu.org
2022-01-19  9:32 ` guojiufu at gcc dot gnu.org
2022-01-24  9:07 ` cvs-commit at gcc dot gnu.org
2022-02-15 12:58 ` rguenth 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-102087-4-mA6uir4sAM@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).