public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10677] c++: Fix up constant expression __builtin_convertvector folding [PR104472] Date: Tue, 10 May 2022 08:23:41 +0000 (GMT) [thread overview] Message-ID: <20220510082341.70B663836004@sourceware.org> (raw) https://gcc.gnu.org/g:f755dd4bda6cb1ae5c6d8e9c3a285faea236d3c3 commit r10-10677-gf755dd4bda6cb1ae5c6d8e9c3a285faea236d3c3 Author: Jakub Jelinek <jakub@redhat.com> Date: Fri Feb 11 13:52:44 2022 +0100 c++: Fix up constant expression __builtin_convertvector folding [PR104472] The following testcase ICEs, because due to the -frounding-math fold_const_call fails, which is it returns NULL, and returning NULL from cxx_eval* is wrong, all the callers rely on them to either return folded value or original with *non_constant_p = true. The following patch does that, and additionally falls through into the default case where there is diagnostics for the !ctx->quiet case too. 2022-02-11 Jakub Jelinek <jakub@redhat.com> PR c++/104472 * constexpr.c (cxx_eval_internal_function) <case IFN_VEC_CONVERT>: Only return fold_const_call result if it is non-NULL. Otherwise fall through into the default: case to return t, set *non_constant_p and emit diagnostics if needed. * g++.dg/cpp0x/constexpr-104472.C: New test. (cherry picked from commit 84993d94e13ad2ab3aee151bb5a5e767cf75d51e) Diff: --- gcc/cp/constexpr.c | 9 +++------ gcc/testsuite/g++.dg/cpp0x/constexpr-104472.C | 9 +++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index cd8ef069dde..a72b3641e90 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1687,13 +1687,10 @@ cxx_eval_internal_function (const constexpr_ctx *ctx, tree t, false, non_constant_p, overflow_p); if (TREE_CODE (arg) == VECTOR_CST) - return fold_const_call (CFN_VEC_CONVERT, TREE_TYPE (t), arg); - else - { - *non_constant_p = true; - return t; - } + if (tree r = fold_const_call (CFN_VEC_CONVERT, TREE_TYPE (t), arg)) + return r; } + /* FALLTHRU */ default: if (!ctx->quiet) diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-104472.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-104472.C new file mode 100644 index 00000000000..c9c8bf414fe --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-104472.C @@ -0,0 +1,9 @@ +// PR c++/104472 +// { dg-options "-O2 -frounding-math" } +// { dg-add-options float16 } +// { dg-require-effective-target float16 } + +typedef short __attribute__((__vector_size__ (16))) V; +typedef _Float16 __attribute__((__vector_size__ (16))) F; + +V v = __builtin_convertvector (__builtin_convertvector ((V){5534}, F), V) < 8;
reply other threads:[~2022-05-10 8: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=20220510082341.70B663836004@sourceware.org \ --to=jakub@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).