public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Jeff Law <jeffreyalaw@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] expr: Fix ICE on BFmode -> SFmode conversion of constant [PR107262]
Date: Wed, 19 Oct 2022 10:21:45 +0200	[thread overview]
Message-ID: <BEDFE2AA-6A94-40C6-94F0-A05DD79B3BC8@suse.de> (raw)
In-Reply-To: <Y0+tShfF4ku2nMoM@tucnak>



> Am 19.10.2022 um 09:55 schrieb Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org>:
> 
> Hi!
> 
> 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.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard 


> 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.
> 
> --- gcc/expr.cc.jj    2022-10-14 09:35:56.134991155 +0200
> +++ gcc/expr.cc    2022-10-18 14:07:24.330512745 +0200
> @@ -416,8 +416,15 @@ convert_mode_scalar (rtx to, rtx from, i
>          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)
> --- gcc/testsuite/gcc.dg/pr107262.c.jj    2022-10-18 14:09:44.114607505 +0200
> +++ gcc/testsuite/gcc.dg/pr107262.c    2022-10-18 14:09:33.708749313 +0200
> @@ -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;
> +}
> 
>    Jakub
> 

      reply	other threads:[~2022-10-19  8:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19  7:54 Jakub Jelinek
2022-10-19  8:21 ` Richard Biener [this message]

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=BEDFE2AA-6A94-40C6-94F0-A05DD79B3BC8@suse.de \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jeffreyalaw@gmail.com \
    /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: link
Be 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).