From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id D10823858D32 for ; Sat, 3 Jun 2023 17:31:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D10823858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=YFkR5sX0U+hFhCJJ5CcIWaTMmYkiWwVRU9pX8r5ptSo=; b=rW/32RR5ukazL5z3GgV+OUg/Wo Nz1EyvWN0j+Iuckv9L5aVzhr/YiDlB01mQIk+BZkEYE+RpV1LRayOTUYfltPtOTOx+uQLnl2fNx1V T0aVT5j5N6wO5qScTRlLkHyLnmp5/Cm9RLGcp+3xlZuOUX4Ljmg7jxfGDqxnfm0+fPAgw7rZ9OZ2g ekgqQIuMzwIBrJRB2w3GU2a4e1CpFiHmCm8hyxS//TlBf/h4FIGi2SaoVkGzrCx8N/P1YqHjoOub+ ed3dAvsGf9CEdnAAHyX+ZY7b9W1B7SbuzWRNihMXnAez3ZDI7n3d0ROBLG8U8m0hqfsQ19s/CCg16 G0FL6oGw==; Received: from host86-169-41-81.range86-169.btcentralplus.com ([86.169.41.81]:57035 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1q5V6N-0003XW-05; Sat, 03 Jun 2023 13:31:43 -0400 From: "Roger Sayle" To: Cc: "'Uros Bizjak'" Subject: [x86_64 PATCH] PR target/110083: Fix-up REG_EQUAL notes on COMPARE in STV. Date: Sat, 3 Jun 2023 18:31:40 +0100 Message-ID: <035801d99641$43215980$c9640c80$@nextmovesoftware.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0359_01D99649.A4E5C180" X-Mailer: Microsoft Outlook 16.0 Content-Language: en-gb Thread-Index: AdmWQH36UVvbdowLQRW9Pk2DxUBdaw== X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: This is a multipart message in MIME format. ------=_NextPart_000_0359_01D99649.A4E5C180 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This patch fixes PR target/110083, an ICE-on-valid regression exposed by my recent PTEST improvements (to address PR target/109973). The latent bug (admittedly mine) is that the scalar-to-vector (STV) pass doesn't update or delete REG_EQUAL notes attached to COMPARE instructions. As a result the operands of COMPARE would be mismatched, with the register transformed to V1TImode, but the immediate operand left as const_wide_int, which is valid for TImode but not V1TImode. This remained latent when the STV conversion converted the mode of the COMPARE to CCmode, with later passes recognizing the REG_EQUAL note is obviously invalid as the modes didn't match, but now that we (correctly) preserve the CCZmode on COMPARE, the mismatched operand modes trigger a sanity checking ICE downstream. Fixed by updating (or deleting) any REG_EQUAL notes in convert_compare. Before: (expr_list:REG_EQUAL (compare:CCZ (reg:V1TI 119 [ ivin.29_38 ]) (const_wide_int 0x80000000000000000000000000000000)) After: (expr_list:REG_EQUAL (compare:CCZ (reg:V1TI 119 [ ivin.29_38 ]) (const_vector:V1TI [ (const_wide_int 0x80000000000000000000000000000000) ])) This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and make -k check, both with and without --target_board=unix{-m32} with no new failures. Ok for mainline? 2023-06-03 Roger Sayle gcc/ChangeLog PR target/110083 * config/i386/i386-features.cc (scalar_chain::convert_compare): Update or delete REG_EQUAL notes, converting CONST_INT and CONST_WIDE_INT immediate operands to a suitable CONST_VECTOR. gcc/testsuite/ChangeLog PR target/110083 * gcc.target/i386/pr110083.c: New test case. Roger -- ------=_NextPart_000_0359_01D99649.A4E5C180 Content-Type: text/plain; name="patchvt.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="patchvt.txt" diff --git a/gcc/config/i386/i386-features.cc = b/gcc/config/i386/i386-features.cc=0A= index 3417f6b..4a3b07a 100644=0A= --- a/gcc/config/i386/i386-features.cc=0A= +++ b/gcc/config/i386/i386-features.cc=0A= @@ -980,6 +980,39 @@ rtx=0A= scalar_chain::convert_compare (rtx op1, rtx op2, rtx_insn *insn)=0A= {=0A= rtx src, tmp;=0A= +=0A= + /* Handle any REG_EQUAL notes. */=0A= + tmp =3D find_reg_equal_equiv_note (insn);=0A= + if (tmp)=0A= + {=0A= + if (GET_CODE (XEXP (tmp, 0)) =3D=3D COMPARE=0A= + && GET_MODE (XEXP (tmp, 0)) =3D=3D CCZmode=0A= + && REG_P (XEXP (XEXP (tmp, 0), 0)))=0A= + {=0A= + rtx *op =3D &XEXP (XEXP (tmp, 0), 1);=0A= + if (CONST_SCALAR_INT_P (*op))=0A= + {=0A= + if (constm1_operand (*op, GET_MODE (*op)))=0A= + *op =3D CONSTM1_RTX (vmode);=0A= + else=0A= + {=0A= + unsigned n =3D GET_MODE_NUNITS (vmode);=0A= + rtx *v =3D XALLOCAVEC (rtx, n);=0A= + v[0] =3D *op;=0A= + for (unsigned i =3D 1; i < n; ++i)=0A= + v[i] =3D const0_rtx;=0A= + *op =3D gen_rtx_CONST_VECTOR (vmode, gen_rtvec_v (n, v));=0A= + }=0A= + tmp =3D NULL_RTX;=0A= + }=0A= + else if (REG_P (*op))=0A= + tmp =3D NULL_RTX;=0A= + }=0A= +=0A= + if (tmp)=0A= + remove_note (insn, tmp);=0A= + }=0A= +=0A= /* Comparison against anything other than zero, requires an XOR. */=0A= if (op2 !=3D const0_rtx)=0A= {=0A= diff --git a/gcc/testsuite/gcc.target/i386/pr110083.c = b/gcc/testsuite/gcc.target/i386/pr110083.c=0A= new file mode 100644=0A= index 0000000..4b38ca8=0A= --- /dev/null=0A= +++ b/gcc/testsuite/gcc.target/i386/pr110083.c=0A= @@ -0,0 +1,26 @@=0A= +/* { dg-do compile { target int128 } } */=0A= +/* { dg-options "-O2 -msse4 -mstv -mno-stackrealign" } */=0A= +typedef int TItype __attribute__ ((mode (TI)));=0A= +typedef unsigned int UTItype __attribute__ ((mode (TI)));=0A= +=0A= +void foo (void)=0A= +{=0A= + static volatile TItype ivin, ivout;=0A= + static volatile float fv1, fv2;=0A= + ivin =3D ((TItype) (UTItype) ~ (((UTItype) ~ (UTItype) 0) >> 1));=0A= + fv1 =3D ((TItype) (UTItype) ~ (((UTItype) ~ (UTItype) 0) >> 1));=0A= + fv2 =3D ivin;=0A= + ivout =3D fv2;=0A= + if (ivin !=3D ((TItype) (UTItype) ~ (((UTItype) ~ (UTItype) 0) >> 1))=0A= + || ((((128) > sizeof (TItype) * 8 - 1)) && ivout !=3D ivin)=0A= + || ((((128) > sizeof (TItype) * 8 - 1))=0A= + && ivout !=3D=0A= + ((TItype) (UTItype) ~ (((UTItype) ~ (UTItype) 0) >> 1)))=0A= + || fv1 !=3D=0A= + (float) ((TItype) (UTItype) ~ (((UTItype) ~ (UTItype) 0) >> 1))=0A= + || fv2 !=3D=0A= + (float) ((TItype) (UTItype) ~ (((UTItype) ~ (UTItype) 0) >> 1))=0A= + || fv1 !=3D fv2)=0A= + __builtin_abort ();=0A= +}=0A= +=0A= ------=_NextPart_000_0359_01D99649.A4E5C180--