From patchwork Thu Aug 24 20:26:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1825664 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=mbw0O7nM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RWvky5p8tz1yZs for ; Fri, 25 Aug 2023 06:27:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D06593858410 for ; Thu, 24 Aug 2023 20:27:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D06593858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692908821; bh=TKpAqQvPEw55sMqMQe/RG/x+998oKA5SVqxj3Y7o91U=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=mbw0O7nMyfpeommGlbwVlDkCqnzGgjkklDACfOv0PPC/8Onkkbeem9saoTeP+gbai ZP77ZLtYGTlgFl0oS5WF/zcefuAmM1WsHE3jkWlP/jQ0ymdcczbugnE0J53geCFW1m UAwtKwvAWEwk/14lhng7JAKE11G8wvx+WF19YJg8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 88F533858C53 for ; Thu, 24 Aug 2023 20:26:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 88F533858C53 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-52683da3f5cso390829a12.3 for ; Thu, 24 Aug 2023 13:26:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692908800; x=1693513600; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=TKpAqQvPEw55sMqMQe/RG/x+998oKA5SVqxj3Y7o91U=; b=dvV8rUxpoVwP1BkPj+hUA+Ye1k7BhsTnvjV2FN8g5jdFn8njErz41jRRX/0umfilme b13fe/IOVlixe+2DDguKFSFoi0z1Fb1oBvzF+zXdpBxWWioUWE+/NSM11zwmleWwNpwa Uf09k1/lpWpDqkHRwaqXvyFYViCDmngxSFBuvRxgHL74n3Q0Gqhy3dV+/ib3xDEdhNCa JyxvRb1a0Z4nYs+6iBcEJ5FbOpmGtKWR8nrNKuitdTRxuhm7YPXZYLxxMsABClRpn0DT BA49IVjY7tc4CbQ5itH8lkwD0jnqqHHdTfWUIM0UWyEJBk549LMKu6ANt0ZHsN3oMOnz dO2w== X-Gm-Message-State: AOJu0YwWsFp/08i5Gg28c+JHIsM/F5qUqRvJAvzVjA5pVlsaw4X0adnk RSSXyuvghzJqpuN9tD9lek87EIDXFBpBOB8Na3F+75lr66t5GQ== X-Google-Smtp-Source: AGHT+IGz37fZ15lZWGHR6lIFNlUNYXJSGmFauOfOO7BhJZiVOuc4h0FnoFzCIP2xgXEdgAKN4myLeV/bG2tyDtdT+zY= X-Received: by 2002:a50:fa83:0:b0:525:7da7:af10 with SMTP id w3-20020a50fa83000000b005257da7af10mr13148680edr.23.1692908799804; Thu, 24 Aug 2023 13:26:39 -0700 (PDT) MIME-Version: 1.0 Date: Thu, 24 Aug 2023 22:26:28 +0200 Message-ID: Subject: [committed] i386: Optimize pinsrq of 0 with index 1 into movq [PR94866] To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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-Patchwork-Original-From: Uros Bizjak via Gcc-patches From: Uros Bizjak Reply-To: Uros Bizjak Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Add new pattern involving vec_merge RTX that is produced by combine from the combination of sse4_1_pinsrq and *movdi_internal: 7: r86:DI=0 8: r85:V2DI=vec_merge(vec_duplicate(r86:DI),r87:V2DI,0x2) REG_DEAD r87:V2DI REG_DEAD r86:DI Successfully matched this instruction: (set (reg:V2DI 85 [ a ]) (vec_merge:V2DI (reg:V2DI 87) (const_vector:V2DI [ (const_int 0 [0]) repeated x2 ]) (const_int 1 [0x1]))) PR target/94866 gcc/ChangeLog: * config/i386/sse.md (*sse2_movq128__1): New insn pattern. gcc/testsuite/ChangeLog: * g++.target/i386/pr94866.C: New test. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Uros. diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index da85223a9b4..52104f8d1c9 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -1770,6 +1770,18 @@ (define_insn "*sse2_movq128_" (set_attr "prefix" "maybe_vex") (set_attr "mode" "TI")]) +(define_insn "*sse2_movq128__1" + [(set (match_operand:VI8F_128 0 "register_operand" "=v") + (vec_merge:VI8F_128 + (match_operand:VI8F_128 1 "nonimmediate_operand" "vm") + (match_operand:VI8F_128 2 "const0_operand") + (const_int 1)))] + "TARGET_SSE2" + "%vmovq\t{%1, %0|%0, %q1}" + [(set_attr "type" "ssemov") + (set_attr "prefix" "maybe_vex") + (set_attr "mode" "TI")]) + ;; Move a DI from a 32-bit register pair (e.g. %edx:%eax) to an xmm. ;; We'd rather avoid this entirely; if the 32-bit reg pair was loaded ;; from memory, we'd prefer to load the memory directly into the %xmm diff --git a/gcc/testsuite/g++.target/i386/pr94866.C b/gcc/testsuite/g++.target/i386/pr94866.C new file mode 100644 index 00000000000..eb0f5ef11c5 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/pr94866.C @@ -0,0 +1,13 @@ +// PR target/94866 +// { dg-do compile } +// { dg-options "-O2 -msse4.1" } +// { dg-require-effective-target c++11 } + +typedef long long v2di __attribute__((vector_size(16))); + +v2di _mm_move_epi64(v2di a) +{ + return v2di{a[0], 0LL}; +} + +// { dg-final { scan-assembler-times "movq\[ \\t\]+\[^\n\]*%xmm" 1 } }