From patchwork Fri Feb 12 22:21:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Bergner X-Patchwork-Id: 1440091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=uqBUBZK3; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dcnzd5GZXz9sB4 for ; Sat, 13 Feb 2021 09:22:04 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A18F83848022; Fri, 12 Feb 2021 22:22:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A18F83848022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1613168521; bh=ltYU4ZtED41vVl9miO+dTIeaa0VX15/3EJLxNqnGvWw=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=uqBUBZK36QECupHYJnXQ0+I7YCQmmWx2D13UbTV4KRkWxf1x4LjrlJmyzdAe0L6Mf dn9rM2T+bBYWsX0922fWiUSAoLaqNvBXqEOOGn9tXwxhXPFJmplawtccfazUQn7FY2 oVBYdeUsQ6MRrMUrD08mFn8qGT+vTSUFWzngNkO4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 005F63857C75 for ; Fri, 12 Feb 2021 22:21:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 005F63857C75 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 11CMD1j6020863; Fri, 12 Feb 2021 17:21:54 -0500 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 36p297g6a2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Feb 2021 17:21:54 -0500 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 11CMGQnO014474; Fri, 12 Feb 2021 22:21:53 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma02dal.us.ibm.com with ESMTP id 36hjravehg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Feb 2021 22:21:53 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 11CMLq9w17039864 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Feb 2021 22:21:52 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 767E8BE058; Fri, 12 Feb 2021 22:21:52 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA0BCBE04F; Fri, 12 Feb 2021 22:21:51 +0000 (GMT) Received: from [9.160.72.247] (unknown [9.160.72.247]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 12 Feb 2021 22:21:51 +0000 (GMT) Subject: rtl-optimization: Fix uninitialized use of opaque mode variable ICE [PR98872] To: Segher Boessenkool , GCC Patches , richard.sandiford@arm.com References: <20210208132951.GA27854@gate.crashing.org> Message-ID: Date: Fri, 12 Feb 2021 16:21:51 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210208132951.GA27854@gate.crashing.org> Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.737 definitions=2021-02-12_09:2021-02-12, 2021-02-12 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 mlxscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 mlxlogscore=999 spamscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102120159 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Peter Bergner via Gcc-patches From: Peter Bergner Reply-To: Peter Bergner Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" On 2/8/21 7:29 AM, Segher Boessenkool wrote: >> I think we should either add a new rtx code for constant opaque modes >> or make init-regs just emit the clobber for opaque modes (and not emit >> the move). > > Thanks for looking Richard. That last option sounds good to me as well. Ok, guarding the emit_move_insn with a CONST0_RTX test which causes us to only emit the clobber for opaque modes fixes the problem. Nice! That means we can eliminate the rest of the patch other than the test case! >>> --- /dev/null >>> +++ b/gcc/testsuite/gcc.target/powerpc/pr98872.c >>> @@ -0,0 +1,20 @@ >>> +/* PR target/98872 */ >>> +/* { dg-do compile } */ >>> +/* { dg-require-effective-target power10_ok } */ >>> +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ >>> + >>> +/* Verify we do not ICE on the tests below. */ > > Do the existing tests already check the expected code for this? Yes, our mma-builtin-*.c tests check for expected output. The updated patch below fixes the bug too and is much simpler! :-) rtl-optimization: Fix uninitialized use of opaque mode variable ICE [PR98872] The initialize_uninitialized_regs function emits (set (reg:) (CONST0_RTX)) for all uninitialized pseudo uses. However, some modes (eg, opaque modes) may not have a CONST0_RTX defined, leading to an ICE when we try and create the initialization insn. The fix is to skip emitting the initialization if there is no CONST0_RTX defined for the mode. This following patch fixes the ICE and is currently regtesting. Ok for trunk if the bootstrap and regtesting come back clean? Peter 2021-02-12 Peter Bergner gcc/ PR rtl-optimization/98872 * init-regs.c (initialize_uninitialized_regs): Skip initialization if CONST0_RTX is NULL. gcc/testsuite/ PR rtl-optimization/98872 * gcc.target/powerpc/pr98872.c: New test. diff --git a/gcc/init-regs.c b/gcc/init-regs.c index 903c6541f10..72e898f3e33 100644 --- a/gcc/init-regs.c +++ b/gcc/init-regs.c @@ -105,7 +105,10 @@ initialize_uninitialized_regs (void) start_sequence (); emit_clobber (reg); - emit_move_insn (reg, CONST0_RTX (GET_MODE (reg))); + /* PR98872: Only emit an initialization if MODE has a + CONST0_RTX defined. */ + if (CONST0_RTX (GET_MODE (reg))) + emit_move_insn (reg, CONST0_RTX (GET_MODE (reg))); move_insn = get_insns (); end_sequence (); emit_insn_before (move_insn, insn); diff --git a/gcc/testsuite/gcc.target/powerpc/pr98872.c b/gcc/testsuite/gcc.target/powerpc/pr98872.c new file mode 100644 index 00000000000..f33ad9b48b6 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr98872.c @@ -0,0 +1,19 @@ +/* PR target/98872 */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ + +/* Verify we do not ICE on the following tests. */ + +void +foo (__vector_quad *dst) +{ + __vector_quad acc; + *dst = acc; +} + +void +bar (__vector_pair *dst) +{ + __vector_pair pair; + *dst = pair; +}