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 2654D3858400 for ; Sat, 16 Jul 2022 12:06:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2654D3858400 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=QiNcXJE+yA6kZ6jQVOhYLV9+lUdis7WUFxNnW3atpTw=; b=SFzi1Ksf+fG7yMnEnMr98fY4ed eXk/iuaxB+qRgSB4fx8IOUpg527XeUzYKzzWut3XDUlPoapYSpNTew/sAV8wKQ0wi32zDZrXaN7Hq ZhPAGNdB6DarIjm56pDURAQDmW3OE23DU10M0QoHf9danN7QI0GVcGV5fdlv2gL7VVolQF9SDxR+9 24yIMN8qIE003KiOGbLW8QPw2E0veqjBy0MMQCvCEHDqQ+9AyK95R3rUGLZTBccy/ZfOapFmLU02j +qbQFNY2vRNPQALKxBSPVFcklZcdv2ry4hK6KzfUNRxmz80PhwdKv5lZnnzDSX4ePQOmzLiIRVwnh mua+Gwtg==; Received: from host109-154-33-170.range109-154.btcentralplus.com ([109.154.33.170]:51859 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oCgZW-0000Pk-8p; Sat, 16 Jul 2022 08:06:58 -0400 From: "Roger Sayle" To: "'GCC Patches'" Subject: [x86 PATCH] Fix issue with x86_64_const_vector_operand predicate. Date: Sat, 16 Jul 2022 13:06:57 +0100 Message-ID: <008201d8990c$8ce7ac00$a6b70400$@nextmovesoftware.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0083_01D89914.EEAC1400" X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdiZC73+xIJ9cQsSQmqkLEaV3YKMPQ== Content-Language: en-gb 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=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, 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-List-Received-Date: Sat, 16 Jul 2022 12:07:01 -0000 This is a multipart message in MIME format. ------=_NextPart_000_0083_01D89914.EEAC1400 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This patch fixes (what I believe is) a latent bug in i386.md's x86_64_const_vector_operand define_predicate. According to the documentation, when a predicate is called with rtx operand OP and machine_mode operand MODE, we can't shouldn't assume that the MODE is (or has been checked to be) GET_MODE (OP). The failure mode is that recog can call x86_64_const_vector_operand on an arbitrary CONST_VECTOR passing a MODE of V2QI_mode, but when the CONST_VECTOR is in fact V1TImode, it's unsafe to directly call ix86_convert_const_vector_to_integer, which assumes that the CONST_VECTOR contains CONST_INTs when it actually contains CONST_WIDE_INTs. The checks in this define_predicate need to be testing OP's mode, and ideally confirming that this matches the passed in/specified MODE. This bug is currently latent, but adding an innocent/unrelated define_insn, such as "(set (reg:CCC FLAGS_REG) (const_int 0))" to i386.md can occasionally change the order in which genrecog generates its tests, then ICEing during bootstrap due to V1TI CONST_VECTORs. 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? 2022-07-16 Roger Sayle gcc/ChangeLog * config/i386/predicates.md (x86_64_const_vector_operand): Check the operand's mode matches the specified mode argument. Thanks in advance, Roger -- ------=_NextPart_000_0083_01D89914.EEAC1400 Content-Type: text/plain; name="patchpm.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="patchpm.txt" diff --git a/gcc/config/i386/predicates.md = b/gcc/config/i386/predicates.md=0A= index c71c453..42053ea 100644=0A= --- a/gcc/config/i386/predicates.md=0A= +++ b/gcc/config/i386/predicates.md=0A= @@ -1199,6 +1199,10 @@=0A= (define_predicate "x86_64_const_vector_operand"=0A= (match_code "const_vector")=0A= {=0A= + if (mode =3D=3D VOIDmode)=0A= + mode =3D GET_MODE (op);=0A= + else if (GET_MODE (op) !=3D mode)=0A= + return false;=0A= if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)=0A= return false;=0A= HOST_WIDE_INT val =3D ix86_convert_const_vector_to_integer (op, mode);=0A= ------=_NextPart_000_0083_01D89914.EEAC1400--