From patchwork Sun Sep 27 13:21:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1372065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: 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=fvZPEZa0; dkim-atps=neutral Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BzmXP2FkQz9s0b for ; Sun, 27 Sep 2020 23:22:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 89CFB38708A0; Sun, 27 Sep 2020 13:22:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89CFB38708A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1601212927; bh=isQC8voDXXFeqdoREPMo1eHxzYWwnmVsePWbULAs2FA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fvZPEZa0+6ra0YZ+1riwWSN9plrBPi8p94MrbKZ0ISdYiiSzsNHXK48a5CoBAE6AW E5ZmtNwMZZVLAKtjyi6QDGagylpRRez9qb/MqfRrI6NzfRWG3uEjnHfxQ5C6cjmrAQ qPBRZ8zSdhyyGcwtcNUDf0GXsz71tqpsP9EZ3leo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by sourceware.org (Postfix) with ESMTPS id 6A8CA3870874 for ; Sun, 27 Sep 2020 13:22:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6A8CA3870874 Received: by mail-pl1-x643.google.com with SMTP id c3so1934846plz.5 for ; Sun, 27 Sep 2020 06:22:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=isQC8voDXXFeqdoREPMo1eHxzYWwnmVsePWbULAs2FA=; b=qagPnAsgtBLR1sGAzZPeQ9nUQE0Q4w+mDA1qSdF/NdsU9oT+Yq5743MgWN6z1r0sAc lJllhOdtbL25vXgWU1GDJohhFjPXuEyrDURoCk8yDqXPG5dSU8Xqs4lpDCX3uXdgsK8P MCl8CSfXsmY9rTi/hEUj08TMnhtdipsufGfL8ZejTH6pqoes1Ng2zHMUU8LG+pYxNIpQ loFQ6p2Ss3Z9wmR5fqbngRcyoed+qnvbhiIQGBrCJzOa4WBfFSebZMHZIT7qP5/SHm6b j1hRD1vFIyAfmf19rDWdsTozIuFd38YKsHHKsxJA99aGtvM76UEb966Jajn+ECXk0YpN Cy9A== X-Gm-Message-State: AOAM532eMZ51neyFDPmSbJJcvn2FOYTj87iP8nckTvAZmov0fvTJPY3f q08DNiYykzJC0xwbseJdQ+ddxK+nhM0= X-Google-Smtp-Source: ABdhPJzZCiC5jE3+OlKcHxXhC1l+rMVZ6XIUZJciLjYDTbf7wMHKqn1Q3y2FMM93cPAysAg4peOWJg== X-Received: by 2002:a17:90a:e38a:: with SMTP id b10mr5396803pjz.17.1601212923092; Sun, 27 Sep 2020 06:22:03 -0700 (PDT) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id i1sm8222913pfk.21.2020.09.27.06.22.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 06:22:02 -0700 (PDT) Received: from gnu-cfl-2.localdomain (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id AECEF1A0177 for ; Sun, 27 Sep 2020 06:22:00 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] x86: Use SET operation in MOVDIRI and MOVDIR64B Date: Sun, 27 Sep 2020 06:21:59 -0700 Message-Id: <20200927132159.36304-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Spam-Status: No, score=-3041.0 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: "H.J. Lu via Gcc-patches" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Since MOVDIRI and MOVDIR64B write to memory, similar to UNSPEC_MOVNT, use SET operation in MOVDIRI and MOVDIR64B patterns with UNSPEC instead of UNSPECV. gcc/ PR target/97184 * config/i386/i386.md (UNSPECV_MOVDIRI): Renamed to ... (UNSPEC_MOVDIRI): This. (UNSPECV_MOVDIR64B): Renamed to ... (UNSPEC_MOVDIR64B): This. (movdiri): Use SET operation. (@movdir64b_): Likewise. gcc/testsuite/ PR target/97184 * gcc.target/i386/movdir64b.c: New test. * gcc.target/i386/movdiri32.c: Likewise. * gcc.target/i386/movdiri64.c: Likewise. * testsuite/lib/target-supports.exp (check_effective_target_movdir): New. --- gcc/config/i386/i386.md | 20 ++++++++++---------- gcc/testsuite/gcc.target/i386/movdir64b.c | 23 +++++++++++++++++++++++ gcc/testsuite/gcc.target/i386/movdiri32.c | 20 ++++++++++++++++++++ gcc/testsuite/gcc.target/i386/movdiri64.c | 20 ++++++++++++++++++++ gcc/testsuite/lib/target-supports.exp | 17 +++++++++++++++++ 5 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/movdir64b.c create mode 100644 gcc/testsuite/gcc.target/i386/movdiri32.c create mode 100644 gcc/testsuite/gcc.target/i386/movdiri64.c diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 93aae8123fd..9dd12cf8643 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -186,6 +186,10 @@ (define_c_enum "unspec" [ ;; IRET support UNSPEC_INTERRUPT_RETURN + + ;; For MOVDIRI and MOVDIR64B support + UNSPEC_MOVDIRI + UNSPEC_MOVDIR64B ]) (define_c_enum "unspecv" [ @@ -280,10 +284,6 @@ (define_c_enum "unspecv" [ UNSPECV_SETSSBSY UNSPECV_CLRSSBSY - ;; For MOVDIRI and MOVDIR64B support - UNSPECV_MOVDIRI - UNSPECV_MOVDIR64B - ;; For TSXLDTRK support UNSPECV_XSUSLDTRK UNSPECV_XRESLDTRK @@ -21531,17 +21531,17 @@ (define_insn "wbnoinvd" ;; MOVDIRI and MOVDIR64B (define_insn "movdiri" - [(unspec_volatile:SWI48 [(match_operand:SWI48 0 "memory_operand" "m") - (match_operand:SWI48 1 "register_operand" "r")] - UNSPECV_MOVDIRI)] + [(set (match_operand:SWI48 0 "memory_operand" "=m") + (unspec:SWI48 [(match_operand:SWI48 1 "register_operand" "r")] + UNSPEC_MOVDIRI))] "TARGET_MOVDIRI" "movdiri\t{%1, %0|%0, %1}" [(set_attr "type" "other")]) (define_insn "@movdir64b_" - [(unspec_volatile:XI [(match_operand:P 0 "register_operand" "r") - (match_operand:XI 1 "memory_operand")] - UNSPECV_MOVDIR64B)] + [(set (mem:XI (match_operand:P 0 "register_operand" "r")) + (unspec:XI [(match_operand:XI 1 "memory_operand" "m")] + UNSPEC_MOVDIR64B))] "TARGET_MOVDIR64B" "movdir64b\t{%1, %0|%0, %1}" [(set_attr "type" "other")]) diff --git a/gcc/testsuite/gcc.target/i386/movdir64b.c b/gcc/testsuite/gcc.target/i386/movdir64b.c new file mode 100644 index 00000000000..70d872ec5d5 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/movdir64b.c @@ -0,0 +1,23 @@ +/* { dg-do run { target movdir } } */ +/* { dg-options "-mmovdir64b -O2" } */ + +#include +#include + +unsigned long long int src[8] = {1, 2, 3, 4, 5, 6, 7, 8}; +unsigned long long int dest[8] __attribute__ ((aligned (64))) + = {-1, -1, -1, -1, -1, -1, -1, -1}; + +int +main () +{ + if (!__builtin_cpu_supports ("movdir64b")) + return 0; + + _movdir64b (dest, src); + + if (memcmp (dest, src, sizeof (dest)) != 0) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/movdiri32.c b/gcc/testsuite/gcc.target/i386/movdiri32.c new file mode 100644 index 00000000000..604fa0dd9e9 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/movdiri32.c @@ -0,0 +1,20 @@ +/* { dg-do run { target movdir } } */ +/* { dg-options "-mmovdiri -O2" } */ + +#include + +unsigned int dest = -1; + +int +main () +{ + if (!__builtin_cpu_supports ("movdiri")) + return 0; + + _directstoreu_u32 (&dest, 0xbadbeef); + + if (dest != 0xbadbeef) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/movdiri64.c b/gcc/testsuite/gcc.target/i386/movdiri64.c new file mode 100644 index 00000000000..551b98e8d08 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/movdiri64.c @@ -0,0 +1,20 @@ +/* { dg-do run { target { movdir && { ! ia32 } } } } */ +/* { dg-options "-mmovdiri -O2" } */ + +#include + +unsigned long long int dest = -1LL; + +int +main () +{ + if (!__builtin_cpu_supports ("movdiri")) + return 0; + + _directstoreu_u64 (&dest, 0x12345678badbeef); + + if (dest != 0x12345678badbeef) + abort (); + + return 0; +} diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 0a00972edb5..2ccb4e61bc9 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -10519,3 +10519,20 @@ proc check_effective_target_ident_directive {} { int i; }] } + +# Return 1 if we're able to assemble movdiri and movdir64b + +proc check_effective_target_movdir { } { + return [check_no_compiler_messages movdir object { + void + foo (unsigned int *d, unsigned int s) + { + __builtin_ia32_directstoreu_u32 (d, s); + } + void + bar (void *d, const void *s) + { + __builtin_ia32_movdir64b (d, s); + } + } "-mmovdiri -mmovdir64b" ] +}