public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/104931] wrong-code with number_of_iterations_lt_to_ne
Date: Wed, 16 Mar 2022 13:09:41 +0000 [thread overview]
Message-ID: <bug-104931-4-yRvVMjMMGj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104931-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104931
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #3)
> The bug was made latent by g:51d464b608b38b9e2007948d10b1e0f1dcec142c which
> ensured that
>
> /* If the loop exits immediately, there is nothing to do. */
> tree tem = fold_binary (code, boolean_type_node, iv0->base, iv1->base);
> if (tem && integer_zerop (tem))
> {
> if (!every_iteration)
> return false;
> niter->niter = build_int_cst (unsigned_type_for (type), 0);
> niter->max = 0;
> return true;
> }
>
> triggered, folding (_2 + 4294967272) + 12 < _2 + 4294967272 to false. That's
> the following part of the revision, and it probably triggers when doing
> expand_simple_operations.
>
> diff --git a/gcc/match.pd b/gcc/match.pd
> index 84c9b918041..f5dcbf32bc7 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -2143,6 +2143,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
> (simplify
> (pointer_plus (pointer_plus:s @0 @1) @3)
> (pointer_plus @0 (plus @1 @3)))
> +#if GENERIC
> +(simplify
> + (pointer_plus (convert:s (pointer_plus:s @0 @1)) @3)
> + (convert:type (pointer_plus @0 (plus @1 @3))))
> +#endif
>
> /* Pattern match
>
> It does seem to me that niter analysis relies on statically detecting
> not rolling loops, at least for the cases we assume no overflow happens
> and we use number_of_iterations_lt_to_ne. I can't convince myself that
> only INTEGER_CST appearant negative delta are problematic for
> pointer types (which we always assume to have no overflow), but that would
> be the most simplistic solution here. Still "negative" delta values should
> be problematic for all cases, and since we only restrict us to constant
> modulo, delta can also be non-constant.
I verified backporting the above fixes the issue. That's really the patch
I'm most comfortable with at this point ... :/
next prev parent reply other threads:[~2022-03-16 13:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-15 10:20 [Bug tree-optimization/104931] New: " rguenth at gcc dot gnu.org
2022-03-15 10:20 ` [Bug tree-optimization/104931] " rguenth at gcc dot gnu.org
2022-03-15 10:37 ` rguenth at gcc dot gnu.org
2022-03-15 13:11 ` rguenth at gcc dot gnu.org
2022-03-16 12:34 ` rguenth at gcc dot gnu.org
2022-03-16 13:09 ` rguenth at gcc dot gnu.org [this message]
2022-03-16 13:14 ` [Bug tree-optimization/104931] [9/10/11 Regression] " rguenth at gcc dot gnu.org
2022-03-16 13:32 ` rguenth at gcc dot gnu.org
2022-03-17 13:45 ` rguenth at gcc dot gnu.org
2022-03-17 13:46 ` rguenth at gcc dot gnu.org
2022-03-17 13:53 ` rguenth at gcc dot gnu.org
2022-03-17 14:27 ` rguenth at gcc dot gnu.org
2022-03-23 14:08 ` cvs-commit at gcc dot gnu.org
2022-05-27 9:47 ` [Bug tree-optimization/104931] [10 " rguenth at gcc dot gnu.org
2022-06-28 10:48 ` jakub at gcc dot gnu.org
2023-07-07 9: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-104931-4-yRvVMjMMGj@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).