From patchwork Thu Feb 1 20:27:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 195453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp4511dyc; Thu, 1 Feb 2024 12:28:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRGwolxPqF8PJeqxyqylHBmeCtsiXRmR42krvVcdfXN3E6tNAJt40+QGGryWlKBXaYULdi X-Received: by 2002:a25:dc12:0:b0:dc2:4d19:4fea with SMTP id y18-20020a25dc12000000b00dc24d194feamr3795482ybe.11.1706819301691; Thu, 01 Feb 2024 12:28:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706819301; cv=pass; d=google.com; s=arc-20160816; b=tHikBYRie98nDbnm9vHiWp89t38q7RHWVYt0ivybO+NxFqG5Gkvkno4EwTbKKSYpzU FhQAiVkDw/LmJ7CczxtGEU15eQiO/Av6/NY1tXJbqgD36oLDFQiaJYMB2mdaOo798jSU jLlinA1j/69jquJyykHjP//1ScXiPyxlZ6svyyJecC3pQM2mjSPt7e4BHbKa6fyTeStx jXfitupcDXQT05MvbFUrgwOtNP5uh3bkLpogYaYU2k5Ce8q4Pchq6ss9cYo6+RvA5NwV /g8vzkCgHT3e55KmUsK3ow3bsWrrd8ItdT6Z4v1MdI/+tJi/syCPbKBXy/P80fTB/CGH BBsA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:to:subject:message-id:date:from :mime-version:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=k38PTpg+lD2WdmSIdlbCw+KIiItzR4LLJi86BXtMAXM=; fh=iH865Lqz4GFOyHFOIJKFbaSsDgL871oOxnpfLevTFW0=; b=SYxsarkkUUxrM9PFlya/KgGoW5S32gJQDMw9O0bHNEwpLf1+ChvNkkp3N629EF3hqo exQH/P6pgzs4m2SIOiDf9EmCdyGDpPiN9hmUVLFvzWnj0N9wIyTev+QPsxAz8Zx2yfYw l+hLERi2QQK0si8vBDcYNtj+SLc2Ye9xLa1EwJsMiJn1o68YPtesCPuDMFyp3mweSJxP +o7+hutj9V8xErWQLAF1tJubZUOsehQUoTzxnBY4nXbm5qsiE3W/EMajxUXddbydL34h wce4lDNofonmFmPFBwJsm0U5Q3pP2URCSj+pJcph49JpolGnx8/O1sdvX93z8HZLu3LL bhVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hWEehHEB; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCXpNAYaQdq1tSMIZ0D61cQT2YXSdsW9a8qvCeg+GtUY1WZ4b0hnmmSVpP5AKLSoYsyjem/aZ+nUL4piYxYn1/o1HGVKpQ== Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n6-20020a0ce486000000b0068c4ee6bb81si313899qvl.61.2024.02.01.12.28.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 12:28:21 -0800 (PST) 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=pass header.i=@gmail.com header.s=20230601 header.b=hWEehHEB; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 54BA93861848 for ; Thu, 1 Feb 2024 20:28:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 21A7538582AF for ; Thu, 1 Feb 2024 20:27:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 21A7538582AF Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 21A7538582AF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706819253; cv=none; b=bqL6VaMLhT5rgN8JkYxJ4sWr/fbZAC9Eb5lm4bXgfZYVoar4Mtr7QRjQsnk1mjN5iED0XzEXyoc7IFlkK8MZzA4R8dvgH+jQmB9IcW/BVhKvOuAUPUBST/1LGmMi43pYXDiH6OSsKHWWkJSuPY+fKYiJC+Gyia696z1WMW56yt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706819253; c=relaxed/simple; bh=MseSLlXrMLOst9PvRof7X+WQ7cXfLgl2Zuqz5E4kQWY=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=sC/eLbqO/nhQvDmll3sy/a2uzJPp9maLBsFoFZH3/FYGKJ4tIL4mo1YMMXzdkhtimSVuQxA0rU/BIwJvUkAnh9uti+LbQcCjHH54w4P2UxgWf1N/tTVYMfHJFHSEobKHyuZFY5bMXyG5NfKxIrX6gFKnVMvgv4HcV90GYQiH5Lw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-55817a12ad8so1822344a12.2 for ; Thu, 01 Feb 2024 12:27:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706819250; x=1707424050; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=k38PTpg+lD2WdmSIdlbCw+KIiItzR4LLJi86BXtMAXM=; b=hWEehHEBFXf/66LDcZDSworI4Z9Re2JRAWf56tyb3j9mCD0xSxh47p9u2VyPPbVggR B5JzI4JGH0IVybJrBCorDsg+ujRM3Lhzub+sT9Yixp2YWMRAFtpoMzPhDhjdy+MzNELB kG3PdIj8fJQrbcQ15fXs5RFuS4/zEXOVzKZuJMuVHL9HP6kDQcum/wCNfeyER3J0On4W UtK3DTAji0lrQ9BA9Xkn4H4h4X8lJKsFO8ppnWXDbzYVjyhXfKTK62C/o5RhDNksGsfm D79jAz76s6IZH1xwhY3OYerNqNiKh6xjPm5Yft8OtCZDJk7oHOGbZcmYvFivNAjQnL2J a2AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706819250; x=1707424050; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=k38PTpg+lD2WdmSIdlbCw+KIiItzR4LLJi86BXtMAXM=; b=fBqcZG4keMUfBAA4Q3D5O4UTogiRAMx2kHXl16ivhd2rKg0lme5eXqGc4ZJXSxjG45 wVOCc8nCuYtFiKl7VhCinxntNgwH63Jnv0QCIE44xw8XxjGirNuvtjq0lKRQx2Lr3Ur6 GY3zUfFUjvHD0Tm4XSk08Z6ky2/X/8fh8KtCJucH3MgcUoPnKBPqj/ZBcxC4O+z2187e 6UnEyyBmQ4Ucr5b6IMuYX08XMFZ+Lqk0WHUB8GgBGiZ18PKqlQH0dfbp2I9PlnFtsInC sCknbIN7i022fYFRhHEusXJk7wF+Xo3tzpCOvBXzBypEvyJEZPOCA6VO7XQYBnQ/8x4W hU+w== X-Gm-Message-State: AOJu0Yw1efgSlMIlcvVnUjlnGsUzLi2xdZ7uBrzRnGh+D2xVzMsjComo uySEtH5d7A+3ATDWjI++a568D57E414Nhqf4z+mxLXyVoRKllXd+Bt8oU84OCeRuTBsaVEwN6iJ IZ7DDNdxecZzGztAxfeMwq8sVKsagR8Pe4bsGMQ== X-Received: by 2002:aa7:c888:0:b0:55f:e584:221e with SMTP id p8-20020aa7c888000000b0055fe584221emr272655eds.29.1706819250467; Thu, 01 Feb 2024 12:27:30 -0800 (PST) MIME-Version: 1.0 From: Uros Bizjak Date: Thu, 1 Feb 2024 21:27:19 +0100 Message-ID: Subject: [committed] i386: Improve *cmp_doubleword splitter [PR113701] To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789729755957762798 X-GMAIL-MSGID: 1789729755957762798 The fix for PR70321 introduced a splitter that split a doubleword comparison into a pair of XORs followed by an IOR to set the (zero) flags register. To help the reload, splitter forced SUBREG pieces of double-word input values to a pseudo, but this regressed gcc.target/i386/pr82580.c int f0 (U x, U y) { return x == y; } from: xorq %rdx, %rdi xorq %rcx, %rsi xorl %eax, %eax orq %rsi, %rdi sete %al ret to: xchgq %rdi, %rsi movq %rdx, %r8 movq %rcx, %rax movq %rsi, %rdx movq %rdi, %rcx xorq %rax, %rcx xorq %r8, %rdx xorl %eax, %eax orq %rcx, %rdx sete %al ret To mitigate the regression, remove this legacy heuristic (workaround?). There have been many incremental changes and improvements to x86 TImode and register allocation, so this legacy workaround is not only no longer useful, but it actually hurts register allocation. The patched compiler now produces: xchgq %rdi, %rsi xorl %eax, %eax xorq %rsi, %rdx xorq %rdi, %rcx orq %rcx, %rdx sete %al ret PR target/113701 gcc/ChangeLog: * config/i386/i386.md (*cmp_doubleword): Do not force SUBREG pieces to pseudos. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Uros. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index bac0a6ade67..a82f2e456fe 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -1632,10 +1632,6 @@ (define_insn_and_split "*cmp_doubleword" (set (match_dup 4) (ior:DWIH (match_dup 4) (match_dup 5)))])] { split_double_mode (mode, &operands[0], 2, &operands[0], &operands[2]); - /* Placing the SUBREG pieces in pseudos helps reload. */ - for (int i = 0; i < 4; i++) - if (SUBREG_P (operands[i])) - operands[i] = force_reg (mode, operands[i]); operands[4] = gen_reg_rtx (mode);