aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-10-19 11:29:44 +0200
committerJakub Jelinek <jakub@redhat.com>2022-10-19 11:29:44 +0200
commit65b98fc763d14d371fcf37a17e33519012ec2bac (patch)
treee9961f79899f56a602bb92e27a76505844b96aba /gcc/expr.cc
parent07cc4c1da1046f0ffda241d59df796417c122ff5 (diff)
downloadgcc-65b98fc763d14d371fcf37a17e33519012ec2bac.zip
gcc-65b98fc763d14d371fcf37a17e33519012ec2bac.tar.gz
gcc-65b98fc763d14d371fcf37a17e33519012ec2bac.tar.bz2
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.
Diffstat (limited to 'gcc/expr.cc')
-rw-r--r--gcc/expr.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/gcc/expr.cc b/gcc/expr.cc
index 4c892d6..efe387e 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)