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: 62664 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 71C493858C2B for ; Tue, 3 Jan 2023 10:34:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 71C493858C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672742082; 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=LuZTktRSMfJRPkHspqLL97jyG6k7li0RMUxhVLNMpcSrmYtrn1IiejhxCGWYmJiYQ AUjORRL3ADvOxvshfVPVlTthpzJiIKan77HA/F/y6HUz3aLRNdeBgGb7qpZucrLerW yntvbcFgGhizpPEgB6AXpl9aZGbeCawC8q1GOW6s= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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; +}