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.
This commit is contained in:
parent
07cc4c1da1
commit
65b98fc763
2 changed files with 22 additions and 2 deletions
11
gcc/expr.cc
11
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)
|
||||
|
|
13
gcc/testsuite/gcc.dg/pr107262.c
Normal file
13
gcc/testsuite/gcc.dg/pr107262.c
Normal file
|
@ -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;
|
||||
}
|
Loading…
Add table
Reference in a new issue