From patchwork Sun Sep 8 02:26:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 826442 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp1425061wrb; Sat, 7 Sep 2024 19:28:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVMTgIcfu/BUWxuvSFeZYLuTbA3eNwgORS+psV83OKWlnk2AdaSB9954fLMWFvtKXHKDoEu3A==@linaro.org X-Google-Smtp-Source: AGHT+IEovJdJUGyKkRf5K+Rn1mHnVOxHh0COJ7lBj5oor1n33JaoSMdLWZMpk7JK1T+B6p7SFUHL X-Received: by 2002:a05:6830:44a7:b0:710:b12b:12b3 with SMTP id 46e09a7af769-710d6eda642mr4296604a34.28.1725762491931; Sat, 07 Sep 2024 19:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725762491; cv=none; d=google.com; s=arc-20240605; b=ShxWXtPaib+QtIJWJFD3/XpH22/UUxls7fQV3ac4XAJrhhZr611KwVov2AxBXYhTHS zpTQCk+zKd6qdriOm77DN9WItJFtSpxElqUut+q8EYMxBqsqLL5IbWlO04wOKvvrXjsT lAM/UiO4WN27kLW+NtGOiIhJxS/ZZPmcdfPPBCqoYsxgpUYTajBPYIIOAXl5oDyp8q7O Z+zNwzyz3RMz8+uQ68R1tTXnl6gZ4PQhd5sOKCrVOaHq7VeRouLsVFSKMdxdNuOaKOI4 eM6EdMSktuaEPnsZrvPElGrKSZqP9Jz6x6UldgSWNZCDem0+rZnFmtGX2VdE8Bq11/i8 ttYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=U2j0lMZsRK4bacOx+pZpf0i68zngCZE0Eba4wU07RQs=; fh=ygZYpEcIWhzezS2Faber1kIRniTU78jI+DFuNO+oyiU=; b=g7Tjr3Uypb3r5c0Pn0FNq3THsWPRPioi7Pykzfbe+izGaP/NzxCwyO8WAQg8vJS97U EAjvVK19b5Q23t4FoLK10zJqNlEHzo5KI9VV8dgjV6XoTlASsjTJzK3PyLoLcn9AtY0v A/pLwigQDxdjg2aLNuKG+C1+ELJZHpHA+vYR+jABQu7L8or67k++AevsQQVv1TO4nKiw mI7XW87AtIJVA5t+DXj9a9t7t5dX93RyM69gGGdevpLTLrqAFXtNeCwxRNllqclTzWcE 7E6/g79rXhUe7aLDhAT/qoO6Navq6mVZySYxfkDMDTlqmrpG21jEV7PEAV4pKIkurrxT F3/A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tw9FG8Ej; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6c53476f5e7si23683846d6.294.2024.09.07.19.28.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Sep 2024 19:28:11 -0700 (PDT) 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=Tw9FG8Ej; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sn7dQ-0002tK-6T; Sat, 07 Sep 2024 22:26:40 -0400 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 1sn7dP-0002rU-9M for qemu-devel@nongnu.org; Sat, 07 Sep 2024 22:26:39 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sn7dN-0004yk-Gk for qemu-devel@nongnu.org; Sat, 07 Sep 2024 22:26:39 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-718d704704aso1736871b3a.3 for ; Sat, 07 Sep 2024 19:26:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725762395; x=1726367195; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=U2j0lMZsRK4bacOx+pZpf0i68zngCZE0Eba4wU07RQs=; b=Tw9FG8EjLTa0SG5k28aQBqP9E5LVtZdytAb77859ohRzHVpeC1wI5mq6CAnV/St2vU E6EV7xt5HAL+8Qic95UvIBUJNYmrJ58exYTdIJZNkzLoT5pZQSvwbIXWlV9sYDHalaW0 w5aw7FCrRj5SnhRmMAVlpnoYDuiC8CWXEqf66VJni0pFVSVxb9F7pnieWlmoS4le8Lxe p0MzRoolfi38TdXl+q3u6RQJTxKQekRqh5OqD2S1sScsTOBB+hnYq0fENARxorjOQXpn iGtXHojG893hvi7bCnpBcZDTSGLZsfdtT0f+NCFaG8Y9iVHbRYjsqTDTSrDSJbTa+1s2 Ho9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725762395; x=1726367195; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=U2j0lMZsRK4bacOx+pZpf0i68zngCZE0Eba4wU07RQs=; b=iSnL4xjzPtCxeAgSOwxpfLpVT7xB3J4djpKH2v06vgCyamDJiQ4dE/jkI5F0IMhX6B aUhe5yHZiBlsRELlPJ85HMizUHT9UrfWazxowyyV+t5k6ZzLRWW+tmCC2oqKsPFqfCwo RTJBdyyQVEbjSxoZ3mERsI1xFNP+xkzUQkXgLY/zq/Hhff7czUHtRnjF36K27QlY0jdO Px7y66Qt+Dqni+QmkpWSGle4nhgxHG8D+NzX8gJ9sEkByLl1Yp6K/VktprmgMv4sqfiQ 9x/5fjQOnE6N478ezcWapXP70NiY46PaJOE3VrBd0FlGfs8rM3P2cR5Mg/csP0GsBING fErg== X-Gm-Message-State: AOJu0YxuychNb3zW8w/zhUagcVNjxl3FcjqBYdA9C6wuroan2scB/GFD XMQddoQuLxjRDWqxrh7HLqQzRW6RZwNXGRV33Ajs0YH1+OYoyyPK95rxIUw8vZAwqnUX3fSmEuG L X-Received: by 2002:a05:6a21:398a:b0:1c6:ecee:1850 with SMTP id adf61e73a8af0-1cf2a0fb354mr5000725637.49.1725762394766; Sat, 07 Sep 2024 19:26:34 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadbfe46d4sm4084019a91.1.2024.09.07.19.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Sep 2024 19:26:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: zhiwei_liu@linux.alibaba.com, tangtiancheng.ttc@alibaba-inc.com, liwei1518@gmail.com, bmeng.cn@gmail.com Subject: [PATCH 00/12] tcg: Improve support for cmpsel_vec Date: Sat, 7 Sep 2024 19:26:20 -0700 Message-ID: <20240908022632.459477-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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 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 The patches to optimize cmp_vec and cmpsel_vec -- particularly canonicalizing immediate operands -- are directed toward helping the in flight tcg/riscv vector backend. In order for that to happen, the tcg/i386 backend must be changed so that it does not rely upon choices that it made during early expansion, before optimization changes things. While I was looking at the issues i386 was attempting to solve during early expansion, I realized that avx512 does not have the same issues. Expansion of vector cmp and cmpsel become trivial. I think I've split the difference nicely, so that avx1 still works. Also, the avx512 predication example should be a nice model for riscv and some future aarch64 sve vectorization. r~ Richard Henderson (11): tcg: Export vec_gen_6 tcg/i386: Split out tcg_out_vex_modrm_type tcg/i386: Do not expand cmp_vec early tcg/i386: Do not expand cmpsel_vec early tcg/optimize: Fold movcond with true and false values identical tcg/optimize: Optimize cmp_vec and cmpsel_vec tcg/optimize: Optimize bitsel_vec tcg/i386: Optimize cmpsel with constant 0 arguments tcg/i386: Implement cmp_vec with avx512 insns tcg/i386: Add predicate parameters to tcg_out_evex_opc tcg/i386: Implement cmpsel_vec with avx512 insns TANG Tiancheng (1): tcg: Fix iteration step in 32-bit gvec operation tcg/i386/tcg-target-con-set.h | 1 + tcg/i386/tcg-target-con-str.h | 1 + tcg/i386/tcg-target.h | 2 +- tcg/i386/tcg-target.opc.h | 1 - tcg/tcg-internal.h | 2 + tcg/optimize.c | 99 +++++++ tcg/tcg-op-gvec.c | 2 +- tcg/tcg-op-vec.c | 4 +- tcg/i386/tcg-target.c.inc | 469 +++++++++++++++++++++------------- 9 files changed, 400 insertions(+), 181 deletions(-)