From patchwork Sat Jul 16 12:06:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 26 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp880195eik; Sat, 16 Jul 2022 05:07:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tcH8cQQfMZVtfI9BUKyIFyZbys6cb9lpaMvAojE+p7EGYGgrHuNw1BsGAy+8IldQBPVv/w X-Received: by 2002:a17:907:7615:b0:72b:35a6:5992 with SMTP id jx21-20020a170907761500b0072b35a65992mr17758490ejc.97.1657973251569; Sat, 16 Jul 2022 05:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657973251; cv=none; d=google.com; s=arc-20160816; b=HRlVTPquhDsb/y/w4q4GaZA1Pc0CwMVAeLcDfFu1CH317yk8Z1a+ULbXIdIShVvaYP ZTkARuNWvHx1GSWdTrEermT9EBV2tpsulKei5gC8nXasKXZiqCJWD7C5vHkZY2Yb+Cpv fNs7X86vTzIfajZc1GdHbgAHQX1p7tgsjTUrwKIxSIl1rL1lOGDfiAaiw3WCmArbxmAp 8lish9E6B8B4QCoHrfdlqZlyd+0HnnnIcemW5bKmZmngrMlmWo3ZPRky+R+T6g+2n5SZ qD1NXfgFx7wOjeyF0L1xpqtMOqyr6p1QhSU1ZYwfIP4WnLLZseQvXPqrF66AAxHOnVA2 typg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-language:thread-index :mime-version:message-id:date:subject:to:from:dkim-signature :dmarc-filter:delivered-to; bh=QiNcXJE+yA6kZ6jQVOhYLV9+lUdis7WUFxNnW3atpTw=; b=G2c4Wln4R2e4NrqPj5oWjKbu0Z8KUMLGxZduT+mpWddWCA31olKHD1Fyf0f7Lh7B+S u61ZthIap0oocArp5NDHfrlObHMlZwCmJ1yzyn6zntXjMhgmMEcSKq73Ll4cmCyC5nE9 DK9o94RYcAl8QeM13h7KFIseEE728tunYDjEHUb6d115r3xx9Km6+Akwef8duD6FK6d8 QlCmTvc6lZky+aTgdOmcP3dg6tGiyTR44IG92kfg01s0mOOaSm7x5ZXxw0evVz5xDkwC uAt9SPSYlIz0+elBqgNl0iwAAJyYzFu8C7E7aqwz22g/3gx2u3OEui06WVG7+i4EbMDx gWcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=SFzi1Ksf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id eb11-20020a0564020d0b00b0043a7fac2daesi4305031edb.514.2022.07.16.05.07.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Jul 2022 05:07:31 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=SFzi1Ksf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 52F1A3856DF4 for ; Sat, 16 Jul 2022 12:07:23 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-LABELS: =?utf-8?b?IlxcSW1wb3J0YW50Ig==?= X-GMAIL-THRID: =?utf-8?q?1738510960118728872?= X-GMAIL-MSGID: =?utf-8?q?1738510960118728872?= 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 diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index c71c453..42053ea 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -1199,6 +1199,10 @@ (define_predicate "x86_64_const_vector_operand" (match_code "const_vector") { + if (mode == VOIDmode) + mode = GET_MODE (op); + else if (GET_MODE (op) != mode) + return false; if (GET_MODE_SIZE (mode) > UNITS_PER_WORD) return false; HOST_WIDE_INT val = ix86_convert_const_vector_to_integer (op, mode);