public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/115154] [13/14/15 Regression] wrong code at optimization levels -O2, -O3, -Os since r13-7434-g682bbd364708fe Date: Sun, 19 May 2024 22:57:51 +0000 [thread overview] Message-ID: <bug-115154-4-CImTXfUhpf@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-115154-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115154 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Known to work|14.1.0 | Summary|[13 Regression] wrong code |[13/14/15 Regression] wrong |at optimization levels -O2, |code at optimization levels |-O3, -Os since |-O2, -O3, -Os since |r13-7434-g682bbd364708fe |r13-7434-g682bbd364708fe --- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This works and might be the best for GCC 13/14 but maybe I think we can do better. ``` diff --git a/gcc/match.pd b/gcc/match.pd index 0f9c34fa897..6bc512cabdf 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2400,7 +2400,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (convert (mult@0 zero_one_valued_p@1 INTEGER_CST@2)) (if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (@0)) - && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@0))) + && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@0)) + && (TYPE_UNSIGNED (type) || TYPE_PRECISION (type) > 1)) (mult (convert @1) (convert @2)))) /* (X << C) != 0 can be simplified to X, when C is zero_one_valued_p. ``` For bit 1 precision, look at the lower bit of the INTEGER_CST and decide if it should be @1 or `0` and that would avoid the overflow too. Note you can reproduce the failure on the trunk and GCC 14 by using -fsanitize=undefined which I missed in the original bug report and that is because r14-3432-gddd64a6ec3b38e is disable for undefined sanitizers case.
next prev parent reply other threads:[~2024-05-19 22:57 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-19 2:46 [Bug tree-optimization/115154] New: [13/14 Regression] wrong code at optimization levels -O2, -O3, -Os bic60176 at gmail dot com 2024-05-19 2:55 ` [Bug tree-optimization/115154] [13 " pinskia at gcc dot gnu.org 2024-05-19 3:04 ` pinskia at gcc dot gnu.org 2024-05-19 3:08 ` pinskia at gcc dot gnu.org 2024-05-19 7:23 ` sjames at gcc dot gnu.org 2024-05-19 14:05 ` [Bug tree-optimization/115154] [13 Regression] wrong code at optimization levels -O2, -O3, -Os since r13-7434-g682bbd364708fe sjames at gcc dot gnu.org 2024-05-19 22:09 ` sjames at gcc dot gnu.org 2024-05-19 22:17 ` pinskia at gcc dot gnu.org 2024-05-19 22:41 ` pinskia at gcc dot gnu.org 2024-05-19 22:47 ` pinskia at gcc dot gnu.org 2024-05-19 22:57 ` pinskia at gcc dot gnu.org [this message] 2024-05-19 22:59 ` [Bug tree-optimization/115154] [13/14/15 " pinskia at gcc dot gnu.org 2024-05-19 23:09 ` pinskia at gcc dot gnu.org 2024-05-20 7:29 ` pinskia at gcc dot gnu.org 2024-05-20 22:03 ` pinskia at gcc dot gnu.org 2024-05-21 9:20 ` jakub at gcc dot gnu.org 2024-05-21 14:24 ` cvs-commit at gcc dot gnu.org 2024-05-21 14:25 ` cvs-commit at gcc dot gnu.org 2024-05-21 14:29 ` cvs-commit at gcc dot gnu.org 2024-05-21 14:31 ` pinskia 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-115154-4-CImTXfUhpf@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).