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: Tue, 15 Mar 2022 13:11:38 +0000 [thread overview] Message-ID: <bug-104931-4-1NBaApwLTt@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 #2 from Richard Biener <rguenth at gcc dot gnu.org> --- But maybe the code relies on a positive 'delta' - after all the same issue must exist for integer typed IVs. Probably most interesting cases get folded early in the correct way if they do not iterate. Given niter_type is unsigned_type_for (type) the use of FLOOR_MOD_EXPR seems pointless but would be required when doing a signed floor-mod as in the fix. Note there's tree niter_type = TREE_TYPE (step); tree mod = fold_build2 (FLOOR_MOD_EXPR, niter_type, *delta, step); .. if (integer_nonzerop (mod)) mod = fold_build2 (MINUS_EXPR, niter_type, step, mod); .. mpz_init (mmod); wi::to_mpz (wi::to_wide (mod), mmod, UNSIGNED); mpz_neg (mmod, mmod); so there's evidence that 'mod' is assumed to be positive in the end but 'delta' can be effectively signed here. Note 'step' is the absolute value of step, it's always (made) positive. The code has been this way since Zdenek wrote it. The proposed patch has passed bootstrap & testing (but I believe it's incomplete).
next prev parent reply other threads:[~2022-03-15 13:11 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 [this message] 2022-03-16 12:34 ` rguenth at gcc dot gnu.org 2022-03-16 13:09 ` rguenth at gcc dot gnu.org 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-1NBaApwLTt@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: linkBe 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).