From patchwork Tue Sep 27 23:34:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1683638 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) 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=RBLhFUFj; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4McbZz0rxDz1yql for ; Wed, 28 Sep 2022 09:35:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E10F638582AD for ; Tue, 27 Sep 2022 23:35:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E10F638582AD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664321718; bh=1LTGfXimHHvJvhCqcczoThgCjaZrT9dW7IuqfPz9T/4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=RBLhFUFjDL5WrRg5t7b8JIfHCeyEIkON0ewIeRqiMkUJWm5ed+B5Bxj1xlONIRzYI FlW+ODFAAiOxt+DYj+0Dd9OFvzD/asTlLC3hcWK/tDgipBeAqzScJftrogXAiD+oSl z30inUhTDtwvx64+717gfPFCbydL6SK3AyRqr698= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 895643858C2F for ; Tue, 27 Sep 2022 23:34:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 895643858C2F Received: by mail-pl1-x62a.google.com with SMTP id f23so10405519plr.6 for ; Tue, 27 Sep 2022 16:34:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=1LTGfXimHHvJvhCqcczoThgCjaZrT9dW7IuqfPz9T/4=; b=Kl2rKlwEPh+TCSfgqrzsoWHqeUnUJqB334F6Eq6lkHO4uI2mPcJtUfpbDbtSkai+Jp MBXz5gGtdhVa4QHMb9OqzBA3HB8QVrDT7mrbbOewAe8pQyf+UmS7ghT/ewyuRiGnU2BT yGQPdId4rmwUzxoCDNXO6bhkN2fWj87ZBmxWn3QvxZMDjYdKSGAR8g6tHD40IhnAIJtJ 70yq255CEVOrmqQJw13MOPJDN31LeRr6FDH7Oj41koZTh8egW1op/kSucI02urevxyNl ww9etOfGU/4A5/ZFo+zJhysfPH/EOEixHloS8XOcpGyMGCmmuoGm4l5cwyS/4ftOgxd7 nKKw== X-Gm-Message-State: ACrzQf3auhk1+WiwBbtB9vhJTdbh5pR8OARwnQiZbso8Lp5HcEnboexv QLpCxDqVdHWzt/dRrGz0Z8i93v9P9OY= X-Google-Smtp-Source: AMsMyM7oOjaVx/zwAdF7hBHvVQ8Wn+T/9FQzeR40NO8JxkkhVkToBqyeffqY0ohjtTA6pH/7hgEiEw== X-Received: by 2002:a17:90b:3809:b0:202:b482:b7d6 with SMTP id mq9-20020a17090b380900b00202b482b7d6mr6992463pjb.209.1664321696947; Tue, 27 Sep 2022 16:34:56 -0700 (PDT) Received: from gnu-tgl-3.localdomain ([172.56.30.226]) by smtp.gmail.com with ESMTPSA id ik21-20020a170902ab1500b00178ad87714bsm2110172plb.195.2022.09.27.16.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 16:34:56 -0700 (PDT) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 98832C0125; Tue, 27 Sep 2022 16:34:54 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Mark XMM4-XMM6 as clobbered by encodekey128/encodekey256 Date: Tue, 27 Sep 2022 16:34:54 -0700 Message-Id: <20220927233454.144656-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Spam-Status: No, score=-3026.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, 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: "H.J. Lu via Gcc-patches" From: "H.J. Lu" Reply-To: "H.J. Lu" Cc: Hongtao Liu , Hongyu Wang Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" encodekey128 and encodekey256 operations clear XMM4-XMM6. But it is documented that XMM4-XMM6 are reserved for future usages and software should not rely upon them being zeroed. Change encodekey128 and encodekey256 to clobber XMM4-XMM6. gcc/ PR target/107061 * config/i386/predicates.md (encodekey128_operation): Check XMM4-XMM6 as clobbered. (encodekey256_operation): Likewise. * config/i386/sse.md (encodekey128u32): Clobber XMM4-XMM6. (encodekey256u32): Likewise. gcc/testsuite/ PR target/107061 * gcc.target/i386/keylocker-encodekey128.c: Don't check XMM4-XMM6. * gcc.target/i386/keylocker-encodekey256.c: Likewise. --- gcc/config/i386/predicates.md | 20 +++++++++---------- gcc/config/i386/sse.md | 4 ++-- .../gcc.target/i386/keylocker-encodekey128.c | 1 - .../gcc.target/i386/keylocker-encodekey256.c | 1 - 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index 655eabf793b..c4141a96735 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -2107,11 +2107,11 @@ (define_predicate "encodekey128_operation" for(i = 4; i < 7; i++) { elt = XVECEXP (op, 0, i); - if (GET_CODE (elt) != SET - || GET_CODE (SET_DEST (elt)) != REG - || GET_MODE (SET_DEST (elt)) != V2DImode - || REGNO (SET_DEST (elt)) != GET_SSE_REGNO (i) - || SET_SRC (elt) != CONST0_RTX (V2DImode)) + if (GET_CODE (elt) != CLOBBER + || GET_MODE (elt) != VOIDmode + || GET_CODE (XEXP (elt, 0)) != REG + || GET_MODE (XEXP (elt, 0)) != V2DImode + || REGNO (XEXP (elt, 0)) != GET_SSE_REGNO (i)) return false; } @@ -2157,11 +2157,11 @@ (define_predicate "encodekey256_operation" for(i = 4; i < 7; i++) { elt = XVECEXP (op, 0, i + 1); - if (GET_CODE (elt) != SET - || GET_CODE (SET_DEST (elt)) != REG - || GET_MODE (SET_DEST (elt)) != V2DImode - || REGNO (SET_DEST (elt)) != GET_SSE_REGNO (i) - || SET_SRC (elt) != CONST0_RTX (V2DImode)) + if (GET_CODE (elt) != CLOBBER + || GET_MODE (elt) != VOIDmode + || GET_CODE (XEXP (elt, 0)) != REG + || GET_MODE (XEXP (elt, 0)) != V2DImode + || REGNO (XEXP (elt, 0)) != GET_SSE_REGNO (i)) return false; } diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 5c189635124..076064f97e6 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -29015,7 +29015,7 @@ (define_expand "encodekey128u32" for (i = 4; i < 7; i++) XVECEXP (operands[2], 0, i) - = gen_rtx_SET (xmm_regs[i], CONST0_RTX (V2DImode)); + = gen_rtx_CLOBBER (VOIDmode, xmm_regs[i]); XVECEXP (operands[2], 0, 7) = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG)); @@ -29072,7 +29072,7 @@ (define_expand "encodekey256u32" for (i = 4; i < 7; i++) XVECEXP (operands[2], 0, i + 1) - = gen_rtx_SET (xmm_regs[i], CONST0_RTX (V2DImode)); + = gen_rtx_CLOBBER (VOIDmode, xmm_regs[i]); XVECEXP (operands[2], 0, 8) = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG)); diff --git a/gcc/testsuite/gcc.target/i386/keylocker-encodekey128.c b/gcc/testsuite/gcc.target/i386/keylocker-encodekey128.c index 805e0628673..57fa9bdc831 100644 --- a/gcc/testsuite/gcc.target/i386/keylocker-encodekey128.c +++ b/gcc/testsuite/gcc.target/i386/keylocker-encodekey128.c @@ -6,7 +6,6 @@ /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm0,\[^\\n\\r\]*" } } */ /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm1,\[^\\n\\r\]*16\[^\\n\\r\]*" } } */ /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm2,\[^\\n\\r\]*32\[^\\n\\r\]*" } } */ -/* { dg-final { scan-assembler "(?:movdqa|movaps)\[ \\t\]+\[^\\n\]*%xmm\[4-6\],\[^\\n\\r\]*" } } */ #include diff --git a/gcc/testsuite/gcc.target/i386/keylocker-encodekey256.c b/gcc/testsuite/gcc.target/i386/keylocker-encodekey256.c index 26f04dcf014..a9398b4e7a2 100644 --- a/gcc/testsuite/gcc.target/i386/keylocker-encodekey256.c +++ b/gcc/testsuite/gcc.target/i386/keylocker-encodekey256.c @@ -8,7 +8,6 @@ /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm1,\[^\\n\\r\]*16\[^\\n\\r\]*" } } */ /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm2,\[^\\n\\r\]*32\[^\\n\\r\]*" } } */ /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm3,\[^\\n\\r\]*48\[^\\n\\r\]*" } } */ -/* { dg-final { scan-assembler "(?:movdqa|movaps)\[ \\t\]+\[^\\n\]*%xmm\[4-6\],\[^\\n\\r\]*" } } */ #include