public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Ball <ricbal02@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-10410] tree-optimization/114672 - WIDEN_MULT_PLUS_EXPR type mismatch Date: Thu, 2 May 2024 19:23:07 +0000 (GMT) [thread overview] Message-ID: <20240502192307.B4C7C3858D20@sourceware.org> (raw) https://gcc.gnu.org/g:87e37c72cfb153d65ac8b26d6f2d1fe155818318 commit r12-10410-g87e37c72cfb153d65ac8b26d6f2d1fe155818318 Author: Richard Biener <rguenther@suse.de> Date: Wed Apr 10 10:33:40 2024 +0200 tree-optimization/114672 - WIDEN_MULT_PLUS_EXPR type mismatch The following makes sure to restrict WIDEN_MULT*_EXPR to a mode precision final compute type as the mode is used to find the optab and type checking chokes when seeing bit-precisions later which would likely also not properly expanded to RTL. PR tree-optimization/114672 * tree-ssa-math-opts.cc (convert_plusminus_to_widen): Only allow mode-precision results. * gcc.dg/torture/pr114672.c: New testcase. (cherry picked from commit 912753cc5f18d786e334dd425469fa7f93155661) Diff: --- gcc/testsuite/gcc.dg/torture/pr114672.c | 14 ++++++++++++++ gcc/tree-ssa-math-opts.cc | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/torture/pr114672.c b/gcc/testsuite/gcc.dg/torture/pr114672.c new file mode 100644 index 00000000000..b69511fe8db --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr114672.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +struct { + __INT64_TYPE__ m : 60; +} s; + +short a; +short b; + +void +foo () +{ + s.m += a * b; +} diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc index bab0cc5aef4..ffd8eebd2a9 100644 --- a/gcc/tree-ssa-math-opts.cc +++ b/gcc/tree-ssa-math-opts.cc @@ -2802,8 +2802,9 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple *stmt, lhs = gimple_assign_lhs (stmt); type = TREE_TYPE (lhs); - if (TREE_CODE (type) != INTEGER_TYPE - && TREE_CODE (type) != FIXED_POINT_TYPE) + if ((TREE_CODE (type) != INTEGER_TYPE + && TREE_CODE (type) != FIXED_POINT_TYPE) + || !type_has_mode_precision_p (type)) return false; if (code == MINUS_EXPR)
reply other threads:[~2024-05-02 19:23 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240502192307.B4C7C3858D20@sourceware.org \ --to=ricbal02@gcc.gnu.org \ --cc=gcc-cvs@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).