From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 032E1385782C for ; Wed, 19 Oct 2022 07:54:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 032E1385782C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666166098; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=PMzubtr3C897eQvd/UCEhUUs2b6ZHnAvURmD/kgBdRM=; b=RpI8QQL/sjzXs4e45JkT35SN8Ivdx2sFxmOlUPb/o0I7tz/ABHlU8Bgsae+lhO/vRmBevC +NbGrODL84gyuFf1LdnLiinKk8N6SmtdC9+8xLV/0lwAA6OWypnl6+nou/E8/xrCYLzGUi SuVvGMNX7EwHU+zwr26Uhe/YlqiIHwA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-297-qTIZueGVPH64vv6U7G_nrw-1; Wed, 19 Oct 2022 03:54:55 -0400 X-MC-Unique: qTIZueGVPH64vv6U7G_nrw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D2E1029AA387; Wed, 19 Oct 2022 07:54:54 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8E2FCC1908B; Wed, 19 Oct 2022 07:54:54 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 29J7sp3V3797095 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 19 Oct 2022 09:54:52 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 29J7soWi3797094; Wed, 19 Oct 2022 09:54:50 +0200 Date: Wed, 19 Oct 2022 09:54:50 +0200 From: Jakub Jelinek To: Richard Biener , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] expr: Fix ICE on BFmode -> SFmode conversion of constant [PR107262] Message-ID: Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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? 2022-10-19 Jakub Jelinek 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