From patchwork Tue Jan 3 10:34:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 38365 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4542485wrt; Tue, 3 Jan 2023 02:34:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXsqbQq5N5NNirJG7tKvmm6X+TD8TluOVcxTlInGuaLYoIV7zP/ox4zW3mi84dZPqpiFZzoL X-Received: by 2002:a17:907:1710:b0:7c0:c36d:f5df with SMTP id le16-20020a170907171000b007c0c36df5dfmr47520701ejc.70.1672742098189; Tue, 03 Jan 2023 02:34:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672742098; cv=none; d=google.com; s=arc-20160816; b=rC6PTZDe2bVYyUwWWs93CAbB5VZrQkvfVXYSvA5mhLL9sClG90EKihAF1rxVmMBAEv WgC0Z0qULA8ZmCfGick1Tg+tySUmVvkS9bzdCEG9dM8fbw7cR6l78WJG7zLoNhZN+gAs 5Q5DZC39wb5rHHLbFXIAb7gZOqHNgeLHunrm5Gdk10kbYaWUzoY6HUDISyEIAONqIxIl /BVTCcqFF+jU2VQrjt14irOVy+YxCqt+Uxbvc1hkVMTgKegRs8Qrkrj0Gu9umKX8C70F TuSZ3bj9GNEdA6AjYEhXC+l36yGjKXCGrs7cS424g2U3zoBwxG99xeogFT8F0kXEbEkv 1xNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :delivered-to:dkim-signature:dkim-filter; bh=uLkch8EnT+/a/sq+TAAlNRf+mayglDRA0IJL6fGIvEI=; b=cQFqAG6j7hYyPVGCcbfI6jUXbhDmfCto+RzeDkEOwaq0a6dFvU0tbUvIZVVbPpX4Ww cNmk3exdQtD8pkg43MoGZ9W97pWeFSNiVDFu8BrmnqXttDOeVawZ3pnKU9oNQNmbCZo5 G8/jeH+DE6cZjrd8YegF6XfdUFam0yWq5Iqkfzq9CgpBueAXsOkyUlbovwNxfQHPeaex dwadw6oZ9LFxV067IoeIIx/MKTa8jZ1lsPo8WZa/rEeMUHrvNkNuxaxmqX6MNWNlkzJY NDrv6neM8fbBwthtXMpPbGe8AT80VZqQxnJXTmxAqG3eIPXqnlRVIcJSPX/S4cLRkTL9 0y9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fHtuvMf3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p20-20020a1709060dd400b007ae199ea55asi20364449eji.817.2023.01.03.02.34.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 02:34:58 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fHtuvMf3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 40F963858C83 for ; Tue, 3 Jan 2023 10:34:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40F963858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672742097; bh=uLkch8EnT+/a/sq+TAAlNRf+mayglDRA0IJL6fGIvEI=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=fHtuvMf3kmdkMwht4tskU9pLffae8adTsHNwdE8YEv8Cj+BAbxBymc8RtGxgBbpEA 1PKnI82u/oB0pJryrx/a6kvKLB6gPGkQNSUvQClt1OmJEo+5uetFADZdkcW4xZJei7 QxY3vDepsXbbs27kHFVVloo+avm3YUZhJ53wtkQU= 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 8E9563858D1E for ; Tue, 3 Jan 2023 10:34:13 +0000 (GMT) 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-151-sJtcjOJ4OlORsVjo86eH3w-1; Tue, 03 Jan 2023 05:34:12 -0500 X-MC-Unique: sJtcjOJ4OlORsVjo86eH3w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 95EE63C14841; Tue, 3 Jan 2023 10:34:11 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A44A140EBF4; Tue, 3 Jan 2023 10:34:11 +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 303AY8MI278976 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 3 Jan 2023 11:34:08 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 303AY78P278975; Tue, 3 Jan 2023 11:34:07 +0100 Date: Tue, 3 Jan 2023 11:34:07 +0100 To: Richard Biener , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] expr: Fix up store_expr into SUBREG_PROMOTED_* target [PR108264] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.9 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 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?1753997218454537604?= X-GMAIL-MSGID: =?utf-8?q?1753997218454537604?= Hi! The following testcase ICEs on s390x-linux (e.g. with -march=z13). The problem is that target is (subreg/s/u:SI (reg/v:DI 66 [ x+-4 ]) 4) and we call convert_move from temp to the SUBREG_REG of that, expecting to extend the value properly. That works nicely if temp has some scalar integer mode (or partial one), but ICEs when temp has V4QImode on the assertion that from and to modes have the same bitsize. store_expr generally allows say store from V4QI to SI target because they have the same size and if temp is a CONST_INT, we already have code to convert the constant properly, so the following patch just adds handling of non-scalar integer modes by converting them to the mode of target first before convert_move extends them. Bootstrapped/regtested on x86_64-linux, i686-linux and s390x-linux, ok for trunk? 2023-01-03 Jakub Jelinek PR middle-end/108264 * expr.cc (store_expr): For stores into SUBREG_PROMOTED_* targets from source which doesn't have scalar integral mode first convert it to outer_mode. * gcc.dg/pr108264.c: New test. Jakub --- gcc/expr.cc.jj 2023-01-02 09:32:23.000000000 +0100 +++ gcc/expr.cc 2023-01-02 16:48:13.226990815 +0100 @@ -6226,6 +6226,9 @@ store_expr (tree exp, rtx target, int ca temp = convert_modes (inner_mode, outer_mode, temp, SUBREG_PROMOTED_SIGN (target)); } + else if (!SCALAR_INT_MODE_P (GET_MODE (temp))) + temp = convert_modes (outer_mode, TYPE_MODE (TREE_TYPE (exp)), + temp, SUBREG_PROMOTED_SIGN (target)); convert_move (SUBREG_REG (target), temp, SUBREG_PROMOTED_SIGN (target)); --- gcc/testsuite/gcc.dg/pr108264.c.jj 2023-01-02 17:01:14.865887522 +0100 +++ gcc/testsuite/gcc.dg/pr108264.c 2023-01-02 17:00:52.238209030 +0100 @@ -0,0 +1,27 @@ +/* PR middle-end/108264 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-fpic" { target fpic } } */ + +int v; +extern int bar (void); + +static inline void +foo (char *d) +{ + switch (bar ()) + { + case 2: + d[0] = d[1] = d[2] = d[3] = v; + break; + case 4: + d[0] = 0; + } +} + +int +baz (int x) +{ + foo ((char *) &x); + return x; +}