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 8E9563858D1E for ; Tue, 3 Jan 2023 10:34:13 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672742053; 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=uLkch8EnT+/a/sq+TAAlNRf+mayglDRA0IJL6fGIvEI=; b=Kb1b/6q4PrYGIUP05xA7yCkw+7D5Y1tBf/y+fuaHdww68p4Hnr/6QL7FOa5jiOFtekMozZ V7RZmgXjuts/UJVcLU1Dts4nvR6W86PCfHVvPN5+xFRv2v9rnyU8CTOlTm2SVyYh7WG0Xg OpJe6l4YQuRKLG4LwBA3avwztFTG5GI= 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 From: Jakub Jelinek 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: Reply-To: Jakub Jelinek 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-Type: text/plain; charset=us-ascii 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 List-Id: 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. --- 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; +} Jakub