From patchwork Wed Oct 19 07:54:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 4468 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp187031wrs; Wed, 19 Oct 2022 00:55:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4nSp4HkQ9If/NkNkNDdeGdB9WO5EOJg67nRWupKw8wNJPmut2cZ9yHBoqTT0k1ok3XC7fg X-Received: by 2002:a17:907:2bef:b0:78d:8b6c:a20b with SMTP id gv47-20020a1709072bef00b0078d8b6ca20bmr5768130ejc.674.1666166149476; Wed, 19 Oct 2022 00:55:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666166149; cv=none; d=google.com; s=arc-20160816; b=L2Y9HQ7ix7wjGvc9g/m02saZa7pAIVw8wtXwiXA77AAh5ibF40Qt0CVTkkb85milXJ MdpgvdR2Gka6hrCmsi20y2EBVZ+VNSJ7qAbnwFkYWQHlGTaOJzTpfrXhPvU6Kq3MWXlS vX27cLaSIQzpCqgnWPIxVO3MbhOZpCvfM12I7VveL3zKFgi0VAJloZ2BTA/vuTstOdMH gHOZtsnfwkvIra/42ZKchyCvFppyfpT+oLmdOdzmH+b1zrpos3N8nSFiG8Eil9FlWoxB /lWUQ7mUPrSkLAE0O8sGSeMwAm0h5ag9Mwvb4ChV8C8j0uTo63budixiHbqXxBzPuYA3 b1kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=PMzubtr3C897eQvd/UCEhUUs2b6ZHnAvURmD/kgBdRM=; b=kqBkbTmQieksn6CWMndbDKOW/Rxnu21zGpYLbjhF+cXkEEgKGZVc0VFKp+YOLOYRFN ClUa5j1MdJj5+gHLhouqXG5GFV+al9CjfspgdVgJGR4enX3us99pn0DYKmxeBivCFBP1 134QxN4gBa81UILhzVr9ueeRPzTquAHi2l9yH9kA5istbfB3tW0c5r6ASnqoDGSOVilK u+yozMqBZ8iraRe9jIhMfjjMZcgw64r67UT9zuQ5bkAss5xP7Y+0dwW9+o+qXSZjX0Er 3AJF7UWId6srjDKL+yrkvQIIT8vvAw9eUnWfWwUKjNhxE+0TKZqEPJQcOELsnuz4ydCf avUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gItLe27c; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qa42-20020a17090786aa00b0077cecf89064si14679038ejc.512.2022.10.19.00.55.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 00:55:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gItLe27c; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5CE243857C59 for ; Wed, 19 Oct 2022 07:55:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5CE243857C59 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666166143; bh=PMzubtr3C897eQvd/UCEhUUs2b6ZHnAvURmD/kgBdRM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=gItLe27c05AdYCywExAW3ar3FVurhNCxh1gkP+go0C4HFacf5H+HUDoy/uXl4jkXw 20zbiQbf3PyeDwqlmDU0SU+tcXINsHYAWExtDLJ17hWJR3D9ryWzr0Mn+iBA9B0ldZ hlTaRnid7+iVE8QK5CEG+pTmNNf5thOzEB7zxBGw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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 To: Richard Biener , Jeff Law Subject: [PATCH] expr: Fix ICE on BFmode -> SFmode conversion of constant [PR107262] Message-ID: 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-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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747101836476117680?= X-GMAIL-MSGID: =?utf-8?q?1747101836476117680?= 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. Jakub --- 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; +}