From patchwork Sat Feb 17 00:39:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 773708 Delivered-To: patch@linaro.org Received: by 2002:a5d:4943:0:b0:33b:4db1:f5b3 with SMTP id r3csp206882wrs; Fri, 16 Feb 2024 16:41:36 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVoG4vfI1D6m95pqAU7t5kYg9buCnJYonvgMArEpdqW5tFPbKF8d+lYYIQgZYryHgXmwSlx+w71cqJ1q/T5ChUg X-Google-Smtp-Source: AGHT+IGrwuhd0F5HHeDcynom73+CQ/JuJDEEXDR5ZbDtMod8GLUpFTXLX+ZK3F0QskxCboBNH6p4 X-Received: by 2002:a05:6808:291:b0:3bd:956a:1aa3 with SMTP id z17-20020a056808029100b003bd956a1aa3mr5650188oic.57.1708130496514; Fri, 16 Feb 2024 16:41:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708130496; cv=none; d=google.com; s=arc-20160816; b=NBKWgES+QYLFaU81rbEOqrJ20wFxu8MRNrnhjnbkOf8nmWy9qZODJxBb+LODkP8n2M 0ImB1MnbmINxHVrptGsggSlS/sA8mW58PJNgNI8GkmPA/q8hFTQw0H7adfRGcyDGYgFT zHfaELTobPptTAf515SLs8ii5beHPmoaDoXQS/c7AGjPTbneC3oXieDb44fbPQIfLGcq vrN6F2Rn7yBvZbFUFpJYzG1NB66y0LvnfFflqo1Vno3Aay+OwMO3MwAdCFr7564yBIE3 ataPGp/JvJi8Z2aLd7YFLgp7p1S67XxWZDezSfq+F8e0xJwMlmTmWYPAzwmq25kKRf6X Pfuw== 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-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=r70v09Z1jYUdUmudZIEve8pIi40latYcxErAtIALfYA=; fh=bXD9UGo7d05OYjVg0qF2wA28p2gxs496M6ftxgeDKVY=; b=Jt2CypKXQthg9hDZ6XQhYRTkXcjAyzjKFdCruD8Dp2vhxUz78LmcD+XJHcYJf5iuGF hTTzD1uVPTiP/qX530PNm2cYHVfwCczJUPEj+nu4DOX65Bj8BcjgraFQZL1/y26Rn9NW RKHiw9EEuM66p2w7RqJpGJMUsXq7TicTtum1GXSXGi1/as6eQSOnbiKOyZyvP/zuVu6N hYMzhOlRtk99FLHTa+zqmKy/q/aFpc6SKLm93uTkwoMBJr+czDQmjzUZs4j/q0etmLFa kuDPKIzgEUmN/Uk+/FMaHfeQVd5aKBXt8oqifMI+wQk7lT39KZyAb1HjcEtWDYzKyQE6 CtvQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XvDDbv4q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m14-20020a05620a220e00b0078734b9c63dsi1094411qkh.657.2024.02.16.16.41.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Feb 2024 16:41:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XvDDbv4q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb8jn-000646-UP; Fri, 16 Feb 2024 19:39:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rb8jm-00063l-B2 for qemu-devel@nongnu.org; Fri, 16 Feb 2024 19:39:26 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rb8jk-0008FB-JP for qemu-devel@nongnu.org; Fri, 16 Feb 2024 19:39:25 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d934c8f8f7so27591215ad.2 for ; Fri, 16 Feb 2024 16:39:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708130362; x=1708735162; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r70v09Z1jYUdUmudZIEve8pIi40latYcxErAtIALfYA=; b=XvDDbv4qQrIQj7MG9zVeMlVChMd0+JgPo9jXjdSOZCgwgMfPWGI7hjpSEsnwE1vtbf Fbs/wU38AJ8HT148xV8fNLiFdS4TC2SSVYP9sI4KxtPnZIfaXWlmj2XEvOXYRUHTHC9M M/r1nEryzHPiFbS6Xen+upVb7Qa4z0jiEeFkyKjFlGKRNW8nyIGtVhjem0Mcbt3DzsJp aDJj0YatcNJOJyNtyo1oj8BwQUpmrMpa+1IWGMrnIrUGkS4vXO9H3m096qC/g71ttrNI 9T+rLhzfQdF5ywtSCi9iSTaqVW0G/DvG/0wK2F97SVktgkV74H9uOrRBBGKoMQjuu78U XhSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708130362; x=1708735162; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r70v09Z1jYUdUmudZIEve8pIi40latYcxErAtIALfYA=; b=ny597UNYM3sAnQerPUNMlw/yx4TTT7/b7BwiEjrSFXgOAVOpuWahNHgTE27jk8k6hM maj62NIVW7f6beONZv99JA4MXGtsr4cWNGNuprf4dlJ3m/NqXc3v3qao0GdV3aMhEUEt iXRiH1fnBDizE9EabxYYTA8cgqjfcIkqbh8FQZw0k5eUnm0YjJwIOizdvDlPLa53a7sH Rc6tjl2kEUgqEhcvOYmRuSQvoOdbLZ/fctu8gUJReA3GF2PKQERMDliWjStaJmSS0lEc dDZGhQKxjcL4pWlb+yEH1Gm0hASk2sZDbmlS0TQ5TCf+dbZO6WCRT5C93x0VFTt9ed0R tyjg== X-Gm-Message-State: AOJu0YyFqv0tXV3xRqrPRJ1ydDM1baryAkHLejmAjvVT/7wLaQROfp35 6oPRlwyqtDmzzVM9gIkJFo2JQBIKWeUufH2j3daDTnlkUbRlvFQxgwZgDU8XC6USoZTlXWQfLtL i X-Received: by 2002:a17:902:e806:b0:1db:c6a0:d023 with SMTP id u6-20020a170902e80600b001dbc6a0d023mr368588plg.8.1708130362643; Fri, 16 Feb 2024 16:39:22 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id z6-20020a170902ee0600b001d90306bdcfsm419325plb.65.2024.02.16.16.39.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 16:39:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: amonakov@ispras.ru, mmromanov@ispras.ru Subject: [PATCH v5 01/10] util/bufferiszero: Remove SSE4.1 variant Date: Fri, 16 Feb 2024 14:39:09 -1000 Message-Id: <20240217003918.52229-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240217003918.52229-1-richard.henderson@linaro.org> References: <20240217003918.52229-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Alexander Monakov The SSE4.1 variant is virtually identical to the SSE2 variant, except for using 'PTEST+JNZ' in place of 'PCMPEQB+PMOVMSKB+CMP+JNE' for testing if an SSE register is all zeroes. The PTEST instruction decodes to two uops, so it can be handled only by the complex decoder, and since CMP+JNE are macro-fused, both sequences decode to three uops. The uops comprising the PTEST instruction dispatch to p0 and p5 on Intel CPUs, so PCMPEQB+PMOVMSKB is comparatively more flexible from dispatch standpoint. Hence, the use of PTEST brings no benefit from throughput standpoint. Its latency is not important, since it feeds only a conditional jump, which terminates the dependency chain. I never observed PTEST variants to be faster on real hardware. Signed-off-by: Alexander Monakov Signed-off-by: Mikhail Romanov Reviewed-by: Richard Henderson Message-Id: <20240206204809.9859-2-amonakov@ispras.ru> --- util/bufferiszero.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/util/bufferiszero.c b/util/bufferiszero.c index 3e6a5dfd63..f5a3634f9a 100644 --- a/util/bufferiszero.c +++ b/util/bufferiszero.c @@ -100,34 +100,6 @@ buffer_zero_sse2(const void *buf, size_t len) } #ifdef CONFIG_AVX2_OPT -static bool __attribute__((target("sse4"))) -buffer_zero_sse4(const void *buf, size_t len) -{ - __m128i t = _mm_loadu_si128(buf); - __m128i *p = (__m128i *)(((uintptr_t)buf + 5 * 16) & -16); - __m128i *e = (__m128i *)(((uintptr_t)buf + len) & -16); - - /* Loop over 16-byte aligned blocks of 64. */ - while (likely(p <= e)) { - __builtin_prefetch(p); - if (unlikely(!_mm_testz_si128(t, t))) { - return false; - } - t = p[-4] | p[-3] | p[-2] | p[-1]; - p += 4; - } - - /* Finish the aligned tail. */ - t |= e[-3]; - t |= e[-2]; - t |= e[-1]; - - /* Finish the unaligned tail. */ - t |= _mm_loadu_si128(buf + len - 16); - - return _mm_testz_si128(t, t); -} - static bool __attribute__((target("avx2"))) buffer_zero_avx2(const void *buf, size_t len) { @@ -221,7 +193,6 @@ select_accel_cpuinfo(unsigned info) #endif #ifdef CONFIG_AVX2_OPT { CPUINFO_AVX2, 128, buffer_zero_avx2 }, - { CPUINFO_SSE4, 64, buffer_zero_sse4 }, #endif { CPUINFO_SSE2, 64, buffer_zero_sse2 }, { CPUINFO_ALWAYS, 0, buffer_zero_int },