public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3374] expr: Fix ICE on BFmode -> SFmode conversion of constant [PR107262]
@ 2022-10-19 9:30 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2022-10-19 9:30 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:65b98fc763d14d371fcf37a17e33519012ec2bac
commit r13-3374-g65b98fc763d14d371fcf37a17e33519012ec2bac
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Oct 19 11:29:44 2022 +0200
expr: Fix ICE on BFmode -> SFmode conversion of constant [PR107262]
I forgot to handle the case where lowpart_subreg returns a VOIDmode
CONST_INT, in that case convert_mode_scalar obviously doesn't work.
The following patch fixes that.
2022-10-19 Jakub Jelinek <jakub@redhat.com>
PR middle-end/107262
* expr.cc (convert_mode_scalar): For BFmode -> SFmode conversions
of constants, use simplify_unary_operation if fromi has VOIDmode
instead of recursive convert_mode_scalar.
* gcc.dg/pr107262.c: New test.
Diff:
---
gcc/expr.cc | 11 +++++++++--
gcc/testsuite/gcc.dg/pr107262.c | 13 +++++++++++++
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/gcc/expr.cc b/gcc/expr.cc
index 4c892d69249..efe387e6173 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -416,8 +416,15 @@ convert_mode_scalar (rtx to, rtx from, int unsignedp)
rtx tof = NULL_RTX;
if (fromi)
{
- rtx toi = gen_reg_rtx (toi_mode);
- convert_mode_scalar (toi, fromi, 1);
+ rtx toi;
+ if (GET_MODE (fromi) == VOIDmode)
+ toi = simplify_unary_operation (ZERO_EXTEND, toi_mode,
+ fromi, fromi_mode);
+ else
+ {
+ toi = gen_reg_rtx (toi_mode);
+ convert_mode_scalar (toi, fromi, 1);
+ }
toi
= maybe_expand_shift (LSHIFT_EXPR, toi_mode, toi,
GET_MODE_PRECISION (to_mode)
diff --git a/gcc/testsuite/gcc.dg/pr107262.c b/gcc/testsuite/gcc.dg/pr107262.c
new file mode 100644
index 00000000000..2ced0474645
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr107262.c
@@ -0,0 +1,13 @@
+/* PR middle-end/107262 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math" } */
+/* { dg-add-options bfloat16 } */
+/* { dg-require-effective-target bfloat16_runtime } */
+
+__bf16
+foo (__bf16 a)
+{
+ __bf16 b = 0;
+ b /= a;
+ return b;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-19 9:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 9:30 [gcc r13-3374] expr: Fix ICE on BFmode -> SFmode conversion of constant [PR107262] Jakub Jelinek
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).