public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114965] [13/14/15 Regression] wrong code generated for Emacs/Gnulib strftime (regression from 13.2) Date: Wed, 08 May 2024 08:19:19 +0000 [thread overview] Message-ID: <bug-114965-4-YLmQBp7AdT@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-114965-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114965 --- Comment #14 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:d54151df3ba0ee3203e0b8cb8f8fcd168a766c51 commit r14-10184-gd54151df3ba0ee3203e0b8cb8f8fcd168a766c51 Author: Jakub Jelinek <jakub@redhat.com> Date: Wed May 8 10:17:32 2024 +0200 reassoc: Fix up optimize_range_tests_to_bit_test [PR114965] The optimize_range_tests_to_bit_test optimization normally emits a range test first: if (entry_test_needed) { tem = build_range_check (loc, optype, unshare_expr (exp), false, lowi, high); if (tem == NULL_TREE || is_gimple_val (tem)) continue; } so during the bit test we already know that exp is in the [lowi, high] range, but skips it if we have range info which tells us this isn't necessary. Also, normally it emits shifts by exp - lowi counter, but has an optimization to use just exp counter if the mask isn't a more expensive constant in that case and lowi is > 0 and high is smaller than prec. The following testcase is miscompiled because the two abnormal cases are triggered. The range of exp is [43, 43][48, 48][95, 95], so we on 64-bit arch decide we don't need the entry test, because 95 - 43 < 64. And we also decide to use just exp as counter, because the range test tests just for exp == 43 || exp == 48, so high is smaller than 64 too. Because 95 is in the exp range, we can't do that, we'd either need to do a range test first, i.e. if (exp - 43U <= 48U - 43U) if ((1UL << exp) & mask1)) or need to subtract lowi from the shift counter, i.e. if ((1UL << (exp - 43)) & mask2) but can't do both unless r.upper_bound () is < prec. The following patch ensures that. 2024-05-08 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/114965 * tree-ssa-reassoc.cc (optimize_range_tests_to_bit_test): Don't try to optimize away exp - lowi subtraction from shift count unless entry test is emitted or unless r.upper_bound () is smaller than prec. * gcc.c-torture/execute/pr114965.c: New test. (cherry picked from commit 9adec2d91e62a479474ae79df5b455fd4b8463ba)
next prev parent reply other threads:[~2024-05-08 8:19 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-06 22:17 [Bug c/114965] New: " eggert at cs dot ucla.edu 2024-05-06 23:05 ` [Bug middle-end/114965] " pinskia at gcc dot gnu.org 2024-05-06 23:07 ` [Bug tree-optimization/114965] [14/15 Regression] " pinskia at gcc dot gnu.org 2024-05-06 23:08 ` pinskia at gcc dot gnu.org 2024-05-06 23:10 ` [Bug tree-optimization/114965] [13/14/15 " pinskia at gcc dot gnu.org 2024-05-06 23:35 ` pinskia at gcc dot gnu.org 2024-05-06 23:45 ` pinskia at gcc dot gnu.org 2024-05-07 4:45 ` sjames at gcc dot gnu.org 2024-05-07 8:51 ` rguenth at gcc dot gnu.org 2024-05-07 9:49 ` sjames at gcc dot gnu.org 2024-05-07 11:25 ` jakub at gcc dot gnu.org 2024-05-07 11:49 ` jakub at gcc dot gnu.org 2024-05-07 16:24 ` jakub at gcc dot gnu.org 2024-05-07 16:38 ` eggert at cs dot ucla.edu 2024-05-08 8:18 ` cvs-commit at gcc dot gnu.org 2024-05-08 8:19 ` cvs-commit at gcc dot gnu.org [this message] 2024-05-08 8:20 ` [Bug tree-optimization/114965] [13 " jakub at gcc dot gnu.org 2024-05-09 4:27 ` cvs-commit at gcc dot gnu.org 2024-05-09 8:19 ` 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-114965-4-YLmQBp7AdT@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).